--- python2.7-2.7.5.orig/debian/mkbinfmt.py +++ python2.7-2.7.5/debian/mkbinfmt.py @@ -0,0 +1,17 @@ +# mkbinfmt.py +import imp, sys, string, os.path + +magic = string.join(["\\x%.2x" % ord(c) for c in imp.get_magic()],"") + +name = sys.argv[1] + +binfmt = '''\ +package %s +interpreter /usr/bin/%s +magic %s\ +''' % (name, name, magic) + +#filename = '/usr/share/binfmts/' + name +#open(filename,'w+').write(binfmt) + +print binfmt --- python2.7-2.7.5.orig/debian/_sysconfigdata.py +++ python2.7-2.7.5/debian/_sysconfigdata.py @@ -0,0 +1,6 @@ +import sys + +if hasattr(sys, 'gettotalrefcount'): + from _sysconfigdata_d import * +else: + from _sysconfigdata_nd import * --- python2.7-2.7.5.orig/debian/control +++ python2.7-2.7.5/debian/control @@ -0,0 +1,213 @@ +Source: python2.7 +Section: python +Priority: optional +Maintainer: Ubuntu Core Developers +XSBC-Original-Maintainer: Matthias Klose +Build-Depends: debhelper (>= 5), quilt, autoconf, lsb-release, sharutils, + libreadline-dev, libtinfo-dev, libncursesw5-dev (>= 5.3), + tk8.5-dev, blt-dev (>= 2.4z), libssl-dev, + zlib1g-dev, libbz2-dev, + libexpat1-dev, + libbluetooth-dev [linux-any], + locales [!armel !avr32 !hppa !ia64 !mipsel], + libsqlite3-dev, libffi-dev (>= 3.0.5), + libgpm2 [linux-any], + mime-support, netbase, bzip2, + libdb5.1-dev, libgdbm-dev, python:any, help2man, + gcc (>= 4:4.8) [amd64 armel armhf i386 x32 kfreebsd-any hurd-any], + xvfb, xauth +Build-Depends-Indep: python-sphinx +Build-Conflicts: tcl8.4-dev, tk8.4-dev, python2.7-xml, python-xml, autoconf2.13, python-cxx-dev +Standards-Version: 3.9.4 +Vcs-Browser: https://code.launchpad.net/~doko/python/pkg2.7-debian +Vcs-Bzr: http://bazaar.launchpad.net/~doko/python/pkg2.7-debian +XS-Testsuite: autopkgtest + +Package: python2.7 +Architecture: any +Multi-Arch: allowed +Priority: standard +Depends: python2.7-minimal (= ${binary:Version}), libpython2.7-stdlib (= ${binary:Version}), mime-support, ${shlibs:Depends}, ${misc:Depends} +Suggests: python2.7-doc, binutils +Conflicts: python-profiler (<= 2.7.1-2) +Breaks: python-virtualenv (<< 1.7.1.2-2~), vim-nox (<< 2:7.3.547-4), vim-gtk (<< 2:7.3.547-4), vim-gnome (<< 2:7.3.547-4), vim-athena (<< 2:7.3.547-4) +Replaces: python-profiler (<= 2.7.1-2), python2.7-minimal (<< 2.7.3-7~) +Description: Interactive high-level object-oriented language (version 2.7) + Python is a high-level, interactive, object-oriented language. Its 2.7 version + includes an extensive class library with lots of goodies for + network programming, system administration, sounds and graphics. + +Package: libpython2.7-stdlib +Architecture: any +Multi-Arch: same +Priority: standard +Depends: libpython2.7-minimal (= ${binary:Version}), mime-support, ${shlibs:Depends}, ${misc:Depends} +Provides: python2.7-cjkcodecs, python2.7-ctypes, python2.7-elementtree, python2.7-celementtree, python2.7-wsgiref, python2.7-profiler, python2.7-argparse, python-argparse +Replaces: python2.7 (<< 2.7.5-0~) +Description: Interactive high-level object-oriented language (standard library, version 2.7) + Python is a high-level, interactive, object-oriented language. Its 2.7 version + includes an extensive class library with lots of goodies for + network programming, system administration, sounds and graphics. + . + This package contains Python 2.7's standard library. It is normally not + used on its own, but as a dependency of python2.7. + +Package: python2.7-minimal +Architecture: any +Multi-Arch: allowed +Priority: required +Pre-Depends: ${shlibs:Pre-Depends} +Depends: libpython2.7-minimal (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Recommends: python2.7 +Suggests: binfmt-support +Replaces: python2.7 (<< 2.7.1~rc1-2~) +Conflicts: binfmt-support (<< 1.1.2) +Description: Minimal subset of the Python language (version 2.7) + This package contains the interpreter and some essential modules. It can + be used in the boot process for some basic tasks. + See /usr/share/doc/python2.7-minimal/README.Debian for a list of the modules + contained in this package. + +Package: libpython2.7-minimal +Architecture: any +Multi-Arch: same +Priority: required +Depends: ${shlibs:Depends}, ${misc:Depends} +Recommends: libpython2.7-stdlib +Replaces: python2.7 (<< 2.7.4-2), python2.7-minimal (<< 2.7.3-10), libpython2.7-stdlib (<< 2.7.4-2) +Breaks: python2.7-minimal (<< 2.7.4~rc1-1~) +Conflicts: binfmt-support (<< 1.1.2) +Description: Minimal subset of the Python language (version 2.7) + This package contains some essential modules. It is normally not + used on it's own, but as a dependency of python2.7-minimal. + +Package: libpython2.7 +Architecture: any +Multi-Arch: same +Section: libs +Priority: standard +Pre-Depends: multiarch-support +Depends: libpython2.7-stdlib (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Replaces: python2.7 (<< 2.6) +Description: Shared Python runtime library (version 2.7) + Python is a high-level, interactive, object-oriented language. Its 2.7 version + includes an extensive class library with lots of goodies for + network programming, system administration, sounds and graphics. + . + This package contains the shared runtime library, normally not needed + for programs using the statically linked interpreter. + +Package: python2.7-examples +Architecture: all +Depends: python2.7 (>= ${source:Version}), ${misc:Depends} +Description: Examples for the Python language (v2.7) + Examples, Demos and Tools for Python (v2.7). These are files included in + the upstream Python distribution (v2.7). + +Package: python2.7-dev +Architecture: any +Multi-Arch: allowed +Depends: python2.7 (= ${binary:Version}), libpython2.7-dev (= ${binary:Version}), libpython2.7 (= ${binary:Version}), libexpat1-dev, ${shlibs:Depends}, ${misc:Depends} +Recommends: libc6-dev | libc-dev +Replaces: python2.7 (<< 2.7-3) +Description: Header files and a static library for Python (v2.7) + Header files, a static library and development tools for building + Python (v2.7) modules, extending the Python interpreter or embedding + Python (v2.7) in applications. + . + Maintainers of Python packages should read README.maintainers. + +Package: libpython2.7-dev +Section: libdevel +Architecture: any +Multi-Arch: same +Pre-Depends: multiarch-support +Depends: libpython2.7-stdlib (= ${binary:Version}), libpython2.7 (= ${binary:Version}), libexpat1-dev, ${shlibs:Depends}, ${misc:Depends} +Replaces: python2.7 (<< 2.7-3), python2.7-dev (<< 2.7.3-10), python2.7-minimal (<< 2.7.3-10) +Recommends: libc6-dev | libc-dev +Description: Header files and a static library for Python (v2.7) + Header files, a static library and development tools for building + Python (v2.7) modules, extending the Python interpreter or embedding + Python (v2.7) in applications. + . + Maintainers of Python packages should read README.maintainers. + . + This package contains development files. It is normally not + used on it's own, but as a dependency of python2.7-dev. + +Package: libpython2.7-testsuite +Section: libdevel +Architecture: all +Depends: libpython2.7-stdlib (>= ${binary:Version}), ${misc:Depends} +Suggests: python-gdbm, python-tk +Description: Testsuite for the Python standard library (v2.7) + The complete testsuite for the Python standard library. Note that + a subset is found in the libpython2.7-stdlib package, which should + be enough for other packages to use (please do not build-depend + on this package, but file a bug report to include additional + testsuite files in the libpython2.7-stdlib package). + +Package: idle-python2.7 +Architecture: all +Depends: python2.7, python-tk (>= 2.6~a3), python2.7-tk, ${misc:Depends} +Enhances: python2.7 +Replaces: python2.7 (<< 2.6.1-2) +Description: IDE for Python (v2.7) using Tkinter + IDLE is an Integrated Development Environment for Python (v2.7). + IDLE is written using Tkinter and therefore quite platform-independent. + +Package: python2.7-doc +Section: doc +Architecture: all +Depends: libjs-jquery, ${misc:Depends} +Suggests: python2.7 +Description: Documentation for the high-level object-oriented language Python (v2.7) + These is the official set of documentation for the interactive high-level + object-oriented language Python (v2.7). All documents are provided + in HTML format. The package consists of ten documents: + . + * What's New in Python2.7 + * Tutorial + * Python Library Reference + * Macintosh Module Reference + * Python Language Reference + * Extending and Embedding Python + * Python/C API Reference + * Installing Python Modules + * Documenting Python + * Distributing Python Modules + +Package: python2.7-dbg +Section: debug +Architecture: any +Multi-Arch: allowed +Priority: extra +Depends: python2.7 (= ${binary:Version}), libpython2.7-dbg (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Suggests: python-gdbm-dbg, python-tk-dbg +Description: Debug Build of the Python Interpreter (version 2.7) + The package holds two things: + . + - A Python interpreter configured with --pydebug. Dynamically loaded modules + are searched as _d.so first. Third party extensions need a separate + build to be used by this interpreter. + - Debug information for standard python interpreter and extensions. + . + See the README.debug for more information. + +Package: libpython2.7-dbg +Section: debug +Architecture: any +Multi-Arch: same +Priority: extra +Pre-Depends: multiarch-support +Depends: libpython2.7-stdlib (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}, python +Suggests: python2.7-gdbm-dbg, python2.7-tk-dbg +Replaces: python2.7-dbg (<< 2.7.3-10) +Description: Debug Build of the Python Interpreter (version 2.7) + The package holds two things: + . + - Extensions for a Python interpreter configured with --pydebug. + - Debug information for standard python extensions. + . + See the README.debug for more information. + --- python2.7-2.7.5.orig/debian/python-config.1 +++ python2.7-2.7.5/debian/python-config.1 @@ -0,0 +1,102 @@ +.TH PYTHON\-CONFIG 1 "November 27, 2011" +.SH NAME +python\-config \- output build options for python C/C++ extensions or embedding +.SH SYNOPSIS +.BI "python\-config" +[ +.BI "\-\-prefix" +] +[ +.BI "\-\-exec\-prefix" +] +[ +.BI "\-\-includes" +] +[ +.BI "\-\-libs" +] +[ +.BI "\-\-cflags" +] +[ +.BI "\-\-ldflags" +] +[ +.BI "\-\-extension\-suffix" +] +[ +.BI "\-\-configdir" +] +[ +.BI "\-\-help" +] +.SH DESCRIPTION +.B python\-config +helps compiling and linking programs, which embed the Python interpreter, or +extension modules that can be loaded dynamically (at run time) into +the interpreter. +.SH OPTIONS +.TP +.BI "\-\-cflags" +print the C compiler flags. +.TP +.BI "\-\-ldflags" +print the flags that should be passed to the linker. +.TP +.BI "\-\-includes" +similar to \fI\-\-cflags\fP but only with \-I options (path to python header files). +.TP +.BI "\-\-libs" +similar to \fI\-\-ldflags\fP but only with \-l options (used libraries). +.TP +.BI "\-\-prefix" +prints the prefix (base directory) under which python can be found. +.TP +.BI "\-\-exec\-prefix" +print the prefix used for executable program directories (such as bin, sbin, etc). +.TP +.BI "\-\-extension\-suffix" +print suffix used for extension modules (including the _d modified for debug builds). +.TP +.BI "\-\-configdir" +prints the path to the configuration directory under which the Makefile, etc. can be found). +.TP +.BI "\-\-help" +print the usage message. +.PP + +.SH EXAMPLES +To build the singe\-file c program \fIprog\fP against the python library, use +.PP +.RS +gcc $(python\-config \-\-cflags \-\-ldflags) progr.cpp \-o progr.cpp +.RE +.PP +The same in a makefile: +.PP +.RS +CFLAGS+=$(shell python\-config \-\-cflags) +.RE +.RS +LDFLAGS+=$(shell python\-config \-\-ldflags) +.RE +.RS +all: progr +.RE + +To build a dynamically loadable python module, use +.PP +.RS +gcc $(python\-config \-\-cflags \-\-ldflags) \-shared \-fPIC progr.cpp \-o progr.so +.RE + +.SH "SEE ALSO" +python (1) +.br +http://docs.python.org/extending/extending.html +.br +/usr/share/doc/python/faq/extending.html + +.SH AUTHORS +This manual page was written by Johann Felix Soden +for the Debian project (and may be used by others). --- python2.7-2.7.5.orig/debian/pyhtml2devhelp.py +++ python2.7-2.7.5/debian/pyhtml2devhelp.py @@ -0,0 +1,222 @@ +#! /usr/bin/python + +import formatter, htmllib +import os, sys, re + +class PyHTMLParser(htmllib.HTMLParser): + pages_to_include = set(('whatsnew/index.html', 'tutorial/index.html', 'using/index.html', + 'reference/index.html', 'library/index.html', 'howto/index.html', + 'extending/index.html', 'c-api/index.html', 'install/index.html', + 'distutils/index.html')) + + def __init__(self, formatter, basedir, fn, indent, parents=set()): + htmllib.HTMLParser.__init__(self, formatter) + self.basedir = basedir + self.dir, self.fn = os.path.split(fn) + self.data = '' + self.parents = parents + self.link = {} + self.indent = indent + self.last_indent = indent - 1 + self.sub_indent = 0 + self.sub_count = 0 + self.next_link = False + + def process_link(self): + new_href = os.path.join(self.dir, self.link['href']) + text = self.link['text'] + indent = self.indent + self.sub_indent + if self.last_indent == indent: + print '%s' % (' ' * self.last_indent) + self.sub_count -= 1 + print '%s' % (' ' * indent, new_href, text) + self.sub_count += 1 + self.last_indent = self.indent + self.sub_indent + + def start_li(self, attrs): + self.sub_indent += 1 + self.next_link = True + + def end_li(self): + indent = self.indent + self.sub_indent + if self.sub_count > 0: + print '%s' % (' ' * self.last_indent) + self.sub_count -= 1 + self.last_indent -= 1 + self.sub_indent -= 1 + + def start_a(self, attrs): + self.link = {} + for attr in attrs: + self.link[attr[0]] = attr[1] + self.data = '' + + def end_a(self): + process = False + text = self.data.replace('\t', '').replace('\n', ' ').replace('&', '&').replace('<', '<').replace('>', '>') + self.link['text'] = text + # handle a tag without href attribute + try: + href = self.link['href'] + except KeyError: + return + + abs_href = os.path.join(self.basedir, href) + if abs_href in self.parents: + return + if href.startswith('..') or href.startswith('http:') \ + or href.startswith('mailto:') or href.startswith('news:'): + return + if href in ('', 'about.html', 'modindex.html', 'genindex.html', 'glossary.html', + 'search.html', 'contents.html', 'download.html', 'bugs.html', + 'license.html', 'copyright.html'): + return + + if self.link.has_key('class'): + if self.link['class'] in ('biglink'): + process = True + if self.link['class'] in ('reference external'): + if self.next_link: + process = True + next_link = False + + if process == True: + self.process_link() + if href in self.pages_to_include: + self.parse_file(os.path.join(self.dir, href)) + + def finish(self): + if self.sub_count > 0: + print '%s' % (' ' * self.last_indent) + + def handle_data(self, data): + self.data += data + + def parse_file(self, href): + # TODO basedir bestimmen + parent = os.path.join(self.basedir, self.fn) + self.parents.add(parent) + parser = PyHTMLParser(formatter.NullFormatter(), + self.basedir, href, self.indent + 1, + self.parents) + text = file(self.basedir + '/' + href).read() + parser.feed(text) + parser.finish() + parser.close() + if parent in self.parents: + self.parents.remove(parent) + +class PyIdxHTMLParser(htmllib.HTMLParser): + def __init__(self, formatter, basedir, fn, indent): + htmllib.HTMLParser.__init__(self, formatter) + self.basedir = basedir + self.dir, self.fn = os.path.split(fn) + self.data = '' + self.link = {} + self.indent = indent + self.active = False + self.indented = False + self.nolink = False + self.header = '' + self.last_letter = 'Z' + self.last_text = '' + + def process_link(self): + new_href = os.path.join(self.dir, self.link['href']) + text = self.link['text'] + if not self.active: + return + if text.startswith('['): + return + if self.link.get('rel', None) in ('prev', 'parent', 'next', 'contents', 'index'): + return + if self.indented: + text = self.last_text + ' ' + text + else: + # Save it in case we need it again + self.last_text = re.sub(' \([\w\-\.\s]+\)', '', text) + indent = self.indent + print '%s' % (' ' * indent, new_href, text) + + def start_dl(self, attrs): + if self.last_text: + # Looks like we found the second part to a command + self.indented = True + + def end_dl(self): + self.indented = False + + def start_dt(self, attrs): + self.data = '' + self.nolink = True + + def end_dt(self): + if not self.active: + return + if self.nolink == True: + # Looks like we found the first part to a command + self.last_text = re.sub(' \([\w\-\.\s]+\)', '', self.data) + self.nolink = False + + def start_h2(self, attrs): + for k, v in attrs: + if k == 'id': + self.header = v + if v == '_': + self.active = True + + def start_td(self, attrs): + self.indented = False + self.last_text = '' + + def start_table(self, attrs): + pass + + def end_table(self): + if self.header == self.last_letter: + self.active = False + + def start_a(self, attrs): + self.nolink = False + self.link = {} + for attr in attrs: + self.link[attr[0]] = attr[1] + self.data = '' + + def end_a(self): + text = self.data.replace('\t', '').replace('\n', ' ').replace('&', '&').replace('<', '<').replace('>', '>') + self.link['text'] = text + # handle a tag without href attribute + try: + href = self.link['href'] + except KeyError: + return + self.process_link() + + def handle_data(self, data): + self.data += data + +def main(): + base = sys.argv[1] + fn = sys.argv[2] + version = sys.argv[3] + + parser = PyHTMLParser(formatter.NullFormatter(), base, fn, indent=0) + print '' + print '' % (version, version) + print '' + parser.parse_file(fn) + print '' + + print '' + + fn = 'genindex-all.html' + parser = PyIdxHTMLParser(formatter.NullFormatter(), base, fn, indent=1) + text = file(base + '/' + fn).read() + parser.feed(text) + parser.close() + + print '' + print '' + +main() --- python2.7-2.7.5.orig/debian/README.Debian.in +++ python2.7-2.7.5/debian/README.Debian.in @@ -0,0 +1,8 @@ +The documentation for this package is in /usr/share/doc/@PVER@/. + +A draft of the "Debian Python Policy" can be found in + + /usr/share/doc/python + +Sometime it will be moved to /usr/share/doc/debian-policy in the +debian-policy package. --- python2.7-2.7.5.orig/debian/PVER-doc.doc-base.PVER-api.in +++ python2.7-2.7.5/debian/PVER-doc.doc-base.PVER-api.in @@ -0,0 +1,13 @@ +Document: @PVER@-api +Title: Python/C API Reference Manual (v@VER@) +Author: Guido van Rossum +Abstract: This manual documents the API used by C (or C++) programmers who + want to write extension modules or embed Python. It is a + companion to *Extending and Embedding the Python Interpreter*, + which describes the general principles of extension writing but + does not document the API functions in detail. +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/@PVER@/html/c-api/index.html +Files: /usr/share/doc/@PVER@/html/c-api/*.html --- python2.7-2.7.5.orig/debian/PVER-doc.doc-base.PVER-ext.in +++ python2.7-2.7.5/debian/PVER-doc.doc-base.PVER-ext.in @@ -0,0 +1,16 @@ +Document: @PVER@-ext +Title: Extending and Embedding the Python Interpreter (v@VER@) +Author: Guido van Rossum +Abstract: This document describes how to write modules in C or C++ to extend + the Python interpreter with new modules. Those modules can define + new functions but also new object types and their methods. The + document also describes how to embed the Python interpreter in + another application, for use as an extension language. Finally, + it shows how to compile and link extension modules so that they + can be loaded dynamically (at run time) into the interpreter, if + the underlying operating system supports this feature. +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/@PVER@/html/extending/index.html +Files: /usr/share/doc/@PVER@/html/extending/*.html --- python2.7-2.7.5.orig/debian/PVER-doc.overrides.in +++ python2.7-2.7.5/debian/PVER-doc.overrides.in @@ -0,0 +1,2 @@ +# this is referenced by the html docs +@PVER@-doc binary: extra-license-file --- python2.7-2.7.5.orig/debian/changelog.shared +++ python2.7-2.7.5/debian/changelog.shared @@ -0,0 +1,3 @@ + * Link the interpreter against the shared runtime library. With + gcc-4.1 the difference in the pystones benchmark dropped from about + 12% to about 5%. --- python2.7-2.7.5.orig/debian/README.idle-PVER.in +++ python2.7-2.7.5/debian/README.idle-PVER.in @@ -0,0 +1,14 @@ + + The Python IDLE package for Debian + ---------------------------------- + +This package contains Python @VER@'s Integrated DeveLopment Environment, IDLE. + +IDLE is included in the Python @VER@ upstream distribution (Tools/idle) and +depends on Tkinter (available as @PVER@-tk package). + +I have written a simple man page. + + + 06/16/1999 + Gregor Hoffleit --- python2.7-2.7.5.orig/debian/control.in +++ python2.7-2.7.5/debian/control.in @@ -0,0 +1,212 @@ +Source: @PVER@ +Section: python +Priority: optional +Maintainer: Matthias Klose +Build-Depends: debhelper (>= 5), quilt, autoconf, lsb-release, sharutils, + libreadline-dev, libtinfo-dev, libncursesw5-dev (>= 5.3), + tk8.5-dev, blt-dev (>= 2.4z), libssl-dev, + zlib1g-dev, libbz2-dev, + libexpat1-dev, + libbluetooth-dev [linux-any], + locales [!armel !avr32 !hppa !ia64 !mipsel], + libsqlite3-dev, libffi-dev (>= 3.0.5), + libgpm2 [linux-any], + mime-support, netbase, bzip2, + libdb5.1-dev, libgdbm-dev, python@bd_qual@, help2man, + gcc (>= 4:4.8) [amd64 armel armhf i386 x32 kfreebsd-any hurd-any], + xvfb, xauth +Build-Depends-Indep: python-sphinx +Build-Conflicts: tcl8.4-dev, tk8.4-dev, @PVER@-xml, python-xml, autoconf2.13, python-cxx-dev +Standards-Version: 3.9.4 +Vcs-Browser: https://code.launchpad.net/~doko/python/pkg@VER@-debian +Vcs-Bzr: http://bazaar.launchpad.net/~doko/python/pkg@VER@-debian +XS-Testsuite: autopkgtest + +Package: @PVER@ +Architecture: any +Multi-Arch: allowed +Priority: @PRIO@ +Depends: @PVER@-minimal (= ${binary:Version}), lib@PVER@-stdlib (= ${binary:Version}), mime-support, ${shlibs:Depends}, ${misc:Depends} +Suggests: @PVER@-doc, binutils +Conflicts: python-profiler (<= 2.7.1-2) +Breaks: python-virtualenv (<< 1.7.1.2-2~), vim-nox (<< 2:7.3.547-4), vim-gtk (<< 2:7.3.547-4), vim-gnome (<< 2:7.3.547-4), vim-athena (<< 2:7.3.547-4) +Replaces: python-profiler (<= 2.7.1-2), @PVER@-minimal (<< 2.7.3-7~) +Description: Interactive high-level object-oriented language (version @VER@) + Python is a high-level, interactive, object-oriented language. Its @VER@ version + includes an extensive class library with lots of goodies for + network programming, system administration, sounds and graphics. + +Package: lib@PVER@-stdlib +Architecture: any +Multi-Arch: same +Priority: @PRIO@ +Depends: lib@PVER@-minimal (= ${binary:Version}), mime-support, ${shlibs:Depends}, ${misc:Depends} +Provides: @PVER@-cjkcodecs, @PVER@-ctypes, @PVER@-elementtree, @PVER@-celementtree, @PVER@-wsgiref, @PVER@-profiler, @PVER@-argparse, python-argparse +Replaces: @PVER@ (<< 2.7.5-0~) +Description: Interactive high-level object-oriented language (standard library, version @VER@) + Python is a high-level, interactive, object-oriented language. Its @VER@ version + includes an extensive class library with lots of goodies for + network programming, system administration, sounds and graphics. + . + This package contains Python @VER@'s standard library. It is normally not + used on its own, but as a dependency of python@VER@. + +Package: @PVER@-minimal +Architecture: any +Multi-Arch: allowed +Priority: @MINPRIO@ +Pre-Depends: ${shlibs:Pre-Depends} +Depends: lib@PVER@-minimal (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Recommends: @PVER@ +Suggests: binfmt-support +Replaces: @PVER@ (<< 2.7.1~rc1-2~) +Conflicts: binfmt-support (<< 1.1.2) +Description: Minimal subset of the Python language (version @VER@) + This package contains the interpreter and some essential modules. It can + be used in the boot process for some basic tasks. + See /usr/share/doc/@PVER@-minimal/README.Debian for a list of the modules + contained in this package. + +Package: lib@PVER@-minimal +Architecture: any +Multi-Arch: same +Priority: @MINPRIO@ +Depends: ${shlibs:Depends}, ${misc:Depends} +Recommends: lib@PVER@-stdlib +Replaces: @PVER@ (<< 2.7.4-2), @PVER@-minimal (<< 2.7.3-10), lib@PVER@-stdlib (<< 2.7.4-2) +Breaks: @PVER@-minimal (<< 2.7.4~rc1-1~) +Conflicts: binfmt-support (<< 1.1.2) +Description: Minimal subset of the Python language (version @VER@) + This package contains some essential modules. It is normally not + used on it's own, but as a dependency of @PVER@-minimal. + +Package: lib@PVER@ +Architecture: any +Multi-Arch: same +Section: libs +Priority: @PRIO@ +Pre-Depends: multiarch-support +Depends: lib@PVER@-stdlib (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Replaces: @PVER@ (<< 2.6) +Description: Shared Python runtime library (version @VER@) + Python is a high-level, interactive, object-oriented language. Its @VER@ version + includes an extensive class library with lots of goodies for + network programming, system administration, sounds and graphics. + . + This package contains the shared runtime library, normally not needed + for programs using the statically linked interpreter. + +Package: @PVER@-examples +Architecture: all +Depends: @PVER@ (>= ${source:Version}), ${misc:Depends} +Description: Examples for the Python language (v@VER@) + Examples, Demos and Tools for Python (v@VER@). These are files included in + the upstream Python distribution (v@VER@). + +Package: @PVER@-dev +Architecture: any +Multi-Arch: allowed +Depends: @PVER@ (= ${binary:Version}), lib@PVER@-dev (= ${binary:Version}), lib@PVER@ (= ${binary:Version}), libexpat1-dev, ${shlibs:Depends}, ${misc:Depends} +Recommends: libc6-dev | libc-dev +Replaces: @PVER@ (<< 2.7-3) +Description: Header files and a static library for Python (v@VER@) + Header files, a static library and development tools for building + Python (v@VER@) modules, extending the Python interpreter or embedding + Python (v@VER@) in applications. + . + Maintainers of Python packages should read README.maintainers. + +Package: lib@PVER@-dev +Section: libdevel +Architecture: any +Multi-Arch: same +Pre-Depends: multiarch-support +Depends: lib@PVER@-stdlib (= ${binary:Version}), lib@PVER@ (= ${binary:Version}), libexpat1-dev, ${shlibs:Depends}, ${misc:Depends} +Replaces: @PVER@ (<< 2.7-3), @PVER@-dev (<< 2.7.3-10), @PVER@-minimal (<< 2.7.3-10) +Recommends: libc6-dev | libc-dev +Description: Header files and a static library for Python (v@VER@) + Header files, a static library and development tools for building + Python (v@VER@) modules, extending the Python interpreter or embedding + Python (v@VER@) in applications. + . + Maintainers of Python packages should read README.maintainers. + . + This package contains development files. It is normally not + used on it's own, but as a dependency of @PVER@-dev. + +Package: lib@PVER@-testsuite +Section: libdevel +Architecture: all +Depends: lib@PVER@-stdlib (>= ${binary:Version}), ${misc:Depends} +Suggests: python-gdbm, python-tk +Description: Testsuite for the Python standard library (v@VER@) + The complete testsuite for the Python standard library. Note that + a subset is found in the lib@PVER@-stdlib package, which should + be enough for other packages to use (please do not build-depend + on this package, but file a bug report to include additional + testsuite files in the lib@PVER@-stdlib package). + +Package: idle-@PVER@ +Architecture: all +Depends: @PVER@, python-tk (>= 2.6~a3), @PVER@-tk, ${misc:Depends} +Enhances: @PVER@ +Replaces: @PVER@ (<< 2.6.1-2) +Description: IDE for Python (v@VER@) using Tkinter + IDLE is an Integrated Development Environment for Python (v@VER@). + IDLE is written using Tkinter and therefore quite platform-independent. + +Package: @PVER@-doc +Section: doc +Architecture: all +Depends: libjs-jquery, ${misc:Depends} +Suggests: @PVER@ +Description: Documentation for the high-level object-oriented language Python (v@VER@) + These is the official set of documentation for the interactive high-level + object-oriented language Python (v@VER@). All documents are provided + in HTML format. The package consists of ten documents: + . + * What's New in Python@VER@ + * Tutorial + * Python Library Reference + * Macintosh Module Reference + * Python Language Reference + * Extending and Embedding Python + * Python/C API Reference + * Installing Python Modules + * Documenting Python + * Distributing Python Modules + +Package: @PVER@-dbg +Section: debug +Architecture: any +Multi-Arch: allowed +Priority: extra +Depends: @PVER@ (= ${binary:Version}), lib@PVER@-dbg (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Suggests: python-gdbm-dbg, python-tk-dbg +Description: Debug Build of the Python Interpreter (version @VER@) + The package holds two things: + . + - A Python interpreter configured with --pydebug. Dynamically loaded modules + are searched as _d.so first. Third party extensions need a separate + build to be used by this interpreter. + - Debug information for standard python interpreter and extensions. + . + See the README.debug for more information. + +Package: lib@PVER@-dbg +Section: debug +Architecture: any +Multi-Arch: same +Priority: extra +Pre-Depends: multiarch-support +Depends: lib@PVER@-stdlib (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}, python +Suggests: @PVER@-gdbm-dbg, @PVER@-tk-dbg +Replaces: @PVER@-dbg (<< 2.7.3-10) +Description: Debug Build of the Python Interpreter (version @VER@) + The package holds two things: + . + - Extensions for a Python interpreter configured with --pydebug. + - Debug information for standard python extensions. + . + See the README.debug for more information. + --- python2.7-2.7.5.orig/debian/PVER.desktop.in +++ python2.7-2.7.5/debian/PVER.desktop.in @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=Python (v@VER@) +Comment=Python Interpreter (v@VER@) +Exec=/usr/bin/@PVER@ +Icon=/usr/share/pixmaps/@PVER@.xpm +Terminal=true +Type=Application +Categories=Development; +StartupNotify=true +NoDisplay=true --- python2.7-2.7.5.orig/debian/README.source +++ python2.7-2.7.5/debian/README.source @@ -0,0 +1,7 @@ +The source tarball is lacking the files Lib/profile.py and Lib/pstats.py, +which Debian considers to have a license non-suitable for main (the use +of these modules limited to python). + +The package uses quilt to apply / unapply patches. +See /usr/share/doc/quilt/README.source. The series file is generated +during the build. --- python2.7-2.7.5.orig/debian/PVER-minimal.README.Debian.in +++ python2.7-2.7.5/debian/PVER-minimal.README.Debian.in @@ -0,0 +1,152 @@ +Contents of the @PVER@-minimal package +----------------------------------------- + +@PVER@-minimal consists of a minimum set of modules which may be needed +for python scripts used during the boot process. If other packages +are needed in these scripts, don't work around the missing module, but +file a bug report against this package. The modules in this package +are: + + __builtin__ builtin + __future__ module + _abcoll module + _bisect extension + _bytesio extension + _codecs builtin + _collections extension + _fileio extension + _functools extension + _hashlib extensionx + _heapq extension + _io extension + _locale extension + _md5 extension + _random extension + _sha extension + _sha256 extension + _sha512 extension + _socket extension + _sre builtin + _ssl extensionx + _struct extension + _symtable builtin + _sysconfigdata module + _types builtin + _warnings builtin + _weakref extension + _weakrefset module + abc module + atexit module + ConfigParser module + StringIO module + UserDict module + cPickle extension + cStringIO extension + array extension + base64 module + binascii extension + bisect module + cmath extension + codecs module + collections module + compileall module + copy module + copy_reg module + dis module + errno builtin + exceptions builtin + fcntl extension + fnmatch module + functools module + gc builtin + genericpath module + getopt module + glob module + grp extension + hashlib module + heapq module + imp builtin + inspect module + io module + itertools extension + keyword module + linecache module + logging package + marshal builtin + math extension + md5 module + opcode module + operator extension + optparse module + os module + pickle module + platform module + popen2 module + posix builtin + posixpath module + pkgutil module + pwd builtin + py_compile module + random module + re module + repr module + runpy module + select extension + sha module + shutil module + signal builtin + socket module + spwd extension + sre module + sre_compile module + sre_constants module + sre_parse module + ssl module + stat module + string module + strop extension + struct module + subprocess module + sys builtin + syslog extension + sysconfig module + tempfile module + textwrap module + time extension + token module + thread builtin + token module + tokenize module + traceback module + types module + unicodedata extension + weakref module + warnings module + zipimport extension + zlib extension + +Included are as well the codecs and stringprep modules, and the encodings +modules for all encodings except the multibyte encodings and the bz2 codec. + +The following modules are excluded, their import is guarded from the +importing module: + + Used in Excluded + ------------ ------------------------------------ + os nt ntpath os2 os2emxpath mac macpath + riscos riscospath riscosenviron + optparse gettext + pickle doctest + subprocess threading + +This list was derived by looking at the modules in the perl-base package, +then adding python specific "core modules". + +TODO's +------ + +- time.strptime cannot be used. The required _strptime module is not + included in the -minimal package yet. _strptime, locale, _locale and + calendar have to be added. + +- modules used very often in the testsuite: copy, cPickle, operator. --- python2.7-2.7.5.orig/debian/PVER-minimal.postrm.in +++ python2.7-2.7.5/debian/PVER-minimal.postrm.in @@ -0,0 +1,21 @@ +#! /bin/sh + +set -e + +if [ "$1" = "remove" ]; then + + if [ -f /var/lib/python/@PVER@_installed ]; then + rm -f /var/lib/python/@PVER@_installed + rmdir --ignore-fail-on-non-empty /var/lib/python 2>/dev/null + fi +fi + +if [ "$1" = "purge" ]; then + for d in `find /usr/lib/@PVER@ -depth -type d -empty 2> /dev/null`; do \ + while rmdir $d 2> /dev/null; do d=`dirname $d`; done; \ + done +fi + +#DEBHELPER# + +exit 0 --- python2.7-2.7.5.orig/debian/control.stdlib +++ python2.7-2.7.5/debian/control.stdlib @@ -0,0 +1,16 @@ +Package: @PVER@-tk +Architecture: any +Depends: @PVER@ (= ${Source-Version}), ${shlibs:Depends} +Suggests: tix +XB-Python-Version: @VER@ +Description: Tkinter - Writing Tk applications with Python (v@VER@) + A module for writing portable GUI applications with Python (v@VER@) using Tk. + Also known as Tkinter. + +Package: @PVER@-gdbm +Architecture: any +Depends: @PVER@ (= ${Source-Version}), ${shlibs:Depends} +Description: GNU dbm database support for Python (v@VER@) + GNU dbm database module for Python. Install this if you want to + create or read GNU dbm database files with Python. + --- python2.7-2.7.5.orig/debian/libPVER-minimal.overrides.in +++ python2.7-2.7.5/debian/libPVER-minimal.overrides.in @@ -0,0 +1 @@ +lib@PVER@-minimal binary: python-script-but-no-python-dep --- python2.7-2.7.5.orig/debian/README.Tk +++ python2.7-2.7.5/debian/README.Tk @@ -0,0 +1,8 @@ +Tkinter documentation can be found at + + http://www.pythonware.com/library/index.htm + +more specific: + + http://www.pythonware.com/library/tkinter/introduction/index.htm + http://www.pythonware.com/library/tkinter/an-introduction-to-tkinter.pdf --- python2.7-2.7.5.orig/debian/dh_rmemptydirs +++ python2.7-2.7.5/debian/dh_rmemptydirs @@ -0,0 +1,10 @@ +#! /bin/sh -e + +pkg=`echo $1 | sed 's/^-p//'` + +: # remove empty directories, when all components are in place +for d in `find debian/$pkg -depth -type d -empty 2> /dev/null`; do \ + while rmdir $$d 2> /dev/null; do d=`dirname $$d`; done; \ +done + +exit 0 --- python2.7-2.7.5.orig/debian/mincheck.py +++ python2.7-2.7.5/debian/mincheck.py @@ -0,0 +1,41 @@ + +import sys + +def get_listed(fn): + modules = set() + for line in file(fn).readlines(): + modules.add(line.split()[1]) + return modules + +def get_dependencies(fn): + t = eval(file(fn).read()) + modules = set() + depgraph = t['depgraph'] + for mod, deps in depgraph.iteritems(): + if mod != '__main__': + modules.add(mod) + modules.update(deps.keys()) + return depgraph, modules + +def main(): + mods = get_listed(sys.argv[1]) + depgraph, deps = get_dependencies(sys.argv[2]) + print "Listed modules:", sorted(mods) + print + print "Dependent modules:", sorted(deps) + print + + missing = deps.difference(mods) + if missing: + print "Missing modules in python-minimal:" + print missing + for m in missing: + users = [] + for caller, callees in depgraph.iteritems(): + if m in callees: + users.append(caller) + print m, "used in: ", users + sys.exit(len(missing)) + +main() + --- python2.7-2.7.5.orig/debian/PVER.overrides.in +++ python2.7-2.7.5/debian/PVER.overrides.in @@ -0,0 +1,14 @@ +# idlelib images +@PVER@ binary: image-file-in-usr-lib + +# yes, we have to +@PVER@ binary: depends-on-python-minimal + +@PVER@ binary: desktop-command-not-in-package +@PVER@ binary: menu-command-not-in-package + +# license file referred by the standard library +@PVER@ binary: extra-license-file + +# no, not useless +@PVER@ binary: manpage-has-useless-whatis-entry --- python2.7-2.7.5.orig/debian/idle-PVER.postrm.in +++ python2.7-2.7.5/debian/idle-PVER.postrm.in @@ -0,0 +1,11 @@ +#! /bin/sh + +set -e + +if [ "$1" = "purge" ]; then + rm -rf /etc/idle-@PVER@ +fi + +#DEBHELPER# + +exit 0 --- python2.7-2.7.5.orig/debian/libpython.symbols.in +++ python2.7-2.7.5/debian/libpython.symbols.in @@ -0,0 +1,1336 @@ + PyAST_Check@Base @VER@ + PyAST_Compile@Base @VER@ + PyAST_FromNode@Base @VER@ + PyAST_mod2obj@Base @VER@ + PyAST_obj2mod@Base @VER@ + PyArena_AddPyObject@Base @VER@ + PyArena_Free@Base @VER@ + PyArena_Malloc@Base @VER@ + PyArena_New@Base @VER@ + PyArg_Parse@Base @VER@ + PyArg_ParseTuple@Base @VER@ + PyArg_ParseTupleAndKeywords@Base @VER@ + PyArg_UnpackTuple@Base @VER@ + PyArg_VaParse@Base @VER@ + PyArg_VaParseTupleAndKeywords@Base @VER@ + PyBaseObject_Type@Base @VER@ + PyBaseString_Type@Base @VER@ + PyBool_FromLong@Base @VER@ + PyBool_Type@Base @VER@ + PyBuffer_FillContiguousStrides@Base @VER@ + PyBuffer_FillInfo@Base @VER@ + PyBuffer_FromContiguous@Base @VER@ + PyBuffer_FromMemory@Base @VER@ + PyBuffer_FromObject@Base @VER@ + PyBuffer_FromReadWriteMemory@Base @VER@ + PyBuffer_FromReadWriteObject@Base @VER@ + PyBuffer_GetPointer@Base @VER@ + PyBuffer_IsContiguous@Base @VER@ + PyBuffer_New@Base @VER@ + PyBuffer_Release@Base @VER@ + PyBuffer_ToContiguous@Base @VER@ + PyBuffer_Type@Base @VER@ + (optional)PyBufferedIOBase_Type@Base @VER@ + (optional)PyBufferedRWPair_Type@Base @VER@ + (optional)PyBufferedRandom_Type@Base @VER@ + (optional)PyBufferedReader_Type@Base @VER@ + (optional)PyBufferedWriter_Type@Base @VER@ + PyByteArrayIter_Type@Base @VER@ + PyByteArray_AsString@Base @VER@ + PyByteArray_Concat@Base @VER@ + PyByteArray_Fini@Base @VER@ + PyByteArray_FromObject@Base @VER@ + PyByteArray_FromStringAndSize@Base @VER@ + PyByteArray_Init@Base @VER@ + PyByteArray_Resize@Base @VER@ + PyByteArray_Size@Base @VER@ + PyByteArray_Type@Base @VER@ + (optional)PyBytesIO_Type@Base @VER@ + PyCFunction_Call@Base @VER@ + PyCFunction_ClearFreeList@Base @VER@ + PyCFunction_Fini@Base @VER@ + PyCFunction_GetFlags@Base @VER@ + PyCFunction_GetFunction@Base @VER@ + PyCFunction_GetSelf@Base @VER@ + PyCFunction_New@Base @VER@ + PyCFunction_NewEx@Base @VER@ + PyCFunction_Type@Base @VER@ + PyCObject_AsVoidPtr@Base @VER@ + PyCObject_FromVoidPtr@Base @VER@ + PyCObject_FromVoidPtrAndDesc@Base @VER@ + PyCObject_GetDesc@Base @VER@ + PyCObject_Import@Base @VER@ + PyCObject_SetVoidPtr@Base @VER@ + PyCObject_Type@Base @VER@ + PyCallIter_New@Base @VER@ + PyCallIter_Type@Base @VER@ + PyCallable_Check@Base @VER@ + PyCapsule_GetContext@Base @VER@ + PyCapsule_GetDestructor@Base @VER@ + PyCapsule_GetName@Base @VER@ + PyCapsule_GetPointer@Base @VER@ + PyCapsule_Import@Base @VER@ + PyCapsule_IsValid@Base @VER@ + PyCapsule_New@Base @VER@ + PyCapsule_SetContext@Base @VER@ + PyCapsule_SetDestructor@Base @VER@ + PyCapsule_SetName@Base @VER@ + PyCapsule_SetPointer@Base @VER@ + PyCapsule_Type@Base @VER@ + PyCell_Get@Base @VER@ + PyCell_New@Base @VER@ + PyCell_Set@Base @VER@ + PyCell_Type@Base @VER@ + PyClassMethod_New@Base @VER@ + PyClassMethod_Type@Base @VER@ + PyClass_IsSubclass@Base @VER@ + PyClass_New@Base @VER@ + PyClass_Type@Base @VER@ + PyCode_Addr2Line@Base @VER@ + PyCode_New@Base @VER@ + PyCode_NewEmpty@Base @VER@ + PyCode_Optimize@Base @VER@ + PyCode_Type@Base @VER@ + PyCodec_BackslashReplaceErrors@Base @VER@ + PyCodec_Decode@Base @VER@ + PyCodec_Decoder@Base @VER@ + PyCodec_Encode@Base @VER@ + PyCodec_Encoder@Base @VER@ + PyCodec_IgnoreErrors@Base @VER@ + PyCodec_IncrementalDecoder@Base @VER@ + PyCodec_IncrementalEncoder@Base @VER@ + PyCodec_LookupError@Base @VER@ + PyCodec_Register@Base @VER@ + PyCodec_RegisterError@Base @VER@ + PyCodec_ReplaceErrors@Base @VER@ + PyCodec_StreamReader@Base @VER@ + PyCodec_StreamWriter@Base @VER@ + PyCodec_StrictErrors@Base @VER@ + PyCodec_XMLCharRefReplaceErrors@Base @VER@ + PyComplex_AsCComplex@Base @VER@ + PyComplex_FromCComplex@Base @VER@ + PyComplex_FromDoubles@Base @VER@ + PyComplex_ImagAsDouble@Base @VER@ + PyComplex_RealAsDouble@Base @VER@ + PyComplex_Type@Base @VER@ + PyDescr_NewClassMethod@Base @VER@ + PyDescr_NewGetSet@Base @VER@ + PyDescr_NewMember@Base @VER@ + PyDescr_NewMethod@Base @VER@ + PyDescr_NewWrapper@Base @VER@ + PyDictItems_Type@Base @VER@ + PyDictIterItem_Type@Base @VER@ + PyDictIterKey_Type@Base @VER@ + PyDictIterValue_Type@Base @VER@ + PyDictKeys_Type@Base @VER@ + PyDictProxy_New@Base @VER@ + PyDictProxy_Type@Base @VER@ + PyDictValues_Type@Base @VER@ + PyDict_Clear@Base @VER@ + PyDict_Contains@Base @VER@ + PyDict_Copy@Base @VER@ + PyDict_DelItem@Base @VER@ + PyDict_DelItemString@Base @VER@ + PyDict_Fini@Base @VER@ + PyDict_GetItem@Base @VER@ + PyDict_GetItemString@Base @VER@ + PyDict_Items@Base @VER@ + PyDict_Keys@Base @VER@ + PyDict_Merge@Base @VER@ + PyDict_MergeFromSeq2@Base @VER@ + PyDict_New@Base @VER@ + PyDict_Next@Base @VER@ + PyDict_SetItem@Base @VER@ + PyDict_SetItemString@Base @VER@ + PyDict_Size@Base @VER@ + PyDict_Type@Base @VER@ + PyDict_Update@Base @VER@ + PyDict_Values@Base @VER@ + PyEllipsis_Type@Base @VER@ + PyEnum_Type@Base @VER@ + PyErr_BadArgument@Base @VER@ + PyErr_BadInternalCall@Base @VER@ + PyErr_CheckSignals@Base @VER@ + PyErr_Clear@Base @VER@ + PyErr_Display@Base @VER@ + PyErr_ExceptionMatches@Base @VER@ + PyErr_Fetch@Base @VER@ + PyErr_Format@Base @VER@ + PyErr_GivenExceptionMatches@Base @VER@ + PyErr_NewException@Base @VER@ + PyErr_NewExceptionWithDoc@Base @VER@ + PyErr_NoMemory@Base @VER@ + PyErr_NormalizeException@Base @VER@ + PyErr_Occurred@Base @VER@ + PyErr_Print@Base @VER@ + PyErr_PrintEx@Base @VER@ + PyErr_ProgramText@Base @VER@ + PyErr_Restore@Base @VER@ + PyErr_SetFromErrno@Base @VER@ + PyErr_SetFromErrnoWithFilename@Base @VER@ + PyErr_SetFromErrnoWithFilenameObject@Base @VER@ + PyErr_SetInterrupt@Base @VER@ + PyErr_SetNone@Base @VER@ + PyErr_SetObject@Base @VER@ + PyErr_SetString@Base @VER@ + PyErr_SyntaxLocation@Base @VER@ + PyErr_Warn@Base @VER@ + PyErr_WarnEx@Base @VER@ + PyErr_WarnExplicit@Base @VER@ + PyErr_WriteUnraisable@Base @VER@ + PyEval_AcquireLock@Base @VER@ + PyEval_AcquireThread@Base @VER@ + PyEval_CallFunction@Base @VER@ + PyEval_CallMethod@Base @VER@ + PyEval_CallObjectWithKeywords@Base @VER@ + PyEval_EvalCode@Base @VER@ + PyEval_EvalCodeEx@Base @VER@ + PyEval_EvalFrame@Base @VER@ + PyEval_EvalFrameEx@Base @VER@ + PyEval_GetBuiltins@Base @VER@ + PyEval_GetCallStats@Base @VER@ + PyEval_GetFrame@Base @VER@ + PyEval_GetFuncDesc@Base @VER@ + PyEval_GetFuncName@Base @VER@ + PyEval_GetGlobals@Base @VER@ + PyEval_GetLocals@Base @VER@ + PyEval_GetRestricted@Base @VER@ + PyEval_InitThreads@Base @VER@ + PyEval_MergeCompilerFlags@Base @VER@ + PyEval_ReInitThreads@Base @VER@ + PyEval_ReleaseLock@Base @VER@ + PyEval_ReleaseThread@Base @VER@ + PyEval_RestoreThread@Base @VER@ + PyEval_SaveThread@Base @VER@ + PyEval_SetProfile@Base @VER@ + PyEval_SetTrace@Base @VER@ + PyEval_ThreadsInitialized@Base @VER@ + PyExc_ArithmeticError@Base @VER@ + PyExc_AssertionError@Base @VER@ + PyExc_AttributeError@Base @VER@ + PyExc_BaseException@Base @VER@ + (optional)PyExc_BlockingIOError@Base @VER@ + PyExc_BufferError@Base @VER@ + PyExc_BytesWarning@Base @VER@ + PyExc_DeprecationWarning@Base @VER@ + PyExc_EOFError@Base @VER@ + PyExc_EnvironmentError@Base @VER@ + PyExc_Exception@Base @VER@ + PyExc_FloatingPointError@Base @VER@ + PyExc_FutureWarning@Base @VER@ + PyExc_GeneratorExit@Base @VER@ + PyExc_IOError@Base @VER@ + PyExc_ImportError@Base @VER@ + PyExc_ImportWarning@Base @VER@ + PyExc_IndentationError@Base @VER@ + PyExc_IndexError@Base @VER@ + PyExc_KeyError@Base @VER@ + PyExc_KeyboardInterrupt@Base @VER@ + PyExc_LookupError@Base @VER@ + PyExc_MemoryError@Base @VER@ + PyExc_MemoryErrorInst@Base @VER@ + PyExc_NameError@Base @VER@ + PyExc_NotImplementedError@Base @VER@ + PyExc_OSError@Base @VER@ + PyExc_OverflowError@Base @VER@ + PyExc_PendingDeprecationWarning@Base @VER@ + PyExc_RecursionErrorInst@Base @VER@ + PyExc_ReferenceError@Base @VER@ + PyExc_RuntimeError@Base @VER@ + PyExc_RuntimeWarning@Base @VER@ + PyExc_StandardError@Base @VER@ + PyExc_StopIteration@Base @VER@ + PyExc_SyntaxError@Base @VER@ + PyExc_SyntaxWarning@Base @VER@ + PyExc_SystemError@Base @VER@ + PyExc_SystemExit@Base @VER@ + PyExc_TabError@Base @VER@ + PyExc_TypeError@Base @VER@ + PyExc_UnboundLocalError@Base @VER@ + PyExc_UnicodeDecodeError@Base @VER@ + PyExc_UnicodeEncodeError@Base @VER@ + PyExc_UnicodeError@Base @VER@ + PyExc_UnicodeTranslateError@Base @VER@ + PyExc_UnicodeWarning@Base @VER@ + PyExc_UserWarning@Base @VER@ + PyExc_ValueError@Base @VER@ + PyExc_Warning@Base @VER@ + PyExc_ZeroDivisionError@Base @VER@ + (optional)PyFileIO_Type@Base @VER@ + PyFile_AsFile@Base @VER@ + PyFile_DecUseCount@Base @VER@ + PyFile_FromFile@Base @VER@ + PyFile_FromString@Base @VER@ + PyFile_GetLine@Base @VER@ + PyFile_IncUseCount@Base @VER@ + PyFile_Name@Base @VER@ + PyFile_SetBufSize@Base @VER@ + PyFile_SetEncoding@Base @VER@ + PyFile_SetEncodingAndErrors@Base @VER@ + PyFile_SoftSpace@Base @VER@ + PyFile_Type@Base @VER@ + PyFile_WriteObject@Base @VER@ + PyFile_WriteString@Base @VER@ + PyFloat_AsDouble@Base @VER@ + PyFloat_AsReprString@Base @VER@ + PyFloat_AsString@Base @VER@ + PyFloat_ClearFreeList@Base @VER@ + PyFloat_Fini@Base @VER@ + PyFloat_FromDouble@Base @VER@ + PyFloat_FromString@Base @VER@ + PyFloat_GetInfo@Base @VER@ + PyFloat_GetMax@Base @VER@ + PyFloat_GetMin@Base @VER@ + PyFloat_Type@Base @VER@ + PyFrame_BlockPop@Base @VER@ + PyFrame_BlockSetup@Base @VER@ + PyFrame_ClearFreeList@Base @VER@ + PyFrame_FastToLocals@Base @VER@ + PyFrame_Fini@Base @VER@ + PyFrame_GetLineNumber@Base @VER@ + PyFrame_LocalsToFast@Base @VER@ + PyFrame_New@Base @VER@ + PyFrame_Type@Base @VER@ + PyFrozenSet_New@Base @VER@ + PyFrozenSet_Type@Base @VER@ + PyFunction_GetClosure@Base @VER@ + PyFunction_GetCode@Base @VER@ + PyFunction_GetDefaults@Base @VER@ + PyFunction_GetGlobals@Base @VER@ + PyFunction_GetModule@Base @VER@ + PyFunction_New@Base @VER@ + PyFunction_SetClosure@Base @VER@ + PyFunction_SetDefaults@Base @VER@ + PyFunction_Type@Base @VER@ + PyFuture_FromAST@Base @VER@ + PyGC_Collect@Base @VER@ + PyGILState_Ensure@Base @VER@ + PyGILState_GetThisThreadState@Base @VER@ + PyGILState_Release@Base @VER@ + PyGen_NeedsFinalizing@Base @VER@ + PyGen_New@Base @VER@ + PyGen_Type@Base @VER@ + PyGetSetDescr_Type@Base @VER@ + PyGrammar_AddAccelerators@Base @VER@ + PyGrammar_FindDFA@Base @VER@ + PyGrammar_LabelRepr@Base @VER@ + PyGrammar_RemoveAccelerators@Base @VER@ + (optional)PyIOBase_Type@Base @VER@ + PyImport_AddModule@Base @VER@ + PyImport_AppendInittab@Base @VER@ + PyImport_Cleanup@Base @VER@ + PyImport_ExecCodeModule@Base @VER@ + PyImport_ExecCodeModuleEx@Base @VER@ + PyImport_ExtendInittab@Base @VER@ + PyImport_FrozenModules@Base @VER@ + PyImport_GetImporter@Base @VER@ + PyImport_GetMagicNumber@Base @VER@ + PyImport_GetModuleDict@Base @VER@ + PyImport_Import@Base @VER@ + PyImport_ImportFrozenModule@Base @VER@ + PyImport_ImportModule@Base @VER@ + PyImport_ImportModuleLevel@Base @VER@ + PyImport_ImportModuleNoBlock@Base @VER@ + PyImport_Inittab@Base @VER@ + PyImport_ReloadModule@Base @VER@ + (optional)PyIncrementalNewlineDecoder_Type@Base @VER@ + PyInstance_New@Base @VER@ + PyInstance_NewRaw@Base @VER@ + PyInstance_Type@Base @VER@ + PyInt_AsLong@Base @VER@ + PyInt_AsSsize_t@Base @VER@ + PyInt_AsUnsignedLongLongMask@Base @VER@ + PyInt_AsUnsignedLongMask@Base @VER@ + PyInt_ClearFreeList@Base @VER@ + PyInt_Fini@Base @VER@ + PyInt_FromLong@Base @VER@ + PyInt_FromSize_t@Base @VER@ + PyInt_FromSsize_t@Base @VER@ + PyInt_FromString@Base @VER@ + PyInt_FromUnicode@Base @VER@ + PyInt_GetMax@Base @VER@ + PyInt_Type@Base @VER@ + PyInterpreterState_Clear@Base @VER@ + PyInterpreterState_Delete@Base @VER@ + PyInterpreterState_Head@Base @VER@ + PyInterpreterState_New@Base @VER@ + PyInterpreterState_Next@Base @VER@ + PyInterpreterState_ThreadHead@Base @VER@ + PyIter_Next@Base @VER@ + PyListIter_Type@Base @VER@ + PyListRevIter_Type@Base @VER@ + PyList_Append@Base @VER@ + PyList_AsTuple@Base @VER@ + PyList_Fini@Base @VER@ + PyList_GetItem@Base @VER@ + PyList_GetSlice@Base @VER@ + PyList_Insert@Base @VER@ + PyList_New@Base @VER@ + PyList_Reverse@Base @VER@ + PyList_SetItem@Base @VER@ + PyList_SetSlice@Base @VER@ + PyList_Size@Base @VER@ + PyList_Sort@Base @VER@ + PyList_Type@Base @VER@ + PyLong_AsDouble@Base @VER@ + PyLong_AsLong@Base @VER@ + PyLong_AsLongAndOverflow@Base @VER@ + PyLong_AsLongLong@Base @VER@ + PyLong_AsLongLongAndOverflow@Base @VER@ + PyLong_AsSsize_t@Base @VER@ + PyLong_AsUnsignedLong@Base @VER@ + PyLong_AsUnsignedLongLong@Base @VER@ + PyLong_AsUnsignedLongLongMask@Base @VER@ + PyLong_AsUnsignedLongMask@Base @VER@ + PyLong_AsVoidPtr@Base @VER@ + PyLong_FromDouble@Base @VER@ + PyLong_FromLong@Base @VER@ + PyLong_FromLongLong@Base @VER@ + PyLong_FromSize_t@Base @VER@ + PyLong_FromSsize_t@Base @VER@ + PyLong_FromString@Base @VER@ + PyLong_FromUnicode@Base @VER@ + PyLong_FromUnsignedLong@Base @VER@ + PyLong_FromUnsignedLongLong@Base @VER@ + PyLong_FromVoidPtr@Base @VER@ + PyLong_GetInfo@Base @VER@ + PyLong_Type@Base @VER@ + PyMapping_Check@Base @VER@ + PyMapping_GetItemString@Base @VER@ + PyMapping_HasKey@Base @VER@ + PyMapping_HasKeyString@Base @VER@ + PyMapping_Length@Base @VER@ + PyMapping_SetItemString@Base @VER@ + PyMapping_Size@Base @VER@ + PyMarshal_Init@Base @VER@ + PyMarshal_ReadLastObjectFromFile@Base @VER@ + PyMarshal_ReadLongFromFile@Base @VER@ + PyMarshal_ReadObjectFromFile@Base @VER@ + PyMarshal_ReadObjectFromString@Base @VER@ + PyMarshal_ReadShortFromFile@Base @VER@ + PyMarshal_WriteLongToFile@Base @VER@ + PyMarshal_WriteObjectToFile@Base @VER@ + PyMarshal_WriteObjectToString@Base @VER@ + PyMem_Free@Base @VER@ + PyMem_Malloc@Base @VER@ + PyMem_Realloc@Base @VER@ + PyMemberDescr_Type@Base @VER@ + PyMember_Get@Base @VER@ + PyMember_GetOne@Base @VER@ + PyMember_Set@Base @VER@ + PyMember_SetOne@Base @VER@ + PyMemoryView_FromBuffer@Base @VER@ + PyMemoryView_FromObject@Base @VER@ + PyMemoryView_GetContiguous@Base @VER@ + PyMemoryView_Type@Base @VER@ + PyMethod_Class@Base @VER@ + PyMethod_ClearFreeList@Base @VER@ + PyMethod_Fini@Base @VER@ + PyMethod_Function@Base @VER@ + PyMethod_New@Base @VER@ + PyMethod_Self@Base @VER@ + PyMethod_Type@Base @VER@ + PyModule_AddIntConstant@Base @VER@ + PyModule_AddObject@Base @VER@ + PyModule_AddStringConstant@Base @VER@ + PyModule_GetDict@Base @VER@ + PyModule_GetFilename@Base @VER@ + PyModule_GetName@Base @VER@ + PyModule_GetWarningsModule@Base @VER@ + PyModule_New@Base @VER@ + PyModule_Type@Base @VER@ + PyNode_AddChild@Base @VER@ + PyNode_Compile@Base @VER@ + PyNode_Free@Base @VER@ + PyNode_ListTree@Base @VER@ + PyNode_New@Base @VER@ + PyNullImporter_Type@Base @VER@ + PyNumber_Absolute@Base @VER@ + PyNumber_Add@Base @VER@ + PyNumber_And@Base @VER@ + (optional)PyNumber_AsOff_t@Base @VER@ + PyNumber_AsSsize_t@Base @VER@ + PyNumber_Check@Base @VER@ + PyNumber_Coerce@Base @VER@ + PyNumber_CoerceEx@Base @VER@ + PyNumber_Divide@Base @VER@ + PyNumber_Divmod@Base @VER@ + PyNumber_Float@Base @VER@ + PyNumber_FloorDivide@Base @VER@ + PyNumber_InPlaceAdd@Base @VER@ + PyNumber_InPlaceAnd@Base @VER@ + PyNumber_InPlaceDivide@Base @VER@ + PyNumber_InPlaceFloorDivide@Base @VER@ + PyNumber_InPlaceLshift@Base @VER@ + PyNumber_InPlaceMultiply@Base @VER@ + PyNumber_InPlaceOr@Base @VER@ + PyNumber_InPlacePower@Base @VER@ + PyNumber_InPlaceRemainder@Base @VER@ + PyNumber_InPlaceRshift@Base @VER@ + PyNumber_InPlaceSubtract@Base @VER@ + PyNumber_InPlaceTrueDivide@Base @VER@ + PyNumber_InPlaceXor@Base @VER@ + PyNumber_Index@Base @VER@ + PyNumber_Int@Base @VER@ + PyNumber_Invert@Base @VER@ + PyNumber_Long@Base @VER@ + PyNumber_Lshift@Base @VER@ + PyNumber_Multiply@Base @VER@ + PyNumber_Negative@Base @VER@ + PyNumber_Or@Base @VER@ + PyNumber_Positive@Base @VER@ + PyNumber_Power@Base @VER@ + PyNumber_Remainder@Base @VER@ + PyNumber_Rshift@Base @VER@ + PyNumber_Subtract@Base @VER@ + PyNumber_ToBase@Base @VER@ + PyNumber_TrueDivide@Base @VER@ + PyNumber_Xor@Base @VER@ + PyOS_AfterFork@Base @VER@ + PyOS_FiniInterrupts@Base @VER@ + PyOS_InitInterrupts@Base @VER@ + PyOS_InputHook@Base @VER@ + PyOS_InterruptOccurred@Base @VER@ + PyOS_Readline@Base @VER@ + PyOS_ReadlineFunctionPointer@Base @VER@ + PyOS_StdioReadline@Base @VER@ + PyOS_ascii_atof@Base @VER@ + PyOS_ascii_formatd@Base @VER@ + PyOS_ascii_strtod@Base @VER@ + PyOS_double_to_string@Base @VER@ + PyOS_getsig@Base @VER@ + PyOS_mystricmp@Base @VER@ + PyOS_mystrnicmp@Base @VER@ + PyOS_setsig@Base @VER@ + PyOS_snprintf@Base @VER@ + PyOS_string_to_double@Base @VER@ + PyOS_strtol@Base @VER@ + PyOS_strtoul@Base @VER@ + PyOS_vsnprintf@Base @VER@ + PyObject_AsCharBuffer@Base @VER@ + PyObject_AsFileDescriptor@Base @VER@ + PyObject_AsReadBuffer@Base @VER@ + PyObject_AsWriteBuffer@Base @VER@ + PyObject_Call@Base @VER@ + PyObject_CallFunction@Base @VER@ + PyObject_CallFunctionObjArgs@Base @VER@ + PyObject_CallMethod@Base @VER@ + PyObject_CallMethodObjArgs@Base @VER@ + PyObject_CallObject@Base @VER@ + PyObject_CheckReadBuffer@Base @VER@ + PyObject_ClearWeakRefs@Base @VER@ + PyObject_Cmp@Base @VER@ + PyObject_Compare@Base @VER@ + PyObject_CopyData@Base @VER@ + PyObject_DelItem@Base @VER@ + PyObject_DelItemString@Base @VER@ + PyObject_Dir@Base @VER@ + PyObject_Format@Base @VER@ + PyObject_Free@Base @VER@ + PyObject_GC_Del@Base @VER@ + PyObject_GC_Track@Base @VER@ + PyObject_GC_UnTrack@Base @VER@ + PyObject_GenericGetAttr@Base @VER@ + PyObject_GenericSetAttr@Base @VER@ + PyObject_GetAttr@Base @VER@ + PyObject_GetAttrString@Base @VER@ + PyObject_GetBuffer@Base @VER@ + PyObject_GetItem@Base @VER@ + PyObject_GetIter@Base @VER@ + PyObject_HasAttr@Base @VER@ + PyObject_HasAttrString@Base @VER@ + PyObject_Hash@Base @VER@ + PyObject_HashNotImplemented@Base @VER@ + PyObject_Init@Base @VER@ + PyObject_InitVar@Base @VER@ + PyObject_IsInstance@Base @VER@ + PyObject_IsSubclass@Base @VER@ + PyObject_IsTrue@Base @VER@ + PyObject_Length@Base @VER@ + PyObject_Malloc@Base @VER@ + PyObject_Not@Base @VER@ + PyObject_Print@Base @VER@ + PyObject_Realloc@Base @VER@ + PyObject_Repr@Base @VER@ + PyObject_RichCompare@Base @VER@ + PyObject_RichCompareBool@Base @VER@ + PyObject_SelfIter@Base @VER@ + PyObject_SetAttr@Base @VER@ + PyObject_SetAttrString@Base @VER@ + PyObject_SetItem@Base @VER@ + PyObject_Size@Base @VER@ + PyObject_Str@Base @VER@ + PyObject_Type@Base @VER@ + PyObject_Unicode@Base @VER@ + PyParser_ASTFromFile@Base @VER@ + PyParser_ASTFromString@Base @VER@ + PyParser_AddToken@Base @VER@ + PyParser_Delete@Base @VER@ + PyParser_New@Base @VER@ + PyParser_ParseFile@Base @VER@ + PyParser_ParseFileFlags@Base @VER@ + PyParser_ParseFileFlagsEx@Base @VER@ + PyParser_ParseString@Base @VER@ + PyParser_ParseStringFlags@Base @VER@ + PyParser_ParseStringFlagsFilename@Base @VER@ + PyParser_ParseStringFlagsFilenameEx@Base @VER@ + PyParser_SetError@Base @VER@ + PyParser_SimpleParseFile@Base @VER@ + PyParser_SimpleParseFileFlags@Base @VER@ + PyParser_SimpleParseString@Base @VER@ + PyParser_SimpleParseStringFilename@Base @VER@ + PyParser_SimpleParseStringFlags@Base @VER@ + PyParser_SimpleParseStringFlagsFilename@Base @VER@ + PyProperty_Type@Base @VER@ + PyRange_Type@Base @VER@ + (optional)PyRawIOBase_Type@Base @VER@ + PyReversed_Type@Base @VER@ + PyRun_AnyFile@Base @VER@ + PyRun_AnyFileEx@Base @VER@ + PyRun_AnyFileExFlags@Base @VER@ + PyRun_AnyFileFlags@Base @VER@ + PyRun_File@Base @VER@ + PyRun_FileEx@Base @VER@ + PyRun_FileExFlags@Base @VER@ + PyRun_FileFlags@Base @VER@ + PyRun_InteractiveLoop@Base @VER@ + PyRun_InteractiveLoopFlags@Base @VER@ + PyRun_InteractiveOne@Base @VER@ + PyRun_InteractiveOneFlags@Base @VER@ + PyRun_SimpleFile@Base @VER@ + PyRun_SimpleFileEx@Base @VER@ + PyRun_SimpleFileExFlags@Base @VER@ + PyRun_SimpleString@Base @VER@ + PyRun_SimpleStringFlags@Base @VER@ + PyRun_String@Base @VER@ + PyRun_StringFlags@Base @VER@ + PySTEntry_Type@Base @VER@ + PyST_GetScope@Base @VER@ + PySeqIter_New@Base @VER@ + PySeqIter_Type@Base @VER@ + PySequence_Check@Base @VER@ + PySequence_Concat@Base @VER@ + PySequence_Contains@Base @VER@ + PySequence_Count@Base @VER@ + PySequence_DelItem@Base @VER@ + PySequence_DelSlice@Base @VER@ + PySequence_Fast@Base @VER@ + PySequence_GetItem@Base @VER@ + PySequence_GetSlice@Base @VER@ + PySequence_In@Base @VER@ + PySequence_InPlaceConcat@Base @VER@ + PySequence_InPlaceRepeat@Base @VER@ + PySequence_Index@Base @VER@ + PySequence_Length@Base @VER@ + PySequence_List@Base @VER@ + PySequence_Repeat@Base @VER@ + PySequence_SetItem@Base @VER@ + PySequence_SetSlice@Base @VER@ + PySequence_Size@Base @VER@ + PySequence_Tuple@Base @VER@ + PySet_Add@Base @VER@ + PySet_Clear@Base @VER@ + PySet_Contains@Base @VER@ + PySet_Discard@Base @VER@ + PySet_Fini@Base @VER@ + PySet_New@Base @VER@ + PySet_Pop@Base @VER@ + PySet_Size@Base @VER@ + PySet_Type@Base @VER@ + PySignal_SetWakeupFd@Base @VER@ + PySlice_GetIndices@Base @VER@ + PySlice_GetIndicesEx@Base @VER@ + PySlice_New@Base @VER@ + PySlice_Type@Base @VER@ + PyStaticMethod_New@Base @VER@ + PyStaticMethod_Type@Base @VER@ + (optional)PyStringIO_Type@Base @VER@ + PyString_AsDecodedObject@Base @VER@ + PyString_AsDecodedString@Base @VER@ + PyString_AsEncodedObject@Base @VER@ + PyString_AsEncodedString@Base @VER@ + PyString_AsString@Base @VER@ + PyString_AsStringAndSize@Base @VER@ + PyString_Concat@Base @VER@ + PyString_ConcatAndDel@Base @VER@ + PyString_Decode@Base @VER@ + PyString_DecodeEscape@Base @VER@ + PyString_Encode@Base @VER@ + PyString_Fini@Base @VER@ + PyString_Format@Base @VER@ + PyString_FromFormat@Base @VER@ + PyString_FromFormatV@Base @VER@ + PyString_FromString@Base @VER@ + PyString_FromStringAndSize@Base @VER@ + PyString_InternFromString@Base @VER@ + PyString_InternImmortal@Base @VER@ + PyString_InternInPlace@Base @VER@ + PyString_Repr@Base @VER@ + PyString_Size@Base @VER@ + PyString_Type@Base @VER@ + PyStructSequence_InitType@Base @VER@ + PyStructSequence_New@Base @VER@ + PyStructSequence_UnnamedField@Base @VER@ + PySuper_Type@Base @VER@ + PySymtable_Build@Base @VER@ + PySymtable_Free@Base @VER@ + PySymtable_Lookup@Base @VER@ + PySys_AddWarnOption@Base @VER@ + PySys_GetFile@Base @VER@ + PySys_GetObject@Base @VER@ + PySys_HasWarnOptions@Base @VER@ + PySys_ResetWarnOptions@Base @VER@ + PySys_SetArgv@Base @VER@ + PySys_SetArgvEx@Base @VER@ + PySys_SetObject@Base @VER@ + PySys_SetPath@Base @VER@ + PySys_WriteStderr@Base @VER@ + PySys_WriteStdout@Base @VER@ + (optional)PyTextIOBase_Type@Base @VER@ + (optional)PyTextIOWrapper_Type@Base @VER@ + PyThreadState_Clear@Base @VER@ + PyThreadState_Delete@Base @VER@ + PyThreadState_DeleteCurrent@Base @VER@ + PyThreadState_Get@Base @VER@ + PyThreadState_GetDict@Base @VER@ + PyThreadState_New@Base @VER@ + PyThreadState_Next@Base @VER@ + PyThreadState_SetAsyncExc@Base @VER@ + PyThreadState_Swap@Base @VER@ + PyThread_ReInitTLS@Base @VER@ + PyThread_acquire_lock@Base @VER@ + PyThread_allocate_lock@Base @VER@ + PyThread_create_key@Base @VER@ + PyThread_delete_key@Base @VER@ + PyThread_delete_key_value@Base @VER@ + PyThread_exit_thread@Base @VER@ + PyThread_free_lock@Base @VER@ + PyThread_get_key_value@Base @VER@ + PyThread_get_stacksize@Base @VER@ + PyThread_get_thread_ident@Base @VER@ + PyThread_init_thread@Base @VER@ + PyThread_release_lock@Base @VER@ + PyThread_set_key_value@Base @VER@ + PyThread_set_stacksize@Base @VER@ + PyThread_start_new_thread@Base @VER@ + PyToken_OneChar@Base @VER@ + PyToken_ThreeChars@Base @VER@ + PyToken_TwoChars@Base @VER@ + PyTokenizer_Free@Base @VER@ + PyTokenizer_FromFile@Base @VER@ + PyTokenizer_FromString@Base @VER@ + PyTokenizer_Get@Base @VER@ + PyTokenizer_RestoreEncoding@Base @VER@ + PyTraceBack_Here@Base @VER@ + PyTraceBack_Print@Base @VER@ + PyTraceBack_Type@Base @VER@ + PyTupleIter_Type@Base @VER@ + PyTuple_ClearFreeList@Base @VER@ + PyTuple_Fini@Base @VER@ + PyTuple_GetItem@Base @VER@ + PyTuple_GetSlice@Base @VER@ + PyTuple_New@Base @VER@ + PyTuple_Pack@Base @VER@ + PyTuple_SetItem@Base @VER@ + PyTuple_Size@Base @VER@ + PyTuple_Type@Base @VER@ + PyType_ClearCache@Base @VER@ + PyType_GenericAlloc@Base @VER@ + PyType_GenericNew@Base @VER@ + PyType_IsSubtype@Base @VER@ + PyType_Modified@Base @VER@ + PyType_Ready@Base @VER@ + PyType_Type@Base @VER@ + PyUnicodeDecodeError_Create@Base @VER@ + PyUnicodeDecodeError_GetEncoding@Base @VER@ + PyUnicodeDecodeError_GetEnd@Base @VER@ + PyUnicodeDecodeError_GetObject@Base @VER@ + PyUnicodeDecodeError_GetReason@Base @VER@ + PyUnicodeDecodeError_GetStart@Base @VER@ + PyUnicodeDecodeError_SetEnd@Base @VER@ + PyUnicodeDecodeError_SetReason@Base @VER@ + PyUnicodeDecodeError_SetStart@Base @VER@ + PyUnicodeEncodeError_Create@Base @VER@ + PyUnicodeEncodeError_GetEncoding@Base @VER@ + PyUnicodeEncodeError_GetEnd@Base @VER@ + PyUnicodeEncodeError_GetObject@Base @VER@ + PyUnicodeEncodeError_GetReason@Base @VER@ + PyUnicodeEncodeError_GetStart@Base @VER@ + PyUnicodeEncodeError_SetEnd@Base @VER@ + PyUnicodeEncodeError_SetReason@Base @VER@ + PyUnicodeEncodeError_SetStart@Base @VER@ + PyUnicodeTranslateError_Create@Base @VER@ + PyUnicodeTranslateError_GetEnd@Base @VER@ + PyUnicodeTranslateError_GetObject@Base @VER@ + PyUnicodeTranslateError_GetReason@Base @VER@ + PyUnicodeTranslateError_GetStart@Base @VER@ + PyUnicodeTranslateError_SetEnd@Base @VER@ + PyUnicodeTranslateError_SetReason@Base @VER@ + PyUnicodeTranslateError_SetStart@Base @VER@ + PyUnicodeUCS4_AsASCIIString@Base @VER@ + PyUnicodeUCS4_AsCharmapString@Base @VER@ + PyUnicodeUCS4_AsEncodedObject@Base @VER@ + PyUnicodeUCS4_AsEncodedString@Base @VER@ + PyUnicodeUCS4_AsLatin1String@Base @VER@ + PyUnicodeUCS4_AsRawUnicodeEscapeString@Base @VER@ + PyUnicodeUCS4_AsUTF16String@Base @VER@ + PyUnicodeUCS4_AsUTF32String@Base @VER@ + PyUnicodeUCS4_AsUTF8String@Base @VER@ + PyUnicodeUCS4_AsUnicode@Base @VER@ + PyUnicodeUCS4_AsUnicodeEscapeString@Base @VER@ + PyUnicodeUCS4_AsWideChar@Base @VER@ + PyUnicodeUCS4_ClearFreelist@Base @VER@ + PyUnicodeUCS4_Compare@Base @VER@ + PyUnicodeUCS4_Concat@Base @VER@ + PyUnicodeUCS4_Contains@Base @VER@ + PyUnicodeUCS4_Count@Base @VER@ + PyUnicodeUCS4_Decode@Base @VER@ + PyUnicodeUCS4_DecodeASCII@Base @VER@ + PyUnicodeUCS4_DecodeCharmap@Base @VER@ + PyUnicodeUCS4_DecodeLatin1@Base @VER@ + PyUnicodeUCS4_DecodeRawUnicodeEscape@Base @VER@ + PyUnicodeUCS4_DecodeUTF16@Base @VER@ + PyUnicodeUCS4_DecodeUTF16Stateful@Base @VER@ + PyUnicodeUCS4_DecodeUTF32@Base @VER@ + PyUnicodeUCS4_DecodeUTF32Stateful@Base @VER@ + PyUnicodeUCS4_DecodeUTF8@Base @VER@ + PyUnicodeUCS4_DecodeUTF8Stateful@Base @VER@ + PyUnicodeUCS4_DecodeUnicodeEscape@Base @VER@ + PyUnicodeUCS4_Encode@Base @VER@ + PyUnicodeUCS4_EncodeASCII@Base @VER@ + PyUnicodeUCS4_EncodeCharmap@Base @VER@ + PyUnicodeUCS4_EncodeDecimal@Base @VER@ + PyUnicodeUCS4_EncodeLatin1@Base @VER@ + PyUnicodeUCS4_EncodeRawUnicodeEscape@Base @VER@ + PyUnicodeUCS4_EncodeUTF16@Base @VER@ + PyUnicodeUCS4_EncodeUTF32@Base @VER@ + PyUnicodeUCS4_EncodeUTF8@Base @VER@ + PyUnicodeUCS4_EncodeUnicodeEscape@Base @VER@ + PyUnicodeUCS4_Find@Base @VER@ + PyUnicodeUCS4_Format@Base @VER@ + PyUnicodeUCS4_FromEncodedObject@Base @VER@ + PyUnicodeUCS4_FromFormat@Base @VER@ + PyUnicodeUCS4_FromFormatV@Base @VER@ + PyUnicodeUCS4_FromObject@Base @VER@ + PyUnicodeUCS4_FromOrdinal@Base @VER@ + PyUnicodeUCS4_FromString@Base @VER@ + PyUnicodeUCS4_FromStringAndSize@Base @VER@ + PyUnicodeUCS4_FromUnicode@Base @VER@ + PyUnicodeUCS4_FromWideChar@Base @VER@ + PyUnicodeUCS4_GetDefaultEncoding@Base @VER@ + PyUnicodeUCS4_GetMax@Base @VER@ + PyUnicodeUCS4_GetSize@Base @VER@ + PyUnicodeUCS4_Join@Base @VER@ + PyUnicodeUCS4_Partition@Base @VER@ + PyUnicodeUCS4_RPartition@Base @VER@ + PyUnicodeUCS4_RSplit@Base @VER@ + PyUnicodeUCS4_Replace@Base @VER@ + PyUnicodeUCS4_Resize@Base @VER@ + PyUnicodeUCS4_RichCompare@Base @VER@ + PyUnicodeUCS4_SetDefaultEncoding@Base @VER@ + PyUnicodeUCS4_Split@Base @VER@ + PyUnicodeUCS4_Splitlines@Base @VER@ + PyUnicodeUCS4_Tailmatch@Base @VER@ + PyUnicodeUCS4_Translate@Base @VER@ + PyUnicodeUCS4_TranslateCharmap@Base @VER@ + PyUnicode_AsDecodedObject@Base @VER@ + PyUnicode_BuildEncodingMap@Base @VER@ + PyUnicode_DecodeUTF7@Base @VER@ + PyUnicode_DecodeUTF7Stateful@Base @VER@ + PyUnicode_EncodeUTF7@Base @VER@ + PyUnicode_Type@Base @VER@ + PyWeakref_GetObject@Base @VER@ + PyWeakref_NewProxy@Base @VER@ + PyWeakref_NewRef@Base @VER@ + PyWrapperDescr_Type@Base @VER@ + PyWrapper_New@Base @VER@ + Py_AddPendingCall@Base @VER@ + Py_AtExit@Base @VER@ + Py_BuildValue@Base @VER@ + Py_BytesWarningFlag@Base @VER@ + Py_CompileString@Base @VER@ + Py_CompileStringFlags@Base @VER@ + Py_DebugFlag@Base @VER@ + Py_DecRef@Base @VER@ + Py_DivisionWarningFlag@Base @VER@ + Py_DontWriteBytecodeFlag@Base @VER@ + Py_EndInterpreter@Base @VER@ + Py_Exit@Base @VER@ + Py_FatalError@Base @VER@ + Py_FdIsInteractive@Base @VER@ + Py_FileSystemDefaultEncoding@Base @VER@ + Py_Finalize@Base @VER@ + Py_FindMethod@Base @VER@ + Py_FindMethodInChain@Base @VER@ + Py_FlushLine@Base @VER@ + Py_FrozenFlag@Base @VER@ + Py_FrozenMain@Base @VER@ + Py_GetArgcArgv@Base @VER@ + Py_GetBuildInfo@Base @VER@ + Py_GetCompiler@Base @VER@ + Py_GetCopyright@Base @VER@ + Py_GetExecPrefix@Base @VER@ + Py_GetPath@Base @VER@ + Py_GetPlatform@Base @VER@ + Py_GetPrefix@Base @VER@ + Py_GetProgramFullPath@Base @VER@ + Py_GetProgramName@Base @VER@ + Py_GetPythonHome@Base @VER@ + Py_GetRecursionLimit@Base @VER@ + Py_GetVersion@Base @VER@ + Py_HashRandomizationFlag@Base @VER@ + Py_IgnoreEnvironmentFlag@Base @VER@ + Py_IncRef@Base @VER@ + Py_Initialize@Base @VER@ + Py_InitializeEx@Base @VER@ + Py_InspectFlag@Base @VER@ + Py_InteractiveFlag@Base @VER@ + Py_IsInitialized@Base @VER@ + Py_Main@Base @VER@ + Py_MakePendingCalls@Base @VER@ + Py_NewInterpreter@Base @VER@ + Py_NoSiteFlag@Base @VER@ + Py_NoUserSiteDirectory@Base @VER@ + Py_OptimizeFlag@Base @VER@ + Py_Py3kWarningFlag@Base @VER@ + Py_ReprEnter@Base @VER@ + Py_ReprLeave@Base @VER@ + Py_SetProgramName@Base @VER@ + Py_SetPythonHome@Base @VER@ + Py_SetRecursionLimit@Base @VER@ + Py_SubversionRevision@Base @VER@ + Py_SubversionShortBranch@Base @VER@ + Py_SymtableString@Base @VER@ + Py_TabcheckFlag@Base @VER@ + Py_UnicodeFlag@Base @VER@ + Py_UniversalNewlineFgets@Base @VER@ + Py_UniversalNewlineFread@Base @VER@ + Py_UseClassExceptionsFlag@Base @VER@ + Py_VaBuildValue@Base @VER@ + Py_VerboseFlag@Base @VER@ + Py_meta_grammar@Base @VER@ + Py_pgen@Base @VER@ + _PyArg_NoKeywords@Base @VER@ + _PyArg_ParseTupleAndKeywords_SizeT@Base @VER@ + _PyArg_ParseTuple_SizeT@Base @VER@ + _PyArg_Parse_SizeT@Base @VER@ + _PyArg_VaParseTupleAndKeywords_SizeT@Base @VER@ + _PyArg_VaParse_SizeT@Base @VER@ + _PyBuiltin_Init@Base @VER@ + _PyByteArray_empty_string@Base @VER@ + _PyBytes_FormatAdvanced@Base @VER@ + _PyCode_CheckLineNumber@Base @VER@ + _PyCodec_Lookup@Base @VER@ + _PyComplex_FormatAdvanced@Base @VER@ + _PyDict_Contains@Base @VER@ + _PyDict_MaybeUntrack@Base @VER@ + _PyDict_NewPresized@Base @VER@ + _PyDict_Next@Base @VER@ + _PyErr_BadInternalCall@Base @VER@ + _PyEval_CallTracing@Base @VER@ + _PyEval_SliceIndex@Base @VER@ + _PyExc_Fini@Base @VER@ + _PyExc_Init@Base @VER@ + (optional)_PyFileIO_closed@Base @VER@ + _PyFile_SanitizeMode@Base @VER@ + _PyFloat_FormatAdvanced@Base @VER@ + _PyFloat_Init@Base @VER@ + _PyFloat_Pack4@Base @VER@ + _PyFloat_Pack8@Base @VER@ + _PyFloat_Unpack4@Base @VER@ + _PyFloat_Unpack8@Base @VER@ + _PyFrame_Init@Base @VER@ + _PyGC_Dump@Base @VER@ + _PyGC_generation0@Base @VER@ + _PyGILState_Fini@Base @VER@ + _PyGILState_Init@Base @VER@ + (optional)_PyIOBase_check_closed@Base @VER@ + (optional)_PyIOBase_check_readable@Base @VER@ + (optional)_PyIOBase_check_seekable@Base @VER@ + (optional)_PyIOBase_check_writable@Base @VER@ + (optional)_PyIOBase_finalize@Base @VER@ + (optional)_PyIO_ConvertSsize_t@Base @VER@ + (optional)_PyIO_empty_bytes@Base @VER@ + (optional)_PyIO_empty_str@Base @VER@ + (optional)_PyIO_find_line_ending@Base @VER@ + (optional)_PyIO_locale_module@Base @VER@ + (optional)_PyIO_os_module@Base @VER@ + (optional)_PyIO_str_close@Base @VER@ + (optional)_PyIO_str_closed@Base @VER@ + (optional)_PyIO_str_decode@Base @VER@ + (optional)_PyIO_str_encode@Base @VER@ + (optional)_PyIO_str_fileno@Base @VER@ + (optional)_PyIO_str_flush@Base @VER@ + (optional)_PyIO_str_getstate@Base @VER@ + (optional)_PyIO_str_isatty@Base @VER@ + (optional)_PyIO_str_newlines@Base @VER@ + (optional)_PyIO_str_nl@Base @VER@ + (optional)_PyIO_str_read1@Base @VER@ + (optional)_PyIO_str_read@Base @VER@ + (optional)_PyIO_str_readable@Base @VER@ + (optional)_PyIO_str_readinto@Base @VER@ + (optional)_PyIO_str_readline@Base @VER@ + (optional)_PyIO_str_reset@Base @VER@ + (optional)_PyIO_str_seek@Base @VER@ + (optional)_PyIO_str_seekable@Base @VER@ + (optional)_PyIO_str_setstate@Base @VER@ + (optional)_PyIO_str_tell@Base @VER@ + (optional)_PyIO_str_truncate@Base @VER@ + (optional)_PyIO_str_writable@Base @VER@ + (optional)_PyIO_str_write@Base @VER@ + (optional)_PyIO_trap_eintr@Base @VER@ + (optional)_PyIO_unsupported_operation@Base @VER@ + (optional)_PyIO_zero@Base @VER@ + _PyImportHooks_Init@Base @VER@ + _PyImport_AcquireLock@Base @VER@ + _PyImport_DynLoadFiletab@Base @VER@ + _PyImport_Filetab@Base @VER@ + _PyImport_FindExtension@Base @VER@ + _PyImport_FindModule@Base @VER@ + _PyImport_Fini@Base @VER@ + _PyImport_FixupExtension@Base @VER@ + _PyImport_GetDynLoadFunc@Base @VER@ + _PyImport_Init@Base @VER@ + _PyImport_Inittab@Base @VER@ + _PyImport_IsScript@Base @VER@ + _PyImport_LoadDynamicModule@Base @VER@ + _PyImport_ReleaseLock@Base @VER@ + _PyImport_ReInitLock@Base @VER@ + (optional)_PyIncrementalNewlineDecoder_decode@Base @VER@ + _PyInstance_Lookup@Base @VER@ + _PyInt_AsInt@Base @VER@ + _PyInt_Format@Base @VER@ + _PyInt_FormatAdvanced@Base @VER@ + _PyInt_FromGid@Base @VER@ + _PyInt_FromUid@Base @VER@ + _PyInt_Init@Base @VER@ + _PyList_Extend@Base @VER@ + _PyLong_AsByteArray@Base @VER@ + _PyLong_AsInt@Base @VER@ + _PyLong_Copy@Base @VER@ + _PyLong_DigitValue@Base @VER@ + _PyLong_Format@Base @VER@ + _PyLong_FormatAdvanced@Base @VER@ + _PyLong_Frexp@Base @VER@ + _PyLong_FromByteArray@Base @VER@ + _PyLong_Init@Base @VER@ + _PyLong_New@Base @VER@ + _PyLong_NumBits@Base @VER@ + _PyLong_Sign@Base @VER@ + _PyModule_Clear@Base @VER@ + _PyNode_SizeOf@Base @VER@ + _PyNumber_ConvertIntegralToInt@Base @VER@ + _PyOS_GetOpt@Base @VER@ + _PyOS_ReadlineTState@Base @VER@ + _PyOS_ResetGetOpt@Base @VER@ + _PyOS_URandom@Base @VER@ + _PyOS_ascii_formatd@Base @VER@ + _PyOS_ascii_strtod@Base @VER@ + _PyOS_optarg@Base @VER@ + _PyOS_opterr@Base @VER@ + _PyOS_optind@Base @VER@ + _PyObject_CallFunction_SizeT@Base @VER@ + _PyObject_CallMethod_SizeT@Base @VER@ + _PyObject_Del@Base @VER@ + _PyObject_Dump@Base @VER@ + _PyObject_GC_Del@Base @VER@ + _PyObject_GC_Malloc@Base @VER@ + _PyObject_GC_New@Base @VER@ + _PyObject_GC_NewVar@Base @VER@ + _PyObject_GC_Resize@Base @VER@ + _PyObject_GC_Track@Base @VER@ + _PyObject_GC_UnTrack@Base @VER@ + _PyObject_GenericGetAttrWithDict@Base @VER@ + _PyObject_GenericSetAttrWithDict@Base @VER@ + _PyObject_GetDictPtr@Base @VER@ + _PyObject_LengthHint@Base @VER@ + _PyObject_LookupSpecial@Base @VER@ + _PyObject_New@Base @VER@ + _PyObject_NewVar@Base @VER@ + _PyObject_NextNotImplemented@Base @VER@ + _PyObject_RealIsInstance@Base @VER@ + _PyObject_RealIsSubclass@Base @VER@ + _PyObject_SlotCompare@Base @VER@ + _PyObject_Str@Base @VER@ + _PyParser_Grammar@Base @VER@ + _PyParser_TokenNames@Base @VER@ + _PyRandom_Init@Base @VER@ + _PySequence_IterSearch@Base @VER@ + _PySet_Next@Base @VER@ + _PySet_NextEntry@Base @VER@ + _PySet_Update@Base @VER@ + _PySlice_FromIndices@Base @VER@ + _PyString_Eq@Base @VER@ + _PyString_FormatLong@Base @VER@ + _PyString_InsertThousandsGrouping@Base @VER@ + _PyString_Join@Base @VER@ + _PyString_Resize@Base @VER@ + _PySys_Init@Base @VER@ + _PyThreadState_Current@Base @VER@ + _PyThreadState_GetFrame@Base @VER@ + _PyThreadState_Init@Base @VER@ + _PyThreadState_Prealloc@Base @VER@ + _PyThread_CurrentFrames@Base @VER@ + _PyTime_DoubleToTimet@Base @VER@ + _PyTime_FloatTime@Base @VER@ + _PyTrash_delete_later@Base @VER@ + _PyTrash_delete_nesting@Base @VER@ + _PyTrash_deposit_object@Base @VER@ + _PyTrash_destroy_chain@Base @VER@ + _PyTrash_thread_deposit_object@Base @VER@ + _PyTrash_thread_destroy_chain@Base @VER@ + _PyTuple_MaybeUntrack@Base @VER@ + _PyTuple_Resize@Base @VER@ + _PyType_Lookup@Base @VER@ + _PyUnicodeUCS4_AsDefaultEncodedString@Base @VER@ + _PyUnicodeUCS4_Fini@Base @VER@ + _PyUnicodeUCS4_Init@Base @VER@ + _PyUnicodeUCS4_IsAlpha@Base @VER@ + _PyUnicodeUCS4_IsDecimalDigit@Base @VER@ + _PyUnicodeUCS4_IsDigit@Base @VER@ + _PyUnicodeUCS4_IsLinebreak@Base @VER@ + _PyUnicodeUCS4_IsLowercase@Base @VER@ + _PyUnicodeUCS4_IsNumeric@Base @VER@ + _PyUnicodeUCS4_IsTitlecase@Base @VER@ + _PyUnicodeUCS4_IsUppercase@Base @VER@ + _PyUnicodeUCS4_IsWhitespace@Base @VER@ + _PyUnicodeUCS4_ToDecimalDigit@Base @VER@ + _PyUnicodeUCS4_ToDigit@Base @VER@ + _PyUnicodeUCS4_ToLowercase@Base @VER@ + _PyUnicodeUCS4_ToNumeric@Base @VER@ + _PyUnicodeUCS4_ToTitlecase@Base @VER@ + _PyUnicodeUCS4_ToUppercase@Base @VER@ + _PyUnicode_BidirectionalNames@Base @VER@ + _PyUnicode_CategoryNames@Base @VER@ + _PyUnicode_Database_Records@Base @VER@ + _PyUnicode_DecodeUnicodeInternal@Base @VER@ + _PyUnicode_EastAsianWidthNames@Base @VER@ + _PyUnicode_FormatAdvanced@Base @VER@ + _PyUnicode_TypeRecords@Base @VER@ + _PyUnicode_XStrip@Base @VER@ + _PyWarnings_Init@Base @VER@ + _PyWeakref_CallableProxyType@Base @VER@ + _PyWeakref_ClearRef@Base @VER@ + _PyWeakref_GetWeakrefCount@Base @VER@ + _PyWeakref_ProxyType@Base @VER@ + _PyWeakref_RefType@Base @VER@ + _Py_Assert@Base @VER@ + _Py_Assign@Base @VER@ + _Py_Attribute@Base @VER@ + _Py_AugAssign@Base @VER@ + _Py_BinOp@Base @VER@ + _Py_BoolOp@Base @VER@ + _Py_Break@Base @VER@ + _Py_BuildValue_SizeT@Base @VER@ + _Py_Call@Base @VER@ + _Py_CheckInterval@Base @VER@ + _Py_CheckRecursionLimit@Base @VER@ + _Py_CheckRecursiveCall@Base @VER@ + _Py_ClassDef@Base @VER@ + _Py_Compare@Base @VER@ + _Py_Continue@Base @VER@ + _Py_Delete@Base @VER@ + _Py_Dict@Base @VER@ + _Py_DictComp@Base @VER@ + _Py_DisplaySourceLine@Base @VER@ + _Py_Ellipsis@Base @VER@ + _Py_EllipsisObject@Base @VER@ + _Py_ExceptHandler@Base @VER@ + _Py_Exec@Base @VER@ + _Py_Expr@Base @VER@ + _Py_Expression@Base @VER@ + _Py_ExtSlice@Base @VER@ + _Py_For@Base @VER@ + _Py_FunctionDef@Base @VER@ + _Py_GeneratorExp@Base @VER@ + _Py_Gid_Converter@Base @VER@ + _Py_Global@Base @VER@ + _Py_HashDouble@Base @VER@ + _Py_HashPointer@Base @VER@ + _Py_HashSecret@Base @VER@ + _Py_If@Base @VER@ + _Py_IfExp@Base @VER@ + _Py_Import@Base @VER@ + _Py_ImportFrom@Base @VER@ + _Py_Index@Base @VER@ + _Py_InsertThousandsGroupingLocale@Base @VER@ + _Py_Interactive@Base @VER@ + _Py_Lambda@Base @VER@ + _Py_List@Base @VER@ + _Py_ListComp@Base @VER@ + _Py_Mangle@Base @VER@ + _Py_Module@Base @VER@ + _Py_Name@Base @VER@ + _Py_NoneStruct@Base @VER@ + _Py_NotImplementedStruct@Base @VER@ + _Py_Num@Base @VER@ + _Py_PackageContext@Base @VER@ + _Py_Pass@Base @VER@ + _Py_Print@Base @VER@ + _Py_QnewFlag@Base @VER@ + _Py_Raise@Base @VER@ + _Py_ReadyTypes@Base @VER@ + _Py_ReleaseInternedStrings@Base @VER@ + _Py_Repr@Base @VER@ + _Py_Return@Base @VER@ + _Py_Set@Base @VER@ + _Py_SetComp@Base @VER@ + _Py_Slice@Base @VER@ + _Py_Str@Base @VER@ + _Py_Subscript@Base @VER@ + _Py_Suite@Base @VER@ + _Py_SwappedOp@Base @VER@ + _Py_Ticker@Base @VER@ + _Py_TrueStruct@Base @VER@ + _Py_TryExcept@Base @VER@ + _Py_TryFinally@Base @VER@ + _Py_Tuple@Base @VER@ + _Py_Uid_Converter@Base @VER@ + _Py_UnaryOp@Base @VER@ + _Py_VaBuildValue_SizeT@Base @VER@ + _Py_While@Base @VER@ + _Py_With@Base @VER@ + _Py_Yield@Base @VER@ + _Py_ZeroStruct@Base @VER@ + _Py_abstract_hack@Base @VER@ + _Py_add_one_to_index_C@Base @VER@ + _Py_add_one_to_index_F@Base @VER@ + (optional)_Py_acosh@Base @VER@ + _Py_addarc@Base @VER@ + _Py_addbit@Base @VER@ + _Py_adddfa@Base @VER@ + _Py_addfirstsets@Base @VER@ + _Py_addlabel@Base @VER@ + _Py_addstate@Base @VER@ + _Py_alias@Base @VER@ + _Py_arguments@Base @VER@ + _Py_ascii_whitespace@Base @VER@ + (optional)_Py_asinh@Base @VER@ + (optional)_Py_atanh@Base @VER@ + _Py_bytes_capitalize@Base @VER@ + _Py_bytes_isalnum@Base @VER@ + _Py_bytes_isalpha@Base @VER@ + _Py_bytes_isdigit@Base @VER@ + _Py_bytes_islower@Base @VER@ + _Py_bytes_isspace@Base @VER@ + _Py_bytes_istitle@Base @VER@ + _Py_bytes_isupper@Base @VER@ + _Py_bytes_lower@Base @VER@ + _Py_bytes_swapcase@Base @VER@ + _Py_bytes_title@Base @VER@ + _Py_bytes_upper@Base @VER@ + _Py_c_abs@Base @VER@ + _Py_c_diff@Base @VER@ + _Py_c_neg@Base @VER@ + _Py_c_pow@Base @VER@ + _Py_c_prod@Base @VER@ + _Py_c_quot@Base @VER@ + _Py_c_sum@Base @VER@ + _Py_capitalize__doc__@Base @VER@ + _Py_capsule_hack@Base @VER@ + _Py_cobject_hack@Base @VER@ + _Py_comprehension@Base @VER@ + _Py_ctype_table@Base @VER@ + _Py_ctype_tolower@Base @VER@ + _Py_ctype_toupper@Base @VER@ + _Py_delbitset@Base @VER@ + (arch=!m68k)_Py_dg_dtoa@Base @VER@ + (arch=!m68k)_Py_dg_freedtoa@Base @VER@ + (arch=!m68k)_Py_dg_strtod@Base @VER@ + _Py_double_round@Base @VER@ + (optional)_Py_expm1@Base @VER@ + _Py_findlabel@Base @VER@ + (arch=i386 lpia m68k)_Py_force_double@Base @VER@ + (arch=amd64 i386 lpia)_Py_get_387controlword@Base @VER@ + _Py_hgidentifier@Base 2.7.1 + _Py_hgversion@Base 2.7.1 + _Py_isalnum__doc__@Base @VER@ + _Py_isalpha__doc__@Base @VER@ + _Py_isdigit__doc__@Base @VER@ + _Py_islower__doc__@Base @VER@ + _Py_isspace__doc__@Base @VER@ + _Py_istitle__doc__@Base @VER@ + _Py_isupper__doc__@Base @VER@ + _Py_keyword@Base @VER@ + (optional)_Py_log1p@Base @VER@ + _Py_lower__doc__@Base @VER@ + _Py_mergebitset@Base @VER@ + _Py_meta_grammar@Base @VER@ + _Py_newbitset@Base @VER@ + _Py_newgrammar@Base @VER@ + (optional)_Py_parse_inf_or_nan@Base @VER@ + _Py_pgen@Base @VER@ + _Py_samebitset@Base @VER@ + (arch=amd64 i386 lpia)_Py_set_387controlword@Base @VER@ + _Py_svnversion@Base @VER@ + _Py_swapcase__doc__@Base @VER@ + _Py_title__doc__@Base @VER@ + _Py_translatelabels@Base @VER@ + _Py_upper__doc__@Base @VER@ + + PyFPE_counter@Base @VER@ + PyFPE_dummy@Base @VER@ + PyFPE_jbuf@Base @VER@ + + asdl_int_seq_new@Base @VER@ + asdl_seq_new@Base @VER@ + +# don't check for the following symbols, found in extensions +# which either can be built as builtin or extension. + + (optional)fast_save_leave@Base @VER@ + (optional)partial_reduce@Base @VER@ + (optional)partial_setstate@Base @VER@ + + (optional)md5_append@Base @VER@ + (optional)md5_finish@Base @VER@ + (optional)md5_init@Base @VER@ + +# _check_for_multiple_distdirs@Base @VER@ + (optional)init_ast@Base @VER@ + (optional)init_bisect@Base @VER@ + (optional)init_codecs@Base @VER@ + (optional)init_collections@Base @VER@ + (optional)init_functools@Base @VER@ + (optional)init_hashlib@Base @VER@ + (optional)init_heapq@Base @VER@ + (optional)init_io@Base @VER@ + (optional)init_locale@Base @VER@ + (optional)init_md5@Base @VER@ + (optional)init_random@Base @VER@ + (optional)init_sha@Base @VER@ + (optional)init_sha256@Base @VER@ + (optional)init_sha512@Base @VER@ + (optional)init_socket@Base @VER@ + (optional)init_sockobject@Base @VER@ + (optional)init_sre@Base @VER@ + (optional)init_ssl@Base @VER@ + (optional)init_struct@Base @VER@ + (optional)init_symtable@Base @VER@ + (optional)init_weakref@Base @VER@ + (optional)initarray@Base @VER@ + (optional)initbinascii@Base @VER@ + (optional)initcPickle@Base @VER@ + (optional)initcStringIO@Base @VER@ + (optional)initcmath@Base @VER@ + (optional)initerrno@Base @VER@ + (optional)initfcntl@Base @VER@ + (optional)initgc@Base @VER@ + (optional)initgrp@Base @VER@ + (optional)initimp@Base @VER@ + (optional)inititertools@Base @VER@ + (optional)initmath@Base @VER@ + (optional)initoperator@Base @VER@ + (optional)initposix@Base @VER@ + (optional)initpwd@Base @VER@ + (optional)initselect@Base @VER@ + (optional)initsignal@Base @VER@ + (optional)initspwd@Base @VER@ + (optional)initstrop@Base @VER@ + (optional)initsyslog@Base @VER@ + (optional)initthread@Base @VER@ + (optional)inittime@Base @VER@ + (optional)initunicodedata@Base @VER@ + (optional)initxxsubtype@Base @VER@ + (optional)initzipimport@Base @VER@ + (optional)initzlib@Base @VER@ --- python2.7-2.7.5.orig/debian/changelog +++ python2.7-2.7.5/debian/changelog @@ -0,0 +1,3441 @@ +python2.7 (2.7.5-8ubuntu3.1) saucy-security; urgency=medium + + * SECURITY UPDATE: denial of service and possible code execution via + buffer overflow in socket.recvfrom_into + - debian/patches/CVE-2014-1912.diff: check buffer length in + Modules/socketmodule.c, added tests to Lib/test/test_socket.py. + - CVE-2014-1912 + + -- Marc Deslauriers Thu, 27 Feb 2014 09:06:35 -0500 + +python2.7 (2.7.5-8ubuntu3) saucy; urgency=low + + * For autopkg tests, only run the separate tests when defined. + + -- Matthias Klose Thu, 19 Sep 2013 15:31:48 +0200 + +python2.7 (2.7.5-8ubuntu2) saucy; urgency=low + + * Don't run the curses autopkg test. + + -- Matthias Klose Thu, 19 Sep 2013 11:10:47 +0200 + +python2.7 (2.7.5-8ubuntu1) saucy; urgency=low + + * Merge with Debian; remaining changes: + - Regenerate the control file. + + -- Matthias Klose Wed, 18 Sep 2013 13:53:38 +0200 + +python2.7 (2.7.5-8) unstable; urgency=medium + + * Update to 20130917, taken from the 2.7 branch. + - Fix SSL module to handle NULL bytes inside subjectAltNames general + names (CVE-2013-4238). Closes: #719566. + * Don't run the curses autopkg test. + * Set Multi-Arch attributes for binary packages. + * Fix multiarch include header for sparc64. Closes: #714802, #715063. + + -- Matthias Klose Tue, 17 Sep 2013 15:47:45 +0200 + +python2.7 (2.7.5-7) unstable; urgency=low + + * Update to 20130803, taken from the 2.7 branch. + * Update package descriptions (Filipus Klutiero). Closes: #715801. + * Fix multiarch include header for sparc64. Closes: #715063. + * Move removal of the sitecustomize.py file into the libpython-minimal + postrm. Closes: #709964. + + -- Matthias Klose Sun, 04 Aug 2013 11:56:52 +0200 + +python2.7 (2.7.5-6) unstable; urgency=low + + * Update to 20130613, taken from the 2.7 branch. + * Refresh patches. + * Don't run consistency check for cross builds. + * Really skip byte compile of non-existing sitecustomize.py. + * Fix the multiarch header file for mips64 (YunQiang Su). Closes: #710374. + + -- Matthias Klose Thu, 13 Jun 2013 13:06:51 +0200 + +python2.7 (2.7.5-5) unstable; urgency=low + + * Update to 20130602, taken from the 2.7 branch. + * Fix possible abuse of ssl.match_hostname() for denial of service + using certificates with many wildcards (CVE-2013-2099). Closes: #709066. + * Don't try to byte-compile sitecustomize.py if the target of the + symlink doesn't exist anymore. Closes: #709157. + * Handle byte compilation in python2.7{-minimal,}, byte removal in + libpython2.7{-minimal,-stdlib}. Closes: #709964. + * Backport patch to fix issue #13146, possible race conditions when writing + .pyc/.pyo files in py_compile.py (Barry Warsaw). LP: #1058884. + * Fix issue #17988, internal error in regular expression engine on 32bit + targets (closes: #710315). + + -- Matthias Klose Sun, 02 Jun 2013 15:11:19 +0200 + +python2.7 (2.7.5-4) unstable; urgency=low + + * Move the libc dependency of -minimal from Depends to Pre-Depends. + Closes: #708831. + * Disable the test_io test on armel, armhf, mips, mipsel. Hangs the + buildds. + + -- Matthias Klose Mon, 20 May 2013 12:21:06 +0200 + +python2.7 (2.7.5-3) unstable; urgency=high + + * Fix the multiarch header file for ppc64. Closes: #708641. + + -- Matthias Klose Sat, 18 May 2013 20:18:38 +0200 + +python2.7 (2.7.5-2) unstable; urgency=low + + * Only run the _multiprocessing build check on linux targets. + + -- Matthias Klose Wed, 15 May 2013 22:09:30 +0200 + +python2.7 (2.7.5-1) unstable; urgency=low + + * Python 2.7.5 release. + * Set the platinclude dir back to the non-multiarch include path, + where the multiarch pyconfig.h compatibility header is found. + * Fix issue #17703: Fix a regression where an illegal use of Py_DECREF() + after interpreter finalization can cause a crash. + * Issue #17754, setting LANG and LC_ALL for the compiler call in ctypes/util. + * Issue #17761, platform._parse_release_file doesn't close the + /etc/lsb-release file, and doesn't know about 'Ubuntu'. + * Fix autopkg tests. + * Re-enable lto and pgo optimized builds, accidentally disabled for the + last upload. + * more autopkg test fixes. + * Link the ctypes extension with the shared libffi library. + * Fix a distutils test with the deb install layout. + * Move lib2to3 library into libpython2.7-stdlib. Closes: #705078. + * Don't set yet any Multi-Arch: attributes in Debian. + + -- Matthias Klose Wed, 15 May 2013 15:02:13 +0200 + +python2.7 (2.7.4-2) experimental; urgency=low + + * Idle updates: + - Issue #17657: Show full Tk version in IDLE's about dialog. + - Issue #17613: Prevent traceback when removing syntax colorizer. + - Issue #1207589: Backwards-compatibility patch for right-click menu. + - Issue #16887: Now accepts Cancel in tabify/untabify dialog box. + - Issue #14254: Now handles readline correctly across shell restarts. + - Issue #17614: No longer raises exception when quickly closing a file. + - Issue #6698: Now opens just an editor window when configured to do so. + - Issue #8900: Using keyboard shortcuts in IDLE to open a file no longer + raises an exception. + - Issue #6649: Fixed missing exit status. + * Build a libpython2.7-testsuite package. LP: #301629. + * Add autopkg tests to run the installed testsuite in normal and debug + mode. + * Re-enable running the tests during the build. + * Add the io and _io modules to libpython2.7-minimal. + * Backport ssl.CertificateError as well. Closes: #626539. LP: #1166344. + * Don't ship an uncompress python man page. Closes: #705079. + + -- Matthias Klose Thu, 11 Apr 2013 00:44:48 +0200 + +python2.7 (2.7.4-1ubuntu4) raring; urgency=low + + * Build a libpython2.7-testsuite package. LP: #301629. + * Add autopkg tests to run the installed testsuite in normal and debug + mode. + * Re-enable running the tests during the build. + * Idle updates: + - Issue #17657: Show full Tk version in IDLE's about dialog. + - Issue #17613: Prevent traceback when removing syntax colorizer. + - Issue #1207589: Backwards-compatibility patch for right-click menu. + - Issue #16887: Now accepts Cancel in tabify/untabify dialog box. + - Issue #14254: Now handles readline correctly across shell restarts. + - Issue #17614: No longer raises exception when quickly closing a file. + - Issue #6698: Now opens just an editor window when configured to do so. + - Issue #8900: Using keyboard shortcuts in IDLE to open a file no longer + raises an exception. + - Issue #6649: Fixed missing exit status. + + -- Matthias Klose Tue, 09 Apr 2013 17:53:02 +0200 + +python2.7 (2.7.4-1ubuntu3) raring; urgency=low + + * Add the io and _io modules to libpython2.7-minimal. LP: #1165172. + * Add missing import for the ssl module. LP: #1166644. + + -- Matthias Klose Tue, 09 Apr 2013 12:11:12 +0200 + +python2.7 (2.7.4-1ubuntu2) raring; urgency=low + + * Backport ssl.CertificateError as well. Closes: #626539. LP: #1166344. + + -- Matthias Klose Mon, 08 Apr 2013 20:59:52 +0200 + +python2.7 (2.7.4-1ubuntu1) raring; urgency=low + + * Merge with Debian; remaining changes: + - Build-depend on python:any instead of python. + + -- Matthias Klose Sat, 06 Apr 2013 17:45:49 +0200 + +python2.7 (2.7.4-1) experimental; urgency=low + + * Python 2.7.4 release. + - Issue #17550: Fix the --enable-profiling configure switch. + - Issue #15801 (again): With string % formatting, relax the type check + for a mapping such that any type with a __getitem__ can be used on the + right hand side. + - Issue #17625: In IDLE, close the replace dialog after it is used. + - Issue #17531: Fix tests that thought group and user ids were always + the int type. Also, always allow -1 as a valid group and user id. + - Issue 17538: Document XML vulnerabilties + * Byte-compile files in libpython2.7-dbg. + * libpython2.7-minimal: Break earlier python2.7-minimal versions. + Closes: #704084. LP: #1157687. + * Call python with -E -S for the byte compilation. + + -- Matthias Klose Sat, 06 Apr 2013 16:38:57 +0200 + +python2.7 (2.7.4~rc1-4) experimental; urgency=low + + * Fix byte-compiliation/-removal for the split-out library packages. + LP: #1160944. + + -- Matthias Klose Sat, 30 Mar 2013 12:51:58 +0100 + +python2.7 (2.7.4~rc1-3) experimental; urgency=low + + * Fix webbrowser update. Closes: #703872. LP: #1159636. + + -- Matthias Klose Mon, 25 Mar 2013 14:33:50 +0100 + +python2.7 (2.7.4~rc1-2) experimental; urgency=low + + * Backport webbrowser updates from 3.3. Closes: #700429. + * Build again using db-5.1 instead of db-5.3. + + -- Matthias Klose Sun, 24 Mar 2013 18:27:57 +0100 + +python2.7 (2.7.4~rc1-1) experimental; urgency=low + + * Python 2.7.4 release candidate 1. + - Issue #10211: Buffer objects expose the new buffer interface internally. + - Issue #10212: cStringIO and struct.unpack support new buffer objects. + - Issue #12098: multiprocessing on Windows now starts child processes + using the same sys.flags as the current process. + - Issue #8862: Fixed curses cleanup when getkey is interrputed by a signal. + - Issue #9090: When a socket with a timeout fails with EWOULDBLOCK or + EAGAIN, retry the select() loop instead of bailing out. + - Issue #1285086: Get rid of the refcounting hack and speed up + urllib.unquote(). + - Issue #17368: Fix an off-by-one error in the Python JSON decoder + that caused a failure while decoding empty object literals when + object_pairs_hook was specified. + - Issue #17477: Update the bsddb module to pybsddb 5.3.0, supporting + db-5.x, and dropping support for db-4.1 and db-4.2. + - Issue #17192: Update the ctypes module's libffi to v3.0.13. This + specifically addresses a stack misalignment issue on x86 and issues on + some more recent platforms. + - Issue #11420: make test suite pass with -B/DONTWRITEBYTECODE set. + - Issue #17299: Add test coverage for cPickle with file objects + and general IO objects. + - Issue #11963: remove human verification from test_parser and + test_subprocess. + - Issue #16004: Add `make touch`. + - Issue #17047: remove doubled words in docs and docstrings + * Rework the sysconfigdata patch into something upstreamable. + + -- Matthias Klose Sun, 24 Mar 2013 01:56:36 +0100 + +python2.7 (2.7.3-16ubuntu2) raring; urgency=low + + * Update to 20130315, taken from the 2.7 branch. + - Issue #1285086: Get rid of the refcounting hack and speed + up urllib.unquote(). + - Issue #17368: Fix an off-by-one error in the Python JSON decoder + that caused a failure while decoding empty object literals when + object_pairs_hook was specified. + - Issue #17299: Add test coverage for cPickle with file objects and general + IO objects. + - Issue #11963: Remove human verification from test_parser and + test_subprocess. + - Issue #16004: Add `make touch`. + - Issue #17412: Update 2.7 Doc/make.bat to also use sphinx-1.0.7. + - Issue #17047: Remove doubled words in docs and docstrings. + * Revert the patch for Issue #1159051, handling corrupted gzip files + with unexpected EOF. LP: #1116079. + + -- Matthias Klose Fri, 15 Mar 2013 12:20:10 -0700 + +python2.7 (2.7.3-16ubuntu1) raring; urgency=low + + * Merge with Debian; remaining changes: + - Build-depend on python:any instead of python. + * Update symbols files. + + -- Matthias Klose Fri, 08 Mar 2013 14:30:55 +0800 + +python2.7 (2.7.3-16) experimental; urgency=low + + * Update to 20130308, taken from the 2.7 branch. + - Issue #10156: In the interpreter's initialization phase, unicode globals + are now initialized dynamically as needed. + - Issue #16975: Fix error handling bug in the escape-decode decoder. + - Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase + interface and support all mandatory methods and properties. + - Issue #13454: Fix a crash when deleting an iterator created by + itertools.tee() if all other iterators were very advanced before. + - Issue #3754: fix typo in pthread AC_CACHE_VAL. + - Issue #17029: Let h2py search the multiarch system include directory. + - Issue #16445: Fixed potential segmentation fault when deleting an + exception message. + - Issue #17275: Corrected class name in init error messages of the + C version of BufferedWriter and BufferedRandom. + - Issue #7963: Fixed misleading error message that issued when object is + called without arguments. + - Issue #5308: Raise ValueError when marshalling too large object (a + sequence with size >= 2**31), instead of producing illegal marshal data. + - Issue #17043: The unicode-internal decoder no longer read past the end of + input buffer. + - Issue #16979: Fix error handling bugs in the unicode-escape-decode + decoder. + - Issue #17278: Fix a crash in heapq.heappush() and heapq.heappop() when + the list is being resized concurrently. + - Issue #17018: Make Process.join() retry if os.waitpid() fails with EINTR. + - Issue #14720: sqlite3: Convert datetime microseconds correctly. + - Issue #17225: JSON decoder now counts columns in the first line starting + with 1, as in other lines. + - Issue #7842: backported fix for py_compile.compile() syntax error + handling. + - Issue #13153: Tkinter functions now raise TclError instead of ValueError + when a unicode argument contains non-BMP character. + - Issue #9669: Protect re against infinite loops on zero-width matching in + non-greedy repeat. + - Issue #13169: The maximal repetition number in a regular expression + has been increased from 65534 to 2147483647 (on 32-bit platform) or + 4294967294 (on 64-bit). + - Issue #11311: StringIO.readline(0) now returns an empty string + as all other file-like objects. + - Issue #16800: tempfile.gettempdir() no longer left temporary files when + the disk is full. Original patch by Amir Szekely. + - Issue #13555: cPickle now supports files larger than 2 GiB. + - Issue #17052: unittest discovery should use self.testLoader. + - Issue #4591: Uid and gid values larger than 2**31 are supported now. + - Issue #17141: random.vonmisesvariate() no more hangs for large kappas. + - Issue #17149: Fix random.vonmisesvariate to always return results in + the range [0, 2*math.pi]. + - Issue #1470548: XMLGenerator now works with UTF-16 and UTF-32 encodings. + - Issue #6975: os.path.realpath() now correctly resolves multiple nested + symlinks on POSIX platforms. + - Issue #17156: pygettext.py now correctly escapes non-ascii characters. + - Issue #7358: cStringIO.StringIO now supports writing to and reading from + a stream larger than 2 GiB on 64-bit systems. + - IDLE was displaying spurious SystemExit tracebacks when running scripts + that terminated by raising SystemExit (i.e. unittest and turtledemo). + - Issue #10355: In SpooledTemporaryFile class mode and name properties and + xreadlines method now work for unrolled files. encoding and newlines + - Issue #16686: Fixed a lot of bugs in audioop module. + - Issue #17073: Fix some integer overflows in sqlite3 module. + - Issue #6083: Fix multiple segmentation faults occured when + PyArg_ParseTuple parses nested mutating sequence. + - Issue #5289: Fix ctypes.util.find_library on Solaris. + - Issue #17106: Fix a segmentation fault in io.TextIOWrapper when an + underlying stream or a decoder produces data of an unexpected type (i.e. + when io.TextIOWrapper initialized with text stream or use bytes-to-bytes + codec). + - Issue #13994: Add compatibility alias in distutils.ccompiler for + distutils.sysconfig.customize_compiler. + - Issue #15633: httplib.HTTPResponse is now mark closed when the server + sends less than the advertised Content-Length. + - Issue #15881: Fixed atexit hook in multiprocessing. + - Issue #14340: Upgrade the embedded expat library to version 2.1.0. + - Issue #11159: SAX parser now supports unicode file names. + - Issue #6972: The zipfile module no longer overwrites files outside of + its destination path when extracting malicious zip files. + - Issue #17049: Localized calendar methods now return unicode if a locale + includes an encoding and the result string contains month or weekday (was + regression from Python 2.6). + - Issue #4844: ZipFile now raises BadZipfile when opens a ZIP file with an + incomplete "End of Central Directory" record. + - Issue #15505: `unittest.installHandler` no longer assumes SIGINT handler + is set to a callable object. + - Issue #17051: Fix a memory leak in os.path.isdir() on Windows. + - Issue #12268: The io module file object write methods no longer abort + early when a write system calls is interrupted (EINTR). + - Issue #17249: convert a test in test_capi to use unittest and reap + threads. + - We now run both test_email.py and test_email_renamed.py when running the + test_email regression test. test_email_renamed contains some tests that + test_email does not. + - Issue #17041: Fix testing when Python is configured with the + --without-doc-strings option. + - Issue #5033: Fix building of the sqlite3 extension module when the + SQLite library version has "beta" in it. + - Issue #17228: Fix building without pymalloc. + - Issue #17086: Backport the patches from the 3.3 branch to cross-build + the package. + - Issue #16406: combine the pages for uploading and registering to PyPI. + - Issue #16403: Document how distutils uses the maintainer field in + PKG-INFO. + - Issue #16695: Document how glob handles filenames starting with a dot. + - Issue #8890: Stop advertising an insecure practice by replacing uses + of the /tmp directory with better alternatives in the documentation. + - Issue #17203: add long option names to unittest discovery docs. + * python2.7-dbg, libpython2.7-dbg: Drop dependency on python. + * python2.7-dbg: Make gdb (not gdb-minimal) a recommendation. + * python2.7: Replace python2.7-minimal (<< 2.7.3-7). Closes: #702005. + * Build the _md5, _sha1, _sha256 and _sha512 extension modules. + * Fix multiarch include for AArch64. + + -- Matthias Klose Fri, 08 Mar 2013 09:54:59 +0800 + +python2.7 (2.7.3-15) experimental; urgency=low + + * Update to 20130124, taken from the 2.7 branch. + - Issue #14850: Now a charmap decoder treats U+FFFE as "undefined mapping" + in any mapping, not only in a Unicode string. + - Issue #11461: Fix the incremental UTF-16 decoder. + - Issue #1159051: GzipFile now raises EOFError when reading a corrupted + file with truncated header or footer. + - Issue #16992: On Windows in signal.set_wakeup_fd, validate the file + descriptor argument. + - Issue #15861: tkinter now correctly works with lists and tuples + containing strings with whitespaces, backslashes or unbalanced braces. + - Issue #10527: Use poll() instead of select() for multiprocessing pipes. + - Issue #9720: zipfile now writes correct local headers for files larger + than 4 GiB. + - Issue #16829: IDLE printing no longer fails if there are spaces or other + special characters in the file path. + - Issue #13899: \A, \Z, and \B now correctly match the A, Z, and B literals + when used inside character classes (e.g. '[\A]'). + - Issue #16398: Optimize deque.rotate() so that it only moves pointers + and doesn't touch the underlying data with increfs and decrefs. + - Issue #15109: Fix regression in sqlite3's iterdump method where it would + die with an encoding error if the database contained string values + containing non-ASCII. + - Issue #15545: Fix regression in sqlite3's iterdump method where it was + failing if the connection used a row factory (such as sqlite3.Row) that + produced unsortable objects. + - Issue #16953: Fix socket module compilation on platforms with + HAVE_BROKEN_POLL. + - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the + build host. + - Issue #15539: Fix a number of bugs in Tools/scripts/pindent.py. + * Backport cross-build support from python3.3. LP: #873007. + * Add pyconfig.h compatibility headers. Closes: #695667. LP: #1094246. + + -- Matthias Klose Thu, 24 Jan 2013 14:57:08 +0100 + +python2.7 (2.7.3-14) experimental; urgency=low + + * Update to 20130105, taken from the 2.7 branch. + - Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB. + - Issue #15516: Fix a bug in PyString_FromFormat where it failed + to properly ignore errors from a __int__() method. + - Issue #16839: Fix a segfault when calling unicode() on a classic class + early in interpreter initialization. + - Issue #16761: Calling ``int()`` and ``long()`` with *base* argument only + now raises TypeError. + - Issue #16828: Fix error incorrectly raised by bz2.compress(''). + LP: #1090043. + - Issue #16819: IDLE method completion now correctly works for unicode + literals. + - Issue 10527: make multiprocessing use poll() instead of select() + if available. + - Issue #16485: Now file descriptors are closed if file header patching + failed on closing an aifc file. + - Issue #12065: connect_ex() on an SSL socket now returns the original + errno when the socket's timeout expires (it used to return None). + - Issue #16504: IDLE now catches SyntaxErrors raised by tokenizer. + - Issue #16702: test_urllib2_localnet tests now correctly ignores proxies + for localhost tests. + - Issue #16713: Fix the parsing of tel url with params using urlparse + module. + - Issue #16443: Add docstrings to regular expression match objects. + - Issue #8853: Allow port to be of type long for socket.getaddrinfo(). + - Issue #16597: In buffered and text IO, call close() on the underlying + stream if invoking flush() fails. + - Issue #15701: Fix HTTPError info method call to return the headers + information. + - Issue #14958: Change IDLE systax highlighting to recognize all string + and byte literals currently supported in Python 2.7. + - Issue #15324: Fix regrtest parsing of --fromfile and --randomize options. + - Issue #16618: Add more regression tests for glob. + - Issue #13094: add "Why do lambdas defined in a loop with different values + all return the same result?" programming FAQ. + * python-config --help returns with an exit value 0. LP: #1093860. + * Update package description for the -dbg packages. Closes: #696616. + + -- Matthias Klose Sat, 05 Jan 2013 17:22:13 +0100 + +python2.7 (2.7.3-13) experimental; urgency=low + + * Update to 20121220, taken from the 2.7 branch. + - Issue #16646: ftplib.FTP.makeport() might lose socket error details. + - Issue #16298: In HTTPResponse.read(), close the socket when there is no + Content-Length and the incoming stream is finished. + * Filter out -D_FORTIFY_SOURCE for the debug builds. Meaningless. + * Install the _sysconfigdata.py and python-config.sh from both shared + builds, but don't link extensions against the shared python library. + Closes: #695979. + * Fix python2.7-dbg-config symlink. LP: #1091615. + * During purge, check for existance of /etc/python2.7 before trying + to remove it. Closes: #696023. + * python2.7-dev, libpython2.7-dev: Drop the dependency on libssl-dev. + * debian/patches/sys-multiarch.diff: Expose multiarch tuple as + sys._multiarch (Barry Warsaw). Closes: #695958. + Note: Usage of sysconfig.get_config_var('MULTIARCH') is preferred. + + -- Matthias Klose Thu, 20 Dec 2012 16:57:49 +0100 + +python2.7 (2.7.3-12) experimental; urgency=low + + * Fix typo in pkgconfig file. Closes: #695671, LP: #1088988. + + -- Matthias Klose Mon, 10 Dec 2012 19:10:32 +0100 + +python2.7 (2.7.3-11) experimental; urgency=low + + * Update to 20121210, taken from the 2.7 branch. + - Issue #16602: When a weakref's target was part of a long deallocation + chain, the object could remain reachable through its weakref even though + its refcount had dropped to zero. + - Issue #16588: Silence unused-but-set warnings in Python/thread_pthread. + - Issue #16248: Disable code execution from the user's home directory by + tkinter when the -E flag is passed to Python. Patch by Zachary Ware. + - Issue #16628: Fix a memory leak in ctypes.resize(). + - Issue #13614: Fix setup.py register failure with invalid rst in + description. + - Issue #10182: The re module doesn't truncate indices to 32 bits anymore. + - Issue #16573: In 2to3, treat enumerate() like a consuming call, so + superfluous list() calls aren't added to filter(), map(), and zip() + which are directly passed enumerate(). + - Issue #16476: Fix json.tool to avoid including trailing whitespace. + - Issue #16549: Add tests for json.tools. + - Issue #15990: Improve argument/parameter documentation. + * Use _sysconfigdata.py in distutils.sysconfig. + * Fix distutils.sysconfig.get_{config_h,makefile}_filename for multiarch. + * Backport ssl.match_hostname from Python3. Closes: #626539. + + -- Matthias Klose Mon, 10 Dec 2012 16:06:41 +0100 + +python2.7 (2.7.3-10) experimental; urgency=low + + * Update to 20121128, taken from the 2.7 branch. + - Issue #9011: Fix hacky AST code that modified the CST when compiling + a negated numeric literal. + - Issue #16306: Fix multiple error messages when unknown command line + parameters where passed to the interpreter. + - Issue #15379: Fix passing of non-BMP characters as integers for the + charmap decoder (already working as unicode strings). + - Issue #16453: Fix equality testing of dead weakref objects. + - Issue #9535: Fix pending signals that have been received but not yet + handled by Python to not persist after os.fork() in the child process. + - Issue #15001: fix segfault on "del sys.modules['__main__']". + - Issue #5057: the peepholer no longer optimizes subscription on unicode + literals (e.g. u'foo'[0]) in order to produce compatible pyc files + between narrow and wide builds. + - Issue #8401: assigning an int to a bytearray slice (e.g. b[3:4] = 5) + now raises an error. + - Issue #14700: Fix buggy overflow checks for large width and precision + in string formatting operations. + - Issue #16345: Fix an infinite loop when ``fromkeys`` on a dict subclass + received a nonempty dict from the constructor. + - Issue #6074: Ensure cached bytecode files can always be updated by the + user that created them, even when the source file is read-only. + - Issue #14783: Improve int() and long() docstrings and switch docstrings + for unicode(), slice(), range(), and xrange() to use multi-line + signatures. + - Issue #16030: Fix overflow bug in computing the `repr` of an xrange + object with large start, step or length. + - Issue #16029: Fix overflow bug occurring when pickling xranges with large + start, step or length. + - Issue #16037: Limit httplib's _read_status() function to work around + broken HTTP servers and reduce memory usage (backport of a 3.2 fix). + - Issue #13992: The trashcan mechanism is now thread-safe. This eliminates + sporadic crashes in multi-thread programs when several long deallocator + chains ran concurrently and involved subclasses of built-in container + types. + - Issue #15801: Make sure mappings passed to '%' formatting are actually + subscriptable. + - Issue #15604: Update uses of PyObject_IsTrue() to check for and handle + errors correctly. + - Issue #15897: zipimport.c doesn't check return value of fseek(). + - Issue #16369: Global PyTypeObjects not initialized with PyType_Ready(...). + - Issue #15033: Fix the exit status bug when modules invoked using + -m switch, return the proper failure return value (1). + - Issue #1160: Fix compiling large regular expressions on UCS2 builds. + - Issue #14313: zipfile now raises NotImplementedError when the compression + type is unknown. + - Issue #16408: Fix file descriptors not being closed in error conditions + in the zipfile module. + - Issue #16327: The subprocess module no longer leaks file descriptors + used for stdin/stdout/stderr pipes to the child when fork() fails. + - Issue #14396: Handle the odd rare case of waitpid returning 0 when not + expected in subprocess.Popen.wait(). + - Issue #16411: Fix a bug where zlib.decompressobj().flush() might try + to access previously-freed memory. + - Issue #16350: zlib.decompressobj().decompress() now accumulates data from + successive calls after EOF in unused_data, instead of only saving the + argument to the last call. decompressobj().flush() now correctly sets + unused_data and unconsumed_tail. A bug in the handling of MemoryError + when setting the unconsumed_tail attribute has also been fixed. + - Issue #12759: sre_parse now raises a proper error when the name + of the group is missing. + - Issue #16152: fix tokenize to ignore whitespace at the end of the code + when no newline is found. + - Issue #1207589: Add Cut/Copy/Paste items to IDLE right click + Context Menu. + - Issue #16230: Fix a crash in select.select() when one the lists changes + size while iterated on. + - Issue #16228: Fix a crash in the json module where a list changes size + while it is being encoded. + - Issue #14897: Enhance error messages of struct.pack and struct.pack_into. + - Issue #12890: cgitb no longer prints spurious

tags in text + mode when the logdir option is specified. + - Issue #14398: Fix size truncation and overflow bugs in the bz2 module. + - Issue #5148: Ignore 'U' in mode given to gzip.open() and gzip.GzipFile(). + - Issue #16220: wsgiref now always calls close() on an iterable response. + - Issue #16461: Wave library should be able to deal with 4GB wav files, + and sample rate of 44100 Hz. + - Issue #16176: Properly identify Windows 8 via platform.platform(). + - Issue #15756: subprocess.poll() now properly handles errno.ECHILD to + return a returncode of 0 when the child has already exited or cannot + be waited on. + - Issue #12376: Pass on parameters in TextTestResult.__init__ super call. + - Issue #15222: Insert blank line after each message in mbox mailboxes. + - Issue #16013: Fix CSV Reader parsing issue with ending quote characters. + - Issue #15421: fix an OverflowError in Calendar.itermonthdates() after + datetime.MAXYEAR. + - Issue #15970: xml.etree.ElementTree now serializes correctly the + empty HTML elements 'meta' and 'param'. + - Issue #15676: Now "mmap" check for empty files before doing the + offset check. + - Issue #15340: Fix importing the random module when /dev/urandom cannot + be opened. This was a regression caused by the hash randomization patch. + - Issue #15841: The readable(), writable() and seekable() methods of + io.BytesIO and io.StringIO objects now raise ValueError when the object + has been closed. + - Issue #16112: platform.architecture does not correctly escape argument to + /usr/bin/file. + - Issue #12776,#11839: call argparse type function (specified by + add_argument) only once. Before, the type function was called twice in + the case where the default was specified and the argument was given as + well. This was especially problematic for the FileType type, as a + default file would always be opened, even if a file argument was + specified on the command line. + - Issue #15906: Fix a regression in argparse caused by the preceding change, + when action='append', type='str' and default=[]. + - Issue #13370: Ensure that ctypes works on Mac OS X when Python is + compiled using the clang compiler + - Issue #15544: Fix Decimal.__float__ to work with payload-carrying NaNs. + - Issue #15199: Fix JavaScript's default MIME type to + application/javascript. + - Issue #15477: In cmath and math modules, add workaround for platforms + whose system-supplied log1p function doesn't respect signs of zeros. + - Issue #15908: Fix misbehaviour of the sha1 module when called on data + larger than 2**32 bytes. + - Issue #15910: Fix misbehaviour of _md5 and sha1 modules when "updating" + on data larger than 2**32 bytes. + - Fix the leak of a dict in the time module when used in an embedded + interpreter that is repeatedly initialized and shutdown and reinitialized. + - Issue #12268: File readline, readlines and read or readall methods + no longer lose data when an underlying read system call is interrupted + within an io module object. IOError is no longer raised due to a read + system call returning EINTR from within these methods. + - Issue #16012: Fix a regression in pyexpat. The parser's UseForeignDTD() + method doesn't require an argument again. + - Issue #16559: Add more tests for the json module, including some from the + official test suite at json.org. + - Issue #16274: Fix test_asyncore on Solaris. + - Issue #15040: Close files in mailbox tests for PyPy compatibility. + - Issue #15802: Fix test logic in TestMaildir.test_create_tmp. + - Issue #15765: Extend a previous fix to Solaris and OpenBSD for quirky + getcwd() behaviour (issue #9185) to NetBSD as well. + - Issue #15615: Add some tests for the json module's handling of invalid + input data. + - Issue #15923: fix a mistake in asdl_c.py that resulted in a TypeError + after 2801bf875a24 (see #15801). + - Issue #11715: Fix multiarch detection without having Debian development + tools (dpkg-dev) installed. + - Issue #15819: Make sure we can build Python out-of-tree from a readonly + source directory. (Somewhat related to Issue #9860.) + - Issue #15822: Ensure 2to3 grammar pickles are properly installed. + - Issue #13301: use ast.literal_eval() instead of eval() + in Tools/i18n/msgfmt.py. + - Issue #16400: Update the description of which versions of a given package + PyPI displays. + - Issue #15677: Document that zlib and gzip accept a compression level + of 0 to mean 'no compression'. + - Issue #8040: added a version switcher to the documentation. + - Issue #16115: Improve subprocess.Popen() documentation around args, + shell, and executable arguments. + - Issue #15979: Improve timeit documentation. + - Issue #16036: Improve documentation of built-in int()'s signature and + arguments. + - Issue #15935: Clarification of argparse docs, re: add_argument() type and + default arguments. + - Issue #13769: Document the effect of ensure_ascii to the return type + of JSON decoding functions. + - Issue #14880: Fix kwargs notation in csv.reader, + .writer & .register_dialect. + - Issue #14674: Add a discussion of the json module's standard compliance. + * Clarify location of the gdbinit file. LP: #975676. + * Fix traceback for missing distutils wininst .exe files. LP: #1081155. + * Backport python3.3 multiarch packaging changes (Riku Voipio), and fix + multiarch issues discovered after the backport. + Closes: #683755. + * Use a shell implementation for the python-config script. + + -- Matthias Klose Thu, 29 Nov 2012 20:18:20 +0100 + +python2.7 (2.7.3-5) unstable; urgency=low + + * Enable verbose build for the sharedmods target. + * Fix issue #15847: allow args to be a tuple in parse_args. Closes: #686583. + * Fix issue #15340: Fix importing the random module when /dev/urandom cannot + be opened. Regression caused by the hash randomization patch. + * Don't use `-n' anymore to start idle in the desktop/menu files, not + needed anymore for multiseat installations. + + -- Matthias Klose Sun, 09 Sep 2012 16:54:26 +0200 + +python2.7 (2.7.3-4) unstable; urgency=low + + * Follwup for issue #9374. Restore the removed attributes in the + urlparse module. + * Update symbols files. + * Disable test_subprocess on the Hurd buildds. + * Call dh_movefiles with --srcdir. Closes: #685543. + + -- Matthias Klose Sun, 26 Aug 2012 12:24:31 +0200 + +python2.7 (2.7.3-3) unstable; urgency=low + + * Update to 20120814, taken from the 2.7 branch. Posix relevant patches: + - Issue #15041: Update "see also" list in tkinter documentation. + - Issue #14579: Fix error handling bug in the utf-16 decoder. + - Issue #15368: An issue that caused bytecode generation to be + non-deterministic when using randomized hashing (-R) has been fixed. + - Issue #15567: Fix NameError when running threading._test + - Issue #15424: Add a __sizeof__ implementation for array objects. + - Issue #13052: Fix IDLE crashing when replace string in Search/Replace + dialog ended with '\'. + - Issue #15538: Fix compilation of the getnameinfo() / getaddrinfo() + emulation code. + - Issue #9803: Don't close IDLE on saving if breakpoint is open. + - Issue #12288: Consider '0' and '0.0' as valid initialvalue + for tkinter SimpleDialog. + - Issue #15489: Add a __sizeof__ implementation for BytesIO objects. + - Issue #15469: Add a __sizeof__ implementation for deque objects. + - Issue #15487: Add a __sizeof__ implementation for buffered I/O objects. + - Issue #15512: Add a __sizeof__ implementation for parser. + - Issue #15402: An issue in the struct module that caused sys.getsizeof to + return incorrect results for struct.Struct instances has been fixed. + - Issue #15232: when mangle_from is True, email.Generator now correctly + mangles lines that start with 'From ' that occur in a MIME preamble + or epilog. + - Issue #13922: argparse no longer incorrectly strips '--'s that appear + after the first one. + - Issue #12353: argparse now correctly handles null argument values. + - Issue #14635: telnetlib will use poll() rather than select() when possible + to avoid failing due to the select() file descriptor limit. + - Issue #6056: Make multiprocessing use setblocking(True) on the + sockets it uses. + - Issue #15630: Add an example for "continue" stmt in the tutorial. + - Issue #15250: Document that filecmp.dircmp compares files shallowly. + * Fortified build. + * Python/import.c: Don't export isdir(). + * Modules/socketmodule.c: Don't export netdb_lock. + * Add breaks for vim-{nox,gtk,gnome,athena}. Closes: #682034. + * Don't ship python2.pc, should be shipped with python-dev instead. + Closes: #684612. + + -- Matthias Klose Tue, 14 Aug 2012 17:55:32 +0200 + +python2.7 (2.7.3-2) unstable; urgency=low + + * Update to 20120713, taken from the 2.7 branch. + - Issue #15033: Fix the exit status bug when modules invoked using -m swith, + return the proper failure return value (1). + - Issue #12268: File readline, readlines and read() methods no longer lose + data when an underlying read system call is interrupted. IOError is no + longer raised due to a read system call returning EINTR from within these + methods. + - Issue #13512: Create ~/.pypirc securely (CVE-2011-4944). + - Issue #7719: Make distutils ignore ``.nfs*`` files instead of choking + later on. + - Issue #10053: Don't close FDs when FileIO.__init__ fails. + - Issue #15247: FileIO now raises an error when given a file descriptor + pointing to a directory. + - Issue #14591: Fix bug in Random.jumpahead that could produce an invalid + Mersenne Twister state on 64-bit machines. + - Issue #5346: Preserve permissions of mbox, MMDF and Babyl mailbox + files on flush(). + - Issue #15219: Fix a reference leak when hashlib.new() is called with + invalid parameters. + - Issue #9559: If messages were only added, a new file is no longer + created and renamed over the old file when flush() is called on an + mbox, MMDF or Babyl mailbox. + - Issue #14653: email.utils.mktime_tz() no longer relies on system + mktime() when timezone offest is supplied. + - Issue #15101: Make pool finalizer avoid joining current thread. + - Issue #15054: A bug in tokenize.tokenize that caused string literals + with 'b' and 'br' prefixes to be incorrectly tokenized has been fixed. + - Issue #15036: Mailbox no longer throws an error if a flush is done + between operations when removing or changing multiple items in mbox, + MMDF, or Babyl mailboxes. + - Issue #15043: test_gdb is now skipped entirely if gdb security settings + block loading of the gdb hooks + - Issue #13557: Clarify effect of giving two different namespaces to exec or + execfile(). + * Don't build the _hashlib and _ssl extensions as a builtin, but as + extensions. Closes: #680930. + * Backport issue #13150: sysconfig no longer parses the Makefile and config.h + files when imported, instead doing it at build time. This makes importing + sysconfig faster and reduces Python startup time by 20%. + * python2.7: Add a break for python-virtualenv (<< 1.7.1.2-2~). + * Don't run the test_gdb test on mips/mipsel, not even in debug mode. + * For lto builds, use -g instead of -g1; filter out lto flags in the + installed Makefile. Closes: #681348. + + -- Matthias Klose Fri, 13 Jul 2012 05:03:43 +0200 + +python2.7 (2.7.3-1) unstable; urgency=low + + * Python 2.7.3 release. + * Update to 20120615, taken from the 2.7 branch. + * The wininst-* files cannot be built within Debian from the included + sources, needing a zlib mingw build, which the zlib maintainer isn't + going to provide. Closes: #639407. + * Let pydoc handle dist-packages the same as site-packages. + Closes: #671021. + * python2.7-doc: Fix underscore.js symlink. Closes: #671795, #676339. + * Do not italicize punctuation in python(1) manual page (Matt Kraai). + Closes: #579269. + * Build _heapq as a builtin (and move it to -minimal). + + -- Matthias Klose Fri, 15 Jun 2012 15:26:21 +0200 + +python2.7 (2.7.3~rc2-2.1) unstable; urgency=low + + * Non-maintainer upload (with maintainer's permission). + * Disable testsuite on GNU/kFreeBSD. (Closes: #669281) + + -- Robert Millan Sun, 22 Apr 2012 22:04:26 +0200 + +python2.7 (2.7.3~rc2-2) unstable; urgency=low + + * Use xdg-open/gvfs-open in Lib/webbrowser.py (Michael Vogt). + LP: #971311. + * Add a paragraph about python-foo-dbg packages to README.debug. + LP: #872050. + * Disable some tests (no feedback from porters): + - test_socket on hurd-i386. + - test_io on amd64. + - test_signal on kfreebsd-*. Closes: #654783. + - test_threading on sparc. + * Tighten build dependency on libexpat-dev. Closes: #665346. + * Build-depend on db-5.1, don't care about testsuite regressions on + some esoteric ports. If packages rely on threaded applications or + transactions, please use the python-bsddb3 package. + Closes: #621374. + * Don't ship the python2 and python2-config symlinks, move these + to the python-minimal and python-dev packages. Closes: #663874. + * Remove PVER-doc.doc-base.PVER-doc.in. Closes: #656763. + * Update symbols files. + * Avoid runtime path for the sqlite extension. + * CVE-2011-4944, distutils creates ~/.pypirc insecurely. Closes: #650555. + * Fix issue #14505, file descriptor leak when deallocating file objects + created with PyFile_FromString(). Closes: #664529. + + -- Matthias Klose Thu, 05 Apr 2012 15:47:03 +0200 + +python2.7 (2.7.3~rc2-1) unstable; urgency=low + + * Python 2.7.3 release candidate 2. + * Build-depend on expat >= 2.1~. + + -- Matthias Klose Wed, 21 Mar 2012 05:21:47 +0100 + +python2.7 (2.7.3~rc1-1) unstable; urgency=low + + * Python 2.7.3 release candidate 1. + * Update to 20120309, taken from the 2.7 branch. + * Fix dangling libpython.a symlink. Closes: #660231. + + -- Matthias Klose Fri, 09 Mar 2012 19:28:43 +0100 + +python2.7 (2.7.2-13) unstable; urgency=low + + * Update to 20120120, taken from the 2.7 branch. + * Remove patch integrated upstream (issue9054.diff). + * Backport Issue #9189 to distutils/sysconfig.py as well. + Closes: #656118. + * Disable test_io on kfreebsd again. Closes: #654783. + * Disable test_bsddb3 tests on kfreebsd again. + + -- Matthias Klose Fri, 20 Jan 2012 16:33:47 +0100 + +python2.7 (2.7.2-12) unstable; urgency=low + + * Run the tests with a script command which doesn't exit immediatly + when stdin is /dev/null (Colin Watson). + + -- Matthias Klose Fri, 13 Jan 2012 11:04:31 +0100 + +python2.7 (2.7.2-11) unstable; urgency=low + + * Don't run the test_site tests when $HOME doesn't exist. + + -- Matthias Klose Wed, 11 Jan 2012 09:19:00 +0100 + +python2.7 (2.7.2-10) unstable; urgency=low + + * Update to 20120110, taken from the 2.7 branch. + * Overwrite some lintian warnings: + - The -dbg interpreters are not unusual. + - The -gdb.py files don't need a python dependency. + - lintian can't handle a whatis entry starting with one word on the line. + * Fix test failures related to distutils debian installation layout. + * Add build-arch/build-indep targets. + * Regenerate Setup and Makefiles after correcting Setup.local. + * profiled-build.diff: Pass PY_CFLAGS instead of CFLAGS for the profiled + build. + * Pass dpkg-buildflags to the build process, and build third party + extensions with these flags. + * Add support to build using -flto (and -g1) on some architectures. + * Disable pgo builds for some architectures (for now, keep just + amd64 armel armhf i386 powerpc ppc64). + * Build-depend on libgdbm-dev to build and run the gdbm tests. + * Build-depend on xvfb to run the tkinter tests. + * python2.7: Provide python2.7-argparse and python-argparse. + * Don't run test_threading on mips/mipsel. + * Run the test_gdb test for the debug build only. + * Add build conflict to python-cxx-dev (pydoc test failures). + * Disable test_ssl certificate check, certificate expired on python.org. + + -- Matthias Klose Tue, 10 Jan 2012 16:44:56 +0100 + +python2.7 (2.7.2-9) unstable; urgency=low + + * Update to 20111217, taken from the 2.7 branch. + + -- Matthias Klose Sat, 17 Dec 2011 17:36:27 +0100 + +python2.7 (2.7.2-8) unstable; urgency=low + + * Update to 20111130, taken from the 2.7 branch. + * New patch, ctypes-arm, allow for ",hard-float" after libc6 in ldconfig -p + output (Loic Minier). LP: #898172. + * debian/rules: Define DPKG_VARS (Alban Browaeys). Closes: #647419). + * Add python-config man page (Johann Felix Soden). Closes: #650181). + + -- Matthias Klose Wed, 30 Nov 2011 19:16:23 +0100 + +python2.7 (2.7.2-7) unstable; urgency=low + + * Adjust patches for removed Lib/plat-linux3. + * Add build conflict to libncurses5-dev, let configure search for + ncurses headers in /usr/include/ncursesw too. + + -- Matthias Klose Wed, 05 Oct 2011 11:30:16 +0200 + +python2.7 (2.7.2-6) unstable; urgency=low + + * Update to 20111004, taken from the 2.7 branch. + * Use the ncursesw include directory when linking with ncursesw. + * Rebuild with libreadline not linked with libncurses*. Closes: #643816. + * Fix typos in the multiprocessing module. Closes: #643856. + + -- Matthias Klose Tue, 04 Oct 2011 16:09:29 +0200 + +python2.7 (2.7.2-5) unstable; urgency=low + + * Update to 20110816, taken from the 2.7 branch. + - Fix issue#12752. LP: #824734. + * Don't run test_threading on the kfreebsd-i386 buildd. + + -- Matthias Klose Tue, 16 Aug 2011 08:33:31 +0200 + +python2.7 (2.7.2-4) unstable; urgency=low + + * Update to 20110803, taken from the 2.7 branch. + * Fix build on s390x. Closes: #636033. + * Use linux-any for some build dependencies. Closes: #634809. + * Revert previous change to treat Linux 3.x as Linux 2. Use the + plat-linux3 directory instead. + + -- Matthias Klose Wed, 03 Aug 2011 12:36:05 +0200 + +python2.7 (2.7.2-3) unstable; urgency=low + + * Update to 20110709, taken from the 2.7 branch. + * Make the conflict against python-profiler a versioned conflict. + * Don't run the bsddb3 tests on kfreebsd-i386. + * Don't add the bsddb multilib path, if already in the standard lib path. + * Treat Linux 3.x as Linux 2. Closes: #633015. + * Assume working semaphores on Linux, don't rely on running kernel + for the check. Closes: #631188. + + -- Matthias Klose Sat, 09 Jul 2011 13:19:47 +0200 + +python2.7 (2.7.2-2) unstable; urgency=low + + * Update to 20110628, taken from the 2.7 branch. + * Add profile/pstats to the python2.7 package, update debian copyright. + * Don't run the bsddb3 tests on kfreebsd-amd64. + * Don't run the benchmark on hurd-i386. + + -- Matthias Klose Tue, 28 Jun 2011 23:05:21 +0200 + +python2.7 (2.7.2-1) unstable; urgency=low + + * Python 2.7.2 release. + + -- Matthias Klose Sun, 12 Jun 2011 21:04:24 +0200 + +python2.7 (2.7.2~rc1-2) unstable; urgency=medium + + * Set pyexpat dummy version string. + + -- Matthias Klose Tue, 31 May 2011 12:05:56 +0200 + +python2.7 (2.7.2~rc1-1) unstable; urgency=low + + * Python 2.7.2 release candidate 1. + * Update libpython symbols file for m68k (Thorsten Glaser). Closes: #627458. + * Apply proposed patch for issue #670664. LP: #357067. + + -- Matthias Klose Mon, 30 May 2011 06:44:23 +0200 + +python2.7 (2.7.1-9) unstable; urgency=low + + * Update to 20110520, taken from the 2.7 branch. + + -- Matthias Klose Fri, 20 May 2011 13:43:12 +0200 + +python2.7 (2.7.1-8) unstable; urgency=low + + * Keep the ssl.PROTOCOL_SSLv2 module constant , just raise an exception + when trying to create a PySSL object. Closes: #623423. + + -- Matthias Klose Wed, 20 Apr 2011 12:31:03 +0200 + +python2.7 (2.7.1-7) unstable; urgency=low + + * Update to 20110419, taken from the 2.7 branch. + * Build without OpenSSL v2 support. Closes: #620581. + * Force linking the curses module against libncursesw. Closes: #622064. + * Link libpython with --whole-archive. Closes: #614711. + * Re-enable running the testsuite during the build. + + -- Matthias Klose Tue, 19 Apr 2011 17:36:56 +0200 + +python2.7 (2.7.1-6) unstable; urgency=low + + * Update to 20110307, taken from the 2.7 branch. + * Disable the profile guided build on ia64, sparc. + + -- Matthias Klose Mon, 07 Mar 2011 02:19:02 +0100 + +python2.7 (2.7.1-5) experimental; urgency=low + + * Update to 20110224, taken from the 2.7 branch. + * Update patches. + * Re-enable profile guided build. + + -- Matthias Klose Thu, 24 Feb 2011 06:01:42 +0100 + +python2.7 (2.7.1-4) experimental; urgency=low + + * Update to 20110119, taken from the 2.7 branch. + + -- Matthias Klose Wed, 19 Jan 2011 04:21:14 +0100 + +python2.7 (2.7.1-3) experimental; urgency=low + + * Do not run test_multiprocessing when running the testsuite. + Fails on armel and powerpc on some buildds. + + -- Matthias Klose Fri, 24 Dec 2010 01:46:55 +0100 + +python2.7 (2.7.1-2) experimental; urgency=low + + * Update to 20101222, taken from the 2.7 branch. + * Re-enable the distutils-sysconfig.diff patch, apparently + lost when updating the patches for 2.7. + * Disable the profiled builds on all architectures. + + -- Matthias Klose Wed, 22 Dec 2010 15:39:48 +0100 + +python2.7 (2.7.1-1) experimental; urgency=low + + * Python 2.7.1 release. + + -- Matthias Klose Sun, 28 Nov 2010 12:05:23 +0100 + +python2.7 (2.7.1~rc1-2) experimental; urgency=low + + * Move the pyconfig.h file into the -min package, required by sysconfig. + Closes: #603237. + + -- Matthias Klose Sun, 14 Nov 2010 09:40:09 +0100 + +python2.7 (2.7.1~rc1-1) experimental; urgency=low + + * Python 2.7.1 release candidate 1. + * Move the Makefile into the -min package, required by sysconfig. + Closes: #603237. + + -- Matthias Klose Sun, 14 Nov 2010 00:33:48 +0100 + +python2.7 (2.7-9) experimental; urgency=low + + * Update to 20101016, taken from the 2.7 branch. + + -- Matthias Klose Sat, 16 Oct 2010 12:46:57 +0200 + +python2.7 (2.7-8) experimental; urgency=low + + * Disabled the profiled build on armel. + + -- Matthias Klose Thu, 23 Sep 2010 15:06:06 +0200 + +python2.7 (2.7-7) experimental; urgency=low + + * Update to 20100922, taken from the 2.7 branch. + * Update GNU/Hurd patches (Pino Toscano). Closes: #597419. + + -- Matthias Klose Wed, 22 Sep 2010 20:35:24 +0200 + +python2.7 (2.7-6) experimental; urgency=low + + * Update to 20100915, taken from the 2.7 branch. + - Fix issue #9729, Unconnected SSLSocket.{send,recv} raises TypeError + (Andrew Bennetts). LP: #637821. + * Add copyright information for expat, libffi and zlib. Addresses: #596276. + * Apply proposed fix for issue 9054, configure --with-system-expat. + * Provide Lib/plat-gnukfreebsd[78] (Jakub Wilk). Addresses: #593818. + + -- Matthias Klose Wed, 15 Sep 2010 17:43:18 +0200 + +python2.7 (2.7-5) experimental; urgency=low + + * Update to 20100829, taken from the 2.7 branch. + * Don't configure --with-system-expat, segfaults the interpreter in the + testsuite. + * Disable more tests on hppa and hurd-i386, which fail on the buildds. + + -- Matthias Klose Sun, 29 Aug 2010 16:22:37 +0200 + +python2.7 (2.7-4) experimental; urgency=low + + * Update to 20100822, taken from the 2.7 branch. + * Fixed in previous 2.7 uploads: Multiple integer overflows in audioop.c + in the audioop module (CVE-2010-1634). + * Fix some lintian warnings. + * Configure --with-system-expat. + + -- Matthias Klose Mon, 23 Aug 2010 13:03:40 +0200 + +python2.7 (2.7-3) experimental; urgency=low + + * Update to 20100807, taken from the 2.7 branch. + * Move '/usr/local/.../dist-packages' before '/usr/lib/.../dist-packages' + in sys.path. Adresses: #588342. + * Fix detection of ffi.h header file. Closes: #591408. + * python2-7-dev: Depend on libssl-dev. LP: #611845. + + -- Matthias Klose Sat, 07 Aug 2010 21:28:04 +0200 + +python2.7 (2.7-2) experimental; urgency=low + + * Complete debug-build.diff, some parts lost in quilt conversion. + * Move the pkgconfig file into the -dev package. + + -- Matthias Klose Tue, 06 Jul 2010 21:07:48 +0200 + +python2.7 (2.7-1) experimental; urgency=low + + * Python 2.7 release. + * Update to 20100706, taken from the trunk. + * Update symbols files. + + -- Matthias Klose Tue, 06 Jul 2010 07:21:23 +0200 + +python2.7 (2.7~rc2-3) experimental; urgency=low + + * Update to 20100703, taken from the trunk. + * Move the _weakrefset module, not extension to -minimal. Closes: #587568. + * Move the sysconfig module to -minimal. Closes: #586113. + * Move the shutil module to python2.6-minimal. Addresses: #587628. + + -- Matthias Klose Sat, 03 Jul 2010 13:27:36 +0200 + +python2.7 (2.7~rc2-2) experimental; urgency=low + + * Fix applying plat-linux2* patches. + * Use the profiled build on armel, sparc and sparc64. + + -- Matthias Klose Tue, 29 Jun 2010 08:04:59 +0200 + +python2.7 (2.7~rc2-1) experimental; urgency=low + + * Python 2.7 release candidate 2. + * Update to 20100628, taken from the trunk. + * Merge packaging changes from python2.6 (2.6.5+20100628-1). + + -- Matthias Klose Tue, 29 Jun 2010 00:57:00 +0200 + +python2.7 (2.7~b1-2) experimental; urgency=low + + * Update to 20100508, taken from the trunk. + + -- Matthias Klose Sat, 08 May 2010 17:34:07 +0200 + +python2.7 (2.7~b1-1) experimental; urgency=low + + * Python 2.7 beta1. + * Update to 20100420, taken from the trunk. + * Update libpython symbols files. + * Apply proposed patch for issue #7332, segfaults in + PyMarshal_ReadLastObjectFromFile in import_submodule. + * Don't build-depend on locales on avr32. Closes: #575144. + + -- Matthias Klose Tue, 20 Apr 2010 23:53:42 +0200 + +python2.7 (2.7~a4-1) experimental; urgency=low + + * Python 2.7 alpha4. + * Update to 20100316, taken from the trunk. + * Point distutils.sysconfig to the system installation. Closes: #573363. + + -- Matthias Klose Tue, 16 Mar 2010 15:45:07 +0100 + +python2.7 (2.7~a3-1) experimental; urgency=low + + * Python 2.7 alpha3. + + -- Matthias Klose Tue, 16 Feb 2010 03:04:01 +0100 + +python2.7 (2.7~a2-1) experimental; urgency=low + + * Python 2.7 alpha2. + + -- Matthias Klose Sat, 16 Jan 2010 14:49:59 +0100 + +python2.6 (2.6.5+20100628-1) unstable; urgency=low + + * Update to 20100614, taken from the 2.6 release branch (r82337). + * Apply plat-linux2- patch for alpha, hppa, mips, mipsel, sparc + and sparc64. + + -- Matthias Klose Mon, 28 Jun 2010 21:26:43 +0200 + +python2.6 (2.6.5+20100626-1) unstable; urgency=low + + * Update to 20100614, taken from the 2.6 release branch (r82245). + * Update libpython symbols files. Closes: #587012. + * Move the logging package and the runpy module to python2.6-minimal. + + -- Matthias Klose Sat, 26 Jun 2010 14:29:41 +0200 + +python2.6 (2.6.5+20100616-1) unstable; urgency=medium + + * Update to 20100614, taken from the 2.6 release branch (r81601). + * Reapply the backport for issue #8233, lost in the conversion to + quilt. + * Disable the profiled build on alpha. + * Make pydoc more robust not to fail on exceptions other than import + exceptions. + * posixmodule: Add flags for statvfs.f_flag to constant list. + + -- Matthias Klose Wed, 16 Jun 2010 07:56:40 +0200 + +python2.6 (2.6.5+20100529-1) unstable; urgency=low + + * Update to 20100529, taken from the 2.6 release branch (r81601). + - Fix issue #5753, CVE-2008-5983 python: untrusted python modules + search path. Closes: #572010. + * Convert internal dpatch system to quilt. + * Build the ossaudio extension on GNU/kFreeBSD. Closes: #574696. + + -- Matthias Klose Sat, 29 May 2010 15:07:51 +0200 + +python2.6 (2.6.5-2) unstable; urgency=low + + * Update libpython symbols files. + * debian/patches/issue8032.dpatch: Update to version from the + trunk. + * Fix issue #8329: Don't return the same lists from select.select + when no fds are changed. + * Fix issue #8310: Allow dis to examine new style classes. + * Fix issues #8279: Fix test_gdb failures. + * Fix issue #8233: When run as a script, py_compile.py optionally + takes a single argument `-`. + * Apply proposed patch for issue #7332, segfaults in + PyMarshal_ReadLastObjectFromFile in import_submodule. + * Don't build-depend on locales on avr32. Closes: #575144. + + -- Matthias Klose Tue, 20 Apr 2010 19:41:36 +0200 + +python2.6 (2.6.5-1ubuntu6) lucid; urgency=low + + * Fix applying patch for issue #8310. + + -- Matthias Klose Fri, 16 Apr 2010 14:20:35 +0200 + +python2.6 (2.6.5-1ubuntu5) lucid; urgency=low + + * Fix issue #8329: Don't return the same lists from select.select + when no fds are changed. + * Fix issue #8310: Allow dis to examine new style classes. + + -- Matthias Klose Thu, 15 Apr 2010 01:21:07 +0200 + +python2.6 (2.6.5-1ubuntu4) lucid; urgency=low + + * debian/patches/issue8032.dpatch: Update to version from the + trunk. Upload for beta2 to avoid apport errors. + - Handle PyFrameObject's: LP: #543624, #548723. + - Detect cycles in object reference graph and add extra + protection: LP: #544823, LP: #552356. + + -- Matthias Klose Thu, 01 Apr 2010 22:53:06 +0200 + +python2.6 (2.6.5-1ubuntu3) lucid; urgency=low + + * debian/patches/issue8140.dpatch: Incomplete patch; regenerate. + * debian/patches/issue8032.dpatch: Update to v4: + - Add support for PySetObject (set/frozenset). + - Add support for PyBaseExceptionObject (BaseException). + - Fix a signed vs unsigned char issue that led to exceptions + in gdb for PyStringObject instances. + - Handle the case of loops in the object reference graph. + - Unit tests for all of the above. + + -- Matthias Klose Wed, 31 Mar 2010 18:52:32 +0200 + +python2.6 (2.6.5-1ubuntu2) lucid; urgency=low + + * Disable profiled build on powerpc. + + -- Matthias Klose Sat, 20 Mar 2010 15:17:18 +0100 + +python2.6 (2.6.5-1ubuntu1) lucid; urgency=low + + * Merge with Debian (2.6.5-1). + + -- Matthias Klose Sat, 20 Mar 2010 03:57:17 +0100 + +python2.6 (2.6.5-1) unstable; urgency=low + + * Python 2.6.5 final release. + * Fix issue #4961: Inconsistent/wrong result of askyesno function in + tkMessageBox with Tcl8.5. LP: #462950. + * Issue #8154, fix segfault with os.execlp('true'). LP: #418848. + * Apply proposed patch for issue #8032, gdb7 hooks for debugging. + + -- Matthias Klose Fri, 19 Mar 2010 00:12:55 +0100 + +python2.6 (2.6.5~rc2-2) unstable; urgency=low + + * Add copyright notices for the readline and _ssl extensions. + Closes: #573866. + * Backport issue #8140: Extend compileall to compile single files. + Add -i option. + * Backport issue #6949, build _bsddb extension with db-4.8.x. + + -- Matthias Klose Tue, 16 Mar 2010 03:02:21 +0100 + +python2.6 (2.6.5~rc2-1) unstable; urgency=low + + * Python 2.6.5 release candidate 2. + - Replace the Monty Python audio test file. Closes: #568674. + * Fix build failure on sparc64. Closes: #570845. + + -- Matthias Klose Thu, 11 Mar 2010 16:50:03 +0100 + +python2.6 (2.6.5~rc2-0ubuntu1) lucid; urgency=low + + * Python 2.6.5 release candidate 2. + + -- Matthias Klose Thu, 11 Mar 2010 13:30:19 +0100 + +python2.6 (2.6.4-6ubuntu1) lucid; urgency=low + + * Merge with Debian (2.6.4-6). + + -- Matthias Klose Tue, 16 Feb 2010 01:08:50 +0100 + +python2.6 (2.6.4-6) unstable; urgency=low + + * Update to 20100215, taken from the 2.6 release branch. + * python2.6-minimal: Skip moving syssite contents to new location, if + /usr/local/lib/python2.6 cannot be written. Closes: #569532. LP: #338227. + * libpython2.6: Fix symlink in /usr/lib/python2.6/config. LP: #521050. + + -- Matthias Klose Mon, 15 Feb 2010 22:12:18 +0100 + +python2.6 (2.6.4-5ubuntu1) lucid; urgency=low + + * Merge with Debian (2.6.4-5). + + -- Matthias Klose Sun, 31 Jan 2010 22:31:41 +0100 + +python2.6 (2.6.4-5) unstable; urgency=low + + * Update to 20100131, taken from the 2.6 release branch. + - Fix typo in os.execvp docstring. Closes: #558764. + * distutils.sysconfig.get_python_lib(): Only return ".../dist-packages" if + prefix is the default prefix and if PYTHONUSERBASE is not set in the + environment and if --user option is not present. LP: #476005. + * distutils install: Don't install into /usr/local/local, if option + --prefix=/usr/local is present, without changing the install prefix. + LP: #510211. + + -- Matthias Klose Sun, 31 Jan 2010 21:16:51 +0100 + +python2.6 (2.6.4-4ubuntu1) lucid; urgency=low + + * Update to 20100122, taken from the 2.6 release branch. + - Fix DoS via XML document with malformed UTF-8 sequences (CVE_2009_3560). + Closes: #566233. + - Fix typo in os.execvp docstring. Closes: #558764. + * python2.6-doc: Fix searching in local documentation. LP: #456025. + * Update locale module from the trunk. LP: #223281. + * Merge with Debian (2.6.4-4). + + -- Matthias Klose Fri, 22 Jan 2010 11:37:29 +0100 + +python2.6 (2.6.4-4) unstable; urgency=low + + * Update to 20100122, taken from the 2.6 release branch. + - Fix DoS via XML document with malformed UTF-8 sequences (CVE_2009_3560). + Closes: #566233. + * Hurd fixes (Pino Toscano). Closes: #565693: + - hurd-broken-poll.dpatch: ported from 2.5. + - hurd-disable-nonworking-constants.dpatch: disable a few constants from + the public API whose C counterparts are not implemented, so using them + either always blocks or always fails (caused issues in the test suite). + - Exclude the profiled build for hurd. + - Disable four blocking tests from the test suite. + + -- Matthias Klose Fri, 22 Jan 2010 11:10:41 +0100 + +python2.6 (2.6.4-3) unstable; urgency=low + + * Disable the profiled build on s390, mips, mipsel. + * Fix symbol files for kfreebsd-amd64 and sparc64. + + -- Matthias Klose Sat, 16 Jan 2010 16:12:17 +0100 + +python2.6 (2.6.4-2) unstable; urgency=low + + * Update to 20100116, taken from the 2.6 release branch. + * Fix bashism in makesetup shell script. Closes: #530170, #530171. + * Fix build issues on avr (Bradley Smith). Closes: #528439. + - Configure --without-ffi. + - Don't run lengthly tests. + * locale.py: Update locale aliases from the 2.7 branch. + + -- Matthias Klose Sat, 16 Jan 2010 11:05:12 +0100 + +python2.6 (2.6.4-1) experimental; urgency=low + + * Python 2.6.4 final release. + - Issue #7120: logging: Removed import of multiprocessing which is causing + crash in GAE. + - Issue #7149: fix exception in urllib when detecting proxy settings + on OSX. + - Issue #7115: Fixed the extension module builds that is failing when + using paths in the extension name instead of dotted names. LP: #449734. + - Issue #6894: Fixed the issue urllib2 doesn't respect "no_proxy" + environment. + - Issue #7052: Removed nonexisting NullHandler from logging.__all__. + - Issue #7039: Fixed distutils.tests.test_sysconfig when running on + installation with no build. + - Issue #7019: Raise ValueError when unmarshalling bad long data, instead + of producing internally inconsistent Python longs. + * distutils install: Don't install into /usr/local/local, if option + --prefix=/usr/local is present. + + -- Matthias Klose Tue, 27 Oct 2009 01:22:21 +0100 + +python2.6 (2.6.4~rc1-1) experimental; urgency=low + + * Python 2.6.4 release candidate 1. + - Issue #7052: Removed nonexisting NullHandler from logging.__all__. + - Issue #7039: Fixed distutils.tests.test_sysconfig when running on + installation with no build. + - Issue #7019: Raise ValueError when unmarshalling bad long data, instead + of producing internally inconsistent Python longs. + - Issue #7068: Fixed the partial renaming that occured in r72594. + - Issue #7042: Fix test_signal (test_itimer_virtual) failure on OS X 10.6. + * Remove the conflict with python-setuptools (fixed in issue #7068). + * Build _hashlib as a builtin. + * python2.6-doc: Don't compress the sphinx inventory. + * python2.6-doc: Fix jquery.js symlink. + + -- Matthias Klose Sat, 10 Oct 2009 10:21:02 +0200 + +python2.6 (2.6.3-1) experimental; urgency=low + + * Final Python 2.6.3 release. + - Issue #5329: Fix os.popen* regression from 2.5 with commands as a + sequence running through the shell. + - Issue #6990: Fix threading.local subclasses leaving old state around + after a reference cycle GC which could be recycled by new locals. + - Issue #6790: Make it possible again to pass an `array.array` to + `httplib.HTTPConnection.send`. + - Issue #6922: Fix an infinite loop when trying to decode an invalid + UTF-32 stream with a non-raising error handler like "replace" or + "ignore". + - Issue #1590864: Fix potential deadlock when mixing threads and fork(). + - Issue #6844: Do not emit DeprecationWarnings when accessing a "message" + attribute on exceptions that was set explicitly. + - Issue #6236, #6348: Fix various failures in the `io` module under AIX + and other platforms, when using a non-gcc compiler. Patch by egreen. + - Issue #6851: Fix urllib.urlopen crash on secondairy threads on OSX 10.6 + - Issue #6947: Fix distutils test on windows. Patch by Hirokazu Yamamoto. + - Issue #4606: Passing 'None' if ctypes argtype is set to POINTER(...) + does now always result in NULL. + - Issue #5042: ctypes Structure sub-subclass does now initialize + correctly with base class positional arguments. + - Issue #6938: Fix a TypeError in string formatting of a multiprocessing + debug message. + - Issue #6944: Fix a SystemError when socket.getnameinfo() was called + with something other than a tuple as first argument. + - Issue #6980: Fix ctypes build failure on armel-linux-gnueabi with + -mfloat-abi=softfp. + * python2.6-dbg: Don't create debug subdirectory in /usr/local. No + separate debug directory needed anymore. + * Run the benchmark with -C 2 -n 5 -w 4 on all architectures. + * Build-depend on the versioned db4.x-dev to avoid unexpected updates + for anydbm databases. + + -- Matthias Klose Sat, 03 Oct 2009 13:19:56 +0200 + +python2.6 (2.6.2-3) experimental; urgency=low + + * Update to 20090919, taken from the 2.6 release branch. + * Add a conflict to python-setuptools (<< 0.6c9-3), C extension + builds broken. + * Add new symbols for update from the branch. + + -- Matthias Klose Sat, 19 Sep 2009 10:36:34 +0200 + +python2.6 (2.6.2-2) experimental; urgency=low + + * Symbol _Py_force_double@Base is i386 only. Closes: #534208. + + -- Matthias Klose Tue, 23 Jun 2009 06:14:40 +0200 + +python2.6 (2.6.2-1) experimental; urgency=low + + * Final Python 2.6.2 release. + - Update Doc/tools/sphinxext/download.html. Closes: #526797. + * Update to 20090621, taken from the 2.6 release branch. + + * Address issues when working with PYTHONUSERBASE and non standard prefix + (pointed out by Larry Hastings): + - distutils.sysconfig.get_python_lib(): Only return ".../dist-packages" if + prefix is the default prefix and if PYTHONUSERBASE is not set in the + environment. + - site.addusersitepackages(): Add USER_BASE/.../dist-packages to sys.path. + * Always use the `unix_prefix' scheme for setup.py install in a virtualenv + setup. LP: #339904. + * Don't make the setup.py install options --install-layout=deb and --prefix + conflict with each other. + * distutils: Always install into `/usr/local/lib/python2.6/dist-packages' + if an option `--prefix=/usr/local' is present (except for virtualenv + and PYTHONUSERBASE installations). LP: #362570. + * Always use `site-packages' as site directory name in virtualenv. + + * Do not add /usr/lib/pythonXY.zip on sys.path. + * Add symbols files for libpython2.6 and python2.6-dbg, don't include symbols + from builtins, which can either be built as builtins or extensions. + * Keep an empty lib-dynload in python2.6-minimal to avoid a warning on + startup. + * Build a shared library configured --with-pydebug. LP: #322580. + * Fix some lintian warnings. + * Use the information in /etc/lsb-release for platform.dist(). LP: #196526. + * Move the bdist_wininst files into the -dev package (only needed to build + windows installers). + * Document changes to the site directory name in the installation manual. + * Fix issue #1113244: Py_XINCREF, Py_DECREF, Py_XDECREF: Add + `do { ... } while (0)' to avoid compiler warnings. Closes: #516956. + * debian/pyhtml2devhelp.py: update for python 2.6 (Marc Deslauriers). + * debian/rules: re-enable documentation files for devhelp. LP: #338791. + * python2.6-doc: Depend on libjs-jquery, use jquery.js from this package. + Closes: #523482. + + -- Matthias Klose Sun, 21 Jun 2009 16:12:15 +0200 + +python2.6 (2.6.1-3) experimental; urgency=low + + * Update to 20090318, taken from the 2.6 release branch. + * Use the information in /etc/lsb-release for platform.dist(). + * Update installation schemes: LP: #338395. Closes: #520278. + - When the --prefix option is used for setup.py install, Use the + `unix_prefix' scheme. + - Use the `deb_system' scheme if --install-layout=deb is specified. + - Use the the `unix_local' scheme if neither --install-layout=deb + nor --prefix is specified. + - The options --install-layout=deb and --prefix are exclusive. + * Don't fail installation/removal if directories in /usr/local cannot + be created. LP: #338227. + * Don't try to move away the site-packages directory. There never was a + python2.6 upload using site-packages. Closes: #518780. + * Fix build failure on mips/mipsel. Closes: #519386. + + -- Matthias Klose Wed, 18 Mar 2009 22:17:20 +0100 + +python2.6 (2.6.1-2) experimental; urgency=low + + * Move libpython2.6.a into the python2.6-dev package. + * Move idlelib into the idle-python2.6 package. + + -- Matthias Klose Wed, 25 Feb 2009 18:42:19 +0100 + +python2.6 (2.6.1-1) experimental; urgency=low + + * New upstream version, upload to experimental. + * Update to 20090225, taken from the 2.6 release branch. + * Don't build-depend on locales on armel, hppa, ia64 and mipsel; package is + currently not installable. + + -- Matthias Klose Wed, 25 Feb 2009 18:42:19 +0100 + +python2.6 (2.6.1-0ubuntu9) jaunty; urgency=low + + * Don't build pyexpat, _elementtree and _ctypes as builtin extensions, + third party packages make too many assumptions about these not built + as builtins. + + -- Matthias Klose Tue, 24 Feb 2009 16:34:27 +0100 + +python2.6 (2.6.1-0ubuntu8) jaunty; urgency=low + + * Link the shared libpython with $(MODLIBS). + + -- Matthias Klose Sun, 22 Feb 2009 16:38:49 +0100 + +python2.6 (2.6.1-0ubuntu7) jaunty; urgency=low + + * Update to 20090222, taken from the 2.6 release branch. + + -- Matthias Klose Sun, 22 Feb 2009 10:35:29 +0100 + +python2.6 (2.6.1-0ubuntu6) jaunty; urgency=low + + * Don't build the gdbm extension from the python2.6 source. + * Build the dbm extension using libdb. + * Don't build-depend on locales on sparc (currently not installable), only + needed by the testsuite. + * Update to 20090219, taken from the 2.6 release branch. + + -- Matthias Klose Thu, 19 Feb 2009 12:43:20 +0100 + +python2.6 (2.6.1-0ubuntu5) jaunty; urgency=low + + * Add build dependency on libdb-dev. + + -- Matthias Klose Mon, 16 Feb 2009 13:34:41 +0100 + +python2.6 (2.6.1-0ubuntu4) jaunty; urgency=low + + * Disable the profiled build on all architectures. + + -- Matthias Klose Mon, 16 Feb 2009 11:18:51 +0100 + +python2.6 (2.6.1-0ubuntu3) jaunty; urgency=low + + * Disable the profiled build on armel as well. + + -- Matthias Klose Sun, 15 Feb 2009 10:38:02 +0100 + +python2.6 (2.6.1-0ubuntu2) jaunty; urgency=low + + * Don't use the profiled build on amd64, lpia and sparc (GCC + PR profile/38292). + + -- Matthias Klose Sat, 14 Feb 2009 14:09:34 +0100 + +python2.6 (2.6.1-0ubuntu1) jaunty; urgency=low + + * Update to 20090211, taken from the 2.6 release branch. + + -- Matthias Klose Fri, 13 Feb 2009 12:51:00 +0100 + +python2.6 (2.6.1-0ubuntu1~ppa1) jaunty; urgency=low + + * Python 2.6.1 release. + * Update to 20081206, taken from the 2.6 release branch. + * Ensure that all extensions from the -minimal package are statically + linked into the interpreter. + * Include expat, _elementtree, datetime, bisect, _bytesio, _locale, + _fileio in -minimal to link these extensions statically. + + -- Matthias Klose Fri, 05 Dec 2008 20:43:51 +0100 + +python2.6 (2.6-0ubuntu1~ppa5) intrepid; urgency=low + + * Test build + + -- Matthias Klose Fri, 14 Nov 2008 10:14:38 +0100 + +python2.6 (2.6-0ubuntu1~ppa4) intrepid; urgency=low + + * Do not build the bsddb3 module from this source, but recommend the + python-bsddb3 package (will be a dependency after python-bsddb3 is in + the archive). + * For locally installed packages, create a directory + /usr/local/lib/python2.6/dist-packages. This is the default for + installations done with distutils and setuptools. Third party stuff + packaged within the distribution goes to /usr/lib/python2.6/dist-packages. + There is no /usr/lib/python2.6/site-packages in the file system and + on sys.path. No package within the distribution must not install + anything in this location. + * Place the gdbm extension into the python2.6 package. + * distutils: Add an option --install-layout=deb, which + - installs into $prefix/dist-packages instead of $prefix/site-packages. + - doesn't encode the python version into the egg name. + + -- Matthias Klose Sat, 25 Oct 2008 11:12:24 +0000 + +python2.6 (2.6-0ubuntu1~ppa3) intrepid; urgency=low + + * Build-depend on libdb4.6-dev, instead of libdb-dev (4.7). Test suite + hangs in the bsddb tests. + + -- Matthias Klose Wed, 22 Oct 2008 11:05:13 +0200 + +python2.6 (2.6-0ubuntu1~ppa2) intrepid; urgency=low + + * Update to 20081021, taken from the 2.6 release branch. + * Fix typos and section names in doc-base files. LP: #273344. + * Build a new package libpython2.6. + * For locally installed packages, create a directory + /usr/local/lib/python2.6/system-site-packages, which is symlinked + from /usr/lib/python2.6/site-packages. Third party stuff packaged + within the distribution goes to /usr/lib/python2.6/dist-packages. + + -- Matthias Klose Tue, 21 Oct 2008 18:09:31 +0200 + +python2.6 (2.6-0ubuntu1~ppa1) intrepid; urgency=low + + * Python 2.6 release. + * Update to current branch 20081009. + + -- Matthias Klose Thu, 09 Oct 2008 14:28:26 +0200 + +python2.6 (2.6~b3-0ubuntu1~ppa1) intrepid; urgency=low + + * Python 2.6 beta3 release. + + -- Matthias Klose Sun, 24 Aug 2008 01:34:54 +0000 + +python2.6 (2.6~b2-0ubuntu1~ppa1) intrepid; urgency=low + + * Python 2.6 beta2 release. + + -- Matthias Klose Thu, 07 Aug 2008 16:45:56 +0200 + +python2.6 (2.6~b1-0ubuntu1~ppa1) intrepid; urgency=low + + * Python 2.6 beta1 release. + + -- Matthias Klose Tue, 15 Jul 2008 12:57:20 +0000 + +python2.6 (2.6~a3-0ubuntu1~ppa2) hardy; urgency=low + + * Test build + + -- Matthias Klose Thu, 29 May 2008 18:08:48 +0200 + +python2.6 (2.6~a3-0ubuntu1~ppa1) hardy; urgency=low + + * Python 2.6 alpha3 release. + * Update to current trunk 20080523. + + -- Matthias Klose Thu, 22 May 2008 17:37:46 +0200 + +python2.5 (2.5.2-5) unstable; urgency=low + + * Backport new function signal.set_wakeup_fd from the trunk. + Background: http://bugzilla.gnome.org/show_bug.cgi?id=481569 + + -- Matthias Klose Wed, 30 Apr 2008 12:05:10 +0000 + +python2.5 (2.5.2-4) unstable; urgency=low + + * Update to 20080427, taken from the 2.5 release branch. + - Fix issues #2670, #2682. + * Disable running pybench on the hppa buildd (ftbfs). + * Allow setting BASECFLAGS, OPT and EXTRA_LDFLAGS (like, CC, CXX, CPP, + CFLAGS, CPPFLAGS, CCSHARED, LDSHARED) from the environment. + * Support parallel= in DEB_BUILD_OPTIONS (see #209008). + + -- Matthias Klose Sun, 27 Apr 2008 10:40:51 +0200 + +python2.5 (2.5.2-3) unstable; urgency=medium + + * Update to 20080416, taken from the 2.5 release branch. + - Fix CVE-2008-1721, integer signedness error in the zlib extension module. + - Fix urllib2 file descriptor happens byte-at-a-time, reverting + a fix for excessively large memory allocations when calling .read() + on a socket object wrapped with makefile(). + * Disable some regression tests on some architectures: + - arm: test_compiler, test_ctypes. + - armel: test_compiler. + - hppa: test_fork1, test_wait3. + - m68k: test_bsddb3, test_compiler. + * Build-depend on libffi-dev instead of libffi4-dev. + * Fix CVE-2008-1679, integer overflows in the imageop module. + + -- Matthias Klose Wed, 16 Apr 2008 23:37:46 +0200 + +python2.5 (2.5.2-2) unstable; urgency=low + + * Use site.addsitedir() to add directories in /usr/local to sys.path. + Addresses: #469157, #469818. + + -- Matthias Klose Sat, 08 Mar 2008 16:11:23 +0100 + +python2.5 (2.5.2-1) unstable; urgency=low + + * Python 2.5.2 release. + * Merge from Ubuntu: + - Move site customization into sitecustomize.py, don't make site.py + a config file. Addresses: #309719, #413172, #457361. + - Move site.py to python2.4-minimal, remove `addbuilddir' from site.py, + which is unnecessary for installed builds. + - python2.5-dev: Recommend libc-dev instead of suggesting it. LP: #164909. + - Fix issue 961805, Tk Text.edit_modified() fails. LP: #84720. + + -- Matthias Klose Thu, 28 Feb 2008 23:18:52 +0100 + +python2.5 (2.5.1-7) unstable; urgency=low + + * Update to 20080209, taken from the 2.5 release branch. + * Build the _bsddb extension with db-4.5 again; 4.6 is seriously + broken when used with the _bsddb extension. + * Do not run pybench on arm and armel. + * python2.5: Provide python2.5-wsgiref. + * Fix a pseudo RC report with duplicated attributes in the control + file. Closes: #464307. + + -- Matthias Klose Sun, 10 Feb 2008 00:22:57 +0100 + +python2.5 (2.5.1-6) unstable; urgency=low + + * Update to 20080102, taken from the 2.5 release branch. + - Only define _BSD_SOURCE on OpenBSD systems. Closes: #455400. + * Fix handling of packages in linecache.py (Kevin Goodsell). LP: #70902. + * Bump debhelper to v5. + * Register binfmt for .py[co] files. + * Use absolute paths when byte-compiling files. Addresses: #453346. + Closes: #413566, LP: #177722. + * CVE-2007-4965, http://bugs.python.org/issue1179: + Multiple integer overflows in the imageop module in Python 2.5.1 and + earlier allow context-dependent attackers to cause a denial of service + (application crash) and possibly obtain sensitive information (memory + contents) via crafted arguments to (1) the tovideo method, and unspecified + other vectors related to (2) imageop.c, (3) rbgimgmodule.c, and other + files, which trigger heap-based buffer overflows. + Patch prepared by Stephan Herrmann. Closes: #443333, LP: #163845. + * Register info docs when doing source only uploads. LP: #174786. + * Remove deprecated value from categories in desktop file. LP: #172874. + * python2.5-dbg: Don't include the gdbm and _tkinter extensions, now provided + in separate packages. + * Provide a symlink changelog -> NEWS. Closes: #439271. + * Fix build failure on hurd, working around poll() on systems on which it + returns an error on invalid FDs. Closes: #438914. + * Configure --with-system-ffi on all architectures. Closes: #448520. + * Fix version numbers in copyright and README files (Dan O'Huiginn). + Closes: #446682. + * Move some documents from python2.5 to python2.5-dev. + + -- Matthias Klose Wed, 02 Jan 2008 22:22:19 +0100 + +python2.5 (2.5.1-5) unstable; urgency=low + + * Build the _bsddb extension with db-4.6. + + -- Matthias Klose Fri, 17 Aug 2007 00:39:35 +0200 + +python2.5 (2.5.1-4) unstable; urgency=low + + * Update to 20070813, taken from the 2.5 release branch. + * Include plat-mac/plistlib.py (plat-mac is not in sys.path by default. + Closes: #435826. + * Use emacs22 to build the documentation in info format. Closes: #434969. + * Build-depend on db-dev (>= 4.6). Closes: #434965. + + -- Matthias Klose Mon, 13 Aug 2007 22:22:44 +0200 + +python2.5 (2.5.1-3) unstable; urgency=high + + * Support mixed-endian IEEE floating point, as found in the ARM old-ABI + (Aurelien Jarno). Closes: #434905. + + -- Matthias Klose Fri, 27 Jul 2007 20:01:35 +0200 + +python2.5 (2.5.1-2) unstable; urgency=low + + * Update to 20070717, taken from the 2.5 release branch. + * Fix reference count for sys.pydebug variable. Addresses: #431393. + * Build depend on libbluetooth-dev instead of libbluetooth2-dev. + + -- Matthias Klose Tue, 17 Jul 2007 14:09:47 +0200 + +python2.5 (2.5.1-1) unstable; urgency=low + + * Python-2.5.1 release. + * Build-depend on gcc-4.1 (>= 4.1.2-4) on alpha, powerpc, s390, sparc. + * Merge from Ubuntu: + - Add debian/patches/subprocess-eintr-safety.dpatch (LP: #87292): + - Create and use wrappers around read(), write(), and os.waitpid() in the + subprocess module which retry the operation on an EINTR (which happens + if e. g. an alarm was raised while the system call was in progress). + It is incredibly hard and inconvenient to sensibly handle this in + applications, so let's fix this at the right level. + - Patch based on original proposal of Peter <85>strand + in http://python.org/sf/1068268. + - Add two test cases. + - Change the interpreter to build and install python extensions + built with the python-dbg interpreter with a different name into + the same path (by appending `_d' to the extension name). The debug build + of the interpreter tries to first load a foo_d.so or foomodule_d.so + extension, then tries again with the normal name. + - When trying to import the profile and pstats modules, don't + exit, add a hint to the exception pointing to the python-profiler + package, don't exit. + - Keep the module version in the .egg-info name, only remove the + python version. + - python2.5-dbg: Install Misc/SpecialBuilds.txt, document the + debug changes in README.debug. + * Update to 20070425, taken from the 2.5 release branch. + + -- Matthias Klose Wed, 25 Apr 2007 22:12:50 +0200 + +python2.5 (2.5-6) unstable; urgency=medium + + * webbrowser.py: Recognize other browsers: www-browser, x-www-browser, + iceweasel, iceape. + * Move pyconfig.h from the python2.5-dev into the python2.5 package; + required by builds for pure python modules without having python2.5-dev + installed (matching the functionality in python2.4). + * Move the unicodedata module into python2.5-minimal; allows byte compilation + of UTF8 encoded files. + * Do not install anymore outdated debhelper sample scripts. + * Install Misc/SpecialBuilds.txt as python2.5-dbg document. + + -- Matthias Klose Wed, 21 Feb 2007 01:17:12 +0100 + +python2.5 (2.5-5) unstable; urgency=high + + * Do not run the python benchmark on m68k. Timer problems. + Fixes FTBFS on m68k. + * Update to 20061209, taken from the 2.5 release branch. + - Fixes building the library reference in info format. + + -- Matthias Klose Sat, 9 Dec 2006 13:40:48 +0100 + +python2.5 (2.5-4) unstable; urgency=medium + + * Update to 20061203, taken from the 2.5 release branch. + - Fixes build failures on knetfreebsd and the hurd. Closes: #397000. + * Clarify README about distutils. Closes: #396394. + * Move python2.5-config to python2.5-dev. Closes: #401451. + * Cleanup build-conflicts. Addresses: #394512. + + -- Matthias Klose Sun, 3 Dec 2006 18:22:49 +0100 + +python2.5 (2.5-3.1) unstable; urgency=low + + * Non-maintainer upload. + * python2.5-minimal depends on python-minimal (>= 2.4.4-1) because it's the + first version which lists python2.5 as an unsupported runtime (ie a + runtime that is available but for which modules are not auto-compiled). + And being listed there is required for python-central to accept the + installation of python2.5-minimal. Closes: #397006 + + -- Raphael Hertzog Wed, 22 Nov 2006 15:41:06 +0100 + +python2.5 (2.5-3) unstable; urgency=medium + + * Update to 20061029 (2.4.4 was released on 20061019), taken from + the 2.5 release branch. We do not want to have regressions in + 2.5 compared to the 2.4.4 release. + * Don't run pybench on m68k, fails in the calibration loop. Closes: #391030. + * Run the installation/removal hooks. Closes: #383292, #391036. + + -- Matthias Klose Sun, 29 Oct 2006 11:35:19 +0100 + +python2.5 (2.5-2) unstable; urgency=medium + + * Update to 20061003, taken from the 2.5 release branch. + * On arm and m68k, don't run the pybench in debug mode. + * Fix building the source within exec_prefix (Alexander Wirt). + Closes: #385336. + + -- Matthias Klose Tue, 3 Oct 2006 10:08:36 +0200 + +python2.5 (2.5-1) unstable; urgency=low + + * Python 2.5 release. + * Update to 20060926, taken from the 2.5 release branch. + * Run the Python benchmark during the build, compare the results + of the static and shared builds. + * Fix invalid html in python2.5.devhelp.gz. + * Add a python2.5 console entry to the menu (hidden by default). + * python2.5: Suggest python-profiler. + + -- Matthias Klose Tue, 26 Sep 2006 02:36:11 +0200 + +python2.5 (2.5~c1-1) unstable; urgency=low + + * Python 2.5 release candidate 1. + * Update to trunk 20060818. + + -- Matthias Klose Sat, 19 Aug 2006 19:21:05 +0200 + +python2.5 (2.5~b3-1) unstable; urgency=low + + * Build the _ctypes module for m68k-linux. + + -- Matthias Klose Fri, 11 Aug 2006 18:19:19 +0000 + +python2.5 (2.5~b3-0ubuntu1) edgy; urgency=low + + * Python 2.5 beta3 release. + * Update to trunk 20060811. + * Rebuild the documentation. + * Fix value of sys.exec_prefix in the debug build. + * Do not build the library reference in info format; fails to build. + * Link the interpreter against the shared runtime library. With + gcc-4.1 the difference in the pystones benchmark dropped from about + 12% to about 6%. + * Install the statically linked version of the interpreter as + python2.5-static for now. + * Link the shared libpython with -O1. + + -- Matthias Klose Thu, 10 Aug 2006 14:04:48 +0000 + +python2.5 (2.4.3+2.5b2-3) unstable; urgency=low + + * Disable the testsuite on s390; don't care about "minimally configured" + buildd's. + + -- Matthias Klose Sun, 23 Jul 2006 11:45:03 +0200 + +python2.5 (2.4.3+2.5b2-2) unstable; urgency=low + + * Update to trunk 20060722. + * Merge idle-lib from idle-python2.5 into python2.5. + * Merge lib-tk from python-tk into python2.5. + * Tkinter.py: Suggest installation of python-tk package on failed + import of the _tkinter extension. + * Don't run the testsuite for the debug build on alpha. + * Don't run the test_compiler test on m68k. Just takes too long. + * Disable building ctypes on m68k (requires support for closures). + + -- Matthias Klose Sat, 22 Jul 2006 22:26:42 +0200 + +python2.5 (2.4.3+2.5b2-1) unstable; urgency=low + + * Python 2.5 beta2 release. + * Update to trunk 20060716. + * When built on a buildd, do not run the following test which try to + access the network: test_codecmaps_cn, test_codecmaps_hk, test_codecmaps_jp, + test_codecmaps_kr, test_codecmaps_tw, test_normalization. + * When built on a buildd, do not run tests requiring missing write permissions: + test_ossaudiodev. + + -- Matthias Klose Sun, 16 Jul 2006 02:53:50 +0000 + +python2.5 (2.4.3+2.5b2-0ubuntu1) edgy; urgency=low + + * Python 2.5 beta2 release. + + -- Matthias Klose Thu, 13 Jul 2006 17:16:52 +0000 + +python2.5 (2.4.3+2.5b1-1ubuntu2) edgy; urgency=low + + * Fix python-dev dependencies. + * Update to trunk 20060709. + + -- Matthias Klose Sun, 9 Jul 2006 18:50:32 +0200 + +python2.5 (2.4.3+2.5b1-1ubuntu1) edgy; urgency=low + + * Python 2.5 beta1 release. + * Update to trunk 20060623. + * Merge changes from the python2.4 packages. + * python2.5-minimal: Add _struct. + + -- Matthias Klose Fri, 23 Jun 2006 16:04:46 +0200 + +python2.5 (2.4.3+2.5a1-1) experimental; urgency=low + + * Update to trunk 20060409. + * Run testsuite for debug build as well. + * Build-depend on gcc-4.1. + + -- Matthias Klose Sun, 9 Apr 2006 22:27:05 +0200 + +python2.5 (2.4.3+2.5a1-0ubuntu1) dapper; urgency=low + + * Python 2.5 alpha1 release. + * Drop integrated patches. + * Add build dependencies on libsqlite3-dev and libffi4-dev. + * Add (build-)dependency on mime-support, libgpmg1 (test suite). + * Build using the system FFI. + * python2.5 provides python2.5-ctypes and python2.5-pysqlite2, + python2.5-elementtree. + * Move hashlib.py to python-minimal. + * Lib/hotshot/pstats.py: Error out on missing profile/pstats modules. + + -- Matthias Klose Wed, 5 Apr 2006 14:56:15 +0200 + +python2.4 (2.4.3-8ubuntu1) edgy; urgency=low + + * Resynchronize with Debian unstable. Remaining changes: + - Apply langpack-gettext patch. + - diff.gz contains pregenerated html and info docs. + - Build the -doc package from this source. + + -- Matthias Klose Thu, 22 Jun 2006 18:39:57 +0200 + +python2.4 (2.4.3-8) unstable; urgency=low + + * Remove python2.4's dependency on python-central. On installation of + the runtime, call hooks /usr/share/python/runtime.d/*.rtinstall. + On removal, call hooks /usr/share/python/runtime.d/*.rtremove. + Addresses: #372658. + * Call the rtinstall hooks only, if it's a new installation, or the first + installation using the hooks. Adresses: #373677. + + -- Matthias Klose Sun, 18 Jun 2006 00:56:13 +0200 + +python2.4 (2.4.3-7) unstable; urgency=medium + + * Reupload, depend on python-central (>= 0.4.15). + * Add build-conflict on python-xml. + + -- Matthias Klose Wed, 14 Jun 2006 18:56:57 +0200 + +python2.4 (2.4.3-6) medium; urgency=low + + * idle-python2.4: Remove the old postinst and prerm scripts. + * Name the runtime correctly in python2.4-minimal's installation + scripts. + + -- Matthias Klose Mon, 12 Jun 2006 17:39:56 +0000 + +python2.4 (2.4.3-5) unstable; urgency=low + + * python2.4-prerm: Handle the case, when python-central is not installed. + * idle-python2.4: Depend on python-tk instead of python2.4-tk. + + -- Matthias Klose Fri, 9 Jun 2006 05:17:17 +0200 + +python2.4 (2.4.3-4) unstable; urgency=low + + * SVN update up to 2006-06-07 + * Use python-central. + * Don't build the -tk and -gdbm packages from this source; now built + from the python-stdlib-extensions source. + * Remove leftover build dependency on libgmp3-dev. + * Do not build-depend on libbluetooth1-dev and libgpmg1-dev on + hurd-i386, kfreebsd-i386, kfreebsd-amd64. Closes: #365830. + * Do not run the test_tcl test; hangs for unknown reasons on at least + the following buildds: vivaldi(m68k), goedel (alpha), mayer (mipsel). + And no virtual package to file bug reports for the buildds ... + Closes: #364419. + * Move the Makefile from python2.4-dev to python2.4. Closes: #366473. + * Fix typo in pdb(1). Closes: #365772. + * New autoconf likes the mandir in /usr/share instead of /usr; work + with both locations. Closes: #367618. + + -- Matthias Klose Wed, 7 Jun 2006 21:37:20 +0200 + +python2.4 (2.4.3-3) unstable; urgency=low + + * SVN update up to 2006-04-21 + * Update locale aliases from /usr/share/X11/locale/locale.alias. + * Start idle with option -n from the desktop menu, so that the program + can be started in parallel. + * Testsuite related changes only: + - Add build dependencies mime-support, libgpmg1 (needed by test cases). + - Run the testsuite with bsddb, audio and curses resources enabled. + - Re-run the failed tests in verbose mode. + - Run the test suite for the debug build as well. + - Build depend on netbase, needed by test_socketmodule. + - Build depend on libgpmg1, needed by test_curses. + - On the buildds do not run the tests needing the network resource. + * Update python logo. + * Check for the availability of the profile and pstats modules when + importing hotshot.pstats. Closes: #334067. + * Don't build the -doc package from the python2.4 source. + * Set OPT in the installed Makefile to -O2. + + -- Matthias Klose Fri, 21 Apr 2006 19:58:43 +0200 + +python2.4 (2.4.3-2) unstable; urgency=low + + * Add (build-)dependency on mime-support. + + -- Matthias Klose Tue, 4 Apr 2006 22:21:41 +0200 + +python2.4 (2.4.3-1) unstable; urgency=low + + * Python 2.4.3 release. + + -- Matthias Klose Thu, 30 Mar 2006 23:42:37 +0200 + +python2.4 (2.4.3-0ubuntu1) dapper; urgency=low + + * Python 2.4.3 release. + - Fixed a bug that the gb18030 codec raises RuntimeError on encoding + surrogate pair area on UCS4 build. Ubuntu: #29289. + + -- Matthias Klose Thu, 30 Mar 2006 10:57:32 +0200 + +python2.4 (2.4.2+2.4.3c1-0ubuntu1) dapper; urgency=low + + * SVN update up to 2006-03-25 (2.4.3 candidate 1). + - Regenerate the documentation. + + -- Matthias Klose Mon, 27 Mar 2006 12:03:05 +0000 + +python2.4 (2.4.2-1ubuntu3) dapper; urgency=low + + * SVN update up to 2006-03-04 + - Regenerate the documentation. + - map.mmap(-1, size, ...) can return anonymous memory again on Unix. + Ubuntu #26201. + * Build-depend on libncursesw5-dev, ncursesw5 is preferred for linking. + Provides UTF-8 compliant curses bindings. + * Fix difflib where certain patterns of differences were making difflib + touch the recursion limit. + + -- Matthias Klose Sat, 4 Mar 2006 21:38:24 +0000 + +python2.4 (2.4.2-1ubuntu2) dapper; urgency=low + + * SVN update up to 2006-01-17 + - pwd is now a builtin module, remove it from python-minimal. + - Regenerate the documentation. + * python2.4-tk: Suggest tix instead of tix8.1. + * Move config/Makefile from the -dev package into the runtime package + to be able to use the bdist_wininst distutils command. Closes: #348335. + + -- Matthias Klose Tue, 17 Jan 2006 11:02:24 +0000 + +python2.4 (2.4.2-1ubuntu1) dapper; urgency=low + + * Temporarily remove build dependency on lsb-release. + + -- Matthias Klose Sun, 20 Nov 2005 17:40:18 +0100 + +python2.4 (2.4.2-1build1) dapper; urgency=low + + * Rebuild (openssl-0.9.8). + + -- Matthias Klose Sun, 20 Nov 2005 15:27:24 +0000 + +python2.4 (2.4.2-1) unstable; urgency=low + + * Python 2.4.2 release. + + -- Matthias Klose Thu, 29 Sep 2005 01:49:28 +0200 + +python2.4 (2.4.1+2.4.2rc1-1) unstable; urgency=low + + * Python 2.4.2 release candidate 1. + * Fix "Fatal Python error" from cStringIO's writelines. + Patch by Andrew Bennetts. + + -- Matthias Klose Thu, 22 Sep 2005 10:33:22 +0200 + +python2.4 (2.4.1-5) unstable; urgency=low + + * CVS update up to 2005-09-14 + - Regenerate the html and info docs. + * Add some more locale aliases. + * Fix substitution pf python version in README.python2.4-minimal. + Closes: #327487. + * On m68k, build using -O2 (closes: #326903). + * On Debian, don't configure --with-fpectl, which stopped working with + glibc-2.3.5. + + -- Matthias Klose Wed, 14 Sep 2005 17:32:56 +0200 + +python2.4 (2.4.1-4) unstable; urgency=low + + * CVS update up to 2005-09-04 + - teTeX 3.0 related fixes (closes: #322407). + - Regenerate the html and info docs. + * Add entry for IDLE in the Gnome menus. + * Don't build-depend on libbluetooth-dev on the Hurd (closes: #307037). + * Reenable the cthreads patch for the Hurd (closes: #307052). + + -- Matthias Klose Sun, 4 Sep 2005 18:31:42 +0200 + +python2.4 (2.4.1-3) unstable; urgency=low + + * Synchronise with Ubuntu: + - Build a python2.4-minimal package. + + -- Matthias Klose Tue, 12 Jul 2005 00:23:10 +0000 + +python2.4 (2.4.1-2ubuntu3) breezy; urgency=low + + * CVS update up to 2005-07-07 + * Regenerate the documentation. + + -- Matthias Klose Thu, 7 Jul 2005 09:21:28 +0200 + +python2.4 (2.4.1-2ubuntu2) breezy; urgency=low + + * CVS update up to 2005-06-15 + * Regenerate the documentation. + * Synchronize with Debian. Ubuntu 10485. + * idle-python2.4 enhances python2.4. Ubuntu 11562. + * README.Debian: Fix reference to the doc directory (closes: #311677). + + -- Matthias Klose Wed, 15 Jun 2005 08:56:57 +0200 + +python2.4 (2.4.1-2ubuntu1) breezy; urgency=low + + * Update build dependencies: + db4.2-dev -> db4.3-dev, + libreadline4-dev -> libreadline5-dev. + * python2.4-dev: Add missing templates to generate HTML docs. Ubuntu 11531. + + -- Matthias Klose Sun, 29 May 2005 00:01:05 +0200 + +python2.4 (2.4.1-2) unstable; urgency=low + + * Add the debug symbols for the python2.4, python2.4-gdbm + and python2.4-tk packages to the python2.4-dbg package. + * Add gdbinit example to doc directory. + + -- Matthias Klose Thu, 5 May 2005 11:12:32 +0200 + +python2.4 (2.4.1-1ubuntu2) breezy; urgency=low + + * Add the debug symbols for the python2.4, python2.4-minimal, python2.4-gdbm + and python2.4-tk packages to the python2.4-dbg package. Ubuntu 10261, + * Add gdbinit example to doc directory. + * For os.utime, use utimes(2), correctly working with glibc-2.3.5. + Ubuntu 10294. + + -- Matthias Klose Thu, 5 May 2005 09:06:07 +0200 + +python2.4 (2.4.1-1ubuntu1) breezy; urgency=low + + * Reupload as 2.4.1-1ubuntu1. + + -- Matthias Klose Thu, 14 Apr 2005 10:46:32 +0200 + +python2.4 (2.4.1-1) unstable; urgency=low + + * Python 2.4.1 release. + * Fix noise in python-doc installation/removal. + * New Python section for the info docs. + + -- Matthias Klose Wed, 30 Mar 2005 19:42:03 +0200 + +python2.4 (2.4.1-0) hoary; urgency=low + + * Python 2.4.1 release. + * Fix noise in python-doc installation/removal. + * New Python section for the info docs. + + -- Matthias Klose Wed, 30 Mar 2005 16:35:34 +0200 + +python2.4 (2.4+2.4.1rc2-2) unstable; urgency=low + + * Add the valgrind support file to /etc/python2.4 + * Build the -dbg package with -DPy_USING_MEMORY_DEBUGGER. + * Lib/locale.py: + - correctly parse LANGUAGE as a colon separated list of languages. + - prefer LC_ALL, LC_CTYPE and LANG over LANGUAGE to get the correct + encoding. + - Don't map 'utf8', 'utf-8' to 'utf', which is not a known encoding + for glibc. + * Fix two typos in python(1). Addresses: #300124. + + -- Matthias Klose Sat, 19 Mar 2005 21:50:14 +0100 + +python2.4 (2.4+2.4.1rc2-1) unstable; urgency=low + + * Python 2.4.1 release candidate 2. + * Build-depend on libbluetooth1-dev. + + -- Matthias Klose Sat, 19 Mar 2005 00:57:14 +0100 + +python2.4 (2.4dfsg-2) unstable; urgency=low + + * CVS update up to 2005-03-03 + + -- Matthias Klose Thu, 3 Mar 2005 22:22:16 +0100 + +python2.4 (2.4dfsg-1ubuntu4) hoary; urgency=medium + + * Move exception finalisation later in the shutdown process - this + fixes the crash seen in bug #1165761, taken from CVS. + * codecs.StreamReader: Reset codec when seeking. Ubuntu #6972. + * Apply fix for SF1124295, fixing an obscure bit of Zope's security machinery. + * distutils: Don't add standard library dirs to library_dirs + and runtime_library_dirs. On amd64, runtime paths pointing to /usr/lib64 + aren't recognized by dpkg-shlibdeps, and the packages containing these + libraries aren't added to ${shlibs:Depends}. + * Lib/locale.py: + - correctly parse LANGUAGE as a colon separated list of languages. + - prefer LC_ALL, LC_CTYPE and LANG over LANGUAGE to get the correct + encoding. + - Don't map 'utf8', 'utf-8' to 'utf', which is not a known encoding + for glibc. + * os.py: Avoid using items() in environ.update(). Fixes #1124513. + * Python/pythonrun.c: + * Build depend on locales, generate the locales needed for the + testsuite. + * Add build dependency on libbluetooth1-dev, adding some bluetooth + functionality to the socket module. + * Lib/test/test_sundry.py: Don't fail on import of profile & pstats, + which are separated out to the python-profiler package. + * Fix typos in manpage. + + -- Matthias Klose Tue, 29 Mar 2005 13:35:53 +0200 + + +python2.4 (2.4dfsg-1ubuntu3) hoary; urgency=low + + * debian/patches/langpack-gettext.dpatch: + - langpack support for python-gettext added + + -- Michael Vogt Tue, 1 Mar 2005 13:13:36 +0100 + +python2.4 (2.4dfsg-1ubuntu2) hoary; urgency=low + + * Revert 'essential' status on python2.4-minimal. This status on + on python-minimal is sufficient (Ubuntu #6392). + + -- Matthias Klose Wed, 9 Feb 2005 23:09:42 +0100 + +python2.4 (2.4dfsg-1ubuntu1) hoary; urgency=low + + * Resyncronise with Debian. + * Mark the python2.4-minimal package as 'essential'. + + -- Matthias Klose Wed, 9 Feb 2005 13:31:09 +0100 + +python2.4 (2.4dfsg-1) unstable; urgency=medium + + * Add licenses and acknowledgements for incorporated software in the + debian/copyright file (addresses: #293932). + * Replace md5 implementation with one having a DFSG conforming license. + * Remove the profile.py and pstats.py modules from the source package, + not having a DFSG conforming license. The modules can be found in + the python2.x-profile package in the non-free section. + Addresses: #293932. + * Add missing norwegian locales (Tollef Fog Heen). + * CVS updates of the release24-maint branch upto 2005-02-08 (date of + the Python 2.3.5 release). + + -- Matthias Klose Tue, 8 Feb 2005 19:13:10 +0100 + +python2.4 (2.4-7ubuntu1) hoary; urgency=low + + * Fix the name of the python-dbg man page. + * Resyncronise with Debian. + * Move more modules to -minimal (new code in copy.py requires these): + dis, inspect, opcode, token, tokenize. + + -- Matthias Klose Tue, 8 Feb 2005 19:13:10 +0100 + +python2.4 (2.4-7) unstable; urgency=medium + + * Add licenses and acknowledgements for incorporated software in the + debian/copyright file (addresses: #293932). + * Replace md5 implementation with one having a DFSG conforming license. + * Add missing norwegian locales (Tollef Fog Heen). + * CVS updates of the release24-maint branch upto 2005-02-08 (date of + the Python 2.3.5 release). + + -- Matthias Klose Tue, 8 Feb 2005 19:13:10 +0100 + +python2.4 (2.4-6) unstable; urgency=low + + * Build a python2.4-dbg package using --with-pydebug. Add a debug + directory /lib-dynload/debug to sys.path instead of + /lib-dynload und install the extension modules of the + debug build in this directory. + Change the module load path to load extension modules from other + site-packages/debug directories (for further details see the + README in the python2.4-dbg package). Closes: #5415. + * Apply the pydebug-path patch. The package was already built in -5. + + -- Matthias Klose Fri, 4 Feb 2005 22:15:13 +0100 + +python2.4 (2.4-5) unstable; urgency=high + + * Fix a flaw in SimpleXMLRPCServerthat can affect any XML-RPC servers. + This affects any programs have been written that allow remote + untrusted users to do unrestricted traversal and can allow them to + access or change function internals using the im_* and func_* attributes. + References: CAN-2005-0089. + * CVS updates of the release24-maint branch upto 2005-02-04. + + -- Matthias Klose Fri, 4 Feb 2005 08:12:10 +0100 + +python2.4 (2.4-4) unstable; urgency=medium + + * Update debian/copyright to the 2.4 license text (closes: #290898). + * Remove /usr/bin/smtpd.py (closes: #291049). + + -- Matthias Klose Mon, 17 Jan 2005 23:54:37 +0100 + +python2.4 (2.4-3ubuntu6) hoary; urgency=low + + * Use old-style dpatches instead of dpatch-run. + + -- Tollef Fog Heen Mon, 7 Feb 2005 15:58:05 +0100 + +python2.4 (2.4-3ubuntu5) hoary; urgency=low + + * Actually apply the patch as well (add to list of patches in + debian/rules) + + -- Tollef Fog Heen Sun, 6 Feb 2005 15:12:58 +0100 + +python2.4 (2.4-3ubuntu4) hoary; urgency=low + + * Add nb_NO and nn_NO locales to Lib/locale.py + + -- Tollef Fog Heen Sun, 6 Feb 2005 14:33:05 +0100 + +python2.4 (2.4-3ubuntu3) hoary; urgency=low + + * Fix a flaw in SimpleXMLRPCServerthat can affect any XML-RPC servers. + This affects any programs have been written that allow remote + untrusted users to do unrestricted traversal and can allow them to + access or change function internals using the im_* and func_* attributes. + References: CAN-2005-0089. + + -- Matthias Klose Wed, 2 Feb 2005 09:08:20 +0000 + +python2.4 (2.4-3ubuntu2) hoary; urgency=low + + * Build a python2.4-dbg package using --with-pydebug. Add a debug + directory /lib-dynload/debug to sys.path instead of + /lib-dynload und install the extension modules of the + debug build in this directory. + Change the module load path to load extension modules from other + site-packages/debug directories (for further details see the + README in the python2.4-dbg package). Closes: #5415. + * Update debian/copyright to the 2.4 license text (closes: #290898). + * Add operator and copy to the -minimal package. + + -- Matthias Klose Mon, 17 Jan 2005 23:19:47 +0100 + +python2.4 (2.4-3ubuntu1) hoary; urgency=low + + * Resynchronise with Debian. + * python2.4: Depend on the very same version of python2.4-minimal. + * Docment, that time.strptime currently cannot be used, if the + python-minimal package is installed without the python package. + + -- Matthias Klose Sun, 9 Jan 2005 19:35:48 +0100 + +python2.4 (2.4-3) unstable; urgency=medium + + * Build the fpectl module. + * Updated to CVS release24-maint 20050107. + + -- Matthias Klose Sat, 8 Jan 2005 19:05:21 +0100 + +python2.4 (2.4-2ubuntu5) hoary; urgency=low + + * Updated to CVS release24-maint 20050102. + * python-minimal: + - os.py: Use dict instead of UserDict, remove UserDict from -minimal. + - add pickle, threading, needed for subprocess module. + - optparse.py: conditionally import gettext, if not available, + define _ as the identity function. Patch taken from the trunk. + Avoids import of _locale, locale, gettext, copy, repr, itertools, + collections, token, tokenize. + - Add a build check to make sure that the minimal module list is + closed under dependency. + * Fix lintian warnings. + + -- Matthias Klose Sun, 2 Jan 2005 22:00:14 +0100 + +python2.4 (2.4-2ubuntu4) hoary; urgency=low + + * Add UserDict.py to the -minimal package, since os.py needs it. + + -- Colin Watson Thu, 30 Dec 2004 20:41:28 +0000 + +python2.4 (2.4-2ubuntu3) hoary; urgency=low + + * Add os.py and traceback.py to the -minimal package, get the list + of modules from the README. + + -- Matthias Klose Mon, 27 Dec 2004 08:20:45 +0100 + +python2.4 (2.4-2ubuntu2) hoary; urgency=low + + * Add compileall.py and py_compile.py to the -minimal package, not + just to the README ... + + -- Matthias Klose Sat, 25 Dec 2004 22:24:56 +0100 + +python2.4 (2.4-2ubuntu1) hoary; urgency=low + + * Separate the interpreter and a minimal subset of modules into + a python2.4-minimal package. See the README.Debian.gz in this + package. + * Move site.py to python2.4-minimal as well. + * Add documentation files for devhelp. + + -- Matthias Klose Sun, 19 Dec 2004 22:47:32 +0100 + +python2.4 (2.4-2) unstable; urgency=medium + + * Updated patch for #283108. Thanks to Jim Meyering. + + -- Matthias Klose Fri, 3 Dec 2004 17:00:16 +0100 + +python2.4 (2.4-1) unstable; urgency=low + + * Final 2.4 release. + * Flush stdout/stderr if closed (SF #1074011). + + -- Matthias Klose Wed, 1 Dec 2004 07:54:34 +0100 + +python2.4 (2.3.97-2) unstable; urgency=low + + * Don't run test_tcl, hanging on the buildds. + + -- Matthias Klose Fri, 19 Nov 2004 23:48:42 +0100 + +python2.4 (2.3.97-1) unstable; urgency=low + + * Python 2.4 Release Candidate 1. + + -- Matthias Klose Fri, 19 Nov 2004 21:27:02 +0100 + +python2.4 (2.3.96-1) experimental; urgency=low + + * Updated to CVS release24-maint 20041113. + * Build the docs in info format again. + + -- Matthias Klose Sat, 13 Nov 2004 21:21:10 +0100 + +python2.4 (2.3.95-2) experimental; urgency=low + + * Move distutils package from the python2.4-dev into the python2.4 + package. + + -- Matthias Klose Thu, 11 Nov 2004 22:56:14 +0100 + +python2.4 (2.3.95-1) experimental; urgency=low + + * Python 2.4 beta2 release. + + -- Matthias Klose Thu, 4 Nov 2004 23:43:47 +0100 + +python2.4 (2.3.94-1) experimental; urgency=low + + * Python 2.4 beta1 release. + + -- Matthias Klose Sat, 16 Oct 2004 08:33:57 +0200 + +python2.4 (2.3.93-1) experimental; urgency=low + + * Python 2.4 alpha3 release. + + -- Matthias Klose Fri, 3 Sep 2004 21:53:47 +0200 + +python2.4 (2.3.92-1) experimental; urgency=low + + * Python 2.4 alpha2 release. + + -- Matthias Klose Thu, 5 Aug 2004 23:53:18 +0200 + +python2.4 (2.3.91-1) experimental; urgency=low + + * Python 2.4 alpha1 release. + Highlights: http://www.python.org/2.4/highlights.html + + -- Matthias Klose Fri, 9 Jul 2004 17:38:54 +0200 + +python2.4 (2.3.90-1) experimental; urgency=low + + * Package HEAD branch (pre alpha ..). + + -- Matthias Klose Mon, 14 Jun 2004 23:19:57 +0200 + +python2.3 (2.3.4-1) unstable; urgency=medium + + * Final Python 2.3.4 Release. + * In the API docs, fix signature of PyModule_AddIntConstant (closes: #250826). + * locale.getdefaultlocale: don't fail with empty environment variables. + Closes: #249816. + * Include distutils/command/wininst.exe in -dev package (closes: #249006). + * Disable cthreads on the Hurd (Michael Banck). Closes: #247211. + * Add a note to pygettext(1), that this program is deprecated in favour + of xgettext, which now includes support for Python as well. + Closes: #246332. + + -- Matthias Klose Fri, 28 May 2004 22:59:42 +0200 + +python2.3 (2.3.3.91-1) unstable; urgency=low + + * Python 2.3.4 Release Candidate 1. + * Do not use the default namespace for attributes. Patch taken from the + 2.3 maintenance branch. + The xmllib module is obsolete. Use xml.sax instead. + * http://python.org/sf/945642 - fix nonblocking i/o with ssl socket. + + -- Matthias Klose Thu, 13 May 2004 21:24:52 +0200 + +python2.3 (2.3.3-7) unstable; urgency=low + + * Add a workaround for GNU libc nl_langinfo()'s returning NULL. + Closes: #239237. + Patch taken from 2.3 maintenance branch. + * threading.py: Remove calls to currentThread() in _Condition methods that + were side-effect. Side-effects were deemed unnecessary and were causing + problems at shutdown time when threads were catching exceptions at start + time and then triggering exceptions trying to call currentThread() after + gc'ed. Masked the initial exception which was deemed bad. + Closes: #195812. + * Properly support normalization of empty unicode strings. Closes: #239986. + Patch taken from 2.3 maintenance branch. + * README.maintainers: Add section where to find the documentation tools. + * Fix crash in pyexpat module (closes: #229281). + * For the Hurd, set the interpreters recursion limit to 930. + * Do not try to byte-compile the test files on installation; this + currently breaks the Hurd install. + + -- Matthias Klose Sat, 1 May 2004 07:50:46 +0200 + +python2.3 (2.3.3-6) unstable; urgency=low + + * Don't build the unversioned python{,-*} packages anymore. Now + built from the python-defaults package. + * Update to the proposed python-policy: byte-compile using -E. + * Remove python-elisp's dependency on emacs20 (closes: #232785). + * Don't build python-elisp from the python2.3 source anymore, + get it from python-mode.sf.net as a separate source package. + * python2.3-dev suggests libc-dev (closes: #231091). + * get LDSHARED and CCSHARED (like, CC, CXX, CPP, CFLAGS) from + the environment + * Set CXX in installed config/Makefile (closes: #230273). + + -- Matthias Klose Tue, 24 Feb 2004 07:07:51 +0100 + +python2.3 (2.3.3-5) unstable; urgency=low + + * Build-depend on libdb4.2-dev, instead of libdb4.1-dev. According + to the docs the file format is compatible. + + -- Matthias Klose Mon, 12 Jan 2004 10:37:45 +0100 + +python2.3 (2.3.3-4) unstable; urgency=low + + * Fix broken _bsddb module. setup.py picked up the wrong library. + + -- Matthias Klose Sun, 4 Jan 2004 11:30:00 +0100 + +python2.3 (2.3.3-3) unstable; urgency=low + + * Fix typo in patch (closes: #224797, #226064). + + -- Matthias Klose Sun, 4 Jan 2004 09:23:21 +0100 + +python2.3 (2.3.3-2) unstable; urgency=medium + + * Lib/email/Charset: use locale unaware function to lower case of locale + name (closes: #224797). + * Update python-mode to version from python-mode.sf.net. Fixes highlighting + problems (closes: #223520). + * Backport from mainline: Add IPV6_ socket options from RFCs 3493 and 3542. + + -- Matthias Klose Fri, 2 Jan 2004 14:03:26 +0100 + +python2.3 (2.3.3-1) unstable; urgency=low + + * New upstream release. + * Copy the templates, tools and scripts from the Doc dir in the source + to /usr/share/lib/python2.3/doc in the python2.3-dev package. Needed + for packages building documentation like python does (closes: #207337). + + -- Matthias Klose Fri, 19 Dec 2003 10:57:39 +0100 + +python2.3 (2.3.2.91-1) unstable; urgency=low + + * New upstream version (2.3.3 release candidate). + * Update python-mode.el (closes: #158811, #159630). + Closing unreproducible report (closes: #159628). + + -- Matthias Klose Sat, 6 Dec 2003 14:41:14 +0100 + +python2.3 (2.3.2-7) unstable; urgency=low + + * Put the conflict in the correct direction. python2.3 (2.3.2-6) doesn't + conflict with python (<= 2.3.2-5) but python (2.3.2-6) conflicts with + python2.3 (<= 2.3.2-5) (thanks to Brian May). Really closes #221791. + + -- Matthias Klose Fri, 21 Nov 2003 00:20:02 +0100 + +python2.3 (2.3.2-6) unstable; urgency=low + + * Add conflicts with older python{,2.3} packages to fix overwrite + errors (closes: #221791). + + -- Matthias Klose Thu, 20 Nov 2003 07:24:36 +0100 + +python2.3 (2.3.2-5) unstable; urgency=low + + * Updated to CVS release23-maint 20031119. + * Re-upgrade the dependency of python2.3 on python (>= 2.3) to + a dependency (closes: #221523). + + -- Matthias Klose Wed, 19 Nov 2003 00:30:27 +0100 + +python2.3 (2.3.2-4) unstable; urgency=low + + * Don't build-depend on latex2html (moved to non-free), but keep + the prebuilt docs in debian/patches (closes: #221347). + * Fix typos in the library reference (closes: #220510, #220954). + * Fix typo in python-elisp's autoloading code (closes: #220308). + * Update proposed python policy: private modules can be installed + into /usr/lib/ (arch dependent) and into /usr/share/ + (arch independent). + + -- Matthias Klose Tue, 18 Nov 2003 00:41:39 +0100 + +python2.3 (2.3.2-3) unstable; urgency=low + + * Downgrade the dependency of python2.3 on python (>= 2.3) to + a recommendation. + * Fix path to interpreter in binfmt file. + * Fix segfault in unicodedata module (closes: #218697). + * Adjust python-elisp autoload code (closes: #219821). + + -- Matthias Klose Sun, 9 Nov 2003 19:43:37 +0100 + +python2.3 (2.3.2-2) unstable; urgency=medium + + * Fix broken doc link (closes: #214217). + * Disable wrongly detected large file support for GNU/Hurd. + * Really fix the FTBFS for the binary-indep target (closes: #214303). + + -- Matthias Klose Mon, 6 Oct 2003 07:54:58 +0200 + +python2.3 (2.3.2-1) unstable; urgency=low + + * New upstream version. + * Fix a FTBFS for the binary-indep target. + + -- Matthias Klose Sat, 4 Oct 2003 10:20:15 +0200 + +python2.3 (2.3.1-3) unstable; urgency=low + + * Fix names of codec packages in recommends. + * On alpha compile using -mieee (see #212912). + + -- Matthias Klose Sun, 28 Sep 2003 10:48:12 +0200 + +python2.3 (2.3.1-2) unstable; urgency=low + + * Update python policy draft (closes: #128911, #163785). + * Re-add os.fsync function (closes: #212672). + * Let python2.3-doc conflict with older python2.3 versions (closes: #211882). + * Add recommends for pythonX.Y-japanese-codecs, pythonX.Y-iconvcodec, + pythonX.Y-cjkcodecs, pythonX.Y-korean-codecs (closes: #207161). + * Generate binfmt file (closes: #208005). + * Add IPPROTO_IPV6 option to the socketmodule (closes: #206569). + * Bugs reported against python2.2 and fixed in python2.3: + - Crashes in idle (closes: #186887, #200084). + + -- Matthias Klose Sat, 27 Sep 2003 11:21:47 +0200 + +python2.3 (2.3.1-1) unstable; urgency=low + + * New upstream version (bug fix release). + + -- Matthias Klose Wed, 24 Sep 2003 11:27:43 +0200 + +python2.3 (2.3-4) unstable; urgency=high + + * Disable check for utimes function, which is broken in glibc-2.3.2. + Packages using distutils had '1970/01/01-01:00:01' timestamps in files. + * Bugs fixed by making python2.3 the default python version: + - Canvas.scan_dragto() takes a 3rd optional parmeter "gain". + Closes: #158168. + - New command line parsing module (closes: #38628). + - compileall.py allows compiling single files (closes: #139971). + * Bugs reported for 2.2 and fixed in 2.3: + - Idle does save files with ASCII characters (closes: #179313). + - imaplib support for prefix-quoted strings (closes: #150485). + - posixpath includes getctime (closes: #173827). + - pydoc has support for keywords (closes: #186775). + * Bugs reported for 2.1 and fixed in 2.3: + - Fix handling of "#anchor" URLs in urlparse (closes: #147844). + - Fix readline if C stdin is not a tty, even if sys.stdin is. + Closes: #131810. + * Updated to CVS release23-maint 20030810 (fixing memory leaks in + array and socket modules). + * pydoc's usage output uses the basename of the script. + * Don't explicitely remove /etc/python2.3 on purge (closes: #202864). + * python conflicts with python-xmlbase (closes: #204773). + * Add dependency python (>= 2.3) to python2.3, so make sure the + unversioned names can be used. + + -- Matthias Klose Sun, 10 Aug 2003 09:27:52 +0200 + +python2.3 (2.3-3) unstable; urgency=medium + + * Fix shlibs file. + + -- Matthias Klose Fri, 8 Aug 2003 08:45:12 +0200 + +python2.3 (2.3-2) unstable; urgency=medium + + * Make python2.3 the default python version. + + -- Matthias Klose Tue, 5 Aug 2003 22:13:22 +0200 + +python2.3 (2.3-1) unstable; urgency=low + + * Python 2.3 final release. + + -- Matthias Klose Wed, 30 Jul 2003 08:12:28 +0200 + +python2.3 (2.2.107-1rc2) unstable; urgency=medium + + * Python 2.3 release candidate 2. + * Don't compress .txt files referenced by the html docs (closes: #200298). + * Include the email/_compat* files (closes: #200349). + + -- Matthias Klose Fri, 25 Jul 2003 07:08:09 +0200 + +python2.3 (2.2.106-2beta2) unstable; urgency=medium + + * Python 2.3 beta2 release, updated to CVS 20030704. + - Fixes AssertionError in httplib (closed: #192452). + - Fixes uncaught division by zero in difflib.py (closed: #199287). + * Detect presence of setgroups(2) at configure time (closes: #199839). + * Use default gcc on arm as well. + + -- Matthias Klose Sat, 5 Jul 2003 10:21:33 +0200 + +python2.3 (2.2.105-1beta2) unstable; urgency=low + + * Python 2.3 beta2 release. + - Includes merged idle fork. + - Fixed socket.setdefaulttimeout(). Closes: #189380. + - socket.ssl works with _socketobj. Closes: #196082. + * Do not link libtix to the _tkinter module. It's loaded via + 'package require tix' at runtime. python2.3-tkinter now + suggests tix8.1 instead. + * On arm, use gcc-3.2 to build. + * Add -fno-strict-aliasing rules to OPT to avoid warnings + "dereferencing type-punned pointer will break strict-aliasing rules", + when building with gcc-3.3. + + -- Matthias Klose Mon, 30 Jun 2003 00:19:32 +0200 + +python2.3 (2.2.104-1beta1.1) unstable; urgency=low + + * Non-maintainer upload with maintainer consent. + * debian/control (Build-Depends): s/libgdbmg1-dev/libgdbm-dev/. + + -- James Troup Wed, 4 Jun 2003 02:24:27 +0100 + +python2.3 (2.2.104-1beta1) unstable; urgency=low + + * Python 2.3 beta1 release, updated to CVS 20030514. + - build the current documentation. + * Reenable Tix support. + + -- Matthias Klose Wed, 14 May 2003 07:38:57 +0200 + +python2.3 (2.2.103-1beta1) unstable; urgency=low + + * Python 2.3 beta1 release, updated to CVS 20030506. + - updated due to build problems on mips/mipsel. + - keep the 2.3b1 documentation (doc build problems with cvs). + + -- Matthias Klose Wed, 7 May 2003 06:26:39 +0200 + +python2.3 (2.2.102-1beta1) unstable; urgency=low + + * Python 2.3 beta1 release. + + -- Matthias Klose Sat, 3 May 2003 22:45:16 +0200 + +python2.3 (2.2.101-1exp1) unstable; urgency=medium + + * Python 2.3 alpha2 release, updated to CVS 20030321. + * Tkinter: Catch exceptions thrown for undefined substitutions in + events (needed for tk 8.4.2). + + -- Matthias Klose Fri, 21 Mar 2003 21:32:14 +0100 + +python2.3 (2.2.100-1exp1) unstable; urgency=low + + * Python 2.3 alpha2 release, updated to CVS 20030221. + + -- Matthias Klose Fri, 21 Feb 2003 19:37:17 +0100 + +python2.3 (2.2.99-1exp1) unstable; urgency=low + + * Python 2.3 alpha1 release updated to CVS 20030123. + - should fix the testsuite (and package build) failure on alpha. + * Remove build dependency on libexpat1-dev. Merge the python2.3-xmlbase + package into python2.3 (closes: #177739). + + -- Matthias Klose Thu, 23 Jan 2003 22:48:12 +0100 + +python2.3 (2.2.98-1exp1) unstable; urgency=low + + * Python 2.3 alpha1 release updated to CVS 20030117. + * Build using libdb4.1. + + -- Matthias Klose Sat, 18 Jan 2003 00:14:01 +0100 + +python2.3 (2.2.97-1exp1) unstable; urgency=low + + * Python 2.3 alpha1 release updated to CVS 20030109. + * Build-Depend on g++ (>= 3:3.2). + * Python package maintainers: please wait uploading python dependent + packages until python2.2 and python2.1 are compiled using gcc-3.2. + + -- Matthias Klose Thu, 9 Jan 2003 23:56:42 +0100 + +python2.3 (2.2.96-1exp1) unstable; urgency=low + + * Python 2.3 alpha1 release (not exactly the tarball, but taken from + CVS 20030101). + - Includes support for linking with threaded tk8.4 (closes: #172714). + * Install and register whatsnew document (closes: #173859). + * Properly unregister info documentation. + + -- Matthias Klose Wed, 1 Jan 2003 17:38:54 +0100 + +python2.3 (2.2.95-1exp1) unstable; urgency=low + + * Experimental packages from CVS 021212. + - data in unicodedate module is up to date (closes: #171061). + * Fix idle packaging (closes: #170394). + * Configure using unicode UCS-4 (closes: #171062). + This change breaks compatibility with binary modules, but what do you + expect from experimental packages ... Please recompile dependent packages. + * Don't strip binaries for now. + + -- Matthias Klose Thu, 12 Dec 2002 21:42:27 +0100 + +python2.3 (2.2.94-1exp1) unstable; urgency=low + + * Experimental packages from CVS 021120. + * Remove outdated README.dbm. + * Depend on tk8.4. + * python-elisp: Install emacsen install file with mode 644 (closes: #167718). + + -- Matthias Klose Thu, 21 Nov 2002 01:04:51 +0100 + +python2.3 (2.2.93-1exp1) unstable; urgency=medium + + * Experimental packages from CVS 021015. + * Build a static library libpython2.3-pic.a. + * Enable large file support for the Hurd (closes: #164602). + + -- Matthias Klose Tue, 15 Oct 2002 21:06:27 +0200 + +python2.3 (2.2.92-1exp1) unstable; urgency=low + + * Experimental packages from CVS 020922. + * Fix build error on ia64 (closes: #161234). + * Build depend on gcc-3.2-3.2.1-0pre2 to fix build error on arm. + + -- Matthias Klose Sun, 22 Sep 2002 18:30:28 +0200 + +python2.3 (2.2.91-1exp1) unstable; urgency=low + + * Experimental packages from CVS 020906. + * idle-python2.3: Fix conflict (closes: #159267). + * Fix location of python-mode.el (closes: #159564, #159619). + * Use tix8.1. + * Apply fix for distutils/ccompiler problem (closes: #159288). + + -- Matthias Klose Sat, 7 Sep 2002 09:55:07 +0200 + +python2.3 (2.2.90-1exp1) unstable; urgency=low + + * Experimental packages from CVS 020820. + * Don't build python2.3-elisp, but put the latest version into + python-elisp. + + -- Matthias Klose Thu, 22 Aug 2002 21:52:04 +0200 + +python2.2 (2.2.1-6) unstable; urgency=low + + * CVS updates of the release22-maint branch upto 2002-07-23. + * Enable IPv6 support (closes: #152543). + * Add python2.2-tk suggestion for python2.2 (pydoc -g). + * Fix from SF patch #527518: proxy config with user+pass authentication. + * Point pydoc to the correct location of the docs (closes: #147579). + * Remove '*.py[co]' files, when removing the python package, + not when purging (closes: #147130). + * Update to new py2texi.el version (Milan Zamazal). + + -- Matthias Klose Mon, 29 Jul 2002 23:11:32 +0200 + +python2.2 (2.2.1-5) unstable; urgency=low + + * CVS updates of the release22-maint branch upto 2002-05-03. + * Build the info docs (closes: #145653). + + -- Matthias Klose Fri, 3 May 2002 22:35:46 +0200 + +python2.2 (2.2.1-4) unstable; urgency=high + + * Fix indentation errors introduced in last upload (closes: #143809). + + -- Matthias Klose Sun, 21 Apr 2002 01:00:14 +0200 + +python2.2 (2.2.1-3) unstable; urgency=high + + * Add Build-Conflicts: tcl8.0-dev, tk8.0-dev, tcl8.2-dev, tk8.2-dev. + Closes: #143534 (build a working _tkinter module, on machines, where + 8.0's tk.h gets included). + * CVS updates of the release22-maint branch upto 2002-04-20. + + -- Matthias Klose Sat, 20 Apr 2002 09:22:37 +0200 + +python2.2 (2.2.1-2) unstable; urgency=low + + * Forgot to copy the dlmodule patch from the 2.1.3 package. Really + closes: #141681. + + -- Matthias Klose Sat, 13 Apr 2002 01:28:05 +0200 + +python2.2 (2.2.1-1) unstable; urgency=high + + * Final 2.2.1 release. + * According to report #131813, the python interpreter is much faster on some + architectures, when beeing linked statically with the python library (25%). + Gregor and me tested on i386, m68k and alpha, but we could not reproduce + such a speedup (generally between 5% and 10%). But we are linking the + python executable now statically ... + * Build info docs from the tex source, merge the python-doc-info + package into the python-doc package. + * Always build the dl module. Failure in case of + sizeof(int)!=sizeof(long)!=sizeof(void*) + is delayed until dl.open is called. Closes: #141681. + + -- Matthias Klose Thu, 11 Apr 2002 00:19:19 +0200 + +python2.2 (2.2.0.92-0) unstable; urgency=low + + * Package CVS sources, omit cvs-updates.dpatch (closes: #140977). + + -- Matthias Klose Wed, 3 Apr 2002 08:20:52 +0200 + +python2.2 (2.2-6) unstable; urgency=medium + + * Update to python-2.2.1 release candidate 2 (final release scheduled + for April 10). + * Enable dl module (closes: #138992). + * Build doc files with python binary from package (closes: #139657). + * Build _tkinter module with BLT and Tix support. + * python2.2-elisp: Conflict with python2-elisp (closes: #138970). + * string.split docs updated in python-2.2.1 (closes: #129272). + + -- Matthias Klose Mon, 1 Apr 2002 13:52:36 +0200 + +python2.2 (2.2-5) unstable; urgency=low + + * CVS updates of the release22-maint branch upto 20020310 (aproaching + the first 2.2.1 release candidate). + * Stolen from HEAD: check argument of locale.nl_langinfo (closes: #137371). + + -- Matthias Klose Fri, 15 Mar 2002 01:05:59 +0100 + +python2.2 (2.2-4) unstable; urgency=medium + + * Include test/{__init__.py,README,pystone.py} in package (closes: #129013). + * Fix python-elisp conflict (closes: #129046). + * Don't compress stylesheets (closes: #133179). + * CVS updates of the release22-maint branch upto 20020310. + + -- Matthias Klose Sun, 10 Mar 2002 23:32:28 +0100 + +python2.2 (2.2-3) unstable; urgency=medium + + * Updates from the CVS python22-maint branch up to 20020107. + webbrowser.py: properly escape url's. + * The Hurd does not have large file support: disabled. + + -- Matthias Klose Mon, 7 Jan 2002 21:55:57 +0100 + +python2.2 (2.2-2) unstable; urgency=medium + + * CVS updates of the release22-maint branch upto 20011229. Fixes: + - Include TCP_CORK flag in plat-linux2 headers (fixes: #84340). + - Update CDROM.py module (fixes: #125785). + * Add missing chunk of the GNU/Hurd patch (therefore urgency medium). + * Send anonymous password when using anonftp (closes: #126814). + + -- Matthias Klose Sat, 29 Dec 2001 20:18:26 +0100 + +python2.2 (2.2-1) unstable; urgency=low + + * New upstream version: 2.2. + * Bugs fixed upstream: + - Docs for os.kill reference the signal module for constants. + - Documentation strings in the tutorial end with a period (closes: #94770). + - Tk: grid_location method moved from Grid to Misc (closes: #98338). + - mhlib.SubMessage.getbodytext takes decode parameter (closes: #31876). + - Strings in modules are locale aware (closes: #51444). + - Printable 8-bit characters in strings are correctly printed + (closes: #64354). + - Dictionary can be updated with abstract mapping object (closes: #46566). + * Make site.py a config files. + + -- Matthias Klose Sat, 22 Dec 2001 00:51:46 +0100 + +python2.2 (2.1.99c1-1) unstable; urgency=low + + * New upstream version: 2.2c1 (release candidate). + * Do not provide python2.2-base anymore. + * Install correct README.Debian for python2.2 package. Include hint + where to find Makefile.pre.in. + * Suggest installation of python-ssl. + * Remove idle config files on purge. + * Remove empty /usr/lib/python2.2 directory on purge. + + -- Matthias Klose Sat, 15 Dec 2001 17:56:27 +0100 + +python2.2 (2.1.99beta2-1) unstable; urgency=high + + * debian/rules: Reflect removal of regrtest package (closes: #122278). + Resulted in build failures on all architectures. + * Build -doc package from source. + + -- Matthias Klose Sat, 8 Dec 2001 00:38:41 +0100 + +python2.2 (2.1.99beta2-0.1) unstable; urgency=low + + * Non maintainer upload. + * New upstream version (this is 2.2beta2). + * Do not build the python-regrtest package anymore; keep the test framework + components test/regrtest.py and test/test_support.py in the python + package (closes: #119408). + + -- Gregor Hoffleit Tue, 27 Nov 2001 09:53:26 +0100 + +python2.2 (2.1.99beta1-4) unstable; urgency=low + + * Configure with --with-fpectl (closes: #118125). + * setup.py: Remove broken check for _curses_panel module (#116081). + * idle: Move config-* files to /etc and mark as conffiles (#106390). + * Move idle packages to section `devel'. + + -- Matthias Klose Wed, 31 Oct 2001 10:56:45 +0100 + +python2.2 (2.1.99beta1-3) unstable; urgency=low + + * Fix shlibs file (was still referring to 2.1). Closes: #116810. + * README.Debian: point to draft of python-policy in the python package. + + -- Matthias Klose Wed, 31 Oct 2001 10:56:45 +0100 + +python2.2 (2.1.99beta1-2) unstable; urgency=medium + + * Fix shlibs file (was still referring to 2.1). Closes: #116810. + * Rename package python2.2-base to python2.2. + + -- Matthias Klose Wed, 24 Oct 2001 23:00:50 +0200 + +python2.2 (2.1.99beta1-1) unstable; urgency=low + + * New upstream version (beta). Call the package version 2.1.99beta1-1. + * New maintainer until the final 2.2 release. + * Updated the debian patches. + + -- Matthias Klose Sat, 20 Oct 2001 18:56:26 +0200 + +python2.1 (2.1.1-1.2) unstable; urgency=low + + * Really remove the python alternative. + + -- Matthias Klose Sat, 20 Oct 2001 15:16:56 +0200 + +python2.1 (2.1.1-1.1) unstable; urgency=low + + * README FOR PACKAGE MAINTAINERS: It is planned to remove the python2-XXX + packages from unstable and move on to python2.1. + If you repackage/adapt your modules for python2.1, don't build + python2-XXX and python2.1-XXX packages from the same source package, + so that the python2-XXX package can be removed without influencing the + python2.1-XXX package. + + See the debian-python mailing list at http://lists.debian.org/devel.html + for details and the current discussion and a draft for a debian-python + policy (August to October 2001). + + * Remove alternative for /usr/bin/python. The python-base package now + provides the default python version. + + * Regenerate control file to fix build dependencies (closes: #116190). + * Remove alternative for /usr/bin/{python,pydoc}. + * Provide a libpython2.1.so symlink in /usr/lib/python2.1/config, + so that the shared library is found when -L/usr/lib/python2.1/config + is specified. + * Conflict with old package versions, where /usr/bin/python is a real + program (closes: #115943). + * python2.1-elisp conflicts with python-elisp (closes: #115895). + * We now have 2.1 (closes: #96851, #107849, #110243). + + -- Matthias Klose Fri, 19 Oct 2001 17:34:41 +0200 + +python2.1 (2.1.1-1) unstable; urgency=low + + * Incorporated Matthias' modifications. + + -- Gregor Hoffleit Thu, 11 Oct 2001 00:16:42 +0200 + +python2.1 (2.1.1-0.2) unstable; urgency=low + + * New upstream 2.1.1. + * GPL compatible licence (fixes #84080, #102949, #110643). + * Fixed upstream (closes: #99692, #111340). + * Build in separate build directory. + * Split Debian patches into debian/patches directory. + * Build dependencies: Add libgmp3-dev, libexpat1-dev, tighten + debhelper dependency. + * debian/rules: Updated a "bit". + * python-elisp: Remove custom dependency (closes: #87783), + fix emacs path (closes: #89712), remove emacs19 dependency (#82694). + * Mention distutils in python-dev package description (closes: #108170). + * Update README.Debian (closes: #85430). + * Run versioned python in postinsts (closes: #113349). + * debian/sample.{postinst,prerm}: Change to version independent scripts. + * Use '/usr/bin/env python2.1' as interpreter for all python scripts. + * Add libssl-dev to Build-Conflicts. + * python-elisp: Add support for emacs21 (closes: #98635). + * Do not compress .py files in doc directories. + * Don't link explicitely with libc. + + -- Matthias Klose Wed, 3 Oct 2001 09:53:08 +0200 + +python2.1 (2.1.1-0.1) unstable; urgency=low + + * New upstream version (CVS branch release21-maint, will become 2.1.1): + This CVS branch will be released as 2.1.1 under a GPL compatible + license. + + -- Gregor Hoffleit Wed, 27 Jun 2001 22:47:58 +0200 + +python2 (2.1-0.1) unstable; urgency=low + + * Fixed Makefile.pre.in. + * Fixed the postinst files in order to use 2.1 (instead of 2.0). + * Mention the immanent release of 2.0.1 and 2.1.1, with a GPL + compatible license. + + -- Gregor Hoffleit Sun, 17 Jun 2001 21:05:25 +0200 + +python2 (2.1-0) unstable; urgency=low + + * New upstream version. + * Experimental packages. + + -- Gregor Hoffleit Thu, 10 May 2001 00:20:04 +0200 + +python2 (2.0-7) unstable; urgency=low + + * Rebuilt with recent tcl8.3-dev/tk8.3-dev in order to fix a + dependency problem with python2-tk (closes: #87793, #92962). + * Change postinst to create and update /usr/local/lib/python2.0 and + site-python with permissions and owner as mandated by policy: + 2775 and root:staff (closes: #89047). + * Fix to compileall.py: A superfluous argument made compileall without + options fail (cf. #92990 for python). + * Move the distutils module into python2-dev. It needs Makefile.pre.in + in order to work (closes: #89900). + * Remove build-dependency on libgdbm2-dev (which isn't built anyway). + * Add a build-dependency on libdb2-dev (cf. #90220 for python). + + -- Gregor Hoffleit Sat, 14 Apr 2001 21:07:51 +0200 + +python2 (2.0-6) unstable; urgency=low + + * Remove python-zlib package; merge it into python-base. + * Mark that README.python2 is not yet updated. + + -- Gregor Hoffleit Wed, 21 Feb 2001 12:34:18 +0100 + +python2 (2.0-5) unstable; urgency=low + + * Recompile with tcl/tk8.3 (closes: #82088). + * Modifications to README.why-python2 (closes: #82116). + * Add menu hint to idle2 menu entry. + * idle2 is renamed idle-python2 and now build correctly (closes: #82218). + * Add build-dependency on autoconf (closes: #85339). + * Build bsddbmodule as shared module (Modules/Setup.config.in), + and link libpython2.so with -lm in Makefile (closes: #86027). + * various cleanups in debian/rules, e.g. removing dh_suidregister. + * Make pdb available as /usr/bin/pdb-python2 in python2-dev + (cf. #79870 in python-base). + * Remove libgmp3 from build-dependencies, since we currently can't + build the mpzmodule for Python2 due to license problems. + + -- Gregor Hoffleit Sun, 18 Feb 2001 00:12:17 +0100 + +python2 (2.0-4) unstable; urgency=low + + * control: make python2-elisp conflict with python-elisp (it doesn't + make sense to have both of them installed, does it ?) + * include build-depend on libxmltok1-dev. + * again, build with tcl/tk8.0. + + -- Gregor Hoffleit Wed, 10 Jan 2001 23:37:01 +0100 + +python2 (2.0-3) unstable; urgency=low + + * Modules/Setup.in: Added a missing \ that made _tkinter be built + incorrectly. + * rules: on the fly, change all '#!' python scripts to use python2. + + -- Gregor Hoffleit Wed, 13 Dec 2000 20:07:24 +0100 + +python2 (2.0-2) unstable; urgency=low + + * Aaargh. Remove conflicts/provides/replaces on python-base to make + parallel installation of python-base and python2-base possible. + * Install examples into /usr/share/doc/python2 (not python) and fix + symlink to python2.0 (thanks to Rick Younie for + pointing out this). + * Rename man page to python2.1. + + -- Gregor Hoffleit Wed, 13 Dec 2000 09:31:05 +0100 + +python2 (2.0-1) unstable; urgency=low + + * New upstream version. Initial release for python2. + + -- Gregor Hoffleit Mon, 11 Dec 2000 22:39:46 +0100 --- python2.7-2.7.5.orig/debian/argparse.egg-info +++ python2.7-2.7.5/debian/argparse.egg-info @@ -0,0 +1,8 @@ +Metadata-Version: 1.0 +Name: argparse +Version: 1.2.1 +Summary: Python command-line parsing library +Author: Steven Bethard +Author-email: steven.bethard@gmail.com +License: Python Software Foundation License +Platform: any --- python2.7-2.7.5.orig/debian/source.lintian-overrides.in +++ python2.7-2.7.5/debian/source.lintian-overrides.in @@ -0,0 +1,11 @@ +# this is conditional in the rules file +@PVER@ source: debhelper-script-needs-versioned-build-depends dh_icons (>= 5.0.51~) + +# generated during the build +@PVER@ source: quilt-build-dep-but-no-series-file + +# doesn't support any newer versions +@PVER@ source: build-depends-on-versioned-berkeley-db + +# using the system libffi +@PVER@ source: outdated-autotools-helper-file --- python2.7-2.7.5.orig/debian/PVER-dbg.postinst.in +++ python2.7-2.7.5/debian/PVER-dbg.postinst.in @@ -0,0 +1,19 @@ +#! /bin/sh + +set -e + +if [ "$1" = configure ]; then + files=$(dpkg -L lib@PVER@-dbg | sed -n '/^\/usr\/lib\/@PVER@\/.*\.py$/p') + if [ -n "$files" ]; then + @PVER@ -E -S /usr/lib/@PVER@/py_compile.py $files + if grep -sq '^byte-compile[^#]*optimize' /etc/python/debian_config; then + @PVER@ -E -S -O /usr/lib/@PVER@/py_compile.py $files + fi + else + echo >&2 "@PVER@-dbg: can't get files for byte-compilation" + fi +fi + +#DEBHELPER# + +exit 0 --- python2.7-2.7.5.orig/debian/README.python +++ python2.7-2.7.5/debian/README.python @@ -0,0 +1,153 @@ + + Python 2.x for Debian + --------------------- + +This is Python 2.x packaged for Debian. + +This document contains information specific to the Debian packages of +Python 2.x. + + + + [TODO: This document is not yet up-to-date with the packages.] + + + + + + +Currently, it features those two main topics: + + 1. Release notes for the Debian packages: + 2. Notes for developers using the Debian Python packages: + +Release notes and documentation from the upstream package are installed +in /usr/share/doc/python/. + +Up-to-date information regarding Python on Debian systems is also +available as http://www.debian.org/~flight/python/. + +There's a mailing list for discussion of issues related to Python on Debian +systems: debian-python@lists.debian.org. The list is not intended for +general Python problems, but as a forum for maintainers of Python-related +packages and interested third parties. + + + +1. Release notes for the Debian packages: + + +Results of the regression test: +------------------------------ + +The package does successfully run the regression tests for all included +modules. Seven packages are skipped since they are platform-dependent and +can't be used with Linux. + + +Noteworthy changes since the 1.4 packages: +----------------------------------------- + +- Threading support enabled. +- Tkinter for Tcl/Tk 8.x. +- New package python-zlib. +- The dbmmodule was dropped. Use bsddb instead. gdbmmodule is provided + for compatibility's sake. +- python-elisp adheres to the new emacs add-on policy; it now depends + on emacsen. python-elisp probably won't work correctly with emacs19. + Refer to /usr/doc/python-elisp/ for more information. +- Remember that 1.5 has dropped the `ni' interface in favor of a generic + `packages' concept. +- Python 1.5 regression test as additional package python-regrtest. You + don't need to install this package unless you don't trust the + maintainer ;-). +- once again, modified upstream's compileall.py and py_compile.py. + Now they support compilation of optimized byte-code (.pyo) for use + with "python -O", removal of .pyc and .pyo files where the .py source + files are missing (-d) and finally the fake of a installation directory + when .py files have to be compiled out of place for later installation + in a different directory (-i destdir, used in ./debian/rules). +- The Debian packages for python 1.4 do call + /usr/lib/python1.4/compileall.py in their postrm script. Therefore + I had to provide a link from /usr/lib/python1.5/compileall.py, otherwise + the old packages won't be removed completely. THIS IS A SILLY HACK! + + + +2. Notes for developers using the Debian python packages: + + +Embedding python: +---------------- + +The files for embedding python resp. extending the python interpreter +are included in the python-dev package. With the configuration in the +Debian GNU/Linux packages of python 1.5, you will want to use something +like + + -I/usr/include/python1.5 (e.g. for config.h) + -L/usr/lib/python1.5/config -lpython1.5 (... -lpthread) + (also for Makefile.pre.in, Setup etc.) + +Makefile.pre.in automatically gets that right. Note that unlike 1.4, +python 1.5 has only one library, libpython1.5.a. + +Currently, there's no shared version of libpython. Future version of +the Debian python packages will support this. + + +Python extension packages: +------------------------- + +According to www.python.org/doc/essays/packages.html, extension packages +should only install into /usr/lib/python1.5/site-packages/ (resp. +/usr/lib/site-python/ for packages that are definitely version independent). +No extension package should install files directly into /usr/lib/python1.5/. + +But according to the FSSTND, only Debian packages are allowed to use +/usr/lib/python1.5/. Therefore Debian Python additionally by default +searches a second hierarchy in /usr/local/lib/. These directories take +precedence over their equivalents in /usr/lib/. + +a) Locally installed Python add-ons + + /usr/local/lib/python1.5/site-packages/ + /usr/local/lib/site-python/ (version-independent modules) + +b) Python add-ons packaged for Debian + + /usr/lib/python1.5/site-packages/ + /usr/lib/site-python/ (version-independent modules) + +Note that no package must install files directly into /usr/lib/python1.5/ +or /usr/local/lib/python1.5/. Only the site-packages directory is allowed +for third-party extensions. + +Use of the new `package' scheme is strongly encouraged. The `ni' interface +is obsolete in python 1.5. + +Header files for extensions go into /usr/include/python1.5/. + + +Installing extensions for local use only: +---------------------------------------- + +Most extensions use Python's Makefile.pre.in. Note that Makefile.pre.in +by default will install files into /usr/lib/, not into /usr/local/lib/, +which is not allowed for local extensions. You'll have to change the +Makefile accordingly. Most times, "make prefix=/usr/local install" will +work. + + +Packaging python extensions for Debian: +-------------------------------------- + +Maintainers of Python extension packages should read README.maintainers. + + + + + 03/09/98 + Gregor Hoffleit + +Last change: 07/16/1999 --- python2.7-2.7.5.orig/debian/libPVER.overrides.in +++ python2.7-2.7.5/debian/libPVER.overrides.in @@ -0,0 +1 @@ +lib@PVER@ binary: package-name-doesnt-match-sonames --- python2.7-2.7.5.orig/debian/libPVER-minimal.postrm.in +++ python2.7-2.7.5/debian/libPVER-minimal.postrm.in @@ -0,0 +1,26 @@ +#! /bin/sh + +set -e + +if [ "$1" = "remove" ]; then + pc=$(dpkg-query -f '${db:Status-Abbrev} ${binary:Package}\n' -W pkgname \ + | grep -v '^.n' | wc -l) + if [ "$pc" -le 1 ]; then + find /usr/lib/@PVER@ -name '*.py[co]' -print0 | xargs -r0 rm -f + fi +fi + +if [ "$1" = "purge" ]; then + pc=$(dpkg-query -f '${db:Status-Abbrev} ${binary:Package}\n' -W pkgname \ + | grep -v '^.n' | wc -l) + if [ "$pc" -le 1 ]; then + rm -f /etc/@PVER@/site.py /etc/@PVER@/sitecustomize.py + if [ -d /etc/@PVER@ ]; then + rmdir --ignore-fail-on-non-empty /etc/@PVER@ 2>/dev/null + fi + fi +fi + +#DEBHELPER# + +exit 0 --- python2.7-2.7.5.orig/debian/2to3-2.7.1 +++ python2.7-2.7.5/debian/2to3-2.7.1 @@ -0,0 +1,41 @@ +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.40.4. +.TH 2TO3-2.7 "1" "January 2012" "2to3-2.7 2.7" "User Commands" +.SH NAME +2to3-2.7 \- Python2 to Python3 converter +.SH SYNOPSIS +.B 2to3 +[\fIoptions\fR] \fIfile|dir \fR... +.SH OPTIONS +.TP +\fB\-h\fR, \fB\-\-help\fR +show this help message and exit +.TP +\fB\-d\fR, \fB\-\-doctests_only\fR +Fix up doctests only +.TP +\fB\-f\fR FIX, \fB\-\-fix\fR=\fIFIX\fR +Each FIX specifies a transformation; default: all +.TP +\fB\-j\fR PROCESSES, \fB\-\-processes\fR=\fIPROCESSES\fR +Run 2to3 concurrently +.TP +\fB\-x\fR NOFIX, \fB\-\-nofix\fR=\fINOFIX\fR +Prevent a transformation from being run +.TP +\fB\-l\fR, \fB\-\-list\-fixes\fR +List available transformations +.TP +\fB\-p\fR, \fB\-\-print\-function\fR +Modify the grammar so that print() is a function +.TP +\fB\-v\fR, \fB\-\-verbose\fR +More verbose logging +.TP +\fB\-\-no\-diffs\fR +Don't show diffs of the refactoring +.TP +\fB\-w\fR, \fB\-\-write\fR +Write back modified files +.TP +\fB\-n\fR, \fB\-\-nobackups\fR +Don't write backups for modified files --- python2.7-2.7.5.orig/debian/PVER-dbg.prerm.in +++ python2.7-2.7.5/debian/PVER-dbg.prerm.in @@ -0,0 +1,28 @@ +#! /bin/sh + +set -e + +case "$1" in + remove) + rm -f /usr/lib/debug/usr/bin/@PVER@-gdb.py[co] + rm -f /usr/lib/debug/usr/lib/lib@PVER@.so.1.0-gdb.py[co] + dpkg -L lib@PVER@-dbg \ + | awk '/\.py$/ {print $0"c\n" $0"o"}' \ + | xargs -r rm -f >&2 + ;; + upgrade) + dpkg -L lib@PVER@-dbg \ + | awk '/\.py$/ {print $0"c\n" $0"o"}' \ + | xargs -r rm -f >&2 + ;; + deconfigure) + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# --- python2.7-2.7.5.orig/debian/source.lintian-overrides +++ python2.7-2.7.5/debian/source.lintian-overrides @@ -0,0 +1,11 @@ +# this is conditional in the rules file +python2.7 source: debhelper-script-needs-versioned-build-depends dh_icons (>= 5.0.51~) + +# generated during the build +python2.7 source: quilt-build-dep-but-no-series-file + +# doesn't support any newer versions +python2.7 source: build-depends-on-versioned-berkeley-db + +# using the system libffi +python2.7 source: outdated-autotools-helper-file --- python2.7-2.7.5.orig/debian/PVER-doc.doc-base.PVER-inst.in +++ python2.7-2.7.5/debian/PVER-doc.doc-base.PVER-inst.in @@ -0,0 +1,12 @@ +Document: @PVER@-inst +Title: Installing Python Modules (v@VER@) +Author: Greg Ward +Abstract: This document describes the Python Distribution Utilities + (``Distutils'') from the end-user's point-of-view, describing how to + extend the capabilities of a standard Python installation by building + and installing third-party Python modules and extensions. +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/@PVER@/html/install/index.html +Files: /usr/share/doc/@PVER@/html/install/*.html --- python2.7-2.7.5.orig/debian/libPVER-minimal.postinst.in +++ python2.7-2.7.5/debian/libPVER-minimal.postinst.in @@ -0,0 +1,13 @@ +#! /bin/sh + +set -e + +if [ ! -f /etc/@PVER@/sitecustomize.py ]; then + cat <<-EOF + # Empty sitecustomize.py to avoid a dangling symlink +EOF +fi + +#DEBHELPER# + +exit 0 --- python2.7-2.7.5.orig/debian/multiarch.h.in +++ python2.7-2.7.5/debian/multiarch.h.in @@ -0,0 +1,73 @@ +#if defined(__linux__) +# if defined(__x86_64__) && defined(__LP64__) +# include +# elif defined(__x86_64__) && defined(__ILP32__) +# include +# elif defined(__i386__) +# include +# elif defined(__aarch64__) && defined(__AARCH64EL__) +# include +# elif defined(__alpha__) +# include +# elif defined(__ARM_EABI__) && defined(__ARM_PCS_VFP) +# include +# elif defined(__ARM_EABI__) && !defined(__ARM_PCS_VFP) +# include +# elif defined(__hppa__) +# include +# elif defined(__ia64__) +# include +# elif defined(__m68k__) && !defined(__mcoldfire__) +# include +# elif defined(__mips_hard_float) && defined(_MIPSEL) +# if _MIPS_SIM == _ABIO32 +# include +# elif _MIPS_SIM == _ABIN32 +# include +# elif _MIPS_SIM == _ABI64 +# include +# else +# error unknown multiarch location for @header@ +# endif +# elif defined(__mips_hard_float) +# if _MIPS_SIM == _ABIO32 +# include +# elif _MIPS_SIM == _ABIN32 +# include +# elif _MIPS_SIM == _ABI64 +# include +# else +# error unknown multiarch location for @header@ +# endif +# elif defined(__powerpc__) && defined(__SPE__) +# include +# elif defined(__powerpc64__) +# include +# elif defined(__powerpc__) +# include +# elif defined(__s390x__) +# include +# elif defined(__s390__) +# include +# elif defined(__sh__) && defined(__LITTLE_ENDIAN__) +# include +# elif defined(__sparc__) && defined(__arch64__) +# include +# elif defined(__sparc__) +# include +# else +# error unknown multiarch location for @header@ +# endif +#elif defined(__FreeBSD_kernel__) +# if defined(__LP64__) +# include +# elif defined(__i386__) +# include +# else +# error unknown multiarch location for @header@ +# endif +#elif defined(__gnu_hurd__) +# include +#else +# error unknown multiarch location for @header@ +#endif --- python2.7-2.7.5.orig/debian/compat +++ python2.7-2.7.5/debian/compat @@ -0,0 +1 @@ +5 --- python2.7-2.7.5.orig/debian/idle-PVER.prerm.in +++ python2.7-2.7.5/debian/idle-PVER.prerm.in @@ -0,0 +1,17 @@ +#! /bin/sh +# +# sample prerm script for the Debian idle-@PVER@ package. +# Written 1998 by Gregor Hoffleit . +# + +set -e + +PACKAGE=`basename $0 .prerm` + +dpkg --listfiles $PACKAGE | + awk '$0~/\.py$/ {print $0"c\n" $0"o"}' | + xargs rm -f >&2 + +#DEBHELPER# + +exit 0 --- python2.7-2.7.5.orig/debian/idle-PVER.menu.in +++ python2.7-2.7.5/debian/idle-PVER.menu.in @@ -0,0 +1,5 @@ +?package(idle-@PVER@):needs="X11" section="Applications/Programming"\ + title="IDLE (Python v@VER@)"\ + icon="/usr/share/pixmaps/@PVER@.xpm"\ + command="/usr/bin/idle-@PVER@" \ + hints="Environments" --- python2.7-2.7.5.orig/debian/PVER.pycentral.in +++ python2.7-2.7.5/debian/PVER.pycentral.in @@ -0,0 +1,4 @@ +[@PVER@] +runtime: @PVER@ +interpreter: /usr/bin/@PVER@ +prefix: /usr/lib/@PVER@ --- python2.7-2.7.5.orig/debian/libPVER-stdlib.prerm.in +++ python2.7-2.7.5/debian/libPVER-stdlib.prerm.in @@ -0,0 +1,35 @@ +#! /bin/sh + +set -e + +remove_bytecode() +{ + pkg=$1 + dpkg -L $1 \ + | awk '/\.py$/ {print $0"c\n" $0"o"}' \ + | xargs -r rm -f >&2 +} + +case "$1" in + remove) + pc=$(dpkg-query -f '${db:Status-Abbrev} ${binary:Package}\n' -W pkgname \ + | grep -v '^.n' | wc -l) + if [ "$pc" -le 1 ]; then + remove_bytecode lib@PVER@-stdlib + fi + ;; + upgrade) + remove_bytecode lib@PVER@-stdlib + # byte compilation in @PVER@ postinst, strict dependency + ;; + deconfigure) + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# --- python2.7-2.7.5.orig/debian/libPVER-minimal.prerm.in +++ python2.7-2.7.5/debian/libPVER-minimal.prerm.in @@ -0,0 +1,35 @@ +#! /bin/sh + +set -e + +remove_bytecode() +{ + pkg=$1 + dpkg -L $1 \ + | awk '/\.py$/ {print $0"c\n" $0"o"}' \ + | xargs -r rm -f >&2 +} + +case "$1" in + remove) + pc=$(dpkg-query -f '${db:Status-Abbrev} ${binary:Package}\n' -W pkgname \ + | grep -v '^.n' | wc -l) + if [ "$pc" -le 1 ]; then + remove_bytecode lib@PVER@-minimal + fi + ;; + upgrade) + remove_bytecode lib@PVER@-minimal + # byte compilation in @PVER@-minimal postinst, strict dependency + ;; + deconfigure) + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# --- python2.7-2.7.5.orig/debian/depgraph.py +++ python2.7-2.7.5/debian/depgraph.py @@ -0,0 +1,199 @@ +#! /usr/bin/python + +# Copyright 2004 Toby Dickenson +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject +# to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +import sys, getopt, colorsys, imp, md5 + +class pydepgraphdot: + + def main(self,argv): + opts,args = getopt.getopt(argv,'',['mono']) + self.colored = 1 + for o,v in opts: + if o=='--mono': + self.colored = 0 + self.render() + + def fix(self,s): + # Convert a module name to a syntactically correct node name + return s.replace('.','_') + + def render(self): + p,t = self.get_data() + + # normalise our input data + for k,d in p.items(): + for v in d.keys(): + if not p.has_key(v): + p[v] = {} + + f = self.get_output_file() + + f.write('digraph G {\n') + #f.write('concentrate = true;\n') + #f.write('ordering = out;\n') + f.write('ranksep=1.0;\n') + f.write('node [style=filled,fontname=Helvetica,fontsize=10];\n') + allkd = p.items() + allkd.sort() + for k,d in allkd: + tk = t.get(k) + if self.use(k,tk): + allv = d.keys() + allv.sort() + for v in allv: + tv = t.get(v) + if self.use(v,tv) and not self.toocommon(v,tv): + f.write('%s -> %s' % ( self.fix(k),self.fix(v) ) ) + self.write_attributes(f,self.edge_attributes(k,v)) + f.write(';\n') + f.write(self.fix(k)) + self.write_attributes(f,self.node_attributes(k,tk)) + f.write(';\n') + f.write('}\n') + + def write_attributes(self,f,a): + if a: + f.write(' [') + f.write(','.join(a)) + f.write(']') + + def node_attributes(self,k,type): + a = [] + a.append('label="%s"' % self.label(k)) + if self.colored: + a.append('fillcolor="%s"' % self.color(k,type)) + else: + a.append('fillcolor=white') + if self.toocommon(k,type): + a.append('peripheries=2') + return a + + def edge_attributes(self,k,v): + a = [] + weight = self.weight(k,v) + if weight!=1: + a.append('weight=%d' % weight) + length = self.alien(k,v) + if length: + a.append('minlen=%d' % length) + return a + + def get_data(self): + t = eval(sys.stdin.read()) + return t['depgraph'],t['types'] + + def get_output_file(self): + return sys.stdout + + def use(self,s,type): + # Return true if this module is interesting and should be drawn. Return false + # if it should be completely omitted. This is a default policy - please override. + if s=='__main__': + return 0 + #if s in ('os','sys','time','__future__','types','re','string'): + if s in ('sys'): + # nearly all modules use all of these... more or less. They add nothing to + # our diagram. + return 0 + if s.startswith('encodings.'): + return 0 + if self.toocommon(s,type): + # A module where we dont want to draw references _to_. Dot doesnt handle these + # well, so it is probably best to not draw them at all. + return 0 + return 1 + + def toocommon(self,s,type): + # Return true if references to this module are uninteresting. Such references + # do not get drawn. This is a default policy - please override. + # + if s=='__main__': + # references *to* __main__ are never interesting. omitting them means + # that main floats to the top of the page + return 1 + #if type==imp.PKG_DIRECTORY: + # # dont draw references to packages. + # return 1 + return 0 + + def weight(self,a,b): + # Return the weight of the dependency from a to b. Higher weights + # usually have shorter straighter edges. Return 1 if it has normal weight. + # A value of 4 is usually good for ensuring that a related pair of modules + # are drawn next to each other. This is a default policy - please override. + # + if b.split('.')[-1].startswith('_'): + # A module that starts with an underscore. You need a special reason to + # import these (for example random imports _random), so draw them close + # together + return 4 + return 1 + + def alien(self,a,b): + # Return non-zero if references to this module are strange, and should be drawn + # extra-long. the value defines the length, in rank. This is also good for putting some + # vertical space between seperate subsystems. This is a default policy - please override. + # + return 0 + + def label(self,s): + # Convert a module name to a formatted node label. This is a default policy - please override. + # + return '\\.\\n'.join(s.split('.')) + + def color(self,s,type): + # Return the node color for this module name. This is a default policy - please override. + # + # Calculate a color systematically based on the hash of the module name. Modules in the + # same package have the same color. Unpackaged modules are grey + t = self.normalise_module_name_for_hash_coloring(s,type) + return self.color_from_name(t) + + def normalise_module_name_for_hash_coloring(self,s,type): + if type==imp.PKG_DIRECTORY: + return s + else: + i = s.rfind('.') + if i<0: + return '' + else: + return s[:i] + + def color_from_name(self,name): + n = md5.md5(name).digest() + hf = float(ord(n[0])+ord(n[1])*0xff)/0xffff + sf = float(ord(n[2]))/0xff + vf = float(ord(n[3]))/0xff + r,g,b = colorsys.hsv_to_rgb(hf, 0.3+0.6*sf, 0.8+0.2*vf) + return '#%02x%02x%02x' % (r*256,g*256,b*256) + + +def main(): + pydepgraphdot().main(sys.argv[1:]) + +if __name__=='__main__': + main() + + + --- python2.7-2.7.5.orig/debian/libPVER-testsuite.prerm.in +++ python2.7-2.7.5/debian/libPVER-testsuite.prerm.in @@ -0,0 +1,29 @@ +#! /bin/sh + +set -e + +remove_bytecode() +{ + pkg=$1 + dpkg -L $1 \ + | awk '/\.py$/ {print $0"c\n" $0"o"}' \ + | xargs -r rm -f >&2 +} + +case "$1" in + remove) + remove_bytecode lib@PVER@-testsuite + ;; + upgrade) + ;; + deconfigure) + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# --- python2.7-2.7.5.orig/debian/PVER-examples.overrides.in +++ python2.7-2.7.5/debian/PVER-examples.overrides.in @@ -0,0 +1,2 @@ +# don't care about permissions of the example files +@PVER@-examples binary: executable-not-elf-or-script --- python2.7-2.7.5.orig/debian/sitecustomize.py.in +++ python2.7-2.7.5/debian/sitecustomize.py.in @@ -0,0 +1,7 @@ +# install the apport exception handler if available +try: + import apport_python_hook +except ImportError: + pass +else: + apport_python_hook.install() --- python2.7-2.7.5.orig/debian/pymindeps.py +++ python2.7-2.7.5/debian/pymindeps.py @@ -0,0 +1,175 @@ +#! /usr/bin/python + +# Matthias Klose +# Modified to only exclude module imports from a given module. + +# Copyright 2004 Toby Dickenson +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject +# to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +import os, sys, pprint +import modulefinder +import imp + +class mymf(modulefinder.ModuleFinder): + def __init__(self,*args,**kwargs): + self._depgraph = {} + self._types = {} + self._last_caller = None + modulefinder.ModuleFinder.__init__(self, *args, **kwargs) + + def import_hook(self, name, caller=None, fromlist=None, level=-1): + old_last_caller = self._last_caller + try: + self._last_caller = caller + return modulefinder.ModuleFinder.import_hook(self, name, caller, + fromlist, level) + finally: + self._last_caller = old_last_caller + + def import_module(self, partnam, fqname, parent): + m = modulefinder.ModuleFinder.import_module(self, + partnam, fqname, parent) + if m is not None and self._last_caller: + caller = self._last_caller.__name__ + if '.' in caller: + caller = caller[:caller.index('.')] + callee = m.__name__ + if '.' in callee: + callee = callee[:callee.index('.')] + #print "XXX last_caller", caller, "MOD", callee + #self._depgraph.setdefault(self._last_caller.__name__,{})[r.__name__] = 1 + #if caller in ('pdb', 'doctest') or callee in ('pdb', 'doctest'): + # print caller, "-->", callee + if caller != callee: + self._depgraph.setdefault(caller,{})[callee] = 1 + return m + + def find_module(self, name, path, parent=None): + if parent is not None: + # assert path is not None + fullname = parent.__name__+'.'+name + elif name == "__init__": + fullname = os.path.basename(path[0]) + else: + fullname = name + if self._last_caller: + caller = self._last_caller.__name__ + if fullname in excluded_imports.get(caller, []): + #self.msgout(3, "find_module -> Excluded", fullname) + raise ImportError, name + + if fullname in self.excludes: + #self.msgout(3, "find_module -> Excluded", fullname) + raise ImportError, name + + if path is None: + if name in sys.builtin_module_names: + return (None, None, ("", "", imp.C_BUILTIN)) + + path = self.path + return imp.find_module(name, path) + + def load_module(self, fqname, fp, pathname, file_info): + suffix, mode, type = file_info + m = modulefinder.ModuleFinder.load_module(self, fqname, + fp, pathname, file_info) + if m is not None: + self._types[m.__name__] = type + return m + + def load_package(self, fqname, pathname): + m = modulefinder.ModuleFinder.load_package(self, fqname,pathname) + if m is not None: + self._types[m.__name__] = imp.PKG_DIRECTORY + return m + +def reduce_depgraph(dg): + pass + +# guarded imports, which don't need to be included in python-minimal +excluded_imports = { + 'codecs': set(('encodings',)), + 'collections': set(('doctest', 'dummy_thread', 'cPickle')), + 'copy': set(('reprlib',)), + 'difflib': set(('doctest',)), + 'hashlib': set(('logging',)), + 'hashlib': set(('_hashlib', '_md5', '_sha', '_sha256','_sha512',)), + 'heapq': set(('doctest',)), + 'inspect': set(('compiler',)), + 'os': set(('nt', 'ntpath', 'os2', 'os2emxpath', 'mac', 'macpath', + 'riscos', 'riscospath', 'riscosenviron')), + 'optparse': set(('gettext',)), + 'pickle': set(('doctest',)), + 'platform': set(('plistlib', 'tempfile')), + #'socket': set(('_ssl', 'ssl')), + 'tempfile': set(('dummy_thread',)), + 'subprocess': set(('threading',)), + 'shutil': set(('distutils', 'tarfile', 'zipfile')), + 'sysconfig': set(('pprint', '_osx_support')), + } + +def main(argv): + # Parse command line + import getopt + try: + opts, args = getopt.getopt(sys.argv[1:], "dmp:qx:") + except getopt.error as msg: + print(msg) + return + + # Process options + debug = 1 + domods = 0 + addpath = [] + exclude = [] + for o, a in opts: + if o == '-d': + debug = debug + 1 + if o == '-m': + domods = 1 + if o == '-p': + addpath = addpath + a.split(os.pathsep) + if o == '-q': + debug = 0 + if o == '-x': + exclude.append(a) + + path = sys.path[:] + path = addpath + path + + if debug > 1: + print("version:", sys.version) + print("path:") + for item in path: + print(" ", repr(item)) + + #exclude = ['__builtin__', 'sys', 'os'] + exclude = [] + mf = mymf(path, debug, exclude) + for arg in args: + mf.run_script(arg) + + depgraph = reduce_depgraph(mf._depgraph) + + pprint.pprint({'depgraph':mf._depgraph, 'types':mf._types}) + +if __name__=='__main__': + main(sys.argv[1:]) --- python2.7-2.7.5.orig/debian/PVER-doc.doc-base.PVER-dist.in +++ python2.7-2.7.5/debian/PVER-doc.doc-base.PVER-dist.in @@ -0,0 +1,13 @@ +Document: @PVER@-dist +Title: Distributing Python Modules (v@VER@) +Author: Greg Ward +Abstract: This document describes the Python Distribution Utilities + (``Distutils'') from the module developer's point-of-view, describing + how to use the Distutils to make Python modules and extensions easily + available to a wider audience with very little overhead for + build/release/install mechanics. +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/@PVER@/html/distutils/index.html +Files: /usr/share/doc/@PVER@/html/distutils/*.html --- python2.7-2.7.5.orig/debian/PVER-dbg.overrides.in +++ python2.7-2.7.5/debian/PVER-dbg.overrides.in @@ -0,0 +1,11 @@ +@PVER@-dbg binary: package-name-doesnt-match-sonames +@PVER@-dbg binary: non-dev-pkg-with-shlib-symlink + +# no, it's not unusual +@PVER@-dbg binary: unusual-interpreter + +# just the gdb debug file +@PVER@-dbg binary: python-script-but-no-python-dep + +# pointless lintian ... +@PVER@-dbg binary: hardening-no-fortify-functions --- python2.7-2.7.5.orig/debian/README.PVER.in +++ python2.7-2.7.5/debian/README.PVER.in @@ -0,0 +1,95 @@ + + Python @VER@ for Debian + --------------------- + +This is Python @VER@ packaged for Debian. + +This document contains information specific to the Debian packages of +Python @VER@. + + + + [TODO: This document is not yet up-to-date with the packages.] + +Currently, it features those two main topics: + + 1. Release notes for the Debian packages: + 2. Notes for developers using the Debian Python packages: + +Release notes and documentation from the upstream package are installed +in /usr/share/doc/@PVER@/. + +There's a mailing list for discussion of issues related to Python on Debian +systems: debian-python@lists.debian.org. The list is not intended for +general Python problems, but as a forum for maintainers of Python-related +packages and interested third parties. + + + +1. Release notes for the Debian packages: + + +Results of the regression test: +------------------------------ + +The package does successfully run the regression tests for all included +modules. Seven packages are skipped since they are platform-dependent and +can't be used with Linux. + + +2. Notes for developers using the Debian python packages: + +See the draft of the Debian Python policy in /usr/share/doc/python. + +distutils can be found in the @PVER@-dev package. Development files +like the python library or Makefiles can be found in the @PVER@-dev +package in /usr/lib/@PVER@/config. Therefore, if you need to install +a pure python extension, you only need @PVER@. On the other hand, to +install a C extension, you need @PVER@-dev. + +a) Locally installed Python add-ons + + /usr/local/lib/@PVER@/site-packages/ + /usr/local/lib/site-python/ (version-independent modules) + +b) Python add-ons packaged for Debian + + /usr/lib/@PVER@/site-packages/ + /usr/lib/site-python/ (version-independent modules) + +Note that no package must install files directly into /usr/lib/@PVER@/ +or /usr/local/lib/@PVER@/. Only the site-packages directory is allowed +for third-party extensions. + +Use of the new `package' scheme is strongly encouraged. The `ni' interface +is obsolete in python 1.5. + +Header files for extensions go into /usr/include/@PVER@/. + + +Installing extensions for local use only: +---------------------------------------- + +Consider using distutils ... + +Most extensions use Python's Makefile.pre.in. Note that Makefile.pre.in +by default will install files into /usr/lib/, not into /usr/local/lib/, +which is not allowed for local extensions. You'll have to change the +Makefile accordingly. Most times, "make prefix=/usr/local install" will +work. + + +Packaging python extensions for Debian: +-------------------------------------- + +Maintainers of Python extension packages should read + + /usr/share/doc/python/python-policy.txt.gz + + + + + 03/09/98 + Gregor Hoffleit + +Last change: 2001-12-14 --- python2.7-2.7.5.orig/debian/PVER-minimal.prerm.in +++ python2.7-2.7.5/debian/PVER-minimal.prerm.in @@ -0,0 +1,36 @@ +#! /bin/sh + +set -e + +case "$1" in + remove) + if [ "$DEBIAN_FRONTEND" != noninteractive ]; then + echo "Unlinking and removing bytecode for runtime @PVER@" + fi + for hook in /usr/share/python/runtime.d/*.rtremove; do + [ -x $hook ] || continue + $hook rtremove @PVER@ || continue + done + + if which update-binfmts >/dev/null; then + update-binfmts --package @PVER@ --remove @PVER@ /usr/bin/@PVER@ + fi + + localsite=/usr/local/lib/@PVER@/dist-packages + [ -d $localsite ] && rmdir $localsite 2>/dev/null || true + [ -d $(dirname $localsite) ] \ + && rmdir $(dirname $localsite) 2>/dev/null || true + ;; + upgrade) + ;; + deconfigure) + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# --- python2.7-2.7.5.orig/debian/PVER-minimal.postinst.in +++ python2.7-2.7.5/debian/PVER-minimal.postinst.in @@ -0,0 +1,78 @@ +#! /bin/sh + +set -e + +if [ ! -f /etc/@PVER@/sitecustomize.py ]; then + cat <<-EOF + # Empty sitecustomize.py to avoid a dangling symlink +EOF +fi + +case "$1" in + configure) + # Create empty directories in /usr/local + if [ ! -e /usr/local/lib/@PVER@ ]; then + mkdir -p /usr/local/lib/@PVER@ 2> /dev/null || true + chmod 2775 /usr/local/lib/@PVER@ 2> /dev/null || true + chown root:staff /usr/local/lib/@PVER@ 2> /dev/null || true + fi + localsite=/usr/local/lib/@PVER@/dist-packages + if [ ! -e $localsite ]; then + mkdir -p $localsite 2> /dev/null || true + chmod 2775 $localsite 2> /dev/null || true + chown root:staff $localsite 2> /dev/null || true + fi + + if which update-binfmts >/dev/null; then + update-binfmts --import @PVER@ + fi + + ;; +esac + +if [ "$1" = configure ]; then + if ls -L /usr/lib/@PVER@/sitecustomize.py >/dev/null 2>&1; then + filt='cat' + else + filt='fgrep -v sitecustomize.py' + fi + files=$(dpkg -L lib@PVER@-minimal \ + | sed -n '/^\/usr\/lib\/@PVER@\/.*\.py$/p' | $filt) + if [ -n "$files" ]; then + @PVER@ -E -S /usr/lib/@PVER@/py_compile.py $files + if grep -sq '^byte-compile[^#]*optimize' /etc/python/debian_config; then + @PVER@ -E -S -O /usr/lib/@PVER@/py_compile.py $files + fi + else + echo >&2 "@PVER@-minimal: can't get files for byte-compilation" + fi + bc=no + if [ -z "$2" ] || dpkg --compare-versions "$2" lt 2.7-9 \ + || [ -f /var/lib/python/@PVER@_installed ]; then + bc=yes + fi + if grep -sq '^unsupported-versions[^#]*@PVER@' /usr/share/python/debian_defaults + then + # FIXME: byte compile anyway? + bc=no + fi + if [ "$bc" = yes ]; then + # new installation or installation of first version with hook support + if [ "$DEBIAN_FRONTEND" != noninteractive ]; then + echo "Linking and byte-compiling packages for runtime @PVER@..." + fi + version=$(dpkg -s @PVER@-minimal | awk '/^Version:/ {print $2}') + for hook in /usr/share/python/runtime.d/*.rtinstall; do + [ -x $hook ] || continue + $hook rtinstall @PVER@ "$2" "$version" + done + if [ -f /var/lib/python/@PVER@_installed ]; then + rm -f /var/lib/python/@PVER@_installed + rmdir --ignore-fail-on-non-empty /var/lib/python 2>/dev/null + fi + fi +fi + +#DEBHELPER# + +exit 0 --- python2.7-2.7.5.orig/debian/PVER-doc.doc-base.PVER-ref.in +++ python2.7-2.7.5/debian/PVER-doc.doc-base.PVER-ref.in @@ -0,0 +1,18 @@ +Document: @PVER@-ref +Title: Python Reference Manual (v@VER@) +Author: Guido van Rossum +Abstract: This reference manual describes the syntax and "core semantics" of + the language. It is terse, but attempts to be exact and complete. + The semantics of non-essential built-in object types and of the + built-in functions and modules are described in the *Python + Library Reference*. For an informal introduction to the language, + see the *Python Tutorial*. For C or C++ programmers, two + additional manuals exist: *Extending and Embedding the Python + Interpreter* describes the high-level picture of how to write a + Python extension module, and the *Python/C API Reference Manual* + describes the interfaces available to C/C++ programmers in detail. +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/@PVER@/html/reference/index.html +Files: /usr/share/doc/@PVER@/html/reference/*.html --- python2.7-2.7.5.orig/debian/PVER-doc.doc-base.PVER-lib.in +++ python2.7-2.7.5/debian/PVER-doc.doc-base.PVER-lib.in @@ -0,0 +1,15 @@ +Document: @PVER@-lib +Title: Python Library Reference (v@VER@) +Author: Guido van Rossum +Abstract: This library reference manual documents Python's standard library, + as well as many optional library modules (which may or may not be + available, depending on whether the underlying platform supports + them and on the configuration choices made at compile time). It + also documents the standard types of the language and its built-in + functions and exceptions, many of which are not or incompletely + documented in the Reference Manual. +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/@PVER@/html/library/index.html +Files: /usr/share/doc/@PVER@/html/library/*.html --- python2.7-2.7.5.orig/debian/libPVER-stdlib.overrides.in +++ python2.7-2.7.5/debian/libPVER-stdlib.overrides.in @@ -0,0 +1,14 @@ +# idlelib images +lib@PVER@-stdlib binary: image-file-in-usr-lib + +# license file referred by the standard library +lib@PVER@-stdlib binary: extra-license-file + +# template files +lib@PVER@-stdlib binary: interpreter-not-absolute usr/lib/python3.3/venv/scripts/posix/pydoc #!__VENV_PYTHON__ +lib@PVER@-stdlib binary: unusual-interpreter usr/lib/python3.3/venv/scripts/posix/pydoc #!__VENV_PYTHON__ + +# the split is the reason for that +lib@PVER@-stdlib binary: python-script-but-no-python-dep + +lib@PVER@-stdlib binary: arch-dependent-file-not-in-arch-specific-directory --- python2.7-2.7.5.orig/debian/copyright +++ python2.7-2.7.5/debian/copyright @@ -0,0 +1,732 @@ +This package was put together by Klee Dienes from +sources from ftp.python.org:/pub/python, based on the Debianization by +the previous maintainers Bernd S. Brentrup and +Bruce Perens. Current maintainer is Matthias Klose . + +It was downloaded from http://python.org/ + +Copyright: + +Upstream Author: Guido van Rossum and others. + +License: + +The following text includes the Python license and licenses and +acknowledgements for incorporated software. The licenses can be read +in the HTML and texinfo versions of the documentation as well, after +installing the pythonx.y-doc package. Licenses for files not licensed +under the Python Licenses are found at the end of this file. + + +Python License +============== + +A. HISTORY OF THE SOFTWARE +========================== + +Python was created in the early 1990s by Guido van Rossum at Stichting +Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands +as a successor of a language called ABC. Guido remains Python's +principal author, although it includes many contributions from others. + +In 1995, Guido continued his work on Python at the Corporation for +National Research Initiatives (CNRI, see http://www.cnri.reston.va.us) +in Reston, Virginia where he released several versions of the +software. + +In May 2000, Guido and the Python core development team moved to +BeOpen.com to form the BeOpen PythonLabs team. In October of the same +year, the PythonLabs team moved to Digital Creations (now Zope +Corporation, see http://www.zope.com). In 2001, the Python Software +Foundation (PSF, see http://www.python.org/psf/) was formed, a +non-profit organization created specifically to own Python-related +Intellectual Property. Zope Corporation is a sponsoring member of +the PSF. + +All Python releases are Open Source (see http://www.opensource.org for +the Open Source Definition). Historically, most, but not all, Python +releases have also been GPL-compatible; the table below summarizes +the various releases. + + Release Derived Year Owner GPL- + from compatible? (1) + + 0.9.0 thru 1.2 1991-1995 CWI yes + 1.3 thru 1.5.2 1.2 1995-1999 CNRI yes + 1.6 1.5.2 2000 CNRI no + 2.0 1.6 2000 BeOpen.com no + 1.6.1 1.6 2001 CNRI yes (2) + 2.1 2.0+1.6.1 2001 PSF no + 2.0.1 2.0+1.6.1 2001 PSF yes + 2.1.1 2.1+2.0.1 2001 PSF yes + 2.2 2.1.1 2001 PSF yes + 2.1.2 2.1.1 2002 PSF yes + 2.1.3 2.1.2 2002 PSF yes + 2.2.1 2.2 2002 PSF yes + 2.2.2 2.2.1 2002 PSF yes + 2.2.3 2.2.2 2003 PSF yes + 2.3 2.2.2 2002-2003 PSF yes + 2.3.1 2.3 2002-2003 PSF yes + 2.3.2 2.3.1 2002-2003 PSF yes + 2.3.3 2.3.2 2002-2003 PSF yes + 2.3.4 2.3.3 2004 PSF yes + 2.3.5 2.3.4 2005 PSF yes + 2.4 2.3 2004 PSF yes + 2.4.1 2.4 2005 PSF yes + 2.4.2 2.4.1 2005 PSF yes + 2.4.3 2.4.2 2006 PSF yes + 2.5 2.4 2006 PSF yes + 2.5.1 2.5 2007 PSF yes + 2.5.2 2.5.1 2008 PSF yes + 2.5.3 2.5.2 2008 PSF yes + 2.6 2.5 2008 PSF yes + 2.6.1 2.6 2008 PSF yes + 2.6.2 2.6.1 2009 PSF yes + 2.6.3 2.6.2 2009 PSF yes + 2.6.4 2.6.3 2009 PSF yes + 2.6.5 2.6.4 2010 PSF yes + 2.7 2.6 2010 PSF yes + +Footnotes: + +(1) GPL-compatible doesn't mean that we're distributing Python under + the GPL. All Python licenses, unlike the GPL, let you distribute + a modified version without making your changes open source. The + GPL-compatible licenses make it possible to combine Python with + other software that is released under the GPL; the others don't. + +(2) According to Richard Stallman, 1.6.1 is not GPL-compatible, + because its license has a choice of law clause. According to + CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1 + is "not incompatible" with the GPL. + +Thanks to the many outside volunteers who have worked under Guido's +direction to make these releases possible. + + +B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON +=============================================================== + +PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 +-------------------------------------------- + +1. This LICENSE AGREEMENT is between the Python Software Foundation +("PSF"), and the Individual or Organization ("Licensee") accessing and +otherwise using this software ("Python") in source or binary form and +its associated documentation. + +2. Subject to the terms and conditions of this License Agreement, PSF +hereby grants Licensee a nonexclusive, royalty-free, world-wide +license to reproduce, analyze, test, perform and/or display publicly, +prepare derivative works, distribute, and otherwise use Python +alone or in any derivative version, provided, however, that PSF's +License Agreement and PSF's notice of copyright, i.e., "Copyright (c) +2001, 2002, 2003, 2004, 2005, 2006, 2007 Python Software Foundation; +All Rights Reserved" are retained in Python alone or in any derivative +version prepared by Licensee. + +3. In the event Licensee prepares a derivative work that is based on +or incorporates Python or any part thereof, and wants to make +the derivative work available to others as provided herein, then +Licensee hereby agrees to include in any such work a brief summary of +the changes made to Python. + +4. PSF is making Python available to Licensee on an "AS IS" +basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR +IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND +DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT +INFRINGE ANY THIRD PARTY RIGHTS. + +5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON +FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS +A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, +OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +6. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +7. Nothing in this License Agreement shall be deemed to create any +relationship of agency, partnership, or joint venture between PSF and +Licensee. This License Agreement does not grant permission to use PSF +trademarks or trade name in a trademark sense to endorse or promote +products or services of Licensee, or any third party. + +8. By copying, installing or otherwise using Python, Licensee +agrees to be bound by the terms and conditions of this License +Agreement. + + +BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0 +------------------------------------------- + +BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1 + +1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an +office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the +Individual or Organization ("Licensee") accessing and otherwise using +this software in source or binary form and its associated +documentation ("the Software"). + +2. Subject to the terms and conditions of this BeOpen Python License +Agreement, BeOpen hereby grants Licensee a non-exclusive, +royalty-free, world-wide license to reproduce, analyze, test, perform +and/or display publicly, prepare derivative works, distribute, and +otherwise use the Software alone or in any derivative version, +provided, however, that the BeOpen Python License is retained in the +Software, alone or in any derivative version prepared by Licensee. + +3. BeOpen is making the Software available to Licensee on an "AS IS" +basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR +IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND +DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT +INFRINGE ANY THIRD PARTY RIGHTS. + +4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE +SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS +AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY +DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +5. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +6. This License Agreement shall be governed by and interpreted in all +respects by the law of the State of California, excluding conflict of +law provisions. Nothing in this License Agreement shall be deemed to +create any relationship of agency, partnership, or joint venture +between BeOpen and Licensee. This License Agreement does not grant +permission to use BeOpen trademarks or trade names in a trademark +sense to endorse or promote products or services of Licensee, or any +third party. As an exception, the "BeOpen Python" logos available at +http://www.pythonlabs.com/logos.html may be used according to the +permissions granted on that web page. + +7. By copying, installing or otherwise using the software, Licensee +agrees to be bound by the terms and conditions of this License +Agreement. + + +CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1 +--------------------------------------- + +1. This LICENSE AGREEMENT is between the Corporation for National +Research Initiatives, having an office at 1895 Preston White Drive, +Reston, VA 20191 ("CNRI"), and the Individual or Organization +("Licensee") accessing and otherwise using Python 1.6.1 software in +source or binary form and its associated documentation. + +2. Subject to the terms and conditions of this License Agreement, CNRI +hereby grants Licensee a nonexclusive, royalty-free, world-wide +license to reproduce, analyze, test, perform and/or display publicly, +prepare derivative works, distribute, and otherwise use Python 1.6.1 +alone or in any derivative version, provided, however, that CNRI's +License Agreement and CNRI's notice of copyright, i.e., "Copyright (c) +1995-2001 Corporation for National Research Initiatives; All Rights +Reserved" are retained in Python 1.6.1 alone or in any derivative +version prepared by Licensee. Alternately, in lieu of CNRI's License +Agreement, Licensee may substitute the following text (omitting the +quotes): "Python 1.6.1 is made available subject to the terms and +conditions in CNRI's License Agreement. This Agreement together with +Python 1.6.1 may be located on the Internet using the following +unique, persistent identifier (known as a handle): 1895.22/1013. This +Agreement may also be obtained from a proxy server on the Internet +using the following URL: http://hdl.handle.net/1895.22/1013". + +3. In the event Licensee prepares a derivative work that is based on +or incorporates Python 1.6.1 or any part thereof, and wants to make +the derivative work available to others as provided herein, then +Licensee hereby agrees to include in any such work a brief summary of +the changes made to Python 1.6.1. + +4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS" +basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR +IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND +DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT +INFRINGE ANY THIRD PARTY RIGHTS. + +5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON +1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS +A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1, +OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +6. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +7. This License Agreement shall be governed by the federal +intellectual property law of the United States, including without +limitation the federal copyright law, and, to the extent such +U.S. federal law does not apply, by the law of the Commonwealth of +Virginia, excluding Virginia's conflict of law provisions. +Notwithstanding the foregoing, with regard to derivative works based +on Python 1.6.1 that incorporate non-separable material that was +previously distributed under the GNU General Public License (GPL), the +law of the Commonwealth of Virginia shall govern this License +Agreement only as to issues arising under or with respect to +Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this +License Agreement shall be deemed to create any relationship of +agency, partnership, or joint venture between CNRI and Licensee. This +License Agreement does not grant permission to use CNRI trademarks or +trade name in a trademark sense to endorse or promote products or +services of Licensee, or any third party. + +8. By clicking on the "ACCEPT" button where indicated, or by copying, +installing or otherwise using Python 1.6.1, Licensee agrees to be +bound by the terms and conditions of this License Agreement. + + ACCEPT + + +CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2 +-------------------------------------------------- + +Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam, +The Netherlands. All rights reserved. + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Stichting Mathematisch +Centrum or CWI not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO +THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE +FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + +Licenses and Acknowledgements for Incorporated Software +======================================================= + +Mersenne Twister +---------------- + +The `_random' module includes code based on a download from +`http://www.math.keio.ac.jp/~matumoto/MT2002/emt19937ar.html'. The +following are the verbatim comments from the original code: + + A C-program for MT19937, with initialization improved 2002/1/26. + Coded by Takuji Nishimura and Makoto Matsumoto. + + Before using, initialize the state by using init_genrand(seed) + or init_by_array(init_key, key_length). + + Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + Any feedback is very welcome. + http://www.math.keio.ac.jp/matumoto/emt.html + email: matumoto@math.keio.ac.jp + + +Sockets +------- + +The `socket' module uses the functions, `getaddrinfo', and +`getnameinfo', which are coded in separate source files from the WIDE +Project, `http://www.wide.ad.jp/about/index.html'. + + Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the project nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + GAI_ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + FOR GAI_ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON GAI_ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN GAI_ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + + +Floating point exception control +-------------------------------- + +The source for the `fpectl' module includes the following notice: + + --------------------------------------------------------------------- + / Copyright (c) 1996. \ + | The Regents of the University of California. | + | All rights reserved. | + | | + | Permission to use, copy, modify, and distribute this software for | + | any purpose without fee is hereby granted, provided that this en- | + | tire notice is included in all copies of any software which is or | + | includes a copy or modification of this software and in all | + | copies of the supporting documentation for such software. | + | | + | This work was produced at the University of California, Lawrence | + | Livermore National Laboratory under contract no. W-7405-ENG-48 | + | between the U.S. Department of Energy and The Regents of the | + | University of California for the operation of UC LLNL. | + | | + | DISCLAIMER | + | | + | This software was prepared as an account of work sponsored by an | + | agency of the United States Government. Neither the United States | + | Government nor the University of California nor any of their em- | + | ployees, makes any warranty, express or implied, or assumes any | + | liability or responsibility for the accuracy, completeness, or | + | usefulness of any information, apparatus, product, or process | + | disclosed, or represents that its use would not infringe | + | privately-owned rights. Reference herein to any specific commer- | + | cial products, process, or service by trade name, trademark, | + | manufacturer, or otherwise, does not necessarily constitute or | + | imply its endorsement, recommendation, or favoring by the United | + | States Government or the University of California. The views and | + | opinions of authors expressed herein do not necessarily state or | + | reflect those of the United States Government or the University | + | of California, and shall not be used for advertising or product | + \ endorsement purposes. / + --------------------------------------------------------------------- + + +Cookie management +----------------- + +The `Cookie' module contains the following notice: + + Copyright 2000 by Timothy O'Malley + + All Rights Reserved + + Permission to use, copy, modify, and distribute this software + and its documentation for any purpose and without fee is hereby + granted, provided that the above copyright notice appear in all + copies and that both that copyright notice and this permission + notice appear in supporting documentation, and that the name of + Timothy O'Malley not be used in advertising or publicity + pertaining to distribution of the software without specific, written + prior permission. + + Timothy O'Malley DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS, IN NO EVENT SHALL Timothy O'Malley BE LIABLE FOR + ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + + +Execution tracing +----------------- + +The `trace' module contains the following notice: + + portions copyright 2001, Autonomous Zones Industries, Inc., all rights... + err... reserved and offered to the public under the terms of the + Python 2.2 license. + Author: Zooko O'Whielacronx + http://zooko.com/ + mailto:zooko@zooko.com + + Copyright 2000, Mojam Media, Inc., all rights reserved. + Author: Skip Montanaro + + Copyright 1999, Bioreason, Inc., all rights reserved. + Author: Andrew Dalke + + Copyright 1995-1997, Automatrix, Inc., all rights reserved. + Author: Skip Montanaro + + Copyright 1991-1995, Stichting Mathematisch Centrum, all rights reserved. + + Permission to use, copy, modify, and distribute this Python software and + its associated documentation for any purpose without fee is hereby + granted, provided that the above copyright notice appears in all copies, + and that both that copyright notice and this permission notice appear in + supporting documentation, and that the name of neither Automatrix, + Bioreason or Mojam Media be used in advertising or publicity pertaining + to distribution of the software without specific, written prior + permission. + + +UUencode and UUdecode functions +------------------------------- + +The `uu' module contains the following notice: + + Copyright 1994 by Lance Ellinghouse + Cathedral City, California Republic, United States of America. + All Rights Reserved + Permission to use, copy, modify, and distribute this software and its + documentation for any purpose and without fee is hereby granted, + provided that the above copyright notice appear in all copies and that + both that copyright notice and this permission notice appear in + supporting documentation, and that the name of Lance Ellinghouse + not be used in advertising or publicity pertaining to distribution + of the software without specific, written prior permission. + LANCE ELLINGHOUSE DISCLAIMS ALL WARRANTIES WITH REGARD TO + THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS, IN NO EVENT SHALL LANCE ELLINGHOUSE CENTRUM BE LIABLE + FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + Modified by Jack Jansen, CWI, July 1995: + - Use binascii module to do the actual line-by-line conversion + between ascii and binary. This results in a 1000-fold speedup. The C + version is still 5 times faster, though. + - Arguments more compliant with python standard + + +XML Remote Procedure Calls +-------------------------- + +The `xmlrpclib' module contains the following notice: + + The XML-RPC client interface is + + Copyright (c) 1999-2002 by Secret Labs AB + Copyright (c) 1999-2002 by Fredrik Lundh + + By obtaining, using, and/or copying this software and/or its + associated documentation, you agree that you have read, understood, + and will comply with the following terms and conditions: + + Permission to use, copy, modify, and distribute this software and + its associated documentation for any purpose and without fee is + hereby granted, provided that the above copyright notice appears in + all copies, and that both that copyright notice and this permission + notice appear in supporting documentation, and that the name of + Secret Labs AB or the author not be used in advertising or publicity + pertaining to distribution of the software without specific, written + prior permission. + + SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- + ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR + BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + OF THIS SOFTWARE. + +Licenses for Software linked to +=============================== + +Note that the choice of GPL compatibility outlined above doesn't extend +to modules linked to particular libraries, since they change the +effective License of the module binary. + + +GNU Readline +------------ + +The 'readline' module makes use of GNU Readline. + + The GNU Readline Library is free software; you can redistribute it + and/or modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + On Debian systems, you can find the complete statement in + /usr/share/doc/readline-common/copyright'. A copy of the GNU General + Public License is available in /usr/share/common-licenses/GPL-2'. + + +OpenSSL +------- + +The '_ssl' module makes use of OpenSSL. + + The OpenSSL toolkit stays under a dual license, i.e. both the + conditions of the OpenSSL License and the original SSLeay license + apply to the toolkit. Actually both licenses are BSD-style Open + Source licenses. Note that both licenses are incompatible with + the GPL. + + On Debian systems, you can find the complete license text in + /usr/share/doc/openssl/copyright'. + + +Files with other licenses than the Python License +------------------------------------------------- + +Files: Lib/profile.py Lib/pstats.py +Copyright: Disney Enterprises, Inc. All Rights Reserved. +License: # Licensed to PSF under a Contributor Agreement + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + either express or implied. See the License for the specific language + overning permissions and limitations under the License. + + On Debian systems, the Apache 2.0 license can be found in + /usr/share/common-licenses/Apache-2.0. + +Files: Modules/zlib/* +Copyright: (C) 1995-2010 Jean-loup Gailly and Mark Adler +License: This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + If you use the zlib library in a product, we would appreciate *not* receiving + lengthy legal documents to sign. The sources are provided for free but without + warranty of any kind. The library has been entirely written by Jean-loup + Gailly and Mark Adler; it does not include third-party code. + +Files: Modules/_ctypes/libffi/* +Copyright: Copyright (C) 1996-2009 Red Hat, Inc and others. +License: Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + ``Software''), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + Documentation: + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. A copy of the license is included in the + section entitled ``GNU General Public License''. + +Files: Modules/expat/* +Copyright: Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd + and Clark Cooper + Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers +License: Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Files: Misc/python-mode.el +Copyright: Copyright (C) 1992,1993,1994 Tim Peters +License: This software is provided as-is, without express or implied + warranty. Permission to use, copy, modify, distribute or sell this + software, without fee, for any purpose and by any individual or + organization, is hereby granted, provided that the above copyright + notice and this paragraph appear in all copies. + +Files: PC/_subprocess.c +Copyright: Copyright (c) 2004 by Fredrik Lundh + Copyright (c) 2004 by Secret Labs AB, http://www.pythonware.com + Copyright (c) 2004 by Peter Astrand +License: + * Permission to use, copy, modify, and distribute this software and + * its associated documentation for any purpose and without fee is + * hereby granted, provided that the above copyright notice appears in + * all copies, and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * authors not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. + * + * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Files: PC/winsound.c +Copyright: Copyright (c) 1999 Toby Dickenson +License: * Permission to use this software in any way is granted without + * fee, provided that the copyright notice above appears in all + * copies. This software is provided "as is" without any warranty. + */ + +/* Modified by Guido van Rossum */ +/* Beep added by Mark Hammond */ +/* Win9X Beep and platform identification added by Uncle Timmy */ --- python2.7-2.7.5.orig/debian/watch +++ python2.7-2.7.5/debian/watch @@ -0,0 +1,3 @@ +version=3 +opts=dversionmangle=s/.*\+//,uversionmangle=s/([abcr]+[1-9])$/~$1/ \ + http://www.python.org/ftp/python/2\.7(\.\d)?/Python-(2\.7[.\dabcr]*)\.tgz --- python2.7-2.7.5.orig/debian/locale-gen +++ python2.7-2.7.5/debian/locale-gen @@ -0,0 +1,31 @@ +#!/bin/sh + +LOCPATH=`pwd`/locales +export LOCPATH + +[ -d $LOCPATH ] || mkdir -p $LOCPATH + +umask 022 + +echo "Generating locales..." +while read locale charset; do + case $locale in \#*) continue;; esac + [ -n "$locale" -a -n "$charset" ] || continue + echo -n " `echo $locale | sed 's/\([^.\@]*\).*/\1/'`" + echo -n ".$charset" + echo -n `echo $locale | sed 's/\([^\@]*\)\(\@.*\)*/\2/'` + echo -n '...' + if [ -f $LOCPATH/$locale ]; then + input=$locale + else + input=`echo $locale | sed 's/\([^.]*\)[^@]*\(.*\)/\1\2/'` + fi + localedef -i $input -c -f $charset $LOCPATH/$locale #-A /etc/locale.alias + echo ' done'; \ +done <&2 + exit 1 + ;; +esac + +rmdir /usr/local/lib/python@VER@/site-packages 2>/dev/null && \ + rmdir /usr/local/lib/python@VER@ 2>/dev/null || \ + true + +#DEBHELPER# --- python2.7-2.7.5.orig/debian/idle-PVER.1.in +++ python2.7-2.7.5/debian/idle-PVER.1.in @@ -0,0 +1,104 @@ +.TH IDLE 1 "21 September 2004" +.SH NAME +\fBIDLE\fP \- An Integrated DeveLopment Environment for Python +.SH SYNTAX +.B idle [ \fI-dins\fP ] [ \fI-t title\fP ] [ \fIfile\fP ...] +.PP +.B idle [ \fI-dins\fP ] [ \fI-t title\fP ] ( \fI-c cmd\fP | \fI-r file\fP ) [ \fIarg\fP ...] +.PP +.B idle [ \fI-dins\fP ] [ \fI-t title\fP ] - [ \fIarg\fP ...] +.SH DESCRIPTION +This manual page documents briefly the +.BR idle +command. +This manual page was written for Debian +because the original program does not have a manual page. +For more information, refer to IDLE's help menu. +.PP +.B IDLE +is an Integrated DeveLopment Environment for Python. IDLE is based on +Tkinter, Python's bindings to the Tk widget set. Features are 100% pure +Python, multi-windows with multiple undo and Python colorizing, a Python +shell window subclass, a debugger. IDLE is cross-platform, i.e. it works +on all platforms where Tk is installed. +.LP +.SH OPTIONS +.TP +.B \-h +.PD +Print this help message and exit. +.TP +.B \-n +.PD +Run IDLE without a subprocess (see Help/IDLE Help for details). +.PP +The following options will override the IDLE 'settings' configuration: +.TP +.B \-e +.PD +Open an edit window. +.TP +.B \-i +.PD +Open a shell window. +.PP +The following options imply -i and will open a shell: +.TP +.B \-c cmd +.PD +Run the command in a shell, or +.TP +.B \-r file +.PD +Run script from file. +.PP +.TP +.B \-d +.PD +Enable the debugger. +.TP +.B \-s +.PD +Run $IDLESTARTUP or $PYTHONSTARTUP before anything else. +.TP +.B \-t title +.PD +Set title of shell window. +.PP +A default edit window will be bypassed when -c, -r, or - are used. +.PP +[arg]* and [file]* are passed to the command (-c) or script (-r) in sys.argv[1:]. +.SH EXAMPLES +.TP +idle +.PD +Open an edit window or shell depending on IDLE's configuration. +.TP +idle foo.py foobar.py +.PD +Edit the files, also open a shell if configured to start with shell. +.TP +idle -est "Baz" foo.py +.PD +Run $IDLESTARTUP or $PYTHONSTARTUP, edit foo.py, and open a shell +window with the title "Baz". +.TP +idle -c "import sys; print sys.argv" "foo" +.PD +Open a shell window and run the command, passing "-c" in sys.argv[0] +and "foo" in sys.argv[1]. +.TP +idle -d -s -r foo.py "Hello World" +.PD +Open a shell window, run a startup script, enable the debugger, and +run foo.py, passing "foo.py" in sys.argv[0] and "Hello World" in +sys.argv[1]. +.TP +echo "import sys; print sys.argv" | idle - "foobar" +.PD +Open a shell window, run the script piped in, passing '' in sys.argv[0] +and "foobar" in sys.argv[1]. +.SH SEE ALSO +python(1). +.SH AUTHORS +Various. --- python2.7-2.7.5.orig/debian/FAQ.html +++ python2.7-2.7.5/debian/FAQ.html @@ -0,0 +1,8997 @@ + + +The Whole Python FAQ + + + +

The Whole Python FAQ

+Last changed on Wed Feb 12 21:31:08 2003 CET + +

(Entries marked with ** were changed within the last 24 hours; +entries marked with * were changed within the last 7 days.) +

+ +

+


+

1. General information and availability

+ + +

+


+

2. Python in the real world

+ + +

+


+

3. Building Python and Other Known Bugs

+ + +

+


+

4. Programming in Python

+ + +

+


+

5. Extending Python

+ + +

+


+

6. Python's design

+ + +

+


+

7. Using Python on non-UNIX platforms

+ + +

+


+

8. Python on Windows

+ + +
+

1. General information and availability

+ +
+

1.1. What is Python?

+Python is an interpreted, interactive, object-oriented programming +language. It incorporates modules, exceptions, dynamic typing, very +high level dynamic data types, and classes. Python combines +remarkable power with very clear syntax. It has interfaces to many +system calls and libraries, as well as to various window systems, and +is extensible in C or C++. It is also usable as an extension language +for applications that need a programmable interface. Finally, Python +is portable: it runs on many brands of UNIX, on the Mac, and on PCs +under MS-DOS, Windows, Windows NT, and OS/2. +

+To find out more, the best thing to do is to start reading the +tutorial from the documentation set (see a few questions further +down). +

+See also question 1.17 (what is Python good for). +

+ +Edit this entry / +Log info + +/ Last changed on Mon May 26 16:05:18 1997 by +GvR +

+ +


+

1.2. Why is it called Python?

+Apart from being a computer scientist, I'm also a fan of "Monty +Python's Flying Circus" (a BBC comedy series from the seventies, in +the -- unlikely -- case you didn't know). It occurred to me one day +that I needed a name that was short, unique, and slightly mysterious. +And I happened to be reading some scripts from the series at the +time... So then I decided to call my language Python. +

+By now I don't care any more whether you use a Python, some other +snake, a foot or 16-ton weight, or a wood rat as a logo for Python! +

+ +Edit this entry / +Log info + +/ Last changed on Thu Aug 24 00:50:41 2000 by +GvR +

+ +


+

1.3. How do I obtain a copy of the Python source?

+The latest Python source distribution is always available from +python.org, at http://www.python.org/download. The latest development sources can be obtained via anonymous CVS from SourceForge, at http://www.sf.net/projects/python . +

+The source distribution is a gzipped tar file containing the complete C source, LaTeX +documentation, Python library modules, example programs, and several +useful pieces of freely distributable software. This will compile and +run out of the box on most UNIX platforms. (See section 7 for +non-UNIX information.) +

+Older versions of Python are also available from python.org. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Apr 9 17:06:16 2002 by +A.M. Kuchling +

+ +


+

1.4. How do I get documentation on Python?

+All documentation is available on-line, starting at http://www.python.org/doc/. +

+The LaTeX source for the documentation is part of the source +distribution. If you don't have LaTeX, the latest Python +documentation set is available, in various formats like postscript +and html, by anonymous ftp - visit the above URL for links to the +current versions. +

+PostScript for a high-level description of Python is in the file nluug-paper.ps +(a separate file on the ftp site). +

+ +Edit this entry / +Log info + +/ Last changed on Wed Jan 21 12:02:55 1998 by +Ken Manheimer +

+ +


+

1.5. Are there other ftp sites that mirror the Python distribution?

+The following anonymous ftp sites keep mirrors of the Python +distribution: +

+USA: +

+

+        ftp://ftp.python.org/pub/python/
+        ftp://gatekeeper.dec.com/pub/plan/python/
+        ftp://ftp.uu.net/languages/python/
+        ftp://ftp.wustl.edu/graphics/graphics/sgi-stuff/python/
+        ftp://ftp.sterling.com/programming/languages/python/
+        ftp://uiarchive.cso.uiuc.edu/pub/lang/python/
+        ftp://ftp.pht.com/mirrors/python/python/
+	ftp://ftp.cdrom.com/pub/python/
+
+Europe: +

+

+        ftp://ftp.cwi.nl/pub/python/
+        ftp://ftp.funet.fi/pub/languages/python/
+        ftp://ftp.sunet.se/pub/lang/python/
+        ftp://unix.hensa.ac.uk/mirrors/uunet/languages/python/
+        ftp://ftp.lip6.fr/pub/python/
+        ftp://sunsite.cnlab-switch.ch/mirror/python/
+        ftp://ftp.informatik.tu-muenchen.de/pub/comp/programming/languages/python/
+
+Australia: +

+

+        ftp://ftp.dstc.edu.au/pub/python/
+
+

+ +Edit this entry / +Log info + +/ Last changed on Wed Mar 24 09:20:49 1999 by +A.M. Kuchling +

+ +


+

1.6. Is there a newsgroup or mailing list devoted to Python?

+There is a newsgroup, comp.lang.python, +and a mailing list. The newsgroup and mailing list are gatewayed into +each other -- if you can read news it's unnecessary to subscribe to +the mailing list. To subscribe to the mailing list +(python-list@python.org) visit its Mailman webpage at +http://www.python.org/mailman/listinfo/python-list +

+More info about the newsgroup and mailing list, and about other lists, +can be found at +http://www.python.org/psa/MailingLists.html. +

+Archives of the newsgroup are kept by Deja News and accessible +through the "Python newsgroup search" web page, +http://www.python.org/search/search_news.html. +This page also contains pointer to other archival collections. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Jun 23 09:29:36 1999 by +GvR +

+ +


+

1.7. Is there a WWW page devoted to Python?

+Yes, http://www.python.org/ is the official Python home page. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 23 14:42:59 1997 by +Ken Manheimer +

+ +


+

1.8. Is the Python documentation available on the WWW?

+Yes. Python 2.0 documentation is available from +http://www.pythonlabs.com/tech/python2.0/doc/ and from +http://www.python.org/doc/. Note that most documentation +is available for on-line browsing as well as for downloading. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 2 03:14:08 2001 by +Moshe Zadka +

+ +


+

1.9. Are there any books on Python?

+Yes, many, and more are being published. See +the python.org Wiki at http://www.python.org/cgi-bin/moinmoin/PythonBooks for a list. +

+You can also search online bookstores for "Python" +(and filter out the Monty Python references; or +perhaps search for "Python" and "language"). +

+ +Edit this entry / +Log info + +/ Last changed on Mon Aug 5 19:08:49 2002 by +amk +

+ +


+

1.10. Are there any published articles about Python that I can reference?

+If you can't reference the web site, and you don't want to reference the books +(see previous question), there are several articles on Python that you could +reference. +

+Most publications about Python are collected on the Python web site: +

+

+    http://www.python.org/doc/Publications.html
+
+It is no longer recommended to reference this +very old article by Python's author: +

+

+    Guido van Rossum and Jelke de Boer, "Interactively Testing Remote
+    Servers Using the Python Programming Language", CWI Quarterly, Volume
+    4, Issue 4 (December 1991), Amsterdam, pp 283-303.
+
+

+ +Edit this entry / +Log info + +/ Last changed on Sat Jul 4 20:52:31 1998 by +GvR +

+ +


+

1.11. Are there short introductory papers or talks on Python?

+There are several - you can find links to some of them collected at +http://www.python.org/doc/Hints.html#intros. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 23 15:04:05 1997 by +Ken Manheimer +

+ +


+

1.12. How does the Python version numbering scheme work?

+Python versions are numbered A.B.C or A.B. A is the major version +number -- it is only incremented for really major changes in the +language. B is the minor version number, incremented for less +earth-shattering changes. C is the micro-level -- it is +incremented for each bugfix release. See PEP 6 for more information +about bugfix releases. +

+Not all releases have bugfix releases. +Note that in the past (ending with 1.5.2), +micro releases have added significant changes; +in fact the changeover from 0.9.9 to 1.0.0 was the first time +that either A or B changed! +

+Alpha, beta and release candidate versions have an additional suffixes. +The suffix for an alpha version is "aN" for some small number N, the +suffix for a beta version is "bN" for some small number N, and the +suffix for a release candidate version is "cN" for some small number N. +

+Note that (for instance) all versions labeled 2.0aN precede the +versions labeled 2.0bN, which precede versions labeled 2.0cN, and +those precede 2.0. +

+As a rule, no changes are made between release candidates and the final +release unless there are show-stopper bugs. +

+You may also find version numbers with a "+" suffix, e.g. "2.2+". +These are unreleased versions, built directly from the CVS trunk. +

+See also the documentation for sys.version, sys.hexversion, and +sys.version_info. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jan 14 06:34:17 2002 by +GvR +

+ +


+

1.13. How do I get a beta test version of Python?

+All releases, including alphas, betas and release candidates, are announced on +comp.lang.python and comp.lang.python.announce newsgroups, +which are gatewayed into the python-list@python.org and +python-announce@python.org. In addition, all these announcements appear on +the Python home page, at http://www.python.org. +

+You can also access the development version of Python through CVS. See http://sourceforge.net/cvs/?group_id=5470 for details. If you're not familiar with CVS, documents like http://linux.oreillynet.com/pub/a/linux/2002/01/03/cvs_intro.html +provide an introduction. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 00:57:08 2002 by +Neal Norwitz +

+ +


+

1.14. Are there copyright restrictions on the use of Python?

+Hardly. You can do anything you want with the source, as long as +you leave the copyrights in, and display those copyrights in any +documentation about Python that you produce. Also, don't use the +author's institute's name in publicity without prior written +permission, and don't hold them responsible for anything (read the +actual copyright for a precise legal wording). +

+In particular, if you honor the copyright rules, it's OK to use Python +for commercial use, to sell copies of Python in source or binary form, +or to sell products that enhance Python or incorporate Python (or part +of it) in some form. I would still like to know about all commercial +use of Python! +

+ +Edit this entry / +Log info +

+ +


+

1.15. Why was Python created in the first place?

+Here's a very brief summary of what got me started: +

+I had extensive experience with implementing an interpreted language +in the ABC group at CWI, and from working with this group I had +learned a lot about language design. This is the origin of many +Python features, including the use of indentation for statement +grouping and the inclusion of very-high-level data types (although the +details are all different in Python). +

+I had a number of gripes about the ABC language, but also liked many +of its features. It was impossible to extend the ABC language (or its +implementation) to remedy my complaints -- in fact its lack of +extensibility was one of its biggest problems. +I had some experience with using Modula-2+ and talked with the +designers of Modula-3 (and read the M3 report). M3 is the origin of +the syntax and semantics used for exceptions, and some other Python +features. +

+I was working in the Amoeba distributed operating system group at +CWI. We needed a better way to do system administration than by +writing either C programs or Bourne shell scripts, since Amoeba had +its own system call interface which wasn't easily accessible from the +Bourne shell. My experience with error handling in Amoeba made me +acutely aware of the importance of exceptions as a programming +language feature. +

+It occurred to me that a scripting language with a syntax like ABC +but with access to the Amoeba system calls would fill the need. I +realized that it would be foolish to write an Amoeba-specific +language, so I decided that I needed a language that was generally +extensible. +

+During the 1989 Christmas holidays, I had a lot of time on my hand, +so I decided to give it a try. During the next year, while still +mostly working on it in my own time, Python was used in the Amoeba +project with increasing success, and the feedback from colleagues made +me add many early improvements. +

+In February 1991, after just over a year of development, I decided +to post to USENET. The rest is in the Misc/HISTORY file. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 23 00:06:23 1997 by +GvR +

+ +


+

1.16. Do I have to like "Monty Python's Flying Circus"?

+No, but it helps. Pythonistas like the occasional reference to SPAM, +and of course, nobody expects the Spanish Inquisition +

+The two main reasons to use Python are: +

+

+ - Portable
+ - Easy to learn
+
+The three main reasons to use Python are: +

+

+ - Portable
+ - Easy to learn
+ - Powerful standard library
+
+(And nice red uniforms.) +

+And remember, there is no rule six. +

+ +Edit this entry / +Log info + +/ Last changed on Wed May 28 10:39:21 1997 by +GvR +

+ +


+

1.17. What is Python good for?

+Python is used in many situations where a great deal of dynamism, +ease of use, power, and flexibility are required. +

+In the area of basic text +manipulation core Python (without any non-core extensions) is easier +to use and is roughly as fast as just about any language, and this makes Python +good for many system administration type tasks and for CGI programming +and other application areas that manipulate text and strings and such. +

+When augmented with +standard extensions (such as PIL, COM, Numeric, oracledb, kjbuckets, +tkinter, win32api, etc.) +or special purpose extensions (that you write, perhaps using helper tools such +as SWIG, or using object protocols such as ILU/CORBA or COM) Python +becomes a very convenient "glue" or "steering" +language that helps make heterogeneous collections of unrelated +software packages work together. +For example by combining Numeric with oracledb you can help your +SQL database do statistical analysis, or even Fourier transforms. +One of the features that makes Python excel in the "glue language" role +is Python's simple, usable, and powerful C language runtime API. +

+Many developers also use Python extensively as a graphical user +interface development aide. +

+ +Edit this entry / +Log info + +/ Last changed on Sat May 24 10:13:11 1997 by +Aaron Watters +

+ +


+

1.18. Can I use the FAQ Wizard software to maintain my own FAQ?

+Sure. It's in Tools/faqwiz/ of the python source tree. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Mar 29 06:50:32 2002 by +Aahz +

+ +


+

1.19. Which editor has good support for editing Python source code?

+On Unix, the first choice is Emacs/XEmacs. There's an elaborate +mode for editing Python code, which is available from the Python +source distribution (Misc/python-mode.el). It's also bundled +with XEmacs (we're still working on legal details to make it possible +to bundle it with FSF Emacs). And it has its own web page: +

+

+    http://www.python.org/emacs/python-mode/index.html
+
+There are many other choices, for Unix, Windows or Macintosh. +Richard Jones compiled a table from postings on the Python newsgroup: +

+

+    http://www.bofh.asn.au/~richard/editors.html
+
+See also FAQ question 7.10 for some more Mac and Win options. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 15 23:21:04 1998 by +Gvr +

+ +


+

1.20. I've never programmed before. Is there a Python tutorial?

+There are several, and at least one book. +All information for beginning Python programmers is collected here: +

+

+    http://www.python.org/doc/Newbies.html
+
+

+ +Edit this entry / +Log info + +/ Last changed on Wed Sep 5 05:34:07 2001 by +GvR +

+ +


+

1.21. Where in the world is www.python.org located?

+It's currently in Amsterdam, graciously hosted by XS4ALL: +

+

+    http://www.xs4all.nl
+
+Thanks to Thomas Wouters for setting this up!!!! +

+ +Edit this entry / +Log info + +/ Last changed on Fri Aug 3 21:49:27 2001 by +GvR +

+ +


+

2. Python in the real world

+ +
+

2.1. How many people are using Python?

+Certainly thousands, and quite probably tens of thousands of users. +More are seeing the light each day. The comp.lang.python newsgroup is +very active, but overall there is no accurate estimate of the number of subscribers or Python users. +

+Jacek Artymiak has created a Python Users Counter; you can see the +current count by visiting +http://www.wszechnica.safenet.pl/cgi-bin/checkpythonuserscounter.py +(this will not increment the counter; use the link there if you haven't +added yourself already). Most Python users appear not to have registered themselves. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Feb 21 23:29:18 2002 by +GvR +

+ +


+

2.2. Have any significant projects been done in Python?

+At CWI (the former home of Python), we have written a 20,000 line +authoring environment for transportable hypermedia presentations, a +5,000 line multimedia teleconferencing tool, as well as many many +smaller programs. +

+At CNRI (Python's new home), we have written two large applications: +Grail, a fully featured web browser (see +http://grail.cnri.reston.va.us), +and the Knowbot Operating Environment, +a distributed environment for mobile code. +

+The University of Virginia uses Python to control a virtual reality +engine. See http://alice.cs.cmu.edu. +

+The ILU project at Xerox PARC can generate Python glue for ILU +interfaces. See ftp://ftp.parc.xerox.com/pub/ilu/ilu.html. ILU +is a free CORBA compliant ORB which supplies distributed object +connectivity to a host of platforms using a host of languages. +

+Mark Hammond and Greg Stein and others are interfacing Python to +Microsoft's COM and ActiveX architectures. This means, among other +things, that Python may be used in active server pages or as a COM +controller (for example to automatically extract from or insert information +into Excel or MSAccess or any other COM aware application). +Mark claims Python can even be a ActiveX scripting host (which +means you could embed JScript inside a Python application, if you +had a strange sense of humor). Python/AX/COM is distributed as part +of the PythonWin distribution. +

+The University of California, Irvine uses a student administration +system called TELE-Vision written entirely in Python. Contact: Ray +Price rlprice@uci.edu. +

+The Melbourne Cricket Ground (MCG) in Australia (a 100,000+ person venue) +has it's scoreboard system written largely in Python on MS Windows. +Python expressions are used to create almost every scoring entry that +appears on the board. The move to Python/C++ away from exclusive C++ +has provided a level of functionality that would simply not have been +viable otherwise. +

+See also the next question. +

+Note: this FAQ entry is really old. +See http://www.python.org/psa/Users.html for a more recent list. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Oct 25 13:24:15 2000 by +GvR +

+ +


+

2.3. Are there any commercial projects going on using Python?

+Yes, there's lots of commercial activity using Python. See +http://www.python.org/psa/Users.html for a list. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Oct 14 18:17:33 1998 by +ken +

+ +


+

2.4. How stable is Python?

+Very stable. New, stable releases have been coming out roughly every 3 to 12 months since 1991, and this seems likely to continue. +

+With the introduction of retrospective "bugfix" releases the stability of the language implementations can be, and is being, improved independently of the new features offered by more recent major or minor releases. Bugfix releases, indicated by a third component of the version number, only fix known problems and do not gratuitously introduce new and possibly incompatible features or modified library functionality. +

+Release 2.2 got its first bugfix on April 10, 2002. The new version +number is now 2.2.1. The 2.1 release, at 2.1.3, can probably be +considered the "most stable" platform because it has been bugfixed +twice. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jul 23 10:20:04 2002 by +Jens Kubieziel +

+ +


+

2.5. What new developments are expected for Python in the future?

+See http://www.python.org/peps/ for the Python Enhancement +Proposals (PEPs). PEPs are design +documents +describing a suggested new feature for Python, providing +a concise technical specification and a rationale. +

+Also, follow the discussions on the python-dev mailing list. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Apr 9 17:09:51 2002 by +A.M. Kuchling +

+ +


+

2.6. Is it reasonable to propose incompatible changes to Python?

+In general, no. There are already millions of lines of Python code +around the world, so any changes in the language that invalidates more +than a very small fraction of existing programs has to be frowned +upon. Even if you can provide a conversion program, there still is +the problem of updating all documentation. Providing a gradual +upgrade path is the only way if a feature has to be changed. +

+See http://www.python.org/peps/pep-0005.html for the proposed +mechanism for creating backwards-incompatibilities. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Apr 1 22:13:47 2002 by +Fred Drake +

+ +


+

2.7. What is the future of Python?

+Please see http://www.python.org/peps/ for proposals of future +activities. One of the PEPs (Python Enhancement Proposals) deals +with the PEP process and PEP format -- see +http://www.python.org/peps/pep-0001.html if you want to +submit a PEP. In http://www.python.org/peps/pep-0042.html there +is a list of wishlists the Python Development team plans to tackle. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Apr 1 22:15:46 2002 by +Fred Drake +

+ +


+

2.8. What was the PSA, anyway?

+The Python Software Activity was +created by a number of Python aficionados who want Python to be more +than the product and responsibility of a single individual. +The PSA was not an independent organization, but lived +under the umbrealla of CNRI. +

+The PSA has been superseded by the Python Software Foundation, +an independent non-profit organization. The PSF's home page +is at http://www.python.org/psf/. +

+Some pages created by the PSA still live at +http://www.python.org/psa/ +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jul 25 18:19:44 2002 by +GvR +

+ +


+

2.9. Deleted

+

+

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 2 02:51:30 2001 by +Moshe Zadka +

+ +


+

2.10. Deleted

+

+

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 2 02:52:19 2001 by +Moshe Zadka +

+ +


+

2.11. Is Python Y2K (Year 2000) Compliant?

+As of January, 2001 no major problems have been reported and Y2K +compliance seems to be a non-issue. +

+Since Python is available free of charge, there are no absolute +guarantees. If there are unforeseen problems, liability is the +user's rather than the developers', and there is nobody you can sue for damages. +

+Python does few +date manipulations, and what it does is all based on the Unix +representation for time (even on non-Unix systems) which uses seconds +since 1970 and won't overflow until 2038. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jan 8 17:19:32 2001 by +Steve Holden +

+ +


+

2.12. Is Python a good language in a class for beginning programmers?

+Yes. This long answer attempts to address any concerns you might +have with teaching Python as a programmer's first language. +(If you want to discuss Python's use in education, then +you may be interested in joining the edu-sig mailinglist. +See http://www.python.org/sigs/edu-sig/ ) +

+It is still common to start students with a procedural +(subset of a) statically typed language such as Pascal, C, or +a subset of C++ or Java. I think that students may be better +served by learning Python as their first language. Python has +a very simple and consistent syntax and a large standard library. +Most importantly, using Python in a beginning programming course +permits students to concentrate on important programming skills, +such as problem decomposition and data type design. +

+With Python, students can be quickly introduced to basic concepts +such as loops and procedures. They can even probably work with +user-defined objects in their very first course. They could +implement a tree structure as nested Python lists, for example. +They could be introduced to objects in their first course if +desired. For a student who has never programmed before, using +a statically typed language seems unnatural. It presents +additional complexity that the student must master and slows +the pace of the course. The students are trying to learn to +think like a computer, decompose problems, design consistent +interfaces, and encapsulate data. While learning to use a +statically typed language is important, it is not necessarily the +best topic to address in the students' first programming course. +

+Many other aspects of Python make it a good first language. +Python has a large standard library (like Java) so that +students can be assigned programming projects very early in the +course that do something. Assignments aren't restricted to the +standard four-function calculator and check balancing programs. +By using the standard library, students can gain the satisfaction +of working on realistic applications as they learn the fundamentals +of programming. Using the standard library also teaches students +about code reuse. +

+Python's interactive interpreter also enables students to +test language features while they're programming. They can keep +a window with the interpreter running while they enter their +programs' source in another window. If they can't remember the +methods for a list, they can do something like this: +

+

+ >>> L = []
+ >>> dir(L)
+ ['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove',
+ 'reverse', 'sort']
+ >>> print L.append.__doc__
+ L.append(object) -- append object to end
+ >>> L.append(1)
+ >>> L
+ [1]
+
+With the interpreter, documentation is never far from the +student as he's programming. +

+There are also good IDEs for Python. Guido van Rossum's IDLE +is a cross-platform IDE for Python that is written in Python +using Tk. There is also a Windows specific IDE called PythonWin. +Emacs users will be happy to know that there is a very good Python +mode for Emacs. All of these programming environments provide +syntax highlighting, auto-indenting, and access to the interactive +interpreter while coding. For more information about IDEs, see XXX. +

+If your department is currently using Pascal because it was +designed to be a teaching language, then you'll be happy to +know that Guido van Rossum designed Python to be simple to +teach to everyone but powerful enough to implement real world +applications. Python makes a good language for first time +programmers because that was one of Python's design goals. +There are papers at http://www.python.org/doc/essays/ on the Python website +by Python's creator explaining his objectives for the language. +One that may interest you is titled "Computer Programming for Everybody" +http://www.python.org/doc/essays/cp4e.html +

+If you're seriously considering Python as a language for your +school, Guido van Rossum may even be willing to correspond with +you about how the language would fit in your curriculum. +See http://www.python.org/doc/FAQ.html#2.2 for examples of +Python's use in the "real world." +

+While Python, its source code, and its IDEs are freely +available, this consideration should not rule +out other languages. There are other free languages (Java, +free C compilers), and many companies are willing to waive some +or all of their fees for student programming tools if it +guarantees that a whole graduating class will know how to +use their tools. That is, if one of the requirements for +the language that will be taught is that it be freely +available, then Python qualifies, but this requirement +does not preclude other languages. +

+While Python jobs may not be as prevalent as C/C++/Java jobs, +teachers should not worry about teaching students critical job +skills in their first course. The skills that win students a +job are those they learn in their senior classes and internships. +Their first programming courses are there to lay a solid +foundation in programming fundamentals. The primary question +in choosing the language for such a course should be which +language permits the students to learn this material without +hindering or limiting them. +

+Another argument for Python is that there are many tasks for +which something like C++ is overkill. That's where languages +like Python, Perl, Tcl, and Visual Basic thrive. It's critical +for students to know something about these languages. (Every +employer for whom I've worked used at least one such language.) +Of the languages listed above, Python probably makes the best +language in a programming curriculum since its syntax is simple, +consistent, and not unlike other languages (C/C++/Java) that +are probably in the curriculum. By starting students with +Python, a department simultaneously lays the foundations for +other programming courses and introduces students to the type +of language that is often used as a "glue" language. As an +added bonus, Python can be used to interface with Microsoft's +COM components (thanks to Mark Hammond). There is also Jython, +a Java implementation of the Python interpreter, that can be +used to connect Java components. +

+If you currently start students with Pascal or C/C++ or Java, +you may be worried they will have trouble learning a statically +typed language after starting with Python. I think that this +fear most often stems from the fact that the teacher started +with a statically typed language, and we tend to like to teach +others in the same way we were taught. In reality, the +transition from Python to one of these other languages is +quite simple. +

+To motivate a statically typed language such as C++, begin the +course by explaining that unlike Python, their first language, +C++ is compiled to a machine dependent executable. Explain +that the point is to make a very fast executable. To permit +the compiler to make optimizations, programmers must help it +by specifying the "types" of variables. By restricting each +variable to a specific type, the compiler can reduce the +book-keeping it has to do to permit dynamic types. The compiler +also has to resolve references at compile time. Thus, the +language gains speed by sacrificing some of Python's dynamic +features. Then again, the C++ compiler provides type safety +and catches many bugs at compile time instead of run time (a +critical consideration for many commercial applications). C++ +is also designed for very large programs where one may want to +guarantee that others don't touch an object's implementation. +C++ provides very strong language features to separate an object's +implementation from its interface. Explain why this separation +is a good thing. +

+The first day of a C++ course could then be a whirlwind introduction +to what C++ requires and provides. The point here is that after +a semester or two of Python, students are hopefully competent +programmers. They know how to handle loops and write procedures. +They've also worked with objects, thought about the benefits of +consistent interfaces, and used the technique of subclassing to +specialize behavior. Thus, a whirlwind introduction to C++ could +show them how objects and subclassing looks in C++. The +potentially difficult concepts of object-oriented design were +taught without the additional obstacles presented by a language +such as C++ or Java. When learning one of these languages, +the students would already understand the "road map." They +understand objects; they would just be learning how objects +fit in a statically typed languages. Language requirements +and compiler errors that seem unnatural to beginning programmers +make sense in this new context. Many students will find it +helpful to be able to write a fast prototype of their algorithms +in Python. Thus, they can test and debug their ideas before +they attempt to write the code in the new language, saving the +effort of working with C++ types for when they've discovered a +working solution for their assignments. When they get annoyed +with the rigidity of types, they'll be happy to learn about +containers and templates to regain some of the lost flexibility +Python afforded them. Students may also gain an appreciation +for the fact that no language is best for every task. They'll +see that C++ is faster, but they'll know that they can gain +flexibility and development speed with a Python when execution +speed isn't critical. +

+If you have any concerns that weren't addressed here, try +posting to the Python newsgroup. Others there have done some +work with using Python as an instructional tool. Good luck. +We'd love to hear about it if you choose Python for your course. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Dec 2 19:32:35 2002 by +Bill Sconce +

+ +


+

3. Building Python and Other Known Bugs

+ +
+

3.1. Is there a test set?

+Sure. You can run it after building with "make test", or you can +run it manually with this command at the Python prompt: +

+

+ import test.autotest
+
+In Python 1.4 or earlier, use +

+

+ import autotest
+
+The test set doesn't test all features of Python, +but it goes a long way to confirm that Python is actually working. +

+NOTE: if "make test" fails, don't just mail the output to the +newsgroup -- this doesn't give enough information to debug the +problem. Instead, find out which test fails, and run that test +manually from an interactive interpreter. For example, if +"make test" reports that test_spam fails, try this interactively: +

+

+ import test.test_spam
+
+This generally produces more verbose output which can be diagnosed +to debug the problem. If you find a bug in Python or the libraries, or in the tests, please report this in the Python bug tracker at SourceForge: +

+http://sourceforge.net/tracker/?func=add&group_id=5470&atid=105470 +

+ +Edit this entry / +Log info + +/ Last changed on Fri Apr 27 10:29:36 2001 by +Fred Drake +

+ +


+

3.2. When running the test set, I get complaints about floating point operations, but when playing with floating point operations I cannot find anything wrong with them.

+The test set makes occasional unwarranted assumptions about the +semantics of C floating point operations. Until someone donates a +better floating point test set, you will have to comment out the +offending floating point tests and execute similar tests manually. +

+ +Edit this entry / +Log info +

+ +


+

3.3. Link errors after rerunning the configure script.

+It is generally necessary to run "make clean" after a configuration +change. +

+ +Edit this entry / +Log info +

+ +


+

3.4. The python interpreter complains about options passed to a script (after the script name).

+You are probably linking with GNU getopt, e.g. through -liberty. +Don't. The reason for the complaint is that GNU getopt, unlike System +V getopt and other getopt implementations, doesn't consider a +non-option to be the end of the option list. A quick (and compatible) +fix for scripts is to add "--" to the interpreter, like this: +

+

+        #! /usr/local/bin/python --
+
+You can also use this interactively: +

+

+        python -- script.py [options]
+
+Note that a working getopt implementation is provided in the Python +distribution (in Python/getopt.c) but not automatically used. +

+ +Edit this entry / +Log info +

+ +


+

3.5. When building on the SGI, make tries to run python to create glmodule.c, but python hasn't been built or installed yet.

+Comment out the line mentioning glmodule.c in Setup and build a +python without gl first; install it or make sure it is in your $PATH, +then edit the Setup file again to turn on the gl module, and make +again. You don't need to do "make clean"; you do need to run "make +Makefile" in the Modules subdirectory (or just run "make" at the +toplevel). +

+ +Edit this entry / +Log info +

+ +


+

3.6. I use VPATH but some targets are built in the source directory.

+On some systems (e.g. Sun), if the target already exists in the +source directory, it is created there instead of in the build +directory. This is usually because you have previously built without +VPATH. Try running "make clobber" in the source directory. +

+ +Edit this entry / +Log info +

+ +


+

3.7. Trouble building or linking with the GNU readline library.

+You can use the GNU readline library to improve the interactive user +interface: this gives you line editing and command history when +calling python interactively. Its sources are distributed with +Python (at least for 2.0). Uncomment the line +

+#readline readline.c -lreadline -ltermcap +

+in Modules/Setup. The configuration option --with-readline +is no longer supported, at least in Python 2.0. Some hints on +building and using the readline library: +On SGI IRIX 5, you may have to add the following +to rldefs.h: +

+

+        #ifndef sigmask
+        #define sigmask(sig) (1L << ((sig)-1))
+        #endif
+
+On some systems, you will have to add #include "rldefs.h" to the +top of several source files, and if you use the VPATH feature, you +will have to add dependencies of the form foo.o: foo.c to the +Makefile for several values of foo. +The readline library requires use of the termcap library. A +known problem with this is that it contains entry points which +cause conflicts with the STDWIN and SGI GL libraries. The STDWIN +conflict can be solved by adding a line saying '#define werase w_erase' to the +stdwin.h file (in the STDWIN distribution, subdirectory H). The +GL conflict has been solved in the Python configure script by a +hack that forces use of the static version of the termcap library. +Check the newsgroup gnu.bash.bug news:gnu.bash.bug for +specific problems with the readline library (I don't read this group +but I've been told that it is the place for readline bugs). +

+ +Edit this entry / +Log info + +/ Last changed on Sat Dec 2 18:23:48 2000 by +Issac Trotts +

+ +


+

3.8. Trouble with socket I/O on older Linux 1.x versions.

+Once you've built Python, use it to run the regen script in the +Lib/plat-linux2 directory. Apparently the files as distributed don't match the system headers on some Linux versions. +

+Note that this FAQ entry only applies to Linux kernel versions 1.x.y; +these are hardly around any more. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jul 30 20:05:52 2002 by +Jens Kubieziel +

+ +


+

3.9. Trouble with prototypes on Ultrix.

+Ultrix cc seems broken -- use gcc, or edit config.h to #undef +HAVE_PROTOTYPES. +

+ +Edit this entry / +Log info +

+ +


+

3.10. Other trouble building Python on platform X.

+Please submit the details to the SourceForge bug tracker: +

+

+  http://sourceforge.net/tracker/?group_id=5470&atid=105470
+
+and we'll look +into it. Please provide as many details as possible. In particular, +if you don't tell us what type of computer and what operating system +(and version) you are using it will be difficult for us to figure out +what is the matter. If you have compilation output logs, +please use file uploads -- don't paste everything in the message box. +

+In many cases, we won't have access to the same hardware or operating system version, so please, if you have a SourceForge account, log in before filing your report, or if you don't have an account, include an email address at which we can reach you for further questions. Logging in to SourceForge first will also cause SourceForge to send you updates as we act on your report. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Apr 27 10:53:18 2001 by +Fred Drake +

+ +


+

3.11. How to configure dynamic loading on Linux.

+This is now automatic as long as your Linux version uses the ELF +object format (all recent Linuxes do). +

+ +Edit this entry / +Log info +

+ +


+

3.12. I can't get shared modules to work on Linux 2.0 (Slackware96)?

+This is a bug in the Slackware96 release. The fix is simple: Make sure +that there is a link from /lib/libdl.so to /lib/libdl.so.1 so that the +following links are setup: /lib/libdl.so -> /lib/libdl.so.1 +/lib/libdl.so.1 -> /lib/libdl.so.1.7.14 You may have to rerun the +configure script, after rm'ing the config.cache file, before you +attempt to rebuild python after this fix. +

+ +Edit this entry / +Log info + +/ Last changed on Wed May 21 15:45:03 1997 by +GvR +

+ +


+

3.13. Trouble when making modules shared on Linux.

+This happens when you have built Python for static linking and then +enable +
+  *shared*
+
+in the Setup file. Shared library code must be +compiled with "-fpic". If a .o file for the module already exist that +was compiled for static linking, you must remove it or do "make clean" +in the Modules directory. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 23 13:42:30 1997 by +GvR +

+ +


+

3.14. [deleted]

+[ancient information on threads on linux (when thread support +was not standard) used to be here] +

+ +Edit this entry / +Log info + +/ Last changed on Sun Jun 2 17:27:13 2002 by +Erno Kuusela +

+ +


+

3.15. Errors when linking with a shared library containing C++ code.

+Link the main Python binary with C++. Change the definition of +LINKCC in Modules/Makefile to be your C++ compiler. You may have to +edit config.c slightly to make it compilable with C++. +

+ +Edit this entry / +Log info +

+ +


+

3.16. Deleted

+

+

+ +Edit this entry / +Log info + +/ Last changed on Tue Sep 11 16:02:22 2001 by +GvR +

+ +


+

3.17. Deleted.

+

+

+ +Edit this entry / +Log info + +/ Last changed on Tue Sep 11 15:54:57 2001 by +GvR +

+ +


+

3.18. Compilation or link errors for the _tkinter module

+Most likely, there's a version mismatch between the Tcl/Tk header +files (tcl.h and tk.h) and the Tcl/Tk libraries you are using e.g. +"-ltk8.0" and "-ltcl8.0" arguments for _tkinter in the Setup file). +It is possible to install several versions of the Tcl/Tk libraries, +but there can only be one version of the tcl.h and tk.h header +files. If the library doesn't match the header, you'll get +problems, either when linking the module, or when importing it. +Fortunately, the version number is clearly stated in each file, +so this is easy to find. Reinstalling and using the latest +version usually fixes the problem. +

+(Also note that when compiling unpatched Python 1.5.1 against +Tcl/Tk 7.6/4.2 or older, you get an error on Tcl_Finalize. See +the 1.5.1 patch page at http://www.python.org/1.5/patches-1.5.1/.) +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jun 11 00:49:14 1998 by +Gvr +

+ +


+

3.19. I configured and built Python for Tcl/Tk but "import Tkinter" fails.

+Most likely, you forgot to enable the line in Setup that says +"TKPATH=:$(DESTLIB)/tkinter". +

+ +Edit this entry / +Log info +

+ +


+

3.20. [deleted]

+[ancient information on a gcc+tkinter bug on alpha was here] +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 16:46:23 2002 by +Erno Kuusela +

+ +


+

3.21. Several common system calls are missing from the posix module.

+Most likely, all test compilations run by the configure script +are failing for some reason or another. Have a look in config.log to +see what could be the reason. A common reason is specifying a +directory to the --with-readline option that doesn't contain the +libreadline.a file. +

+ +Edit this entry / +Log info +

+ +


+

3.22. ImportError: No module named string, on MS Windows.

+Most likely, your PYTHONPATH environment variable should be set to +something like: +

+set PYTHONPATH=c:\python;c:\python\lib;c:\python\scripts +

+(assuming Python was installed in c:\python) +

+ +Edit this entry / +Log info +

+ +


+

3.23. Core dump on SGI when using the gl module.

+There are conflicts between entry points in the termcap and curses +libraries and an entry point in the GL library. There's a hack of a +fix for the termcap library if it's needed for the GNU readline +library, but it doesn't work when you're using curses. Concluding, +you can't build a Python binary containing both the curses and gl +modules. +

+ +Edit this entry / +Log info +

+ +


+

3.24. "Initializer not a constant" while building DLL on MS-Windows

+Static type object initializers in extension modules may cause compiles to +fail with an error message like "initializer not a constant". +Fredrik Lundh <Fredrik.Lundh@image.combitech.se> explains: +

+This shows up when building DLL under MSVC. There's two ways to +address this: either compile the module as C++, or change your code to +something like: +

+

+  statichere PyTypeObject bstreamtype = {
+      PyObject_HEAD_INIT(NULL) /* must be set by init function */
+      0,
+      "bstream",
+      sizeof(bstreamobject),
+
+
+  ...
+
+
+  void
+  initbstream()
+  {
+      /* Patch object type */
+      bstreamtype.ob_type = &PyType_Type;
+      Py_InitModule("bstream", functions);
+      ...
+  }
+
+

+ +Edit this entry / +Log info + +/ Last changed on Sun May 25 14:58:05 1997 by +Aaron Watters +

+ +


+

3.25. Output directed to a pipe or file disappears on Linux.

+Some people have reported that when they run their script +interactively, it runs great, but that when they redirect it +to a pipe or file, no output appears. +

+

+    % python script.py
+    ...some output...
+    % python script.py >file
+    % cat file
+    % # no output
+    % python script.py | cat
+    % # no output
+    %
+
+This was a bug in Linux kernel. It is fixed and should not appear anymore. So most Linux users are not affected by this. +

+If redirection doesn't work on your Linux system, check what shell you are using. Shells like (t)csh doesn't support redirection. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jan 16 13:38:30 2003 by +Jens Kubieziel +

+ +


+

3.26. [deleted]

+[ancient libc/linux problem was here] +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 16:48:08 2002 by +Erno Kuusela +

+ +


+

3.27. [deleted]

+[ancient linux + threads + tk problem was described here] +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 16:49:08 2002 by +Erno Kuusela +

+ +


+

3.28. How can I test if Tkinter is working?

+Try the following: +

+

+  python
+  >>> import _tkinter
+  >>> import Tkinter
+  >>> Tkinter._test()
+
+This should pop up a window with two buttons, +one "Click me" and one "Quit". +

+If the first statement (import _tkinter) fails, your Python +installation probably has not been configured to support Tcl/Tk. +On Unix, if you have installed Tcl/Tk, you have to rebuild Python +after editing the Modules/Setup file to enable the _tkinter module +and the TKPATH environment variable. +

+It is also possible to get complaints about Tcl/Tk version +number mismatches or missing TCL_LIBRARY or TK_LIBRARY +environment variables. These have to do with Tcl/Tk installation +problems. +

+A common problem is to have installed versions of tcl.h and tk.h +that don't match the installed version of the Tcl/Tk libraries; +this usually results in linker errors or (when using dynamic +loading) complaints about missing symbols during loading +the shared library. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Aug 28 17:01:46 1997 by +Guido van Rossum +

+ +


+

3.29. Is there a way to get the interactive mode of the python interpreter to perform function/variable name completion?

+(From a posting by Guido van Rossum) +

+On Unix, if you have enabled the readline module (i.e. if Emacs-style +command line editing and bash-style history works for you), you can +add this by importing the undocumented standard library module +"rlcompleter". When completing a simple identifier, it +completes keywords, built-ins and globals in __main__; when completing +NAME.NAME..., it evaluates (!) the expression up to the last dot and +completes its attributes. +

+This way, you can do "import string", type "string.", hit the +completion key twice, and see the list of names defined by the +string module. +

+Tip: to use the tab key as the completion key, call +

+

+    readline.parse_and_bind("tab: complete")
+
+You can put this in a ~/.pythonrc file, and set the PYTHONSTARTUP +environment variable to ~/.pythonrc. This will cause the completion to be enabled +whenever you run Python interactively. +

+Notes (see the docstring for rlcompleter.py for more information): +

+* The evaluation of the NAME.NAME... form may cause arbitrary +application defined code to be executed if an object with a +__getattr__ hook is found. Since it is the responsibility of the +application (or the user) to enable this feature, I consider this an +acceptable risk. More complicated expressions (e.g. function calls or +indexing operations) are not evaluated. +

+* GNU readline is also used by the built-in functions input() and +raw_input(), and thus these also benefit/suffer from the complete +features. Clearly an interactive application can benefit by +specifying its own completer function and using raw_input() for all +its input. +

+* When stdin is not a tty device, GNU readline is never +used, and this module (and the readline module) are silently inactive. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Jun 12 09:55:24 1998 by +A.M. Kuchling +

+ +


+

3.30. Why is the Python interpreter not built as a shared library?

+(This is a Unix question; on Mac and Windows, it is a shared +library.) +

+It's just a nightmare to get this to work on all different platforms. +Shared library portability is a pain. And yes, I know about GNU libtool +-- but it requires me to use its conventions for filenames etc, and it +would require a complete and utter rewrite of all the makefile and +config tools I'm currently using. +

+In practice, few applications embed Python -- it's much more common to +have Python extensions, which already are shared libraries. Also, +serious embedders often want total control over which Python version +and configuration they use so they wouldn't want to use a standard +shared library anyway. So while the motivation of saving space +when lots of apps embed Python is nice in theory, I +doubt that it will save much in practice. (Hence the low priority I +give to making a shared library.) +

+For Linux systems, the simplest method of producing libpython1.5.so seems to +be (originally from the Minotaur project web page, +http://www.equi4.com/minotaur/minotaur.html): +

+

+  make distclean 
+  ./configure 
+  make OPT="-fpic -O2" 
+  mkdir .extract 
+  (cd .extract; ar xv ../libpython1.5.a) 
+  gcc -shared -o libpython1.5.so .extract/*.o 
+  rm -rf .extract
+
+In Python 2.3 this will be supported by the standard build routine +(at least on Linux) with --enable-shared. Note however that there +is little advantage, and it slows down Python because of the need +for PIC code and the extra cost at startup time to find the library. +

+ +Edit this entry / +Log info + +/ Last changed on Thu May 30 13:36:55 2002 by +GvR +

+ +


+

3.31. Build with GCC on Solaris 2.6 (SunOS 5.6) fails

+If you have upgraded Solaris 2.5 or 2.5.1 to Solaris 2.6, +but you have not upgraded +your GCC installation, the compile may fail, e.g. like this: +

+

+ In file included from /usr/include/sys/stream.h:26,
+                  from /usr/include/netinet/in.h:38,
+                  from /usr/include/netdb.h:96,
+                  from ./socketmodule.c:121:
+ /usr/include/sys/model.h:32: #error "No DATAMODEL_NATIVE specified"
+
+Solution: rebuild GCC for Solaris 2.6. +You might be able to simply re-run fixincludes, but +people have had mixed success with doing that. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Oct 21 11:18:46 1998 by +GvR +

+ +


+

3.32. Running "make clean" seems to leave problematic files that cause subsequent builds to fail.

+Use "make clobber" instead. +

+Use "make clean" to reduce the size of the source/build directory +after you're happy with your build and installation. +If you have already tried to build python and you'd like to start +over, you should use "make clobber". It does a "make clean" and also +removes files such as the partially built Python library from a previous build. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jun 24 20:39:26 1999 by +TAB +

+ +


+

3.33. Submitting bug reports and patches

+To report a bug or submit a patch, please use the relevant service +from the Python project at SourceForge. +

+Bugs: http://sourceforge.net/tracker/?group_id=5470&atid=105470 +

+Patches: http://sourceforge.net/tracker/?group_id=5470&atid=305470 +

+If you have a SourceForge account, please log in before submitting your bug report; this will make it easier for us to contact you regarding your report in the event we have follow-up questions. It will also enable SourceForge to send you update information as we act on your bug. If you do not have a SourceForge account, please consider leaving your name and email address as part of the report. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Apr 27 10:58:26 2001 by +Fred Drake +

+ +


+

3.34. I can't load shared libraries under Python 1.5.2, Solaris 7, and gcc 2.95.2

+When trying to load shared libraries, you may see errors like: +ImportError: ld.so.1: python: fatal: relocation error: file /usr/local/lib/python1.5/site-packages/Perp/util/du_SweepUtilc.so: +
+ symbol PyExc_RuntimeError: referenced symbol not found
+
+

+There is a problem with the configure script for Python 1.5.2 +under Solaris 7 with gcc 2.95 . configure should set the make variable +LINKFORSHARED=-Xlinker -export-dynamic +

+

+in Modules/Makefile, +

+Manually add this line to the Modules/Makefile. +This builds a Python executable that can load shared library extensions (xxx.so) . +

+ +Edit this entry / +Log info + +/ Last changed on Mon Feb 19 10:37:05 2001 by +GvR +

+ +


+

3.35. In the regression test, test___all__ fails for the profile module. What's wrong?

+If you have been using the profile module, and have properly calibrated a copy of the module as described in the documentation for the profiler: +

+http://www.python.org/doc/current/lib/profile-calibration.html +

+then it is possible that the regression test "test___all__" will fail if you run the regression test manually rather than using "make test" in the Python source directory. This will happen if you have set your PYTHONPATH environment variable to include the directory containing your calibrated profile module. You have probably calibrated the profiler using an older version of the profile module which does not define the __all__ value, added to the module as of Python 2.1. +

+The problem can be fixed by removing the old calibrated version of the profile module and using the latest version to do a fresh calibration. In general, you will need to re-calibrate for each version of Python anyway, since the performance characteristics can change in subtle ways that impact profiling. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Apr 27 10:44:10 2001 by +Fred Drake +

+ +


+

3.36. relocations remain against allocatable but non-writable sections

+This linker error occurs on Solaris if you attempt to build an extension module which incorporates position-dependent (non-PIC) code. A common source of problems is that a static library (.a file), such as libreadline.a or libcrypto.a is linked with the extension module. The error specifically occurs when using gcc as the compiler, but /usr/ccs/bin/ld as the linker. +

+The following solutions and work-arounds are known: +

+1. Rebuild the libraries (libreadline, libcrypto) with -fPIC (-KPIC if using the system compiler). This is recommended; all object files in a shared library should be position-independent. +

+2. Statically link the extension module and its libraries into the Python interpreter, by editing Modules/Setup. +

+3. Use GNU ld instead of /usr/ccs/bin/ld; GNU ld will accept non-PIC code in shared libraries (and mark the section writable) +

+4. Pass -mimpure-text to GCC when linking the module. This will force gcc to not pass -z text to ld; in turn, ld will make all text sections writable. +

+Options 3 and 4 are not recommended, since the ability to share code across processes is lost. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 29 12:05:11 2002 by +Martin v. Löwis +

+ +


+

4. Programming in Python

+ +
+

4.1. Is there a source code level debugger with breakpoints, step, etc.?

+Yes. +

+Module pdb is a rudimentary but adequate console-mode debugger for Python. It is part of the standard Python library, and is documented in the Library Reference Manual. (You can also write your own debugger by using the code for pdb as an example.) +

+The IDLE interactive development environment, which is part of the standard Python distribution (normally available in Tools/idle), includes a graphical debugger. There is documentation for the IDLE debugger at http://www.python.org/idle/doc/idle2.html#Debugger +

+Pythonwin is a Python IDE that includes a GUI debugger based on bdb. The Pythonwin debugger colors breakpoints and has quite a few cool features (including debugging non-Pythonwin programs). A reference can be found at http://www.python.org/ftp/python/pythonwin/pwindex.html +More recent versions of PythonWin are available as a part of the ActivePython distribution (see http://www.activestate.com/Products/ActivePython/index.html). +

+Pydb is a version of the standard Python debugger pdb, modified for use with DDD (Data Display Debugger), a popular graphical debugger front end. Pydb can be found at http://packages.debian.org/unstable/devel/pydb.html +and DDD can be found at http://www.gnu.org/software/ddd/ +

+There are a number of commmercial Python IDEs that include graphical debuggers. They include: +

+

+ * Wing IDE (http://wingide.com/) 
+ * Komodo IDE (http://www.activestate.com/Products/Komodo/)
+
+

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 28 01:43:41 2003 by +Stephen Ferg +

+ +


+

4.2. Can I create an object class with some methods implemented in C and others in Python (e.g. through inheritance)? (Also phrased as: Can I use a built-in type as base class?)

+In Python 2.2, you can inherit from builtin classes such as int, list, dict, etc. +

+In previous versions of Python, you can easily create a Python class which serves as a wrapper around a built-in object, e.g. (for dictionaries): +

+

+        # A user-defined class behaving almost identical
+        # to a built-in dictionary.
+        class UserDict:
+                def __init__(self): self.data = {}
+                def __repr__(self): return repr(self.data)
+                def __cmp__(self, dict):
+                        if type(dict) == type(self.data):
+                                return cmp(self.data, dict)
+                        else:
+                                return cmp(self.data, dict.data)
+                def __len__(self): return len(self.data)
+                def __getitem__(self, key): return self.data[key]
+                def __setitem__(self, key, item): self.data[key] = item
+                def __delitem__(self, key): del self.data[key]
+                def keys(self): return self.data.keys()
+                def items(self): return self.data.items()
+                def values(self): return self.data.values()
+                def has_key(self, key): return self.data.has_key(key)
+
+A2. See Jim Fulton's ExtensionClass for an example of a mechanism +which allows you to have superclasses which you can inherit from in +Python -- that way you can have some methods from a C superclass (call +it a mixin) and some methods from either a Python superclass or your +subclass. ExtensionClass is distributed as a part of Zope (see +http://www.zope.org), but will be phased out with Zope 3, since +Zope 3 uses Python 2.2 or later which supports direct inheritance +from built-in types. Here's a link to the original paper about +ExtensionClass: +http://debian.acm.ndsu.nodak.edu/doc/python-extclass/ExtensionClass.html +

+A3. The Boost Python Library (BPL, http://www.boost.org/libs/python/doc/index.html) +provides a way of doing this from C++ (i.e. you can inherit from an +extension class written in C++ using the BPL). +

+ +Edit this entry / +Log info + +/ Last changed on Tue May 28 21:09:52 2002 by +GvR +

+ +


+

4.3. Is there a curses/termcap package for Python?

+The standard Python source distribution comes with a curses module in +the Modules/ subdirectory, though it's not compiled by default (note +that this is not available in the Windows distribution -- there is +no curses module for Windows). +

+In Python versions before 2.0 the module only supported plain curses; +you couldn't use ncurses features like colors with it (though it would +link with ncurses). +

+In Python 2.0, the curses module has been greatly extended, starting +from Oliver Andrich's enhanced version, to provide many additional +functions from ncurses and SYSV curses, such as colour, alternative +character set support, pads, and mouse support. This means the +module is no longer compatible with operating systems that only +have BSD curses, but there don't seem to be any currently +maintained OSes that fall into this category. +

+ +Edit this entry / +Log info + +/ Last changed on Sun Jun 23 20:24:06 2002 by +Tim Peters +

+ +


+

4.4. Is there an equivalent to C's onexit() in Python?

+For Python 2.0: The new atexit module provides a register function that +is similar to C's onexit. See the Library Reference for details. For +2.0 you should not assign to sys.exitfunc! +

+For Python 1.5.2: You need to import sys and assign a function to +sys.exitfunc, it will be called when your program exits, is +killed by an unhandled exception, or (on UNIX) receives a +SIGHUP or SIGTERM signal. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Dec 28 12:14:55 2000 by +Bjorn Pettersen +

+ +


+

4.5. [deleted]

+[python used to lack nested scopes, it was explained here] +

+ +Edit this entry / +Log info + +/ Last changed on Thu Mar 21 05:18:22 2002 by +Erno Kuusela +

+ +


+

4.6. How do I iterate over a sequence in reverse order?

+If it is a list, the fastest solution is +

+

+        list.reverse()
+        try:
+                for x in list:
+                        "do something with x"
+        finally:
+                list.reverse()
+
+This has the disadvantage that while you are in the loop, the list +is temporarily reversed. If you don't like this, you can make a copy. +This appears expensive but is actually faster than other solutions: +

+

+        rev = list[:]
+        rev.reverse()
+        for x in rev:
+                <do something with x>
+
+If it's not a list, a more general but slower solution is: +

+

+        for i in range(len(sequence)-1, -1, -1):
+                x = sequence[i]
+                <do something with x>
+
+A more elegant solution, is to define a class which acts as a sequence +and yields the elements in reverse order (solution due to Steve +Majewski): +

+

+        class Rev:
+                def __init__(self, seq):
+                        self.forw = seq
+                def __len__(self):
+                        return len(self.forw)
+                def __getitem__(self, i):
+                        return self.forw[-(i + 1)]
+
+You can now simply write: +

+

+        for x in Rev(list):
+                <do something with x>
+
+Unfortunately, this solution is slowest of all, due to the method +call overhead... +

+ +Edit this entry / +Log info + +/ Last changed on Sun May 25 21:10:50 1997 by +GvR +

+ +


+

4.7. My program is too slow. How do I speed it up?

+That's a tough one, in general. There are many tricks to speed up +Python code; I would consider rewriting parts in C only as a last +resort. One thing to notice is that function and (especially) method +calls are rather expensive; if you have designed a purely OO interface +with lots of tiny functions that don't do much more than get or set an +instance variable or call another method, you may consider using a +more direct way, e.g. directly accessing instance variables. Also see +the standard module "profile" (described in the Library Reference +manual) which makes it possible to find out where +your program is spending most of its time (if you have some patience +-- the profiling itself can slow your program down by an order of +magnitude). +

+Remember that many standard optimization heuristics you +may know from other programming experience may well apply +to Python. For example it may be faster to send output to output +devices using larger writes rather than smaller ones in order to +avoid the overhead of kernel system calls. Thus CGI scripts +that write all output in "one shot" may be notably faster than +those that write lots of small pieces of output. +

+Also, be sure to use "aggregate" operations where appropriate. +For example the "slicing" feature allows programs to chop up +lists and other sequence objects in a single tick of the interpreter +mainloop using highly optimized C implementations. Thus to +get the same effect as +

+

+  L2 = []
+  for i in range[3]:
+       L2.append(L1[i])
+
+it is much shorter and far faster to use +

+

+  L2 = list(L1[:3]) # "list" is redundant if L1 is a list.
+
+Note that the map() function, particularly used with +builtin methods or builtin functions can be a convenient +accelerator. For example to pair the elements of two +lists together: +

+

+  >>> map(None, [1,2,3], [4,5,6])
+  [(1, 4), (2, 5), (3, 6)]
+
+or to compute a number of sines: +

+

+  >>> map( math.sin, (1,2,3,4))
+  [0.841470984808, 0.909297426826, 0.14112000806,   -0.756802495308]
+
+The map operation completes very quickly in such cases. +

+Other examples of aggregate operations include the join and split +methods of string objects. For example if s1..s7 are large (10K+) strings then +"".join([s1,s2,s3,s4,s5,s6,s7]) may be far faster than +the more obvious s1+s2+s3+s4+s5+s6+s7, since the "summation" +will compute many subexpressions, whereas join does all +copying in one pass. For manipulating strings also consider the +regular expression libraries and the "substitution" operations +String % tuple and String % dictionary. Also be sure to use +the list.sort builtin method to do sorting, and see FAQ's 4.51 +and 4.59 for examples of moderately advanced usage -- list.sort beats +other techniques for sorting in all but the most extreme +circumstances. +

+There are many other aggregate operations +available in the standard libraries and in contributed libraries +and extensions. +

+Another common trick is to "push loops into functions or methods." +For example suppose you have a program that runs slowly and you +use the profiler (profile.run) to determine that a Python function ff +is being called lots of times. If you notice that ff +

+

+   def ff(x):
+       ...do something with x computing result...
+       return result
+
+tends to be called in loops like (A) +

+

+   list = map(ff, oldlist)
+
+or (B) +

+

+   for x in sequence:
+       value = ff(x)
+       ...do something with value...
+
+then you can often eliminate function call overhead by rewriting +ff to +

+

+   def ffseq(seq):
+       resultseq = []
+       for x in seq:
+           ...do something with x computing result...
+           resultseq.append(result)
+       return resultseq
+
+and rewrite (A) to +

+

+    list = ffseq(oldlist)
+
+and (B) to +

+

+    for value in ffseq(sequence):
+        ...do something with value...
+
+Other single calls ff(x) translate to ffseq([x])[0] with little +penalty. Of course this technique is not always appropriate +and there are other variants, which you can figure out. +

+You can gain some performance by explicitly storing the results of +a function or method lookup into a local variable. A loop like +

+

+    for key in token:
+        dict[key] = dict.get(key, 0) + 1
+
+resolves dict.get every iteration. If the method isn't going to +change, a faster implementation is +

+

+    dict_get = dict.get  # look up the method once
+    for key in token:
+        dict[key] = dict_get(key, 0) + 1
+
+Default arguments can be used to determine values once, at +compile time instead of at run time. This can only be done for +functions or objects which will not be changed during program +execution, such as replacing +

+

+    def degree_sin(deg):
+        return math.sin(deg * math.pi / 180.0)
+
+with +

+

+    def degree_sin(deg, factor = math.pi/180.0, sin = math.sin):
+        return sin(deg * factor)
+
+Because this trick uses default arguments for terms which should +not be changed, it should only be used when you are not concerned +with presenting a possibly confusing API to your users. +

+

+For an anecdote related to optimization, see +

+

+	http://www.python.org/doc/essays/list2str.html
+
+

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 01:03:54 2002 by +Neal Norwitz +

+ +


+

4.8. When I have imported a module, then edit it, and import it again (into the same Python process), the changes don't seem to take place. What is going on?

+For reasons of efficiency as well as consistency, Python only reads +the module file on the first time a module is imported. (Otherwise a +program consisting of many modules, each of which imports the same +basic module, would read the basic module over and over again.) To +force rereading of a changed module, do this: +

+

+        import modname
+        reload(modname)
+
+Warning: this technique is not 100% fool-proof. In particular, +modules containing statements like +

+

+        from modname import some_objects
+
+will continue to work with the old version of the imported objects. +

+ +Edit this entry / +Log info +

+ +


+

4.9. How do I find the current module name?

+A module can find out its own module name by looking at the +(predefined) global variable __name__. If this has the value +'__main__' you are running as a script. +

+ +Edit this entry / +Log info +

+ +


+

4.10. I have a module in which I want to execute some extra code when it is run as a script. How do I find out whether I am running as a script?

+See the previous question. E.g. if you put the following on the +last line of your module, main() is called only when your module is +running as a script: +

+

+        if __name__ == '__main__': main()
+
+

+ +Edit this entry / +Log info +

+ +


+

4.11. I try to run a program from the Demo directory but it fails with ImportError: No module named ...; what gives?

+This is probably an optional module (written in C!) which hasn't +been configured on your system. This especially happens with modules +like "Tkinter", "stdwin", "gl", "Xt" or "Xm". For Tkinter, STDWIN and +many other modules, see Modules/Setup.in for info on how to add these +modules to your Python, if it is possible at all. Sometimes you will +have to ftp and build another package first (e.g. Tcl and Tk for Tkinter). +Sometimes the module only works on specific platforms (e.g. gl only works +on SGI machines). +

+NOTE: if the complaint is about "Tkinter" (upper case T) and you have +already configured module "tkinter" (lower case t), the solution is +not to rename tkinter to Tkinter or vice versa. There is probably +something wrong with your module search path. Check out the value of +sys.path. +

+For X-related modules (Xt and Xm) you will have to do more work: they +are currently not part of the standard Python distribution. You will +have to ftp the Extensions tar file, i.e. +ftp://ftp.python.org/pub/python/src/X-extension.tar.gz and follow +the instructions there. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Feb 12 21:31:08 2003 by +Jens Kubieziel +

+ +


+

4.12. [deleted]

+[stdwin (long dead windowing library) entry deleted] +

+ +Edit this entry / +Log info + +/ Last changed on Thu Mar 21 08:30:13 2002 by +Erno Kuusela +

+ +


+

4.13. What GUI toolkits exist for Python?

+Depending on what platform(s) you are aiming at, there are several. +

+Currently supported solutions: +

+Cross-platform: +

+Tk: +

+There's a neat object-oriented interface to the Tcl/Tk widget set, +called Tkinter. It is part of the standard Python distribution and +well-supported -- all you need to do is build and install Tcl/Tk and +enable the _tkinter module and the TKPATH definition in Modules/Setup +when building Python. This is probably the easiest to install and +use, and the most complete widget set. It is also very likely that in +the future the standard Python GUI API will be based on or at least +look very much like the Tkinter interface. For more info about Tk, +including pointers to the source, see the Tcl/Tk home page at +http://www.scriptics.com. Tcl/Tk is now fully +portable to the Mac and Windows platforms (NT and 95 only); you need +Python 1.4beta3 or later and Tk 4.1patch1 or later. +

+wxWindows: +

+There's an interface to wxWindows called wxPython. wxWindows is a +portable GUI class library written in C++. It supports GTK, Motif, +MS-Windows and Mac as targets. Ports to other platforms are being +contemplated or have already had some work done on them. wxWindows +preserves the look and feel of the underlying graphics toolkit, and +there is quite a rich widget set and collection of GDI classes. +See the wxWindows page at http://www.wxwindows.org/ for more details. +wxPython is a python extension module that wraps many of the wxWindows +C++ classes, and is quickly gaining popularity amongst Python +developers. You can get wxPython as part of the source or CVS +distribution of wxWindows, or directly from its home page at +http://alldunn.com/wxPython/. +

+Gtk+: +

+PyGtk bindings for the Gtk+ Toolkit by James Henstridge exist; see ftp://ftp.daa.com.au/pub/james/python/. Note that there are two incompatible bindings. If you are using Gtk+ 1.2.x you should get the 0.6.x PyGtk bindings from +

+

+    ftp://ftp.gtk.org/pub/python/v1.2
+
+If you plan to use Gtk+ 2.0 with Python (highly recommended if you are just starting with Gtk), get the most recent distribution from +

+

+    ftp://ftp.gtk.org/pub/python/v2.0
+
+If you are adventurous, you can also check out the source from the Gnome CVS repository. Set your CVS directory to :pserver:anonymous@anoncvs.gnome.org:/cvs/gnome and check the gnome-python module out from the repository. +

+Other: +

+There are also bindings available for the Qt toolkit (PyQt), and for KDE (PyKDE); see http://www.thekompany.com/projects/pykde/. +

+For OpenGL bindings, see http://starship.python.net/~da/PyOpenGL. +

+Platform specific: +

+The Mac port has a rich and ever-growing set of modules that support +the native Mac toolbox calls. See the documentation that comes with +the Mac port. See ftp://ftp.python.org/pub/python/mac. Support +by Jack Jansen jack@cwi.nl. +

+Pythonwin by Mark Hammond (MHammond@skippinet.com.au) +includes an interface to the Microsoft Foundation +Classes and a Python programming environment using it that's written +mostly in Python. See http://www.python.org/windows/. +

+There's an object-oriented GUI based on the Microsoft Foundation +Classes model called WPY, supported by Jim Ahlstrom jim@interet.com. +Programs written in WPY run unchanged and with native look and feel on +Windows NT/95, Windows 3.1 (using win32s), and on Unix (using Tk). +Source and binaries for Windows and Linux are available in +ftp://ftp.python.org/pub/python/wpy/. +

+Obsolete or minority solutions: +

+There's an interface to X11, including the Athena and Motif widget +sets (and a few individual widgets, like Mosaic's HTML widget and +SGI's GL widget) available from +ftp://ftp.python.org/pub/python/src/X-extension.tar.gz. +Support by Sjoerd Mullender sjoerd@cwi.nl. +

+On top of the X11 interface there's the vpApp +toolkit by Per Spilling, now also maintained by Sjoerd Mullender +sjoerd@cwi.nl. See ftp://ftp.cwi.nl/pub/sjoerd/vpApp.tar.gz. +

+For SGI IRIX only, there are unsupported interfaces to the complete +GL (Graphics Library -- low level but very good 3D capabilities) as +well as to FORMS (a buttons-and-sliders-etc package built on top of GL +by Mark Overmars -- ftp'able from +ftp://ftp.cs.ruu.nl/pub/SGI/FORMS/). This is probably also +becoming obsolete, as OpenGL takes over (see above). +

+There's an interface to STDWIN, a platform-independent low-level +windowing interface for Mac and X11. This is totally unsupported and +rapidly becoming obsolete. The STDWIN sources are at +ftp://ftp.cwi.nl/pub/stdwin/. +

+There is an interface to WAFE, a Tcl interface to the X11 +Motif and Athena widget sets. WAFE is at +http://www.wu-wien.ac.at/wafe/wafe.html. +

+ +Edit this entry / +Log info + +/ Last changed on Mon May 13 21:40:39 2002 by +Skip Montanaro +

+ +


+

4.14. Are there any interfaces to database packages in Python?

+Yes! See the Database Topic Guide at +http://www.python.org/topics/database/ for details. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 4 20:12:19 2000 by +Barney Warplug +

+ +


+

4.15. Is it possible to write obfuscated one-liners in Python?

+Yes. See the following three examples, due to Ulf Bartelt: +

+

+        # Primes < 1000
+        print filter(None,map(lambda y:y*reduce(lambda x,y:x*y!=0,
+        map(lambda x,y=y:y%x,range(2,int(pow(y,0.5)+1))),1),range(2,1000)))
+
+
+        # First 10 Fibonacci numbers
+        print map(lambda x,f=lambda x,f:(x<=1) or (f(x-1,f)+f(x-2,f)): f(x,f),
+        range(10))
+
+
+        # Mandelbrot set
+        print (lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+y,map(lambda y,
+        Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,Sy=Sy,L=lambda yc,Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,i=IM,
+        Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro,
+        i=i,Sx=Sx,F=lambda xc,yc,x,y,k,f=lambda xc,yc,x,y,k,f:(k<=0)or (x*x+y*y
+        >=4.0) or 1+f(xc,yc,x*x-y*y+xc,2.0*x*y+yc,k-1,f):f(xc,yc,x,y,k,f):chr(
+        64+F(Ru+x*(Ro-Ru)/Sx,yc,0,0,i)),range(Sx))):L(Iu+y*(Io-Iu)/Sy),range(Sy
+        ))))(-2.1, 0.7, -1.2, 1.2, 30, 80, 24)
+        #    \___ ___/  \___ ___/  |   |   |__ lines on screen
+        #        V          V      |   |______ columns on screen
+        #        |          |      |__________ maximum of "iterations"
+        #        |          |_________________ range on y axis
+        #        |____________________________ range on x axis
+
+Don't try this at home, kids! +

+ +Edit this entry / +Log info + +/ Last changed on Wed May 21 15:48:33 1997 by +GvR +

+ +


+

4.16. Is there an equivalent of C's "?:" ternary operator?

+Not directly. In many cases you can mimic a?b:c with "a and b or +c", but there's a flaw: if b is zero (or empty, or None -- anything +that tests false) then c will be selected instead. In many cases you +can prove by looking at the code that this can't happen (e.g. because +b is a constant or has a type that can never be false), but in general +this can be a problem. +

+Tim Peters (who wishes it was Steve Majewski) suggested the following +solution: (a and [b] or [c])[0]. Because [b] is a singleton list it +is never false, so the wrong path is never taken; then applying [0] to +the whole thing gets the b or c that you really wanted. Ugly, but it +gets you there in the rare cases where it is really inconvenient to +rewrite your code using 'if'. +

+As a last resort it is possible to implement the "?:" operator as a function: +

+

+    def q(cond,on_true,on_false):
+        from inspect import isfunction
+
+
+        if cond:
+            if not isfunction(on_true): return on_true
+            else: return apply(on_true)
+        else:
+            if not isfunction(on_false): return on_false 
+            else: return apply(on_false)
+
+In most cases you'll pass b and c directly: q(a,b,c). To avoid evaluating b +or c when they shouldn't be, encapsulate them +within a lambda function, e.g.: q(a,lambda: b, lambda: c). +

+

+

+It has been asked why Python has no if-then-else expression, +since most language have one; it is a frequently requested feature. +

+There are several possible answers: just as many languages do +just fine without one; it can easily lead to less readable code; +no sufficiently "Pythonic" syntax has been discovered; a search +of the standard library found remarkably few places where using an +if-then-else expression would make the code more understandable. +

+Nevertheless, in an effort to decide once and for all whether +an if-then-else expression should be added to the language, +PEP 308 (http://www.python.org/peps/pep-0308.html) has been +put forward, proposing a specific syntax. The community can +now vote on this issue. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Feb 7 19:41:13 2003 by +David Goodger +

+ +


+

4.17. My class defines __del__ but it is not called when I delete the object.

+There are several possible reasons for this. +

+The del statement does not necessarily call __del__ -- it simply +decrements the object's reference count, and if this reaches zero +__del__ is called. +

+If your data structures contain circular links (e.g. a tree where +each child has a parent pointer and each parent has a list of +children) the reference counts will never go back to zero. You'll +have to define an explicit close() method which removes those +pointers. Please don't ever call __del__ directly -- __del__ should +call close() and close() should make sure that it can be called more +than once for the same object. +

+If the object has ever been a local variable (or argument, which is +really the same thing) to a function that caught an expression in an +except clause, chances are that a reference to the object still exists +in that function's stack frame as contained in the stack trace. +Normally, deleting (better: assigning None to) sys.exc_traceback will +take care of this. If a stack was printed for an unhandled +exception in an interactive interpreter, delete sys.last_traceback +instead. +

+There is code that deletes all objects when the interpreter exits, +but it is not called if your Python has been configured to support +threads (because other threads may still be active). You can define +your own cleanup function using sys.exitfunc (see question 4.4). +

+Finally, if your __del__ method raises an exception, a warning message is printed to sys.stderr. +

+

+Starting with Python 2.0, a garbage collector periodically reclaims the space used by most cycles with no external references. (See the "gc" module documentation for details.) There are, however, pathological cases where it can be expected to fail. Moreover, the garbage collector runs some time after the last reference to your data structure vanishes, so your __del__ method may be called at an inconvenient and random time. This is inconvenient if you're trying to reproduce a problem. Worse, the order in which object's __del__ methods are executed is arbitrary. +

+Another way to avoid cyclical references is to use the "weakref" module, which allows you to point to objects without incrementing their reference count. Tree data structures, for instance, should use weak references for their parent and sibling pointers (if they need them!). +

+Question 6.14 is intended to explain the new garbage collection algorithm. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 10 15:27:28 2002 by +Matthias Urlichs +

+ +


+

4.18. How do I change the shell environment for programs called using os.popen() or os.system()? Changing os.environ doesn't work.

+You must be using either a version of python before 1.4, or on a +(rare) system that doesn't have the putenv() library function. +

+Before Python 1.4, modifying the environment passed to subshells was +left out of the interpreter because there seemed to be no +well-established portable way to do it (in particular, some systems, +have putenv(), others have setenv(), and some have none at all). As +of Python 1.4, almost all Unix systems do have putenv(), and so does +the Win32 API, and thus the os module was modified so that changes to +os.environ are trapped and the corresponding putenv() call is made. +

+ +Edit this entry / +Log info +

+ +


+

4.19. What is a class?

+A class is the particular object type created by executing +a class statement. Class objects are used as templates, to create +instance objects, which embody both the data structure +(attributes) and program routines (methods) specific to a datatype. +

+A class can be based on one or more other classes, called its base +class(es). It then inherits the attributes and methods of its base classes. This allows an object model to be successively refined +by inheritance. +

+The term "classic class" is used to refer to the original +class implementation in Python. One problem with classic +classes is their inability to use the built-in data types +(such as list and dictionary) as base classes. Starting +with Python 2.2 an attempt is in progress to unify user-defined +classes and built-in types. It is now possible to declare classes +that inherit from built-in types. +

+ +Edit this entry / +Log info + +/ Last changed on Mon May 27 01:31:21 2002 by +Steve Holden +

+ +


+

4.20. What is a method?

+A method is a function that you normally call as +x.name(arguments...) for some object x. The term is used for methods +of classes and class instances as well as for methods of built-in +objects. (The latter have a completely different implementation and +only share the way their calls look in Python code.) Methods of +classes (and class instances) are defined as functions inside the +class definition. +

+ +Edit this entry / +Log info +

+ +


+

4.21. What is self?

+Self is merely a conventional name for the first argument of a +method -- i.e. a function defined inside a class definition. A method +defined as meth(self, a, b, c) should be called as x.meth(a, b, c) for +some instance x of the class in which the definition occurs; +the called method will think it is called as meth(x, a, b, c). +

+ +Edit this entry / +Log info +

+ +


+

4.22. What is an unbound method?

+An unbound method is a method defined in a class that is not yet +bound to an instance. You get an unbound method if you ask for a +class attribute that happens to be a function. You get a bound method +if you ask for an instance attribute. A bound method knows which +instance it belongs to and calling it supplies the instance automatically; +an unbound method only knows which class it wants for its first +argument (a derived class is also OK). Calling an unbound method +doesn't "magically" derive the first argument from the context -- you +have to provide it explicitly. +

+Trivia note regarding bound methods: each reference to a bound +method of a particular object creates a bound method object. If you +have two such references (a = inst.meth; b = inst.meth), they will +compare equal (a == b) but are not the same (a is not b). +

+ +Edit this entry / +Log info + +/ Last changed on Wed May 6 18:07:25 1998 by +Clarence Gardner +

+ +


+

4.23. How do I call a method defined in a base class from a derived class that overrides it?

+If your class definition starts with "class Derived(Base): ..." +then you can call method meth defined in Base (or one of Base's base +classes) as Base.meth(self, arguments...). Here, Base.meth is an +unbound method (see previous question). +

+ +Edit this entry / +Log info +

+ +


+

4.24. How do I call a method from a base class without using the name of the base class?

+DON'T DO THIS. REALLY. I MEAN IT. It appears that you could call +self.__class__.__bases__[0].meth(self, arguments...) but this fails when +a doubly-derived method is derived from your class: for its instances, +self.__class__.__bases__[0] is your class, not its base class -- so +(assuming you are doing this from within Derived.meth) you would start +a recursive call. +

+Often when you want to do this you are forgetting that classes +are first class in Python. You can "point to" the class you want +to delegate an operation to either at the instance or at the +subclass level. For example if you want to use a "glorp" +operation of a superclass you can point to the right superclass +to use. +

+

+  class subclass(superclass1, superclass2, superclass3):
+      delegate_glorp = superclass2
+      ...
+      def glorp(self, arg1, arg2):
+            ... subclass specific stuff ...
+            self.delegate_glorp.glorp(self, arg1, arg2)
+       ...
+
+
+  class subsubclass(subclass):
+       delegate_glorp = superclass3
+       ...
+
+Note, however that setting delegate_glorp to subclass in +subsubclass would cause an infinite recursion on subclass.delegate_glorp. Careful! Maybe you are getting too fancy for your own good. Consider simplifying the design (?). +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jul 28 13:58:22 1997 by +aaron watters +

+ +


+

4.25. How can I organize my code to make it easier to change the base class?

+You could define an alias for the base class, assign the real base +class to it before your class definition, and use the alias throughout +your class. Then all you have to change is the value assigned to the +alias. Incidentally, this trick is also handy if you want to decide +dynamically (e.g. depending on availability of resources) which base +class to use. Example: +

+

+        BaseAlias = <real base class>
+        class Derived(BaseAlias):
+                def meth(self):
+                        BaseAlias.meth(self)
+                        ...
+
+

+ +Edit this entry / +Log info + +/ Last changed on Wed May 21 15:49:57 1997 by +GvR +

+ +


+

4.26. How can I find the methods or attributes of an object?

+This depends on the object type. +

+For an instance x of a user-defined class, instance attributes are +found in the dictionary x.__dict__, and methods and attributes defined +by its class are found in x.__class__.__bases__[i].__dict__ (for i in +range(len(x.__class__.__bases__))). You'll have to walk the tree of +base classes to find all class methods and attributes. +

+Many, but not all built-in types define a list of their method names +in x.__methods__, and if they have data attributes, their names may be +found in x.__members__. However this is only a convention. +

+For more information, read the source of the standard (but +undocumented) module newdir. +

+ +Edit this entry / +Log info +

+ +


+

4.27. I can't seem to use os.read() on a pipe created with os.popen().

+os.read() is a low-level function which takes a file descriptor (a +small integer). os.popen() creates a high-level file object -- the +same type used for sys.std{in,out,err} and returned by the builtin +open() function. Thus, to read n bytes from a pipe p created with +os.popen(), you need to use p.read(n). +

+ +Edit this entry / +Log info +

+ +


+

4.28. How can I create a stand-alone binary from a Python script?

+Even though there are Python compilers being developed, +you probably don't need a real compiler, if all you want +is a stand-alone program. There are three solutions to that. +

+One is to use the freeze tool, which is included in the Python +source tree as Tools/freeze. It converts Python byte +code to C arrays. Using a C compiler, you can embed all +your modules into a new program, which is then linked +with the standard Python modules. +

+It works by scanning your source recursively for import statements +(in both forms) and looking for the modules in the standard Python path +as well as in the source directory (for built-in modules). It then +1 the modules written in Python to C code (array initializers +that can be turned into code objects using the marshal module) and +creates a custom-made config file that only contains those built-in +modules which are actually used in the program. It then compiles the +generated C code and links it with the rest of the Python interpreter +to form a self-contained binary which acts exactly like your script. +

+(Hint: the freeze program only works if your script's filename ends in +".py".) +

+There are several utilities which may be helpful. The first is Gordon McMillan's installer at +

+

+    http://www.mcmillan-inc.com/install1.html
+
+which works on Windows, Linux and at least some forms of Unix. +

+Another is Thomas Heller's py2exe (Windows only) at +

+

+    http://starship.python.net/crew/theller/py2exe/
+
+A third is Christian Tismer's SQFREEZE +(http://starship.python.net/crew/pirx/) which appends the byte code +to a specially-prepared Python interpreter, which +will find the byte code in executable. +

+A fourth is Fredrik Lundh's Squeeze +(http://www.pythonware.com/products/python/squeeze/). +

+ +Edit this entry / +Log info + +/ Last changed on Wed Jun 19 14:01:30 2002 by +Gordon McMillan +

+ +


+

4.29. What WWW tools are there for Python?

+See the chapters titled "Internet Protocols and Support" and +"Internet Data Handling" in the Library Reference +Manual. Python is full of good things which will help you build server-side and client-side web systems. +

+A summary of available frameworks is maintained by Paul Boddie at +

+

+    http://thor.prohosting.com/~pboddie/Python/web_modules.html
+
+Cameron Laird maintains a useful set of pages about Python web technologies at +

+

+   http://starbase.neosoft.com/~claird/comp.lang.python/web_python.html/
+
+There was a web browser written in Python, called Grail -- +see http://sourceforge.net/project/grail/. This project has been terminated; http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/grail/grail/README gives more details. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Nov 11 22:48:25 2002 by +GvR +

+ +


+

4.30. How do I run a subprocess with pipes connected to both input and output?

+Use the standard popen2 module. For example: +

+

+	import popen2
+	fromchild, tochild = popen2.popen2("command")
+	tochild.write("input\n")
+	tochild.flush()
+	output = fromchild.readline()
+
+Warning: in general, it is unwise to +do this, because you can easily cause a deadlock where your +process is blocked waiting for output from the child, while the child +is blocked waiting for input from you. This can be caused +because the parent expects the child to output more text than it does, +or it can be caused by data being stuck in stdio buffers due to lack +of flushing. The Python parent can of course explicitly flush the data +it sends to the child before it reads any output, but if the child is +a naive C program it can easily have been written to never explicitly +flush its output, even if it is interactive, since flushing is +normally automatic. +

+Note that a deadlock is also possible if you use popen3 to read +stdout and stderr. If one of the two is too large for the internal +buffer (increasing the buffersize does not help) and you read() +the other one first, there is a deadlock, too. +

+Note on a bug in popen2: unless your program calls wait() +or waitpid(), finished child processes are never removed, +and eventually calls to popen2 will fail because of a limit on +the number of child processes. Calling os.waitpid with the +os.WNOHANG option can prevent this; a good place to insert such +a call would be before calling popen2 again. +

+Another way to produce a deadlock: Call a wait() and there is +still more output from the program than what fits into the +internal buffers. +

+In many cases, all you really need is to run some data through a +command and get the result back. Unless the data is infinite in size, +the easiest (and often the most efficient!) way to do this is to write +it to a temporary file and run the command with that temporary file as +input. The standard module tempfile exports a function mktemp() which +generates unique temporary file names. +

+

+ import tempfile
+ import os
+ class Popen3:
+    """
+    This is a deadlock-save version of popen, that returns
+    an object with errorlevel, out (a string) and err (a string).
+    (capturestderr may not work under windows.)
+    Example: print Popen3('grep spam','\n\nhere spam\n\n').out
+    """
+    def __init__(self,command,input=None,capturestderr=None):
+        outfile=tempfile.mktemp()
+        command="( %s ) > %s" % (command,outfile)
+        if input:
+            infile=tempfile.mktemp()
+            open(infile,"w").write(input)
+            command=command+" <"+infile
+        if capturestderr:
+            errfile=tempfile.mktemp()
+            command=command+" 2>"+errfile
+        self.errorlevel=os.system(command) >> 8
+        self.out=open(outfile,"r").read()
+        os.remove(outfile)
+        if input:
+            os.remove(infile)
+        if capturestderr:
+            self.err=open(errfile,"r").read()
+            os.remove(errfile)
+
+Note that many interactive programs (e.g. vi) don't work well with +pipes substituted for standard input and output. You will have to use +pseudo ttys ("ptys") instead of pipes. There is some undocumented +code to use these in the library module pty.py -- I'm afraid you're on +your own here. +

+A different answer is a Python interface to Don Libes' "expect" +library. A Python extension that interfaces to expect is called "expy" +and available from +http://expectpy.sourceforge.net/. +

+A pure Python solution that works like expect is pexpect of Noah Spurrier. +A beta version is available from +http://pexpect.sourceforge.net/ +

+ +Edit this entry / +Log info + +/ Last changed on Tue Sep 3 16:31:31 2002 by +Tobias Polzin +

+ +


+

4.31. How do I call a function if I have the arguments in a tuple?

+Use the built-in function apply(). For instance, +

+

+    func(1, 2, 3)
+
+is equivalent to +

+

+    args = (1, 2, 3)
+    apply(func, args)
+
+Note that func(args) is not the same -- it calls func() with exactly +one argument, the tuple args, instead of three arguments, the integers +1, 2 and 3. +

+In Python 2.0, you can also use extended call syntax: +

+f(*args) is equivalent to apply(f, args) +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 2 03:42:50 2001 by +Moshe Zadka +

+ +


+

4.32. How do I enable font-lock-mode for Python in Emacs?

+If you are using XEmacs 19.14 or later, any XEmacs 20, FSF Emacs 19.34 +or any Emacs 20, font-lock should work automatically for you if you +are using the latest python-mode.el. +

+If you are using an older version of XEmacs or Emacs you will need +to put this in your .emacs file: +

+

+        (defun my-python-mode-hook ()
+          (setq font-lock-keywords python-font-lock-keywords)
+          (font-lock-mode 1))
+        (add-hook 'python-mode-hook 'my-python-mode-hook)
+
+

+ +Edit this entry / +Log info + +/ Last changed on Mon Apr 6 16:18:46 1998 by +Barry Warsaw +

+ +


+

4.33. Is there a scanf() or sscanf() equivalent?

+Not as such. +

+For simple input parsing, the easiest approach is usually to split +the line into whitespace-delimited words using string.split(), and to +convert decimal strings to numeric values using int(), +long() or float(). (Python's int() is 32-bit and its +long() is arbitrary precision.) string.split supports an optional +"sep" parameter which is useful if the line uses something other +than whitespace as a delimiter. +

+For more complicated input parsing, regular expressions (see module re) +are better suited and more powerful than C's sscanf(). +

+There's a contributed module that emulates sscanf(), by Steve Clift; +see contrib/Misc/sscanfmodule.c of the ftp site: +

+

+    http://www.python.org/ftp/python/contrib-09-Dec-1999/Misc/
+
+

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 01:07:51 2002 by +Neal Norwitz +

+ +


+

4.34. Can I have Tk events handled while waiting for I/O?

+Yes, and you don't even need threads! But you'll have to +restructure your I/O code a bit. Tk has the equivalent of Xt's +XtAddInput() call, which allows you to register a callback function +which will be called from the Tk mainloop when I/O is possible on a +file descriptor. Here's what you need: +

+

+        from Tkinter import tkinter
+        tkinter.createfilehandler(file, mask, callback)
+
+The file may be a Python file or socket object (actually, anything +with a fileno() method), or an integer file descriptor. The mask is +one of the constants tkinter.READABLE or tkinter.WRITABLE. The +callback is called as follows: +

+

+        callback(file, mask)
+
+You must unregister the callback when you're done, using +

+

+        tkinter.deletefilehandler(file)
+
+Note: since you don't know *how many bytes* are available for reading, +you can't use the Python file object's read or readline methods, since +these will insist on reading a predefined number of bytes. For +sockets, the recv() or recvfrom() methods will work fine; for other +files, use os.read(file.fileno(), maxbytecount). +

+ +Edit this entry / +Log info +

+ +


+

4.35. How do I write a function with output parameters (call by reference)?

+[Mark Lutz] The thing to remember is that arguments are passed by +assignment in Python. Since assignment just creates references to +objects, there's no alias between an argument name in the caller and +callee, and so no call-by-reference per se. But you can simulate it +in a number of ways: +

+1) By using global variables; but you probably shouldn't :-) +

+2) By passing a mutable (changeable in-place) object: +

+

+      def func1(a):
+          a[0] = 'new-value'     # 'a' references a mutable list
+          a[1] = a[1] + 1        # changes a shared object
+
+
+      args = ['old-value', 99]
+      func1(args)
+      print args[0], args[1]     # output: new-value 100
+
+3) By returning a tuple, holding the final values of arguments: +

+

+      def func2(a, b):
+          a = 'new-value'        # a and b are local names
+          b = b + 1              # assigned to new objects
+          return a, b            # return new values
+
+
+      x, y = 'old-value', 99
+      x, y = func2(x, y)
+      print x, y                 # output: new-value 100
+
+4) And other ideas that fall-out from Python's object model. For instance, it might be clearer to pass in a mutable dictionary: +

+

+      def func3(args):
+          args['a'] = 'new-value'     # args is a mutable dictionary
+          args['b'] = args['b'] + 1   # change it in-place
+
+
+      args = {'a':' old-value', 'b': 99}
+      func3(args)
+      print args['a'], args['b']
+
+5) Or bundle-up values in a class instance: +

+

+      class callByRef:
+          def __init__(self, **args):
+              for (key, value) in args.items():
+                  setattr(self, key, value)
+
+
+      def func4(args):
+          args.a = 'new-value'        # args is a mutable callByRef
+          args.b = args.b + 1         # change object in-place
+
+
+      args = callByRef(a='old-value', b=99)
+      func4(args)
+      print args.a, args.b
+
+
+   But there's probably no good reason to get this complicated :-).
+
+[Python's author favors solution 3 in most cases.] +

+ +Edit this entry / +Log info + +/ Last changed on Sun Jun 8 23:49:46 1997 by +David Ascher +

+ +


+

4.36. Please explain the rules for local and global variables in Python.

+[Ken Manheimer] In Python, procedure variables are implicitly +global, unless they are assigned anywhere within the block. +In that case +they are implicitly local, and you need to explicitly declare them as +'global'. +

+Though a bit surprising at first, a moment's consideration explains +this. On one hand, requirement of 'global' for assigned vars provides +a bar against unintended side-effects. On the other hand, if global +were required for all global references, you'd be using global all the +time. Eg, you'd have to declare as global every reference to a +builtin function, or to a component of an imported module. This +clutter would defeat the usefulness of the 'global' declaration for +identifying side-effects. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Aug 28 09:53:27 1998 by +GvR +

+ +


+

4.37. How can I have modules that mutually import each other?

+Suppose you have the following modules: +

+foo.py: +

+

+	from bar import bar_var
+	foo_var=1
+
+bar.py: +

+

+	from foo import foo_var
+	bar_var=2
+
+The problem is that the above is processed by the interpreter thus: +

+

+	main imports foo
+	Empty globals for foo are created
+	foo is compiled and starts executing
+	foo imports bar
+	Empty globals for bar are created
+	bar is compiled and starts executing
+	bar imports foo (which is a no-op since there already is a module named foo)
+	bar.foo_var = foo.foo_var
+	...
+
+The last step fails, because Python isn't done with interpreting foo yet and the global symbol dict for foo is still empty. +

+The same thing happens when you use "import foo", and then try to access "foo.one" in global code. +

+

+There are (at least) three possible workarounds for this problem. +

+Guido van Rossum recommends to avoid all uses of "from <module> import ..." (so everything from an imported module is referenced as <module>.<name>) and to place all code inside functions. Initializations of global variables and class variables should use constants or built-in functions only. +

+

+Jim Roskind suggests the following order in each module: +

+

+ exports (globals, functions, and classes that don't need imported base classes)
+ import statements
+ active code (including globals that are initialized from imported values).
+
+Python's author doesn't like this approach much because the imports +appear in a strange place, but has to admit that it works. +

+

+

+Matthias Urlichs recommends to restructure your code so that the recursive import is not necessary in the first place. +

+

+These solutions are not mutually exclusive. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 06:52:51 2002 by +Matthias Urlichs +

+ +


+

4.38. How do I copy an object in Python?

+Try copy.copy() or copy.deepcopy() for the general case. Not all objects can be copied, but most can. +

+Dictionaries have a copy method. Sequences can be copied by slicing: +

+ new_l = l[:]
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Mar 21 05:40:26 2002 by +Erno Kuusela +

+ +


+

4.39. How to implement persistent objects in Python? (Persistent == automatically saved to and restored from disk.)

+The library module "pickle" now solves this in a very general way +(though you still can't store things like open files, sockets or +windows), and the library module "shelve" uses pickle and (g)dbm to +create persistent mappings containing arbitrary Python objects. +For possibly better performance also look for the latest version +of the relatively recent cPickle module. +

+A more awkward way of doing things is to use pickle's little sister, +marshal. The marshal module provides very fast ways to store +noncircular basic Python types to files and strings, and back again. +Although marshal does not do fancy things like store instances or +handle shared references properly, it does run extremely fast. For +example loading a half megabyte of data may take less than a +third of a second (on some machines). This often beats doing +something more complex and general such as using gdbm with +pickle/shelve. +

+ +Edit this entry / +Log info + +/ Last changed on Sun Jun 8 22:59:00 1997 by +David Ascher +

+ +


+

4.40. I try to use __spam and I get an error about _SomeClassName__spam.

+Variables with double leading underscore are "mangled" to provide a +simple but effective way to define class private variables. See the +chapter "New in Release 1.4" in the Python Tutorial. +

+ +Edit this entry / +Log info +

+ +


+

4.41. How do I delete a file? And other file questions.

+Use os.remove(filename) or os.unlink(filename); for documentation, +see the posix section of the library manual. They are the same, +unlink() is simply the Unix name for this function. In earlier +versions of Python, only os.unlink() was available. +

+To remove a directory, use os.rmdir(); use os.mkdir() to create one. +

+To rename a file, use os.rename(). +

+To truncate a file, open it using f = open(filename, "r+"), and use +f.truncate(offset); offset defaults to the current seek position. +(The "r+" mode opens the file for reading and writing.) +There's also os.ftruncate(fd, offset) for files opened with os.open() +-- for advanced Unix hacks only. +

+The shutil module also contains a number of functions to work on files +including copyfile, copytree, and rmtree amongst others. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Dec 28 12:30:01 2000 by +Bjorn Pettersen +

+ +


+

4.42. How to modify urllib or httplib to support HTTP/1.1?

+Recent versions of Python (2.0 and onwards) support HTTP/1.1 natively. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 2 02:56:56 2001 by +Moshe Zadka +

+ +


+

4.43. Unexplicable syntax errors in compile() or exec.

+When a statement suite (as opposed to an expression) is compiled by +compile(), exec or execfile(), it must end in a newline. In some +cases, when the source ends in an indented block it appears that at +least two newlines are required. +

+ +Edit this entry / +Log info +

+ +


+

4.44. How do I convert a string to a number?

+For integers, use the built-in int() function, e.g. int('144') == 144. Similarly, long() converts from string to long integer, e.g. long('144') == 144L; and float() to floating-point, e.g. float('144') == 144.0. +

+Note that these are restricted to decimal interpretation, so +that int('0144') == 144 and int('0x144') raises ValueError. For Python +2.0 int takes the base to convert from as a second optional argument, so +int('0x144', 16) == 324. +

+For greater flexibility, or before Python 1.5, import the module +string and use the string.atoi() function for integers, +string.atol() for long integers, or string.atof() for +floating-point. E.g., +string.atoi('100', 16) == string.atoi('0x100', 0) == 256. +See the library reference manual section for the string module for +more details. +

+While you could use the built-in function eval() instead of +any of those, this is not recommended, because someone could pass you +a Python expression that might have unwanted side effects (like +reformatting your disk). It also has the effect of interpreting numbers +as Python expressions, so that e.g. eval('09') gives a syntax error +since Python regards numbers starting with '0' as octal (base 8). +

+ +Edit this entry / +Log info + +/ Last changed on Thu Dec 28 12:37:34 2000 by +Bjorn Pettersen +

+ +


+

4.45. How do I convert a number to a string?

+To convert, e.g., the number 144 to the string '144', use the +built-in function repr() or the backquote notation (these are +equivalent). If you want a hexadecimal or octal representation, use +the built-in functions hex() or oct(), respectively. For fancy +formatting, use the % operator on strings, just like C printf formats, +e.g. "%04d" % 144 yields '0144' and "%.3f" % (1/3.0) yields '0.333'. +See the library reference manual for details. +

+ +Edit this entry / +Log info +

+ +


+

4.46. How do I copy a file?

+There's the shutil module which contains a copyfile() +function that implements a copy loop; +it isn't good enough for the Macintosh, though: +it doesn't copy the resource fork and Finder info. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 2 02:59:40 2001 by +Moshe Zadka +

+ +


+

4.47. How do I check if an object is an instance of a given class or of a subclass of it?

+If you are developing the classes from scratch it might be better to +program in a more proper object-oriented style -- instead of doing a different +thing based on class membership, why not use a method and define the +method differently in different classes? +

+However, there are some legitimate situations +where you need to test for class membership. +

+In Python 1.5, you can use the built-in function isinstance(obj, cls). +

+The following approaches can be used with earlier Python versions: +

+An unobvious method is to raise the object +as an exception and to try to catch the exception with the class you're +testing for: +

+

+	def is_instance_of(the_instance, the_class):
+	    try:
+		raise the_instance
+	    except the_class:
+		return 1
+	    except:
+		return 0
+
+This technique can be used to distinguish "subclassness" +from a collection of classes as well +

+

+                try:
+                              raise the_instance
+                except Audible:
+                              the_instance.play(largo)
+                except Visual:
+                              the_instance.display(gaudy)
+                except Olfactory:
+                              sniff(the_instance)
+                except:
+                              raise ValueError, "dunno what to do with this!"
+
+This uses the fact that exception catching tests for class or subclass +membership. +

+A different approach is to test for the presence of a class attribute that +is presumably unique for the given class. For instance: +

+

+	class MyClass:
+	    ThisIsMyClass = 1
+	    ...
+
+
+	def is_a_MyClass(the_instance):
+	    return hasattr(the_instance, 'ThisIsMyClass')
+
+This version is easier to inline, and probably faster (inlined it +is definitely faster). The disadvantage is that someone else could cheat: +

+

+	class IntruderClass:
+	    ThisIsMyClass = 1    # Masquerade as MyClass
+	    ...
+
+but this may be seen as a feature (anyway, there are plenty of other ways +to cheat in Python). Another disadvantage is that the class must be +prepared for the membership test. If you do not "control the +source code" for the class it may not be advisable to modify the +class to support testability. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Jan 2 15:16:04 1998 by +GvR +

+ +


+

4.48. What is delegation?

+Delegation refers to an object oriented technique Python programmers +may implement with particular ease. Consider the following: +

+

+  from string import upper
+
+
+  class UpperOut:
+        def __init__(self, outfile):
+              self.__outfile = outfile
+        def write(self, str):
+              self.__outfile.write( upper(str) )
+        def __getattr__(self, name):
+              return getattr(self.__outfile, name)
+
+Here the UpperOut class redefines the write method +to convert the argument string to upper case before +calling the underlying self.__outfile.write method, but +all other methods are delegated to the underlying +self.__outfile object. The delegation is accomplished +via the "magic" __getattr__ method. Please see the +language reference for more information on the use +of this method. +

+Note that for more general cases delegation can +get trickier. Particularly when attributes must be set +as well as gotten the class must define a __settattr__ +method too, and it must do so carefully. +

+The basic implementation of __setattr__ is roughly +equivalent to the following: +

+

+   class X:
+        ...
+        def __setattr__(self, name, value):
+             self.__dict__[name] = value
+        ...
+
+Most __setattr__ implementations must modify +self.__dict__ to store local state for self without +causing an infinite recursion. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Aug 13 07:11:24 1997 by +aaron watters +

+ +


+

4.49. How do I test a Python program or component.

+We presume for the purposes of this question you are interested +in standalone testing, rather than testing your components inside +a testing framework. The best-known testing framework for Python +is the PyUnit module, maintained at +

+

+    http://pyunit.sourceforge.net/
+
+For standalone testing, it helps to write the program so that +it may be easily tested by using good modular design. +In particular your program +should have almost all functionality encapsulated in either functions +or class methods -- and this sometimes has the surprising and +delightful effect of making the program run faster (because +local variable accesses are faster than global accesses). +Furthermore the program should avoid depending on mutating +global variables, since this makes testing much more difficult to do. +

+The "global main logic" of your program may be as simple +as +

+

+  if __name__=="__main__":
+       main_logic()
+
+at the bottom of the main module of your program. +

+Once your program is organized as a tractable collection +of functions and class behaviours you should write test +functions that exercise the behaviours. A test suite +can be associated with each module which automates +a sequence of tests. This sounds like a lot of work, but +since Python is so terse and flexible it's surprisingly easy. +You can make coding much more pleasant and fun by +writing your test functions in parallel with the "production +code", since this makes it easy to find bugs and even +design flaws earlier. +

+"Support modules" that are not intended to be the main +module of a program may include a "test script interpretation" +which invokes a self test of the module. +

+

+   if __name__ == "__main__":
+      self_test()
+
+Even programs that interact with complex external +interfaces may be tested when the external interfaces are +unavailable by using "fake" interfaces implemented in +Python. For an example of a "fake" interface, the following +class defines (part of) a "fake" file interface: +

+

+ import string
+ testdata = "just a random sequence of characters"
+
+
+ class FakeInputFile:
+   data = testdata
+   position = 0
+   closed = 0
+
+
+   def read(self, n=None):
+       self.testclosed()
+       p = self.position
+       if n is None:
+          result= self.data[p:]
+       else:
+          result= self.data[p: p+n]
+       self.position = p + len(result)
+       return result
+
+
+   def seek(self, n, m=0):
+       self.testclosed()
+       last = len(self.data)
+       p = self.position
+       if m==0: 
+          final=n
+       elif m==1:
+          final=n+p
+       elif m==2:
+          final=len(self.data)+n
+       else:
+          raise ValueError, "bad m"
+       if final<0:
+          raise IOError, "negative seek"
+       self.position = final
+
+
+   def isatty(self):
+       return 0
+
+
+   def tell(self):
+       return self.position
+
+
+   def close(self):
+       self.closed = 1
+
+
+   def testclosed(self):
+       if self.closed:
+          raise IOError, "file closed"
+
+Try f=FakeInputFile() and test out its operations. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 01:12:10 2002 by +Neal Norwitz +

+ +


+

4.50. My multidimensional list (array) is broken! What gives?

+You probably tried to make a multidimensional array like this. +

+

+   A = [[None] * 2] * 3
+
+This makes a list containing 3 references to the same list of length +two. Changes to one row will show in all rows, which is probably not +what you want. The following works much better: +

+

+   A = [None]*3
+   for i in range(3):
+        A[i] = [None] * 2
+
+This generates a list containing 3 different lists of length two. +

+If you feel weird, you can also do it in the following way: +

+

+   w, h = 2, 3
+   A = map(lambda i,w=w: [None] * w, range(h))
+
+For Python 2.0 the above can be spelled using a list comprehension: +

+

+   w,h = 2,3
+   A = [ [None]*w for i in range(h) ]
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Dec 28 12:18:35 2000 by +Bjorn Pettersen +

+ +


+

4.51. I want to do a complicated sort: can you do a Schwartzian Transform in Python?

+Yes, and in Python you only have to write it once: +

+

+ def st(List, Metric):
+     def pairing(element, M = Metric):
+           return (M(element), element)
+     paired = map(pairing, List)
+     paired.sort()
+     return map(stripit, paired)
+
+
+ def stripit(pair):
+     return pair[1]
+
+This technique, attributed to Randal Schwartz, sorts the elements +of a list by a metric which maps each element to its "sort value". +For example, if L is a list of string then +

+

+   import string
+   Usorted = st(L, string.upper)
+
+
+   def intfield(s):
+         return string.atoi( string.strip(s[10:15] ) )
+
+
+   Isorted = st(L, intfield)
+
+Usorted gives the elements of L sorted as if they were upper +case, and Isorted gives the elements of L sorted by the integer +values that appear in the string slices starting at position 10 +and ending at position 15. In Python 2.0 this can be done more +naturally with list comprehensions: +

+

+  tmp1 = [ (x.upper(), x) for x in L ] # Schwartzian transform
+  tmp1.sort()
+  Usorted = [ x[1] for x in tmp1 ]
+
+
+  tmp2 = [ (int(s[10:15]), s) for s in L ] # Schwartzian transform
+  tmp2.sort()
+  Isorted = [ x[1] for x in tmp2 ]
+
+

+Note that Isorted may also be computed by +

+

+   def Icmp(s1, s2):
+         return cmp( intfield(s1), intfield(s2) )
+
+
+   Isorted = L[:]
+   Isorted.sort(Icmp)
+
+but since this method computes intfield many times for each +element of L, it is slower than the Schwartzian Transform. +

+ +Edit this entry / +Log info + +/ Last changed on Sat Jun 1 19:18:46 2002 by +Neal Norwitz +

+ +


+

4.52. How to convert between tuples and lists?

+The function tuple(seq) converts any sequence into a tuple with +the same items in the same order. +For example, tuple([1, 2, 3]) yields (1, 2, 3) and tuple('abc') +yields ('a', 'b', 'c'). If the argument is +a tuple, it does not make a copy but returns the same object, so +it is cheap to call tuple() when you aren't sure that an object +is already a tuple. +

+The function list(seq) converts any sequence into a list with +the same items in the same order. +For example, list((1, 2, 3)) yields [1, 2, 3] and list('abc') +yields ['a', 'b', 'c']. If the argument is a list, +it makes a copy just like seq[:] would. +

+ +Edit this entry / +Log info + +/ Last changed on Sun Jun 14 14:18:53 1998 by +Tim Peters +

+ +


+

4.53. Files retrieved with urllib contain leading garbage that looks like email headers.

+Extremely old versions of Python supplied libraries which +did not support HTTP/1.1; the vanilla httplib in Python 1.4 +only recognized HTTP/1.0. In Python 2.0 full HTTP/1.1 support is included. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jan 8 17:26:18 2001 by +Steve Holden +

+ +


+

4.54. How do I get a list of all instances of a given class?

+Python does not keep track of all instances of a class (or of a +built-in type). +

+You can program the class's constructor to keep track of all +instances, but unless you're very clever, this has the disadvantage +that the instances never get deleted,because your list of all +instances keeps a reference to them. +

+(The trick is to regularly inspect the reference counts of the +instances you've retained, and if the reference count is below a +certain level, remove it from the list. Determining that level is +tricky -- it's definitely larger than 1.) +

+ +Edit this entry / +Log info + +/ Last changed on Tue May 27 23:52:16 1997 by +GvR +

+ +


+

4.55. A regular expression fails with regex.error: match failure.

+This is usually caused by too much backtracking; the regular +expression engine has a fixed size stack which holds at most 4000 +backtrack points. Every character matched by e.g. ".*" accounts for a +backtrack point, so even a simple search like +

+

+  regex.match('.*x',"x"*5000)
+
+will fail. +

+This is fixed in the re module introduced with +Python 1.5; consult the Library Reference section on re for more information. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jul 30 12:35:49 1998 by +A.M. Kuchling +

+ +


+

4.56. I can't get signal handlers to work.

+The most common problem is that the signal handler is declared +with the wrong argument list. It is called as +

+

+	handler(signum, frame)
+
+so it should be declared with two arguments: +

+

+	def handler(signum, frame):
+		...
+
+

+ +Edit this entry / +Log info + +/ Last changed on Wed May 28 09:29:08 1997 by +GvR +

+ +


+

4.57. I can't use a global variable in a function? Help!

+Did you do something like this? +

+

+   x = 1 # make a global
+
+
+   def f():
+         print x # try to print the global
+         ...
+         for j in range(100):
+              if q>3:
+                 x=4
+
+Any variable assigned in a function is local to that function. +unless it is specifically declared global. Since a value is bound +to x as the last statement of the function body, the compiler +assumes that x is local. Consequently the "print x" +attempts to print an uninitialized local variable and will +trigger a NameError. +

+In such cases the solution is to insert an explicit global +declaration at the start of the function, making it +

+

+

+   def f():
+         global x
+         print x # try to print the global
+         ...
+         for j in range(100):
+              if q>3:
+                 x=4
+
+

+In this case, all references to x are interpreted as references +to the x from the module namespace. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Feb 12 15:52:12 2001 by +Steve Holden +

+ +


+

4.58. What's a negative index? Why doesn't list.insert() use them?

+Python sequences are indexed with positive numbers and +negative numbers. For positive numbers 0 is the first index +1 is the second index and so forth. For negative indices -1 +is the last index and -2 is the pentultimate (next to last) index +and so forth. Think of seq[-n] as the same as seq[len(seq)-n]. +

+Using negative indices can be very convenient. For example +if the string Line ends in a newline then Line[:-1] is all of Line except +the newline. +

+Sadly the list builtin method L.insert does not observe negative +indices. This feature could be considered a mistake but since +existing programs depend on this feature it may stay around +forever. L.insert for negative indices inserts at the start of the +list. To get "proper" negative index behaviour use L[n:n] = [x] +in place of the insert method. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Aug 13 07:03:18 1997 by +aaron watters +

+ +


+

4.59. How can I sort one list by values from another list?

+You can sort lists of tuples. +

+

+  >>> list1 = ["what", "I'm", "sorting", "by"]
+  >>> list2 = ["something", "else", "to", "sort"]
+  >>> pairs = map(None, list1, list2)
+  >>> pairs
+  [('what', 'something'), ("I'm", 'else'), ('sorting', 'to'), ('by', 'sort')]
+  >>> pairs.sort()
+  >>> pairs
+  [("I'm", 'else'), ('by', 'sort'), ('sorting', 'to'), ('what', 'something')]
+  >>> result = pairs[:]
+  >>> for i in xrange(len(result)): result[i] = result[i][1]
+  ...
+  >>> result
+  ['else', 'sort', 'to', 'something']
+
+And if you didn't understand the question, please see the +example above ;c). Note that "I'm" sorts before "by" because +uppercase "I" comes before lowercase "b" in the ascii order. +Also see 4.51. +

+In Python 2.0 this can be done like: +

+

+ >>> list1 = ["what", "I'm", "sorting", "by"]
+ >>> list2 = ["something", "else", "to", "sort"]
+ >>> pairs = zip(list1, list2)
+ >>> pairs
+ [('what', 'something'), ("I'm", 'else'), ('sorting', 'to'), ('by', 'sort')]
+ >>> pairs.sort()
+ >>> result = [ x[1] for x in pairs ]
+ >>> result
+ ['else', 'sort', 'to', 'something']
+
+[Followup] +

+Someone asked, why not this for the last steps: +

+

+  result = []
+  for p in pairs: result.append(p[1])
+
+This is much more legible. However, a quick test shows that +it is almost twice as slow for long lists. Why? First of all, +the append() operation has to reallocate memory, and while it +uses some tricks to avoid doing that each time, it still has +to do it occasionally, and apparently that costs quite a bit. +Second, the expression "result.append" requires an extra +attribute lookup. The attribute lookup could be done away +with by rewriting as follows: +

+

+  result = []
+  append = result.append
+  for p in pairs: append(p[1])
+
+which gains back some speed, but is still considerably slower +than the original solution, and hardly less convoluted. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Dec 28 12:56:35 2000 by +Bjorn Pettersen +

+ +


+

4.60. Why doesn't dir() work on builtin types like files and lists?

+It does starting with Python 1.5. +

+Using 1.4, you can find out which methods a given object supports +by looking at its __methods__ attribute: +

+

+    >>> List = []
+    >>> List.__methods__
+    ['append', 'count', 'index', 'insert', 'remove', 'reverse', 'sort']
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Sep 16 14:56:42 1999 by +Skip Montanaro +

+ +


+

4.61. How can I mimic CGI form submission (METHOD=POST)?

+I would like to retrieve web pages that are the result of POSTing a +form. Is there existing code that would let me do this easily? +

+Yes. Here's a simple example that uses httplib. +

+

+    #!/usr/local/bin/python
+
+
+    import httplib, sys, time
+
+
+    ### build the query string
+    qs = "First=Josephine&MI=Q&Last=Public"
+
+
+    ### connect and send the server a path
+    httpobj = httplib.HTTP('www.some-server.out-there', 80)
+    httpobj.putrequest('POST', '/cgi-bin/some-cgi-script')
+    ### now generate the rest of the HTTP headers...
+    httpobj.putheader('Accept', '*/*')
+    httpobj.putheader('Connection', 'Keep-Alive')
+    httpobj.putheader('Content-type', 'application/x-www-form-urlencoded')
+    httpobj.putheader('Content-length', '%d' % len(qs))
+    httpobj.endheaders()
+    httpobj.send(qs)
+    ### find out what the server said in response...
+    reply, msg, hdrs = httpobj.getreply()
+    if reply != 200:
+	sys.stdout.write(httpobj.getfile().read())
+
+Note that in general for "url encoded posts" (the default) query strings must be "quoted" to, for example, change equals signs and spaces to an encoded form when they occur in name or value. Use urllib.quote to perform this quoting. For example to send name="Guy Steele, Jr.": +

+

+   >>> from urllib import quote
+   >>> x = quote("Guy Steele, Jr.")
+   >>> x
+   'Guy%20Steele,%20Jr.'
+   >>> query_string = "name="+x
+   >>> query_string
+   'name=Guy%20Steele,%20Jr.'
+
+

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 21 03:47:07 1999 by +TAB +

+ +


+

4.62. If my program crashes with a bsddb (or anydbm) database open, it gets corrupted. How come?

+Databases opened for write access with the bsddb module (and often by +the anydbm module, since it will preferentially use bsddb) must +explicitly be closed using the close method of the database. The +underlying libdb package caches database contents which need to be +converted to on-disk form and written, unlike regular open files which +already have the on-disk bits in the kernel's write buffer, where they +can just be dumped by the kernel with the program exits. +

+If you have initialized a new bsddb database but not written anything to +it before the program crashes, you will often wind up with a zero-length +file and encounter an exception the next time the file is opened. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 01:15:01 2002 by +Neal Norwitz +

+ +


+

4.63. How do I make a Python script executable on Unix?

+You need to do two things: the script file's mode must be executable +(include the 'x' bit), and the first line must begin with #! +followed by the pathname for the Python interpreter. +

+The first is done by executing 'chmod +x scriptfile' or perhaps +'chmod 755 scriptfile'. +

+The second can be done in a number of way. The most straightforward +way is to write +

+

+  #!/usr/local/bin/python
+
+as the very first line of your file - or whatever the pathname is +where the python interpreter is installed on your platform. +

+If you would like the script to be independent of where the python +interpreter lives, you can use the "env" program. On almost all +platforms, the following will work, assuming the python interpreter +is in a directory on the user's $PATH: +

+

+  #! /usr/bin/env python
+
+Note -- *don't* do this for CGI scripts. The $PATH variable for +CGI scripts is often very minimal, so you need to use the actual +absolute pathname of the interpreter. +

+Occasionally, a user's environment is so full that the /usr/bin/env +program fails; or there's no env program at all. +In that case, you can try the following hack (due to Alex Rezinsky): +

+

+  #! /bin/sh
+  """:"
+  exec python $0 ${1+"$@"}
+  """
+
+The disadvantage is that this defines the script's __doc__ string. +However, you can fix that by adding +

+

+  __doc__ = """...Whatever..."""
+
+

+ +Edit this entry / +Log info + +/ Last changed on Mon Jan 15 09:19:16 2001 by +Neal Norwitz +

+ +


+

4.64. How do you remove duplicates from a list?

+See the Python Cookbook for a long discussion of many cool ways: +

+

+    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52560
+
+Generally, if you don't mind reordering the List +

+

+   if List:
+      List.sort()
+      last = List[-1]
+      for i in range(len(List)-2, -1, -1):
+          if last==List[i]: del List[i]
+          else: last=List[i]
+
+If all elements of the list may be used as +dictionary keys (ie, they are all hashable) +this is often faster +

+

+   d = {}
+   for x in List: d[x]=x
+   List = d.values()
+
+Also, for extremely large lists you might +consider more optimal alternatives to the first one. +The second one is pretty good whenever it can +be used. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 24 21:56:33 2002 by +Tim Peters +

+ +


+

4.65. Are there any known year 2000 problems in Python?

+I am not aware of year 2000 deficiencies in Python 1.5. Python does +very few date calculations and for what it does, it relies on the C +library functions. Python generally represent times either as seconds +since 1970 or as a tuple (year, month, day, ...) where the year is +expressed with four digits, which makes Y2K bugs unlikely. So as long +as your C library is okay, Python should be okay. Of course, I cannot +vouch for your Python code! +

+Given the nature of freely available software, I have to add that this statement is not +legally binding. The Python copyright notice contains the following +disclaimer: +

+

+  STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
+  REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+  MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
+  CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+  DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+  PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+  TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+  PERFORMANCE OF THIS SOFTWARE.
+
+The good news is that if you encounter a problem, you have full +source available to track it down and fix it! +

+ +Edit this entry / +Log info + +/ Last changed on Fri Apr 10 14:59:31 1998 by +GvR +

+ +


+

4.66. I want a version of map that applies a method to a sequence of objects! Help!

+Get fancy! +

+

+  def method_map(objects, method, arguments):
+       """method_map([a,b], "flog", (1,2)) gives [a.flog(1,2), b.flog(1,2)]"""
+       nobjects = len(objects)
+       methods = map(getattr, objects, [method]*nobjects)
+       return map(apply, methods, [arguments]*nobjects)
+
+It's generally a good idea to get to know the mysteries of map and apply +and getattr and the other dynamic features of Python. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jan 5 14:21:14 1998 by +Aaron Watters +

+ +


+

4.67. How do I generate random numbers in Python?

+The standard library module "random" implements a random number +generator. Usage is simple: +

+

+    import random
+
+
+    random.random()
+
+This returns a random floating point number in the range [0, 1). +

+There are also many other specialized generators in this module, such +as +

+

+    randrange(a, b) chooses an integer in the range [a, b)
+    uniform(a, b) chooses a floating point number in the range [a, b)
+    normalvariate(mean, sdev) sample from normal (Gaussian) distribution
+
+Some higher-level functions operate on sequences directly, such as +

+

+    choice(S) chooses random element from a given sequence
+    shuffle(L) shuffles a list in-place, i.e. permutes it randomly
+
+There's also a class, Random, which you can instantiate +to create independent multiple random number generators. +

+All this is documented in the library reference manual. Note that +the module "whrandom" is obsolete. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 01:16:51 2002 by +Neal Norwitz +

+ +


+

4.68. How do I access the serial (RS232) port?

+There's a Windows serial communication module (for communication +over RS 232 serial ports) at +

+

+  ftp://ftp.python.org/pub/python/contrib/sio-151.zip
+  http://www.python.org/ftp/python/contrib/sio-151.zip
+
+For DOS, try Hans Nowak's Python-DX, which supports this, at: +

+

+  http://www.cuci.nl/~hnowak/
+
+For Unix, see a usenet post by Mitch Chapman: +

+

+  http://groups.google.com/groups?selm=34A04430.CF9@ohioee.com
+
+For Win32, POSIX(Linux, BSD, *), Jython, Chris': +

+

+  http://pyserial.sourceforge.net
+
+

+ +Edit this entry / +Log info + +/ Last changed on Tue Jul 2 21:11:07 2002 by +Chris Liechti +

+ +


+

4.69. Images on Tk-Buttons don't work in Py15?

+They do work, but you must keep your own reference to the image +object now. More verbosely, you must make sure that, say, a global +variable or a class attribute refers to the object. +

+Quoting Fredrik Lundh from the mailinglist: +

+

+  Well, the Tk button widget keeps a reference to the internal
+  photoimage object, but Tkinter does not.  So when the last
+  Python reference goes away, Tkinter tells Tk to release the
+  photoimage.  But since the image is in use by a widget, Tk
+  doesn't destroy it.  Not completely.  It just blanks the image,
+  making it completely transparent...
+
+
+  And yes, there was a bug in the keyword argument handling
+  in 1.4 that kept an extra reference around in some cases.  And
+  when Guido fixed that bug in 1.5, he broke quite a few Tkinter
+  programs...
+
+

+ +Edit this entry / +Log info + +/ Last changed on Tue Feb 3 11:31:03 1998 by +Case Roole +

+ +


+

4.70. Where is the math.py (socket.py, regex.py, etc.) source file?

+If you can't find a source file for a module it may be a builtin +or dynamically loaded module implemented in C, C++ or other +compiled language. In this case you may not have the source +file or it may be something like mathmodule.c, somewhere in +a C source directory (not on the Python Path). +

+Fredrik Lundh (fredrik@pythonware.com) explains (on the python-list): +

+There are (at least) three kinds of modules in Python: +1) modules written in Python (.py); +2) modules written in C and dynamically loaded (.dll, .pyd, .so, .sl, etc); +3) modules written in C and linked with the interpreter; to get a list +of these, type: +

+

+    import sys
+    print sys.builtin_module_names
+
+

+ +Edit this entry / +Log info + +/ Last changed on Tue Feb 3 13:55:33 1998 by +Aaron Watters +

+ +


+

4.71. How do I send mail from a Python script?

+The standard library module smtplib does this. +Here's a very simple interactive mail +sender that uses it. This method will work on any host that +supports an SMTP listener. +

+

+    import sys, smtplib
+
+
+    fromaddr = raw_input("From: ")
+    toaddrs  = raw_input("To: ").split(',')
+    print "Enter message, end with ^D:"
+    msg = ''
+    while 1:
+        line = sys.stdin.readline()
+        if not line:
+            break
+        msg = msg + line
+
+
+    # The actual mail send
+    server = smtplib.SMTP('localhost')
+    server.sendmail(fromaddr, toaddrs, msg)
+    server.quit()
+
+If the local host doesn't have an SMTP listener, you need to find one. The simple method is to ask the user. Alternately, you can use the DNS system to find the mail gateway(s) responsible for the source address. +

+A Unix-only alternative uses sendmail. The location of the +sendmail program varies between systems; sometimes it is +/usr/lib/sendmail, sometime /usr/sbin/sendmail. The sendmail manual +page will help you out. Here's some sample code: +

+

+  SENDMAIL = "/usr/sbin/sendmail" # sendmail location
+  import os
+  p = os.popen("%s -t -i" % SENDMAIL, "w")
+  p.write("To: cary@ratatosk.org\n")
+  p.write("Subject: test\n")
+  p.write("\n") # blank line separating headers from body
+  p.write("Some text\n")
+  p.write("some more text\n")
+  sts = p.close()
+  if sts != 0:
+      print "Sendmail exit status", sts
+
+

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 07:05:12 2002 by +Matthias Urlichs +

+ +


+

4.72. How do I avoid blocking in connect() of a socket?

+The select module is widely known to help with asynchronous +I/O on sockets once they are connected. However, it is less +than common knowledge how to avoid blocking on the initial +connect() call. Jeremy Hylton has the following advice (slightly +edited): +

+To prevent the TCP connect from blocking, you can set the socket to +non-blocking mode. Then when you do the connect(), you will either +connect immediately (unlikely) or get an exception that contains the +errno. errno.EINPROGRESS indicates that the connection is in +progress, but hasn't finished yet. Different OSes will return +different errnos, so you're going to have to check. I can tell you +that different versions of Solaris return different errno values. +

+In Python 1.5 and later, you can use connect_ex() to avoid +creating an exception. It will just return the errno value. +

+To poll, you can call connect_ex() again later -- 0 or errno.EISCONN +indicate that you're connected -- or you can pass this socket to +select (checking to see if it is writeable). +

+ +Edit this entry / +Log info + +/ Last changed on Tue Feb 24 21:30:45 1998 by +GvR +

+ +


+

4.73. How do I specify hexadecimal and octal integers?

+To specify an octal digit, precede the octal value with a zero. For example, +to set the variable "a" to the octal value "10" (8 in decimal), type: +

+

+    >>> a = 010
+
+To verify that this works, you can type "a" and hit enter while in the +interpreter, which will cause Python to spit out the current value of "a" +in decimal: +

+

+    >>> a
+    8
+
+Hexadecimal is just as easy. Simply precede the hexadecimal number with a +zero, and then a lower or uppercase "x". Hexadecimal digits can be specified +in lower or uppercase. For example, in the Python interpreter: +

+

+    >>> a = 0xa5
+    >>> a
+    165
+    >>> b = 0XB2
+    >>> b
+    178
+
+

+ +Edit this entry / +Log info + +/ Last changed on Tue Mar 3 12:53:16 1998 by +GvR +

+ +


+

4.74. How to get a single keypress at a time?

+For Windows, see question 8.2. Here is an answer for Unix (see also 4.94). +

+There are several solutions; some involve using curses, which is a +pretty big thing to learn. Here's a solution without curses, due +to Andrew Kuchling (adapted from code to do a PGP-style +randomness pool): +

+

+        import termios, sys, os
+        fd = sys.stdin.fileno()
+        old = termios.tcgetattr(fd)
+        new = termios.tcgetattr(fd)
+        new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
+        new[6][termios.VMIN] = 1
+        new[6][termios.VTIME] = 0
+        termios.tcsetattr(fd, termios.TCSANOW, new)
+        s = ''    # We'll save the characters typed and add them to the pool.
+        try:
+            while 1:
+                c = os.read(fd, 1)
+                print "Got character", `c`
+                s = s+c
+        finally:
+            termios.tcsetattr(fd, termios.TCSAFLUSH, old)
+
+You need the termios module for any of this to work, and I've only +tried it on Linux, though it should work elsewhere. It turns off +stdin's echoing and disables canonical mode, and then reads a +character at a time from stdin, noting the time after each keystroke. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Oct 24 00:36:56 2002 by +chris +

+ +


+

4.75. How can I overload constructors (or methods) in Python?

+(This actually applies to all methods, but somehow the question +usually comes up first in the context of constructors.) +

+Where in C++ you'd write +

+

+    class C {
+        C() { cout << "No arguments\n"; }
+        C(int i) { cout << "Argument is " << i << "\n"; }
+    }
+
+in Python you have to write a single constructor that catches all +cases using default arguments. For example: +

+

+    class C:
+        def __init__(self, i=None):
+            if i is None:
+                print "No arguments"
+            else:
+                print "Argument is", i
+
+This is not entirely equivalent, but close enough in practice. +

+You could also try a variable-length argument list, e.g. +

+

+        def __init__(self, *args):
+            ....
+
+The same approach works for all method definitions. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Apr 20 11:55:55 1998 by +GvR +

+ +


+

4.76. How do I pass keyword arguments from one method to another?

+Use apply. For example: +

+

+    class Account:
+        def __init__(self, **kw):
+            self.accountType = kw.get('accountType')
+            self.balance = kw.get('balance')
+
+
+    class CheckingAccount(Account):
+        def __init__(self, **kw):
+            kw['accountType'] = 'checking'
+            apply(Account.__init__, (self,), kw)
+
+
+    myAccount = CheckingAccount(balance=100.00)
+
+In Python 2.0 you can call it directly using the new ** syntax: +

+

+    class CheckingAccount(Account):
+        def __init__(self, **kw):
+            kw['accountType'] = 'checking'
+            Account.__init__(self, **kw)
+
+or more generally: +

+

+ >>> def f(x, *y, **z):
+ ...  print x,y,z
+ ...
+ >>> Y = [1,2,3]
+ >>> Z = {'foo':3,'bar':None}
+ >>> f('hello', *Y, **Z)
+ hello (1, 2, 3) {'foo': 3, 'bar': None}
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Dec 28 13:04:01 2000 by +Bjorn Pettersen +

+ +


+

4.77. What module should I use to help with generating HTML?

+Check out HTMLgen written by Robin Friedrich. It's a class library +of objects corresponding to all the HTML 3.2 markup tags. It's used +when you are writing in Python and wish to synthesize HTML pages for +generating a web or for CGI forms, etc. +

+It can be found in the FTP contrib area on python.org or on the +Starship. Use the search engines there to locate the latest version. +

+It might also be useful to consider DocumentTemplate, which offers clear +separation between Python code and HTML code. DocumentTemplate is part +of the Bobo objects publishing system (http:/www.digicool.com/releases) +but can be used independantly of course! +

+ +Edit this entry / +Log info + +/ Last changed on Fri Aug 28 09:54:58 1998 by +GvR +

+ +


+

4.78. How do I create documentation from doc strings?

+Use gendoc, by Daniel Larson. See +

+http://starship.python.net/crew/danilo/ +

+It can create HTML from the doc strings in your Python source code. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Oct 7 17:15:51 2002 by +Phil Rittenhouse +

+ +


+

4.79. How do I read (or write) binary data?

+For complex data formats, it's best to use +use the struct module. It's documented in the library reference. +It allows you to take a string read from a file containing binary +data (usually numbers) and convert it to Python objects; and vice +versa. +

+For example, the following code reads two 2-byte integers +and one 4-byte integer in big-endian format from a file: +

+

+  import struct
+
+
+  f = open(filename, "rb")  # Open in binary mode for portability
+  s = f.read(8)
+  x, y, z = struct.unpack(">hhl", s)
+
+The '>' in the format string forces bin-endian data; the letter +'h' reads one "short integer" (2 bytes), and 'l' reads one +"long integer" (4 bytes) from the string. +

+For data that is more regular (e.g. a homogeneous list of ints or +floats), you can also use the array module, also documented +in the library reference. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Oct 7 09:16:45 1998 by +GvR +

+ +


+

4.80. I can't get key bindings to work in Tkinter

+An oft-heard complaint is that event handlers bound to events +with the bind() method don't get handled even when the appropriate +key is pressed. +

+The most common cause is that the widget to which the binding applies +doesn't have "keyboard focus". Check out the Tk documentation +for the focus command. Usually a widget is given the keyboard +focus by clicking in it (but not for labels; see the taketocus +option). +

+ +Edit this entry / +Log info + +/ Last changed on Fri Jun 12 09:37:33 1998 by +GvR +

+ +


+

4.81. "import crypt" fails

+[Unix] +

+Starting with Python 1.5, the crypt module is disabled by default. +In order to enable it, you must go into the Python source tree and +edit the file Modules/Setup to enable it (remove a '#' sign in +front of the line starting with '#crypt'). Then rebuild. +You may also have to add the string '-lcrypt' to that same line. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Aug 5 08:57:09 1998 by +GvR +

+ +


+

4.82. Are there coding standards or a style guide for Python programs?

+Yes, Guido has written the "Python Style Guide". See +http://www.python.org/doc/essays/styleguide.html +

+ +Edit this entry / +Log info + +/ Last changed on Tue Sep 29 09:50:27 1998 by +Joseph VanAndel +

+ +


+

4.83. How do I freeze Tkinter applications?

+Freeze is a tool to create stand-alone applications (see 4.28). +

+When freezing Tkinter applications, the applications will not be +truly stand-alone, as the application will still need the tcl and +tk libraries. +

+One solution is to ship the application with the tcl and tk libraries, +and point to them at run-time using the TCL_LIBRARY and TK_LIBRARY +environment variables. +

+To get truly stand-alone applications, the Tcl scripts that form +the library have to be integrated into the application as well. One +tool supporting that is SAM (stand-alone modules), which is part +of the Tix distribution (http://tix.mne.com). Build Tix with SAM +enabled, perform the appropriate call to Tclsam_init etc inside +Python's Modules/tkappinit.c, and link with libtclsam +and libtksam (you might include the Tix libraries as well). +

+ +Edit this entry / +Log info + +/ Last changed on Wed Jan 20 17:35:01 1999 by +Martin v. Löwis +

+ +


+

4.84. How do I create static class data and static class methods?

+[Tim Peters, tim_one@email.msn.com] +

+Static data (in the sense of C++ or Java) is easy; static methods (again in the sense of C++ or Java) are not supported directly. +

+STATIC DATA +

+For example, +

+

+    class C:
+        count = 0   # number of times C.__init__ called
+
+
+        def __init__(self):
+            C.count = C.count + 1
+
+
+        def getcount(self):
+            return C.count  # or return self.count
+
+c.count also refers to C.count for any c such that isinstance(c, C) holds, unless overridden by c itself or by some class on the base-class search path from c.__class__ back to C. +

+Caution: within a method of C, +

+

+    self.count = 42
+
+creates a new and unrelated instance vrbl named "count" in self's own dict. So rebinding of a class-static data name needs the +

+

+    C.count = 314
+
+form whether inside a method or not. +

+

+STATIC METHODS +

+Static methods (as opposed to static data) are unnatural in Python, because +

+

+    C.getcount
+
+returns an unbound method object, which can't be invoked without supplying an instance of C as the first argument. +

+The intended way to get the effect of a static method is via a module-level function: +

+

+    def getcount():
+        return C.count
+
+If your code is structured so as to define one class (or tightly related class hierarchy) per module, this supplies the desired encapsulation. +

+Several tortured schemes for faking static methods can be found by searching DejaNews. Most people feel such cures are worse than the disease. Perhaps the least obnoxious is due to Pekka Pessi (mailto:ppessi@hut.fi): +

+

+    # helper class to disguise function objects
+    class _static:
+        def __init__(self, f):
+            self.__call__ = f
+
+
+    class C:
+        count = 0
+
+
+        def __init__(self):
+            C.count = C.count + 1
+
+
+        def getcount():
+            return C.count
+        getcount = _static(getcount)
+
+
+        def sum(x, y):
+            return x + y
+        sum = _static(sum)
+
+
+    C(); C()
+    c = C()
+    print C.getcount()  # prints 3
+    print c.getcount()  # prints 3
+    print C.sum(27, 15) # prints 42
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Jan 21 21:35:38 1999 by +Tim Peters +

+ +


+

4.85. __import__('x.y.z') returns <module 'x'>; how do I get z?

+Try +

+

+   __import__('x.y.z').y.z
+
+For more realistic situations, you may have to do something like +

+

+   m = __import__(s)
+   for i in string.split(s, ".")[1:]:
+       m = getattr(m, i)
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Jan 28 11:01:43 1999 by +GvR +

+ +


+

4.86. Basic thread wisdom

+Please note that there is no way to take advantage of +multiprocessor hardware using the Python thread model. The interpreter +uses a global interpreter lock (GIL), +which does not allow multiple threads to be concurrently active. +

+If you write a simple test program like this: +

+

+  import thread
+  def run(name, n):
+      for i in range(n): print name, i
+  for i in range(10):
+      thread.start_new(run, (i, 100))
+
+none of the threads seem to run! The reason is that as soon as +the main thread exits, all threads are killed. +

+A simple fix is to add a sleep to the end of the program, +sufficiently long for all threads to finish: +

+

+  import thread, time
+  def run(name, n):
+      for i in range(n): print name, i
+  for i in range(10):
+      thread.start_new(run, (i, 100))
+  time.sleep(10) # <----------------------------!
+
+But now (on many platforms) the threads don't run in parallel, +but appear to run sequentially, one at a time! The reason is +that the OS thread scheduler doesn't start a new thread until +the previous thread is blocked. +

+A simple fix is to add a tiny sleep to the start of the run +function: +

+

+  import thread, time
+  def run(name, n):
+      time.sleep(0.001) # <---------------------!
+      for i in range(n): print name, i
+  for i in range(10):
+      thread.start_new(run, (i, 100))
+  time.sleep(10)
+
+Some more hints: +

+Instead of using a time.sleep() call at the end, it's +better to use some kind of semaphore mechanism. One idea is to +use a the Queue module to create a queue object, let each thread +append a token to the queue when it finishes, and let the main +thread read as many tokens from the queue as there are threads. +

+Use the threading module instead of the thread module. It's part +of Python since version 1.5.1. It takes care of all these details, +and has many other nice features too! +

+ +Edit this entry / +Log info + +/ Last changed on Fri Feb 7 16:21:55 2003 by +GvR +

+ +


+

4.87. Why doesn't closing sys.stdout (stdin, stderr) really close it?

+Python file objects are a high-level layer of abstraction on top of C streams, which in turn are a medium-level layer of abstraction on top of (among other things) low-level C file descriptors. +

+For most file objects f you create in Python via the builtin "open" function, f.close() marks the Python file object as being closed from Python's point of view, and also arranges to close the underlying C stream. This happens automatically too, in f's destructor, when f becomes garbage. +

+But stdin, stdout and stderr are treated specially by Python, because of the special status also given to them by C: doing +

+

+    sys.stdout.close() # ditto for stdin and stderr
+
+marks the Python-level file object as being closed, but does not close the associated C stream (provided sys.stdout is still bound to its default value, which is the stream C also calls "stdout"). +

+To close the underlying C stream for one of these three, you should first be sure that's what you really want to do (e.g., you may confuse the heck out of extension modules trying to do I/O). If it is, use os.close: +

+

+    os.close(0)   # close C's stdin stream
+    os.close(1)   # close C's stdout stream
+    os.close(2)   # close C's stderr stream
+
+

+ +Edit this entry / +Log info + +/ Last changed on Sat Apr 17 02:22:35 1999 by +Tim Peters +

+ +


+

4.88. What kinds of global value mutation are thread-safe?

+[adapted from c.l.py responses by Gordon McMillan & GvR] +

+A global interpreter lock (GIL) is used internally to ensure that only one thread runs in the Python VM at a time. In general, Python offers to switch among threads only between bytecode instructions (how frequently it offers to switch can be set via sys.setcheckinterval). Each bytecode instruction-- and all the C implementation code reached from it --is therefore atomic. +

+In theory, this means an exact accounting requires an exact understanding of the PVM bytecode implementation. In practice, it means that operations on shared vrbls of builtin data types (ints, lists, dicts, etc) that "look atomic" really are. +

+For example, these are atomic (L, L1, L2 are lists, D, D1, D2 are dicts, x, y +are objects, i, j are ints): +

+

+    L.append(x)
+    L1.extend(L2)
+    x = L[i]
+    x = L.pop()
+    L1[i:j] = L2
+    L.sort()
+    x = y
+    x.field = y
+    D[x] = y
+    D1.update(D2)
+    D.keys()
+
+These aren't: +

+

+    i = i+1
+    L.append(L[-1])
+    L[i] = L[j]
+    D[x] = D[x] + 1
+
+Note: operations that replace other objects may invoke those other objects' __del__ method when their reference count reaches zero, and that can affect things. This is especially true for the mass updates to dictionaries and lists. When in doubt, use a mutex! +

+ +Edit this entry / +Log info + +/ Last changed on Fri Feb 7 16:21:03 2003 by +GvR +

+ +


+

4.89. How do I modify a string in place?

+Strings are immutable (see question 6.2) so you cannot modify a string +directly. If you need an object with this ability, try converting the +string to a list or take a look at the array module. +

+

+    >>> s = "Hello, world"
+    >>> a = list(s)
+    >>> print a
+    ['H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd']
+    >>> a[7:] = list("there!")
+    >>> import string
+    >>> print string.join(a, '')
+    'Hello, there!'
+
+
+    >>> import array
+    >>> a = array.array('c', s)
+    >>> print a
+    array('c', 'Hello, world')
+    >>> a[0] = 'y' ; print a
+    array('c', 'yello world')
+    >>> a.tostring()
+    'yello, world'
+
+

+ +Edit this entry / +Log info + +/ Last changed on Tue May 18 01:22:47 1999 by +Andrew Dalke +

+ +


+

4.90. How to pass on keyword/optional parameters/arguments

+Q: How can I pass on optional or keyword parameters from one function to another? +

+

+	def f1(a, *b, **c):
+		...
+
+A: In Python 2.0 and above: +

+

+	def f2(x, *y, **z):
+		...
+		z['width']='14.3c'
+		...
+		f1(x, *y, **z)
+
+
+   Note: y can be any sequence (e.g., list or tuple) and z must be a dict.
+
+

+A: For versions prior to 2.0, use 'apply', like: +

+

+	def f2(x, *y, **z):
+		...
+		z['width']='14.3c'
+		...
+		apply(f1, (x,)+y, z)
+
+

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 07:20:56 2002 by +Matthias Urlichs +

+ +


+

4.91. How can I get a dictionary to display its keys in a consistent order?

+In general, dictionaries store their keys in an unpredictable order, +so the display order of a dictionary's elements will be similarly +unpredictable. +(See +Question 6.12 +to understand why this is so.) +

+This can be frustrating if you want to save a printable version to a +file, make some changes and then compare it with some other printed +dictionary. If you have such needs you can subclass UserDict.UserDict +to create a SortedDict class that prints itself in a predictable order. +Here's one simpleminded implementation of such a class: +

+

+  import UserDict, string
+
+
+  class SortedDict(UserDict.UserDict):
+    def __repr__(self):
+      result = []
+      append = result.append
+      keys = self.data.keys()
+      keys.sort()
+      for k in keys:
+        append("%s: %s" % (`k`, `self.data[k]`))
+      return "{%s}" % string.join(result, ", ")
+
+
+    ___str__ = __repr__
+
+

+This will work for many common situations you might encounter, though +it's far from a perfect solution. (It won't have any effect on the +pprint module and does not transparently handle values that are or +contain dictionaries. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Sep 16 17:31:06 1999 by +Skip Montanaro +

+ +


+

4.92. Is there a Python tutorial?

+Yes. See question 1.20 at +http://www.python.org/doc/FAQ.html#1.20 +

+ +Edit this entry / +Log info + +/ Last changed on Sat Dec 4 16:04:00 1999 by +TAB +

+ +


+

4.93. Deleted

+See 4.28 +

+ +Edit this entry / +Log info + +/ Last changed on Tue May 28 20:40:37 2002 by +GvR +

+ +


+

4.94. How do I get a single keypress without blocking?

+There are several solutions; some involve using curses, which is a +pretty big thing to learn. Here's a solution without curses. (see also 4.74, for Windows, see question 8.2) +

+

+  import termios, fcntl, sys, os
+  fd = sys.stdin.fileno()
+
+
+  oldterm = termios.tcgetattr(fd)
+  newattr = termios.tcgetattr(fd)
+  newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
+  termios.tcsetattr(fd, termios.TCSANOW, newattr)
+
+
+  oldflags = fcntl.fcntl(fd, fcntl.F_GETFL)
+  fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK)
+
+
+  try:
+      while 1:
+          try:
+              c = sys.stdin.read(1)
+              print "Got character", `c`
+          except IOError: pass
+  finally:
+      termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)
+      fcntl.fcntl(fd, fcntl.F_SETFL, oldflags)
+
+

+You need the termios and the fcntl module for any of this to work, +and I've only tried it on Linux, though it should work elsewhere. +

+In this code, characters are read and printed one at a time. +

+termios.tcsetattr() turns off stdin's echoing and disables canonical +mode. fcntl.fnctl() is used to obtain stdin's file descriptor flags +and modify them for non-blocking mode. Since reading stdin when it is +empty results in an IOError, this error is caught and ignored. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Oct 24 00:39:06 2002 by +chris +

+ +


+

4.95. Is there an equivalent to Perl chomp()? (Remove trailing newline from string)

+There are two partial substitutes. If you want to remove all trailing +whitespace, use the method string.rstrip(). Otherwise, if there is only +one line in the string, use string.splitlines()[0]. +

+

+ -----------------------------------------------------------------------
+
+
+ rstrip() is too greedy, it strips all trailing white spaces.
+ splitlines() takes ControlM as line boundary.
+ Consider these strings as input:
+   "python python    \r\n"
+   "python\rpython\r\n"
+   "python python   \r\r\r\n"
+ The results from rstrip()/splitlines() are perhaps not what we want.
+
+
+ It seems re can perform this task.
+
+

+

+ #!/usr/bin/python 
+ # requires python2                                                             
+
+
+ import re, os, StringIO
+
+
+ lines=StringIO.StringIO(
+   "The Python Programming Language\r\n"
+   "The Python Programming Language \r \r \r\r\n"
+   "The\rProgramming\rLanguage\r\n"
+   "The\rProgramming\rLanguage\r\r\r\r\n"
+   "The\r\rProgramming\r\rLanguage\r\r\r\r\n"
+ )
+
+
+ ln=re.compile("(?:[\r]?\n|\r)$") # dos:\r\n, unix:\n, mac:\r, others: unknown
+ # os.linesep does not work if someone ftps(in binary mode) a dos/mac text file
+ # to your unix box
+ #ln=re.compile(os.linesep + "$")
+
+
+ while 1:
+   s=lines.readline()
+   if not s: break
+   print "1.(%s)" % `s.rstrip()`
+   print "2.(%s)" % `ln.sub( "", s, 1)`
+   print "3.(%s)" % `s.splitlines()[0]`
+   print "4.(%s)" % `s.splitlines()`
+   print
+
+
+ lines.close()
+
+

+ +Edit this entry / +Log info + +/ Last changed on Wed Aug 8 09:51:34 2001 by +Crystal +

+ +


+

4.96. Why is join() a string method when I'm really joining the elements of a (list, tuple, sequence)?

+Strings became much more like other standard types starting in release 1.6, when methods were added which give the same functionality that has always been available using the functions of the string module. These new methods have been widely accepted, but the one which appears to make (some) programmers feel uncomfortable is: +

+

+    ", ".join(['1', '2', '4', '8', '16'])
+
+which gives the result +

+

+    "1, 2, 4, 8, 16"
+
+There are two usual arguments against this usage. +

+The first runs along the lines of: "It looks really ugly using a method of a string literal (string constant)", to which the answer is that it might, but a string literal is just a fixed value. If the methods are to be allowed on names bound to strings there is no logical reason to make them unavailable on literals. Get over it! +

+The second objection is typically cast as: "I am really telling a sequence to join its members together with a string constant". Sadly, you aren't. For some reason there seems to be much less difficulty with having split() as a string method, since in that case it is easy to see that +

+

+    "1, 2, 4, 8, 16".split(", ")
+
+is an instruction to a string literal to return the substrings delimited by the given separator (or, by default, arbitrary runs of white space). In this case a Unicode string returns a list of Unicode strings, an ASCII string returns a list of ASCII strings, and everyone is happy. +

+join() is a string method because in using it you are telling the separator string to iterate over an arbitrary sequence, forming string representations of each of the elements, and inserting itself between the elements' representations. This method can be used with any argument which obeys the rules for sequence objects, inluding any new classes you might define yourself. +

+Because this is a string method it can work for Unicode strings as well as plain ASCII strings. If join() were a method of the sequence types then the sequence types would have to decide which type of string to return depending on the type of the separator. +

+If none of these arguments persuade you, then for the moment you can continue to use the join() function from the string module, which allows you to write +

+

+    string.join(['1', '2', '4', '8', '16'], ", ")
+
+You will just have to try and forget that the string module actually uses the syntax you are compaining about to implement the syntax you prefer! +

+ +Edit this entry / +Log info + +/ Last changed on Fri Aug 2 15:51:58 2002 by +Steve Holden +

+ +


+

4.97. How can my code discover the name of an object?

+Generally speaking, it can't, because objects don't really have names. The assignment statement does not store the assigned value in the name but a reference to it. Essentially, assignment creates a binding of a name to a value. The same is true of def and class statements, but in that case the value is a callable. Consider the following code: +

+

+    class A:
+        pass
+
+
+    B = A
+
+
+    a = B()
+    b = a
+    print b
+    <__main__.A instance at 016D07CC>
+    print a
+    <__main__.A instance at 016D07CC>
+
+

+Arguably the class has a name: even though it is bound to two names and invoked through the name B the created instance is still reported as an instance of class A. However, it is impossible to say whether the instance's name is a or b, since both names are bound to the same value. +

+Generally speaking it should not be necessary for your code to "know the names" of particular values. Unless you are deliberately writing introspective programs, this is usually an indication that a change of approach might be beneficial. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Mar 8 03:53:39 2001 by +Steve Holden +

+ +


+

4.98. Why are floating point calculations so inaccurate?

+The development version of the Python Tutorial now contains an Appendix with more info: +
+    http://www.python.org/doc/current/tut/node14.html
+
+People are often very surprised by results like this: +

+

+ >>> 1.2-1.0
+ 0.199999999999999996
+
+And think it is a bug in Python. It's not. It's a problem caused by +the internal representation of a floating point number. A floating point +number is stored as a fixed number of binary digits. +

+In decimal math, there are many numbers that can't be represented +with a fixed number of decimal digits, i.e. +1/3 = 0.3333333333....... +

+In the binary case, 1/2 = 0.1, 1/4 = 0.01, 1/8 = 0.001, etc. There are +a lot of numbers that can't be represented. The digits are cut off at +some point. +

+Since Python 1.6, a floating point's repr() function prints as many +digits are necessary to make eval(repr(f)) == f true for any float f. +The str() function prints the more sensible number that was probably +intended: +

+

+ >>> 0.2
+ 0.20000000000000001
+ >>> print 0.2
+ 0.2
+
+Again, this has nothing to do with Python, but with the way the +underlying C platform handles floating points, and ultimately with +the inaccuracy you'll always have when writing down numbers of fixed +number of digit strings. +

+One of the consequences of this is that it is dangerous to compare +the result of some computation to a float with == ! +Tiny inaccuracies may mean that == fails. +

+Instead try something like this: +

+

+ epsilon = 0.0000000000001 # Tiny allowed error
+ expected_result = 0.4
+
+
+ if expected_result-epsilon <= computation() <= expected_result+epsilon:
+    ...
+
+

+ +Edit this entry / +Log info + +/ Last changed on Mon Apr 1 22:18:47 2002 by +Fred Drake +

+ +


+

4.99. I tried to open Berkeley DB file, but bsddb produces bsddb.error: (22, 'Invalid argument'). Help! How can I restore my data?

+Don't panic! Your data are probably intact. The most frequent cause +for the error is that you tried to open an earlier Berkeley DB file +with a later version of the Berkeley DB library. +

+Many Linux systems now have all three versions of Berkeley DB +available. If you are migrating from version 1 to a newer version use +db_dump185 to dump a plain text version of the database. +If you are migrating from version 2 to version 3 use db2_dump to create +a plain text version of the database. In either case, use db_load to +create a new native database for the latest version installed on your +computer. If you have version 3 of Berkeley DB installed, you should +be able to use db2_load to create a native version 2 database. +

+You should probably move away from Berkeley DB version 1 files because +the hash file code contains known bugs that can corrupt your data. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Aug 29 16:04:29 2001 by +Skip Montanaro +

+ +


+

4.100. What are the "best practices" for using import in a module?

+First, the standard modules are great. Use them! The standard Python library is large and varied. Using modules can save you time and effort and will reduce maintainenance cost of your code. (Other programs are dedicated to supporting and fixing bugs in the standard Python modules. Coworkers may also be familiar with themodules that you use, reducing the amount of time it takes them to understand your code.) +

+The rest of this answer is largely a matter of personal preference, but here's what some newsgroup posters said (thanks to all who responded) +

+In general, don't use +

+ from modulename import *
+
+Doing so clutters the importer's namespace. Some avoid this idiom even with the few modules that were designed to be imported in this manner. (Modules designed in this manner include Tkinter, thread, and wxPython.) +

+Import modules at the top of a file, one module per line. Doing so makes it clear what other modules your code requires and avoids questions of whether the module name is in scope. Using one import per line makes it easy to add and delete module imports. +

+Move imports into a local scope (such as at the top of a function definition) if there are a lot of imports, and you're trying to avoid the cost (lots of initialization time) of many imports. This technique is especially helpful if many of the imports are unnecessary depending on how the program executes. You may also want to move imports into a function if the modules are only ever used in that function. Note that loading a module the first time may be expensive (because of the one time initialization of the module) but that loading a module multiple times is virtually free (a couple of dictionary lookups). Even if the module name has gone out of scope, the module is probably available in sys.modules. Thus, there isn't really anything wrong with putting no imports at the module level (if they aren't needed) and putting all of the imports at the function level. +

+It is sometimes necessary to move imports to a function or class to avoid problems with circular imports. Gordon says: +

+ Circular imports are fine where both modules use the "import <module>"
+ form of import. They fail when the 2nd module wants to grab a name
+ out of the first ("from module import name") and the import is at
+ the top level. That's because names in the 1st are not yet available,
+ (the first module is busy importing the 2nd).  
+
+In this case, if the 2nd module is only used in one function, then the import can easily be moved into that function. By the time the import is called, the first module will have finished initializing, and the second module can do its import. +

+It may also be necessary to move imports out of the top level of code +if some of the modules are platform-specific. In that case, it may not even be possible to import all of the modules at the top of the file. In this case, importing the correct modules in the corresponding platform-specific code is a good option. +

+If only instances of a specific class uses a module, then it is reasonable to import the module in the class's __init__ method and then assign the module to an instance variable so that the module is always available (via that instance variable) during the life of the object. Note that to delay an import until the class is instantiated, the import must be inside a method. Putting the import inside the class but outside of any method still causes the import to occur when the module is initialized. +

+ +Edit this entry / +Log info + +/ Last changed on Sat Aug 4 04:44:47 2001 by +TAB +

+ +


+

4.101. Is there a tool to help find bugs or perform static analysis?

+Yes. PyChecker is a static analysis tool for finding bugs +in Python source code as well as warning about code complexity +and style. +

+You can get PyChecker from: http://pychecker.sf.net. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Aug 10 15:42:11 2001 by +Neal +

+ +


+

4.102. UnicodeError: ASCII [decoding,encoding] error: ordinal not in range(128)

+This error indicates that your Python installation can handle +only 7-bit ASCII strings. There are a couple ways to fix or +workaround the problem. +

+If your programs must handle data in arbitary character set encodings, the environment the application runs in will generally identify the encoding of the data it is handing you. You need to convert the input to Unicode data using that encoding. For instance, a program that handles email or web input will typically find character set encoding information in Content-Type headers. This can then be used to properly convert input data to Unicode. Assuming the string referred to by "value" is encoded as UTF-8: +

+

+    value = unicode(value, "utf-8")
+
+will return a Unicode object. If the data is not correctly encoded as UTF-8, the above call will raise a UnicodeError. +

+If you only want strings coverted to Unicode which have non-ASCII data, you can try converting them first assuming an ASCII encoding, and then generate Unicode objects if that fails: +

+

+    try:
+        x = unicode(value, "ascii")
+    except UnicodeError:
+        value = unicode(value, "utf-8")
+    else:
+        # value was valid ASCII data
+        pass
+
+

+If you normally use a character set encoding other than US-ASCII and only need to handle data in that encoding, the simplest way to fix the problem may be simply to set the encoding in sitecustomize.py. The following code is just a modified version of the encoding setup code from site.py with the relevant lines uncommented. +

+

+    # Set the string encoding used by the Unicode implementation.
+    # The default is 'ascii'
+    encoding = "ascii" # <= CHANGE THIS if you wish
+
+
+    # Enable to support locale aware default string encodings.
+    import locale
+    loc = locale.getdefaultlocale()
+    if loc[1]:
+        encoding = loc[1]
+    if encoding != "ascii":
+        import sys
+        sys.setdefaultencoding(encoding)
+
+

+Also note that on Windows, there is an encoding known as "mbcs", which uses an encoding specific to your current locale. In many cases, and particularly when working with COM, this may be an appropriate default encoding to use. +

+ +Edit this entry / +Log info + +/ Last changed on Sat Apr 13 04:45:41 2002 by +Skip Montanaro +

+ +


+

4.103. Using strings to call functions/methods

+There are various techniques: +

+* Use a dictionary pre-loaded with strings and functions. The primary +advantage of this technique is that the strings do not need to match the +names of the functions. This is also the primary technique used to +emulate a case construct: +

+

+    def a():
+        pass
+
+
+    def b():
+        pass
+
+
+    dispatch = {'go': a, 'stop': b}  # Note lack of parens for funcs
+
+
+    dispatch[get_input()]()  # Note trailing parens to call function
+
+* Use the built-in function getattr(): +

+

+    import foo
+    getattr(foo, 'bar')()
+
+Note that getattr() works on any object, including classes, class +instances, modules, and so on. +

+This is used in several places in the standard library, like +this: +

+

+    class Foo:
+        def do_foo(self):
+            ...
+
+
+        def do_bar(self):
+            ...
+
+
+     f = getattr(foo_instance, 'do_' + opname)
+     f()
+
+

+* Use locals() or eval() to resolve the function name: +

+def myFunc(): +

+    print "hello"
+
+fname = "myFunc" +

+f = locals()[fname] +f() +

+f = eval(fname) +f() +

+Note: Using eval() can be dangerous. If you don't have absolute control +over the contents of the string, all sorts of things could happen... +

+ +Edit this entry / +Log info + +/ Last changed on Thu Mar 21 08:14:58 2002 by +Erno Kuusela +

+ +


+

4.104. How fast are exceptions?

+A try/except block is extremely efficient. Actually executing an +exception is expensive. In older versions of Python (prior to 2.0), it +was common to code this idiom: +

+

+    try:
+        value = dict[key]
+    except KeyError:
+        dict[key] = getvalue(key)
+        value = dict[key]
+
+This idiom only made sense when you expected the dict to have the key +95% of the time or more; other times, you coded it like this: +

+

+    if dict.has_key(key):
+        value = dict[key]
+    else:
+        dict[key] = getvalue(key)
+        value = dict[key]
+
+In Python 2.0 and higher, of course, you can code this as +

+

+    value = dict.setdefault(key, getvalue(key))
+
+However this evaluates getvalue(key) always, regardless of whether it's needed or not. So if it's slow or has a side effect you should use one of the above variants. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Dec 9 10:12:30 2002 by +Yeti +

+ +


+

4.105. Sharing global variables across modules

+The canonical way to share information across modules within a single +program is to create a special module (often called config or cfg). +Just import the config module in all modules of your application; the +module then becomes available as a global name. Because there is only +one instance of each module, any changes made to the module object get +reflected everywhere. For example: +

+config.py: +

+

+    pass
+
+mod.py: +

+

+    import config
+    config.x = 1
+
+main.py: +

+

+    import config
+    import mod
+    print config.x
+
+Note that using a module is also the basis for implementing the +Singleton design pattern, for the same reason. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Apr 23 23:07:19 2002 by +Aahz +

+ +


+

4.106. Why is cPickle so slow?

+Use the binary option. We'd like to make that the default, but it would +break backward compatibility: +

+

+    largeString = 'z' * (100 * 1024)
+    myPickle = cPickle.dumps(largeString, 1)
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Aug 22 19:54:25 2002 by +Aahz +

+ +


+

4.107. When importing module XXX, why do I get "undefined symbol: PyUnicodeUCS2_..." ?

+You are using a version of Python that uses a 4-byte representation for +Unicode characters, but the extension module you are importing (possibly +indirectly) was compiled using a Python that uses a 2-byte representation +for Unicode characters (the default). +

+If instead the name of the undefined symbol starts with PyUnicodeUCS4_, +the problem is the same by the relationship is reversed: Python was +built using 2-byte Unicode characters, and the extension module was +compiled using a Python with 4-byte Unicode characters. +

+This can easily occur when using pre-built extension packages. RedHat +Linux 7.x, in particular, provides a "python2" binary that is compiled +with 4-byte Unicode. This only causes the link failure if the extension +uses any of the PyUnicode_*() functions. It is also a problem if if an +extension uses any of the Unicode-related format specifiers for +Py_BuildValue (or similar) or parameter-specifications for +PyArg_ParseTuple(). +

+You can check the size of the Unicode character a Python interpreter is +using by checking the value of sys.maxunicode: +

+

+  >>> import sys
+  >>> if sys.maxunicode > 65535:
+  ...     print 'UCS4 build'
+  ... else:
+  ...     print 'UCS2 build'
+
+The only way to solve this problem is to use extension modules compiled +with a Python binary built using the same size for Unicode characters. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Aug 27 15:00:17 2002 by +Fred Drake +

+ +


+

4.108. How do I create a .pyc file?

+QUESTION: +

+I have a module and I wish to generate a .pyc file. +How do I do it? Everything I read says that generation of a .pyc file is +"automatic", but I'm not getting anywhere. +

+

+ANSWER: +

+When a module is imported for the first time (or when the source is more +recent than the current compiled file) a .pyc file containing the compiled code should be created in the +same directory as the .py file. +

+One reason that a .pyc file may not be created is permissions problems with the directory. This can happen, for example, if you develop as one user but run as another, such as if you are testing with a web server. +

+However, in most cases, that's not the problem. +

+Creation of a .pyc file is "automatic" if you are importing a module and Python has the +ability (permissions, free space, etc...) to write the compiled module +back to the directory. But note that running Python on a top level script is not considered an +import and so no .pyc will be created automatically. For example, if you have a top-level module abc.py that imports another module xyz.py, when you run abc, xyz.pyc will be created since xyz is imported, but no abc.pyc file will be created since abc isn't imported. +

+If you need to create abc.pyc -- that is, to create a .pyc file for a +module that is not imported -- you can. (Look up +the py_compile and compileall modules in the Library Reference.) +

+You can manually compile any module using the "py_compile" module. One +way is to use the compile() function in that module interactively: +

+

+    >>> import py_compile
+    >>> py_compile.compile('abc.py')
+
+This will write the .pyc to the same location as abc.py (or you +can override that with the optional parameter cfile). +

+You can also automatically compile all files in a directory or +directories using the "compileall" module, which can also be run +straight from the command line. +

+You can do it from the shell (or DOS) prompt by entering: +

+       python compile.py abc.py
+
+or +
+       python compile.py *
+
+Or you can write a script to do it on a list of filenames that you enter. +

+

+     import sys
+     from py_compile import compile
+
+
+     if len(sys.argv) <= 1:
+        sys.exit(1)
+
+
+     for file in sys.argv[1:]:
+        compile(file)
+
+ACKNOWLEDGMENTS: +

+Steve Holden, David Bolen, Rich Somerfield, Oleg Broytmann, Steve Ferg +

+ +Edit this entry / +Log info + +/ Last changed on Wed Feb 12 15:58:25 2003 by +Stephen Ferg +

+ +


+

5. Extending Python

+ +
+

5.1. Can I create my own functions in C?

+Yes, you can create built-in modules containing functions, +variables, exceptions and even new types in C. This is explained in +the document "Extending and Embedding the Python Interpreter" (http://www.python.org/doc/current/ext/ext.html). Also read the chapter +on dynamic loading. +

+There's more information on this in each of the Python books: +Programming Python, Internet Programming with Python, and Das Python-Buch +(in German). +

+ +Edit this entry / +Log info + +/ Last changed on Mon Dec 10 05:18:57 2001 by +Fred L. Drake, Jr. +

+ +


+

5.2. Can I create my own functions in C++?

+Yes, using the C-compatibility features found in C++. Basically +you place extern "C" { ... } around the Python include files and put +extern "C" before each function that is going to be called by the +Python interpreter. Global or static C++ objects with constructors +are probably not a good idea. +

+ +Edit this entry / +Log info +

+ +


+

5.3. How can I execute arbitrary Python statements from C?

+The highest-level function to do this is PyRun_SimpleString() which takes +a single string argument which is executed in the context of module +__main__ and returns 0 for success and -1 when an exception occurred +(including SyntaxError). If you want more control, use PyRun_String(); +see the source for PyRun_SimpleString() in Python/pythonrun.c. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 23 20:08:14 1997 by +Bill Tutt +

+ +


+

5.4. How can I evaluate an arbitrary Python expression from C?

+Call the function PyRun_String() from the previous question with the +start symbol eval_input (Py_eval_input starting with 1.5a1); it +parses an expression, evaluates it and returns its value. +

+ +Edit this entry / +Log info + +/ Last changed on Wed May 21 22:23:18 1997 by +David Ascher +

+ +


+

5.5. How do I extract C values from a Python object?

+That depends on the object's type. If it's a tuple, +PyTupleSize(o) returns its length and PyTuple_GetItem(o, i) +returns its i'th item; similar for lists with PyListSize(o) +and PyList_GetItem(o, i). For strings, PyString_Size(o) returns +its length and PyString_AsString(o) a pointer to its value +(note that Python strings may contain null bytes so strlen() +is not safe). To test which type an object is, first make sure +it isn't NULL, and then use PyString_Check(o), PyTuple_Check(o), +PyList_Check(o), etc. +

+There is also a high-level API to Python objects which is +provided by the so-called 'abstract' interface -- read +Include/abstract.h for further details. It allows for example +interfacing with any kind of Python sequence (e.g. lists and tuples) +using calls like PySequence_Length(), PySequence_GetItem(), etc.) +as well as many other useful protocols. +

+ +Edit this entry / +Log info + +/ Last changed on Wed May 21 22:34:20 1997 by +David Ascher +

+ +


+

5.6. How do I use Py_BuildValue() to create a tuple of arbitrary length?

+You can't. Use t = PyTuple_New(n) instead, and fill it with +objects using PyTuple_SetItem(t, i, o) -- note that this "eats" a +reference count of o. Similar for lists with PyList_New(n) and +PyList_SetItem(l, i, o). Note that you must set all the tuple items to +some value before you pass the tuple to Python code -- +PyTuple_New(n) initializes them to NULL, which isn't a valid Python +value. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jul 31 18:15:29 1997 by +Guido van Rossum +

+ +


+

5.7. How do I call an object's method from C?

+The PyObject_CallMethod() function can be used to call an arbitrary +method of an object. The parameters are the object, the name of the +method to call, a format string like that used with Py_BuildValue(), and the argument values: +

+

+    PyObject *
+    PyObject_CallMethod(PyObject *object, char *method_name,
+                        char *arg_format, ...);
+
+This works for any object that has methods -- whether built-in or +user-defined. You are responsible for eventually DECREF'ing the +return value. +

+To call, e.g., a file object's "seek" method with arguments 10, 0 +(assuming the file object pointer is "f"): +

+

+        res = PyObject_CallMethod(f, "seek", "(ii)", 10, 0);
+        if (res == NULL) {
+                ... an exception occurred ...
+        }
+        else {
+                Py_DECREF(res);
+        }
+
+Note that since PyObject_CallObject() always wants a tuple for the +argument list, to call a function without arguments, pass "()" for the +format, and to call a function with one argument, surround the argument +in parentheses, e.g. "(i)". +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jun 6 16:15:46 2002 by +Neal Norwitz +

+ +


+

5.8. How do I catch the output from PyErr_Print() (or anything that prints to stdout/stderr)?

+(Due to Mark Hammond): +

+In Python code, define an object that supports the "write()" method. +Redirect sys.stdout and sys.stderr to this object. +Call print_error, or just allow the standard traceback mechanism to +work. Then, the output will go wherever your write() method sends it. +

+The easiest way to do this is to use the StringIO class in the standard +library. +

+Sample code and use for catching stdout: +

+	>>> class StdoutCatcher:
+	...  def __init__(self):
+	...   self.data = ''
+	...  def write(self, stuff):
+	...   self.data = self.data + stuff
+	...  
+	>>> import sys
+	>>> sys.stdout = StdoutCatcher()
+	>>> print 'foo'
+	>>> print 'hello world!'
+	>>> sys.stderr.write(sys.stdout.data)
+	foo
+	hello world!
+
+

+ +Edit this entry / +Log info + +/ Last changed on Wed Dec 16 18:34:25 1998 by +Richard Jones +

+ +


+

5.9. How do I access a module written in Python from C?

+You can get a pointer to the module object as follows: +

+

+        module = PyImport_ImportModule("<modulename>");
+
+If the module hasn't been imported yet (i.e. it is not yet present in +sys.modules), this initializes the module; otherwise it simply returns +the value of sys.modules["<modulename>"]. Note that it doesn't enter +the module into any namespace -- it only ensures it has been +initialized and is stored in sys.modules. +

+You can then access the module's attributes (i.e. any name defined in +the module) as follows: +

+

+        attr = PyObject_GetAttrString(module, "<attrname>");
+
+Calling PyObject_SetAttrString(), to assign to variables in the module, also works. +

+ +Edit this entry / +Log info + +/ Last changed on Wed May 21 22:56:40 1997 by +david ascher +

+ +


+

5.10. How do I interface to C++ objects from Python?

+Depending on your requirements, there are many approaches. To do +this manually, begin by reading the "Extending and Embedding" document +(Doc/ext.tex, see also http://www.python.org/doc/). Realize +that for the Python run-time system, there isn't a whole lot of +difference between C and C++ -- so the strategy to build a new Python +type around a C structure (pointer) type will also work for C++ +objects. +

+A useful automated approach (which also works for C) is SWIG: +http://www.swig.org/. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Oct 15 05:14:01 1999 by +Sjoerd Mullender +

+ +


+

5.11. mSQLmodule (or other old module) won't build with Python 1.5 (or later)

+Since python-1.4 "Python.h" will have the file includes needed in an +extension module. +Backward compatibility is dropped after version 1.4 and therefore +mSQLmodule.c will not build as "allobjects.h" cannot be found. +The following change in mSQLmodule.c is harmless when building it with +1.4 and necessary when doing so for later python versions: +

+Remove lines: +

+

+	#include "allobjects.h"
+	#include "modsupport.h"
+
+And insert instead: +

+

+	#include "Python.h"
+
+You may also need to add +

+

+                #include "rename2.h"
+
+if the module uses "old names". +

+This may happen with other ancient python modules as well, +and the same fix applies. +

+ +Edit this entry / +Log info + +/ Last changed on Sun Dec 21 02:03:35 1997 by +GvR +

+ +


+

5.12. I added a module using the Setup file and the make fails! Huh?

+Setup must end in a newline, if there is no newline there it gets +very sad. Aside from this possibility, maybe you have other +non-Python-specific linkage problems. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jun 24 15:54:01 1997 by +aaron watters +

+ +


+

5.13. I want to compile a Python module on my Red Hat Linux system, but some files are missing.

+Red Hat's RPM for Python doesn't include the +/usr/lib/python1.x/config/ directory, which contains various files required +for compiling Python extensions. +Install the python-devel RPM to get the necessary files. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 26 13:44:04 1999 by +A.M. Kuchling +

+ +


+

5.14. What does "SystemError: _PyImport_FixupExtension: module yourmodule not loaded" mean?

+This means that you have created an extension module named "yourmodule", but your module init function does not initialize with that name. +

+Every module init function will have a line similar to: +

+

+  module = Py_InitModule("yourmodule", yourmodule_functions);
+
+If the string passed to this function is not the same name as your extenion module, the SystemError will be raised. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Mar 25 07:16:08 1999 by +Mark Hammond +

+ +


+

5.15. How to tell "incomplete input" from "invalid input"?

+Sometimes you want to emulate the Python interactive interpreter's +behavior, where it gives you a continuation prompt when the input +is incomplete (e.g. you typed the start of an "if" statement +or you didn't close your parentheses or triple string quotes), +but it gives you a syntax error message immediately when the input +is invalid. +

+In Python you can use the codeop module, which approximates the +parser's behavior sufficiently. IDLE uses this, for example. +

+The easiest way to do it in C is to call PyRun_InteractiveLoop() +(in a separate thread maybe) and let the Python interpreter handle +the input for you. You can also set the PyOS_ReadlineFunctionPointer +to point at your custom input function. See Modules/readline.c and +Parser/myreadline.c for more hints. +

+However sometimes you have to run the embedded Python interpreter +in the same thread as your rest application and you can't allow the +PyRun_InteractiveLoop() to stop while waiting for user input. +The one solution then is to call PyParser_ParseString() +and test for e.error equal to E_EOF (then the input is incomplete). +Sample code fragment, untested, inspired by code from Alex Farber: +

+

+  #include <Python.h>
+  #include <node.h>
+  #include <errcode.h>
+  #include <grammar.h>
+  #include <parsetok.h>
+  #include <compile.h>
+
+
+  int testcomplete(char *code)
+    /* code should end in \n */
+    /* return -1 for error, 0 for incomplete, 1 for complete */
+  {
+    node *n;
+    perrdetail e;
+
+
+    n = PyParser_ParseString(code, &_PyParser_Grammar,
+                             Py_file_input, &e);
+    if (n == NULL) {
+      if (e.error == E_EOF) 
+        return 0;
+      return -1;
+    }
+
+
+    PyNode_Free(n);
+    return 1;
+  }
+
+Another solution is trying to compile the received string with +Py_CompileString(). If it compiles fine - try to execute the returned +code object by calling PyEval_EvalCode(). Otherwise save the input for +later. If the compilation fails, find out if it's an error or just +more input is required - by extracting the message string from the +exception tuple and comparing it to the "unexpected EOF while parsing". +Here is a complete example using the GNU readline library (you may +want to ignore SIGINT while calling readline()): +

+

+  #include <stdio.h>
+  #include <readline.h>
+
+
+  #include <Python.h>
+  #include <object.h>
+  #include <compile.h>
+  #include <eval.h>
+
+
+  int main (int argc, char* argv[])
+  {
+    int i, j, done = 0;                          /* lengths of line, code */
+    char ps1[] = ">>> ";
+    char ps2[] = "... ";
+    char *prompt = ps1;
+    char *msg, *line, *code = NULL;
+    PyObject *src, *glb, *loc;
+    PyObject *exc, *val, *trb, *obj, *dum;
+
+
+    Py_Initialize ();
+    loc = PyDict_New ();
+    glb = PyDict_New ();
+    PyDict_SetItemString (glb, "__builtins__", PyEval_GetBuiltins ());
+
+
+    while (!done)
+    {
+      line = readline (prompt);
+
+
+      if (NULL == line)                          /* CTRL-D pressed */
+      {
+        done = 1;
+      }
+      else
+      {
+        i = strlen (line);
+
+
+        if (i > 0)
+          add_history (line);                    /* save non-empty lines */
+
+
+        if (NULL == code)                        /* nothing in code yet */
+          j = 0;
+        else
+          j = strlen (code);
+
+
+        code = realloc (code, i + j + 2);
+        if (NULL == code)                        /* out of memory */
+          exit (1);
+
+
+        if (0 == j)                              /* code was empty, so */
+          code[0] = '\0';                        /* keep strncat happy */
+
+
+        strncat (code, line, i);                 /* append line to code */
+        code[i + j] = '\n';                      /* append '\n' to code */
+        code[i + j + 1] = '\0';
+
+
+        src = Py_CompileString (code, "<stdin>", Py_single_input);       
+
+
+        if (NULL != src)                         /* compiled just fine - */
+        {
+          if (ps1  == prompt ||                  /* ">>> " or */
+              '\n' == code[i + j - 1])           /* "... " and double '\n' */
+          {                                               /* so execute it */
+            dum = PyEval_EvalCode ((PyCodeObject *)src, glb, loc);
+            Py_XDECREF (dum);
+            Py_XDECREF (src);
+            free (code);
+            code = NULL;
+            if (PyErr_Occurred ())
+              PyErr_Print ();
+            prompt = ps1;
+          }
+        }                                        /* syntax error or E_EOF? */
+        else if (PyErr_ExceptionMatches (PyExc_SyntaxError))           
+        {
+          PyErr_Fetch (&exc, &val, &trb);        /* clears exception! */
+
+
+          if (PyArg_ParseTuple (val, "sO", &msg, &obj) &&
+              !strcmp (msg, "unexpected EOF while parsing")) /* E_EOF */
+          {
+            Py_XDECREF (exc);
+            Py_XDECREF (val);
+            Py_XDECREF (trb);
+            prompt = ps2;
+          }
+          else                                   /* some other syntax error */
+          {
+            PyErr_Restore (exc, val, trb);
+            PyErr_Print ();
+            free (code);
+            code = NULL;
+            prompt = ps1;
+          }
+        }
+        else                                     /* some non-syntax error */
+        {
+          PyErr_Print ();
+          free (code);
+          code = NULL;
+          prompt = ps1;
+        }
+
+
+        free (line);
+      }
+    }
+
+
+    Py_XDECREF(glb);
+    Py_XDECREF(loc);
+    Py_Finalize();
+    exit(0);
+  }
+
+

+ +Edit this entry / +Log info + +/ Last changed on Wed Mar 15 09:47:24 2000 by +Alex Farber +

+ +


+

5.16. How do I debug an extension?

+When using gdb with dynamically loaded extensions, you can't set a +breakpoint in your extension until your extension is loaded. +

+In your .gdbinit file (or interactively), add the command +

+br _PyImport_LoadDynamicModule +

+

+$ gdb /local/bin/python +

+gdb) run myscript.py +

+gdb) continue # repeat until your extension is loaded +

+gdb) finish # so that your extension is loaded +

+gdb) br myfunction.c:50 +

+gdb) continue +

+ +Edit this entry / +Log info + +/ Last changed on Fri Oct 20 11:10:32 2000 by +Joe VanAndel +

+ +


+

5.17. How do I find undefined Linux g++ symbols, __builtin_new or __pure_virtural

+To dynamically load g++ extension modules, you must recompile python, relink python using g++ (change LINKCC in the python Modules Makefile), and link your extension module using g++ (e.g., "g++ -shared -o mymodule.so mymodule.o"). +

+ +Edit this entry / +Log info + +/ Last changed on Sun Jan 14 18:03:51 2001 by +douglas orr +

+ +


+

5.18. How do I define and create objects corresponding to built-in/extension types

+Usually you would like to be able to inherit from a Python type when +you ask this question. The bottom line for Python 2.2 is: types and classes are miscible. You build instances by calling classes, and you can build subclasses to your heart's desire. +

+You need to be careful when instantiating immutable types like integers or strings. See http://www.amk.ca/python/2.2/, section 2, for details. +

+Prior to version 2.2, Python (like Java) insisted that there are first-class and second-class objects (the former are types, the latter classes), and never the twain shall meet. +

+The library has, however, done a good job of providing class wrappers for the more commonly desired objects (see UserDict, UserList and UserString for examples), and more are always welcome if you happen to be in the mood to write code. These wrappers still exist in Python 2.2. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 10 15:14:07 2002 by +Matthias Urlichs +

+ +


+

6. Python's design

+ +
+

6.1. Why isn't there a switch or case statement in Python?

+You can do this easily enough with a sequence of +if... elif... elif... else. There have been some proposals for switch +statement syntax, but there is no consensus (yet) on whether and how +to do range tests. +

+ +Edit this entry / +Log info +

+ +


+

6.2. Why does Python use indentation for grouping of statements?

+Basically I believe that using indentation for grouping is +extremely elegant and contributes a lot to the clarity of the average +Python program. Most people learn to love this feature after a while. +Some arguments for it: +

+Since there are no begin/end brackets there cannot be a disagreement +between grouping perceived by the parser and the human reader. I +remember long ago seeing a C fragment like this: +

+

+        if (x <= y)
+                x++;
+                y--;
+        z++;
+
+and staring a long time at it wondering why y was being decremented +even for x > y... (And I wasn't a C newbie then either.) +

+Since there are no begin/end brackets, Python is much less prone to +coding-style conflicts. In C there are loads of different ways to +place the braces (including the choice whether to place braces around +single statements in certain cases, for consistency). If you're used +to reading (and writing) code that uses one style, you will feel at +least slightly uneasy when reading (or being required to write) +another style. +Many coding styles place begin/end brackets on a line by themself. +This makes programs considerably longer and wastes valuable screen +space, making it harder to get a good overview over a program. +Ideally, a function should fit on one basic tty screen (say, 20 +lines). 20 lines of Python are worth a LOT more than 20 lines of C. +This is not solely due to the lack of begin/end brackets (the lack of +declarations also helps, and the powerful operations of course), but +it certainly helps! +

+ +Edit this entry / +Log info + +/ Last changed on Wed May 21 16:00:15 1997 by +GvR +

+ +


+

6.3. Why are Python strings immutable?

+There are two advantages. One is performance: knowing that a +string is immutable makes it easy to lay it out at construction time +-- fixed and unchanging storage requirements. (This is also one of +the reasons for the distinction between tuples and lists.) The +other is that strings in Python are considered as "elemental" as +numbers. No amount of activity will change the value 8 to anything +else, and in Python, no amount of activity will change the string +"eight" to anything else. (Adapted from Jim Roskind) +

+ +Edit this entry / +Log info +

+ +


+

6.4. Delete

+

+

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 2 03:05:25 2001 by +Moshe Zadka +

+ +


+

6.5. Why does Python use methods for some functionality (e.g. list.index()) but functions for other (e.g. len(list))?

+The major reason is history. Functions were used for those +operations that were generic for a group of types and which +were intended to work even for objects that didn't have +methods at all (e.g. numbers before type/class unification +began, or tuples). +

+It is also convenient to have a function that can readily be applied +to an amorphous collection of objects when you use the functional features of Python (map(), apply() et al). +

+In fact, implementing len(), max(), min() as a built-in function is +actually less code than implementing them as methods for each type. +One can quibble about individual cases but it's a part of Python, +and it's too late to change such things fundamentally now. The +functions have to remain to avoid massive code breakage. +

+Note that for string operations Python has moved from external functions +(the string module) to methods. However, len() is still a function. +

+ +Edit this entry / +Log info + +/ Last changed on Thu May 30 14:08:58 2002 by +Steve Holden +

+ +


+

6.6. Why can't I derive a class from built-in types (e.g. lists or files)?

+As of Python 2.2, you can derive from built-in types. For previous versions, the answer is: +

+This is caused by the relatively late addition of (user-defined) +classes to the language -- the implementation framework doesn't easily +allow it. See the answer to question 4.2 for a work-around. This +may be fixed in the (distant) future. +

+ +Edit this entry / +Log info + +/ Last changed on Thu May 23 02:53:22 2002 by +Neal Norwitz +

+ +


+

6.7. Why must 'self' be declared and used explicitly in method definitions and calls?

+So, is your current programming language C++ or Java? :-) +When classes were added to Python, this was (again) the simplest way of +implementing methods without too many changes to the interpreter. The +idea was borrowed from Modula-3. It turns out to be very useful, for +a variety of reasons. +

+First, it makes it more obvious that you are using a method or +instance attribute instead of a local variable. Reading "self.x" or +"self.meth()" makes it absolutely clear that an instance variable or +method is used even if you don't know the class definition by heart. +In C++, you can sort of tell by the lack of a local variable +declaration (assuming globals are rare or easily recognizable) -- but +in Python, there are no local variable declarations, so you'd have to +look up the class definition to be sure. +

+Second, it means that no special syntax is necessary if you want to +explicitly reference or call the method from a particular class. In +C++, if you want to use a method from base class that is overridden in +a derived class, you have to use the :: operator -- in Python you can +write baseclass.methodname(self, <argument list>). This is +particularly useful for __init__() methods, and in general in cases +where a derived class method wants to extend the base class method of +the same name and thus has to call the base class method somehow. +

+Lastly, for instance variables, it solves a syntactic problem with +assignment: since local variables in Python are (by definition!) those +variables to which a value assigned in a function body (and that +aren't explicitly declared global), there has to be some way to tell +the interpreter that an assignment was meant to assign to an instance +variable instead of to a local variable, and it should preferably be +syntactic (for efficiency reasons). C++ does this through +declarations, but Python doesn't have declarations and it would be a +pity having to introduce them just for this purpose. Using the +explicit "self.var" solves this nicely. Similarly, for using instance +variables, having to write "self.var" means that references to +unqualified names inside a method don't have to search the instance's +directories. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Jan 12 08:01:50 2001 by +Steve Holden +

+ +


+

6.8. Can't you emulate threads in the interpreter instead of relying on an OS-specific thread implementation?

+Answer 1: Unfortunately, the interpreter pushes at least one C stack +frame for each Python stack frame. Also, extensions can call back into +Python at almost random moments. Therefore a complete threads +implementation requires thread support for C. +

+Answer 2: Fortunately, there is Stackless Python, which has a completely redesigned interpreter loop that avoids the C stack. It's still experimental but looks very promising. Although it is binary compatible with standard Python, it's still unclear whether Stackless will make it into the core -- maybe it's just too revolutionary. Stackless Python currently lives here: http://www.stackless.com. A microthread implementation that uses it can be found here: http://world.std.com/~wware/uthread.html. +

+ +Edit this entry / +Log info + +/ Last changed on Sat Apr 15 08:18:16 2000 by +Just van Rossum +

+ +


+

6.9. Why can't lambda forms contain statements?

+Python lambda forms cannot contain statements because Python's +syntactic framework can't handle statements nested inside expressions. +

+However, in Python, this is not a serious problem. Unlike lambda +forms in other languages, where they add functionality, Python lambdas +are only a shorthand notation if you're too lazy to define a function. +

+Functions are already first class objects in Python, and can be +declared in a local scope. Therefore the only advantage of using a +lambda form instead of a locally-defined function is that you don't need to invent a name for the function -- but that's just a local variable to which the function object (which is exactly the same type of object that a lambda form yields) is assigned! +

+ +Edit this entry / +Log info + +/ Last changed on Sun Jun 14 14:15:17 1998 by +Tim Peters +

+ +


+

6.10. [deleted]

+[lambda vs non-nested scopes used to be here] +

+ +Edit this entry / +Log info + +/ Last changed on Thu Mar 21 05:20:56 2002 by +Erno Kuusela +

+ +


+

6.11. [deleted]

+[recursive functions vs non-nested scopes used to be here] +

+ +Edit this entry / +Log info + +/ Last changed on Thu Mar 21 05:22:04 2002 by +Erno Kuusela +

+ +


+

6.12. Why is there no more efficient way of iterating over a dictionary than first constructing the list of keys()?

+As of Python 2.2, you can now iterate over a dictionary directly, +using the new implied dictionary iterator: +

+

+    for k in d: ...
+
+There are also methods returning iterators over the values and items: +

+

+    for k in d.iterkeys(): # same as above
+    for v in d.itervalues(): # iterate over values
+    for k, v in d.iteritems(): # iterate over items
+
+All these require that you do not modify the dictionary during the loop. +

+For previous Python versions, the following defense should do: +

+Have you tried it? I bet it's fast enough for your purposes! In +most cases such a list takes only a few percent of the space occupied +by the dictionary. Apart from the fixed header, +the list needs only 4 bytes (the size of a pointer) per +key. A dictionary uses 12 bytes per key plus between 30 and 70 +percent hash table overhead, plus the space for the keys and values. +By necessity, all keys are distinct objects, and a string object (the most +common key type) costs at least 20 bytes plus the length of the +string. Add to that the values contained in the dictionary, and you +see that 4 bytes more per item really isn't that much more memory... +

+A call to dict.keys() makes one fast scan over the dictionary +(internally, the iteration function does exist) copying the pointers +to the key objects into a pre-allocated list object of the right size. +The iteration time isn't lost (since you'll have to iterate anyway -- +unless in the majority of cases your loop terminates very prematurely +(which I doubt since you're getting the keys in random order). +

+I don't expose the dictionary iteration operation to Python +programmers because the dictionary shouldn't be modified during the +entire iteration -- if it is, there's a small chance that the +dictionary is reorganized because the hash table becomes too full, and +then the iteration may miss some items and see others twice. Exactly +because this only occurs rarely, it would lead to hidden bugs in +programs: it's easy never to have it happen during test runs if you +only insert or delete a few items per iteration -- but your users will +surely hit upon it sooner or later. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 24 21:24:08 2002 by +GvR +

+ +


+

6.13. Can Python be compiled to machine code, C or some other language?

+Not easily. Python's high level data types, dynamic typing of +objects and run-time invocation of the interpreter (using eval() or +exec) together mean that a "compiled" Python program would probably +consist mostly of calls into the Python run-time system, even for +seemingly simple operations like "x+1". +

+Several projects described in the Python newsgroup or at past +Python conferences have shown that this approach is feasible, +although the speedups reached so far are only modest (e.g. 2x). +JPython uses the same strategy for compiling to Java bytecode. +(Jim Hugunin has demonstrated that in combination with whole-program +analysis, speedups of 1000x are feasible for small demo programs. +See the website for the 1997 Python conference.) +

+Internally, Python source code is always translated into a "virtual +machine code" or "byte code" representation before it is interpreted +(by the "Python virtual machine" or "bytecode interpreter"). In order +to avoid the overhead of parsing and translating modules that rarely +change over and over again, this byte code is written on a file whose +name ends in ".pyc" whenever a module is parsed (from a file whose +name ends in ".py"). When the corresponding .py file is changed, it +is parsed and translated again and the .pyc file is rewritten. +

+There is no performance difference once the .pyc file has been loaded +(the bytecode read from the .pyc file is exactly the same as the bytecode +created by direct translation). The only difference is that loading +code from a .pyc file is faster than parsing and translating a .py +file, so the presence of precompiled .pyc files will generally improve +start-up time of Python scripts. If desired, the Lib/compileall.py +module/script can be used to force creation of valid .pyc files for a +given set of modules. +

+Note that the main script executed by Python, even if its filename +ends in .py, is not compiled to a .pyc file. It is compiled to +bytecode, but the bytecode is not saved to a file. +

+If you are looking for a way to translate Python programs in order to +distribute them in binary form, without the need to distribute the +interpreter and library as well, have a look at the freeze.py script +in the Tools/freeze directory. This creates a single binary file +incorporating your program, the Python interpreter, and those parts of +the Python library that are needed by your program. Of course, the +resulting binary will only run on the same type of platform as that +used to create it. +

+Newsflash: there are now several programs that do this, to some extent. +Look for Psyco, Pyrex, PyInline, Py2Cmod, and Weave. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 24 21:26:19 2002 by +GvR +

+ +


+

6.14. How does Python manage memory?

+The details of Python memory management depend on the implementation. +The standard Python implementation (the C implementation) uses reference +counting and another mechanism to collect reference cycles. +

+Jython relies on the Java runtime; so it uses +the JVM's garbage collector. This difference can cause some subtle +porting problems if your Python code depends on the behavior of +the reference counting implementation. +

+The reference cycle collector was added in CPython 2.0. It +periodically executes a cycle detection algorithm which looks for inaccessible cycles and deletes the objects involved. A new gc module provides functions to perform a garbage collection, obtain debugging statistics, and tuning the collector's parameters. +

+The detection of cycles can be disabled when Python is compiled, if you can't afford even a tiny speed penalty or suspect that the cycle collection is buggy, by specifying the "--without-cycle-gc" switch when running the configure script. +

+Sometimes objects get stuck in "tracebacks" temporarily and hence are not deallocated when you might expect. Clear the tracebacks via +

+

+       import sys
+       sys.exc_traceback = sys.last_traceback = None
+
+Tracebacks are used for reporting errors and implementing debuggers and related things. They contain a portion of the program state extracted during the handling of an exception (usually the most recent exception). +

+In the absence of circularities and modulo tracebacks, Python programs need not explicitly manage memory. +

+Why python doesn't use a more traditional garbage collection +scheme? For one thing, unless this were +added to C as a standard feature, it's a portability pain in the ass. +And yes, I know about the Xerox library. It has bits of assembler +code for most common platforms. Not for all. And although it is +mostly transparent, it isn't completely transparent (when I once +linked Python with it, it dumped core). +

+Traditional GC also becomes a problem when Python gets embedded into +other applications. While in a stand-alone Python it may be fine to +replace the standard malloc() and free() with versions provided by the +GC library, an application embedding Python may want to have its own +substitute for malloc() and free(), and may not want Python's. Right +now, Python works with anything that implements malloc() and free() +properly. +

+In Jython, the following code (which is +fine in C Python) will probably run out of file descriptors long before +it runs out of memory: +

+

+        for file in <very long list of files>:
+                f = open(file)
+                c = f.read(1)
+
+Using the current reference counting and destructor scheme, each new +assignment to f closes the previous file. Using GC, this is not +guaranteed. Sure, you can think of ways to fix this. But it's not +off-the-shelf technology. If you want to write code that will +work with any Python implementation, you should explicitly close +the file; this will work regardless of GC: +

+

+       for file in <very long list of files>:
+                f = open(file)
+                c = f.read(1)
+                f.close()
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Mar 21 05:35:38 2002 by +Erno Kuusela +

+ +


+

6.15. Why are there separate tuple and list data types?

+This is done so that tuples can be immutable while lists are mutable. +

+Immutable tuples are useful in situations where you need to pass a few +items to a function and don't want the function to modify the tuple; +for example, +

+

+	point1 = (120, 140)
+	point2 = (200, 300)
+	record(point1, point2)
+	draw(point1, point2)
+
+You don't want to have to think about what would happen if record() +changed the coordinates -- it can't, because the tuples are immutable. +

+On the other hand, when creating large lists dynamically, it is +absolutely crucial that they are mutable -- adding elements to a tuple +one by one requires using the concatenation operator, which makes it +quadratic in time. +

+As a general guideline, use tuples like you would use structs in C or +records in Pascal, use lists like (variable length) arrays. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 23 15:26:03 1997 by +GvR +

+ +


+

6.16. How are lists implemented?

+Despite what a Lisper might think, Python's lists are really +variable-length arrays. The implementation uses a contiguous +array of references to other objects, and keeps a pointer +to this array (as well as its length) in a list head structure. +

+This makes indexing a list (a[i]) an operation whose cost is +independent of the size of the list or the value of the index. +

+When items are appended or inserted, the array of references is resized. +Some cleverness is applied to improve the performance of appending +items repeatedly; when the array must be grown, some extra space +is allocated so the next few times don't require an actual resize. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 23 15:32:24 1997 by +GvR +

+ +


+

6.17. How are dictionaries implemented?

+Python's dictionaries are implemented as resizable hash tables. +

+Compared to B-trees, this gives better performance for lookup +(the most common operation by far) under most circumstances, +and the implementation is simpler. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 23 23:51:14 1997 by +Vladimir Marangozov +

+ +


+

6.18. Why must dictionary keys be immutable?

+The hash table implementation of dictionaries uses a hash value +calculated from the key value to find the key. If the key were +a mutable object, its value could change, and thus its hash could +change. But since whoever changes the key object can't tell that +is incorporated in a dictionary, it can't move the entry around in +the dictionary. Then, when you try to look up the same object +in the dictionary, it won't be found, since its hash value is different; +and if you try to look up the old value, it won't be found either, +since the value of the object found in that hash bin differs. +

+If you think you need to have a dictionary indexed with a list, +try to use a tuple instead. The function tuple(l) creates a tuple +with the same entries as the list l. +

+Some unacceptable solutions that have been proposed: +

+- Hash lists by their address (object ID). This doesn't work because +if you construct a new list with the same value it won't be found; +e.g., +

+

+  d = {[1,2]: '12'}
+  print d[[1,2]]
+
+will raise a KeyError exception because the id of the [1,2] used +in the second line differs from that in the first line. +In other words, dictionary keys should be compared using '==', not using 'is'. +

+- Make a copy when using a list as a key. This doesn't work because +the list (being a mutable object) could contain a reference to itself, +and then the copying code would run into an infinite loop. +

+- Allow lists as keys but tell the user not to modify them. This would +allow a class of hard-to-track bugs in programs that I'd rather not see; +it invalidates an important invariant of dictionaries (every value in +d.keys() is usable as a key of the dictionary). +

+- Mark lists as read-only once they are used as a dictionary key. +The problem is that it's not just the top-level object that could change +its value; you could use a tuple containing a list as a key. Entering +anything as a key into a dictionary would require marking all objects +reachable from there as read-only -- and again, self-referential objects +could cause an infinite loop again (and again and again). +

+There is a trick to get around this if you need to, but +use it at your own risk: You +can wrap a mutable structure inside a class instance which +has both a __cmp__ and a __hash__ method. +

+

+   class listwrapper:
+        def __init__(self, the_list):
+              self.the_list = the_list
+        def __cmp__(self, other):
+              return self.the_list == other.the_list
+        def __hash__(self):
+              l = self.the_list
+              result = 98767 - len(l)*555
+              for i in range(len(l)):
+                   try:
+                        result = result + (hash(l[i]) % 9999999) * 1001 + i
+                   except:
+                        result = (result % 7777777) + i * 333
+              return result
+
+Note that the hash computation is complicated by the +possibility that some members of the list may be unhashable +and also by the possibility of arithmetic overflow. +

+You must make +sure that the hash value for all such wrapper objects that reside in a +dictionary (or other hash based structure), remain fixed while +the object is in the dictionary (or other structure). +

+Furthermore it must always be the case that if +o1 == o2 (ie o1.__cmp__(o2)==0) then hash(o1)==hash(o2) +(ie, o1.__hash__() == o2.__hash__()), regardless of whether +the object is in a dictionary or not. +If you fail to meet these restrictions dictionaries and other +hash based structures may misbehave! +

+In the case of listwrapper above whenever the wrapper +object is in a dictionary the wrapped list must not change +to avoid anomalies. Don't do this unless you are prepared +to think hard about the requirements and the consequences +of not meeting them correctly. You've been warned! +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jul 10 10:08:40 1997 by +aaron watters +

+ +


+

6.19. How the heck do you make an array in Python?

+["this", 1, "is", "an", "array"] +

+Lists are arrays in the C or Pascal sense of the word (see question +6.16). The array module also provides methods for creating arrays +of fixed types with compact representations (but they are slower to +index than lists). Also note that the Numerics extensions and others +define array-like structures with various characteristics as well. +

+To get Lisp-like lists, emulate cons cells +

+

+    lisp_list = ("like",  ("this",  ("example", None) ) )
+
+using tuples (or lists, if you want mutability). Here the analogue +of lisp car is lisp_list[0] and the analogue of cdr is lisp_list[1]. +Only do this if you're sure you really need to (it's usually a lot +slower than using Python lists). +

+Think of Python lists as mutable heterogeneous arrays of +Python objects (say that 10 times fast :) ). +

+ +Edit this entry / +Log info + +/ Last changed on Wed Aug 13 07:08:27 1997 by +aaron watters +

+ +


+

6.20. Why doesn't list.sort() return the sorted list?

+In situations where performance matters, making a copy of the list +just to sort it would be wasteful. Therefore, list.sort() sorts +the list in place. In order to remind you of that fact, it does +not return the sorted list. This way, you won't be fooled into +accidentally overwriting a list when you need a sorted copy but also +need to keep the unsorted version around. +

+As a result, here's the idiom to iterate over the keys of a dictionary +in sorted order: +

+

+	keys = dict.keys()
+	keys.sort()
+	for key in keys:
+		...do whatever with dict[key]...
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Dec 2 17:01:52 1999 by +Fred L. Drake, Jr. +

+ +


+

6.21. How do you specify and enforce an interface spec in Python?

+An interfaces specification for a module as provided +by languages such as C++ and java describes the prototypes +for the methods and functions of the module. Many feel +that compile time enforcement of interface specifications +help aid in the construction of large programs. Python +does not support interface specifications directly, but many +of their advantages can be obtained by an appropriate +test discipline for components, which can often be very +easily accomplished in Python. There is also a tool, PyChecker, +which can be used to find problems due to subclassing. +

+A good test suite for a module can at +once provide a regression test and serve as a module interface +specification (even better since it also gives example usage). Look to +many of the standard libraries which often have a "script +interpretation" which provides a simple "self test." Even +modules which use complex external interfaces can often +be tested in isolation using trivial "stub" emulations of the +external interface. +

+An appropriate testing discipline (if enforced) can help +build large complex applications in Python as well as having interface +specifications would do (or better). Of course Python allows you +to get sloppy and not do it. Also you might want to design +your code with an eye to make it easily tested. +

+ +Edit this entry / +Log info + +/ Last changed on Thu May 23 03:05:29 2002 by +Neal Norwitz +

+ +


+

6.22. Why do all classes have the same type? Why do instances all have the same type?

+The Pythonic use of the word "type" is quite different from +common usage in much of the rest of the programming language +world. A "type" in Python is a description for an object's operations +as implemented in C. All classes have the same operations +implemented in C which sometimes "call back" to differing program +fragments implemented in Python, and hence all classes have the +same type. Similarly at the C level all class instances have the +same C implementation, and hence all instances have the same +type. +

+Remember that in Python usage "type" refers to a C implementation +of an object. To distinguish among instances of different classes +use Instance.__class__, and also look to 4.47. Sorry for the +terminological confusion, but at this point in Python's development +nothing can be done! +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jul 1 12:35:47 1997 by +aaron watters +

+ +


+

6.23. Why isn't all memory freed when Python exits?

+Objects referenced from Python module global name spaces are +not always deallocated when Python exits. +

+This may happen if there are circular references (see question +4.17). There are also certain bits of memory that are allocated +by the C library that are impossible to free (e.g. a tool +like Purify will complain about these). +

+But in general, Python 1.5 and beyond +(in contrast with earlier versions) is quite agressive about +cleaning up memory on exit. +

+If you want to force Python to delete certain things on deallocation +use the sys.exitfunc hook to force those deletions. For example +if you are debugging an extension module using a memory analysis +tool and you wish to make Python deallocate almost everything +you might use an exitfunc like this one: +

+

+  import sys
+
+
+  def my_exitfunc():
+       print "cleaning up"
+       import sys
+       # do order dependant deletions here
+       ...
+       # now delete everything else in arbitrary order
+       for x in sys.modules.values():
+            d = x.__dict__
+            for name in d.keys():
+                 del d[name]
+
+
+  sys.exitfunc = my_exitfunc
+
+Other exitfuncs can be less drastic, of course. +

+(In fact, this one just does what Python now already does itself; +but the example of using sys.exitfunc to force cleanups is still +useful.) +

+ +Edit this entry / +Log info + +/ Last changed on Tue Sep 29 09:46:26 1998 by +GvR +

+ +


+

6.24. Why no class methods or mutable class variables?

+The notation +

+

+    instance.attribute(arg1, arg2)
+
+usually translates to the equivalent of +

+

+    Class.attribute(instance, arg1, arg2)
+
+where Class is a (super)class of instance. Similarly +

+

+    instance.attribute = value
+
+sets an attribute of an instance (overriding any attribute of a class +that instance inherits). +

+Sometimes programmers want to have +different behaviours -- they want a method which does not bind +to the instance and a class attribute which changes in place. +Python does not preclude these behaviours, but you have to +adopt a convention to implement them. One way to accomplish +this is to use "list wrappers" and global functions. +

+

+   def C_hello():
+         print "hello"
+
+
+   class C:
+        hello = [C_hello]
+        counter = [0]
+
+
+    I = C()
+
+Here I.hello[0]() acts very much like a "class method" and +I.counter[0] = 2 alters C.counter (and doesn't override it). +If you don't understand why you'd ever want to do this, that's +because you are pure of mind, and you probably never will +want to do it! This is dangerous trickery, not recommended +when avoidable. (Inspired by Tim Peter's discussion.) +

+In Python 2.2, you can do this using the new built-in operations +classmethod and staticmethod. +See http://www.python.org/2.2/descrintro.html#staticmethods +

+ +Edit this entry / +Log info + +/ Last changed on Tue Sep 11 15:59:37 2001 by +GvR +

+ +


+

6.25. Why are default values sometimes shared between objects?

+It is often expected that a function CALL creates new objects for default +values. This is not what happens. Default values are created when the +function is DEFINED, that is, there is only one such object that all +functions refer to. If that object is changed, subsequent calls to the +function will refer to this changed object. By definition, immutable objects +(like numbers, strings, tuples, None) are safe from change. Changes to mutable +objects (like dictionaries, lists, class instances) is what causes the +confusion. +

+Because of this feature it is good programming practice not to use mutable +objects as default values, but to introduce them in the function. +Don't write: +

+

+	def foo(dict={}):  # XXX shared reference to one dict for all calls
+	    ...
+
+but: +
+	def foo(dict=None):
+		if dict is None:
+			dict = {} # create a new dict for local namespace
+
+See page 182 of "Internet Programming with Python" for one discussion +of this feature. Or see the top of page 144 or bottom of page 277 in +"Programming Python" for another discussion. +

+ +Edit this entry / +Log info + +/ Last changed on Sat Aug 16 07:03:35 1997 by +Case Roole +

+ +


+

6.26. Why no goto?

+Actually, you can use exceptions to provide a "structured goto" +that even works across function calls. Many feel that exceptions +can conveniently emulate all reasonable uses of the "go" or "goto" +constructs of C, Fortran, and other languages. For example: +

+

+   class label: pass # declare a label
+   try:
+        ...
+        if (condition): raise label() # goto label
+        ...
+   except label: # where to goto
+        pass
+   ...
+
+This doesn't allow you to jump into the middle of a loop, but +that's usually considered an abuse of goto anyway. Use sparingly. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Sep 10 07:16:44 1997 by +aaron watters +

+ +


+

6.27. How do you make a higher order function in Python?

+You have two choices: you can use default arguments and override +them or you can use "callable objects." For example suppose you +wanted to define linear(a,b) which returns a function f where f(x) +computes the value a*x+b. Using default arguments: +

+

+     def linear(a,b):
+         def result(x, a=a, b=b):
+             return a*x + b
+         return result
+
+Or using callable objects: +

+

+     class linear:
+        def __init__(self, a, b):
+            self.a, self.b = a,b
+        def __call__(self, x):
+            return self.a * x + self.b
+
+In both cases: +

+

+     taxes = linear(0.3,2)
+
+gives a callable object where taxes(10e6) == 0.3 * 10e6 + 2. +

+The defaults strategy has the disadvantage that the default arguments +could be accidentally or maliciously overridden. The callable objects +approach has the disadvantage that it is a bit slower and a bit +longer. Note however that a collection of callables can share +their signature via inheritance. EG +

+

+      class exponential(linear):
+         # __init__ inherited
+         def __call__(self, x):
+             return self.a * (x ** self.b)
+
+On comp.lang.python, zenin@bawdycaste.org points out that +an object can encapsulate state for several methods in order +to emulate the "closure" concept from functional programming +languages, for example: +

+

+    class counter:
+        value = 0
+        def set(self, x): self.value = x
+        def up(self): self.value=self.value+1
+        def down(self): self.value=self.value-1
+
+
+    count = counter()
+    inc, dec, reset = count.up, count.down, count.set
+
+Here inc, dec and reset act like "functions which share the +same closure containing the variable count.value" (if you +like that way of thinking). +

+ +Edit this entry / +Log info + +/ Last changed on Fri Sep 25 08:38:35 1998 by +Aaron Watters +

+ +


+

6.28. Why do I get a SyntaxError for a 'continue' inside a 'try'?

+This is an implementation limitation, +caused by the extremely simple-minded +way Python generates bytecode. The try block pushes something on the +"block stack" which the continue would have to pop off again. The +current code generator doesn't have the data structures around so that +'continue' can generate the right code. +

+Note that JPython doesn't have this restriction! +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 22 15:01:07 1998 by +GvR +

+ +


+

6.29. Why can't raw strings (r-strings) end with a backslash?

+More precisely, they can't end with an odd number of backslashes: +the unpaired backslash at the end escapes the closing quote character, +leaving an unterminated string. +

+Raw strings were designed to ease creating input for processors (chiefly +regular expression engines) that want to do their own backslash escape processing. Such processors consider an unmatched trailing backslash to be an error anyway, so raw strings disallow that. In return, they allow you to pass on the string quote character by escaping it with a backslash. These rules work well when r-strings are used for their intended purpose. +

+If you're trying to build Windows pathnames, note that all Windows system calls accept forward slashes too: +

+

+    f = open("/mydir/file.txt") # works fine!
+
+If you're trying to build a pathname for a DOS command, try e.g. one of +

+

+    dir = r"\this\is\my\dos\dir" "\\"
+    dir = r"\this\is\my\dos\dir\ "[:-1]
+    dir = "\\this\\is\\my\\dos\\dir\\"
+
+

+ +Edit this entry / +Log info + +/ Last changed on Mon Jul 13 20:50:20 1998 by +Tim Peters +

+ +


+

6.30. Why can't I use an assignment in an expression?

+Many people used to C or Perl complain that they want to be able to +use e.g. this C idiom: +

+

+    while (line = readline(f)) {
+        ...do something with line...
+    }
+
+where in Python you're forced to write this: +

+

+    while 1:
+        line = f.readline()
+        if not line:
+            break
+        ...do something with line...
+
+This issue comes up in the Python newsgroup with alarming frequency +-- search Deja News for past messages about assignment expression. +The reason for not allowing assignment in Python expressions +is a common, hard-to-find bug in those other languages, +caused by this construct: +

+

+    if (x = 0) {
+        ...error handling...
+    }
+    else {
+        ...code that only works for nonzero x...
+    }
+
+Many alternatives have been proposed. Most are hacks that save some +typing but use arbitrary or cryptic syntax or keywords, +and fail the simple criterion that I use for language change proposals: +it should intuitively suggest the proper meaning to a human reader +who has not yet been introduced with the construct. +

+The earliest time something can be done about this will be with +Python 2.0 -- if it is decided that it is worth fixing. +An interesting phenomenon is that most experienced Python programmers +recognize the "while 1" idiom and don't seem to be missing the +assignment in expression construct much; it's only the newcomers +who express a strong desire to add this to the language. +

+One fairly elegant solution would be to introduce a new operator +for assignment in expressions spelled ":=" -- this avoids the "=" +instead of "==" problem. It would have the same precedence +as comparison operators but the parser would flag combination with +other comparisons (without disambiguating parentheses) as an error. +

+Finally -- there's an alternative way of spelling this that seems +attractive but is generally less robust than the "while 1" solution: +

+

+    line = f.readline()
+    while line:
+        ...do something with line...
+        line = f.readline()
+
+The problem with this is that if you change your mind about exactly +how you get the next line (e.g. you want to change it into +sys.stdin.readline()) you have to remember to change two places +in your program -- the second one hidden at the bottom of the loop. +

+ +Edit this entry / +Log info + +/ Last changed on Tue May 18 00:57:41 1999 by +Andrew Dalke +

+ +


+

6.31. Why doesn't Python have a "with" statement like some other languages?

+Basically, because such a construct would be terribly ambiguous. Thanks to Carlos Ribeiro for the following remarks: +

+Some languages, such as Object Pascal, Delphi, and C++, use static types. So it is possible to know, in an unambiguous way, what member is being assigned in a "with" clause. This is the main point - the compiler always knows the scope of every variable at compile time. +

+Python uses dynamic types. It is impossible to know in advance which +attribute will be referenced at runtime. Member attributes may be added or removed from objects on the fly. This would make it impossible to know, from a simple reading, what attribute is being referenced - a local one, a global one, or a member attribute. +

+For instance, take the following snippet (it is incomplete btw, just to +give you the idea): +

+

+   def with_is_broken(a):
+      with a:
+         print x
+
+The snippet assumes that "a" must have a member attribute called "x". +However, there is nothing in Python that guarantees that. What should +happen if "a" is, let us say, an integer? And if I have a global variable named "x", will it end up being used inside the with block? As you see, the dynamic nature of Python makes such choices much harder. +

+The primary benefit of "with" and similar language features (reduction of code volume) can, however, easily be achieved in Python by assignment. Instead of: +

+

+    function(args).dict[index][index].a = 21
+    function(args).dict[index][index].b = 42
+    function(args).dict[index][index].c = 63
+
+would become: +

+

+    ref = function(args).dict[index][index]
+    ref.a = 21
+    ref.b = 42
+    ref.c = 63
+
+This also has the happy side-effect of increasing execution speed, since name bindings are resolved at run-time in Python, and the second method only needs to perform the resolution once. If the referenced object does not have a, b and c attributes, of course, the end result is still a run-time exception. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Jan 11 14:32:58 2002 by +Steve Holden +

+ +


+

6.32. Why are colons required for if/while/def/class?

+The colon is required primarily to enhance readability (one of the +results of the experimental ABC language). Consider this: +

+

+    if a==b
+        print a
+
+versus +

+

+    if a==b:
+        print a
+
+Notice how the second one is slightly easier to read. Notice further how +a colon sets off the example in the second line of this FAQ answer; it's +a standard usage in English. Finally, the colon makes it easier for +editors with syntax highlighting. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 07:22:57 2002 by +Matthias Urlichs +

+ +


+

6.33. Can't we get rid of the Global Interpreter Lock?

+The Global Interpreter Lock (GIL) is often seen as a hindrance to +Python's deployment on high-end multiprocessor server machines, +because a multi-threaded Python program effectively only uses +one CPU, due to the insistence that (almost) all Python code +can only run while the GIL is held. +

+Back in the days of Python 1.5, Greg Stein actually implemented +a comprehensive patch set ("free threading") +that removed the GIL, replacing it with +fine-grained locking. Unfortunately, even on Windows (where locks +are very efficient) this ran ordinary Python code about twice as +slow as the interpreter using the GIL. On Linux the performance +loss was even worse (pthread locks aren't as efficient). +

+Since then, the idea of getting rid of the GIL has occasionally +come up but nobody has found a way to deal with the expected slowdown; +Greg's free threading patch set has not been kept up-to-date for +later Python versions. +

+This doesn't mean that you can't make good use of Python on +multi-CPU machines! You just have to be creative with dividing +the work up between multiple processes rather than multiple +threads. +

+

+It has been suggested that the GIL should be a per-interpreter-state +lock rather than truly global; interpreters then wouldn't be able +to share objects. Unfortunately, this isn't likely to happen either. +

+It would be a tremendous amount of work, because many object +implementations currently have global state. E.g. small ints and +small strings are cached; these caches would have to be moved to the +interpreter state. Other object types have their own free list; these +free lists would have to be moved to the interpreter state. And so +on. +

+And I doubt that it can even be done in finite time, because the same +problem exists for 3rd party extensions. It is likely that 3rd party +extensions are being written at a faster rate than you can convert +them to store all their global state in the interpreter state. +

+And finally, once you have multiple interpreters not sharing any +state, what have you gained over running each interpreter +in a separate process? +

+ +Edit this entry / +Log info + +/ Last changed on Fri Feb 7 16:34:01 2003 by +GvR +

+ +


+

7. Using Python on non-UNIX platforms

+ +
+

7.1. Is there a Mac version of Python?

+Yes, it is maintained by Jack Jansen. See Jack's MacPython Page: +

+

+  http://www.cwi.nl/~jack/macpython.html
+
+

+ +Edit this entry / +Log info + +/ Last changed on Fri May 4 09:33:42 2001 by +GvR +

+ +


+

7.2. Are there DOS and Windows versions of Python?

+Yes. The core windows binaries are available from http://www.python.org/windows/. There is a plethora of Windows extensions available, including a large number of not-always-compatible GUI toolkits. The core binaries include the standard Tkinter GUI extension. +

+Most windows extensions can be found (or referenced) at http://www.python.org/windows/ +

+Windows 3.1/DOS support seems to have dropped off recently. You may need to settle for an old version of Python one these platforms. One such port is WPY +

+WPY: Ports to DOS, Windows 3.1(1), Windows 95, Windows NT and OS/2. +Also contains a GUI package that offers portability between Windows +(not DOS) and Unix, and native look and feel on both. +ftp://ftp.python.org/pub/python/wpy/. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jun 2 20:21:57 1998 by +Mark Hammond +

+ +


+

7.3. Is there an OS/2 version of Python?

+Yes, see http://www.python.org/download/download_os2.html. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Sep 7 11:33:16 1999 by +GvR +

+ +


+

7.4. Is there a VMS version of Python?

+Jean-François Piéronne has ported 2.1.3 to OpenVMS. It can be found at +<http://vmspython.dyndns.org/>. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Sep 19 15:40:38 2002 by +Skip Montanaro +

+ +


+

7.5. What about IBM mainframes, or other non-UNIX platforms?

+I haven't heard about these, except I remember hearing about an +OS/9 port and a port to Vxworks (both operating systems for embedded +systems). If you're interested in any of this, go directly to the +newsgroup and ask there, you may find exactly what you need. For +example, a port to MPE/iX 5.0 on HP3000 computers was just announced, +see http://www.allegro.com/software/. +

+On the IBM mainframe side, for Z/OS there's a port of python 1.4 that goes with their open-unix package, formely OpenEdition MVS, (http://www-1.ibm.com/servers/eserver/zseries/zos/unix/python.html). On a side note, there's also a java vm ported - so, in theory, jython could run too. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Nov 18 03:18:39 2002 by +Bruno Jessen +

+ +


+

7.6. Where are the source or Makefiles for the non-UNIX versions?

+The standard sources can (almost) be used. Additional sources can +be found in the platform-specific subdirectories of the distribution. +

+ +Edit this entry / +Log info +

+ +


+

7.7. What is the status and support for the non-UNIX versions?

+I don't have access to most of these platforms, so in general I am +dependent on material submitted by volunteers. However I strive to +integrate all changes needed to get it to compile on a particular +platform back into the standard sources, so porting of the next +version to the various non-UNIX platforms should be easy. +(Note that Linux is classified as a UNIX platform here. :-) +

+Some specific platforms: +

+Windows: all versions (95, 98, ME, NT, 2000, XP) are supported, +all python.org releases come with a Windows installer. +

+MacOS: Jack Jansen does an admirable job of keeping the Mac version +up to date (both MacOS X and older versions); +see http://www.cwi.nl/~jack/macpython.html +

+For all supported platforms, see http://www.python.org/download/ +(follow the link to "Other platforms" for less common platforms) +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 24 21:34:24 2002 by +GvR +

+ +


+

7.8. I have a PC version but it appears to be only a binary. Where's the library?

+If you are running any version of Windows, then you have the wrong distribution. The FAQ lists current Windows versions. Notably, Pythonwin and wpy provide fully functional installations. +

+But if you are sure you have the only distribution with a hope of working on +your system, then... +

+You still need to copy the files from the distribution directory +"python/Lib" to your system. If you don't have the full distribution, +you can get the file lib<version>.tar.gz from most ftp sites carrying +Python; this is a subset of the distribution containing just those +files, e.g. ftp://ftp.python.org/pub/python/src/lib1.4.tar.gz. +

+Once you have installed the library, you need to point sys.path to it. +Assuming the library is in C:\misc\python\lib, the following commands +will point your Python interpreter to it (note the doubled backslashes +-- you can also use single forward slashes instead): +

+

+        >>> import sys
+        >>> sys.path.insert(0, 'C:\\misc\\python\\lib')
+        >>>
+
+For a more permanent effect, set the environment variable PYTHONPATH, +as follows (talking to a DOS prompt): +

+

+        C> SET PYTHONPATH=C:\misc\python\lib
+
+

+ +Edit this entry / +Log info + +/ Last changed on Fri May 23 16:28:27 1997 by +Ken Manheimer +

+ +


+

7.9. Where's the documentation for the Mac or PC version?

+The documentation for the Unix version also applies to the Mac and +PC versions. Where applicable, differences are indicated in the text. +

+ +Edit this entry / +Log info +

+ +


+

7.10. How do I create a Python program file on the Mac or PC?

+Use an external editor. On the Mac, BBEdit seems to be a popular +no-frills text editor. I work like this: start the interpreter; edit +a module file using BBedit; import and test it in the interpreter; +edit again in BBedit; then use the built-in function reload() to +re-read the imported module; etc. In the 1.4 distribution +you will find a BBEdit extension that makes life a little easier: +it can tell the interpreter to execute the current window. +See :Mac:Tools:BBPy:README. +

+Regarding the same question for the PC, Kurt Wm. Hemr writes: "While +anyone with a pulse could certainly figure out how to do the same on +MS-Windows, I would recommend the NotGNU Emacs clone for MS-Windows. +Not only can you easily resave and "reload()" from Python after making +changes, but since WinNot auto-copies to the clipboard any text you +select, you can simply select the entire procedure (function) which +you changed in WinNot, switch to QWPython, and shift-ins to reenter +the changed program unit." +

+If you're using Windows95 or Windows NT, you should also know about +PythonWin, which provides a GUI framework, with an mouse-driven +editor, an object browser, and a GUI-based debugger. See +

+       http://www.python.org/ftp/python/pythonwin/
+
+for details. +

+ +Edit this entry / +Log info + +/ Last changed on Sun May 25 10:04:25 1997 by +GvR +

+ +


+

7.11. How can I use Tkinter on Windows 95/NT?

+Starting from Python 1.5, it's very easy -- just download and install +Python and Tcl/Tk and you're in business. See +

+

+  http://www.python.org/download/download_windows.html
+
+One warning: don't attempt to use Tkinter from PythonWin +(Mark Hammond's IDE). Use it from the command line interface +(python.exe) or the windowless interpreter (pythonw.exe). +

+ +Edit this entry / +Log info + +/ Last changed on Fri Jun 12 09:32:48 1998 by +GvR +

+ +


+

7.12. cgi.py (or other CGI programming) doesn't work sometimes on NT or win95!

+Be sure you have the latest python.exe, that you are using +python.exe rather than a GUI version of python and that you +have configured the server to execute +

+

+     "...\python.exe -u ..."
+
+for the cgi execution. The -u (unbuffered) option on NT and +win95 prevents the interpreter from altering newlines in the +standard input and output. Without it post/multipart requests +will seem to have the wrong length and binary (eg, GIF) +responses may get garbled (resulting in, eg, a "broken image"). +

+ +Edit this entry / +Log info + +/ Last changed on Wed Jul 30 10:48:02 1997 by +aaron watters +

+ +


+

7.13. Why doesn't os.popen() work in PythonWin on NT?

+The reason that os.popen() doesn't work from within PythonWin is due to a bug in Microsoft's C Runtime Library (CRT). The CRT assumes you have a Win32 console attached to the process. +

+You should use the win32pipe module's popen() instead which doesn't depend on having an attached Win32 console. +

+Example: +

+ import win32pipe
+ f = win32pipe.popen('dir /c c:\\')
+ print f.readlines()
+ f.close()
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Jul 31 15:34:09 1997 by +Bill Tutt +

+ +


+

7.14. How do I use different functionality on different platforms with the same program?

+Remember that Python is extremely dynamic and that you +can use this dynamism to configure a program at run-time to +use available functionality on different platforms. For example +you can test the sys.platform and import different modules based +on its value. +

+

+   import sys
+   if sys.platform == "win32":
+      import win32pipe
+      popen = win32pipe.popen
+   else:
+      import os
+      popen = os.popen
+
+(See FAQ 7.13 for an explanation of why you might want to +do something like this.) Also you can try to import a module +and use a fallback if the import fails: +

+

+    try:
+         import really_fast_implementation
+         choice = really_fast_implementation
+    except ImportError:
+         import slower_implementation
+         choice = slower_implementation
+
+

+ +Edit this entry / +Log info + +/ Last changed on Wed Aug 13 07:39:06 1997 by +aaron watters +

+ +


+

7.15. Is there an Amiga version of Python?

+Yes. See the AmigaPython homepage at http://www.bigfoot.com/~irmen/python.html. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Dec 14 06:53:32 1998 by +Irmen de Jong +

+ +


+

7.16. Why doesn't os.popen()/win32pipe.popen() work on Win9x?

+There is a bug in Win9x that prevents os.popen/win32pipe.popen* from working. The good news is there is a way to work around this problem. +The Microsoft Knowledge Base article that you need to lookup is: Q150956. You will find links to the knowledge base at: +http://www.microsoft.com/kb. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Jun 25 10:45:38 1999 by +Bill Tutt +

+ +


+

8. Python on Windows

+ +
+

8.1. Using Python for CGI on Microsoft Windows

+** Setting up the Microsoft IIS Server/Peer Server +

+On the Microsoft IIS +server or on the Win95 MS Personal Web Server +you set up python in the same way that you +would set up any other scripting engine. +

+Run regedt32 and go to: +

+HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\ScriptMap +

+and enter the following line (making any specific changes that your system may need) +

+.py :REG_SZ: c:\<path to python>\python.exe -u %s %s +

+This line will allow you to call your script with a simple reference like: +http://yourserver/scripts/yourscript.py +provided "scripts" is an "executable" directory for your server (which +it usually is by default). +The "-u" flag specifies unbuffered and binary mode for stdin - needed when working with binary data +

+In addition, it is recommended by people who would know that using ".py" may +not be a good idea for the file extensions when used in this context +(you might want to reserve *.py for support modules and use *.cgi or *.cgp +for "main program" scripts). +However, that issue is beyond this Windows FAQ entry. +

+

+** Apache configuration +

+In the Apache configuration file httpd.conf, add the following line at +the end of the file: +

+ScriptInterpreterSource Registry +

+Then, give your Python CGI-scripts the extension .py and put them in the cgi-bin directory. +

+

+** Netscape Servers: +Information on this topic exists at: +http://home.netscape.com/comprod/server_central/support/fasttrack_man/programs.htm#1010870 +

+ +Edit this entry / +Log info + +/ Last changed on Wed Mar 27 12:25:54 2002 by +Gerhard Häring +

+ +


+

8.2. How to check for a keypress without blocking?

+Use the msvcrt module. This is a standard Windows-specific extensions +in Python 1.5 and beyond. It defines a function kbhit() which checks +whether a keyboard hit is present; also getch() which gets one +character without echo. Plus a few other goodies. +

+(Search for "keypress" to find an answer for Unix as well.) +

+ +Edit this entry / +Log info + +/ Last changed on Mon Mar 30 16:21:46 1998 by +GvR +

+ +


+

8.3. $PYTHONPATH

+In MS-DOS derived environments, a unix variable such as $PYTHONPATH is +set as PYTHONPATH, without the dollar sign. PYTHONPATH is useful for +specifying the location of library files. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jun 11 00:41:26 1998 by +Gvr +

+ +


+

8.4. dedent syntax errors

+The FAQ does not recommend using tabs, and Guido's Python Style Guide recommends 4 spaces for distributed Python code; this is also the Emacs python-mode default; see +

+

+    http://www.python.org/doc/essays/styleguide.html
+
+Under any editor mixing tabs and spaces is a bad idea. MSVC is no different in this respect, and is easily configured to use spaces: Take Tools -> Options -> Tabs, and for file type "Default" set "Tab size" and "Indent size" to 4, and select the "Insert spaces" radio button. +

+If you suspect mixed tabs and spaces are causing problems in leading whitespace, run Python with the -t switch or, run Tools/Scripts/tabnanny.py to check a directory tree in batch mode. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Feb 12 15:04:14 2001 by +Steve Holden +

+ +


+

8.5. How do I emulate os.kill() in Windows?

+Use win32api: +

+

+    def kill(pid):
+        """kill function for Win32"""
+        import win32api
+        handle = win32api.OpenProcess(1, 0, pid)
+        return (0 != win32api.TerminateProcess(handle, 0))
+
+

+ +Edit this entry / +Log info + +/ Last changed on Sat Aug 8 18:55:06 1998 by +Jeff Bauer +

+ +


+

8.6. Why does os.path.isdir() fail on NT shared directories?

+The solution appears to be always append the "\\" on +the end of shared drives. +

+

+  >>> import os
+  >>> os.path.isdir( '\\\\rorschach\\public')
+  0
+  >>> os.path.isdir( '\\\\rorschach\\public\\')
+  1
+
+[Blake Winton responds:] +I've had the same problem doing "Start >> Run" and then a +directory on a shared drive. If I use "\\rorschach\public", +it will fail, but if I use "\\rorschach\public\", it will +work. For that matter, os.stat() does the same thing (well, +it gives an error for "\\\\rorschach\\public", but you get +the idea)... +

+I've got a theory about why this happens, but it's only +a theory. NT knows the difference between shared directories, +and regular directories. "\\rorschach\public" isn't a +directory, it's _really_ an IPC abstraction. This is sort +of lended credence to by the fact that when you're mapping +a network drive, you can't map "\\rorschach\public\utils", +but only "\\rorschach\public". +

+[Clarification by funkster@midwinter.com] +It's not actually a Python +question, as Python is working just fine; it's clearing up something +a bit muddled about Windows networked drives. +

+It helps to think of share points as being like drive letters. +Example: +

+        k: is not a directory
+        k:\ is a directory
+        k:\media is a directory
+        k:\media\ is not a directory
+
+The same rules apply if you substitute "k:" with "\\conky\foo": +
+        \\conky\foo  is not a directory
+        \\conky\foo\ is a directory
+        \\conky\foo\media is a directory
+        \\conky\foo\media\ is not a directory
+
+

+ +Edit this entry / +Log info + +/ Last changed on Sun Jan 31 08:44:48 1999 by +GvR +

+ +


+

8.7. PyRun_SimpleFile() crashes on Windows but not on Unix

+I've seen a number of reports of PyRun_SimpleFile() failing +in a Windows port of an application embedding Python that worked +fine on Unix. PyRun_SimpleString() works fine on both platforms. +

+I think this happens because the application was compiled with a +different set of compiler flags than Python15.DLL. It seems that some +compiler flags affect the standard I/O library in such a way that +using different flags makes calls fail. You need to set it for +the non-debug multi-threaded DLL (/MD on the command line, or can be set via MSVC under Project Settings->C++/Code Generation then the "Use rum-time library" dropdown.) +

+Also note that you can not mix-and-match Debug and Release versions. If you wish to use the Debug Multithreaded DLL, then your module _must_ have an "_d" appended to the base name. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Nov 17 17:37:07 1999 by +Mark Hammond +

+ +


+

8.8. Import of _tkinter fails on Windows 95/98

+Sometimes, the import of _tkinter fails on Windows 95 or 98, +complaining with a message like the following: +

+

+  ImportError: DLL load failed: One of the library files needed
+  to run this application cannot be found.
+
+It could be that you haven't installed Tcl/Tk, but if you did +install Tcl/Tk, and the Wish application works correctly, +the problem may be that its installer didn't +manage to edit the autoexec.bat file correctly. It tries to add a +statement that changes the PATH environment variable to include +the Tcl/Tk 'bin' subdirectory, but sometimes this edit doesn't +quite work. Opening it with notepad usually reveals what the +problem is. +

+(One additional hint, noted by David Szafranski: you can't use +long filenames here; e.g. use C:\PROGRA~1\Tcl\bin instead of +C:\Program Files\Tcl\bin.) +

+ +Edit this entry / +Log info + +/ Last changed on Wed Dec 2 22:32:41 1998 by +GvR +

+ +


+

8.9. Can't extract the downloaded documentation on Windows

+Sometimes, when you download the documentation package to a Windows +machine using a web browser, the file extension of the saved file +ends up being .EXE. This is a mistake; the extension should be .TGZ. +

+Simply rename the downloaded file to have the .TGZ extension, and +WinZip will be able to handle it. (If your copy of WinZip doesn't, +get a newer one from http://www.winzip.com.) +

+ +Edit this entry / +Log info + +/ Last changed on Sat Nov 21 13:41:35 1998 by +GvR +

+ +


+

8.10. Can't get Py_RunSimpleFile() to work.

+This is very sensitive to the compiler vendor, version and (perhaps) +even options. If the FILE* structure in your embedding program isn't +the same as is assumed by the Python interpreter it won't work. +

+The Python 1.5.* DLLs (python15.dll) are all compiled +with MS VC++ 5.0 and with multithreading-DLL options (/MD, I think). +

+If you can't change compilers or flags, try using Py_RunSimpleString(). +A trick to get it to run an arbitrary file is to construct a call to +execfile() with the name of your file as argument. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Jan 13 10:58:14 1999 by +GvR +

+ +


+

8.11. Where is Freeze for Windows?

+("Freeze" is a program that allows you to ship a Python program +as a single stand-alone executable file. It is not a compiler, +your programs don't run any faster, but they are more easily +distributable (to platforms with the same OS and CPU). Read the +README file of the freeze program for more disclaimers.) +

+You can use freeze on Windows, but you must download the source +tree (see http://www.python.org/download/download_source.html). +This is recommended for Python 1.5.2 (and betas thereof) only; +older versions don't quite work. +

+You need the Microsoft VC++ 5.0 compiler (maybe it works with +6.0 too). You probably need to build Python -- the project files +are all in the PCbuild directory. +

+The freeze program is in the Tools\freeze subdirectory of the source +tree. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Feb 17 18:47:24 1999 by +GvR +

+ +


+

8.12. Is a *.pyd file the same as a DLL?

+Yes, .pyd files are dll's. But there are a few differences. If you +have a DLL named foo.pyd, then it must have a function initfoo(). You +can then write Python "import foo", and Python will search for foo.pyd +(as well as foo.py, foo.pyc) and if it finds it, will attempt to call +initfoo() to initialize it. You do not link your .exe with foo.lib, +as that would cause Windows to require the DLL to be present. +

+Note that the search path for foo.pyd is PYTHONPATH, not the same as +the path that Windows uses to search for foo.dll. Also, foo.pyd need +not be present to run your program, whereas if you linked your program +with a dll, the dll is required. Of course, foo.pyd is required if +you want to say "import foo". In a dll, linkage is declared in the +source code with __declspec(dllexport). In a .pyd, linkage is defined +in a list of available functions. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Nov 23 02:40:08 1999 by +Jameson Quinn +

+ +


+

8.13. Missing cw3215mt.dll (or missing cw3215.dll)

+Sometimes, when using Tkinter on Windows, you get an error that +cw3215mt.dll or cw3215.dll is missing. +

+Cause: you have an old Tcl/Tk DLL built with cygwin in your path +(probably C:\Windows). You must use the Tcl/Tk DLLs from the +standard Tcl/Tk installation (Python 1.5.2 comes with one). +

+ +Edit this entry / +Log info + +/ Last changed on Fri Jun 11 00:54:13 1999 by +GvR +

+ +


+

8.14. How to make python scripts executable:

+[Blake Coverett] +

+Win2K: +

+The standard installer already associates the .py extension with a file type +(Python.File) and gives that file type an open command that runs the +interpreter (D:\Program Files\Python\python.exe "%1" %*). This is enough to +make scripts executable from the command prompt as 'foo.py'. If you'd +rather be able to execute the script by simple typing 'foo' with no +extension you need to add .py to the PATHEXT environment variable. +

+WinNT: +

+The steps taken by the installed as described above allow you do run a +script with 'foo.py', but a long time bug in the NT command processor +prevents you from redirecting the input or output of any script executed in +this way. This is often important. +

+An appropriate incantation for making a Python script executable under WinNT +is to give the file an extension of .cmd and add the following as the first +line: +

+

+    @setlocal enableextensions & python -x %~f0 %* & goto :EOF
+
+Win9x: +

+[Due to Bruce Eckel] +

+

+  @echo off
+  rem = """
+  rem run python on this bat file. Needs the full path where
+  rem you keep your python files. The -x causes python to skip
+  rem the first line of the file:
+  python -x c:\aaa\Python\\"%0".bat %1 %2 %3 %4 %5 %6 %7 %8 %9
+  goto endofpython
+  rem """
+
+
+  # The python program goes here:
+
+
+  print "hello, Python"
+
+
+  # For the end of the batch file:
+  rem = """
+  :endofpython
+  rem """
+
+

+ +Edit this entry / +Log info + +/ Last changed on Tue Nov 30 10:25:17 1999 by +GvR +

+ +


+

8.15. Warning about CTL3D32 version from installer

+The Python installer issues a warning like this: +

+

+  This version uses CTL3D32.DLL whitch is not the correct version.
+  This version is used for windows NT applications only.
+
+[Tim Peters] +This is a Microsoft DLL, and a notorious +source of problems. The msg means what it says: you have the wrong version +of this DLL for your operating system. The Python installation did not +cause this -- something else you installed previous to this overwrote the +DLL that came with your OS (probably older shareware of some sort, but +there's no way to tell now). If you search for "CTL3D32" using any search +engine (AltaVista, for example), you'll find hundreds and hundreds of web +pages complaining about the same problem with all sorts of installation +programs. They'll point you to ways to get the correct version reinstalled +on your system (since Python doesn't cause this, we can't fix it). +

+David A Burton has written a little program to fix this. Go to +http://www.burtonsys.com/download.html and click on "ctl3dfix.zip" +

+ +Edit this entry / +Log info + +/ Last changed on Thu Oct 26 15:42:00 2000 by +GvR +

+ +


+

8.16. How can I embed Python into a Windows application?

+Edward K. Ream <edream@tds.net> writes +

+When '##' appears in a file name below, it is an abbreviated version number. For example, for Python 2.1.1, ## will be replaced by 21. +

+Embedding the Python interpreter in a Windows app can be summarized as +follows: +

+1. Do _not_ build Python into your .exe file directly. On Windows, +Python must be a DLL to handle importing modules that are themselves +DLL's. (This is the first key undocumented fact.) Instead, link to +python##.dll; it is typically installed in c:\Windows\System. +

+You can link to Python statically or dynamically. Linking statically +means linking against python##.lib The drawback is that your app won't +run if python##.dll does not exist on your system. +

+General note: python##.lib is the so-called "import lib" corresponding +to python.dll. It merely defines symbols for the linker. +

+Borland note: convert python##.lib to OMF format using Coff2Omf.exe +first. +

+Linking dynamically greatly simplifies link options; everything happens +at run time. Your code must load python##.dll using the Windows +LoadLibraryEx() routine. The code must also use access routines and +data in python##.dll (that is, Python's C API's) using pointers +obtained by the Windows GetProcAddress() routine. Macros can make +using these pointers transparent to any C code that calls routines in +Python's C API. +

+2. If you use SWIG, it is easy to create a Python "extension module" +that will make the app's data and methods available to Python. SWIG +will handle just about all the grungy details for you. The result is C +code that you link _into your .exe file_ (!) You do _not_ have to +create a DLL file, and this also simplifies linking. +

+3. SWIG will create an init function (a C function) whose name depends +on the name of the extension module. For example, if the name of the +module is leo, the init function will be called initleo(). If you use +SWIG shadow classes, as you should, the init function will be called +initleoc(). This initializes a mostly hidden helper class used by the +shadow class. +

+The reason you can link the C code in step 2 into your .exe file is that +calling the initialization function is equivalent to importing the +module into Python! (This is the second key undocumented fact.) +

+4. In short, you can use the following code to initialize the Python +interpreter with your extension module. +

+

+    #include "python.h"
+    ...
+    Py_Initialize();  // Initialize Python.
+    initmyAppc();  // Initialize (import) the helper class. 
+    PyRun_SimpleString("import myApp") ;  // Import the shadow class.
+
+5. There are two problems with Python's C API which will become apparent +if you use a compiler other than MSVC, the compiler used to build +python##.dll. +

+Problem 1: The so-called "Very High Level" functions that take FILE * +arguments will not work in a multi-compiler environment; each compiler's +notion of a struct FILE will be different. From an implementation +standpoint these are very _low_ level functions. +

+Problem 2: SWIG generates the following code when generating wrappers to +void functions: +

+

+    Py_INCREF(Py_None);
+    _resultobj = Py_None;
+    return _resultobj;
+
+Alas, Py_None is a macro that expands to a reference to a complex data +structure called _Py_NoneStruct inside python##.dll. Again, this code +will fail in a mult-compiler environment. Replace such code by: +

+

+    return Py_BuildValue("");
+
+It may be possible to use SWIG's %typemap command to make the change +automatically, though I have not been able to get this to work (I'm a +complete SWIG newbie). +

+6. Using a Python shell script to put up a Python interpreter window +from inside your Windows app is not a good idea; the resulting window +will be independent of your app's windowing system. Rather, you (or the +wxPythonWindow class) should create a "native" interpreter window. It +is easy to connect that window to the Python interpreter. You can +redirect Python's i/o to _any_ object that supports read and write, so +all you need is a Python object (defined in your extension module) that +contains read() and write() methods. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jan 31 16:29:34 2002 by +Victor Kryukov +

+ +


+

8.17. Setting up IIS 5 to use Python for CGI

+In order to set up Internet Information Services 5 to use Python for CGI processing, please see the following links: +

+http://www.e-coli.net/pyiis_server.html (for Win2k Server) +http://www.e-coli.net/pyiis.html (for Win2k pro) +

+ +Edit this entry / +Log info + +/ Last changed on Fri Mar 22 22:05:51 2002 by +douglas savitsky +

+ +


+

8.18. How do I run a Python program under Windows?

+This is not necessarily quite the straightforward question it appears +to be. If you are already familiar with running programs from the +Windows command line then everything will seem really easy and +obvious. If your computer experience is limited then you might need a +little more guidance. Also there are differences between Windows 95, +98, NT, ME, 2000 and XP which can add to the confusion. You might +think of this as "why I pay software support charges" if you have a +helpful and friendly administrator to help you set things up without +having to understand all this yourself. If so, then great! Show them +this page and it should be a done deal. +

+Unless you use some sort of integrated development environment (such +as PythonWin or IDLE, to name only two in a growing family) then you +will end up typing Windows commands into what is variously referred +to as a "DOS window" or "Command prompt window". Usually you can +create such a window from your Start menu (under Windows 2000 I use +"Start | Programs | Accessories | Command Prompt"). You should be +able to recognize when you have started such a window because you will +see a Windows "command prompt", which usually looks like this: +

+

+    C:\>
+
+The letter may be different, and there might be other things after it, +so you might just as easily see something like: +

+

+    D:\Steve\Projects\Python>
+
+depending on how your computer has been set up and what else you have +recently done with it. Once you have started such a window, you are +well on the way to running Python programs. +

+You need to realize that your Python scripts have to be processed by +another program, usually called the "Python interpreter". The +interpreter reads your script, "compiles" it into "Python bytecodes" +(which are instructions for an imaginary computer known as the "Python +Virtual Machine") and then executes the bytecodes to run your +program. So, how do you arrange for the interpreter to handle your +Python? +

+First, you need to make sure that your command window recognises the +word "python" as an instruction to start the interpreter. If you have +opened a command window, you should try entering the command: +

+

+    python
+
+and hitting return. If you then see something like: +

+

+    Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32
+    Type "help", "copyright", "credits" or "license" for more information.
+    >>>
+
+then this part of the job has been correctly managed during Python's +installation process, and you have started the interpreter in +"interactive mode". That means you can enter Python statements or +expressions interactively and have them executed or evaluated while +you wait. This is one of Python's strongest features, but it takes a +little getting used to. Check it by entering a few expressions of your +choice and seeing the results... +

+

+    >>> print "Hello"
+    Hello
+    >>> "Hello" * 3
+    HelloHelloHello
+
+When you want to end your interactive Python session, enter a +terminator (hold the Ctrl key down while you enter a Z, then hit the +"Enter" key) to get back to your Windows command prompt. You may also +find that you have a Start-menu entry such as "Start | Programs | +Python 2.2 | Python (command line)" that results in you seeing the +">>>" prompt in a new window. If so, the window will disappear after +you enter the terminator -- Windows runs a single "python" command in +the window, which terminates when you terminate the interpreter. +

+If the "python" command, instead of displaying the interpreter prompt ">>>", gives you a message like +

+

+    'python' is not recognized as an internal or external command,
+    operable program or batch file.
+
+or +

+

+    Bad command or filename
+
+then you need to make sure that your computer knows where to find the +Python interpreter. To do this you will have to modify a setting +called the PATH, which is a just list of directories where Windows +will look for programs. Rather than just enter the right command every +time you create a command window, you should arrange for Python's +installation directory to be added to the PATH of every command window +as it starts. If you installed Python fairly recently then the command +

+

+    dir C:\py*
+
+will probably tell you where it is installed. Alternatively, perhaps +you made a note. Otherwise you will be reduced to a search of your +whole disk ... break out the Windows explorer and use "Tools | Find" +or hit the "Search" button and look for "python.exe". Suppose you +discover that Python is installed in the C:\Python22 directory (the +default at the time of writing) then you should make sure that +entering the command +

+

+    c:\Python22\python
+
+starts up the interpreter as above (and don't forget you'll need a +"CTRL-Z" and an "Enter" to get out of it). Once you have verified the +directory, you need to add it to the start-up routines your computer +goes through. For older versions of Windows the easiest way to do +this is to edit the C:\AUTOEXEC.BAT file. You would want to add a line +like the following to AUTOEXEC.BAT: +

+

+    PATH C:\Python22;%PATH%
+
+For Windows NT, 2000 and (I assume) XP, you will need to add a string +such as +

+

+    ;C:\Python22
+
+to the current setting for the PATH environment variable, which you +will find in the properties window of "My Computer" under the +"Advanced" tab. Note that if you have sufficient privilege you might +get a choice of installing the settings either for the Current User or +for System. The latter is preferred if you want everybody to be able +to run Python on the machine. +

+If you aren't confident doing any of these manipulations yourself, ask +for help! At this stage you may or may not want to reboot your system +to make absolutely sure the new setting has "taken" (don't you love +the way Windows gives you these freqeuent coffee breaks). You probably +won't need to for Windows NT, XP or 2000. You can also avoid it in +earlier versions by editing the file C:\WINDOWS\COMMAND\CMDINIT.BAT +instead of AUTOEXEC.BAT. +

+You should now be able to start a new command window, enter +

+

+    python
+
+at the "C:>" (or whatever) prompt, and see the ">>>" prompt that +indicates the Python interpreter is reading interactive commands. +

+Let's suppose you have a program called "pytest.py" in directory +"C:\Steve\Projects\Python". A session to run that program might look +like this: +

+

+    C:\> cd \Steve\Projects\Python
+    C:\Steve\Projects\Python> python pytest.py
+
+Because you added a file name to the command to start the interpreter, +when it starts up it reads the Python script in the named file, +compiles it, executes it, and terminates (so you see another "C:\>" +prompt). You might also have entered +

+

+    C:\> python \Steve\Projects\Python\pytest.py
+
+if you hadn't wanted to change your current directory. +

+Under NT, 2000 and XP you may well find that the installation process +has also arranged that the command +

+

+    pytest.py
+
+(or, if the file isn't in the current directory) +

+

+    C:\Steve\Projects\Python\pytest.py
+
+will automatically recognize the ".py" extension and run the Python +interpreter on the named file. Using this feature is fine, but some +versions of Windows have bugs which mean that this form isn't exactly +equivalent to using the interpreter explicitly, so be careful. Easier +to remember, for now, that +

+

+    python C:\Steve\Projects\Python\pytest.py
+
+works pretty close to the same, and redirection will work (more) +reliably. +

+The important things to remember are: +

+1. Start Python from the Start Menu, or make sure the PATH is set +correctly so Windows can find the Python interpreter. +

+

+    python
+
+should give you a '>>>" prompt from the Python interpreter. Don't +forget the CTRL-Z and ENTER to terminate the interpreter (and, if you +started the window from the Start Menu, make the window disappear). +

+2. Once this works, you run programs with commands: +

+

+    python {program-file}
+
+3. When you know the commands to use you can build Windows shortcuts +to run the Python interpreter on any of your scripts, naming +particular working directories, and adding them to your menus, but +that's another lessFAQ. Take a look at +

+

+    python --help
+
+if your needs are complex. +

+4. Interactive mode (where you see the ">>>" prompt) is best used +not for running programs, which are better executed as in steps 2 +and 3, but for checking that individual statements and expressions do +what you think they will, and for developing code by experiment. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Aug 20 16:19:53 2002 by +GvR +

+ +


+Python home / +Python FAQ Wizard 1.0.3 / +Feedback to GvR +

Python Powered
+ + --- python2.7-2.7.5.orig/debian/dh_doclink +++ python2.7-2.7.5/debian/dh_doclink @@ -0,0 +1,28 @@ +#! /bin/sh + +pkg=`echo $1 | sed 's/^-p//'` +target=$2 + +ln -sf $target debian/$pkg/usr/share/doc/$pkg + +f=debian/$pkg.postinst.debhelper +if [ ! -e $f ] || [ "`grep -c '^# dh_doclink' $f`" -eq 0 ]; then +cat >> $f <> $f <&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 --- python2.7-2.7.5.orig/debian/libPVER-dbg.overrides.in +++ python2.7-2.7.5/debian/libPVER-dbg.overrides.in @@ -0,0 +1,7 @@ +lib@PVER@-dbg binary: package-name-doesnt-match-sonames +lib@PVER@-dbg binary: non-dev-pkg-with-shlib-symlink + +lib@PVER@-dbg binary: arch-dependent-file-not-in-arch-specific-directory + +# pointless lintian ... +lib@PVER@-dbg binary: hardening-no-fortify-functions --- python2.7-2.7.5.orig/debian/script.py +++ python2.7-2.7.5/debian/script.py @@ -0,0 +1,61 @@ +#! /usr/bin/python + +# Copyright (C) 2012 Colin Watson . +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject +# to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +"""Trivial script(1) workalike, but without reading from standard input.""" + +import os +import pty +import select +import sys + +filename = sys.argv[1] +command = sys.argv[2] + +pid, master = pty.fork() +if pid == 0: # child + os.execlp("sh", "sh", "-c", command) + +# parent +with open(filename, "w") as logfile: + try: + while True: + rfds, _, _ = select.select([master], [], []) + if master in rfds: + data = os.read(master, 65536) + os.write(1, data) + logfile.write(data) + logfile.flush() + except (IOError, OSError): + pass + +pid, status = os.wait() +returncode = 0 +if os.WIFSIGNALED(status): + returncode = -os.WTERMSIG(status) +elif os.WIFEXITED(status): + returncode = os.WEXITSTATUS(status) +else: + # Should never happen + raise RuntimeError("Unknown child exit status!") +os.close(master) +sys.exit(returncode) --- python2.7-2.7.5.orig/debian/PVER-dbg.README.Debian.in +++ python2.7-2.7.5/debian/PVER-dbg.README.Debian.in @@ -0,0 +1,58 @@ +Contents of the @PVER@-dbg package +------------------------------------- + +For debugging python and extension modules, you may want to add the contents +of /usr/share/doc/@PVER@/gdbinit (found in the @PVER@-dev package) to your +~/.gdbinit file. + +@PVER@-dbg contains two sets of packages: + + - debugging symbols for the standard @PVER@ build. When this package + is installed, gdb will automatically load up the debugging symbols + from it when debugging @PVER@ or one of the included extension + modules. + + - a separate @PVER@-dbg binary, configured --with-pydebug, enabling the + additional debugging code to help debug memory management problems. + +For the latter, all extension modules have to be recompiled to +correctly load with an pydebug enabled build. + + +Debian and Ubuntu specific changes to the debug interpreter +----------------------------------------------------------- +The python2.4 and python2.5 packages in Ubuntu feisty are modified to +first look for extension modules under a different name. + + normal build: foo.so + debug build: foo_d.so foo.so + +This naming schema allows installation of the extension modules into +the same path (The naming is directly taken from the Windows builds +which already uses this naming scheme). + +See https://wiki.ubuntu.com/PyDbgBuilds for more information. + + +Using the python-dbg builds +--------------------------- + + * Call the python-dbg or the pythonX.Y-dbg binaries instead of the + python or pythonX.Y binaries. + + * Debugging a third party extension requires the availabilty of the + extension built for the debug interpreter. For an extension `foo' + make sure that the `python-foo-dbg' package is installed, or else + the interpreter falls back to the extension for the normal build. + The error on fallback is expected. + + * Properties of the debug build are described in + /usr/share/doc/@PVER@/SpecialBuilds.txt.gz. + The debug interpreter is built with Py_DEBUG defined. + + * From SpecialBuilds.txt: This is what is generally meant by "a debug + build" of Python. Py_DEBUG implies LLTRACE, Py_REF_DEBUG, + Py_TRACE_REFS, and PYMALLOC_DEBUG (if WITH_PYMALLOC is enabled). + In addition, C assert()s are enabled (via the C way: by not defining + NDEBUG), and some routines do additional sanity checks inside + "#ifdef Py_DEBUG" blocks. --- python2.7-2.7.5.orig/debian/libPVER-dev.overrides.in +++ python2.7-2.7.5/debian/libPVER-dev.overrides.in @@ -0,0 +1,3 @@ +lib@PVER@-dev binary: python-script-but-no-python-dep + +lib@PVER@-dev binary: arch-dependent-file-not-in-arch-specific-directory --- python2.7-2.7.5.orig/debian/pygettext.1 +++ python2.7-2.7.5/debian/pygettext.1 @@ -0,0 +1,108 @@ +.TH PYGETTEXT 1 "" "pygettext 1.4" +.SH NAME +pygettext \- Python equivalent of xgettext(1) +.SH SYNOPSIS +.B pygettext +[\fIOPTIONS\fR] \fIINPUTFILE \fR... +.SH DESCRIPTION +pygettext is deprecated. The current version of xgettext supports +many languages, including Python. + +pygettext uses Python's standard tokenize module to scan Python +source code, generating .pot files identical to what GNU xgettext generates +for C and C++ code. From there, the standard GNU tools can be used. +.PP +pygettext searches only for _() by default, even though GNU xgettext +recognizes the following keywords: gettext, dgettext, dcgettext, +and gettext_noop. See the \fB\-k\fR/\fB\--keyword\fR flag below for how to +augment this. +.PP +.SH OPTIONS +.TP +\fB\-a\fR, \fB\-\-extract\-all\fR +Extract all strings. +.TP +\fB\-d\fR, \fB\-\-default\-domain\fR=\fINAME\fR +Rename the default output file from messages.pot to name.pot. +.TP +\fB\-E\fR, \fB\-\-escape\fR +Replace non-ASCII characters with octal escape sequences. +.TP +\fB\-D\fR, \fB\-\-docstrings\fR +Extract module, class, method, and function docstrings. +These do not need to be wrapped in _() markers, and in fact cannot +be for Python to consider them docstrings. (See also the \fB\-X\fR option). +.TP +\fB\-h\fR, \fB\-\-help\fR +Print this help message and exit. +.TP +\fB\-k\fR, \fB\-\-keyword\fR=\fIWORD\fR +Keywords to look for in addition to the default set, which are: _ +.IP +You can have multiple \fB\-k\fR flags on the command line. +.TP +\fB\-K\fR, \fB\-\-no\-default\-keywords\fR +Disable the default set of keywords (see above). +Any keywords explicitly added with the \fB\-k\fR/\fB\--keyword\fR option +are still recognized. +.TP +\fB\-\-no\-location\fR +Do not write filename/lineno location comments. +.TP +\fB\-n\fR, \fB\-\-add\-location\fR +Write filename/lineno location comments indicating where each +extracted string is found in the source. These lines appear before +each msgid. The style of comments is controlled by the +\fB\-S\fR/\fB\--style\fR option. This is the default. +.TP +\fB\-o\fR, \fB\-\-output\fR=\fIFILENAME\fR +Rename the default output file from messages.pot to FILENAME. +If FILENAME is `-' then the output is sent to standard out. +.TP +\fB\-p\fR, \fB\-\-output\-dir\fR=\fIDIR\fR +Output files will be placed in directory DIR. +.TP +\fB\-S\fR, \fB\-\-style\fR=\fISTYLENAME\fR +Specify which style to use for location comments. +Two styles are supported: +.RS +.IP \(bu 4 +Solaris # File: filename, line: line-number +.IP \(bu 4 +GNU #: filename:line +.RE +.IP +The style name is case insensitive. +GNU style is the default. +.TP +\fB\-v\fR, \fB\-\-verbose\fR +Print the names of the files being processed. +.TP +\fB\-V\fR, \fB\-\-version\fR +Print the version of pygettext and exit. +.TP +\fB\-w\fR, \fB\-\-width\fR=\fICOLUMNS\fR +Set width of output to columns. +.TP +\fB\-x\fR, \fB\-\-exclude\-file\fR=\fIFILENAME\fR +Specify a file that contains a list of strings that are not be +extracted from the input files. Each string to be excluded must +appear on a line by itself in the file. +.TP +\fB\-X\fR, \fB\-\-no\-docstrings\fR=\fIFILENAME\fR +Specify a file that contains a list of files (one per line) that +should not have their docstrings extracted. This is only useful in +conjunction with the \fB\-D\fR option above. +.PP +If `INPUTFILE' is -, standard input is read. +.SH BUGS +pygettext attempts to be option and feature compatible with GNU xgettext +where ever possible. However some options are still missing or are not fully +implemented. Also, xgettext's use of command line switches with option +arguments is broken, and in these cases, pygettext just defines additional +switches. +.SH AUTHOR +pygettext is written by Barry Warsaw . +.PP +Joonas Paalasmaa put this manual page together +based on "pygettext --help". --- python2.7-2.7.5.orig/debian/idle.desktop.in +++ python2.7-2.7.5/debian/idle.desktop.in @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=IDLE (using Python-@VER@) +Comment=Integrated Development Environment for Python (using Python-@VER@) +Exec=/usr/bin/idle-@PVER@ +Icon=/usr/share/pixmaps/@PVER@.xpm +Terminal=false +Type=Application +Categories=Application;Development; +StartupNotify=true --- python2.7-2.7.5.orig/debian/libPVER-dbg.prerm.in +++ python2.7-2.7.5/debian/libPVER-dbg.prerm.in @@ -0,0 +1,23 @@ +#! /bin/sh + +set -e + +case "$1" in + remove) + dpkg -L lib@PVER@-dbg \ + | awk '/\.py$/ {print $0"c\n" $0"o"}' \ + | xargs -r rm -f >&2 + ;; + upgrade) + ;; + deconfigure) + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# --- python2.7-2.7.5.orig/debian/pydoc.1.in +++ python2.7-2.7.5/debian/pydoc.1.in @@ -0,0 +1,53 @@ +.TH PYDOC@VER@ 1 +.SH NAME +pydoc@VER@ \- the Python documentation tool +.SH SYNOPSIS +.PP +.B pydoc@VER@ +.I name +.PP +.B pydoc@VER@ -k +.I keyword +.PP +.B pydoc@VER@ -p +.I port +.PP +.B pydoc@VER@ -g +.PP +.B pydoc@VER@ -w +.I module [...] +.SH DESCRIPTION +.PP +.B pydoc@VER@ +.I name +Show text documentation on something. +.I name +may be the name of a +Python keyword, topic, function, module, or package, or a dotted +reference to a class or function within a module or module in a +package. If +.I name +contains a '/', it is used as the path to a +Python source file to document. If name is 'keywords', 'topics', +or 'modules', a listing of these things is displayed. +.PP +.B pydoc@VER@ -k +.I keyword +Search for a keyword in the synopsis lines of all available modules. +.PP +.B pydoc@VER@ -p +.I port +Start an HTTP server on the given port on the local machine. +.PP +.B pydoc@VER@ -g +Pop up a graphical interface for finding and serving documentation. +.PP +.B pydoc@VER@ -w +.I name [...] +Write out the HTML documentation for a module to a file in the current +directory. If +.I name +contains a '/', it is treated as a filename; if +it names a directory, documentation is written for all the contents. +.SH AUTHOR +Moshe Zadka, based on "pydoc --help" --- python2.7-2.7.5.orig/debian/pdb.1.in +++ python2.7-2.7.5/debian/pdb.1.in @@ -0,0 +1,16 @@ +.TH PDB@VER@ 1 +.SH NAME +pdb@VER@ \- the Python debugger +.SH SYNOPSIS +.PP +.B pdb@VER@ +.I script [...] +.SH DESCRIPTION +.PP +See /usr/lib/python@VER@/pdb.doc for more information on the use +of pdb. When the debugger is started, help is available via the +help command. +.SH SEE ALSO +python@VER@(1). Chapter 9 of the Python Library Reference +(The Python Debugger). Available in the python@VER@-doc package at +/usr/share/doc/python@VER@/html/lib/module-pdb.html. --- python2.7-2.7.5.orig/debian/libPVER-testsuite.overrides.in +++ python2.7-2.7.5/debian/libPVER-testsuite.overrides.in @@ -0,0 +1,2 @@ +lib@PVER@-testsuite binary: python-script-but-no-python-dep +lib@PVER@-testsuite binary: image-file-in-usr-lib --- python2.7-2.7.5.orig/debian/PVER.postinst.in +++ python2.7-2.7.5/debian/PVER.postinst.in @@ -0,0 +1,41 @@ +#! /bin/sh + +set -e + +case "$1" in + configure) + files=$(dpkg -L lib@PVER@-stdlib | sed -n '/^\/usr\/lib\/@PVER@\/.*\.py$/p') + if [ -n "$files" ]; then + @PVER@ -E -S /usr/lib/@PVER@/py_compile.py $files + if grep -sq '^byte-compile[^#]*optimize' /etc/python/debian_config; then + @PVER@ -E -S -O /usr/lib/@PVER@/py_compile.py $files + fi + else + echo >&2 "@PVER@: can't get files for byte-compilation" + fi + + # Create empty directories in /usr/local + if [ ! -e /usr/local/lib/python@VER@ ]; then + mkdir -p /usr/local/lib/python@VER@ 2> /dev/null || true + chmod 2775 /usr/local/lib/python@VER@ 2> /dev/null || true + chown root:staff /usr/local/lib/python@VER@ 2> /dev/null || true + fi + if [ ! -e /usr/local/lib/python@VER@/site-packages ]; then + mkdir -p /usr/local/lib/python@VER@/site-packages 2> /dev/null || true + chmod 2775 /usr/local/lib/python@VER@/site-packages 2> /dev/null || true + chown root:staff /usr/local/lib/python@VER@/site-packages 2> /dev/null || true + fi + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 --- python2.7-2.7.5.orig/debian/README.maintainers.in +++ python2.7-2.7.5/debian/README.maintainers.in @@ -0,0 +1,88 @@ + +Hints for maintainers of Debian packages of Python extensions +------------------------------------------------------------- + +Most of the content of this README can be found in the Debian Python policy. +See /usr/share/doc/python/python-policy.txt.gz. + +Documentation Tools +------------------- + +If your package ships documentation produced in the Python +documentation format, you can generate it at build-time by +build-depending on @PVER@-dev, and you will find the +templates, tools and scripts in /usr/lib/@PVER@/doc/tools -- +adjust your build scripts accordingly. + + +Makefile.pre.in issues +---------------------- + +Python comes with a `universal Unix Makefile for Python extensions' in +/usr/lib/@PVER@/config/Makefile.pre.in (with Debian, this is included +in the python-dev package), which is used by most Python extensions. + +In general, packages using the Makefile.pre.in approach can be packaged +simply by running dh_make or by using one of debhelper's rules' templates +(see /usr/doc/debhelper/examples/). Makefile.pre.in works fine with e.g. +"make prefix=debian/tmp/usr install". + +One glitch: You may be running into the problem that Makefile.pre.in +doesn't try to create all the directories when they don't exist. Therefore, +you may have to create them manually before "make install". In most cases, +the following should work: + + ... + dh_installdirs /usr/lib/@PVER@ + $(MAKE) prefix=debian/tmp/usr install + ... + + +Byte-compilation +---------------- + +For speed reasons, Python internally compiles source files into a byte-code. +To speed up subsequent imports, it tries to save the byte-code along with +the source with an extension .pyc (resp. pyo). This will fail if the +libraries are installed in a non-writable directory, which may be the +case for /usr/lib/@PVER@/. + +Not that .pyc and .pyo files should not be relocated, since for debugging +purposes the path of the source for is hard-coded into them. + +To precompile files in batches after installation, Python has a script +compileall.py, which compiles all files in a given directory tree. The +Debian version of compileall has been enhanced to support incremental +compilation and to feature a ddir (destination dir) option. ddir is +used to compile files in debian/usr/lib/python/ when they will be +installed into /usr/lib/python/. + + +Currently, there are two ways to use compileall for Debian packages. The +first has a speed penalty, the second has a space penalty in the package. + +1.) Compiling and removing .pyc files in postinst/prerm: + + Use dh_python(1) from the debhelper packages to add commands to byte- + compile on installation and to remove the byte-compiled files on removal. + Your package has to build-depend on: debhelper (>= 4.1.67), python. + + In /usr/share/doc/@PVER@, you'll find sample.postinst and sample.prerm. + If you set the directory where the .py files are installed, these + scripts will install and remove the .pyc and .pyo files for your + package after unpacking resp. before removing the package. + +2.) Compiling the .pyc files `out of place' during installation: + + As of 1.5.1, compileall.py allows you to specify a faked installation + directory using the "-d destdir" option, so that you can precompile + the files in their temporary directory + (e.g. debian/tmp/usr/lib/python2.1/site-packages/PACKAGE). + + + + 11/02/98 + Gregor Hoffleit + + +Last modified: 2007-10-14 --- python2.7-2.7.5.orig/debian/pylogo.xpm +++ python2.7-2.7.5/debian/pylogo.xpm @@ -0,0 +1,351 @@ +/* XPM */ +static char * pylogo_xpm[] = { +"32 32 316 2", +" c None", +". c #8DB0CE", +"+ c #6396BF", +"@ c #4985B7", +"# c #4181B5", +"$ c #417EB2", +"% c #417EB1", +"& c #4D83B0", +"* c #6290B6", +"= c #94B2CA", +"- c #70A1C8", +"; c #3D83BC", +"> c #3881BD", +", c #387DB6", +"' c #387CB5", +") c #387BB3", +"! c #3779B0", +"~ c #3778AE", +"{ c #3776AB", +"] c #3776AA", +"^ c #3775A9", +"/ c #4A7FAC", +"( c #709FC5", +"_ c #3A83BE", +": c #5795C7", +"< c #94B9DB", +"[ c #73A4CE", +"} c #3D80B7", +"| c #387CB4", +"1 c #377AB2", +"2 c #377AB0", +"3 c #3777AC", +"4 c #3774A7", +"5 c #3773A5", +"6 c #3C73A5", +"7 c #4586BB", +"8 c #4489C1", +"9 c #A7C7E1", +"0 c #F7F9FD", +"a c #E1E9F1", +"b c #4C89BC", +"c c #3779AF", +"d c #3778AD", +"e c #3873A5", +"f c #4B7CA4", +"g c #3982BE", +"h c #4389C1", +"i c #A6C6E1", +"j c #F6F9FC", +"k c #D6E4F0", +"l c #4A88BB", +"m c #3773A6", +"n c #366F9F", +"o c #366E9D", +"p c #376E9C", +"q c #4A8BC0", +"r c #79A7CD", +"s c #548EBD", +"t c #387AB0", +"u c #3773A4", +"v c #366D9C", +"w c #387FBA", +"x c #387DB7", +"y c #387BB4", +"z c #3775A8", +"A c #366FA0", +"B c #4981AF", +"C c #427BAA", +"D c #3772A4", +"E c #376B97", +"F c #77A3C8", +"G c #4586BC", +"H c #3882BE", +"I c #3B76A7", +"J c #3B76A6", +"K c #366E9E", +"L c #376B98", +"M c #376B96", +"N c #5681A3", +"O c #F5EEB8", +"P c #FFED60", +"Q c #FFE85B", +"R c #FFE659", +"S c #FDE55F", +"T c #5592C4", +"U c #3A83BF", +"V c #3882BD", +"W c #387FB9", +"X c #3779AE", +"Y c #366F9E", +"Z c #366C98", +"` c #376A94", +" . c #5D85A7", +".. c #F5EDB7", +"+. c #FFEA5D", +"@. c #FFE75A", +"#. c #FFE354", +"$. c #FDDD56", +"%. c #669DC8", +"&. c #3885C3", +"*. c #3884C2", +"=. c #387EB8", +"-. c #387CB6", +";. c #377AB1", +">. c #3772A3", +",. c #366D9B", +"'. c #F5EBB5", +"). c #FFE557", +"!. c #FFE455", +"~. c #FFDF50", +"{. c #FFDB4C", +"]. c #FAD862", +"^. c #8EB4D2", +"/. c #3C86C1", +"(. c #3883C0", +"_. c #3882BF", +":. c #3881BC", +"<. c #3880BB", +"[. c #3775AA", +"}. c #F5EAB3", +"|. c #FFE051", +"1. c #FFDE4F", +"2. c #FFDA4A", +"3. c #FED446", +"4. c #F5DF9D", +"5. c #77A5CA", +"6. c #3885C2", +"7. c #387BB2", +"8. c #6B8EA8", +"9. c #F8E7A1", +"0. c #FFE153", +"a. c #FFDD4E", +"b. c #FFDB4B", +"c. c #FFD746", +"d. c #FFD645", +"e. c #FFD342", +"f. c #F6DB8D", +"g. c #508DBE", +"h. c #3771A3", +"i. c #376A95", +"j. c #3D6F97", +"k. c #C3CBC2", +"l. c #FBD964", +"m. c #FFDC4D", +"n. c #FFD544", +"o. c #FFD040", +"p. c #F9CF58", +"q. c #3F83BB", +"r. c #376B95", +"s. c #3A6C95", +"t. c #4E7BA0", +"u. c #91AABC", +"v. c #F6E4A3", +"w. c #FFDA4B", +"x. c #FFD646", +"y. c #FFD443", +"z. c #FFD241", +"A. c #FFCE3D", +"B. c #FFCC3B", +"C. c #FCC83E", +"D. c #3880BC", +"E. c #3C79AC", +"F. c #5F8DB4", +"G. c #7AA0C0", +"H. c #82A6C3", +"I. c #82A3BF", +"J. c #82A2BE", +"K. c #82A1BB", +"L. c #82A1B9", +"M. c #8BA4B5", +"N. c #C1C5AE", +"O. c #F2E19F", +"P. c #FDD74C", +"Q. c #FFD94A", +"R. c #FFD343", +"S. c #FFCE3E", +"T. c #FFCB39", +"U. c #FFC937", +"V. c #FEC636", +"W. c #3D79AB", +"X. c #9DB6C6", +"Y. c #D0CFA2", +"Z. c #EFE598", +"`. c #F8EE9B", +" + c #F8EB97", +".+ c #F8E996", +"++ c #F8E894", +"@+ c #FAE489", +"#+ c #FCDB64", +"$+ c #FFDA4D", +"%+ c #FFCF3E", +"&+ c #FFCB3A", +"*+ c #FFC734", +"=+ c #FFC532", +"-+ c #3F82B7", +";+ c #387EB9", +">+ c #9EB9D0", +",+ c #F2E287", +"'+ c #FDEB69", +")+ c #FEEC60", +"!+ c #FFEB5E", +"~+ c #FFE254", +"{+ c #FFE152", +"]+ c #FFD747", +"^+ c #FFC633", +"/+ c #FCC235", +"(+ c #578FBE", +"_+ c #6996BC", +":+ c #DED9A8", +"<+ c #FEEC62", +"[+ c #FFE658", +"}+ c #FFDF51", +"|+ c #FFDE50", +"1+ c #FFD03F", +"2+ c #FFCD3C", +"3+ c #FFC431", +"4+ c #FFBF2C", +"5+ c #FAC244", +"6+ c #85AACA", +"7+ c #A1BBD2", +"8+ c #F7E47C", +"9+ c #FFE456", +"0+ c #FFC735", +"a+ c #FFBC29", +"b+ c #F7D280", +"c+ c #9DBAD2", +"d+ c #3B7CB2", +"e+ c #ABC2D6", +"f+ c #FDEB7B", +"g+ c #FFC12E", +"h+ c #FDBD30", +"i+ c #F4DEA8", +"j+ c #5F91BA", +"k+ c #ABC1D4", +"l+ c #FDEE7E", +"m+ c #FFE253", +"n+ c #FFCC3C", +"o+ c #FFBA27", +"p+ c #FAC75B", +"q+ c #4A82B0", +"r+ c #3877AB", +"s+ c #3774A6", +"t+ c #AAC0D4", +"u+ c #FDEE7D", +"v+ c #FFEC5F", +"w+ c #FFE255", +"x+ c #FFD848", +"y+ c #FFD444", +"z+ c #FFCF3F", +"A+ c #FFBC2A", +"B+ c #FFBB28", +"C+ c #FDBA32", +"D+ c #447AA8", +"E+ c #4379A7", +"F+ c #FFE95C", +"G+ c #FFE558", +"H+ c #FFE355", +"I+ c #FED84B", +"J+ c #FCD149", +"K+ c #FBCE47", +"L+ c #FBCD46", +"M+ c #FBC840", +"N+ c #FBC63E", +"O+ c #FBC037", +"P+ c #FAC448", +"Q+ c #FDD44C", +"R+ c #FCD14E", +"S+ c #FFC836", +"T+ c #FFC22F", +"U+ c #FFC02D", +"V+ c #FFE052", +"W+ c #FFC636", +"X+ c #FFCF5C", +"Y+ c #FFD573", +"Z+ c #FFC33E", +"`+ c #FEBD2D", +" @ c #FFDB4D", +".@ c #FFD949", +"+@ c #FFD545", +"@@ c #FFD140", +"#@ c #FFCB48", +"$@ c #FFF7E4", +"%@ c #FFFCF6", +"&@ c #FFE09D", +"*@ c #FFBA2E", +"=@ c #FDBE2F", +"-@ c #FFD748", +";@ c #FFCA38", +">@ c #FFC844", +",@ c #FFF2D7", +"'@ c #FFF9EC", +")@ c #FFDB94", +"!@ c #FFB92D", +"~@ c #FAC54D", +"{@ c #FDD54E", +"]@ c #FFBD2D", +"^@ c #FFC858", +"/@ c #FFD174", +"(@ c #FFBF3E", +"_@ c #FCBD3C", +":@ c #FAD66A", +"<@ c #FECD3F", +"[@ c #FFC330", +"}@ c #FFBD2A", +"|@ c #FFB724", +"1@ c #FFB521", +"2@ c #FFB526", +"3@ c #FBC457", +"4@ c #F7E09E", +"5@ c #F8D781", +"6@ c #FAC349", +"7@ c #FCC134", +"8@ c #FEBE2C", +"9@ c #FBBE3F", +"0@ c #F7CF79", +"a@ c #F5D795", +" . + @ # $ % % & * = ", +" - ; > > , ' ) ! ~ { ] ^ / ", +" ( _ : < [ } | 1 2 ~ 3 4 5 5 6 ", +" 7 8 9 0 a b 2 c d 3 { 5 5 5 e f ", +" g h i j k l c ~ { { m 5 5 n o p ", +" > > q r s t c c d 4 5 u n v v v ", +" w x ' y 2 c d d z 5 u A v v v v ", +" B C 5 D v v v v E ", +" F G H H H x ' ) c c c d I J 5 K v v L M N O P Q R S ", +" T U H V V W ' ) c c X ~ 5 5 5 Y v v Z ` ` ...+.@.#.#.$. ", +" %.&.*.> w W =.-.;.c 3 { ^ 5 5 >.o v ,.E ` ` .'.).!.#.~.{.]. ", +"^./.(._.:.<., ' ) ;.X d [.5 5 >.K v ,.E ` ` ` .}.#.|.1.{.2.3.4.", +"5.6.(.H H x ' 7.c c 3 3 4 5 D K v v ,.` ` ` ` 8.9.0.a.b.c.d.e.f.", +"g._.> <.w ' ' | 2 3 { z 5 5 h.v v v i.` ` ` j.k.l.m.{.d.n.e.o.p.", +"q.> > :.-.' 1 c c c ] 5 5 >.v v ,.r.` ` s.t.u.v.{.w.x.y.z.A.B.C.", +"D.D.w -.' 1 c c c E.F.G.H.I.J.J.K.L.L.L.M.N.O.P.Q.c.R.S.B.T.U.V.", +"D.D.=.' ' 1 c c W.X.Y.Z.`.`.`.`.`. +.+++@+#+$+Q.d.R.%+B.&+*+=+=+", +"-+;+-.' ;.2 c c >+,+'+)+P P P !+Q R ~+{+1.{.]+d.y.%+B.&+^+=+=+/+", +"(+' ' ;.c X X _+:+<+P P P P !+R [+~+}+|+{.]+n.R.1+2+&+^+=+3+4+5+", +"6+' ) ! ~ { { 7+8+P P P P !+R 9+#.{+{.w.]+y.z.S.&+0+=+=+3+4+a+b+", +"c+d+7.! d 3 z e+f+P P P !+R 9+#.{+m.{.]+y.1+B.&+0+=+=+g+4+a+h+i+", +" j+c d 3 { 4 k+l+P P !+@.9+m+1.m.{.]+y.1+n+B.*+=+=+g+a+a+o+p+ ", +" q+r+{ s+m t+u+v+@.R w+{+}+{.x+d.y+z+n+B.0+=+=+g+A+a+B+C+ ", +" * D+E+E+ +.F+G+H+}+}+{.I+J+K+L+M+M+M+M+N+O+O+O+O+P+ ", +" ).).#.{+a.{.x+Q+R+ ", +" #.m+1.a.{.x+y.o.2+B.S+=+=+T+U+O+ ", +" 0.V+{.{.x+n.o.2+B.B.W+X+Y+Z+a+`+ ", +" @{..@+@n.@@B.B.S+^+#@$@%@&@*@=@ ", +" ].-@x.y.o.%+;@S+=+=+>@,@'@)@!@~@ ", +" {@z.z+2+U.=+=+=+T+]@^@/@(@_@ ", +" :@<@U.=+=+[@4+}@|@1@2@3@ ", +" 4@5@6@7@8@a+a+9@0@a@ "}; --- python2.7-2.7.5.orig/debian/README.dbm +++ python2.7-2.7.5/debian/README.dbm @@ -0,0 +1,72 @@ + + Python and dbm modules on Debian + -------------------------------- + +This file documents the configuration of the dbm modules for Debian. It +gives hints at the preferred use of the dbm modules. + + +The preferred way to access dbm databases in Python is the anydbm module. +dbm databases behave like mappings (dictionaries). + +Since there exist several dbm database formats, we choose the following +layout for Python on Debian: + + * creating a new database with anydbm will create a Berkeley DB 2.X Hash + database file. This is the standard format used by libdb starting + with glibc 2.1. + + * opening an existing database with anydbm will try to guess the format + of the file (using whichdb) and then load it using one of the bsddb, + bsddb1, gdbm or dbm (only if the python-gdbm package is installed) + or dumbdbm modules. + + * The modules use the following database formats: + + - bsddb: Berkeley DB 2.X Hash (as in libc6 >=2.1 or libdb2) + - bsddb1: Berkeley DB 1.85 Hash (as in libc6 >=2.1 or libdb2) + - gdbm: GNU dbm 1.x or ndbm + - dbm: " (nearly the same as the gdbm module for us) + - dumbdbm: a hand-crafted format only used in this module + + That means that all usual formats should be readable with anydbm. + + * If you want to create a database in a format different from DB 2.X, + you can still directly use the specified module. + + * I.e. bsddb is the preferred module, and DB 2.X is the preferred format. + + * Note that the db1hash and bsddb1 modules are Debian specific. anydbm + and whichdb have been modified to support DB 2.X Hash files (see + below for details). + + + +For experts only: +---------------- + +Although bsddb employs the new DB 2.X format and uses the new Sleepycat +DB 2 library as included with glibc >= 2.1, it's still using the old +DB 1.85 API (which is still supported by DB 2). + +A more recent version 1.1 of the BSD DB module (available from +http://starship.skyport.net/robind/python/) directly uses the DB 2.X API. +It has a richer set of features. + + +On a glibc 2.1 system, bsddb is linked with -ldb, bsddb1 is linked with +-ldb1 and gdbm as well as dbm are linked with -lgdbm. + +On a glibc 2.0 system (e.g. potato for m68k or slink), bsddb will be +linked with -ldb2 while bsddb1 will be linked with -ldb (therefore +python-base here depends on libdb2). + + +db1hash and bsddb1 nearly completely identical to dbhash and bsddb. The +only difference is that bsddb is linked with the real DB 2 library, while +bsddb1 is linked with an library which provides compatibility with legacy +DB 1.85 databases. + + + July 16, 1999 + Gregor Hoffleit --- python2.7-2.7.5.orig/debian/PVER-doc.doc-base.PVER-new.in +++ python2.7-2.7.5/debian/PVER-doc.doc-base.PVER-new.in @@ -0,0 +1,10 @@ +Document: @PVER@-new +Title: What's new in Python @VER@ +Author: A.M. Kuchling +Abstract: This documents lists new features and changes worth mentioning + in Python @VER@. +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/@PVER@/html/whatsnew/@VER@.html +Files: /usr/share/doc/@PVER@/html/whatsnew/@VER@.html --- python2.7-2.7.5.orig/debian/idle-PVER.postinst.in +++ python2.7-2.7.5/debian/idle-PVER.postinst.in @@ -0,0 +1,32 @@ +#! /bin/sh +# +# postinst script for the Debian idle-@PVER@ package. +# Written 1998 by Gregor Hoffleit . +# + +set -e + +DIRLIST="/usr/lib/python@VER@/idlelib" + +case "$1" in + configure|abort-upgrade|abort-remove|abort-deconfigure) + + for i in $DIRLIST ; do + @PVER@ /usr/lib/@PVER@/compileall.py -q $i + if grep -sq '^byte-compile[^#]*optimize' /etc/python/debian_config + then + @PVER@ -O /usr/lib/@PVER@/compileall.py -q $i + fi + done + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; + +esac + +#DEBHELPER# + +exit 0 --- python2.7-2.7.5.orig/debian/libPVER-dbg.symbols.in +++ python2.7-2.7.5/debian/libPVER-dbg.symbols.in @@ -0,0 +1,33 @@ +libpython@VER@_d.so.1.0 libpython@VER@-dbg #MINVER# + Py_InitModule4TraceRefs@Base @VER@ +#include "libpython.symbols" + _PyDict_Dummy@Base @VER@ + _PyMem_DebugFree@Base @VER@ + _PyMem_DebugMalloc@Base @VER@ + _PyMem_DebugRealloc@Base @VER@ + _PyObject_DebugCheckAddress@Base @VER@ + _PyObject_DebugCheckAddressApi@Base @VER@ + _PyObject_DebugDumpAddress@Base @VER@ + _PyObject_DebugFree@Base @VER@ + _PyObject_DebugFreeApi@Base @VER@ + _PyObject_DebugMalloc@Base @VER@ + _PyObject_DebugMallocApi@Base @VER@ + _PyObject_DebugMallocStats@Base @VER@ + _PyObject_DebugRealloc@Base @VER@ + _PyObject_DebugReallocApi@Base @VER@ + _PySet_Dummy@Base @VER@ + _Py_AddToAllObjects@Base @VER@ + _Py_Dealloc@Base @VER@ + _Py_ForgetReference@Base @VER@ + _Py_GetObjects@Base @VER@ + _Py_GetRefTotal@Base @VER@ + _Py_HashSecret_Initialized@Base @VER@ + _Py_NegativeRefcount@Base @VER@ + _Py_NewReference@Base @VER@ + _Py_PrintReferenceAddresses@Base @VER@ + _Py_PrintReferences@Base @VER@ + _Py_RefTotal@Base @VER@ + _Py_dumptree@Base @VER@ + _Py_printtree@Base @VER@ + _Py_showtree@Base @VER@ + _Py_tok_dump@Base @VER@ --- python2.7-2.7.5.orig/debian/libPVER.symbols.in +++ python2.7-2.7.5/debian/libPVER.symbols.in @@ -0,0 +1,3 @@ +libpython@VER@.so.1.0 libpython@VER@ #MINVER# + Py_InitModule4@Base @VER@ +#include "libpython.symbols" --- python2.7-2.7.5.orig/debian/PVER-doc.doc-base.PVER-tut.in +++ python2.7-2.7.5/debian/PVER-doc.doc-base.PVER-tut.in @@ -0,0 +1,13 @@ +Document: @PVER@-tut +Title: Python Tutorial (v@VER@) +Author: Guido van Rossum, Fred L. Drake, Jr., editor +Abstract: This tutorial introduces the reader informally to the basic + concepts and features of the Python language and system. It helps + to have a Python interpreter handy for hands-on experience, but + all examples are self-contained, so the tutorial can be read + off-line as well. +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/@PVER@/html/tutorial/index.html +Files: /usr/share/doc/@PVER@/html/tutorial/*.html --- python2.7-2.7.5.orig/debian/rules +++ python2.7-2.7.5/debian/rules @@ -0,0 +1,1365 @@ +#!/usr/bin/make -f + +unexport LANG LC_ALL LC_CTYPE LC_COLLATE LC_TIME LC_NUMERIC LC_MESSAGES +unexport CFLAGS CXXFLAGS CPPFLAGS LDFLAGS + +export SHELL = /bin/bash + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +vafilt = $(subst $(2)=,,$(filter $(2)=%,$(1))) + +DPKG_VARS := $(shell dpkg-architecture) +DEB_BUILD_ARCH ?= $(call vafilt,$(DPKG_VARS),DEB_BUILD_ARCH) +DEB_BUILD_GNU_TYPE ?= $(call vafilt,$(DPKG_VARS),DEB_BUILD_GNU_TYPE) +DEB_HOST_ARCH ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_ARCH) +DEB_HOST_ARCH_BITS ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_ARCH_BITS) +DEB_HOST_ARCH_ENDIAN ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_ARCH_ENDIAN) +DEB_HOST_ARCH_OS ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_ARCH_OS) +DEB_HOST_GNU_TYPE ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_GNU_TYPE) +DEB_HOST_MULTIARCH ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_MULTIARCH) + +changelog_values := $(shell dpkg-parsechangelog \ + | awk '/^(Version|Source):/ {print $$2}') +PKGSOURCE := $(word 1, $(changelog_values)) +PKGVERSION := $(word 2, $(changelog_values)) + +on_buildd := $(shell [ -f /CurrentlyBuilding -o "$$LOGNAME" = buildd -o "$$USER" = buildd ] && echo yes) + +ifneq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS))) + WITHOUT_CHECK := yes +endif +WITHOUT_BENCH := +ifneq (,$(findstring nobench, $(DEB_BUILD_OPTIONS))) + WITHOUT_BENCH := yes +endif +ifneq (,$(filter $(DEB_HOST_ARCH), hurd-i386)) + WITHOUT_BENCH := disabled on $(DEB_HOST_ARCH) +endif +ifeq ($(on_buildd),yes) + ifneq (,$(findstring $(DEB_HOST_ARCH), hppa mips mipsel s390)) + WITHOUT_CHECK := yes + endif +endif +ifneq (,$(filter $(DEB_HOST_ARCH), hurd-i386 kfreebsd-amd64 kfreebsd-i386)) + WITHOUT_CHECK := yes +endif +ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) + WITHOUT_BENCH := yes + WITHOUT_CHECK := yes +endif + +COMMA = , +ifneq (,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS)))) + NJOBS := -j $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS)))) +endif + +distribution := $(shell lsb_release -is) +distrelease := $(shell lsb_release -cs) + +VER=2.7 +NVER=2.8 +PVER=python2.7 +PRIORITY=$(shell echo $(VER) | tr -d '.')0 + +PREVVER := $(shell awk '/^python/ && NR > 1 {print substr($$2,2,length($$2)-2); exit}' debian/changelog) + +# default versions are built from the python-defaults source package +# keep the definition to adjust package priorities. +DEFAULT_VERSION = yes +STATIC_PYTHON=yes + +MIN_MODS := $(shell awk '/^ / && $$2 == "module" { print $$1 }' \ + debian/PVER-minimal.README.Debian.in) +MIN_EXTS := $(shell awk '/^ / && $$2 ~ /^extension/ { print $$1 }' \ + debian/PVER-minimal.README.Debian.in) +MIN_BUILTINS := $(shell awk '/^ / && $$2 == "builtin" { print $$1 }' \ + debian/PVER-minimal.README.Debian.in) +MIN_PACKAGES := $(shell awk '/^ / && $$2 == "package" { print $$1 }' \ + debian/PVER-minimal.README.Debian.in) +MIN_ENCODINGS := $(foreach i, \ + $(filter-out \ + big5% bz2% cp932.py cp949.py cp950.py euc_% \ + gb% iso2022% johab.py shift_jis% , \ + $(shell cd Lib/encodings && echo *.py)), \ + encodings/$(i)) \ + codecs.py stringprep.py + +with_tk := no +with_gdbm := no +with_interp := static +#with_interp := shared + +PY_INTERPRETER = /usr/bin/python$(VER) + +ifeq ($(DEFAULT_VERSION),yes) + PY_PRIO = standard + #PYSTDDEP = , python (>= $(VER)) + ifeq ($(distribution),Ubuntu) + PY_MINPRIO = required + else + PY_MINPRIO = $(PY_PRIO) + endif +else + PY_PRIO = optional + PY_MINPRIO = $(PY_PRIO) +endif +with_fpectl = yes + +ifeq (,$(filter $(distrelease),lenny etch squeeze wheezy jessie sid lucid maverick natty oneiric)) + bd_qual = :any +endif +ifeq (,$(filter $(distrelease),lenny etch squeeze wheezy lucid maverick natty oneiric)) + ma_filter = cat +else + ma_filter = grep -v '^Multi-Arch:' +endif + +CC = $(DEB_HOST_GNU_TYPE)-gcc + +DPKG_CFLAGS := $(shell dpkg-buildflags --get CPPFLAGS; dpkg-buildflags --get CFLAGS) +DPKG_LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS) +OPT_CFLAGS := $(filter-out -O%,$(DPKG_CFLAGS)) # default is -O3 +DEBUG_CFLAGS := $(filter-out -D_FORTIFY_SOURCE=%,$(patsubst -O%,-O0,$(DPKG_CFLAGS))) + +# on alpha, use -O2 only, use -mieee +ifeq ($(DEB_HOST_ARCH),alpha) + OPT_CFLAGS += -mieee + DEBUG_CFLAGS += -mieee + EXTRA_OPT_FLAGS += -O2 +endif +# issues with ia64 and m68k with -O3 +ifeq ($(DEB_HOST_ARCH),m68k) + EXTRA_OPT_FLAGS += -O2 +endif + +ifeq ($(DEB_HOST_ARCH_OS),linux) + ifneq (,$(findstring $(DEB_HOST_ARCH), amd64 armel armhf i386 powerpc ppc64)) + with_pgo := yes + endif +endif +ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) + with_pgo := +endif +ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) + with_pgo := +endif + +ifneq (,$(findstring $(DEB_HOST_ARCH), amd64 armel armhf i386)) + with_lto := yes +endif + +ifneq (,$(findstring noopt, $(DEB_BUILD_OPTIONS))) + OPT_CFLAGS := $(filter-out -O%, $(OPT_CFLAGS)) + EXTRA_OPT_CFLAGS = -O0 + with_pgo = + with_lto = +endif + +ifeq ($(with_lto),yes) + LTO_CFLAGS = -g -flto -fuse-linker-plugin + EXTRA_OPT_CFLAGS += $(LTO_CFLAGS) +endif + +make_build_target = $(if $(with_pgo),profile-opt) + +buildd_static := $(CURDIR)/build-static +buildd_shared := $(CURDIR)/build-shared +buildd_debug := $(CURDIR)/build-debug +buildd_shdebug := $(CURDIR)/build-shdebug + +d := debian/tmp +scriptdir = usr/share/lib/python$(VER) +scriptdir = usr/share/python$(VER) +scriptdir = usr/lib/python$(VER) + +# package names and directories +p_base := $(PVER) +p_min := $(PVER)-minimal +p_lib := lib$(PVER) +p_tk := $(PVER)-tk +p_gdbm := $(PVER)-gdbm +p_dev := $(PVER)-dev +p_exam := $(PVER)-examples +p_idle := idle-$(PVER) +p_doc := $(PVER)-doc +p_dbg := $(PVER)-dbg + +p_lbase := lib$(PVER)-stdlib +p_lmin := lib$(PVER)-minimal +p_ldev := lib$(PVER)-dev +p_ldbg := lib$(PVER)-dbg +p_ltst := lib$(PVER)-testsuite + +d_base := debian/$(p_base) +d_min := debian/$(p_min) +d_lib := debian/$(p_lib) +d_tk := debian/$(p_tk) +d_gdbm := debian/$(p_gdbm) +d_dev := debian/$(p_dev) +d_exam := debian/$(p_exam) +d_idle := debian/$(p_idle) +d_doc := debian/$(p_doc) +d_dbg := debian/$(p_dbg) + +d_lbase := debian/$(p_lbase) +d_lmin := debian/$(p_lmin) +d_ldev := debian/$(p_ldev) +d_ldbg := debian/$(p_ldbg) +d_ltst := debian/$(p_ltst) + +build-arch: stamps/stamp-build +build-indep: stamps/stamp-build-doc +build: build-arch +stamps/stamp-build: stamps/stamp-build-static stamps/stamp-mincheck \ + stamps/stamp-build-shared stamps/stamp-build-debug \ + stamps/stamp-build-shared-debug \ + stamps/stamp-check stamps/stamp-pystone stamps/stamp-pybench + touch $@ + +PROFILE_EXCLUDES = test_compiler test_distutils test_platform test_subprocess \ + test_multiprocessing test_cprofile \ + test_thread test_threaded_import test_threadedtempfile \ + test_socketserver \ + test_threading test_threading_local test_threadsignals \ + test_dbm_dumb test_dbm_ndbm test_pydoc test_sundry test_gdb \ + +ifneq (,$(filter $(DEB_HOST_ARCH), arm armel)) + PROFILE_EXCLUDES += test_float +endif +ifneq (,$(filter $(DEB_HOST_ARCH), kfreebsd-amd64 kfreebsd-i386)) + PROFILE_EXCLUDES += test_io +endif +PROFILE_EXCLUDES += test_zipfile +PROFILE_EXCLUDES += test_xmlrpc +PROFILE_EXCLUDES += test_bsddb3 + +PROFILE_TASK = ../Lib/test/regrtest.py \ + -x $(sort $(TEST_EXCLUDES) $(PROFILE_EXCLUDES)) + +stamps/stamp-build-static: stamps/stamp-configure-static + dh_testdir + $(MAKE) $(NJOBS) -C $(buildd_static) \ + EXTRA_CFLAGS="$(EXTRA_OPT_CFLAGS)" \ + PROFILE_TASK='$(PROFILE_TASK)' $(make_build_target) + + : # check that things are correctly built +ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) + ifneq (,$(filter $(DEB_HOST_ARCH_OS), linux)) + cd $(buildd_static) && ./python -c 'from _multiprocessing import SemLock' + endif +endif + + touch stamps/stamp-build-static + +stamps/stamp-build-shared: stamps/stamp-configure-shared + dh_testdir + $(MAKE) $(NJOBS) -C $(buildd_shared) \ + EXTRA_CFLAGS="$(EXTRA_OPT_CFLAGS)" +# : # build the shared library +# $(MAKE) $(NJOBS) -C $(buildd_shared) \ +# libpython$(VER).so + : # build a static library with PIC objects + $(MAKE) $(NJOBS) -C $(buildd_shared) \ + EXTRA_CFLAGS="$(EXTRA_OPT_CFLAGS)" \ + LIBRARY=libpython$(VER)-pic.a libpython$(VER)-pic.a + touch stamps/stamp-build-shared + +stamps/stamp-build-debug: stamps/stamp-configure-debug + dh_testdir + $(MAKE) $(NJOBS) -C $(buildd_debug) \ + EXTRA_CFLAGS="$(DEBUG_CFLAGS)" + touch stamps/stamp-build-debug + +stamps/stamp-build-shared-debug: stamps/stamp-configure-shared-debug + dh_testdir + : # build the shared debug library + $(MAKE) $(NJOBS) -C $(buildd_shdebug) \ + EXTRA_CFLAGS="$(DEBUG_CFLAGS)" + touch stamps/stamp-build-shared-debug + +common_configure_args = \ + --prefix=/usr \ + --enable-ipv6 \ + --enable-unicode=ucs4 \ + --with-dbmliborder=bdb:gdbm \ + --with-system-expat + +ifeq ($(DEB_HOST_ARCH), avr32) + common_configure_args += --without-ffi +else + common_configure_args += --with-system-ffi +endif + +ifeq ($(with_fpectl),yes) + common_configure_args += \ + --with-fpectl +endif + +ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) + common_configure_args += --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) + config_site = ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=yes + ifeq (,$(filter $(DEB_HOST_ARCH),arm m68k)) + ifeq ($(DEB_HOST_ARCH_ENDIAN),little) + config_site += ac_cv_little_endian_double=yes + else + config_site += ac_cv_big_endian_double=yes + endif + endif +endif + +stamps/stamp-configure-shared: stamps/stamp-patch + rm -rf $(buildd_shared) + mkdir -p $(buildd_shared) + cd $(buildd_shared) && \ + CC="$(CC)" CFLAGS="$(OPT_CFLAGS)" LDFLAGS="$(DPKG_LDFLAGS)" \ + $(config_site) \ + ../configure \ + --enable-shared \ + $(common_configure_args) + + $(call __post_configure,$(buildd_shared)) + + touch stamps/stamp-configure-shared + +stamps/stamp-configure-static: stamps/stamp-patch + rm -rf $(buildd_static) + mkdir -p $(buildd_static) + cd $(buildd_static) && \ + CC="$(CC)" CFLAGS="$(OPT_CFLAGS)" LDFLAGS="$(DPKG_LDFLAGS)" \ + $(config_site) \ + ../configure \ + $(common_configure_args) + + $(call __post_configure,$(buildd_static)) + + touch stamps/stamp-configure-static + +stamps/stamp-configure-debug: stamps/stamp-patch + rm -rf $(buildd_debug) + mkdir -p $(buildd_debug) + cd $(buildd_debug) && \ + CC="$(CC)" CFLAGS="$(DEBUG_CFLAGS)" LDFLAGS="$(DPKG_LDFLAGS)" \ + $(config_site) \ + ../configure \ + $(common_configure_args) \ + --with-pydebug + + $(call __post_configure,$(buildd_debug)) + + touch stamps/stamp-configure-debug + +stamps/stamp-configure-shared-debug: stamps/stamp-patch + rm -rf $(buildd_shdebug) + mkdir -p $(buildd_shdebug) + cd $(buildd_shdebug) && \ + CC="$(CC)" CFLAGS="$(DEBUG_CFLAGS)" LDFLAGS="$(DPKG_LDFLAGS)" \ + $(config_site) \ + ../configure \ + $(common_configure_args) \ + --enable-shared \ + --with-pydebug + + $(call __post_configure,$(buildd_shdebug)) + + touch stamps/stamp-configure-shared-debug + +define __post_configure + egrep \ + "^#($$(awk -v ORS='|' '$$2 ~ /^extension$$/ {print $$1}' debian/PVER-minimal.README.Debian.in)XX)" \ + Modules/Setup.dist \ + | sed -e 's/^#//' -e 's/-Wl,-Bdynamic//;s/-Wl,-Bstatic//' \ + >> $(1)/Modules/Setup.local + + : # unconditionally run makesetup + cd $(1) && \ + ../Modules/makesetup -c ../Modules/config.c.in -s Modules \ + Modules/Setup.config Modules/Setup.local Modules/Setup + mv $(1)/config.c $(1)/Modules/ + + : # and fix the timestamps + $(MAKE) -C $(1) Makefile Modules/config.c + + : # apply workaround for missing os.fsync + sed 's/HAVE_SYNC/HAVE_FSYNC/g' $(1)/pyconfig.h \ + > $(1)/pyconfig.h.new + touch -r $(1)/pyconfig.h $(1)/pyconfig.h.new + mv -f $(1)/pyconfig.h.new $(1)/pyconfig.h +endef + +stamps/stamp-mincheck: stamps/stamp-build-static debian/PVER-minimal.README.Debian.in +ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) + for m in $(MIN_MODS) $(MIN_PACKAGES) $(MIN_EXTS) $(MIN_BUILTINS); do \ + echo "import $$m"; \ + done > $(buildd_static)/minmods.py + cd $(buildd_static) && ./python ../debian/pymindeps.py minmods.py \ + > $(buildd_static)/mindeps.txt + if [ -x /usr/bin/dot ]; then \ + python debian/depgraph.py < $(buildd_static)/mindeps.txt \ + > $(buildd_static)/mindeps.dot; \ + dot -Tpng -o $(buildd_static)/mindeps.png \ + $(buildd_static)/mindeps.dot; \ + else true; fi + cd $(buildd_static) && ./python ../debian/mincheck.py \ + minmods.py mindeps.txt +endif + touch stamps/stamp-mincheck + +TEST_RESOURCES = all +ifeq ($(on_buildd),yes) + TEST_RESOURCES := $(TEST_RESOURCES),-network,-urlfetch,-bsddb +endif +TESTOPTS = -w -l -u$(TEST_RESOURCES) +TEST_EXCLUDES = +ifeq ($(on_buildd),yes) + TEST_EXCLUDES += test_codecmaps_cn test_codecmaps_hk \ + test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw \ + test_normalization test_ossaudiodev + ifneq (,$(filter $(DEB_HOST_ARCH), mips mipsel powerpc kfreebsd-i386 sparc)) + TEST_EXCLUDES += test_threading + endif + ifeq (,$(wildcard $(HOME))) + TEST_EXCLUDES += test_site + endif +endif +ifeq (,$(wildcard /dev/dsp)) + TEST_EXCLUDES += test_linuxaudiodev test_ossaudiodev +endif +ifneq (,$(filter $(DEB_HOST_ARCH), armel hppa powerpc)) + TEST_EXCLUDES += test_multiprocessing +endif +ifneq (,$(filter $(DEB_HOST_ARCH), hppa)) + TEST_EXCLUDES += test_fork1 test_socketserver test_threading test_wait3 test_wait4 test_gdb +endif +ifneq (,$(filter $(DEB_HOST_ARCH), arm avr32)) + TEST_EXCLUDES += test_ctypes +endif +TEST_EXCLUDES += test_bsddb3 +ifneq (,$(filter $(DEB_HOST_ARCH), arm armel avr32 m68k)) + ifeq ($(on_buildd),yes) + TEST_EXCLUDES += test_compiler + endif +endif +TEST_EXCLUDES += test_gdb +# fails on some buildds +ifneq (,$(filter $(DEB_HOST_ARCH), amd64 armel armhf mips mipsel)) + TEST_EXCLUDES += test_io +endif +ifneq (,$(filter $(DEB_HOST_ARCH), kfreebsd-amd64 kfreebsd-i386)) + TEST_EXCLUDES += test_io test_signal +endif +ifneq (,$(filter $(DEB_HOST_ARCH), hurd-i386)) + TEST_EXCLUDES += test_io test_random test_signal test_socket test_socketserver test_ssl \ + test_threading test_subprocess +endif +ifneq (,$(filter $(DEB_HOST_ARCH), ia64)) + TEST_EXCLUDES += test_threading test_subprocess +endif +ifneq (,$(TEST_EXCLUDES)) + TESTOPTS += -x $(sort $(TEST_EXCLUDES)) + ifneq (,$(filter $(DEB_HOST_ARCH), mips mipsel)) + TESTOPTS_DEBUG := $(TESTOPTS) + else + TESTOPTS_DEBUG := $(filter-out test_gdb,$(TESTOPTS)) + endif +endif + +ifneq (,$(wildcard /usr/bin/localedef)) + SET_LOCPATH = LOCPATH=$(CURDIR)/locales +endif + +stamps/stamp-check: +ifeq ($(WITHOUT_CHECK),yes) + echo "check run disabled for this build" > $(buildd_static)/test_results +else + : # build locales needed by the testsuite + rm -rf locales + mkdir locales + if which localedef >/dev/null 2>&1; then \ + sh debian/locale-gen; \ + fi + + @echo ========== test environment ============ + @env + @echo ======================================== + ifeq (,$(findstring $(DEB_HOST_ARCH), alpha)) + ( \ + echo '#! /bin/sh'; \ + echo 'set -x'; \ + echo 'export TERM=$${TERM:-dumb}'; \ + echo '$(buildd_static)/python $(CURDIR)/debian/script.py test_results '\''make test TESTOPTS="$(TESTOPTS_DEBUG)"'\'; \ + echo 'echo DONE'; \ + ) > $(buildd_debug)/run_tests + chmod 755 $(buildd_debug)/run_tests + @echo "BEGIN test debug" + -cd $(buildd_debug) && time xvfb-run -a -e xvfb-run.log ./run_tests + @echo "END test debug" + endif + + ( \ + echo '#! /bin/sh'; \ + echo 'set -x'; \ + echo 'export TERM=$${TERM:-dumb}'; \ + echo 'export $(SET_LOCPATH)'; \ + echo '$(buildd_static)/python $(CURDIR)/debian/script.py test_results '\''make test EXTRA_CFLAGS="$(EXTRA_OPT_CFLAGS)" TESTOPTS="$(TESTOPTS)"'\'; \ + echo 'echo DONE'; \ + ) > $(buildd_static)/run_tests + chmod 755 $(buildd_static)/run_tests + @echo "BEGIN test static" + -cd $(buildd_static) && time xvfb-run -a -e xvfb-run.log ./run_tests + @echo "END test static" + + ( \ + echo '#! /bin/sh'; \ + echo 'set -x'; \ + echo 'export TERM=$${TERM:-dumb}'; \ + echo 'export $(SET_LOCPATH)'; \ + echo '$(buildd_static)/python $(CURDIR)/debian/script.py test_results '\''make test EXTRA_CFLAGS="$(EXTRA_OPT_CFLAGS)" TESTOPTS="$(TESTOPTS)"'\'; \ + echo 'echo DONE'; \ + ) > $(buildd_shared)/run_tests + chmod 755 $(buildd_shared)/run_tests + @echo "BEGIN test shared" + -cd $(buildd_shared) && time xvfb-run -a -e xvfb-run.log ./run_tests + @echo "END test shared" +endif + cp -p $(buildd_static)/test_results debian/ + touch stamps/stamp-check + +stamps/stamp-pystone: +ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) + @echo "BEGIN pystone static" + cd $(buildd_static) && ./python ../Lib/test/pystone.py + cd $(buildd_static) && ./python ../Lib/test/pystone.py + @echo "END pystone static" + @echo "BEGIN pystone shared" + cd $(buildd_shared) \ + && LD_LIBRARY_PATH=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}. ./python ../Lib/test/pystone.py + cd $(buildd_shared) \ + && LD_LIBRARY_PATH=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}. ./python ../Lib/test/pystone.py + @echo "END pystone shared" + @echo "BEGIN pystone debug" + cd $(buildd_debug) && ./python ../Lib/test/pystone.py + cd $(buildd_debug) && ./python ../Lib/test/pystone.py + @echo "END pystone debug" +endif + touch stamps/stamp-pystone + +#ifeq (,$(filter $(DEB_HOST_ARCH), arm armel avr32 hppa mips mipsel m68k)) + pybench_options = -C 2 -n 5 -w 4 +#endif + +stamps/stamp-pybench: +ifeq ($(WITHOUT_BENCH),yes) + echo "pybench run disabled for this build" > $(buildd_static)/pybench.log +else + @echo "BEGIN pybench static" + cd $(buildd_static) \ + && time ./python ../Tools/pybench/pybench.py -f run1.pybench $(pybench_options) + cd $(buildd_static) \ + && ./python ../Tools/pybench/pybench.py -f run2.pybench -c run1.pybench $(pybench_options) + @echo "END pybench static" + @echo "BEGIN pybench shared" + cd $(buildd_shared) \ + && LD_LIBRARY_PATH=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}. \ + ./python ../Tools/pybench/pybench.py -f run1.pybench $(pybench_options) + cd $(buildd_shared) \ + && LD_LIBRARY_PATH=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}. \ + ./python ../Tools/pybench/pybench.py -f run2.pybench -c run1.pybench $(pybench_options) + @echo "END pybench shared" + @echo "BEGIN shared/static comparision" + $(buildd_static)/python Tools/pybench/pybench.py \ + -s $(buildd_static)/run2.pybench -c $(buildd_shared)/run2.pybench \ + | tee $(buildd_static)/pybench.log + @echo "END shared/static comparision" +endif + touch stamps/stamp-pybench + +minimal-test: + rm -rf mintest + mkdir -p mintest/lib mintest/dynlib mintest/testlib mintest/all-lib + cp -p $(buildd_static)/python mintest/ + cp -p $(foreach i,$(MIN_MODS),Lib/$(i).py) \ + mintest/lib/ + cp -a $(foreach i,$(MIN_PACKAGES),Lib/$(i)) \ + mintest/lib/ + cp -p $(wildcard $(foreach i,$(MIN_EXTS),$(buildd_static)/build/lib*/$(i).*.so)) \ + mintest/dynlib/ + cp -p Lib/unittest.py mintest/lib/ + cp -pr Lib/test mintest/lib/ + cp -pr Lib mintest/all-lib + cp -p $(buildd_static)/build/lib*/*.so mintest/all-lib/ + ( \ + echo "import sys"; \ + echo "sys.path = ["; \ + echo " '$(CURDIR)/mintest/lib',"; \ + echo " '$(CURDIR)/mintest/dynlib',"; \ + echo "]"; \ + cat Lib/test/regrtest.py; \ + ) > mintest/lib/test/mintest.py + cd mintest && ./python -E -S lib/test/mintest.py \ + -x test_codecencodings_cn test_codecencodings_hk \ + test_codecencodings_jp test_codecencodings_kr \ + test_codecencodings_tw test_codecs test_multibytecodec \ + +stamps/stamp-doc-html: + dh_testdir + $(MAKE) -C Doc html + touch stamps/stamp-doc-html + +build-doc: stamps/stamp-patch stamps/stamp-build-doc +stamps/stamp-build-doc: stamps/stamp-doc-html + touch stamps/stamp-build-doc + +control-file: + sed -e "s/@PVER@/$(PVER)/g" \ + -e "s/@VER@/$(VER)/g" \ + -e "s/@PYSTDDEP@/$(PYSTDDEP)/g" \ + -e "s/@PRIO@/$(PY_PRIO)/g" \ + -e "s/@MINPRIO@/$(PY_MINPRIO)/g" \ + -e "s/@bd_qual@/$(bd_qual)/g" \ + debian/control.in \ + | $(ma_filter) \ + > debian/control.tmp +ifeq ($(distribution),Ubuntu) + ifneq (,$(findstring ubuntu, $(PKGVERSION))) + m='Ubuntu Core Developers '; \ + sed -i "/^Maintainer:/s/\(.*\)/Maintainer: $$m\nXSBC-Original-\1/" \ + debian/control.tmp + endif +endif + [ -e debian/control ] \ + && cmp -s debian/control debian/control.tmp \ + && rm -f debian/control.tmp && exit 0; \ + mv debian/control.tmp debian/control + + + +clean: control-file + dh_testdir + dh_testroot + $(MAKE) -f debian/rules unpatch + rm -rf stamps .pc + rm -f debian/test_results + + $(MAKE) -C Doc clean + sed 's/^@/#/' Makefile.pre.in | $(MAKE) -f - srcdir=. distclean + rm -rf Lib/test/db_home + rm -rf $(buildd_static) $(buildd_shared) $(buildd_debug) $(buildd_shdebug) + find -name '*.py[co]' | xargs -r rm -f + rm -f Lib/lib2to3/*.pickle + rm -rf Lib/plat-$(DEB_HOST_MULTIARCH) + rm -rf locales + rm -rf $(d)-dbg $(d)-shdbg + + for f in debian/*.in; do \ + f2=`echo $$f | sed "s,PVER,$(PVER),g;s/@VER@/$(VER)/g;s,\.in$$,,"`; \ + if [ $$f2 != debian/control ] && [ $$f2 != debian/source.lintian-overrides ]; then \ + rm -f $$f2; \ + fi; \ + done + dh_clean + +stamps/stamp-control: + : # We have to prepare the various control files + + for f in debian/*.in; do \ + f2=`echo $$f | sed "s,PVER,$(PVER),g;s/@VER@/$(VER)/g;s,\.in$$,,"`; \ + if [ $$f2 != debian/control ]; then \ + sed -e "s/@PVER@/$(PVER)/g;s/@VER@/$(VER)/g" \ + -e "s/@PRIORITY@/$(PRIORITY)/g" \ + -e "s,@SCRIPTDIR@,/$(scriptdir),g" \ + -e "s,@INFO@,$(info_docs),g" \ + <$$f >$$f2; \ + fi; \ + done +ifeq ($(DEB_HOST_ARCH_BITS),64) + sed -i 's/\(Py_InitModule4[^@]*\)@/\1_64@/' \ + debian/lib$(PVER).symbols debian/lib$(PVER)-dbg.symbols +endif + +2to3-man: + help2man --no-info --version-string=$(VER) --no-discard-stderr \ + --name 'Python2 to Python3 converter' \ + 2to3-$(VER) > debian/2to3-$(VER).1 + +install: build-arch stamps/stamp-install +stamps/stamp-install: stamps/stamp-build control-file stamps/stamp-control + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + : # make install into tmp and subsequently move the files into + : # their packages' directories. + install -d $(d)/usr +ifeq ($(with_interp),static) + $(MAKE) -C $(buildd_static) install prefix=$(CURDIR)/$(d)/usr +else + $(MAKE) -C $(buildd_shared) install prefix=$(CURDIR)/$(d)/usr +endif + mkdir -p $(d)/usr/include/$(DEB_HOST_MULTIARCH)/$(PVER) + mv $(d)/usr/include/$(PVER)/pyconfig.h \ + $(d)/usr/include/$(DEB_HOST_MULTIARCH)/$(PVER)/. + mv $(d)/usr/bin/python-config.sh $(d)/usr/bin/python$(VER)-config + sed -i 's/-O3/-O2/g;s/$(LTO_CFLAGS)//g;s/-fprofile-use *-fprofile-correction//g' \ + $(d)/usr/bin/python$(VER)-config + + : # fiddle around with the platform directory + mkdir -p $(d)/$(scriptdir)/plat-$(DEB_HOST_MULTIARCH)/ + set -x; echo XXXXXX; \ + for i in Lib/plat-linux2/*; do \ + n=$$(basename $$i); \ + if [ ! -f $(d)/$(scriptdir)/plat-$(DEB_HOST_MULTIARCH)/$$n ]; then \ + cp -p $$i $(d)/$(scriptdir)/plat-$(DEB_HOST_MULTIARCH)/; \ + fi; \ + done + rm -f $(d)/$(scriptdir)/lib-dynload/*.py + cp -p $(buildd_shared)/$(shell cat $(buildd_shared)/pybuilddir.txt)/_sysconfigdata.py \ + $(d)/$(scriptdir)/. + mv $(d)/$(scriptdir)/_sysconfigdata.py \ + $(d)/$(scriptdir)/plat-$(DEB_HOST_MULTIARCH)/_sysconfigdata_nd.py + sed -i 's/ -O3 / -O2 /g;s/$(LTO_CFLAGS)//g;s/-fprofile-use *-fprofile-correction//g' \ + $(d)/$(scriptdir)/plat-$(DEB_HOST_MULTIARCH)/_sysconfigdata_nd.py + cp -p debian/_sysconfigdata.py $(d)/$(scriptdir) + + -find $(d)/usr/lib/python$(VER) -name '*_failed*.so' + find $(d)/usr/lib/python$(VER) -name '*_failed*.so' | xargs -r rm -f + + test -f $(d)/usr/lib/python$(VER)/lib-dynload/_bsddb.so + + for i in $(d)/$(scriptdir)/lib-dynload/*.so; do \ + b=$$(basename $$i .so); \ + d=$${b}.$(DEB_HOST_MULTIARCH).so; \ + mv $$i $(d)/$(scriptdir)/lib-dynload/$$d; \ + done + + mv $(d)/usr/lib/libpython*.a $(d)/usr/lib/$(DEB_HOST_MULTIARCH)/ + + mv $(d)/usr/lib/python$(VER)/site-packages \ + $(d)/usr/lib/python$(VER)/dist-packages + + : # remove files, which are not packaged + rm -f $(d)/usr/bin/smtpd.py + rm -rf $(d)/usr/lib/python$(VER)/ctypes/macholib + rm -f $(d)/$(scriptdir)/plat-*/regen + rm -f $(d)/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/python.pc + rm -f $(d)/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/python2.pc + rm -f $(d)/usr/bin/python2{,-config} + rm -f $(d)/usr/share/man/man1/python.1 + rm -f $(d)/usr/share/man/man1/python2{,-config}.1 + rm -f $(d)/$(scriptdir)/lib2to3/*.pickle + + : # cannot build it, zlib maintainer won't provide a mingw build + find $(d) -name 'wininst*.exe' | xargs -r rm -f + + : # fix some file permissions + chmod a-x $(d)/$(scriptdir)/{fractions,lib-tk/Tix}.py + + : # move manpages to new names + if [ -d $(d)/usr/man/man1 ]; then \ + mkdir -p $(d)/usr/share/man; \ + mv $(d)/usr/man/man1/* $(d)/usr/share/man/man1/; \ + rm -rf $(d)/usr/man/; \ + fi + cp -p debian/pydoc.1 $(d)/usr/share/man/man1/pydoc$(VER).1 + + : # Symlinks to /usr/bin for some tools + ln -sf ../lib/python$(VER)/pdb.py $(d)/usr/bin/pdb$(VER) + cp -p debian/pdb.1 $(d)/usr/share/man/man1/pdb$(VER).1 + + : # versioned install only + rm -f $(d)/usr/bin/python-config + + mv $(d)/usr/bin/2to3 $(d)/usr/bin/2to3-$(VER) + cp debian/2to3-$(VER).1 $(d)/usr/share/man/man1/2to3-$(VER).1 + +# : # remove the bsddb stuff +# rm -rf $(d)/$(scriptdir)/bsddb +# rm -f $(d)/$(scriptdir)/lib-dynload/_bsddb.so + + : # Remove version information from the egg-info file + mv $(d)/$(scriptdir)/lib-dynload/Python-$(VER)*.egg-info \ + $(d)/$(scriptdir)/lib-dynload/Python-$(VER).egg-info + + dh_installdirs -p$(p_lib) \ + usr/lib/$(DEB_HOST_MULTIARCH) \ + $(scriptdir)/config-$(DEB_HOST_MULTIARCH) \ + usr/share/doc + : # install the shared library + cp -p $(buildd_shared)/libpython$(VER).so.1.0 \ + $(d_lib)/usr/lib/$(DEB_HOST_MULTIARCH)/ + dh_link -p$(p_lib) \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER).so.1.0 \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER).so.1 \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER).so.1 \ + /$(scriptdir)/config-$(DEB_HOST_MULTIARCH)/libpython$(VER).so + + ln -sf $(p_base) $(d_lib)/usr/share/doc/$(p_lib) + + ln -sf libpython$(VER).so.1 $(d)/usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER).so + +ifeq ($(with_interp),shared) + : # install the statically linked runtime + install -m755 $(buildd_static)/python $(d)/usr/bin/python$(VER)-static +endif + + mv $(d)/usr/bin/pydoc $(d)/usr/bin/pydoc$(VER) + cp -p Tools/i18n/pygettext.py $(d)/usr/bin/pygettext$(VER) + cp -p debian/pygettext.1 $(d)/usr/share/man/man1/pygettext$(VER).1 + + : # install the Makefile of the shared python build + sed -e '/^OPT/s,-O3,-O2,' \ + -e 's/$(LTO_CFLAGS)//g' \ + -e 's,^RUNSHARED *=.*,RUNSHARED=,' \ + -e '/BLDLIBRARY/s/-L\. //' \ + build-shared/Makefile > $(d)/$(scriptdir)/config-$(DEB_HOST_MULTIARCH)/Makefile + + : # Move the binary and the minimal libraries into $(p_lmin). + dh_installdirs -p$(p_lmin) \ + etc/$(PVER) \ + usr/bin \ + usr/include/$(PVER) \ + usr/share/man/man1 \ + $(scriptdir)/lib-dynload + DH_COMPAT=2 dh_movefiles -p$(p_lmin) --sourcedir=$(d) \ + $(foreach i,$(MIN_MODS),$(scriptdir)/$(i).py) \ + $(foreach i,$(MIN_PACKAGES),$(scriptdir)/$(i)) \ + $(foreach i,$(MIN_ENCODINGS),$(scriptdir)/$(i)) \ + /$(scriptdir)/plat-$(DEB_HOST_MULTIARCH)/_sysconfigdata_nd.py \ + $(scriptdir)/site.py \ + $(shell cd $(d); for i in $(MIN_EXTS); do \ + test -e $(scriptdir)/lib-dynload/$$i.so \ + && echo $(scriptdir)/lib-dynload/$$i.so; \ + done; true) + + : # Move the binary and the minimal libraries into $(p_min). + dh_installdirs -p$(p_min) \ + usr/bin \ + usr/share/man/man1 + DH_COMPAT=2 dh_movefiles -p$(p_min) --sourcedir=$(d) \ + usr/bin/python$(VER) \ + usr/share/man/man1/python$(VER).1 + + : # Install sitecustomize.py. + cp -p debian/sitecustomize.py $(d_lmin)/etc/$(PVER)/ + dh_link -p$(p_lmin) /etc/$(PVER)/sitecustomize.py \ + /$(scriptdir)/sitecustomize.py + + : # Move the static library and the header files into $(p_ldev). +# mv $(d)/usr/share/include/python$(VER)/* $(d)/usr/include/python$(VER)/. +# rm -rf $(d)/usr/share/include + + cp $(d)/usr/bin/python$(VER)-config $(d)/usr/bin/$(DEB_HOST_MULTIARCH)-python$(VER)-config + dh_installdirs -p$(p_ldev) \ + usr/bin \ + $(scriptdir) \ + usr/include \ + usr/share/man/man1 + + DH_COMPAT=2 dh_movefiles -p$(p_ldev) --sourcedir=$(d) \ + usr/bin/$(DEB_HOST_MULTIARCH)-python$(VER)-config \ + usr/lib/python$(VER)/config-$(DEB_HOST_MULTIARCH) \ + usr/include \ + usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER).{a,so} \ + usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/python-$(VER)*.pc + + sed 's/@subdir@/$(PVER)/;s/@header@/pyconfig.h/' \ + debian/multiarch.h.in > $(d_ldev)/usr/include/$(PVER)/pyconfig.h + + cp -p debian/python-config.1 \ + $(d_ldev)/usr/share/man/man1/$(DEB_HOST_MULTIARCH)-python$(VER)-config.1 + +ifneq ($(DEB_HOST_MULTIARCH),$(DEB_HOST_GNU_TYPE)) + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-config \ + $(d_ldev)/usr/bin/$(DEB_HOST_GNU_TYPE)-$(PVER)-config + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-config.1.gz \ + $(d_ldev)/usr/share/man/man1/$(DEB_HOST_GNU_TYPE)-$(PVER)-config.1.gz +endif + + sed -i '/^Cflags:/s,$$, -I$${includedir}/$(DEB_HOST_MULTIARCH)/python$(VER),' \ + $(d_ldev)/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/python-$(VER).pc + + dh_link -p$(p_ldev) \ + /usr/lib/$(PVER)/config-$(DEB_HOST_MULTIARCH)/libpython$(VER).a \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER).a + + cp -p $(buildd_shared)/libpython$(VER)-pic.a \ + $(d_ldev)/usr/lib/python$(VER)/config-$(DEB_HOST_MULTIARCH)/ + + : # Move the static library and the header files into $(p_dev). + dh_installdirs -p$(p_dev) \ + usr/share/doc/python$(VER)/$(DEB_HOST_MULTIARCH) \ + usr/share/man/man1 \ + $(scriptdir) \ + $(scriptdir)/doc/html + + cp -p Misc/HISTORY Misc/README.valgrind Misc/gdbinit \ + debian/README.maintainers \ + $(d_dev)/usr/share/doc/python$(VER)/ + cp -p debian/test_results $(buildd_static)/pybench.log \ + $(d_dev)/usr/share/doc/python$(VER)/$(DEB_HOST_MULTIARCH)/ + + DH_COMPAT=2 dh_movefiles -p$(p_dev) --sourcedir=$(d) \ + usr/bin/python$(VER)-config \ + usr/lib/python$(VER)/distutils/command/wininst-*.exe + + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-config $(d_dev)/usr/bin/$(PVER)-config + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-config.1.gz $(d_dev)/usr/share/man/man1/$(PVER)-config.1.gz + +ifeq ($(with_tk),yes) + : # Move the Tkinter files into $(p_tk). + dh_installdirs -p$(p_tk) \ + $(scriptdir) \ + usr/lib/python$(VER)/lib-dynload + DH_COMPAT=2 dh_movefiles -p$(p_tk) --sourcedir=$(d) \ + usr/lib/python$(VER)/lib-dynload/_tkinter.so +endif + +ifeq ($(with_gdbm),yes) + : # gdbm and dbm modules into $(p_gdbm). + dh_installdirs -p$(p_gdbm) \ + usr/lib/python$(VER)/lib-dynload + DH_COMPAT=2 dh_movefiles -p$(p_gdbm) --sourcedir=$(d) \ + usr/lib/python$(VER)/lib-dynload/gdbm.so +endif + + : # The test framework into $(p_lbase) + DH_COMPAT=2 dh_movefiles -p$(p_lbase) --sourcedir=$(d) \ + $(scriptdir)/test/{regrtest.py,test_support.py,__init__.py,pystone.py} + + : # The complete testsuite into $(p_lbase) + DH_COMPAT=2 dh_movefiles -p$(p_ltst) --sourcedir=$(d) \ + $(scriptdir)/test \ + $(scriptdir)/ctypes/test \ + $(scriptdir)/bsddb/test \ + $(scriptdir)/email/test \ + $(scriptdir)/json/tests \ + $(scriptdir)/sqlite3/test \ + $(scriptdir)/distutils/tests \ + $(scriptdir)/lib2to3/tests \ + $(scriptdir)/unittest/test \ + $(scriptdir)/lib-tk/test + : # test_ctypes fails with test_macholib.py installed + rm -f $(d_ltst)/$(scriptdir)/ctypes/test/test_macholib.py + : # test_bdist_wininst fails, '*.exe' files are not installed + rm -f $(d_ltst)/$(scriptdir)/distutils/tests/test_bdist_wininst.py + + : # IDLE + mv $(d)/usr/bin/idle $(d)/usr/bin/idle-python$(VER) + rm -f $(d)/usr/lib/python$(VER)/idlelib/idle.bat + dh_installdirs -p$(p_idle) \ + usr/bin \ + usr/share/man/man1 + DH_COMPAT=2 dh_movefiles -p$(p_idle) --sourcedir=$(d) \ + usr/lib/python$(VER)/idlelib \ + usr/bin/idle-python$(VER) + cp -p debian/idle-$(PVER).1 $(d_idle)/usr/share/man/man1/ + + : # Move the demos and tools into $(p_exam)'s doc directory + dh_installdirs -p$(p_exam) \ + usr/share/doc/python$(VER)/examples + + cp -rp Demo Tools $(d_exam)/usr/share/doc/python$(VER)/examples/ + rm -rf $(d_exam)/usr/share/doc/python$(VER)/examples/Demo/sgi + : # IDLE is in its own package: + rm -rf $(d_exam)/usr/share/doc/python$(VER)/examples/Tools/idle + : # XXX: We don't need rgb.txt, we'll use our own: + rm -rf $(d_exam)/usr/share/doc/python$(VER)/examples/Tools/pynche/X + + : # XXX: Some files in upstream Demo and Tools have strange + : # exec permissions, make lintian glad: + -chmod 644 $(d_tk)/$(scriptdir)/lib-tk/Tix.py + -chmod 644 $(d)/$(scriptdir)/runpy.py + + cd $(d_exam)/usr/share/doc/python$(VER)/examples && chmod 644 \ + Demo/{classes/*.py*,comparisons/patterns} \ + Demo/{rpc/test,threads/*.py*,md5test/*} \ + Demo/pdist/{client.py,cmdfw.py,cmptree.py,cvslib.py,cvslock.py,FSProxy.py,mac.py,rcsclient.py,rcslib.py,security.py,server.py,sumtree.py} \ + Demo/scripts/{morse.py,newslist.doc} \ + Demo/sockets/{broadcast.py,ftp.py,mcast.py,radio.py} \ + Demo/tix/{bitmaps/{tix.gif,*x[pb]m*},samples/*.py} \ + Demo/tkinter/guido/{AttrDialog.py,hanoi.py,hello.py,imagedraw.py,imageview.py,listtree.py,ManPage.py,ShellWindow.py,wish.py} \ + Tools/scripts/pydocgui.pyw \ + Tools/scripts/mailerdaemon.py + + : # Replace all '#!' calls to python with $(PY_INTERPRETER) + : # and make them executable + for i in `find debian -mindepth 3 -type f ! -name '*.dpatch'`; do \ + sed '1s,#!.*python[^ ]*\(.*\),#! $(PY_INTERPRETER)\1,' \ + $$i > $$i.temp; \ + if cmp --quiet $$i $$i.temp; then \ + rm -f $$i.temp; \ + else \ + mv -f $$i.temp $$i; \ + chmod 755 $$i; \ + echo "fixed interpreter: $$i"; \ + fi; \ + done + + : # Move the docs into $(p_base)'s /usr/share/doc/$(PVER) directory, + : # all other packages only have a copyright file. + dh_installdocs -p$(p_base) \ + README Misc/NEWS Misc/ACKS + ln -sf NEWS.gz $(d_base)/usr/share/doc/$(p_base)/changelog.gz + dh_installdocs --all -N$(p_base) -N$(p_dev) -N$(p_dbg) -N$(p_lib) debian/README.Debian + + : # IDLE has its own changelogs, docs... + dh_installchangelogs -p$(p_idle) Lib/idlelib/ChangeLog + dh_installdocs -p$(p_idle) Lib/idlelib/{NEWS,README,TODO,extend}.txt + + mkdir -p $(d_idle)/usr/share/applications + cp -p debian/idle.desktop \ + $(d_idle)/usr/share/applications/idle-$(PVER).desktop + + : # those packages have own README.Debian's + install -m 644 -p debian/README.$(p_base) \ + $(d_base)/usr/share/doc/$(PVER)/README.Debian + install -m 644 -p debian/README.$(p_idle) \ + $(d_idle)/usr/share/doc/$(p_idle)/README.Debian +ifeq ($(with_tk),yes) + cp -p debian/README.Tk $(d_tk)/usr/share/doc/$(p_tk)/ +endif + + : # library files into $(p_lbase) + dh_installdirs -p$(p_lbase) \ + usr/lib + dh_movefiles -p$(p_lbase) \ + usr/lib/python$(VER) + + : # The rest goes into $(p_base) + mkdir -p $(d)/usr/lib/python$(VER)/dist-packages + (cd $(d) && tar cf - .) | (cd $(d_base) && tar xpf -) + sh debian/dh_rmemptydirs -p$(p_base) + rm -f $(d_base)/usr/bin/python + + : # install egg-info for arparse + install -m 644 debian/argparse.egg-info $(d_lbase)/$(scriptdir)/ + + : # Install menu icon + dh_installdirs -p$(p_base) usr/share/pixmaps + cp -p debian/pylogo.xpm $(d_base)/usr/share/pixmaps/$(PVER).xpm + + : # generate binfmt file + mkdir -p $(d_min)/usr/share/binfmts +ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) + $(buildd_static)/python debian/mkbinfmt.py $(PVER) \ + > $(d_min)/usr/share/binfmts/$(PVER) +else + $(PVER) debian/mkbinfmt.py $(PVER) > $(d_min)/usr/share/binfmts/$(PVER) +endif + + : # desktop entry + mkdir -p $(d_base)/usr/share/applications + cp -p debian/$(PVER).desktop \ + $(d_base)/usr/share/applications/$(PVER).desktop + + : # remove some things + -find debian -name .cvsignore | xargs rm -f + -find debian -name '*.py[co]' | xargs rm -f + + : # remove empty directories, when all components are in place + -find debian ! -name lib-dynload -type d -empty -delete + + : # install debug package + rm -rf $(d)-dbg $(d)-shdbg + : # need some files from the shared build + $(MAKE) -C $(buildd_shdebug) install DESTDIR=$(CURDIR)/$(d)-shdbg + $(MAKE) -C $(buildd_debug) install DESTDIR=$(CURDIR)/$(d)-dbg + mv $(d)-dbg/usr/lib/libpython*.a $(d)-dbg/usr/lib/$(DEB_HOST_MULTIARCH)/ + mv $(d)-shdbg/$(scriptdir)/_sysconfigdata.py \ + $(d)-shdbg/$(scriptdir)/_sysconfigdata_d.py + + for i in $(d)-dbg/$(scriptdir)/lib-dynload/*_d.so; do \ + b=$$(basename $$i _d.so); \ + d=$${b}.$(DEB_HOST_MULTIARCH)_d.so; \ + mv $$i $(d)-dbg/$(scriptdir)/lib-dynload/$$d; \ + done + for i in $(d)-shdbg/$(scriptdir)/lib-dynload/*_d.so; do \ + b=$$(basename $$i _d.so); \ + d=$${b}.$(DEB_HOST_MULTIARCH)_d.so; \ + mv $$i $(d)-shdbg/$(scriptdir)/lib-dynload/$$d; \ + done + + dh_installdirs -p$(p_ldbg) \ + usr/bin \ + usr/share/man/man1 \ + $(scriptdir)/lib-dynload \ + $(scriptdir)/plat-$(DEB_HOST_MULTIARCH) \ + usr/include/$(PVER)_d \ + usr/include/$(DEB_HOST_MULTIARCH)/$(PVER)_d \ + usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig \ + + cp -p $(d)-shdbg/$(scriptdir)/lib-dynload/*.so \ + $(d_ldbg)/$(scriptdir)/lib-dynload/ + cp -p $(buildd_shdebug)/libpython$(VER)_d.so.1.0 \ + $(d_ldbg)/usr/lib/$(DEB_HOST_MULTIARCH)/ + dh_link -p$(p_ldbg) \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)_d.so.1.0 \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)_d.so.1 \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)_d.so.1 \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)_d.so + sed -e '/^Libs:/s,-lpython$(VER),-lpython$(VER)_d,' \ + -e '/^Cflags:/s,python$(VER),python$(VER)_d,' \ + -e '/^Cflags:/s,$$, -I$${includedir}/$(DEB_HOST_MULTIARCH)/python$(VER)_d,' \ + $(d)-dbg/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/python-$(VER).pc \ + > $(d_ldbg)/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/python-$(VER)-dbg.pc + + : # in $(p_ldbg), prefix python-config with triplets + cp $(d)-shdbg/usr/bin/python-config.sh \ + $(d_ldbg)/usr/bin/$(DEB_HOST_MULTIARCH)-$(PVER)-dbg-config + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-config.1.gz \ + $(d_ldbg)/usr/share/man/man1/$(DEB_HOST_MULTIARCH)-$(PVER)-dbg-config.1.gz +ifneq ($(DEB_HOST_MULTIARCH),$(DEB_HOST_GNU_TYPE)) + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-dbg-config \ + $(d_ldbg)/usr/bin/$(DEB_HOST_GNU_TYPE)-$(PVER)-dbg-config + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-config.1.gz \ + $(d_ldbg)/usr/share/man/man1/$(DEB_HOST_GNU_TYPE)-$(PVER)-dbg-config.1.gz +endif + + dh_installdirs -p$(p_dbg) \ + usr/bin \ + $(scriptdir)/lib-dynload \ + usr/share/man/man1 \ + usr/share/doc/$(p_base) + + cp -p Misc/SpecialBuilds.txt $(d_dbg)/usr/share/doc/$(p_base)/ + cp -p debian/$(PVER)-dbg.README.Debian \ + $(d_dbg)/usr/share/doc/$(p_base)/README.debug + cp -p $(buildd_debug)/python $(d_dbg)/usr/bin/$(PVER)-dbg + cp -p $(d)-shdbg/usr/bin/python-config.sh \ + $(d_dbg)/usr/bin/$(PVER)-dbg-config +# cp -p $(buildd_debug)/build/lib*/*_d.so \ + $(d_dbg)/$(scriptdir)/lib-dynload/ + cp -p $(d)-shdbg/$(scriptdir)/_sysconfigdata_d.py \ + $(d_ldbg)/$(scriptdir)/plat-$(DEB_HOST_MULTIARCH)/ +ifneq ($(with_gdbm),yes) + rm -f $(d_ldbg)/$(scriptdir)/lib-dynload/gdbm.$(DEB_HOST_MULTIARCH)_d.so + rm -f $(d_dbg)/usr/lib/debug/$(scriptdir)/lib-dynload/gdbm.$(DEB_HOST_MULTIARCH).so +endif +ifneq ($(with_tk),yes) + rm -f $(d_ldbg)/$(scriptdir)/lib-dynload/_tkinter.$(DEB_HOST_MULTIARCH)_d.so + rm -f $(d_dbg)/usr/lib/debug/$(scriptdir)/lib-dynload/_tkinter.$(DEB_HOST_MULTIARCH).so +endif +# rm -f $(d_dbg)/$(scriptdir)/lib-dynload/_bsddb_d.so + + cp -a $(d)-dbg/$(scriptdir)/config-$(DEB_HOST_MULTIARCH)_d \ + $(d_ldbg)/$(scriptdir)/ + ln -sf ../../$(DEB_HOST_MULTIARCH)/libpython$(VER)_d.so \ + $(d_ldbg)/$(scriptdir)/config-$(DEB_HOST_MULTIARCH)_d/libpython$(VER)_d.so + ln -sf libpython$(VER)_d.so \ + $(d_ldbg)/$(scriptdir)/config-$(DEB_HOST_MULTIARCH)_d/libpython$(VER).so + ln -sf libpython$(VER)_d.a \ + $(d_ldbg)/$(scriptdir)/config-$(DEB_HOST_MULTIARCH)_d/libpython$(VER).a + + for i in $(d_ldev)/usr/include/$(PVER)/*; do \ + i=$$(basename $$i); \ + case $$i in pyconfig.h) continue; esac; \ + ln -sf ../$(PVER)/$$i $(d_ldbg)/usr/include/$(PVER)_d/$$i; \ + done + cp -p $(buildd_debug)/pyconfig.h $(d_ldbg)/usr/include/$(DEB_HOST_MULTIARCH)/$(PVER)_d/ + sed 's/@subdir@/$(PVER)_d/;s/@header@/pyconfig.h/' \ + debian/multiarch.h.in > $(d_ldbg)/usr/include/$(PVER)_d/pyconfig.h + ln -sf $(PVER).1.gz $(d_dbg)/usr/share/man/man1/$(PVER)-dbg.1.gz + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-dbg-config \ + $(d_dbg)/usr/bin/$(PVER)-dbg-config + ln -sf $(PVER)-config.1.gz $(d_dbg)/usr/share/man/man1/$(PVER)-dbg-config.1.gz + + for i in debian/*.overrides; do \ + b=$$(basename $$i .overrides); \ + install -D -m 644 $$i debian/$$b/usr/share/lintian/overrides/$$b; \ + done + + touch stamps/stamp-install + +# Build architecture-independent files here. +binary-indep: build-indep install stamps/stamp-control + dh_testdir -i + dh_testroot -i + + : # $(p_doc) package + dh_installdirs -p$(p_doc) \ + usr/share/doc/$(p_base) \ + usr/share/doc/$(p_doc) + dh_installdocs -p$(p_doc) + cp -a Doc/build/html $(d_doc)/usr/share/doc/$(p_base)/ + rm -f $(d_doc)/usr/share/doc/$(p_base)/html/_static/jquery.js + rm -f $(d_doc)/usr/share/doc/$(p_base)/html/_static/underscore.js + dh_link -p$(p_doc) \ + /usr/share/doc/$(p_base)/html \ + /usr/share/doc/$(p_doc)/html \ + /usr/share/javascript/jquery/jquery.js \ + /usr/share/doc/$(p_base)/html/_static/jquery.js \ + /usr/share/javascript/underscore/underscore.js \ + /usr/share/doc/$(p_base)/html/_static/underscore.js + + : # devhelp docs + python debian/pyhtml2devhelp.py \ + $(d_doc)/usr/share/doc/$(p_base)/html index.html $(VER) \ + > $(d_doc)/usr/share/doc/$(p_base)/html/$(PVER).devhelp + gzip -9v $(d_doc)/usr/share/doc/$(p_base)/html/$(PVER).devhelp + dh_link -p$(p_doc) \ + /usr/share/doc/$(p_base)/html /usr/share/devhelp/books/$(PVER) + + for i in $(p_ltst); do \ + rm -rf debian/$$i/usr/share/doc/$$i; \ + ln -s $(p_lbase) debian/$$i/usr/share/doc/$$i; \ + done + + dh_installdebconf -i $(dh_args) + dh_installexamples -i $(dh_args) + dh_installmenu -i $(dh_args) + -dh_icons -i $(dh_args) || dh_iconcache -i $(dh_args) + dh_installchangelogs -i $(dh_args) + dh_link -i $(dh_args) + dh_compress -i $(dh_args) -X.py -X.cls -X.css -X.txt -X.json -X.js -Xobjects.inv -Xgdbinit + dh_fixperms -i $(dh_args) + + : # make python scripts starting with '#!' executable + for i in `find debian -mindepth 3 -type f ! -name '*.dpatch' ! -perm 755`; do \ + if head -1 $$i | grep -q '^#!'; then \ + chmod 755 $$i; \ + echo "make executable: $$i"; \ + fi; \ + done + -find $(d_doc) -name '*.txt' -perm 755 -exec chmod 644 {} \; + + dh_installdeb -i $(dh_args) + dh_gencontrol -i $(dh_args) + dh_md5sums -i $(dh_args) + dh_builddeb -i $(dh_args) + +# Build architecture-dependent files here. +binary-arch: build-arch install + dh_testdir -a + dh_testroot -a +# dh_installdebconf -a + dh_installexamples -a + dh_installmenu -a + -dh_icons -a || dh_iconcache -a +# dh_installmime -a + dh_installchangelogs -a + for i in $(p_dev) $(p_dbg); do \ + rm -rf debian/$$i/usr/share/doc/$$i; \ + ln -s $(p_base) debian/$$i/usr/share/doc/$$i; \ + done + for i in $(p_lbase); do \ + rm -rf debian/$$i/usr/share/doc/$$i; \ + ln -s $(p_lmin) debian/$$i/usr/share/doc/$$i; \ + done + for i in $(p_ldev) $(p_ldbg) $(p_lib); do \ + rm -rf debian/$$i/usr/share/doc/$$i; \ + ln -s $(p_lbase) debian/$$i/usr/share/doc/$$i; \ + done + -find debian ! -perm -200 -print -exec chmod +w {} \; +ifneq ($(with_tk),yes) + rm -f $(d_lbase)/$(scriptdir)/lib-dynload/_tkinter.$(DEB_HOST_MULTIARCH).so +endif +ifneq ($(with_gdbm),yes) + rm -f $(d_lbase)/$(scriptdir)/lib-dynload/gdbm.$(DEB_HOST_MULTIARCH).so +endif + dh_strip -a -N$(p_dbg) -Xdebug -Xdbg --dbg-package=$(p_dbg) + cp Tools/gdb/libpython.py $(d_dbg)/usr/lib/debug/usr/bin/$(PVER)-gdb.py + ln -sf $(PVER)-gdb.py $(d_dbg)/usr/lib/debug/usr/bin/$(PVER)-dbg-gdb.py + ln -sf ../bin/$(PVER)-gdb.py \ + $(d_dbg)/usr/lib/debug/usr/lib/lib$(PVER).so.1.0-gdb.py + ln -sf ../bin/$(PVER)-gdb.py \ + $(d_dbg)/usr/lib/lib$(PVER)_d.so.1.0-gdb.py + dh_link -a + dh_compress -a -X.py + dh_fixperms -a + + : # make python scripts starting with '#!' executable + for i in `find debian -mindepth 3 -type f ! -name '*.dpatch' ! -perm 755`; do \ + if head -1 $$i | grep -q '^#!'; then \ + chmod 755 $$i; \ + echo "make executable: $$i"; \ + fi; \ + done + + dh_makeshlibs -p$(p_lib) -V '$(p_lib)' + dh_makeshlibs -p$(p_ldbg) -V '$(p_ldbg)' +# don't include the following symbols, found in extensions +# which either can be built as builtin or extension. + sed -ri '/^ (_check_|asdl_|fast_save_|init)/d' \ + $(d_lib)/DEBIAN/symbols $(d_ldbg)/DEBIAN/symbols + dh_shlibdeps -a + dep=`sed -n '/^shlibs:Depends/s/.*\(libc6[^,]*\).*/\1/p' $(d_min).substvars`; \ + echo "shlibs:Pre-Depends=$$dep" >> $(d_min).substvars + sed -i '/^shlibs:Depends/s/libc6[^,]*[, ]*//' $(d_min).substvars + dh_installdeb -a + dh_gencontrol -a + dh_md5sums -a + dh_builddeb -a + +# rules to patch the unpacked files in the source directory +# --------------------------------------------------------------------------- +# various rules to unpack addons and (un)apply patches. +# - patch / apply-patches +# - unpatch / reverse-patches + +patchdir = debian/patches + +glibc_version := $(shell dpkg -s locales | awk '/^Version:/ {print $$2}') +broken_utimes := $(shell dpkg --compare-versions $(glibc_version) lt 2.3.5 && echo yes || echo no) + +$(patchdir)/series: $(patchdir)/series.in + cpp -E \ + -D$(distribution) \ + $(if $(filter $(broken_utimes),yes),-DBROKEN_UTIMES) \ + $(if $(filter $(with_fpectl),yes),-DWITH_FPECTL) \ + -Darch_os_$(DEB_HOST_ARCH_OS) -Darch_$(DEB_HOST_ARCH) \ + -o - $(patchdir)/series.in \ + | egrep -v '^(#.*|$$)' > $(patchdir)/series + +patch: stamps/stamp-patch +stamps/stamp-patch: $(patchdir)/series + dh_testdir + uname -a + @echo USER=$$USER, LOGNAME=$$LOGNAME + QUILT_PATCHES=$(patchdir) quilt push -a || test $$? = 2 + rm -rf autom4te.cache configure + autoconf + mkdir -p stamps + echo ""; echo "Patches applied in this version:" > stamps/pxx + for i in $$(cat $(patchdir)/series); do \ + echo ""; echo "$$i:"; \ + sed -n 's/^# *DP: */ /p' $(patchdir)/$$i; \ + done >> stamps/pxx + mv stamps/pxx $@ + + : # don't build pgen for cross builds, adjust timestamps + touch Parser/acceler.c Parser/grammar1.c Parser/listnode.c \ + Parser/node.c Parser/parser.c Parser/parsetok.c Parser/bitset.c \ + Parser/metagrammar.c Parser/firstsets.c Parser/grammar.c \ + Parser/pgen.c + touch Objects/obmalloc.c Python/mysnprintf.c Python/pyctype.c \ + Parser/tokenizer_pgen.c Parser/printgrammar.c Parser/pgenmain.c + @sleep 1 + touch Grammar/Grammar + @sleep 1 + touch Include/graminit.h + @sleep 1 + touch Python/graminit.c + ln -sf site-packages Lib/dist-packages + +reverse-patches: unpatch +unpatch: + QUILT_PATCHES=$(patchdir) quilt pop -a -R || test $$? = 2 + rm -f stamps/stamp-patch $(patchdir)/series + rm -rf configure autom4te.cache + rm -f Lib/dist-packages + +update-patches: $(patchdir)/series + export QUILT_PATCHES=$(patchdir); \ + export QUILT_REFRESH_ARGS="--no-timestamps --no-index -pab"; \ + export QUILT_DIFF_ARGS="--no-timestamps --no-index -pab"; \ + while quilt push; do quilt refresh; done + +binary: binary-indep binary-arch + +.PHONY: control-file configure build clean binary-indep binary-arch binary install + +# Local Variables: +# mode: makefile +# end: --- python2.7-2.7.5.orig/debian/source/format +++ python2.7-2.7.5/debian/source/format @@ -0,0 +1 @@ +1.0 --- python2.7-2.7.5.orig/debian/patches/setup-modules-ssl.diff +++ python2.7-2.7.5/debian/patches/setup-modules-ssl.diff @@ -0,0 +1,24 @@ +# DP: Modules/Setup.dist: patch to build _hashlib and _ssl extensions statically + +--- a/Modules/Setup.dist ++++ b/Modules/Setup.dist +@@ -215,10 +215,7 @@ + + # Socket module helper for SSL support; you must comment out the other + # socket line above, and possibly edit the SSL variable: +-#SSL=/usr/local/ssl +-#_ssl _ssl.c \ +-# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ +-# -L$(SSL)/lib -lssl -lcrypto ++#_ssl _ssl.c -lssl -lcrypto + + # The crypt module is now disabled by default because it breaks builds + # on many systems (where -lcrypt is needed), e.g. Linux (I believe). +@@ -261,6 +258,7 @@ + #_sha256 sha256module.c + #_sha512 sha512module.c + ++#_hashlib _hashopenssl.c -lssl -lcrypto + + # SGI IRIX specific modules -- off by default. + --- python2.7-2.7.5.orig/debian/patches/issue670664.diff +++ python2.7-2.7.5/debian/patches/issue670664.diff @@ -0,0 +1,54 @@ +# DP: Proposed patch for issue #670664. + +--- a/Lib/HTMLParser.py ++++ b/Lib/HTMLParser.py +@@ -96,6 +96,7 @@ + self.rawdata = '' + self.lasttag = '???' + self.interesting = interesting_normal ++ self.cdata_tag = None + markupbase.ParserBase.reset(self) + + def feed(self, data): +@@ -120,11 +121,13 @@ + """Return full source of start tag: '<...>'.""" + return self.__starttag_text + +- def set_cdata_mode(self): ++ def set_cdata_mode(self, tag): + self.interesting = interesting_cdata ++ self.cdata_tag = tag.lower() + + def clear_cdata_mode(self): + self.interesting = interesting_normal ++ self.cdata_tag = None + + # Internal -- handle data as far as reasonable. May leave state + # and data to be processed by a subsequent call. If 'end' is +@@ -270,7 +273,7 @@ + else: + self.handle_starttag(tag, attrs) + if tag in self.CDATA_CONTENT_ELEMENTS: +- self.set_cdata_mode() ++ self.set_cdata_mode(tag) + return endpos + + # Internal -- check to see if we have a complete starttag; return end +@@ -314,10 +317,16 @@ + j = match.end() + match = endtagfind.match(rawdata, i) # + if not match: ++ if self.cdata_tag is not None: return j + self.error("bad end tag: %r" % (rawdata[i:j],)) +- tag = match.group(1) ++ tag = match.group(1).strip() ++ ++ if self.cdata_tag is not None: ++ if tag.lower() != self.cdata_tag: return j ++ + self.handle_endtag(tag.lower()) + self.clear_cdata_mode() ++ + return j + + # Overridable -- finish processing of start+end tag: --- python2.7-2.7.5.orig/debian/patches/disable-sem-check.diff +++ python2.7-2.7.5/debian/patches/disable-sem-check.diff @@ -0,0 +1,28 @@ +# DP: Assume working semaphores on Linux, don't rely on running kernel for the check. + +--- a/configure.ac ++++ b/configure.ac +@@ -3803,6 +3803,11 @@ + [ac_cv_posix_semaphores_enabled=no], + [ac_cv_posix_semaphores_enabled=yes]) + ) ++case $ac_sys_system in ++ Linux*) ++ # assume enabled, see https://launchpad.net/bugs/630511 ++ ac_cv_posix_semaphores_enabled=yes ++esac + AC_MSG_RESULT($ac_cv_posix_semaphores_enabled) + if test $ac_cv_posix_semaphores_enabled = no + then +@@ -3839,6 +3844,11 @@ + [ac_cv_broken_sem_getvalue=yes], + [ac_cv_broken_sem_getvalue=yes]) + ) ++case $ac_sys_system in ++ Linux*) ++ # assume enabled, see https://launchpad.net/bugs/630511 ++ ac_cv_broken_sem_getvalue=no ++esac + AC_MSG_RESULT($ac_cv_broken_sem_getvalue) + if test $ac_cv_broken_sem_getvalue = yes + then --- python2.7-2.7.5.orig/debian/patches/no-zip-on-sys.path.diff +++ python2.7-2.7.5/debian/patches/no-zip-on-sys.path.diff @@ -0,0 +1,52 @@ +# DP: Do not add /usr/lib/pythonXY.zip on sys.path. + +--- a/Modules/getpath.c ++++ b/Modules/getpath.c +@@ -395,7 +395,9 @@ + char *path = getenv("PATH"); + char *prog = Py_GetProgramName(); + char argv0_path[MAXPATHLEN+1]; ++#ifdef WITH_ZIP_PATH + char zip_path[MAXPATHLEN+1]; ++#endif + int pfound, efound; /* 1 if found; -1 if found build directory */ + char *buf; + size_t bufsz; +@@ -535,6 +537,7 @@ + else + reduce(prefix); + ++#ifdef WITH_ZIP_PATH + strncpy(zip_path, prefix, MAXPATHLEN); + zip_path[MAXPATHLEN] = '\0'; + if (pfound > 0) { /* Use the reduced prefix returned by Py_GetPrefix() */ +@@ -547,6 +550,7 @@ + bufsz = strlen(zip_path); /* Replace "00" with version */ + zip_path[bufsz - 6] = VERSION[0]; + zip_path[bufsz - 5] = VERSION[2]; ++#endif + + if (!(efound = search_for_exec_prefix(argv0_path, home))) { + if (!Py_FrozenFlag) +@@ -586,7 +590,9 @@ + defpath = delim + 1; + } + ++#ifdef WITH_ZIP_PATH + bufsz += strlen(zip_path) + 1; ++#endif + bufsz += strlen(exec_prefix) + 1; + + /* This is the only malloc call in this file */ +@@ -607,9 +613,11 @@ + else + buf[0] = '\0'; + ++#ifdef WITH_ZIP_PATH + /* Next is the default zip path */ + strcat(buf, zip_path); + strcat(buf, delimiter); ++#endif + + /* Next goes merge of compile-time $PYTHONPATH with + * dynamically located prefix. --- python2.7-2.7.5.orig/debian/patches/tkinter-import.diff +++ python2.7-2.7.5/debian/patches/tkinter-import.diff @@ -0,0 +1,16 @@ +# DP: suggest installation of python-tk package on failing _tkinter import + +--- a/Lib/lib-tk/Tkinter.py ++++ b/Lib/lib-tk/Tkinter.py +@@ -36,7 +36,10 @@ + if sys.platform == "win32": + # Attempt to configure Tcl/Tk without requiring PATH + import FixTk +-import _tkinter # If this fails your Python may not be configured for Tk ++try: ++ import _tkinter ++except ImportError, msg: ++ raise ImportError, str(msg) + ', please install the python-tk package' + tkinter = _tkinter # b/w compat for export + TclError = _tkinter.TclError + from types import * --- python2.7-2.7.5.orig/debian/patches/distutils-sysconfig.diff +++ python2.7-2.7.5/debian/patches/distutils-sysconfig.diff @@ -0,0 +1,31 @@ +# DP: Allow setting BASECFLAGS, OPT and EXTRA_LDFLAGS (like, CC, CXX, CPP, +# DP: CFLAGS, CPPFLAGS, CCSHARED, LDSHARED) from the environment. + +--- a/Lib/distutils/sysconfig.py ++++ b/Lib/distutils/sysconfig.py +@@ -173,8 +173,8 @@ + _osx_support.customize_compiler(_config_vars) + _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True' + +- (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \ +- get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', ++ (cc, cxx, opt, cflags, extra_cflags, basecflags, ccshared, ldshared, so_ext, ar, ar_flags) = \ ++ get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', 'EXTRA_CFLAGS', 'BASECFLAGS', + 'CCSHARED', 'LDSHARED', 'SO', 'AR', + 'ARFLAGS') + +@@ -197,8 +197,13 @@ + cpp = cc + " -E" # not always + if 'LDFLAGS' in os.environ: + ldshared = ldshared + ' ' + os.environ['LDFLAGS'] ++ if 'BASECFLAGS' in os.environ: ++ basecflags = os.environ['BASECFLAGS'] ++ if 'OPT' in os.environ: ++ opt = os.environ['OPT'] ++ cflags = ' '.join(str(x) for x in (basecflags, opt, extra_cflags) if x) + if 'CFLAGS' in os.environ: +- cflags = opt + ' ' + os.environ['CFLAGS'] ++ cflags = ' '.join(str(x) for x in (basecflags, opt, os.environ['CFLAGS'], extra_cflags) if x) + ldshared = ldshared + ' ' + os.environ['CFLAGS'] + if 'CPPFLAGS' in os.environ: + cpp = cpp + ' ' + os.environ['CPPFLAGS'] --- python2.7-2.7.5.orig/debian/patches/plat-linux2_sparc.diff +++ python2.7-2.7.5/debian/patches/plat-linux2_sparc.diff @@ -0,0 +1,72 @@ +Index: Lib/plat-linux2/IN.py +=================================================================== +--- ./Lib/plat-linux2/IN.py (Revision 77754) ++++ ./Lib/plat-linux2/IN.py (Arbeitskopie) +@@ -442,37 +442,37 @@ + SIOCGPGRP = 0x8904 + SIOCATMARK = 0x8905 + SIOCGSTAMP = 0x8906 +-SOL_SOCKET = 1 +-SO_DEBUG = 1 +-SO_REUSEADDR = 2 +-SO_TYPE = 3 +-SO_ERROR = 4 +-SO_DONTROUTE = 5 +-SO_BROADCAST = 6 +-SO_SNDBUF = 7 +-SO_RCVBUF = 8 +-SO_KEEPALIVE = 9 +-SO_OOBINLINE = 10 +-SO_NO_CHECK = 11 +-SO_PRIORITY = 12 +-SO_LINGER = 13 +-SO_BSDCOMPAT = 14 +-SO_PASSCRED = 16 +-SO_PEERCRED = 17 +-SO_RCVLOWAT = 18 +-SO_SNDLOWAT = 19 +-SO_RCVTIMEO = 20 +-SO_SNDTIMEO = 21 +-SO_SECURITY_AUTHENTICATION = 22 +-SO_SECURITY_ENCRYPTION_TRANSPORT = 23 +-SO_SECURITY_ENCRYPTION_NETWORK = 24 +-SO_BINDTODEVICE = 25 +-SO_ATTACH_FILTER = 26 +-SO_DETACH_FILTER = 27 +-SO_PEERNAME = 28 +-SO_TIMESTAMP = 29 ++SOL_SOCKET = 0xffff ++SO_DEBUG = 0x0001 ++SO_REUSEADDR = 0x0004 ++SO_TYPE = 0x1008 ++SO_ERROR = 0x1007 ++SO_DONTROUTE = 0x0010 ++SO_BROADCAST = 0x0020 ++SO_SNDBUF = 0x1001 ++SO_RCVBUF = 0x1002 ++SO_KEEPALIVE = 0x0008 ++SO_OOBINLINE = 0x0100 ++SO_NO_CHECK = 0x000b ++SO_PRIORITY = 0x000c ++SO_LINGER = 0x0080 ++SO_BSDCOMPAT = 0x0400 ++SO_PASSCRED = 0x0002 ++SO_PEERCRED = 0x0040 ++SO_RCVLOWAT = 0x0800 ++SO_SNDLOWAT = 0x1000 ++SO_RCVTIMEO = 0x2000 ++SO_SNDTIMEO = 0x4000 ++SO_SECURITY_AUTHENTICATION = 0x5001 ++SO_SECURITY_ENCRYPTION_TRANSPORT = 0x5002 ++SO_SECURITY_ENCRYPTION_NETWORK = 0x5004 ++SO_BINDTODEVICE = 0x000d ++SO_ATTACH_FILTER = 0x001a ++SO_DETACH_FILTER = 0x001b ++SO_PEERNAME = 0x001c ++SO_TIMESTAMP = 0x001d + SCM_TIMESTAMP = SO_TIMESTAMP +-SO_ACCEPTCONN = 30 ++SO_ACCEPTCONN = 0x8000 + SOCK_STREAM = 1 + SOCK_DGRAM = 2 + SOCK_RAW = 3 --- python2.7-2.7.5.orig/debian/patches/sqlite-rpath.diff +++ python2.7-2.7.5/debian/patches/sqlite-rpath.diff @@ -0,0 +1,10 @@ +--- a/setup.py ++++ b/setup.py +@@ -1193,7 +1193,6 @@ + include_dirs=["Modules/_sqlite", + sqlite_incdir], + library_dirs=sqlite_libdir, +- runtime_library_dirs=sqlite_libdir, + extra_link_args=sqlite_extra_link_args, + libraries=["sqlite3",])) + else: --- python2.7-2.7.5.orig/debian/patches/ext-no-libpython-link.diff +++ python2.7-2.7.5/debian/patches/ext-no-libpython-link.diff @@ -0,0 +1,22 @@ +# DP: Don't link extensions with the shared libpython library. + +--- a/Lib/distutils/command/build_ext.py ++++ b/Lib/distutils/command/build_ext.py +@@ -234,7 +234,7 @@ + # for extensions under Linux or Solaris with a shared Python library, + # Python's library directory must be appended to library_dirs + sysconfig.get_config_var('Py_ENABLE_SHARED') +- if ((sys.platform.startswith('linux') or sys.platform.startswith('gnu') ++ if False and ((sys.platform.startswith('linux') or sys.platform.startswith('gnu') + or sys.platform.startswith('sunos')) + and sysconfig.get_config_var('Py_ENABLE_SHARED')): + if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")): +@@ -757,7 +757,7 @@ + return ext.libraries + else: + from distutils import sysconfig +- if sysconfig.get_config_var('Py_ENABLE_SHARED'): ++ if False and sysconfig.get_config_var('Py_ENABLE_SHARED'): + template = "python%d.%d" + pythonlib = (template % + (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) --- python2.7-2.7.5.orig/debian/patches/enable-fpectl.diff +++ python2.7-2.7.5/debian/patches/enable-fpectl.diff @@ -0,0 +1,14 @@ +# DP: Enable the build of the fpectl module. + +--- a/setup.py ++++ b/setup.py +@@ -1371,6 +1371,9 @@ + else: + missing.append('_curses_panel') + ++ #fpectl fpectlmodule.c ... ++ exts.append( Extension('fpectl', ['fpectlmodule.c']) ) ++ + # Andrew Kuchling's zlib module. Note that some versions of zlib + # 1.1.3 have security problems. See CERT Advisory CA-2002-07: + # http://www.cert.org/advisories/CA-2002-07.html --- python2.7-2.7.5.orig/debian/patches/multiarch.diff +++ python2.7-2.7.5/debian/patches/multiarch.diff @@ -0,0 +1,154 @@ +--- a/Lib/sysconfig.py ++++ b/Lib/sysconfig.py +@@ -332,7 +332,7 @@ + def _get_makefile_filename(): + if _PYTHON_BUILD: + return os.path.join(_PROJECT_BASE, "Makefile") +- return os.path.join(get_path('platstdlib').replace("/usr/local","/usr",1), "config" + (sys.pydebug and "_d" or ""), "Makefile") ++ return os.path.join(get_config_var('LIBPL'), "Makefile") + + def _generate_posix_vars(): + """Generate the Python module containing build-time variables.""" +@@ -528,6 +528,12 @@ + # the init-function. + _CONFIG_VARS['userbase'] = _getuserbase() + ++ multiarch = get_config_var('MULTIARCH') ++ if multiarch: ++ _CONFIG_VARS['multiarchsubdir'] = '/' + multiarch ++ else: ++ _CONFIG_VARS['multiarchsubdir'] = '' ++ + if 'srcdir' not in _CONFIG_VARS: + _CONFIG_VARS['srcdir'] = _PROJECT_BASE + +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -97,6 +97,9 @@ + # Multiarch directory (may be empty) + MULTIARCH= @MULTIARCH@ + ++# Multiarch directory (may be empty) ++MULTIARCH= @MULTIARCH@ ++ + # Install prefix for architecture-independent files + prefix= @prefix@ + +@@ -553,6 +556,10 @@ + @mv config.c Modules + @echo "The Makefile was updated, you may need to re-run make." + ++Python/dynload_shlib.o: $(srcdir)/Python/dynload_shlib.c Makefile ++ $(CC) -c $(PY_CORE_CFLAGS) \ ++ $(if $(MULTIARCH),-DMULTIARCH='"$(MULTIARCH)"') \ ++ -o $@ $(srcdir)/Python/dynload_shlib.c + + Modules/Setup: $(srcdir)/Modules/Setup.dist + @if test -f Modules/Setup; then \ +@@ -916,7 +923,7 @@ + (cd $(DESTDIR)$(MANDIR)/man1; $(LN) -s python2.1 python.1) + + # Install the library +-PLATDIR= plat-$(MACHDEP) ++PLATDIR= plat-$(MULTIARCH) + EXTRAPLATDIR= @EXTRAPLATDIR@ + EXTRAMACHDEPPATH=@EXTRAMACHDEPPATH@ + MACHDEPS= $(PLATDIR) $(EXTRAPLATDIR) +@@ -1073,10 +1080,10 @@ + + # Install the library and miscellaneous stuff needed for extending/embedding + # This goes into $(exec_prefix)$(DEBUG_EXT) +-LIBPL= $(LIBP)/config$(DEBUG_EXT) ++LIBPL= $(LIBP)/config-$(MULTIARCH)$(DEBUG_EXT) + + # pkgconfig directory +-LIBPC= $(LIBDIR)/pkgconfig ++LIBPC= $(LIBDIR)/$(MULTIARCH)/pkgconfig + + libainstall: all python-config + @for i in $(LIBDIR) $(LIBP) $(LIBPL) $(LIBPC); \ +@@ -1351,6 +1358,11 @@ + + Python/thread.o: @THREADHEADERS@ + ++Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile ++ $(CC) -c $(PY_CORE_CFLAGS) \ ++ -DMULTIARCH='"$(MULTIARCH)"' \ ++ -o $@ $(srcdir)/Python/sysmodule.c ++ + # Declare targets that aren't real files + .PHONY: all build_all sharedmods oldsharedmods test quicktest memtest + .PHONY: install altinstall oldsharedinstall bininstall altbininstall +--- a/Modules/Setup.dist ++++ b/Modules/Setup.dist +@@ -91,7 +91,7 @@ + TESTPATH= + + # Path components for machine- or system-dependent modules and shared libraries +-MACHDEPPATH=:plat-$(MACHDEP) ++MACHDEPPATH=:plat-$(MULTIARCH) + EXTRAMACHDEPPATH= + + # Path component for the Tkinter-related modules +--- a/Python/dynload_shlib.c ++++ b/Python/dynload_shlib.c +@@ -49,6 +49,12 @@ + #ifdef Py_DEBUG + {"_d.so", "rb", C_EXTENSION}, + {"module_d.so", "rb", C_EXTENSION}, ++# ifdef MULTIARCH ++ {"." MULTIARCH "_d.so", "rb", C_EXTENSION}, ++# endif ++#endif ++#ifdef MULTIARCH ++ {"." MULTIARCH ".so", "rb", C_EXTENSION}, + #endif + {".so", "rb", C_EXTENSION}, + {"module.so", "rb", C_EXTENSION}, +--- a/configure.ac ++++ b/configure.ac +@@ -672,6 +672,9 @@ + MULTIARCH=$($CC --print-multiarch 2>/dev/null) + AC_SUBST(MULTIARCH) + ++MULTIARCH=$($CC --print-multiarch 2>/dev/null) ++AC_SUBST(MULTIARCH) ++ + + # checks for UNIX variants that set C preprocessor variables + AC_USE_SYSTEM_EXTENSIONS +--- a/Lib/distutils/sysconfig.py ++++ b/Lib/distutils/sysconfig.py +@@ -90,7 +90,11 @@ + # Include is located in the srcdir + inc_dir = os.path.join(srcdir, "Include") + return inc_dir +- return os.path.join(prefix, "include", "python" + get_python_version())+(sys.pydebug and "_d" or "") ++ else: ++ if plat_specific: ++ return get_config_var('CONFINCLUDEPY') ++ else: ++ return get_config_var('INCLUDEPY') + elif os.name == "nt": + return os.path.join(prefix, "include") + elif os.name == "os2": +@@ -251,7 +255,7 @@ + if python_build: + return os.path.join(project_base, "Makefile") + lib_dir = get_python_lib(plat_specific=1, standard_lib=1) +- return os.path.join(lib_dir, "config"+(sys.pydebug and "_d" or ""), "Makefile") ++ return os.path.join(get_config_var('LIBPL'), "Makefile") + + + def parse_config_h(fp, g=None): +--- a/Python/sysmodule.c ++++ b/Python/sysmodule.c +@@ -1435,6 +1435,8 @@ + PyFloat_GetInfo()); + SET_SYS_FROM_STRING("long_info", + PyLong_GetInfo()); ++ SET_SYS_FROM_STRING("_multiarch", ++ PyString_FromString(MULTIARCH)); + #ifdef Py_USING_UNICODE + SET_SYS_FROM_STRING("maxunicode", + PyInt_FromLong(PyUnicode_GetMax())); --- python2.7-2.7.5.orig/debian/patches/distutils-install-layout.diff +++ python2.7-2.7.5/debian/patches/distutils-install-layout.diff @@ -0,0 +1,382 @@ +# DP: distutils: Add an option --install-layout=deb, which +# DP: - installs into $prefix/dist-packages instead of $prefix/site-packages. +# DP: - doesn't encode the python version into the egg name. + +--- a/Doc/install/index.rst ++++ b/Doc/install/index.rst +@@ -240,6 +240,8 @@ + +-----------------+-----------------------------------------------------+--------------------------------------------------+-------+ + | Platform | Standard installation location | Default value | Notes | + +=================+=====================================================+==================================================+=======+ ++| Debian/Ubuntu | :file:`{prefix}/lib/python{X.Y}/dist-packages` | :file:`/usr/local/lib/python{X.Y}/dist-packages` | \(0) | +++-----------------+-----------------------------------------------------+--------------------------------------------------+-------+ + | Unix (pure) | :file:`{prefix}/lib/python{X.Y}/site-packages` | :file:`/usr/local/lib/python{X.Y}/site-packages` | \(1) | + +-----------------+-----------------------------------------------------+--------------------------------------------------+-------+ + | Unix (non-pure) | :file:`{exec-prefix}/lib/python{X.Y}/site-packages` | :file:`/usr/local/lib/python{X.Y}/site-packages` | \(1) | +@@ -249,6 +251,14 @@ + + Notes: + ++(0) ++ Starting with Python-2.6 Debian/Ubuntu uses for the Python which comes within ++ the Linux distribution a non-default name for the installation directory. This ++ is to avoid overwriting of the python modules which come with the distribution, ++ which unfortunately is the upstream behaviour of the installation tools. The ++ non-default name in :file:`/usr/local` is used not to overwrite a local python ++ installation (defaulting to :file:`/usr/local`). ++ + (1) + Most Linux distributions include Python as a standard part of the system, so + :file:`{prefix}` and :file:`{exec-prefix}` are usually both :file:`/usr` on +@@ -433,6 +443,15 @@ + + /usr/bin/python setup.py install --prefix=/usr/local + ++Starting with Python-2.6 Debian/Ubuntu does use ++:file:`/usr/lib/python{X.Y}/dist-packages` and ++:file:`/usr/local/lib/python{X.Y}/dist-packages` for the installation ++of python modules included in the Linux distribution. To overwrite ++the name of the site directory, explicitely use the :option:`--prefix` ++option, however make sure that the installation path is included in ++``sys.path``. For packaging of python modules for Debian/Ubuntu, use ++the new ``setup.py install`` option :option:`--install-layout=deb`. ++ + Another possibility is a network filesystem where the name used to write to a + remote directory is different from the name used to read it: for example, the + Python interpreter accessed as :file:`/usr/local/bin/python` might search for +@@ -684,6 +703,17 @@ + import them, this directory must be added to ``sys.path``. There are several + different ways to add the directory. + ++On Debian/Ubuntu, starting with Python-2.6 the convention for system ++installed packages is to put then in the ++:file:`/usr/lib/python{X.Y}/dist-packages/` directory, and for locally ++installed packages is to put them in the ++:file:`/usr/lib/python{X.Y}/dist-packages/` directory. To share the ++locally installed packages for the system provided Python with the ++locally installed packages of a local python installation, make ++:file:`/usr/lib/python{X.Y}/dist-packages/` a symbolic link to the ++:file:`{...}/site-packages/` directory of your local python ++installation. ++ + The most convenient way is to add a path configuration file to a directory + that's already on Python's path, usually to the :file:`.../site-packages/` + directory. Path configuration files have an extension of :file:`.pth`, and each +--- a/Lib/distutils/command/install.py ++++ b/Lib/distutils/command/install.py +@@ -47,6 +47,20 @@ + 'scripts': '$base/bin', + 'data' : '$base', + }, ++ 'unix_local': { ++ 'purelib': '$base/local/lib/python$py_version_short/dist-packages', ++ 'platlib': '$platbase/local/lib/python$py_version_short/dist-packages', ++ 'headers': '$base/local/include/python$py_version_short/$dist_name', ++ 'scripts': '$base/local/bin', ++ 'data' : '$base/local', ++ }, ++ 'deb_system': { ++ 'purelib': '$base/lib/python$py_version_short/dist-packages', ++ 'platlib': '$platbase/lib/python$py_version_short/dist-packages', ++ 'headers': '$base/include/python$py_version_short/$dist_name', ++ 'scripts': '$base/bin', ++ 'data' : '$base', ++ }, + 'unix_home': { + 'purelib': '$base/lib/python', + 'platlib': '$base/lib/python', +@@ -154,6 +168,9 @@ + + ('record=', None, + "filename in which to record list of installed files"), ++ ++ ('install-layout=', None, ++ "installation layout to choose (known values: deb, unix)"), + ] + + boolean_options = ['compile', 'force', 'skip-build', 'user'] +@@ -168,6 +185,7 @@ + self.exec_prefix = None + self.home = None + self.user = 0 ++ self.prefix_option = None + + # These select only the installation base; it's up to the user to + # specify the installation scheme (currently, that means supplying +@@ -189,6 +207,9 @@ + self.install_userbase = USER_BASE + self.install_usersite = USER_SITE + ++ # enable custom installation, known values: deb ++ self.install_layout = None ++ + self.compile = None + self.optimize = None + +@@ -421,6 +442,7 @@ + self.install_base = self.install_platbase = self.home + self.select_scheme("unix_home") + else: ++ self.prefix_option = self.prefix + if self.prefix is None: + if self.exec_prefix is not None: + raise DistutilsOptionError, \ +@@ -435,7 +457,23 @@ + + self.install_base = self.prefix + self.install_platbase = self.exec_prefix +- self.select_scheme("unix_prefix") ++ if self.install_layout: ++ if self.install_layout.lower() in ['deb']: ++ self.select_scheme("deb_system") ++ elif self.install_layout.lower() in ['posix', 'unix']: ++ self.select_scheme("unix_prefix") ++ else: ++ raise DistutilsOptionError( ++ "unknown value for --install-layout") ++ elif (self.prefix_option and os.path.normpath(self.prefix) != '/usr/local') \ ++ or 'PYTHONUSERBASE' in os.environ \ ++ or 'real_prefix' in sys.__dict__: ++ self.select_scheme("unix_prefix") ++ else: ++ if os.path.normpath(self.prefix) == '/usr/local': ++ self.select_scheme("deb_system") ++ else: ++ self.select_scheme("unix_local") + + # finalize_unix () + +--- a/Lib/distutils/command/install_egg_info.py ++++ b/Lib/distutils/command/install_egg_info.py +@@ -14,18 +14,37 @@ + description = "Install package's PKG-INFO metadata as an .egg-info file" + user_options = [ + ('install-dir=', 'd', "directory to install to"), ++ ('install-layout', None, "custom installation layout"), + ] + + def initialize_options(self): + self.install_dir = None ++ self.install_layout = None ++ self.prefix_option = None + + def finalize_options(self): + self.set_undefined_options('install_lib',('install_dir','install_dir')) +- basename = "%s-%s-py%s.egg-info" % ( +- to_filename(safe_name(self.distribution.get_name())), +- to_filename(safe_version(self.distribution.get_version())), +- sys.version[:3] +- ) ++ self.set_undefined_options('install',('install_layout','install_layout')) ++ self.set_undefined_options('install',('prefix_option','prefix_option')) ++ if self.install_layout: ++ basename = "%s-%s.egg-info" % ( ++ to_filename(safe_name(self.distribution.get_name())), ++ to_filename(safe_version(self.distribution.get_version())) ++ ) ++ if not self.install_layout.lower() in ['deb']: ++ raise DistutilsOptionError( ++ "unknown value for --install-layout") ++ elif self.prefix_option or 'real_prefix' in sys.__dict__: ++ basename = "%s-%s-py%s.egg-info" % ( ++ to_filename(safe_name(self.distribution.get_name())), ++ to_filename(safe_version(self.distribution.get_version())), ++ sys.version[:3] ++ ) ++ else: ++ basename = "%s-%s.egg-info" % ( ++ to_filename(safe_name(self.distribution.get_name())), ++ to_filename(safe_version(self.distribution.get_version())) ++ ) + self.target = os.path.join(self.install_dir, basename) + self.outputs = [self.target] + +--- a/Lib/distutils/sysconfig.py ++++ b/Lib/distutils/sysconfig.py +@@ -115,6 +115,7 @@ + If 'prefix' is supplied, use it instead of sys.prefix or + sys.exec_prefix -- i.e., ignore 'plat_specific'. + """ ++ is_default_prefix = not prefix or os.path.normpath(prefix) in ('/usr', '/usr/local') + if prefix is None: + prefix = plat_specific and EXEC_PREFIX or PREFIX + +@@ -123,6 +124,8 @@ + "lib", "python" + get_python_version()) + if standard_lib: + return libpython ++ elif is_default_prefix and 'PYTHONUSERBASE' not in os.environ and 'real_prefix' not in sys.__dict__: ++ return os.path.join(libpython, "dist-packages") + else: + return os.path.join(libpython, "site-packages") + +--- a/Lib/site.py ++++ b/Lib/site.py +@@ -273,6 +273,13 @@ + + if ENABLE_USER_SITE and os.path.isdir(user_site): + addsitedir(user_site, known_paths) ++ if ENABLE_USER_SITE: ++ for dist_libdir in ("local/lib", "lib"): ++ user_site = os.path.join(USER_BASE, dist_libdir, ++ "python" + sys.version[:3], ++ "dist-packages") ++ if os.path.isdir(user_site): ++ addsitedir(user_site, known_paths) + return known_paths + + def getsitepackages(): +--- a/Lib/sysconfig.py ++++ b/Lib/sysconfig.py +@@ -16,6 +16,26 @@ + 'scripts': '{base}/bin', + 'data': '{base}', + }, ++ 'posix_local': { ++ 'stdlib': '{base}/lib/python{py_version_short}', ++ 'platstdlib': '{platbase}/lib/python{py_version_short}', ++ 'purelib': '{base}/local/lib/python{py_version_short}/dist-packages', ++ 'platlib': '{platbase}/local/lib/python{py_version_short}/dist-packages', ++ 'include': '{base}/local/include/python{py_version_short}', ++ 'platinclude': '{platbase}/local/include/python{py_version_short}', ++ 'scripts': '{base}/local/bin', ++ 'data': '{base}/local', ++ }, ++ 'deb_system': { ++ 'stdlib': '{base}/lib/python{py_version_short}', ++ 'platstdlib': '{platbase}/lib/python{py_version_short}', ++ 'purelib': '{base}/lib/python{py_version_short}/dist-packages', ++ 'platlib': '{platbase}/lib/python{py_version_short}/dist-packages', ++ 'include': '{base}/include/python{py_version_short}', ++ 'platinclude': '{platbase}/include/python{py_version_short}', ++ 'scripts': '{base}/bin', ++ 'data': '{base}', ++ }, + 'posix_home': { + 'stdlib': '{base}/lib/python', + 'platstdlib': '{base}/lib/python', +@@ -129,7 +149,7 @@ + _PYTHON_BUILD = is_python_build() + + if _PYTHON_BUILD: +- for scheme in ('posix_prefix', 'posix_home'): ++ for scheme in ('posix_prefix', 'posix_local', 'deb_system', 'posix_home'): + _INSTALL_SCHEMES[scheme]['include'] = '{projectbase}/Include' + _INSTALL_SCHEMES[scheme]['platinclude'] = '{srcdir}' + +@@ -163,8 +183,11 @@ + + def _get_default_scheme(): + if os.name == 'posix': +- # the default scheme for posix is posix_prefix +- return 'posix_prefix' ++ # the default scheme for posix on Debian/Ubuntu is posix_local ++ # FIXME: return dist-packages/posix_prefix only for ++ # is_default_prefix and 'PYTHONUSERBASE' not in os.environ and 'real_prefix' not in sys.__dict__ ++ # is_default_prefix = not prefix or os.path.normpath(prefix) in ('/usr', '/usr/local') ++ return 'posix_local' + return os.name + + def _getuserbase(): +@@ -309,7 +332,7 @@ + def _get_makefile_filename(): + if _PYTHON_BUILD: + return os.path.join(_PROJECT_BASE, "Makefile") +- return os.path.join(get_path('platstdlib'), "config", "Makefile") ++ return os.path.join(get_path('platstdlib').replace("/usr/local","/usr",1), "config", "Makefile") + + def _generate_posix_vars(): + """Generate the Python module containing build-time variables.""" +@@ -438,7 +461,7 @@ + else: + inc_dir = _PROJECT_BASE + else: +- inc_dir = get_path('platinclude') ++ inc_dir = get_path('platinclude').replace("/usr/local","/usr",1) + return os.path.join(inc_dir, 'pyconfig.h') + + def get_scheme_names(): +--- a/Lib/test/test_import.py ++++ b/Lib/test/test_import.py +@@ -301,7 +301,7 @@ + with check_warnings(('', ImportWarning)): + # Just a random non-package directory we always expect to be + # somewhere in sys.path... +- self.assertRaises(ImportError, __import__, "site-packages") ++ self.assertRaises(ImportError, __import__, "dist-packages") + + def test_import_by_filename(self): + path = os.path.abspath(TESTFN) +--- a/Lib/test/test_site.py ++++ b/Lib/test/test_site.py +@@ -242,10 +242,13 @@ + elif os.sep == '/': + # OS X non-framwework builds, Linux, FreeBSD, etc + self.assertEqual(len(dirs), 2) +- wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3], +- 'site-packages') ++ wanted = os.path.join('xoxo', 'local', 'lib', ++ 'python' + sys.version[:3], ++ 'dist-packages') + self.assertEqual(dirs[0], wanted) +- wanted = os.path.join('xoxo', 'lib', 'site-python') ++ wanted = os.path.join('xoxo', 'lib', ++ 'python' + sys.version[:3], ++ 'dist-packages') + self.assertEqual(dirs[1], wanted) + else: + # other platforms +--- a/Lib/test/test_sysconfig.py ++++ b/Lib/test/test_sysconfig.py +@@ -239,8 +239,8 @@ + self.assertTrue(os.path.isfile(config_h), config_h) + + def test_get_scheme_names(self): +- wanted = ('nt', 'nt_user', 'os2', 'os2_home', 'osx_framework_user', +- 'posix_home', 'posix_prefix', 'posix_user') ++ wanted = ('deb_system', 'nt', 'nt_user', 'os2', 'os2_home', 'osx_framework_user', ++ 'posix_home', 'posix_local', 'posix_prefix', 'posix_user') + self.assertEqual(get_scheme_names(), wanted) + + def test_symlink(self): +--- a/Lib/distutils/tests/test_install.py ++++ b/Lib/distutils/tests/test_install.py +@@ -195,7 +195,7 @@ + + found = [os.path.basename(line) for line in content.splitlines()] + expected = ['hello.py', 'hello.pyc', 'sayhi', +- 'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]] ++ 'UNKNOWN-0.0.0.egg-info'] + self.assertEqual(found, expected) + + def test_record_extensions(self): +@@ -225,7 +225,7 @@ + + found = [os.path.basename(line) for line in content.splitlines()] + expected = [_make_ext_name('xx'), +- 'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]] ++ 'UNKNOWN-0.0.0.egg-info'] + self.assertEqual(found, expected) + + def test_debug_mode(self): +--- a/Lib/distutils/tests/test_bdist_dumb.py ++++ b/Lib/distutils/tests/test_bdist_dumb.py +@@ -87,7 +87,7 @@ + fp.close() + + contents = sorted(os.path.basename(fn) for fn in contents) +- wanted = ['foo-0.1-py%s.%s.egg-info' % sys.version_info[:2], 'foo.py'] ++ wanted = ['foo-0.1.egg-info', 'foo.py'] + if not sys.dont_write_bytecode: + wanted.append('foo.pyc') + self.assertEqual(contents, sorted(wanted)) +--- a/Lib/pydoc.py ++++ b/Lib/pydoc.py +@@ -359,6 +359,7 @@ + 'marshal', 'posix', 'signal', 'sys', + 'thread', 'zipimport') or + (file.startswith(basedir) and ++ not file.startswith(os.path.join(basedir, 'dist-packages')) and + not file.startswith(os.path.join(basedir, 'site-packages')))) and + object.__name__ not in ('xml.etree', 'test.pydoc_mod')): + if docloc.startswith("http://"): --- python2.7-2.7.5.orig/debian/patches/libffi-shared.diff +++ python2.7-2.7.5/debian/patches/libffi-shared.diff @@ -0,0 +1,11 @@ +--- a/setup.py ++++ b/setup.py +@@ -2084,7 +2084,7 @@ + break + ffi_lib = None + if ffi_inc is not None: +- for lib_name in ('ffi_convenience', 'ffi_pic', 'ffi'): ++ for lib_name in ('ffi', 'ffi_convenience', 'ffi_pic', 'ffi'): + if (self.compiler.find_library_file(lib_dirs, lib_name)): + ffi_lib = lib_name + break --- python2.7-2.7.5.orig/debian/patches/lto-link-flags.diff +++ python2.7-2.7.5/debian/patches/lto-link-flags.diff @@ -0,0 +1,22 @@ +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -123,8 +123,8 @@ + + # Symbols used for using shared libraries + SO= @SO@ +-LDSHARED= @LDSHARED@ $(LDFLAGS) +-BLDSHARED= @BLDSHARED@ $(LDFLAGS) ++LDSHARED= @LDSHARED@ $(PY_LDFLAGS) ++BLDSHARED= @BLDSHARED@ $(PY_LDFLAGS) $(PY_CFLAGS) + LDCXXSHARED= @LDCXXSHARED@ + DESTSHARED= $(BINLIBDEST)/lib-dynload + +@@ -441,7 +441,7 @@ + + # Build the interpreter + $(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY) +- $(LINKCC) $(PY_LDFLAGS) $(LINKFORSHARED) -o $@ \ ++ $(LINKCC) $(PY_LDFLAGS) $(PY_CFLAGS) $(LINKFORSHARED) -o $@ \ + Modules/python.o \ + -Wl,--whole-archive $(BLDLIBRARY) -Wl,--no-whole-archive $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST) + --- python2.7-2.7.5.orig/debian/patches/hurd-disable-nonworking-constants.diff +++ python2.7-2.7.5/debian/patches/hurd-disable-nonworking-constants.diff @@ -0,0 +1,34 @@ +# DP: Comment out constant exposed on the API which are not implemented on +# DP: GNU/Hurd. They would not work at runtime anyway. + +--- a/Modules/posixmodule.c ++++ b/Modules/posixmodule.c +@@ -9188,12 +9188,14 @@ + #ifdef O_LARGEFILE + if (ins(d, "O_LARGEFILE", (long)O_LARGEFILE)) return -1; + #endif ++#ifndef __GNU__ + #ifdef O_SHLOCK + if (ins(d, "O_SHLOCK", (long)O_SHLOCK)) return -1; + #endif + #ifdef O_EXLOCK + if (ins(d, "O_EXLOCK", (long)O_EXLOCK)) return -1; + #endif ++#endif + + /* MS Windows */ + #ifdef O_NOINHERIT +--- a/Modules/socketmodule.c ++++ b/Modules/socketmodule.c +@@ -4902,9 +4902,11 @@ + #ifdef SO_OOBINLINE + PyModule_AddIntConstant(m, "SO_OOBINLINE", SO_OOBINLINE); + #endif ++#ifndef __GNU__ + #ifdef SO_REUSEPORT + PyModule_AddIntConstant(m, "SO_REUSEPORT", SO_REUSEPORT); + #endif ++#endif + #ifdef SO_SNDBUF + PyModule_AddIntConstant(m, "SO_SNDBUF", SO_SNDBUF); + #endif --- python2.7-2.7.5.orig/debian/patches/bdist-wininst-notfound.diff +++ python2.7-2.7.5/debian/patches/bdist-wininst-notfound.diff @@ -0,0 +1,25 @@ +# DP: the wininst-* files cannot be built within Debian, needing a +# DP: zlib mingw build, which the zlib maintainer isn't going to provide. + +--- a/Lib/distutils/command/bdist_wininst.py ++++ b/Lib/distutils/command/bdist_wininst.py +@@ -14,6 +14,7 @@ + from distutils.core import Command + from distutils.dir_util import remove_tree + from distutils.errors import DistutilsOptionError, DistutilsPlatformError ++from distutils.errors import DistutilsFileError + from distutils import log + from distutils.util import get_platform + +@@ -360,7 +361,10 @@ + sfix = '' + + filename = os.path.join(directory, "wininst-%.1f%s.exe" % (bv, sfix)) +- f = open(filename, "rb") ++ try: ++ f = open(filename, "rb") ++ except IOError, msg: ++ raise DistutilsFileError, str(msg) + ', %s not included in the Debian packages.' % filename + try: + return f.read() + finally: --- python2.7-2.7.5.orig/debian/patches/ssl.match_hostname.diff +++ python2.7-2.7.5/debian/patches/ssl.match_hostname.diff @@ -0,0 +1,112 @@ +--- a/Lib/ssl.py ++++ b/Lib/ssl.py +@@ -56,6 +56,7 @@ + """ + + import textwrap ++import re + + import _ssl # if we can't import it, let the error propagate + +@@ -96,6 +97,69 @@ + # (OpenSSL's default setting is 'DEFAULT:!aNULL:!eNULL') + _DEFAULT_CIPHERS = 'DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2' + ++class CertificateError(ValueError): ++ pass ++ ++def _dnsname_to_pat(dn, max_wildcards=1): ++ pats = [] ++ for frag in dn.split(r'.'): ++ if frag.count('*') > max_wildcards: ++ # Issue #17980: avoid denials of service by refusing more ++ # than one wildcard per fragment. A survery of established ++ # policy among SSL implementations showed it to be a ++ # reasonable choice. ++ raise CertificateError( ++ "too many wildcards in certificate DNS name: " + repr(dn)) ++ if frag == '*': ++ # When '*' is a fragment by itself, it matches a non-empty dotless ++ # fragment. ++ pats.append('[^.]+') ++ else: ++ # Otherwise, '*' matches any dotless fragment. ++ frag = re.escape(frag) ++ pats.append(frag.replace(r'\*', '[^.]*')) ++ return re.compile(r'\A' + r'\.'.join(pats) + r'\Z', re.IGNORECASE) ++ ++ ++def match_hostname(cert, hostname): ++ """Verify that *cert* (in decoded format as returned by ++ SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 rules ++ are mostly followed, but IP addresses are not accepted for *hostname*. ++ ++ CertificateError is raised on failure. On success, the function ++ returns nothing. ++ """ ++ if not cert: ++ raise ValueError("empty or no certificate") ++ dnsnames = [] ++ san = cert.get('subjectAltName', ()) ++ for key, value in san: ++ if key == 'DNS': ++ if _dnsname_to_pat(value).match(hostname): ++ return ++ dnsnames.append(value) ++ if not dnsnames: ++ # The subject is only checked when there is no dNSName entry ++ # in subjectAltName ++ for sub in cert.get('subject', ()): ++ for key, value in sub: ++ # XXX according to RFC 2818, the most specific Common Name ++ # must be used. ++ if key == 'commonName': ++ if _dnsname_to_pat(value).match(hostname): ++ return ++ dnsnames.append(value) ++ if len(dnsnames) > 1: ++ raise CertificateError("hostname %r " ++ "doesn't match either of %s" ++ % (hostname, ', '.join(map(repr, dnsnames)))) ++ elif len(dnsnames) == 1: ++ raise CertificateError("hostname %r " ++ "doesn't match %r" ++ % (hostname, dnsnames[0])) ++ else: ++ raise CertificateError("no appropriate commonName or " ++ "subjectAltName fields were found") + + class SSLSocket(socket): + +--- a/Doc/library/ssl.rst ++++ b/Doc/library/ssl.rst +@@ -521,6 +521,29 @@ + certificate, and no one else will have it in their cache of known (and trusted) + root certificates. + ++.. function:: match_hostname(cert, hostname) ++ ++ Verify that *cert* (in decoded format as returned by ++ :meth:`SSLSocket.getpeercert`) matches the given *hostname*. The rules ++ applied are those for checking the identity of HTTPS servers as outlined ++ in :rfc:`2818`, except that IP addresses are not currently supported. ++ In addition to HTTPS, this function should be suitable for checking the ++ identity of servers in various SSL-based protocols such as FTPS, IMAPS, ++ POPS and others. ++ ++ :exc:`CertificateError` is raised on failure. On success, the function ++ returns nothing:: ++ ++ >>> cert = {'subject': ((('commonName', 'example.com'),),)} ++ >>> ssl.match_hostname(cert, "example.com") ++ >>> ssl.match_hostname(cert, "example.org") ++ Traceback (most recent call last): ++ File "", line 1, in ++ File "/home/py3k/Lib/ssl.py", line 130, in match_hostname ++ ssl.CertificateError: hostname 'example.org' doesn't match 'example.com' ++ ++ Not part of the 2.7 upstream releases. Backported for Debian/Ubuntu. ++ + + Examples + -------- --- python2.7-2.7.5.orig/debian/patches/locale-module.diff +++ python2.7-2.7.5/debian/patches/locale-module.diff @@ -0,0 +1,17 @@ +# DP: * Lib/locale.py: +# DP: - Don't map 'utf8', 'utf-8' to 'utf', which is not a known encoding +# DP: for glibc. + +--- a/Lib/locale.py ++++ b/Lib/locale.py +@@ -1528,8 +1528,8 @@ + 'uk_ua.iso88595': 'uk_UA.ISO8859-5', + 'uk_ua.koi8u': 'uk_UA.KOI8-U', + 'uk_ua.microsoftcp1251': 'uk_UA.CP1251', +- 'univ': 'en_US.utf', +- 'universal': 'en_US.utf', ++ 'univ': 'en_US.UTF-8', ++ 'universal': 'en_US.UTF-8', + 'universal.utf8@ucs4': 'en_US.UTF-8', + 'ur': 'ur_PK.CP1256', + 'ur_pk': 'ur_PK.CP1256', --- python2.7-2.7.5.orig/debian/patches/plat-gnukfreebsd.diff +++ python2.7-2.7.5/debian/patches/plat-gnukfreebsd.diff @@ -0,0 +1,2478 @@ +--- /dev/null ++++ b/Lib/plat-gnukfreebsd7/IN.py +@@ -0,0 +1,809 @@ ++# Generated by h2py from /usr/include/netinet/in.h ++_NETINET_IN_H = 1 ++ ++# Included from features.h ++_FEATURES_H = 1 ++__USE_ANSI = 1 ++__FAVOR_BSD = 1 ++_ISOC99_SOURCE = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 200809L ++_XOPEN_SOURCE = 700 ++_XOPEN_SOURCE_EXTENDED = 1 ++_LARGEFILE64_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++_ATFILE_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++__USE_ISOC99 = 1 ++__USE_ISOC95 = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 2 ++_POSIX_C_SOURCE = 199506L ++_POSIX_C_SOURCE = 200112L ++_POSIX_C_SOURCE = 200809L ++__USE_POSIX_IMPLICITLY = 1 ++__USE_POSIX = 1 ++__USE_POSIX2 = 1 ++__USE_POSIX199309 = 1 ++__USE_POSIX199506 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN2K8 = 1 ++_ATFILE_SOURCE = 1 ++__USE_XOPEN = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_UNIX98 = 1 ++_LARGEFILE_SOURCE = 1 ++__USE_XOPEN2K8 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_FILE_OFFSET64 = 1 ++__USE_MISC = 1 ++__USE_BSD = 1 ++__USE_SVID = 1 ++__USE_ATFILE = 1 ++__USE_GNU = 1 ++__USE_REENTRANT = 1 ++__USE_FORTIFY_LEVEL = 2 ++__USE_FORTIFY_LEVEL = 1 ++__USE_FORTIFY_LEVEL = 0 ++ ++# Included from bits/predefs.h ++__STDC_IEC_559__ = 1 ++__STDC_IEC_559_COMPLEX__ = 1 ++__STDC_ISO_10646__ = 200009L ++__GNU_LIBRARY__ = 6 ++__GLIBC__ = 2 ++__GLIBC_MINOR__ = 11 ++__GLIBC_HAVE_LONG_LONG = 1 ++ ++# Included from sys/cdefs.h ++_SYS_CDEFS_H = 1 ++def __NTH(fct): return fct ++ ++def __NTH(fct): return fct ++ ++def __P(args): return args ++ ++def __PMT(args): return args ++ ++def __STRING(x): return #x ++ ++def __bos(ptr): return __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) ++ ++def __bos0(ptr): return __builtin_object_size (ptr, 0) ++ ++def __warnattr(msg): return __attribute__((__warning__ (msg))) ++ ++__flexarr = [] ++__flexarr = [0] ++__flexarr = [] ++__flexarr = [1] ++def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ++ ++def __attribute__(xyz): return ++ ++def __attribute_format_arg__(x): return __attribute__ ((__format_arg__ (x))) ++ ++def __attribute_format_arg__(x): return ++ ++ ++# Included from bits/wordsize.h ++__WORDSIZE = 32 ++__LDBL_COMPAT = 1 ++def __LDBL_REDIR_DECL(name): return \ ++ ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_EXTERN_INLINES = 1 ++__USE_EXTERN_INLINES_IN_LIBC = 1 ++ ++# Included from gnu/stubs.h ++ ++# Included from stdint.h ++_STDINT_H = 1 ++ ++# Included from bits/wchar.h ++_BITS_WCHAR_H = 1 ++__WCHAR_MAX = (2147483647) ++__WCHAR_MIN = (-__WCHAR_MAX - 1) ++def __INT64_C(c): return c ## L ++ ++def __UINT64_C(c): return c ## UL ++ ++def __INT64_C(c): return c ## LL ++ ++def __UINT64_C(c): return c ## ULL ++ ++INT8_MIN = (-128) ++INT16_MIN = (-32767-1) ++INT32_MIN = (-2147483647-1) ++INT64_MIN = (-__INT64_C(9223372036854775807)-1) ++INT8_MAX = (127) ++INT16_MAX = (32767) ++INT32_MAX = (2147483647) ++INT64_MAX = (__INT64_C(9223372036854775807)) ++UINT8_MAX = (255) ++UINT16_MAX = (65535) ++UINT64_MAX = (__UINT64_C(18446744073709551615)) ++INT_LEAST8_MIN = (-128) ++INT_LEAST16_MIN = (-32767-1) ++INT_LEAST32_MIN = (-2147483647-1) ++INT_LEAST64_MIN = (-__INT64_C(9223372036854775807)-1) ++INT_LEAST8_MAX = (127) ++INT_LEAST16_MAX = (32767) ++INT_LEAST32_MAX = (2147483647) ++INT_LEAST64_MAX = (__INT64_C(9223372036854775807)) ++UINT_LEAST8_MAX = (255) ++UINT_LEAST16_MAX = (65535) ++UINT_LEAST64_MAX = (__UINT64_C(18446744073709551615)) ++INT_FAST8_MIN = (-128) ++INT_FAST16_MIN = (-9223372036854775807L-1) ++INT_FAST32_MIN = (-9223372036854775807L-1) ++INT_FAST16_MIN = (-2147483647-1) ++INT_FAST32_MIN = (-2147483647-1) ++INT_FAST64_MIN = (-__INT64_C(9223372036854775807)-1) ++INT_FAST8_MAX = (127) ++INT_FAST16_MAX = (9223372036854775807L) ++INT_FAST32_MAX = (9223372036854775807L) ++INT_FAST16_MAX = (2147483647) ++INT_FAST32_MAX = (2147483647) ++INT_FAST64_MAX = (__INT64_C(9223372036854775807)) ++UINT_FAST8_MAX = (255) ++UINT_FAST64_MAX = (__UINT64_C(18446744073709551615)) ++INTPTR_MIN = (-9223372036854775807L-1) ++INTPTR_MAX = (9223372036854775807L) ++INTPTR_MIN = (-2147483647-1) ++INTPTR_MAX = (2147483647) ++INTMAX_MIN = (-__INT64_C(9223372036854775807)-1) ++INTMAX_MAX = (__INT64_C(9223372036854775807)) ++UINTMAX_MAX = (__UINT64_C(18446744073709551615)) ++PTRDIFF_MIN = (-9223372036854775807L-1) ++PTRDIFF_MAX = (9223372036854775807L) ++PTRDIFF_MIN = (-2147483647-1) ++PTRDIFF_MAX = (2147483647) ++SIG_ATOMIC_MIN = (-2147483647-1) ++SIG_ATOMIC_MAX = (2147483647) ++WCHAR_MIN = __WCHAR_MIN ++WCHAR_MAX = __WCHAR_MAX ++def INT8_C(c): return c ++ ++def INT16_C(c): return c ++ ++def INT32_C(c): return c ++ ++def INT64_C(c): return c ## L ++ ++def INT64_C(c): return c ## LL ++ ++def UINT8_C(c): return c ++ ++def UINT16_C(c): return c ++ ++def UINT32_C(c): return c ## U ++ ++def UINT64_C(c): return c ## UL ++ ++def UINT64_C(c): return c ## ULL ++ ++def INTMAX_C(c): return c ## L ++ ++def UINTMAX_C(c): return c ## UL ++ ++def INTMAX_C(c): return c ## LL ++ ++def UINTMAX_C(c): return c ## ULL ++ ++ ++# Included from sys/socket.h ++_SYS_SOCKET_H = 1 ++ ++# Included from sys/uio.h ++_SYS_UIO_H = 1 ++from TYPES import * ++ ++# Included from bits/uio.h ++_BITS_UIO_H = 1 ++from TYPES import * ++UIO_MAXIOV = 1024 ++ ++# Included from bits/sigset.h ++_SIGSET_H_types = 1 ++_SIGSET_H_fns = 1 ++def __sigword(sig): return (((sig) - 1) >> 5) ++ ++def __sigemptyset(set): return \ ++ ++def __sigfillset(set): return \ ++ ++def __sigisemptyset(set): return \ ++ ++ ++# Included from bits/socket.h ++__BITS_SOCKET_H = 1 ++ ++# Included from limits.h ++_LIBC_LIMITS_H_ = 1 ++MB_LEN_MAX = 16 ++_LIMITS_H = 1 ++CHAR_BIT = 8 ++SCHAR_MIN = (-128) ++SCHAR_MAX = 127 ++UCHAR_MAX = 255 ++CHAR_MIN = 0 ++CHAR_MAX = UCHAR_MAX ++CHAR_MIN = SCHAR_MIN ++CHAR_MAX = SCHAR_MAX ++SHRT_MIN = (-32768) ++SHRT_MAX = 32767 ++USHRT_MAX = 65535 ++INT_MAX = 2147483647 ++LONG_MAX = 9223372036854775807L ++LONG_MAX = 2147483647L ++LONG_MIN = (-LONG_MAX - 1L) ++ ++# Included from bits/posix1_lim.h ++_BITS_POSIX1_LIM_H = 1 ++_POSIX_AIO_LISTIO_MAX = 2 ++_POSIX_AIO_MAX = 1 ++_POSIX_ARG_MAX = 4096 ++_POSIX_CHILD_MAX = 25 ++_POSIX_CHILD_MAX = 6 ++_POSIX_DELAYTIMER_MAX = 32 ++_POSIX_HOST_NAME_MAX = 255 ++_POSIX_LINK_MAX = 8 ++_POSIX_LOGIN_NAME_MAX = 9 ++_POSIX_MAX_CANON = 255 ++_POSIX_MAX_INPUT = 255 ++_POSIX_MQ_OPEN_MAX = 8 ++_POSIX_MQ_PRIO_MAX = 32 ++_POSIX_NAME_MAX = 14 ++_POSIX_NGROUPS_MAX = 8 ++_POSIX_NGROUPS_MAX = 0 ++_POSIX_OPEN_MAX = 20 ++_POSIX_OPEN_MAX = 16 ++_POSIX_FD_SETSIZE = _POSIX_OPEN_MAX ++_POSIX_PATH_MAX = 256 ++_POSIX_PIPE_BUF = 512 ++_POSIX_RE_DUP_MAX = 255 ++_POSIX_RTSIG_MAX = 8 ++_POSIX_SEM_NSEMS_MAX = 256 ++_POSIX_SEM_VALUE_MAX = 32767 ++_POSIX_SIGQUEUE_MAX = 32 ++_POSIX_SSIZE_MAX = 32767 ++_POSIX_STREAM_MAX = 8 ++_POSIX_SYMLINK_MAX = 255 ++_POSIX_SYMLOOP_MAX = 8 ++_POSIX_TIMER_MAX = 32 ++_POSIX_TTY_NAME_MAX = 9 ++_POSIX_TZNAME_MAX = 6 ++_POSIX_QLIMIT = 1 ++_POSIX_HIWAT = _POSIX_PIPE_BUF ++_POSIX_UIO_MAXIOV = 16 ++_POSIX_CLOCKRES_MIN = 20000000 ++ ++# Included from bits/local_lim.h ++ ++# Included from sys/syslimits.h ++ARG_MAX = 262144 ++CHILD_MAX = 40 ++LINK_MAX = 32767 ++MAX_CANON = 255 ++MAX_INPUT = 255 ++NAME_MAX = 255 ++NGROUPS_MAX = 1023 ++OPEN_MAX = 64 ++PATH_MAX = 1024 ++PIPE_BUF = 512 ++IOV_MAX = 1024 ++_POSIX_THREAD_KEYS_MAX = 128 ++PTHREAD_KEYS_MAX = 1024 ++_POSIX_THREAD_DESTRUCTOR_ITERATIONS = 4 ++PTHREAD_DESTRUCTOR_ITERATIONS = _POSIX_THREAD_DESTRUCTOR_ITERATIONS ++_POSIX_THREAD_THREADS_MAX = 64 ++PTHREAD_THREADS_MAX = 1024 ++AIO_PRIO_DELTA_MAX = 20 ++PTHREAD_STACK_MIN = 16384 ++TIMER_MAX = 256 ++DELAYTIMER_MAX = 2147483647 ++SSIZE_MAX = LONG_MAX ++NGROUPS_MAX = 8 ++ ++# Included from bits/posix2_lim.h ++_BITS_POSIX2_LIM_H = 1 ++_POSIX2_BC_BASE_MAX = 99 ++_POSIX2_BC_DIM_MAX = 2048 ++_POSIX2_BC_SCALE_MAX = 99 ++_POSIX2_BC_STRING_MAX = 1000 ++_POSIX2_COLL_WEIGHTS_MAX = 2 ++_POSIX2_EXPR_NEST_MAX = 32 ++_POSIX2_LINE_MAX = 2048 ++_POSIX2_RE_DUP_MAX = 255 ++_POSIX2_CHARCLASS_NAME_MAX = 14 ++BC_BASE_MAX = _POSIX2_BC_BASE_MAX ++BC_DIM_MAX = _POSIX2_BC_DIM_MAX ++BC_SCALE_MAX = _POSIX2_BC_SCALE_MAX ++BC_STRING_MAX = _POSIX2_BC_STRING_MAX ++COLL_WEIGHTS_MAX = 255 ++EXPR_NEST_MAX = _POSIX2_EXPR_NEST_MAX ++LINE_MAX = _POSIX2_LINE_MAX ++CHARCLASS_NAME_MAX = 2048 ++RE_DUP_MAX = (0x7fff) ++ ++# Included from bits/xopen_lim.h ++_XOPEN_LIM_H = 1 ++ ++# Included from bits/stdio_lim.h ++L_tmpnam = 20 ++TMP_MAX = 238328 ++FILENAME_MAX = 1024 ++L_ctermid = 9 ++L_cuserid = 9 ++FOPEN_MAX = 64 ++IOV_MAX = 1024 ++_XOPEN_IOV_MAX = _POSIX_UIO_MAXIOV ++NL_ARGMAX = _POSIX_ARG_MAX ++NL_LANGMAX = _POSIX2_LINE_MAX ++NL_MSGMAX = INT_MAX ++NL_NMAX = INT_MAX ++NL_SETMAX = INT_MAX ++NL_TEXTMAX = INT_MAX ++NZERO = 20 ++WORD_BIT = 16 ++WORD_BIT = 32 ++WORD_BIT = 64 ++WORD_BIT = 16 ++WORD_BIT = 32 ++WORD_BIT = 64 ++WORD_BIT = 32 ++LONG_BIT = 32 ++LONG_BIT = 64 ++LONG_BIT = 32 ++LONG_BIT = 64 ++LONG_BIT = 64 ++LONG_BIT = 32 ++ ++# Included from bits/types.h ++_BITS_TYPES_H = 1 ++__S32_TYPE = int ++__SWORD_TYPE = int ++__SLONG32_TYPE = int ++ ++# Included from bits/typesizes.h ++_BITS_TYPESIZES_H = 1 ++__PID_T_TYPE = __S32_TYPE ++__CLOCK_T_TYPE = __S32_TYPE ++__SWBLK_T_TYPE = __S32_TYPE ++__CLOCKID_T_TYPE = __S32_TYPE ++__TIMER_T_TYPE = __S32_TYPE ++__SSIZE_T_TYPE = __SWORD_TYPE ++__FD_SETSIZE = 1024 ++PF_UNSPEC = 0 ++PF_LOCAL = 1 ++PF_UNIX = PF_LOCAL ++PF_FILE = PF_LOCAL ++PF_INET = 2 ++PF_IMPLINK = 3 ++PF_PUP = 4 ++PF_CHAOS = 5 ++PF_NS = 6 ++PF_ISO = 7 ++PF_OSI = PF_ISO ++PF_ECMA = 8 ++PF_DATAKIT = 9 ++PF_CCITT = 10 ++PF_SNA = 11 ++PF_DECnet = 12 ++PF_DLI = 13 ++PF_LAT = 14 ++PF_HYLINK = 15 ++PF_APPLETALK = 16 ++PF_ROUTE = 17 ++PF_LINK = 18 ++PF_XTP = 19 ++PF_COIP = 20 ++PF_CNT = 21 ++PF_RTIP = 22 ++PF_IPX = 23 ++PF_SIP = 24 ++PF_PIP = 25 ++PF_ISDN = 26 ++PF_KEY = 27 ++PF_INET6 = 28 ++PF_NATM = 29 ++PF_ATM = 30 ++PF_HDRCMPLT = 31 ++PF_NETGRAPH = 32 ++PF_MAX = 33 ++AF_UNSPEC = PF_UNSPEC ++AF_LOCAL = PF_LOCAL ++AF_UNIX = PF_UNIX ++AF_FILE = PF_FILE ++AF_INET = PF_INET ++AF_IMPLINK = PF_IMPLINK ++AF_PUP = PF_PUP ++AF_CHAOS = PF_CHAOS ++AF_NS = PF_NS ++AF_ISO = PF_ISO ++AF_OSI = PF_OSI ++AF_ECMA = PF_ECMA ++AF_DATAKIT = PF_DATAKIT ++AF_CCITT = PF_CCITT ++AF_SNA = PF_SNA ++AF_DECnet = PF_DECnet ++AF_DLI = PF_DLI ++AF_LAT = PF_LAT ++AF_HYLINK = PF_HYLINK ++AF_APPLETALK = PF_APPLETALK ++AF_ROUTE = PF_ROUTE ++AF_LINK = PF_LINK ++pseudo_AF_XTP = PF_XTP ++AF_COIP = PF_COIP ++AF_CNT = PF_CNT ++pseudo_AF_RTIP = PF_RTIP ++AF_IPX = PF_IPX ++AF_SIP = PF_SIP ++pseudo_AF_PIP = PF_PIP ++AF_ISDN = PF_ISDN ++AF_E164 = AF_ISDN ++pseudo_AF_KEY = PF_KEY ++AF_INET6 = PF_INET6 ++AF_NATM = PF_NATM ++AF_ATM = PF_ATM ++pseudo_AF_HDRCMPLT = PF_HDRCMPLT ++AF_NETGRAPH = PF_NETGRAPH ++AF_MAX = PF_MAX ++SOMAXCONN = 128 ++ ++# Included from bits/sockaddr.h ++_BITS_SOCKADDR_H = 1 ++def __SOCKADDR_COMMON(sa_prefix): return \ ++ ++_HAVE_SA_LEN = 1 ++_SS_SIZE = 128 ++def CMSG_FIRSTHDR(mhdr): return \ ++ ++CMGROUP_MAX = 16 ++SOL_SOCKET = 0xffff ++LOCAL_PEERCRED = 0x001 ++LOCAL_CREDS = 0x002 ++LOCAL_CONNWAIT = 0x004 ++ ++# Included from bits/socket2.h ++def IN_CLASSA(a): return ((((in_addr_t)(a)) & (-2147483648)) == 0) ++ ++IN_CLASSA_NET = (-16777216) ++IN_CLASSA_NSHIFT = 24 ++IN_CLASSA_HOST = ((-1) & ~IN_CLASSA_NET) ++IN_CLASSA_MAX = 128 ++def IN_CLASSB(a): return ((((in_addr_t)(a)) & (-1073741824)) == (-2147483648)) ++ ++IN_CLASSB_NET = (-65536) ++IN_CLASSB_NSHIFT = 16 ++IN_CLASSB_HOST = ((-1) & ~IN_CLASSB_NET) ++IN_CLASSB_MAX = 65536 ++def IN_CLASSC(a): return ((((in_addr_t)(a)) & (-536870912)) == (-1073741824)) ++ ++IN_CLASSC_NET = (-256) ++IN_CLASSC_NSHIFT = 8 ++IN_CLASSC_HOST = ((-1) & ~IN_CLASSC_NET) ++def IN_CLASSD(a): return ((((in_addr_t)(a)) & (-268435456)) == (-536870912)) ++ ++def IN_MULTICAST(a): return IN_CLASSD(a) ++ ++def IN_EXPERIMENTAL(a): return ((((in_addr_t)(a)) & (-536870912)) == (-536870912)) ++ ++def IN_BADCLASS(a): return ((((in_addr_t)(a)) & (-268435456)) == (-268435456)) ++ ++IN_LOOPBACKNET = 127 ++INET_ADDRSTRLEN = 16 ++INET6_ADDRSTRLEN = 46 ++ ++# Included from bits/in.h ++IMPLINK_IP = 155 ++IMPLINK_LOWEXPER = 156 ++IMPLINK_HIGHEXPER = 158 ++IPPROTO_DIVERT = 258 ++SOL_IP = 0 ++IP_OPTIONS = 1 ++IP_HDRINCL = 2 ++IP_TOS = 3 ++IP_TTL = 4 ++IP_RECVOPTS = 5 ++IP_RECVRETOPTS = 6 ++IP_RECVDSTADDR = 7 ++IP_SENDSRCADDR = IP_RECVDSTADDR ++IP_RETOPTS = 8 ++IP_MULTICAST_IF = 9 ++IP_MULTICAST_TTL = 10 ++IP_MULTICAST_LOOP = 11 ++IP_ADD_MEMBERSHIP = 12 ++IP_DROP_MEMBERSHIP = 13 ++IP_MULTICAST_VIF = 14 ++IP_RSVP_ON = 15 ++IP_RSVP_OFF = 16 ++IP_RSVP_VIF_ON = 17 ++IP_RSVP_VIF_OFF = 18 ++IP_PORTRANGE = 19 ++IP_RECVIF = 20 ++IP_IPSEC_POLICY = 21 ++IP_FAITH = 22 ++IP_ONESBCAST = 23 ++IP_NONLOCALOK = 24 ++IP_FW_TABLE_ADD = 40 ++IP_FW_TABLE_DEL = 41 ++IP_FW_TABLE_FLUSH = 42 ++IP_FW_TABLE_GETSIZE = 43 ++IP_FW_TABLE_LIST = 44 ++IP_FW_ADD = 50 ++IP_FW_DEL = 51 ++IP_FW_FLUSH = 52 ++IP_FW_ZERO = 53 ++IP_FW_GET = 54 ++IP_FW_RESETLOG = 55 ++IP_FW_NAT_CFG = 56 ++IP_FW_NAT_DEL = 57 ++IP_FW_NAT_GET_CONFIG = 58 ++IP_FW_NAT_GET_LOG = 59 ++IP_DUMMYNET_CONFIGURE = 60 ++IP_DUMMYNET_DEL = 61 ++IP_DUMMYNET_FLUSH = 62 ++IP_DUMMYNET_GET = 64 ++IP_RECVTTL = 65 ++IP_MINTTL = 66 ++IP_DONTFRAG = 67 ++IP_ADD_SOURCE_MEMBERSHIP = 70 ++IP_DROP_SOURCE_MEMBERSHIP = 71 ++IP_BLOCK_SOURCE = 72 ++IP_UNBLOCK_SOURCE = 73 ++IP_MSFILTER = 74 ++MCAST_JOIN_GROUP = 80 ++MCAST_LEAVE_GROUP = 81 ++MCAST_JOIN_SOURCE_GROUP = 82 ++MCAST_LEAVE_SOURCE_GROUP = 83 ++MCAST_BLOCK_SOURCE = 84 ++MCAST_UNBLOCK_SOURCE = 85 ++IP_DEFAULT_MULTICAST_TTL = 1 ++IP_DEFAULT_MULTICAST_LOOP = 1 ++IP_MIN_MEMBERSHIPS = 31 ++IP_MAX_MEMBERSHIPS = 4095 ++IP_MAX_SOURCE_FILTER = 1024 ++MCAST_UNDEFINED = 0 ++MCAST_INCLUDE = 1 ++MCAST_EXCLUDE = 2 ++IP_PORTRANGE_DEFAULT = 0 ++IP_PORTRANGE_HIGH = 1 ++IP_PORTRANGE_LOW = 2 ++IPCTL_FORWARDING = 1 ++IPCTL_SENDREDIRECTS = 2 ++IPCTL_DEFTTL = 3 ++IPCTL_DEFMTU = 4 ++IPCTL_RTEXPIRE = 5 ++IPCTL_RTMINEXPIRE = 6 ++IPCTL_RTMAXCACHE = 7 ++IPCTL_SOURCEROUTE = 8 ++IPCTL_DIRECTEDBROADCAST = 9 ++IPCTL_INTRQMAXLEN = 10 ++IPCTL_INTRQDROPS = 11 ++IPCTL_STATS = 12 ++IPCTL_ACCEPTSOURCEROUTE = 13 ++IPCTL_FASTFORWARDING = 14 ++IPCTL_KEEPFAITH = 15 ++IPCTL_GIF_TTL = 16 ++IPCTL_MAXID = 17 ++IPV6_SOCKOPT_RESERVED1 = 3 ++IPV6_UNICAST_HOPS = 4 ++IPV6_MULTICAST_IF = 9 ++IPV6_MULTICAST_HOPS = 10 ++IPV6_MULTICAST_LOOP = 11 ++IPV6_JOIN_GROUP = 12 ++IPV6_LEAVE_GROUP = 13 ++IPV6_PORTRANGE = 14 ++ICMP6_FILTER = 18 ++IPV6_CHECKSUM = 26 ++IPV6_V6ONLY = 27 ++IPV6_IPSEC_POLICY = 28 ++IPV6_FAITH = 29 ++IPV6_FW_ADD = 30 ++IPV6_FW_DEL = 31 ++IPV6_FW_FLUSH = 32 ++IPV6_FW_ZERO = 33 ++IPV6_FW_GET = 34 ++IPV6_RTHDRDSTOPTS = 35 ++IPV6_RECVPKTINFO = 36 ++IPV6_RECVHOPLIMIT = 37 ++IPV6_RECVRTHDR = 38 ++IPV6_RECVHOPOPTS = 39 ++IPV6_RECVDSTOPTS = 40 ++IPV6_USE_MIN_MTU = 42 ++IPV6_RECVPATHMTU = 43 ++IPV6_PATHMTU = 44 ++IPV6_PKTINFO = 46 ++IPV6_HOPLIMIT = 47 ++IPV6_NEXTHOP = 48 ++IPV6_HOPOPTS = 49 ++IPV6_DSTOPTS = 50 ++IPV6_RTHDR = 51 ++IPV6_RECVTCLASS = 57 ++IPV6_AUTOFLOWLABEL = 59 ++IPV6_TCLASS = 61 ++IPV6_DONTFRAG = 62 ++IPV6_PREFER_TEMPADDR = 63 ++IPV6_ADD_MEMBERSHIP = IPV6_JOIN_GROUP ++IPV6_DROP_MEMBERSHIP = IPV6_LEAVE_GROUP ++IPV6_RXHOPOPTS = IPV6_HOPOPTS ++IPV6_RXDSTOPTS = IPV6_DSTOPTS ++SOL_IPV6 = 41 ++SOL_ICMPV6 = 58 ++IPV6_DEFAULT_MULTICAST_HOPS = 1 ++IPV6_DEFAULT_MULTICAST_LOOP = 1 ++IPV6_PORTRANGE_DEFAULT = 0 ++IPV6_PORTRANGE_HIGH = 1 ++IPV6_PORTRANGE_LOW = 2 ++IPV6_RTHDR_LOOSE = 0 ++IPV6_RTHDR_STRICT = 1 ++IPV6_RTHDR_TYPE_0 = 0 ++IPV6CTL_FORWARDING = 1 ++IPV6CTL_SENDREDIRECTS = 2 ++IPV6CTL_DEFHLIM = 3 ++IPV6CTL_FORWSRCRT = 5 ++IPV6CTL_STATS = 6 ++IPV6CTL_MRTSTATS = 7 ++IPV6CTL_MRTPROTO = 8 ++IPV6CTL_MAXFRAGPACKETS = 9 ++IPV6CTL_SOURCECHECK = 10 ++IPV6CTL_SOURCECHECK_LOGINT = 11 ++IPV6CTL_ACCEPT_RTADV = 12 ++IPV6CTL_KEEPFAITH = 13 ++IPV6CTL_LOG_INTERVAL = 14 ++IPV6CTL_HDRNESTLIMIT = 15 ++IPV6CTL_DAD_COUNT = 16 ++IPV6CTL_AUTO_FLOWLABEL = 17 ++IPV6CTL_DEFMCASTHLIM = 18 ++IPV6CTL_GIF_HLIM = 19 ++IPV6CTL_KAME_VERSION = 20 ++IPV6CTL_USE_DEPRECATED = 21 ++IPV6CTL_RR_PRUNE = 22 ++IPV6CTL_V6ONLY = 24 ++IPV6CTL_RTEXPIRE = 25 ++IPV6CTL_RTMINEXPIRE = 26 ++IPV6CTL_RTMAXCACHE = 27 ++IPV6CTL_USETEMPADDR = 32 ++IPV6CTL_TEMPPLTIME = 33 ++IPV6CTL_TEMPVLTIME = 34 ++IPV6CTL_AUTO_LINKLOCAL = 35 ++IPV6CTL_RIP6STATS = 36 ++IPV6CTL_PREFER_TEMPADDR = 37 ++IPV6CTL_ADDRCTLPOLICY = 38 ++IPV6CTL_USE_DEFAULTZONE = 39 ++IPV6CTL_MAXFRAGS = 41 ++IPV6CTL_MCAST_PMTU = 44 ++IPV6CTL_STEALTH = 45 ++ICMPV6CTL_ND6_ONLINKNSRFC4861 = 47 ++IPV6CTL_MAXID = 48 ++ ++# Included from endian.h ++_ENDIAN_H = 1 ++__LITTLE_ENDIAN = 1234 ++__BIG_ENDIAN = 4321 ++__PDP_ENDIAN = 3412 ++ ++# Included from bits/endian.h ++__BYTE_ORDER = __LITTLE_ENDIAN ++__FLOAT_WORD_ORDER = __BYTE_ORDER ++LITTLE_ENDIAN = __LITTLE_ENDIAN ++BIG_ENDIAN = __BIG_ENDIAN ++PDP_ENDIAN = __PDP_ENDIAN ++BYTE_ORDER = __BYTE_ORDER ++ ++# Included from bits/byteswap.h ++_BITS_BYTESWAP_H = 1 ++def __bswap_constant_16(x): return \ ++ ++def __bswap_16(x): return \ ++ ++def __bswap_16(x): return \ ++ ++def __bswap_constant_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_constant_64(x): return \ ++ ++def __bswap_64(x): return \ ++ ++def htobe16(x): return __bswap_16 (x) ++ ++def htole16(x): return (x) ++ ++def be16toh(x): return __bswap_16 (x) ++ ++def le16toh(x): return (x) ++ ++def htobe32(x): return __bswap_32 (x) ++ ++def htole32(x): return (x) ++ ++def be32toh(x): return __bswap_32 (x) ++ ++def le32toh(x): return (x) ++ ++def htobe64(x): return __bswap_64 (x) ++ ++def htole64(x): return (x) ++ ++def be64toh(x): return __bswap_64 (x) ++ ++def le64toh(x): return (x) ++ ++def htobe16(x): return (x) ++ ++def htole16(x): return __bswap_16 (x) ++ ++def be16toh(x): return (x) ++ ++def le16toh(x): return __bswap_16 (x) ++ ++def htobe32(x): return (x) ++ ++def htole32(x): return __bswap_32 (x) ++ ++def be32toh(x): return (x) ++ ++def le32toh(x): return __bswap_32 (x) ++ ++def htobe64(x): return (x) ++ ++def htole64(x): return __bswap_64 (x) ++ ++def be64toh(x): return (x) ++ ++def le64toh(x): return __bswap_64 (x) ++ ++def ntohl(x): return (x) ++ ++def ntohs(x): return (x) ++ ++def htonl(x): return (x) ++ ++def htons(x): return (x) ++ ++def ntohl(x): return __bswap_32 (x) ++ ++def ntohs(x): return __bswap_16 (x) ++ ++def htonl(x): return __bswap_32 (x) ++ ++def htons(x): return __bswap_16 (x) ++ ++def IN6_IS_ADDR_UNSPECIFIED(a): return \ ++ ++def IN6_IS_ADDR_LOOPBACK(a): return \ ++ ++def IN6_IS_ADDR_LINKLOCAL(a): return \ ++ ++def IN6_IS_ADDR_SITELOCAL(a): return \ ++ ++def IN6_IS_ADDR_V4MAPPED(a): return \ ++ ++def IN6_IS_ADDR_V4COMPAT(a): return \ ++ ++def IN6_IS_ADDR_MC_NODELOCAL(a): return \ ++ ++def IN6_IS_ADDR_MC_LINKLOCAL(a): return \ ++ ++def IN6_IS_ADDR_MC_SITELOCAL(a): return \ ++ ++def IN6_IS_ADDR_MC_ORGLOCAL(a): return \ ++ ++def IN6_IS_ADDR_MC_GLOBAL(a): return \ ++ +--- /dev/null ++++ b/Lib/plat-gnukfreebsd7/TYPES.py +@@ -0,0 +1,303 @@ ++# Generated by h2py from /usr/include/sys/types.h ++_SYS_TYPES_H = 1 ++ ++# Included from features.h ++_FEATURES_H = 1 ++__USE_ANSI = 1 ++__FAVOR_BSD = 1 ++_ISOC99_SOURCE = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 200809L ++_XOPEN_SOURCE = 700 ++_XOPEN_SOURCE_EXTENDED = 1 ++_LARGEFILE64_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++_ATFILE_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++__USE_ISOC99 = 1 ++__USE_ISOC95 = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 2 ++_POSIX_C_SOURCE = 199506L ++_POSIX_C_SOURCE = 200112L ++_POSIX_C_SOURCE = 200809L ++__USE_POSIX_IMPLICITLY = 1 ++__USE_POSIX = 1 ++__USE_POSIX2 = 1 ++__USE_POSIX199309 = 1 ++__USE_POSIX199506 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN2K8 = 1 ++_ATFILE_SOURCE = 1 ++__USE_XOPEN = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_UNIX98 = 1 ++_LARGEFILE_SOURCE = 1 ++__USE_XOPEN2K8 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_FILE_OFFSET64 = 1 ++__USE_MISC = 1 ++__USE_BSD = 1 ++__USE_SVID = 1 ++__USE_ATFILE = 1 ++__USE_GNU = 1 ++__USE_REENTRANT = 1 ++__USE_FORTIFY_LEVEL = 2 ++__USE_FORTIFY_LEVEL = 1 ++__USE_FORTIFY_LEVEL = 0 ++ ++# Included from bits/predefs.h ++__STDC_IEC_559__ = 1 ++__STDC_IEC_559_COMPLEX__ = 1 ++__STDC_ISO_10646__ = 200009L ++__GNU_LIBRARY__ = 6 ++__GLIBC__ = 2 ++__GLIBC_MINOR__ = 11 ++__GLIBC_HAVE_LONG_LONG = 1 ++ ++# Included from sys/cdefs.h ++_SYS_CDEFS_H = 1 ++def __NTH(fct): return fct ++ ++def __NTH(fct): return fct ++ ++def __P(args): return args ++ ++def __PMT(args): return args ++ ++def __STRING(x): return #x ++ ++def __bos(ptr): return __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) ++ ++def __bos0(ptr): return __builtin_object_size (ptr, 0) ++ ++def __warnattr(msg): return __attribute__((__warning__ (msg))) ++ ++__flexarr = [] ++__flexarr = [0] ++__flexarr = [] ++__flexarr = [1] ++def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ++ ++def __attribute__(xyz): return ++ ++def __attribute_format_arg__(x): return __attribute__ ((__format_arg__ (x))) ++ ++def __attribute_format_arg__(x): return ++ ++ ++# Included from bits/wordsize.h ++__WORDSIZE = 32 ++__LDBL_COMPAT = 1 ++def __LDBL_REDIR_DECL(name): return \ ++ ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_EXTERN_INLINES = 1 ++__USE_EXTERN_INLINES_IN_LIBC = 1 ++ ++# Included from gnu/stubs.h ++ ++# Included from bits/types.h ++_BITS_TYPES_H = 1 ++__S32_TYPE = int ++__SWORD_TYPE = int ++__SLONG32_TYPE = int ++ ++# Included from bits/typesizes.h ++_BITS_TYPESIZES_H = 1 ++__PID_T_TYPE = __S32_TYPE ++__CLOCK_T_TYPE = __S32_TYPE ++__SWBLK_T_TYPE = __S32_TYPE ++__CLOCKID_T_TYPE = __S32_TYPE ++__TIMER_T_TYPE = __S32_TYPE ++__SSIZE_T_TYPE = __SWORD_TYPE ++__FD_SETSIZE = 1024 ++ ++# Included from time.h ++_TIME_H = 1 ++ ++# Included from bits/time.h ++_BITS_TIME_H = 1 ++CLOCKS_PER_SEC = 1000000l ++CLK_TCK = 128 ++CLOCK_REALTIME = 0 ++CLOCK_PROCESS_CPUTIME_ID = 2 ++CLOCK_THREAD_CPUTIME_ID = 3 ++CLOCK_MONOTONIC = 4 ++CLOCK_VIRTUAL = 1 ++CLOCK_PROF = 2 ++CLOCK_UPTIME = 5 ++CLOCK_UPTIME_PRECISE = 7 ++CLOCK_UPTIME_FAST = 8 ++CLOCK_REALTIME_PRECISE = 9 ++CLOCK_REALTIME_FAST = 10 ++CLOCK_MONOTONIC_PRECISE = 11 ++CLOCK_MONOTONIC_FAST = 12 ++CLOCK_SECOND = 13 ++TIMER_RELTIME = 0 ++TIMER_ABSTIME = 1 ++_STRUCT_TIMEVAL = 1 ++CLK_TCK = CLOCKS_PER_SEC ++__clock_t_defined = 1 ++__time_t_defined = 1 ++__clockid_t_defined = 1 ++__timer_t_defined = 1 ++__timespec_defined = 1 ++ ++# Included from xlocale.h ++_XLOCALE_H = 1 ++def __isleap(year): return \ ++ ++__BIT_TYPES_DEFINED__ = 1 ++ ++# Included from endian.h ++_ENDIAN_H = 1 ++__LITTLE_ENDIAN = 1234 ++__BIG_ENDIAN = 4321 ++__PDP_ENDIAN = 3412 ++ ++# Included from bits/endian.h ++__BYTE_ORDER = __LITTLE_ENDIAN ++__FLOAT_WORD_ORDER = __BYTE_ORDER ++LITTLE_ENDIAN = __LITTLE_ENDIAN ++BIG_ENDIAN = __BIG_ENDIAN ++PDP_ENDIAN = __PDP_ENDIAN ++BYTE_ORDER = __BYTE_ORDER ++ ++# Included from bits/byteswap.h ++_BITS_BYTESWAP_H = 1 ++def __bswap_constant_16(x): return \ ++ ++def __bswap_16(x): return \ ++ ++def __bswap_16(x): return \ ++ ++def __bswap_constant_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_constant_64(x): return \ ++ ++def __bswap_64(x): return \ ++ ++def htobe16(x): return __bswap_16 (x) ++ ++def htole16(x): return (x) ++ ++def be16toh(x): return __bswap_16 (x) ++ ++def le16toh(x): return (x) ++ ++def htobe32(x): return __bswap_32 (x) ++ ++def htole32(x): return (x) ++ ++def be32toh(x): return __bswap_32 (x) ++ ++def le32toh(x): return (x) ++ ++def htobe64(x): return __bswap_64 (x) ++ ++def htole64(x): return (x) ++ ++def be64toh(x): return __bswap_64 (x) ++ ++def le64toh(x): return (x) ++ ++def htobe16(x): return (x) ++ ++def htole16(x): return __bswap_16 (x) ++ ++def be16toh(x): return (x) ++ ++def le16toh(x): return __bswap_16 (x) ++ ++def htobe32(x): return (x) ++ ++def htole32(x): return __bswap_32 (x) ++ ++def be32toh(x): return (x) ++ ++def le32toh(x): return __bswap_32 (x) ++ ++def htobe64(x): return (x) ++ ++def htole64(x): return __bswap_64 (x) ++ ++def be64toh(x): return (x) ++ ++def le64toh(x): return __bswap_64 (x) ++ ++ ++# Included from sys/select.h ++_SYS_SELECT_H = 1 ++ ++# Included from bits/select.h ++def __FD_ZERO(fdsp): return \ ++ ++def __FD_ZERO(set): return \ ++ ++ ++# Included from bits/sigset.h ++_SIGSET_H_types = 1 ++_SIGSET_H_fns = 1 ++def __sigword(sig): return (((sig) - 1) >> 5) ++ ++def __sigemptyset(set): return \ ++ ++def __sigfillset(set): return \ ++ ++def __sigisemptyset(set): return \ ++ ++def __FDELT(d): return ((d) / __NFDBITS) ++ ++FD_SETSIZE = __FD_SETSIZE ++def FD_ZERO(fdsetp): return __FD_ZERO (fdsetp) ++ ++ ++# Included from sys/sysmacros.h ++_SYS_SYSMACROS_H = 1 ++def minor(dev): return ((int)((dev) & (-65281))) ++ ++def gnu_dev_major(dev): return major (dev) ++ ++def gnu_dev_minor(dev): return minor (dev) ++ ++ ++# Included from bits/pthreadtypes.h ++_BITS_PTHREADTYPES_H = 1 ++ ++# Included from bits/sched.h ++SCHED_OTHER = 2 ++SCHED_FIFO = 1 ++SCHED_RR = 3 ++CSIGNAL = 0x000000ff ++CLONE_VM = 0x00000100 ++CLONE_FS = 0x00000200 ++CLONE_FILES = 0x00000400 ++CLONE_SIGHAND = 0x00000800 ++CLONE_PTRACE = 0x00002000 ++CLONE_VFORK = 0x00004000 ++CLONE_SYSVSEM = 0x00040000 ++__defined_schedparam = 1 ++__CPU_SETSIZE = 128 ++def __CPUELT(cpu): return ((cpu) / __NCPUBITS) ++ ++def __CPU_ALLOC_SIZE(count): return \ ++ ++def __CPU_ALLOC(count): return __sched_cpualloc (count) ++ ++def __CPU_FREE(cpuset): return __sched_cpufree (cpuset) ++ +--- /dev/null ++++ b/Lib/plat-gnukfreebsd7/DLFCN.py +@@ -0,0 +1,118 @@ ++# Generated by h2py from /usr/include/dlfcn.h ++_DLFCN_H = 1 ++ ++# Included from features.h ++_FEATURES_H = 1 ++__USE_ANSI = 1 ++__FAVOR_BSD = 1 ++_ISOC99_SOURCE = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 200809L ++_XOPEN_SOURCE = 700 ++_XOPEN_SOURCE_EXTENDED = 1 ++_LARGEFILE64_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++_ATFILE_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++__USE_ISOC99 = 1 ++__USE_ISOC95 = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 2 ++_POSIX_C_SOURCE = 199506L ++_POSIX_C_SOURCE = 200112L ++_POSIX_C_SOURCE = 200809L ++__USE_POSIX_IMPLICITLY = 1 ++__USE_POSIX = 1 ++__USE_POSIX2 = 1 ++__USE_POSIX199309 = 1 ++__USE_POSIX199506 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN2K8 = 1 ++_ATFILE_SOURCE = 1 ++__USE_XOPEN = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_UNIX98 = 1 ++_LARGEFILE_SOURCE = 1 ++__USE_XOPEN2K8 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_FILE_OFFSET64 = 1 ++__USE_MISC = 1 ++__USE_BSD = 1 ++__USE_SVID = 1 ++__USE_ATFILE = 1 ++__USE_GNU = 1 ++__USE_REENTRANT = 1 ++__USE_FORTIFY_LEVEL = 2 ++__USE_FORTIFY_LEVEL = 1 ++__USE_FORTIFY_LEVEL = 0 ++ ++# Included from bits/predefs.h ++__STDC_IEC_559__ = 1 ++__STDC_IEC_559_COMPLEX__ = 1 ++__STDC_ISO_10646__ = 200009L ++__GNU_LIBRARY__ = 6 ++__GLIBC__ = 2 ++__GLIBC_MINOR__ = 11 ++__GLIBC_HAVE_LONG_LONG = 1 ++ ++# Included from sys/cdefs.h ++_SYS_CDEFS_H = 1 ++def __NTH(fct): return fct ++ ++def __NTH(fct): return fct ++ ++def __P(args): return args ++ ++def __PMT(args): return args ++ ++def __STRING(x): return #x ++ ++def __bos(ptr): return __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) ++ ++def __bos0(ptr): return __builtin_object_size (ptr, 0) ++ ++def __warnattr(msg): return __attribute__((__warning__ (msg))) ++ ++__flexarr = [] ++__flexarr = [0] ++__flexarr = [] ++__flexarr = [1] ++def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ++ ++def __attribute__(xyz): return ++ ++def __attribute_format_arg__(x): return __attribute__ ((__format_arg__ (x))) ++ ++def __attribute_format_arg__(x): return ++ ++ ++# Included from bits/wordsize.h ++__WORDSIZE = 32 ++__LDBL_COMPAT = 1 ++def __LDBL_REDIR_DECL(name): return \ ++ ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_EXTERN_INLINES = 1 ++__USE_EXTERN_INLINES_IN_LIBC = 1 ++ ++# Included from gnu/stubs.h ++ ++# Included from bits/dlfcn.h ++RTLD_LAZY = 0x00001 ++RTLD_NOW = 0x00002 ++RTLD_BINDING_MASK = 0x3 ++RTLD_NOLOAD = 0x00004 ++RTLD_DEEPBIND = 0x00008 ++RTLD_GLOBAL = 0x00100 ++RTLD_LOCAL = 0 ++RTLD_NODELETE = 0x01000 ++LM_ID_BASE = 0 ++LM_ID_NEWLM = -1 +--- /dev/null ++++ b/Lib/plat-gnukfreebsd8/IN.py +@@ -0,0 +1,809 @@ ++# Generated by h2py from /usr/include/netinet/in.h ++_NETINET_IN_H = 1 ++ ++# Included from features.h ++_FEATURES_H = 1 ++__USE_ANSI = 1 ++__FAVOR_BSD = 1 ++_ISOC99_SOURCE = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 200809L ++_XOPEN_SOURCE = 700 ++_XOPEN_SOURCE_EXTENDED = 1 ++_LARGEFILE64_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++_ATFILE_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++__USE_ISOC99 = 1 ++__USE_ISOC95 = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 2 ++_POSIX_C_SOURCE = 199506L ++_POSIX_C_SOURCE = 200112L ++_POSIX_C_SOURCE = 200809L ++__USE_POSIX_IMPLICITLY = 1 ++__USE_POSIX = 1 ++__USE_POSIX2 = 1 ++__USE_POSIX199309 = 1 ++__USE_POSIX199506 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN2K8 = 1 ++_ATFILE_SOURCE = 1 ++__USE_XOPEN = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_UNIX98 = 1 ++_LARGEFILE_SOURCE = 1 ++__USE_XOPEN2K8 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_FILE_OFFSET64 = 1 ++__USE_MISC = 1 ++__USE_BSD = 1 ++__USE_SVID = 1 ++__USE_ATFILE = 1 ++__USE_GNU = 1 ++__USE_REENTRANT = 1 ++__USE_FORTIFY_LEVEL = 2 ++__USE_FORTIFY_LEVEL = 1 ++__USE_FORTIFY_LEVEL = 0 ++ ++# Included from bits/predefs.h ++__STDC_IEC_559__ = 1 ++__STDC_IEC_559_COMPLEX__ = 1 ++__STDC_ISO_10646__ = 200009L ++__GNU_LIBRARY__ = 6 ++__GLIBC__ = 2 ++__GLIBC_MINOR__ = 11 ++__GLIBC_HAVE_LONG_LONG = 1 ++ ++# Included from sys/cdefs.h ++_SYS_CDEFS_H = 1 ++def __NTH(fct): return fct ++ ++def __NTH(fct): return fct ++ ++def __P(args): return args ++ ++def __PMT(args): return args ++ ++def __STRING(x): return #x ++ ++def __bos(ptr): return __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) ++ ++def __bos0(ptr): return __builtin_object_size (ptr, 0) ++ ++def __warnattr(msg): return __attribute__((__warning__ (msg))) ++ ++__flexarr = [] ++__flexarr = [0] ++__flexarr = [] ++__flexarr = [1] ++def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ++ ++def __attribute__(xyz): return ++ ++def __attribute_format_arg__(x): return __attribute__ ((__format_arg__ (x))) ++ ++def __attribute_format_arg__(x): return ++ ++ ++# Included from bits/wordsize.h ++__WORDSIZE = 32 ++__LDBL_COMPAT = 1 ++def __LDBL_REDIR_DECL(name): return \ ++ ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_EXTERN_INLINES = 1 ++__USE_EXTERN_INLINES_IN_LIBC = 1 ++ ++# Included from gnu/stubs.h ++ ++# Included from stdint.h ++_STDINT_H = 1 ++ ++# Included from bits/wchar.h ++_BITS_WCHAR_H = 1 ++__WCHAR_MAX = (2147483647) ++__WCHAR_MIN = (-__WCHAR_MAX - 1) ++def __INT64_C(c): return c ## L ++ ++def __UINT64_C(c): return c ## UL ++ ++def __INT64_C(c): return c ## LL ++ ++def __UINT64_C(c): return c ## ULL ++ ++INT8_MIN = (-128) ++INT16_MIN = (-32767-1) ++INT32_MIN = (-2147483647-1) ++INT64_MIN = (-__INT64_C(9223372036854775807)-1) ++INT8_MAX = (127) ++INT16_MAX = (32767) ++INT32_MAX = (2147483647) ++INT64_MAX = (__INT64_C(9223372036854775807)) ++UINT8_MAX = (255) ++UINT16_MAX = (65535) ++UINT64_MAX = (__UINT64_C(18446744073709551615)) ++INT_LEAST8_MIN = (-128) ++INT_LEAST16_MIN = (-32767-1) ++INT_LEAST32_MIN = (-2147483647-1) ++INT_LEAST64_MIN = (-__INT64_C(9223372036854775807)-1) ++INT_LEAST8_MAX = (127) ++INT_LEAST16_MAX = (32767) ++INT_LEAST32_MAX = (2147483647) ++INT_LEAST64_MAX = (__INT64_C(9223372036854775807)) ++UINT_LEAST8_MAX = (255) ++UINT_LEAST16_MAX = (65535) ++UINT_LEAST64_MAX = (__UINT64_C(18446744073709551615)) ++INT_FAST8_MIN = (-128) ++INT_FAST16_MIN = (-9223372036854775807L-1) ++INT_FAST32_MIN = (-9223372036854775807L-1) ++INT_FAST16_MIN = (-2147483647-1) ++INT_FAST32_MIN = (-2147483647-1) ++INT_FAST64_MIN = (-__INT64_C(9223372036854775807)-1) ++INT_FAST8_MAX = (127) ++INT_FAST16_MAX = (9223372036854775807L) ++INT_FAST32_MAX = (9223372036854775807L) ++INT_FAST16_MAX = (2147483647) ++INT_FAST32_MAX = (2147483647) ++INT_FAST64_MAX = (__INT64_C(9223372036854775807)) ++UINT_FAST8_MAX = (255) ++UINT_FAST64_MAX = (__UINT64_C(18446744073709551615)) ++INTPTR_MIN = (-9223372036854775807L-1) ++INTPTR_MAX = (9223372036854775807L) ++INTPTR_MIN = (-2147483647-1) ++INTPTR_MAX = (2147483647) ++INTMAX_MIN = (-__INT64_C(9223372036854775807)-1) ++INTMAX_MAX = (__INT64_C(9223372036854775807)) ++UINTMAX_MAX = (__UINT64_C(18446744073709551615)) ++PTRDIFF_MIN = (-9223372036854775807L-1) ++PTRDIFF_MAX = (9223372036854775807L) ++PTRDIFF_MIN = (-2147483647-1) ++PTRDIFF_MAX = (2147483647) ++SIG_ATOMIC_MIN = (-2147483647-1) ++SIG_ATOMIC_MAX = (2147483647) ++WCHAR_MIN = __WCHAR_MIN ++WCHAR_MAX = __WCHAR_MAX ++def INT8_C(c): return c ++ ++def INT16_C(c): return c ++ ++def INT32_C(c): return c ++ ++def INT64_C(c): return c ## L ++ ++def INT64_C(c): return c ## LL ++ ++def UINT8_C(c): return c ++ ++def UINT16_C(c): return c ++ ++def UINT32_C(c): return c ## U ++ ++def UINT64_C(c): return c ## UL ++ ++def UINT64_C(c): return c ## ULL ++ ++def INTMAX_C(c): return c ## L ++ ++def UINTMAX_C(c): return c ## UL ++ ++def INTMAX_C(c): return c ## LL ++ ++def UINTMAX_C(c): return c ## ULL ++ ++ ++# Included from sys/socket.h ++_SYS_SOCKET_H = 1 ++ ++# Included from sys/uio.h ++_SYS_UIO_H = 1 ++from TYPES import * ++ ++# Included from bits/uio.h ++_BITS_UIO_H = 1 ++from TYPES import * ++UIO_MAXIOV = 1024 ++ ++# Included from bits/sigset.h ++_SIGSET_H_types = 1 ++_SIGSET_H_fns = 1 ++def __sigword(sig): return (((sig) - 1) >> 5) ++ ++def __sigemptyset(set): return \ ++ ++def __sigfillset(set): return \ ++ ++def __sigisemptyset(set): return \ ++ ++ ++# Included from bits/socket.h ++__BITS_SOCKET_H = 1 ++ ++# Included from limits.h ++_LIBC_LIMITS_H_ = 1 ++MB_LEN_MAX = 16 ++_LIMITS_H = 1 ++CHAR_BIT = 8 ++SCHAR_MIN = (-128) ++SCHAR_MAX = 127 ++UCHAR_MAX = 255 ++CHAR_MIN = 0 ++CHAR_MAX = UCHAR_MAX ++CHAR_MIN = SCHAR_MIN ++CHAR_MAX = SCHAR_MAX ++SHRT_MIN = (-32768) ++SHRT_MAX = 32767 ++USHRT_MAX = 65535 ++INT_MAX = 2147483647 ++LONG_MAX = 9223372036854775807L ++LONG_MAX = 2147483647L ++LONG_MIN = (-LONG_MAX - 1L) ++ ++# Included from bits/posix1_lim.h ++_BITS_POSIX1_LIM_H = 1 ++_POSIX_AIO_LISTIO_MAX = 2 ++_POSIX_AIO_MAX = 1 ++_POSIX_ARG_MAX = 4096 ++_POSIX_CHILD_MAX = 25 ++_POSIX_CHILD_MAX = 6 ++_POSIX_DELAYTIMER_MAX = 32 ++_POSIX_HOST_NAME_MAX = 255 ++_POSIX_LINK_MAX = 8 ++_POSIX_LOGIN_NAME_MAX = 9 ++_POSIX_MAX_CANON = 255 ++_POSIX_MAX_INPUT = 255 ++_POSIX_MQ_OPEN_MAX = 8 ++_POSIX_MQ_PRIO_MAX = 32 ++_POSIX_NAME_MAX = 14 ++_POSIX_NGROUPS_MAX = 8 ++_POSIX_NGROUPS_MAX = 0 ++_POSIX_OPEN_MAX = 20 ++_POSIX_OPEN_MAX = 16 ++_POSIX_FD_SETSIZE = _POSIX_OPEN_MAX ++_POSIX_PATH_MAX = 256 ++_POSIX_PIPE_BUF = 512 ++_POSIX_RE_DUP_MAX = 255 ++_POSIX_RTSIG_MAX = 8 ++_POSIX_SEM_NSEMS_MAX = 256 ++_POSIX_SEM_VALUE_MAX = 32767 ++_POSIX_SIGQUEUE_MAX = 32 ++_POSIX_SSIZE_MAX = 32767 ++_POSIX_STREAM_MAX = 8 ++_POSIX_SYMLINK_MAX = 255 ++_POSIX_SYMLOOP_MAX = 8 ++_POSIX_TIMER_MAX = 32 ++_POSIX_TTY_NAME_MAX = 9 ++_POSIX_TZNAME_MAX = 6 ++_POSIX_QLIMIT = 1 ++_POSIX_HIWAT = _POSIX_PIPE_BUF ++_POSIX_UIO_MAXIOV = 16 ++_POSIX_CLOCKRES_MIN = 20000000 ++ ++# Included from bits/local_lim.h ++ ++# Included from sys/syslimits.h ++ARG_MAX = 262144 ++CHILD_MAX = 40 ++LINK_MAX = 32767 ++MAX_CANON = 255 ++MAX_INPUT = 255 ++NAME_MAX = 255 ++NGROUPS_MAX = 1023 ++OPEN_MAX = 64 ++PATH_MAX = 1024 ++PIPE_BUF = 512 ++IOV_MAX = 1024 ++_POSIX_THREAD_KEYS_MAX = 128 ++PTHREAD_KEYS_MAX = 1024 ++_POSIX_THREAD_DESTRUCTOR_ITERATIONS = 4 ++PTHREAD_DESTRUCTOR_ITERATIONS = _POSIX_THREAD_DESTRUCTOR_ITERATIONS ++_POSIX_THREAD_THREADS_MAX = 64 ++PTHREAD_THREADS_MAX = 1024 ++AIO_PRIO_DELTA_MAX = 20 ++PTHREAD_STACK_MIN = 16384 ++TIMER_MAX = 256 ++DELAYTIMER_MAX = 2147483647 ++SSIZE_MAX = LONG_MAX ++NGROUPS_MAX = 8 ++ ++# Included from bits/posix2_lim.h ++_BITS_POSIX2_LIM_H = 1 ++_POSIX2_BC_BASE_MAX = 99 ++_POSIX2_BC_DIM_MAX = 2048 ++_POSIX2_BC_SCALE_MAX = 99 ++_POSIX2_BC_STRING_MAX = 1000 ++_POSIX2_COLL_WEIGHTS_MAX = 2 ++_POSIX2_EXPR_NEST_MAX = 32 ++_POSIX2_LINE_MAX = 2048 ++_POSIX2_RE_DUP_MAX = 255 ++_POSIX2_CHARCLASS_NAME_MAX = 14 ++BC_BASE_MAX = _POSIX2_BC_BASE_MAX ++BC_DIM_MAX = _POSIX2_BC_DIM_MAX ++BC_SCALE_MAX = _POSIX2_BC_SCALE_MAX ++BC_STRING_MAX = _POSIX2_BC_STRING_MAX ++COLL_WEIGHTS_MAX = 255 ++EXPR_NEST_MAX = _POSIX2_EXPR_NEST_MAX ++LINE_MAX = _POSIX2_LINE_MAX ++CHARCLASS_NAME_MAX = 2048 ++RE_DUP_MAX = (0x7fff) ++ ++# Included from bits/xopen_lim.h ++_XOPEN_LIM_H = 1 ++ ++# Included from bits/stdio_lim.h ++L_tmpnam = 20 ++TMP_MAX = 238328 ++FILENAME_MAX = 1024 ++L_ctermid = 9 ++L_cuserid = 9 ++FOPEN_MAX = 64 ++IOV_MAX = 1024 ++_XOPEN_IOV_MAX = _POSIX_UIO_MAXIOV ++NL_ARGMAX = _POSIX_ARG_MAX ++NL_LANGMAX = _POSIX2_LINE_MAX ++NL_MSGMAX = INT_MAX ++NL_NMAX = INT_MAX ++NL_SETMAX = INT_MAX ++NL_TEXTMAX = INT_MAX ++NZERO = 20 ++WORD_BIT = 16 ++WORD_BIT = 32 ++WORD_BIT = 64 ++WORD_BIT = 16 ++WORD_BIT = 32 ++WORD_BIT = 64 ++WORD_BIT = 32 ++LONG_BIT = 32 ++LONG_BIT = 64 ++LONG_BIT = 32 ++LONG_BIT = 64 ++LONG_BIT = 64 ++LONG_BIT = 32 ++ ++# Included from bits/types.h ++_BITS_TYPES_H = 1 ++__S32_TYPE = int ++__SWORD_TYPE = int ++__SLONG32_TYPE = int ++ ++# Included from bits/typesizes.h ++_BITS_TYPESIZES_H = 1 ++__PID_T_TYPE = __S32_TYPE ++__CLOCK_T_TYPE = __S32_TYPE ++__SWBLK_T_TYPE = __S32_TYPE ++__CLOCKID_T_TYPE = __S32_TYPE ++__TIMER_T_TYPE = __S32_TYPE ++__SSIZE_T_TYPE = __SWORD_TYPE ++__FD_SETSIZE = 1024 ++PF_UNSPEC = 0 ++PF_LOCAL = 1 ++PF_UNIX = PF_LOCAL ++PF_FILE = PF_LOCAL ++PF_INET = 2 ++PF_IMPLINK = 3 ++PF_PUP = 4 ++PF_CHAOS = 5 ++PF_NS = 6 ++PF_ISO = 7 ++PF_OSI = PF_ISO ++PF_ECMA = 8 ++PF_DATAKIT = 9 ++PF_CCITT = 10 ++PF_SNA = 11 ++PF_DECnet = 12 ++PF_DLI = 13 ++PF_LAT = 14 ++PF_HYLINK = 15 ++PF_APPLETALK = 16 ++PF_ROUTE = 17 ++PF_LINK = 18 ++PF_XTP = 19 ++PF_COIP = 20 ++PF_CNT = 21 ++PF_RTIP = 22 ++PF_IPX = 23 ++PF_SIP = 24 ++PF_PIP = 25 ++PF_ISDN = 26 ++PF_KEY = 27 ++PF_INET6 = 28 ++PF_NATM = 29 ++PF_ATM = 30 ++PF_HDRCMPLT = 31 ++PF_NETGRAPH = 32 ++PF_MAX = 33 ++AF_UNSPEC = PF_UNSPEC ++AF_LOCAL = PF_LOCAL ++AF_UNIX = PF_UNIX ++AF_FILE = PF_FILE ++AF_INET = PF_INET ++AF_IMPLINK = PF_IMPLINK ++AF_PUP = PF_PUP ++AF_CHAOS = PF_CHAOS ++AF_NS = PF_NS ++AF_ISO = PF_ISO ++AF_OSI = PF_OSI ++AF_ECMA = PF_ECMA ++AF_DATAKIT = PF_DATAKIT ++AF_CCITT = PF_CCITT ++AF_SNA = PF_SNA ++AF_DECnet = PF_DECnet ++AF_DLI = PF_DLI ++AF_LAT = PF_LAT ++AF_HYLINK = PF_HYLINK ++AF_APPLETALK = PF_APPLETALK ++AF_ROUTE = PF_ROUTE ++AF_LINK = PF_LINK ++pseudo_AF_XTP = PF_XTP ++AF_COIP = PF_COIP ++AF_CNT = PF_CNT ++pseudo_AF_RTIP = PF_RTIP ++AF_IPX = PF_IPX ++AF_SIP = PF_SIP ++pseudo_AF_PIP = PF_PIP ++AF_ISDN = PF_ISDN ++AF_E164 = AF_ISDN ++pseudo_AF_KEY = PF_KEY ++AF_INET6 = PF_INET6 ++AF_NATM = PF_NATM ++AF_ATM = PF_ATM ++pseudo_AF_HDRCMPLT = PF_HDRCMPLT ++AF_NETGRAPH = PF_NETGRAPH ++AF_MAX = PF_MAX ++SOMAXCONN = 128 ++ ++# Included from bits/sockaddr.h ++_BITS_SOCKADDR_H = 1 ++def __SOCKADDR_COMMON(sa_prefix): return \ ++ ++_HAVE_SA_LEN = 1 ++_SS_SIZE = 128 ++def CMSG_FIRSTHDR(mhdr): return \ ++ ++CMGROUP_MAX = 16 ++SOL_SOCKET = 0xffff ++LOCAL_PEERCRED = 0x001 ++LOCAL_CREDS = 0x002 ++LOCAL_CONNWAIT = 0x004 ++ ++# Included from bits/socket2.h ++def IN_CLASSA(a): return ((((in_addr_t)(a)) & (-2147483648)) == 0) ++ ++IN_CLASSA_NET = (-16777216) ++IN_CLASSA_NSHIFT = 24 ++IN_CLASSA_HOST = ((-1) & ~IN_CLASSA_NET) ++IN_CLASSA_MAX = 128 ++def IN_CLASSB(a): return ((((in_addr_t)(a)) & (-1073741824)) == (-2147483648)) ++ ++IN_CLASSB_NET = (-65536) ++IN_CLASSB_NSHIFT = 16 ++IN_CLASSB_HOST = ((-1) & ~IN_CLASSB_NET) ++IN_CLASSB_MAX = 65536 ++def IN_CLASSC(a): return ((((in_addr_t)(a)) & (-536870912)) == (-1073741824)) ++ ++IN_CLASSC_NET = (-256) ++IN_CLASSC_NSHIFT = 8 ++IN_CLASSC_HOST = ((-1) & ~IN_CLASSC_NET) ++def IN_CLASSD(a): return ((((in_addr_t)(a)) & (-268435456)) == (-536870912)) ++ ++def IN_MULTICAST(a): return IN_CLASSD(a) ++ ++def IN_EXPERIMENTAL(a): return ((((in_addr_t)(a)) & (-536870912)) == (-536870912)) ++ ++def IN_BADCLASS(a): return ((((in_addr_t)(a)) & (-268435456)) == (-268435456)) ++ ++IN_LOOPBACKNET = 127 ++INET_ADDRSTRLEN = 16 ++INET6_ADDRSTRLEN = 46 ++ ++# Included from bits/in.h ++IMPLINK_IP = 155 ++IMPLINK_LOWEXPER = 156 ++IMPLINK_HIGHEXPER = 158 ++IPPROTO_DIVERT = 258 ++SOL_IP = 0 ++IP_OPTIONS = 1 ++IP_HDRINCL = 2 ++IP_TOS = 3 ++IP_TTL = 4 ++IP_RECVOPTS = 5 ++IP_RECVRETOPTS = 6 ++IP_RECVDSTADDR = 7 ++IP_SENDSRCADDR = IP_RECVDSTADDR ++IP_RETOPTS = 8 ++IP_MULTICAST_IF = 9 ++IP_MULTICAST_TTL = 10 ++IP_MULTICAST_LOOP = 11 ++IP_ADD_MEMBERSHIP = 12 ++IP_DROP_MEMBERSHIP = 13 ++IP_MULTICAST_VIF = 14 ++IP_RSVP_ON = 15 ++IP_RSVP_OFF = 16 ++IP_RSVP_VIF_ON = 17 ++IP_RSVP_VIF_OFF = 18 ++IP_PORTRANGE = 19 ++IP_RECVIF = 20 ++IP_IPSEC_POLICY = 21 ++IP_FAITH = 22 ++IP_ONESBCAST = 23 ++IP_NONLOCALOK = 24 ++IP_FW_TABLE_ADD = 40 ++IP_FW_TABLE_DEL = 41 ++IP_FW_TABLE_FLUSH = 42 ++IP_FW_TABLE_GETSIZE = 43 ++IP_FW_TABLE_LIST = 44 ++IP_FW_ADD = 50 ++IP_FW_DEL = 51 ++IP_FW_FLUSH = 52 ++IP_FW_ZERO = 53 ++IP_FW_GET = 54 ++IP_FW_RESETLOG = 55 ++IP_FW_NAT_CFG = 56 ++IP_FW_NAT_DEL = 57 ++IP_FW_NAT_GET_CONFIG = 58 ++IP_FW_NAT_GET_LOG = 59 ++IP_DUMMYNET_CONFIGURE = 60 ++IP_DUMMYNET_DEL = 61 ++IP_DUMMYNET_FLUSH = 62 ++IP_DUMMYNET_GET = 64 ++IP_RECVTTL = 65 ++IP_MINTTL = 66 ++IP_DONTFRAG = 67 ++IP_ADD_SOURCE_MEMBERSHIP = 70 ++IP_DROP_SOURCE_MEMBERSHIP = 71 ++IP_BLOCK_SOURCE = 72 ++IP_UNBLOCK_SOURCE = 73 ++IP_MSFILTER = 74 ++MCAST_JOIN_GROUP = 80 ++MCAST_LEAVE_GROUP = 81 ++MCAST_JOIN_SOURCE_GROUP = 82 ++MCAST_LEAVE_SOURCE_GROUP = 83 ++MCAST_BLOCK_SOURCE = 84 ++MCAST_UNBLOCK_SOURCE = 85 ++IP_DEFAULT_MULTICAST_TTL = 1 ++IP_DEFAULT_MULTICAST_LOOP = 1 ++IP_MIN_MEMBERSHIPS = 31 ++IP_MAX_MEMBERSHIPS = 4095 ++IP_MAX_SOURCE_FILTER = 1024 ++MCAST_UNDEFINED = 0 ++MCAST_INCLUDE = 1 ++MCAST_EXCLUDE = 2 ++IP_PORTRANGE_DEFAULT = 0 ++IP_PORTRANGE_HIGH = 1 ++IP_PORTRANGE_LOW = 2 ++IPCTL_FORWARDING = 1 ++IPCTL_SENDREDIRECTS = 2 ++IPCTL_DEFTTL = 3 ++IPCTL_DEFMTU = 4 ++IPCTL_RTEXPIRE = 5 ++IPCTL_RTMINEXPIRE = 6 ++IPCTL_RTMAXCACHE = 7 ++IPCTL_SOURCEROUTE = 8 ++IPCTL_DIRECTEDBROADCAST = 9 ++IPCTL_INTRQMAXLEN = 10 ++IPCTL_INTRQDROPS = 11 ++IPCTL_STATS = 12 ++IPCTL_ACCEPTSOURCEROUTE = 13 ++IPCTL_FASTFORWARDING = 14 ++IPCTL_KEEPFAITH = 15 ++IPCTL_GIF_TTL = 16 ++IPCTL_MAXID = 17 ++IPV6_SOCKOPT_RESERVED1 = 3 ++IPV6_UNICAST_HOPS = 4 ++IPV6_MULTICAST_IF = 9 ++IPV6_MULTICAST_HOPS = 10 ++IPV6_MULTICAST_LOOP = 11 ++IPV6_JOIN_GROUP = 12 ++IPV6_LEAVE_GROUP = 13 ++IPV6_PORTRANGE = 14 ++ICMP6_FILTER = 18 ++IPV6_CHECKSUM = 26 ++IPV6_V6ONLY = 27 ++IPV6_IPSEC_POLICY = 28 ++IPV6_FAITH = 29 ++IPV6_FW_ADD = 30 ++IPV6_FW_DEL = 31 ++IPV6_FW_FLUSH = 32 ++IPV6_FW_ZERO = 33 ++IPV6_FW_GET = 34 ++IPV6_RTHDRDSTOPTS = 35 ++IPV6_RECVPKTINFO = 36 ++IPV6_RECVHOPLIMIT = 37 ++IPV6_RECVRTHDR = 38 ++IPV6_RECVHOPOPTS = 39 ++IPV6_RECVDSTOPTS = 40 ++IPV6_USE_MIN_MTU = 42 ++IPV6_RECVPATHMTU = 43 ++IPV6_PATHMTU = 44 ++IPV6_PKTINFO = 46 ++IPV6_HOPLIMIT = 47 ++IPV6_NEXTHOP = 48 ++IPV6_HOPOPTS = 49 ++IPV6_DSTOPTS = 50 ++IPV6_RTHDR = 51 ++IPV6_RECVTCLASS = 57 ++IPV6_AUTOFLOWLABEL = 59 ++IPV6_TCLASS = 61 ++IPV6_DONTFRAG = 62 ++IPV6_PREFER_TEMPADDR = 63 ++IPV6_ADD_MEMBERSHIP = IPV6_JOIN_GROUP ++IPV6_DROP_MEMBERSHIP = IPV6_LEAVE_GROUP ++IPV6_RXHOPOPTS = IPV6_HOPOPTS ++IPV6_RXDSTOPTS = IPV6_DSTOPTS ++SOL_IPV6 = 41 ++SOL_ICMPV6 = 58 ++IPV6_DEFAULT_MULTICAST_HOPS = 1 ++IPV6_DEFAULT_MULTICAST_LOOP = 1 ++IPV6_PORTRANGE_DEFAULT = 0 ++IPV6_PORTRANGE_HIGH = 1 ++IPV6_PORTRANGE_LOW = 2 ++IPV6_RTHDR_LOOSE = 0 ++IPV6_RTHDR_STRICT = 1 ++IPV6_RTHDR_TYPE_0 = 0 ++IPV6CTL_FORWARDING = 1 ++IPV6CTL_SENDREDIRECTS = 2 ++IPV6CTL_DEFHLIM = 3 ++IPV6CTL_FORWSRCRT = 5 ++IPV6CTL_STATS = 6 ++IPV6CTL_MRTSTATS = 7 ++IPV6CTL_MRTPROTO = 8 ++IPV6CTL_MAXFRAGPACKETS = 9 ++IPV6CTL_SOURCECHECK = 10 ++IPV6CTL_SOURCECHECK_LOGINT = 11 ++IPV6CTL_ACCEPT_RTADV = 12 ++IPV6CTL_KEEPFAITH = 13 ++IPV6CTL_LOG_INTERVAL = 14 ++IPV6CTL_HDRNESTLIMIT = 15 ++IPV6CTL_DAD_COUNT = 16 ++IPV6CTL_AUTO_FLOWLABEL = 17 ++IPV6CTL_DEFMCASTHLIM = 18 ++IPV6CTL_GIF_HLIM = 19 ++IPV6CTL_KAME_VERSION = 20 ++IPV6CTL_USE_DEPRECATED = 21 ++IPV6CTL_RR_PRUNE = 22 ++IPV6CTL_V6ONLY = 24 ++IPV6CTL_RTEXPIRE = 25 ++IPV6CTL_RTMINEXPIRE = 26 ++IPV6CTL_RTMAXCACHE = 27 ++IPV6CTL_USETEMPADDR = 32 ++IPV6CTL_TEMPPLTIME = 33 ++IPV6CTL_TEMPVLTIME = 34 ++IPV6CTL_AUTO_LINKLOCAL = 35 ++IPV6CTL_RIP6STATS = 36 ++IPV6CTL_PREFER_TEMPADDR = 37 ++IPV6CTL_ADDRCTLPOLICY = 38 ++IPV6CTL_USE_DEFAULTZONE = 39 ++IPV6CTL_MAXFRAGS = 41 ++IPV6CTL_MCAST_PMTU = 44 ++IPV6CTL_STEALTH = 45 ++ICMPV6CTL_ND6_ONLINKNSRFC4861 = 47 ++IPV6CTL_MAXID = 48 ++ ++# Included from endian.h ++_ENDIAN_H = 1 ++__LITTLE_ENDIAN = 1234 ++__BIG_ENDIAN = 4321 ++__PDP_ENDIAN = 3412 ++ ++# Included from bits/endian.h ++__BYTE_ORDER = __LITTLE_ENDIAN ++__FLOAT_WORD_ORDER = __BYTE_ORDER ++LITTLE_ENDIAN = __LITTLE_ENDIAN ++BIG_ENDIAN = __BIG_ENDIAN ++PDP_ENDIAN = __PDP_ENDIAN ++BYTE_ORDER = __BYTE_ORDER ++ ++# Included from bits/byteswap.h ++_BITS_BYTESWAP_H = 1 ++def __bswap_constant_16(x): return \ ++ ++def __bswap_16(x): return \ ++ ++def __bswap_16(x): return \ ++ ++def __bswap_constant_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_constant_64(x): return \ ++ ++def __bswap_64(x): return \ ++ ++def htobe16(x): return __bswap_16 (x) ++ ++def htole16(x): return (x) ++ ++def be16toh(x): return __bswap_16 (x) ++ ++def le16toh(x): return (x) ++ ++def htobe32(x): return __bswap_32 (x) ++ ++def htole32(x): return (x) ++ ++def be32toh(x): return __bswap_32 (x) ++ ++def le32toh(x): return (x) ++ ++def htobe64(x): return __bswap_64 (x) ++ ++def htole64(x): return (x) ++ ++def be64toh(x): return __bswap_64 (x) ++ ++def le64toh(x): return (x) ++ ++def htobe16(x): return (x) ++ ++def htole16(x): return __bswap_16 (x) ++ ++def be16toh(x): return (x) ++ ++def le16toh(x): return __bswap_16 (x) ++ ++def htobe32(x): return (x) ++ ++def htole32(x): return __bswap_32 (x) ++ ++def be32toh(x): return (x) ++ ++def le32toh(x): return __bswap_32 (x) ++ ++def htobe64(x): return (x) ++ ++def htole64(x): return __bswap_64 (x) ++ ++def be64toh(x): return (x) ++ ++def le64toh(x): return __bswap_64 (x) ++ ++def ntohl(x): return (x) ++ ++def ntohs(x): return (x) ++ ++def htonl(x): return (x) ++ ++def htons(x): return (x) ++ ++def ntohl(x): return __bswap_32 (x) ++ ++def ntohs(x): return __bswap_16 (x) ++ ++def htonl(x): return __bswap_32 (x) ++ ++def htons(x): return __bswap_16 (x) ++ ++def IN6_IS_ADDR_UNSPECIFIED(a): return \ ++ ++def IN6_IS_ADDR_LOOPBACK(a): return \ ++ ++def IN6_IS_ADDR_LINKLOCAL(a): return \ ++ ++def IN6_IS_ADDR_SITELOCAL(a): return \ ++ ++def IN6_IS_ADDR_V4MAPPED(a): return \ ++ ++def IN6_IS_ADDR_V4COMPAT(a): return \ ++ ++def IN6_IS_ADDR_MC_NODELOCAL(a): return \ ++ ++def IN6_IS_ADDR_MC_LINKLOCAL(a): return \ ++ ++def IN6_IS_ADDR_MC_SITELOCAL(a): return \ ++ ++def IN6_IS_ADDR_MC_ORGLOCAL(a): return \ ++ ++def IN6_IS_ADDR_MC_GLOBAL(a): return \ ++ +--- /dev/null ++++ b/Lib/plat-gnukfreebsd8/TYPES.py +@@ -0,0 +1,303 @@ ++# Generated by h2py from /usr/include/sys/types.h ++_SYS_TYPES_H = 1 ++ ++# Included from features.h ++_FEATURES_H = 1 ++__USE_ANSI = 1 ++__FAVOR_BSD = 1 ++_ISOC99_SOURCE = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 200809L ++_XOPEN_SOURCE = 700 ++_XOPEN_SOURCE_EXTENDED = 1 ++_LARGEFILE64_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++_ATFILE_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++__USE_ISOC99 = 1 ++__USE_ISOC95 = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 2 ++_POSIX_C_SOURCE = 199506L ++_POSIX_C_SOURCE = 200112L ++_POSIX_C_SOURCE = 200809L ++__USE_POSIX_IMPLICITLY = 1 ++__USE_POSIX = 1 ++__USE_POSIX2 = 1 ++__USE_POSIX199309 = 1 ++__USE_POSIX199506 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN2K8 = 1 ++_ATFILE_SOURCE = 1 ++__USE_XOPEN = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_UNIX98 = 1 ++_LARGEFILE_SOURCE = 1 ++__USE_XOPEN2K8 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_FILE_OFFSET64 = 1 ++__USE_MISC = 1 ++__USE_BSD = 1 ++__USE_SVID = 1 ++__USE_ATFILE = 1 ++__USE_GNU = 1 ++__USE_REENTRANT = 1 ++__USE_FORTIFY_LEVEL = 2 ++__USE_FORTIFY_LEVEL = 1 ++__USE_FORTIFY_LEVEL = 0 ++ ++# Included from bits/predefs.h ++__STDC_IEC_559__ = 1 ++__STDC_IEC_559_COMPLEX__ = 1 ++__STDC_ISO_10646__ = 200009L ++__GNU_LIBRARY__ = 6 ++__GLIBC__ = 2 ++__GLIBC_MINOR__ = 11 ++__GLIBC_HAVE_LONG_LONG = 1 ++ ++# Included from sys/cdefs.h ++_SYS_CDEFS_H = 1 ++def __NTH(fct): return fct ++ ++def __NTH(fct): return fct ++ ++def __P(args): return args ++ ++def __PMT(args): return args ++ ++def __STRING(x): return #x ++ ++def __bos(ptr): return __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) ++ ++def __bos0(ptr): return __builtin_object_size (ptr, 0) ++ ++def __warnattr(msg): return __attribute__((__warning__ (msg))) ++ ++__flexarr = [] ++__flexarr = [0] ++__flexarr = [] ++__flexarr = [1] ++def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ++ ++def __attribute__(xyz): return ++ ++def __attribute_format_arg__(x): return __attribute__ ((__format_arg__ (x))) ++ ++def __attribute_format_arg__(x): return ++ ++ ++# Included from bits/wordsize.h ++__WORDSIZE = 32 ++__LDBL_COMPAT = 1 ++def __LDBL_REDIR_DECL(name): return \ ++ ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_EXTERN_INLINES = 1 ++__USE_EXTERN_INLINES_IN_LIBC = 1 ++ ++# Included from gnu/stubs.h ++ ++# Included from bits/types.h ++_BITS_TYPES_H = 1 ++__S32_TYPE = int ++__SWORD_TYPE = int ++__SLONG32_TYPE = int ++ ++# Included from bits/typesizes.h ++_BITS_TYPESIZES_H = 1 ++__PID_T_TYPE = __S32_TYPE ++__CLOCK_T_TYPE = __S32_TYPE ++__SWBLK_T_TYPE = __S32_TYPE ++__CLOCKID_T_TYPE = __S32_TYPE ++__TIMER_T_TYPE = __S32_TYPE ++__SSIZE_T_TYPE = __SWORD_TYPE ++__FD_SETSIZE = 1024 ++ ++# Included from time.h ++_TIME_H = 1 ++ ++# Included from bits/time.h ++_BITS_TIME_H = 1 ++CLOCKS_PER_SEC = 1000000l ++CLK_TCK = 128 ++CLOCK_REALTIME = 0 ++CLOCK_PROCESS_CPUTIME_ID = 2 ++CLOCK_THREAD_CPUTIME_ID = 3 ++CLOCK_MONOTONIC = 4 ++CLOCK_VIRTUAL = 1 ++CLOCK_PROF = 2 ++CLOCK_UPTIME = 5 ++CLOCK_UPTIME_PRECISE = 7 ++CLOCK_UPTIME_FAST = 8 ++CLOCK_REALTIME_PRECISE = 9 ++CLOCK_REALTIME_FAST = 10 ++CLOCK_MONOTONIC_PRECISE = 11 ++CLOCK_MONOTONIC_FAST = 12 ++CLOCK_SECOND = 13 ++TIMER_RELTIME = 0 ++TIMER_ABSTIME = 1 ++_STRUCT_TIMEVAL = 1 ++CLK_TCK = CLOCKS_PER_SEC ++__clock_t_defined = 1 ++__time_t_defined = 1 ++__clockid_t_defined = 1 ++__timer_t_defined = 1 ++__timespec_defined = 1 ++ ++# Included from xlocale.h ++_XLOCALE_H = 1 ++def __isleap(year): return \ ++ ++__BIT_TYPES_DEFINED__ = 1 ++ ++# Included from endian.h ++_ENDIAN_H = 1 ++__LITTLE_ENDIAN = 1234 ++__BIG_ENDIAN = 4321 ++__PDP_ENDIAN = 3412 ++ ++# Included from bits/endian.h ++__BYTE_ORDER = __LITTLE_ENDIAN ++__FLOAT_WORD_ORDER = __BYTE_ORDER ++LITTLE_ENDIAN = __LITTLE_ENDIAN ++BIG_ENDIAN = __BIG_ENDIAN ++PDP_ENDIAN = __PDP_ENDIAN ++BYTE_ORDER = __BYTE_ORDER ++ ++# Included from bits/byteswap.h ++_BITS_BYTESWAP_H = 1 ++def __bswap_constant_16(x): return \ ++ ++def __bswap_16(x): return \ ++ ++def __bswap_16(x): return \ ++ ++def __bswap_constant_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_constant_64(x): return \ ++ ++def __bswap_64(x): return \ ++ ++def htobe16(x): return __bswap_16 (x) ++ ++def htole16(x): return (x) ++ ++def be16toh(x): return __bswap_16 (x) ++ ++def le16toh(x): return (x) ++ ++def htobe32(x): return __bswap_32 (x) ++ ++def htole32(x): return (x) ++ ++def be32toh(x): return __bswap_32 (x) ++ ++def le32toh(x): return (x) ++ ++def htobe64(x): return __bswap_64 (x) ++ ++def htole64(x): return (x) ++ ++def be64toh(x): return __bswap_64 (x) ++ ++def le64toh(x): return (x) ++ ++def htobe16(x): return (x) ++ ++def htole16(x): return __bswap_16 (x) ++ ++def be16toh(x): return (x) ++ ++def le16toh(x): return __bswap_16 (x) ++ ++def htobe32(x): return (x) ++ ++def htole32(x): return __bswap_32 (x) ++ ++def be32toh(x): return (x) ++ ++def le32toh(x): return __bswap_32 (x) ++ ++def htobe64(x): return (x) ++ ++def htole64(x): return __bswap_64 (x) ++ ++def be64toh(x): return (x) ++ ++def le64toh(x): return __bswap_64 (x) ++ ++ ++# Included from sys/select.h ++_SYS_SELECT_H = 1 ++ ++# Included from bits/select.h ++def __FD_ZERO(fdsp): return \ ++ ++def __FD_ZERO(set): return \ ++ ++ ++# Included from bits/sigset.h ++_SIGSET_H_types = 1 ++_SIGSET_H_fns = 1 ++def __sigword(sig): return (((sig) - 1) >> 5) ++ ++def __sigemptyset(set): return \ ++ ++def __sigfillset(set): return \ ++ ++def __sigisemptyset(set): return \ ++ ++def __FDELT(d): return ((d) / __NFDBITS) ++ ++FD_SETSIZE = __FD_SETSIZE ++def FD_ZERO(fdsetp): return __FD_ZERO (fdsetp) ++ ++ ++# Included from sys/sysmacros.h ++_SYS_SYSMACROS_H = 1 ++def minor(dev): return ((int)((dev) & (-65281))) ++ ++def gnu_dev_major(dev): return major (dev) ++ ++def gnu_dev_minor(dev): return minor (dev) ++ ++ ++# Included from bits/pthreadtypes.h ++_BITS_PTHREADTYPES_H = 1 ++ ++# Included from bits/sched.h ++SCHED_OTHER = 2 ++SCHED_FIFO = 1 ++SCHED_RR = 3 ++CSIGNAL = 0x000000ff ++CLONE_VM = 0x00000100 ++CLONE_FS = 0x00000200 ++CLONE_FILES = 0x00000400 ++CLONE_SIGHAND = 0x00000800 ++CLONE_PTRACE = 0x00002000 ++CLONE_VFORK = 0x00004000 ++CLONE_SYSVSEM = 0x00040000 ++__defined_schedparam = 1 ++__CPU_SETSIZE = 128 ++def __CPUELT(cpu): return ((cpu) / __NCPUBITS) ++ ++def __CPU_ALLOC_SIZE(count): return \ ++ ++def __CPU_ALLOC(count): return __sched_cpualloc (count) ++ ++def __CPU_FREE(cpuset): return __sched_cpufree (cpuset) ++ +--- /dev/null ++++ b/Lib/plat-gnukfreebsd8/DLFCN.py +@@ -0,0 +1,118 @@ ++# Generated by h2py from /usr/include/dlfcn.h ++_DLFCN_H = 1 ++ ++# Included from features.h ++_FEATURES_H = 1 ++__USE_ANSI = 1 ++__FAVOR_BSD = 1 ++_ISOC99_SOURCE = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 200809L ++_XOPEN_SOURCE = 700 ++_XOPEN_SOURCE_EXTENDED = 1 ++_LARGEFILE64_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++_ATFILE_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++__USE_ISOC99 = 1 ++__USE_ISOC95 = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 2 ++_POSIX_C_SOURCE = 199506L ++_POSIX_C_SOURCE = 200112L ++_POSIX_C_SOURCE = 200809L ++__USE_POSIX_IMPLICITLY = 1 ++__USE_POSIX = 1 ++__USE_POSIX2 = 1 ++__USE_POSIX199309 = 1 ++__USE_POSIX199506 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN2K8 = 1 ++_ATFILE_SOURCE = 1 ++__USE_XOPEN = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_UNIX98 = 1 ++_LARGEFILE_SOURCE = 1 ++__USE_XOPEN2K8 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_FILE_OFFSET64 = 1 ++__USE_MISC = 1 ++__USE_BSD = 1 ++__USE_SVID = 1 ++__USE_ATFILE = 1 ++__USE_GNU = 1 ++__USE_REENTRANT = 1 ++__USE_FORTIFY_LEVEL = 2 ++__USE_FORTIFY_LEVEL = 1 ++__USE_FORTIFY_LEVEL = 0 ++ ++# Included from bits/predefs.h ++__STDC_IEC_559__ = 1 ++__STDC_IEC_559_COMPLEX__ = 1 ++__STDC_ISO_10646__ = 200009L ++__GNU_LIBRARY__ = 6 ++__GLIBC__ = 2 ++__GLIBC_MINOR__ = 11 ++__GLIBC_HAVE_LONG_LONG = 1 ++ ++# Included from sys/cdefs.h ++_SYS_CDEFS_H = 1 ++def __NTH(fct): return fct ++ ++def __NTH(fct): return fct ++ ++def __P(args): return args ++ ++def __PMT(args): return args ++ ++def __STRING(x): return #x ++ ++def __bos(ptr): return __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) ++ ++def __bos0(ptr): return __builtin_object_size (ptr, 0) ++ ++def __warnattr(msg): return __attribute__((__warning__ (msg))) ++ ++__flexarr = [] ++__flexarr = [0] ++__flexarr = [] ++__flexarr = [1] ++def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ++ ++def __attribute__(xyz): return ++ ++def __attribute_format_arg__(x): return __attribute__ ((__format_arg__ (x))) ++ ++def __attribute_format_arg__(x): return ++ ++ ++# Included from bits/wordsize.h ++__WORDSIZE = 32 ++__LDBL_COMPAT = 1 ++def __LDBL_REDIR_DECL(name): return \ ++ ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_EXTERN_INLINES = 1 ++__USE_EXTERN_INLINES_IN_LIBC = 1 ++ ++# Included from gnu/stubs.h ++ ++# Included from bits/dlfcn.h ++RTLD_LAZY = 0x00001 ++RTLD_NOW = 0x00002 ++RTLD_BINDING_MASK = 0x3 ++RTLD_NOLOAD = 0x00004 ++RTLD_DEEPBIND = 0x00008 ++RTLD_GLOBAL = 0x00100 ++RTLD_LOCAL = 0 ++RTLD_NODELETE = 0x01000 ++LM_ID_BASE = 0 ++LM_ID_NEWLM = -1 --- python2.7-2.7.5.orig/debian/patches/atomic-pyc-rename.diff +++ python2.7-2.7.5/debian/patches/atomic-pyc-rename.diff @@ -0,0 +1,34 @@ +--- a/Lib/py_compile.py ++++ b/Lib/py_compile.py +@@ -120,13 +120,24 @@ + return + if cfile is None: + cfile = file + (__debug__ and 'c' or 'o') +- with open(cfile, 'wb') as fc: +- fc.write('\0\0\0\0') +- wr_long(fc, timestamp) +- marshal.dump(codeobject, fc) +- fc.flush() +- fc.seek(0, 0) +- fc.write(MAGIC) ++ # Atomically write the pyc/pyo file. Issue #13146. ++ # id() is used to generate a pseudo-random filename. ++ path_tmp = '{}.{}'.format(cfile, id(cfile)) ++ try: ++ with open(path_tmp, 'wb') as fc: ++ fc.write('\0\0\0\0') ++ wr_long(fc, timestamp) ++ marshal.dump(codeobject, fc) ++ fc.flush() ++ fc.seek(0, 0) ++ fc.write(MAGIC) ++ os.rename(path_tmp, cfile) ++ except OSError: ++ try: ++ os.unlink(path_tmp) ++ except OSError: ++ pass ++ raise + + def main(args=None): + """Compile several source files. --- python2.7-2.7.5.orig/debian/patches/deb-locations.diff +++ python2.7-2.7.5/debian/patches/deb-locations.diff @@ -0,0 +1,63 @@ +# DP: adjust locations of directories to debian policy + +--- a/Demo/tkinter/guido/ManPage.py ++++ b/Demo/tkinter/guido/ManPage.py +@@ -189,8 +189,9 @@ + def test(): + import os + import sys +- # XXX This directory may be different on your system +- MANDIR = '/usr/local/man/mann' ++ # XXX This directory may be different on your system, ++ # it is here set for Debian GNU/Linux. ++ MANDIR = '/usr/share/man' + DEFAULTPAGE = 'Tcl' + formatted = 0 + if sys.argv[1:] and sys.argv[1] == '-f': +--- a/Demo/tkinter/guido/tkman.py ++++ b/Demo/tkinter/guido/tkman.py +@@ -9,8 +9,8 @@ + from Tkinter import * + from ManPage import ManPage + +-MANNDIRLIST = ['/depot/sundry/man/mann','/usr/local/man/mann'] +-MAN3DIRLIST = ['/depot/sundry/man/man3','/usr/local/man/man3'] ++MANNDIRLIST = ['/depot/sundry/man/mann','/usr/share/man/mann'] ++MAN3DIRLIST = ['/depot/sundry/man/man3','/usr/share/man/man3'] + + foundmanndir = 0 + for dir in MANNDIRLIST: +--- a/Misc/python.man ++++ b/Misc/python.man +@@ -338,7 +338,7 @@ + These are subject to difference depending on local installation + conventions; ${prefix} and ${exec_prefix} are installation-dependent + and should be interpreted as for GNU software; they may be the same. +-The default for both is \fI/usr/local\fP. ++On Debian GNU/{Hurd,Linux} the default for both is \fI/usr\fP. + .IP \fI${exec_prefix}/bin/python\fP + Recommended location of the interpreter. + .PP +--- a/Tools/faqwiz/faqconf.py ++++ b/Tools/faqwiz/faqconf.py +@@ -21,7 +21,7 @@ + OWNEREMAIL = "nobody@anywhere.org" # Email for feedback + HOMEURL = "http://www.python.org" # Related home page + HOMENAME = "Python home" # Name of related home page +-RCSBINDIR = "/usr/local/bin/" # Directory containing RCS commands ++RCSBINDIR = "/usr/bin/" # Directory containing RCS commands + # (must end in a slash) + + # Parameters you can normally leave alone +--- a/Tools/webchecker/webchecker.py ++++ b/Tools/webchecker/webchecker.py +@@ -19,7 +19,8 @@ + a directory listing is returned. Now, you can point webchecker to the + document tree in the local file system of your HTTP daemon, and have + most of it checked. In fact the default works this way if your local +-web tree is located at /usr/local/etc/httpd/htdpcs (the default for ++web tree is located at /var/www, which is the default for Debian ++GNU/Linux. Other systems use /usr/local/etc/httpd/htdocs (the default for + the NCSA HTTP daemon and probably others). + + Report printed: --- python2.7-2.7.5.orig/debian/patches/link-whole-archive.diff +++ python2.7-2.7.5/debian/patches/link-whole-archive.diff @@ -0,0 +1,13 @@ +# DP: Link libpython with --whole-archive. + +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -443,7 +443,7 @@ + $(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY) + $(LINKCC) $(PY_LDFLAGS) $(LINKFORSHARED) -o $@ \ + Modules/python.o \ +- $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST) ++ -Wl,--whole-archive $(BLDLIBRARY) -Wl,--no-whole-archive $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST) + + platform: $(BUILDPYTHON) pybuilddir.txt + $(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform --- python2.7-2.7.5.orig/debian/patches/langpack-gettext.diff +++ python2.7-2.7.5/debian/patches/langpack-gettext.diff @@ -0,0 +1,34 @@ +# DP: Description: support alternative gettext tree in +# DP: /usr/share/locale-langpack; if a file is present in both trees, +# DP: prefer the newer one +# DP: Upstream status: Ubuntu-Specific + +--- a/Lib/gettext.py ++++ b/Lib/gettext.py +@@ -446,11 +446,26 @@ + if lang == 'C': + break + mofile = os.path.join(localedir, lang, 'LC_MESSAGES', '%s.mo' % domain) ++ mofile_lp = os.path.join("/usr/share/locale-langpack", lang, ++ 'LC_MESSAGES', '%s.mo' % domain) ++ ++ # first look into the standard locale dir, then into the ++ # langpack locale dir ++ ++ # standard mo file + if os.path.exists(mofile): + if all: + result.append(mofile) + else: + return mofile ++ ++ # langpack mofile -> use it ++ if os.path.exists(mofile_lp): ++ if all: ++ result.append(mofile_lp) ++ else: ++ return mofile_lp ++ + return result + + --- python2.7-2.7.5.orig/debian/patches/issue9012a.diff +++ python2.7-2.7.5/debian/patches/issue9012a.diff @@ -0,0 +1,13 @@ +# DP: Link _math.o only once to the static library. + +--- a/Modules/Setup.dist ++++ b/Modules/Setup.dist +@@ -169,7 +169,7 @@ + # Modules that should always be present (non UNIX dependent): + + #array arraymodule.c # array objects +-#cmath cmathmodule.c _math.c # -lm # complex math library functions ++#cmath cmathmodule.c # -lm # complex math library functions + #math mathmodule.c _math.c # -lm # math library functions, e.g. sin() + #_struct _struct.c # binary structure packing/unpacking + #time timemodule.c # -lm # time operations and variables --- python2.7-2.7.5.orig/debian/patches/link-system-expat.diff +++ python2.7-2.7.5/debian/patches/link-system-expat.diff @@ -0,0 +1,22 @@ +# DP: Link with the system expat + +--- a/Modules/Setup.dist ++++ b/Modules/Setup.dist +@@ -181,7 +181,7 @@ + #itertools itertoolsmodule.c # Functions creating iterators for efficient looping + #strop stropmodule.c # String manipulations + #_functools _functoolsmodule.c # Tools for working with functions and callable objects +-#_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator ++#_elementtree -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator + #_pickle _pickle.c # pickle accelerator + #datetime datetimemodule.c # date/time type + #_bisect _bisectmodule.c # Bisection algorithms +@@ -475,7 +475,7 @@ + # + # More information on Expat can be found at www.libexpat.org. + # +-#pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI ++#pyexpat pyexpat.c -lexpat + + + # Hye-Shik Chang's CJKCodecs --- python2.7-2.7.5.orig/debian/patches/installed-testsuite.diff +++ python2.7-2.7.5/debian/patches/installed-testsuite.diff @@ -0,0 +1,35 @@ +# DP: Changes needed to run the installed testsuite. +# DP: Also removed: +# DP: - ctypes/test/test_macholib.py +# DP: - distutils/tests/test_bdist_wininst.py + +--- a/Lib/distutils/tests/test_build_ext.py ++++ b/Lib/distutils/tests/test_build_ext.py +@@ -83,27 +83,6 @@ + self.assertTrue(isinstance(xx.Null(), xx.Null)) + self.assertTrue(isinstance(xx.Str(), xx.Str)) + +- def test_solaris_enable_shared(self): +- dist = Distribution({'name': 'xx'}) +- cmd = build_ext(dist) +- old = sys.platform +- +- sys.platform = 'sunos' # fooling finalize_options +- from distutils.sysconfig import _config_vars +- old_var = _config_vars.get('Py_ENABLE_SHARED') +- _config_vars['Py_ENABLE_SHARED'] = 1 +- try: +- cmd.ensure_finalized() +- finally: +- sys.platform = old +- if old_var is None: +- del _config_vars['Py_ENABLE_SHARED'] +- else: +- _config_vars['Py_ENABLE_SHARED'] = old_var +- +- # make sure we get some library dirs under solaris +- self.assertTrue(len(cmd.library_dirs) > 0) +- + def test_user_site(self): + # site.USER_SITE was introduced in 2.6 + if sys.version < '2.6': --- python2.7-2.7.5.orig/debian/patches/test-sundry.diff +++ python2.7-2.7.5/debian/patches/test-sundry.diff @@ -0,0 +1,17 @@ +# DP: test_sundry: Don't fail on import of the profile and pstats module + +--- a/Lib/test/test_sundry.py ++++ b/Lib/test/test_sundry.py +@@ -62,7 +62,11 @@ + import os2emxpath + import pdb + import posixfile +- import pstats ++ try: ++ import pstats # separated out into the python-profiler package ++ except ImportError: ++ if test_support.verbose: ++ print "skipping profile and pstats" + import py_compile + import rexec + import sched --- python2.7-2.7.5.orig/debian/patches/statvfs-f_flag-constants.diff +++ python2.7-2.7.5/debian/patches/statvfs-f_flag-constants.diff @@ -0,0 +1,57 @@ +From 21fda4c78000d78cb1824fdf0373031d07f5325a Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Wed, 6 Jan 2010 15:22:38 -0500 +Subject: [PATCH] Add flags for statvfs.f_flag to constant list. + +You really need these to figure out what statvfs is trying to say to +you, so add them here. +--- + Modules/posixmodule.c | 37 +++++++++++++++++++++++++++++++++++++ + 1 files changed, 37 insertions(+), 0 deletions(-) + +--- a/Modules/posixmodule.c ++++ b/Modules/posixmodule.c +@@ -9296,6 +9296,43 @@ + if (ins(d, "EX_NOTFOUND", (long)EX_NOTFOUND)) return -1; + #endif /* EX_NOTFOUND */ + ++ /* These came from statvfs.h */ ++#ifdef ST_RDONLY ++ if (ins(d, "ST_RDONLY", (long)ST_RDONLY)) return -1; ++#endif /* ST_RDONLY */ ++#ifdef ST_NOSUID ++ if (ins(d, "ST_NOSUID", (long)ST_NOSUID)) return -1; ++#endif /* ST_NOSUID */ ++ ++ /* GNU extensions */ ++#ifdef ST_NODEV ++ if (ins(d, "ST_NODEV", (long)ST_NODEV)) return -1; ++#endif /* ST_NODEV */ ++#ifdef ST_NOEXEC ++ if (ins(d, "ST_NOEXEC", (long)ST_NOEXEC)) return -1; ++#endif /* ST_NOEXEC */ ++#ifdef ST_SYNCHRONOUS ++ if (ins(d, "ST_SYNCHRONOUS", (long)ST_SYNCHRONOUS)) return -1; ++#endif /* ST_SYNCHRONOUS */ ++#ifdef ST_MANDLOCK ++ if (ins(d, "ST_MANDLOCK", (long)ST_MANDLOCK)) return -1; ++#endif /* ST_MANDLOCK */ ++#ifdef ST_WRITE ++ if (ins(d, "ST_WRITE", (long)ST_WRITE)) return -1; ++#endif /* ST_WRITE */ ++#ifdef ST_APPEND ++ if (ins(d, "ST_APPEND", (long)ST_APPEND)) return -1; ++#endif /* ST_APPEND */ ++#ifdef ST_NOATIME ++ if (ins(d, "ST_NOATIME", (long)ST_NOATIME)) return -1; ++#endif /* ST_NOATIME */ ++#ifdef ST_NODIRATIME ++ if (ins(d, "ST_NODIRATIME", (long)ST_NODIRATIME)) return -1; ++#endif /* ST_NODIRATIME */ ++#ifdef ST_RELATIME ++ if (ins(d, "ST_RELATIME", (long)ST_RELATIME)) return -1; ++#endif /* ST_RELATIME */ ++ + #ifdef HAVE_SPAWNV + #if defined(PYOS_OS2) && defined(PYCC_GCC) + if (ins(d, "P_WAIT", (long)P_WAIT)) return -1; --- python2.7-2.7.5.orig/debian/patches/site-locations.diff +++ python2.7-2.7.5/debian/patches/site-locations.diff @@ -0,0 +1,32 @@ +# DP: Set site-packages/dist-packages + +--- a/Lib/site.py ++++ b/Lib/site.py +@@ -19,6 +19,12 @@ + resulting directories, if they exist, are appended to sys.path, and + also inspected for path configuration files. + ++For Debian and derivatives, this sys.path is augmented with directories ++for packages distributed within the distribution. Local addons go ++into /usr/local/lib/python/dist-packages, Debian addons ++install into /usr/{lib,share}/python/dist-packages. ++/usr/lib/python/site-packages is not used. ++ + A path configuration file is a file whose name has the form + .pth; its contents are additional directories (one per line) + to be added to sys.path. Non-existing directories (or +@@ -288,10 +294,12 @@ + if sys.platform in ('os2emx', 'riscos'): + sitepackages.append(os.path.join(prefix, "Lib", "site-packages")) + elif os.sep == '/': ++ sitepackages.append(os.path.join(prefix, "local/lib", ++ "python" + sys.version[:3], ++ "dist-packages")) + sitepackages.append(os.path.join(prefix, "lib", + "python" + sys.version[:3], +- "site-packages")) +- sitepackages.append(os.path.join(prefix, "lib", "site-python")) ++ "dist-packages")) + else: + sitepackages.append(prefix) + sitepackages.append(os.path.join(prefix, "lib", "site-packages")) --- python2.7-2.7.5.orig/debian/patches/no-large-file-support.diff +++ python2.7-2.7.5/debian/patches/no-large-file-support.diff @@ -0,0 +1,14 @@ +# DP: disable large file support for GNU/Hurd + +--- a/configure.ac ++++ b/configure.ac +@@ -1434,6 +1434,9 @@ + use_lfs=no + fi + ++# Don't use largefile support anyway. ++use_lfs=no ++ + if test "$use_lfs" = "yes"; then + # Two defines needed to enable largefile support on various platforms + # These may affect some typedefs --- python2.7-2.7.5.orig/debian/patches/ctypes-arm.diff +++ python2.7-2.7.5/debian/patches/ctypes-arm.diff @@ -0,0 +1,32 @@ +--- a/Lib/ctypes/util.py ++++ b/Lib/ctypes/util.py +@@ -213,16 +213,27 @@ + + def _findSoname_ldconfig(name): + import struct ++ # XXX this code assumes that we know all unames and that a single ++ # ABI is supported per uname; instead we should find what the ++ # ABI is (e.g. check ABI of current process) or simply ask libc ++ # to load the library for us ++ uname = os.uname()[4] ++ # ARM has a variety of unames, e.g. armv7l ++ if uname.startswith("arm"): ++ uname = "arm" + if struct.calcsize('l') == 4: +- machine = os.uname()[4] + '-32' ++ machine = uname + '-32' + else: +- machine = os.uname()[4] + '-64' ++ machine = uname + '-64' + mach_map = { + 'x86_64-64': 'libc6,x86-64', + 'ppc64-64': 'libc6,64bit', + 'sparc64-64': 'libc6,64bit', + 's390x-64': 'libc6,64bit', + 'ia64-64': 'libc6,IA-64', ++ # this actually breaks on biarch or multiarch as the first ++ # library wins; uname doesn't tell us which ABI we're using ++ 'arm-32': 'libc6(,hard-float)?', + } + abi_type = mach_map.get(machine, 'libc6') + --- python2.7-2.7.5.orig/debian/patches/platform-lsbrelease.diff +++ python2.7-2.7.5/debian/patches/platform-lsbrelease.diff @@ -0,0 +1,50 @@ +# DP: Use /etc/lsb-release to identify the platform. + +--- a/Lib/platform.py ++++ b/Lib/platform.py +@@ -259,7 +259,7 @@ + _supported_dists = ( + 'SuSE', 'debian', 'fedora', 'redhat', 'centos', + 'mandrake', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo', +- 'UnitedLinux', 'turbolinux') ++ 'UnitedLinux', 'turbolinux', 'Ubuntu') + + def _parse_release_file(firstline): + +@@ -288,6 +288,10 @@ + id = l[1] + return '', version, id + ++_distributor_id_file_re = re.compile("(?:DISTRIB_ID\s*=)\s*(.*)", re.I) ++_release_file_re = re.compile("(?:DISTRIB_RELEASE\s*=)\s*(.*)", re.I) ++_codename_file_re = re.compile("(?:DISTRIB_CODENAME\s*=)\s*(.*)", re.I) ++ + def linux_distribution(distname='', version='', id='', + + supported_dists=_supported_dists, +@@ -312,6 +316,25 @@ + args given as parameters. + + """ ++ # check for the LSB /etc/lsb-release file first, needed so ++ # that the distribution doesn't get identified as Debian. ++ try: ++ with open("/etc/lsb-release", "rU") as etclsbrel: ++ for line in etclsbrel: ++ m = _distributor_id_file_re.search(line) ++ if m: ++ _u_distname = m.group(1).strip() ++ m = _release_file_re.search(line) ++ if m: ++ _u_version = m.group(1).strip() ++ m = _codename_file_re.search(line) ++ if m: ++ _u_id = m.group(1).strip() ++ if _u_distname and _u_version: ++ return (_u_distname, _u_version, _u_id) ++ except (EnvironmentError, UnboundLocalError): ++ pass ++ + try: + etc = os.listdir('/etc') + except os.error: --- python2.7-2.7.5.orig/debian/patches/hotshot-import.diff +++ python2.7-2.7.5/debian/patches/hotshot-import.diff @@ -0,0 +1,17 @@ +# DP: hotshot: Check for the availability of the profile and pstats modules. + +--- a/Lib/hotshot/stats.py ++++ b/Lib/hotshot/stats.py +@@ -1,7 +1,10 @@ + """Statistics analyzer for HotShot.""" + +-import profile +-import pstats ++try: ++ import profile ++ import pstats ++except ImportError, e: ++ raise ImportError, str(e) + '; please install the python-profiler package' + + import hotshot.log + --- python2.7-2.7.5.orig/debian/patches/linecache.diff +++ python2.7-2.7.5/debian/patches/linecache.diff @@ -0,0 +1,16 @@ +# DP: Proper handling of packages in linecache.py + +--- a/Lib/linecache.py ++++ b/Lib/linecache.py +@@ -108,6 +108,11 @@ + if os.path.isabs(filename): + return [] + ++ # Take care to handle packages ++ if basename == '__init__.py': ++ # filename referes to a package ++ basename = filename ++ + for dirname in sys.path: + # When using imputil, sys.path may contain things other than + # strings; ignore them when it happens. --- python2.7-2.7.5.orig/debian/patches/disable-utimes.diff +++ python2.7-2.7.5/debian/patches/disable-utimes.diff @@ -0,0 +1,13 @@ +# DP: disable check for utimes function, which is broken in glibc-2.3.2 + +--- a/configure.ac ++++ b/configure.ac +@@ -2698,7 +2698,7 @@ + setsid setpgid setpgrp setuid setvbuf snprintf \ + sigaction siginterrupt sigrelse strftime \ + sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ +- truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty) ++ truncate uname unsetenv waitpid wait3 wait4 wcscoll _getpty) + + # For some functions, having a definition is not sufficient, since + # we want to take their address. --- python2.7-2.7.5.orig/debian/patches/add-python-config-sh.diff +++ python2.7-2.7.5/debian/patches/add-python-config-sh.diff @@ -0,0 +1,174 @@ +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -1059,6 +1059,8 @@ + # Substitution happens here, as the completely-expanded BINDIR + # is not available in configure + sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config ++ # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR} ++ sed -e "s,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g" < Misc/python-config.sh >python-config.sh + + # Install the include files + INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY) +@@ -1118,6 +1120,7 @@ + $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh + $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config + rm python-config ++ $(INSTALL_SCRIPT) python-config.sh $(DESTDIR)$(BINDIR)/python-config.sh + @if [ -s Modules/python.exp -a \ + "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \ + echo; echo "Installing support files for building shared extension modules on AIX:"; \ +--- a/Misc/python-config.in ++++ b/Misc/python-config.in +@@ -55,3 +55,11 @@ + libs.extend(getvar('LINKFORSHARED').split()) + print ' '.join(libs) + ++ elif opt == '--extension-suffix': ++ print sysconfig.get_config_var('SO') ++ ++ elif opt == '--abiflags': ++ print '' ++ ++ elif opt == '--configdir': ++ print sysconfig.get_config_var('LIBPL') +--- /dev/null ++++ b/Misc/python-config.sh.in +@@ -0,0 +1,103 @@ ++#!/bin/sh ++ ++exit_with_usage () ++{ ++ echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--configdir" ++ exit $1 ++} ++ ++if [ "$1" = "" ] ; then ++ exit_with_usage 1 ++fi ++ ++# Returns the actual prefix where this script was installed to. ++installed_prefix () ++{ ++ local RESULT=$(dirname $(cd $(dirname "$1") && pwd -P)) ++ if [ $(which readlink) ] ; then ++ RESULT=$(readlink -f "$RESULT") ++ fi ++ echo $RESULT ++} ++ ++prefix_build="@prefix@" ++prefix_real=$(installed_prefix "$0") ++ ++# Use sed to fix paths from their built to locations to their installed to locations. ++prefix=$(echo "$prefix_build" | sed "s#$prefix_build#$prefix_real#") ++exec_prefix_build="@exec_prefix@" ++exec_prefix=$(echo "$exec_prefix_build" | sed "s#$exec_prefix_build#$prefix_real#") ++includedir=$(echo "@includedir@" | sed "s#$prefix_build#$prefix_real#") ++libdir=$(echo "@libdir@" | sed "s#$prefix_build#$prefix_real#") ++CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix_build#$prefix_real#") ++VERSION="@VERSION@" ++LIBM="@LIBM@" ++LIBC="@LIBC@" ++SYSLIBS="$LIBM $LIBC" ++ABIFLAGS="@DEBUG_EXT@" ++MULTIARCH="@MULTIARCH@" ++LIBS="@LIBS@ $SYSLIBS -lpython${VERSION}${ABIFLAGS}" ++BASECFLAGS="@BASECFLAGS@" ++LDLIBRARY="@LDLIBRARY@" ++LINKFORSHARED="@LINKFORSHARED@" ++OPT="@OPT@" ++PY_ENABLE_SHARED="@PY_ENABLE_SHARED@" ++LIBDEST=${prefix}/lib/python${VERSION} ++LIBPL=${LIBDEST}/config-${MULTIARCH}${ABIFLAGS} ++SO="${ABIFLAGS}.so" ++PYTHONFRAMEWORK="@PYTHONFRAMEWORK@" ++INCDIR="-I$includedir/python${VERSION}${ABIFLAGS}" ++PLATINCDIR="-I$includedir/$MULTIARCH/python${VERSION}${ABIFLAGS}" ++ ++# Scan for --help or unknown argument. ++for ARG in $* ++do ++ case $ARG in ++ --help) ++ exit_with_usage 0 ++ ;; ++ --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--configdir) ++ ;; ++ *) ++ exit_with_usage 1 ++ ;; ++ esac ++done ++ ++for ARG in $* ++do ++ case $ARG in ++ --prefix) ++ echo "$prefix" ++ ;; ++ --exec-prefix) ++ echo "$exec_prefix" ++ ;; ++ --includes) ++ echo "$INCDIR" "$PLATINCDIR" ++ ;; ++ --cflags) ++ echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT" ++ ;; ++ --libs) ++ echo "$LIBS" ++ ;; ++ --ldflags) ++ LINKFORSHAREDUSED= ++ if [ -z "$PYTHONFRAMEWORK" ] ; then ++ LINKFORSHAREDUSED=$LINKFORSHARED ++ fi ++ LIBPLUSED= ++ if [ "$PY_ENABLE_SHARED" = "0" ] ; then ++ LIBPLUSED="-L$LIBPL" ++ fi ++ echo "$LIBPLUSED -L$libdir $LIBS $LINKFORSHAREDUSED" ++ ;; ++ --extension-suffix) ++ echo "$SO" ++ ;; ++ --configdir) ++ echo "$LIBPL" ++ ;; ++esac ++done +--- a/configure.ac ++++ b/configure.ac +@@ -870,6 +870,7 @@ + + # Other platforms follow + if test $enable_shared = "yes"; then ++ PY_ENABLE_SHARED=1 + AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.]) + case $ac_sys_system in + BeOS*) +@@ -930,6 +931,7 @@ + + esac + else # shared is disabled ++ PY_ENABLE_SHARED=0 + case $ac_sys_system in + CYGWIN*) + BLDLIBRARY='$(LIBRARY)' +@@ -937,6 +939,7 @@ + ;; + esac + fi ++AC_SUBST(PY_ENABLE_SHARED) + + if test "$cross_compiling" = yes; then + RUNSHARED= +@@ -4524,7 +4527,7 @@ + AC_MSG_RESULT(done) + + # generate output files +-AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc) ++AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-config.sh) + AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix]) + AC_OUTPUT + --- python2.7-2.7.5.orig/debian/patches/series.in +++ python2.7-2.7.5/debian/patches/series.in @@ -0,0 +1,68 @@ +hg-updates.diff +issue9189.diff +build-libpython.diff +deb-setup.diff +deb-locations.diff +site-locations.diff +distutils-install-layout.diff +locale-module.diff +distutils-link.diff +distutils-sysconfig.diff +test-sundry.diff +tkinter-import.diff +link-opt.diff +debug-build.diff +hotshot-import.diff +linecache.diff +doc-nodownload.diff +profiled-build.diff +no-zip-on-sys.path.diff +platform-lsbrelease.diff +bdist-wininst-notfound.diff +setup-modules-ssl.diff +makesetup-bashism.diff +hurd-disable-nonworking-constants.diff +#ifdef WITH_FPECTL +enable-fpectl.diff +#endif +statvfs-f_flag-constants.diff +#if defined (arch_alpha) +plat-linux2_alpha.diff +#elif defined (arch_hppa) +plat-linux2_hppa.diff +#elif defined (arch_mips) || defined(arch_mipsel) +plat-linux2_mips.diff +#elif defined (arch_sparc) || defined (arch_sparc64) +plat-linux2_sparc.diff +#endif +#if defined (BROKEN_UTIMES) +disable-utimes.diff +#endif +#if defined (Ubuntu) +langpack-gettext.diff +#endif +#if defined (arch_os_hurd) +no-large-file-support.diff +cthreads.diff +#endif +issue9012a.diff +link-system-expat.diff +plat-gnukfreebsd.diff +link-whole-archive.diff +bsddb-libpath.diff +disable-sem-check.diff +ncursesw-incdir.diff +ctypes-arm.diff +lto-link-flags.diff +sqlite-rpath.diff +do-not-italicize-punctuation.patch +multiarch.diff +lib2to3-no-pickled-grammar.diff +add-python-config-sh.diff +ssl.match_hostname.diff +ext-no-libpython-link.diff +build-hash.diff +installed-testsuite.diff +libffi-shared.diff +atomic-pyc-rename.diff +CVE-2014-1912.diff --- python2.7-2.7.5.orig/debian/patches/build-hash.diff +++ python2.7-2.7.5/debian/patches/build-hash.diff @@ -0,0 +1,22 @@ +# DP: Always build the _md5, _sha1, _sha256 and _sha512 extension modules. + +--- a/setup.py ++++ b/setup.py +@@ -850,7 +850,7 @@ + print ("warning: openssl 0x%08x is too old for _hashlib" % + openssl_ver) + missing.append('_hashlib') +- if COMPILED_WITH_PYDEBUG or not have_usable_openssl: ++ if True or COMPILED_WITH_PYDEBUG or not have_usable_openssl: + # The _sha module implements the SHA1 hash algorithm. + exts.append( Extension('_sha', ['shamodule.c']) ) + # The _md5 module implements the RSA Data Security, Inc. MD5 +@@ -861,7 +861,7 @@ + depends = ['md5.h']) ) + + min_sha2_openssl_ver = 0x00908000 +- if COMPILED_WITH_PYDEBUG or openssl_ver < min_sha2_openssl_ver: ++ if True or COMPILED_WITH_PYDEBUG or openssl_ver < min_sha2_openssl_ver: + # OpenSSL doesn't do these until 0.9.8 so we'll bring our own hash + exts.append( Extension('_sha256', ['sha256module.c']) ) + exts.append( Extension('_sha512', ['sha512module.c']) ) --- python2.7-2.7.5.orig/debian/patches/bsddb-libpath.diff +++ python2.7-2.7.5/debian/patches/bsddb-libpath.diff @@ -0,0 +1,19 @@ +# DP: Don't add the bsddb multilib path, if already in the standard lib path + +--- a/setup.py ++++ b/setup.py +@@ -1066,7 +1066,13 @@ + if db_setup_debug: + print "bsddb using BerkeleyDB lib:", db_ver, dblib + print "bsddb lib dir:", dblib_dir, " inc dir:", db_incdir +- db_incs = [db_incdir] ++ # only add db_incdir/dblib_dir if not in the standard paths ++ if db_incdir in inc_dirs: ++ db_incs = [] ++ else: ++ db_incs = [db_incdir] ++ if dblib_dir[0] in lib_dirs: ++ dblib_dir = [] + dblibs = [dblib] + # We add the runtime_library_dirs argument because the + # BerkeleyDB lib we're linking against often isn't in the --- python2.7-2.7.5.orig/debian/patches/build-libpython.diff +++ python2.7-2.7.5/debian/patches/build-libpython.diff @@ -0,0 +1,22 @@ +# DP: Don't include object files twice in libpython. + +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -400,7 +400,7 @@ + $(PYTHON_OBJS) \ + $(MODULE_OBJS) \ + $(SIGNAL_OBJS) \ +- $(MODOBJS) ++ $(sort $(MODOBJS)) + + ######################################################################### + # Rules +@@ -473,7 +473,7 @@ + $(AR) $(ARFLAGS) $@ $(OBJECT_OBJS) + $(AR) $(ARFLAGS) $@ $(PYTHON_OBJS) + $(AR) $(ARFLAGS) $@ $(MODULE_OBJS) $(SIGNAL_OBJS) +- $(AR) $(ARFLAGS) $@ $(MODOBJS) ++ $(AR) $(ARFLAGS) $@ $(sort $(MODOBJS)) + $(RANLIB) $@ + + libpython$(VERSION).so: $(LIBRARY_OBJS) --- python2.7-2.7.5.orig/debian/patches/issue9189.diff +++ python2.7-2.7.5/debian/patches/issue9189.diff @@ -0,0 +1,332 @@ +--- a/Lib/sysconfig.py ++++ b/Lib/sysconfig.py +@@ -231,11 +231,19 @@ + done[n] = v + + # do variable interpolation here +- while notdone: +- for name in notdone.keys(): ++ variables = list(notdone.keys()) ++ ++ # Variables with a 'PY_' prefix in the makefile. These need to ++ # be made available without that prefix through sysconfig. ++ # Special care is needed to ensure that variable expansion works, even ++ # if the expansion uses the name without a prefix. ++ renamed_variables = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS') ++ ++ while len(variables) > 0: ++ for name in tuple(variables): + value = notdone[name] + m = _findvar1_rx.search(value) or _findvar2_rx.search(value) +- if m: ++ if m is not None: + n = m.group(1) + found = True + if n in done: +@@ -246,23 +254,48 @@ + elif n in os.environ: + # do it like make: fall back to environment + item = os.environ[n] ++ ++ elif n in renamed_variables: ++ if name.startswith('PY_') and name[3:] in renamed_variables: ++ item = "" ++ ++ elif 'PY_' + n in notdone: ++ found = False ++ ++ else: ++ item = str(done['PY_' + n]) ++ + else: + done[n] = item = "" ++ + if found: + after = value[m.end():] + value = value[:m.start()] + item + after + if "$" in after: + notdone[name] = value + else: +- try: value = int(value) ++ try: ++ value = int(value) + except ValueError: + done[name] = value.strip() + else: + done[name] = value +- del notdone[name] ++ variables.remove(name) ++ ++ if name.startswith('PY_') \ ++ and name[3:] in renamed_variables: ++ ++ name = name[3:] ++ if name not in done: ++ done[name] = value ++ ++ + else: +- # bogus variable reference; just drop it since we can't deal +- del notdone[name] ++ # bogus variable reference (e.g. "prefix=$/opt/python"); ++ # just drop it since we can't deal ++ done[name] = value ++ variables.remove(name) ++ + # strip spurious spaces + for k, v in done.items(): + if isinstance(v, str): +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -68,12 +68,18 @@ + # Compiler options + OPT= @OPT@ + BASECFLAGS= @BASECFLAGS@ +-CFLAGS= $(BASECFLAGS) @CFLAGS@ $(OPT) $(EXTRA_CFLAGS) ++CONFIGURE_CFLAGS= @CFLAGS@ ++CONFIGURE_CPPFLAGS= @CPPFLAGS@ ++CONFIGURE_LDFLAGS= @LDFLAGS@ ++# Avoid assigning CFLAGS, LDFLAGS, etc. so users can use them on the ++# command line to append to these values without stomping the pre-set ++# values. ++PY_CFLAGS= $(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) + # Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to + # be able to build extension modules using the directories specified in the + # environment variables +-CPPFLAGS= -I. -IInclude -I$(srcdir)/Include @CPPFLAGS@ +-LDFLAGS= @LDFLAGS@ ++PY_CPPFLAGS= -I. -IInclude -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS) ++PY_LDFLAGS= $(CONFIGURE_LDFLAGS) $(LDFLAGS) + LDLAST= @LDLAST@ + SGI_ABI= @SGI_ABI@ + CCSHARED= @CCSHARED@ +@@ -82,7 +88,7 @@ + # Extra C flags added for building the interpreter object files. + CFLAGSFORSHARED=@CFLAGSFORSHARED@ + # C flags used for building the interpreter object files +-PY_CFLAGS= $(CFLAGS) $(CPPFLAGS) $(CFLAGSFORSHARED) -DPy_BUILD_CORE ++PY_CORE_CFLAGS= $(PY_CFLAGS) $(PY_CPPFLAGS) $(CFLAGSFORSHARED) -DPy_BUILD_CORE + + + # Machine-dependent subdirectories +@@ -433,7 +439,7 @@ + + # Build the interpreter + $(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY) +- $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \ ++ $(LINKCC) $(PY_LDFLAGS) $(LINKFORSHARED) -o $@ \ + Modules/python.o \ + $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST) + +@@ -455,7 +461,7 @@ + *\ -s*|s*) quiet="-q";; \ + *) quiet="";; \ + esac; \ +- $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ ++ $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' LDFLAGS='$(PY_LDFLAGS)' OPT='$(OPT)' \ + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build + + # Build static library +@@ -472,18 +478,18 @@ + + libpython$(VERSION).so: $(LIBRARY_OBJS) + if test $(INSTSONAME) != $(LDLIBRARY); then \ +- $(BLDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \ ++ $(BLDSHARED) $(PY_LDFLAGS) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \ + $(LN) -f $(INSTSONAME) $@; \ + else \ +- $(BLDSHARED) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \ ++ $(BLDSHARED) $(PY_LDFLAGS) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \ + fi + + libpython$(VERSION).dylib: $(LIBRARY_OBJS) +- $(CC) -dynamiclib -Wl,-single_module $(LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(VERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \ ++ $(CC) -dynamiclib -Wl,-single_module $(PY_LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(VERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \ + + + libpython$(VERSION).sl: $(LIBRARY_OBJS) +- $(LDSHARED) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST) ++ $(LDSHARED) $(PY_LDFLAGS) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST) + + # Copy up the gdb python hooks into a position where they can be automatically + # loaded by gdb during Lib/test/test_gdb.py +@@ -522,7 +528,7 @@ + # for a shared core library; otherwise, this rule is a noop. + $(DLLLIBRARY) libpython$(VERSION).dll.a: $(LIBRARY_OBJS) + if test -n "$(DLLLIBRARY)"; then \ +- $(LDSHARED) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \ ++ $(LDSHARED) $(PY_LDFLAGS) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \ + $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST); \ + else true; \ + fi +@@ -566,7 +572,7 @@ + $(SIGNAL_OBJS) \ + $(MODOBJS) \ + $(srcdir)/Modules/getbuildinfo.c +- $(CC) -c $(PY_CFLAGS) \ ++ $(CC) -c $(PY_CORE_CFLAGS) \ + -DSVNVERSION="\"`LC_ALL=C $(SVNVERSION)`\"" \ + -DHGVERSION="\"`LC_ALL=C $(HGVERSION)`\"" \ + -DHGTAG="\"`LC_ALL=C $(HGTAG)`\"" \ +@@ -574,7 +580,7 @@ + -o $@ $(srcdir)/Modules/getbuildinfo.c + + Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile +- $(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \ ++ $(CC) -c $(PY_CORE_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \ + -DPREFIX='"$(prefix)"' \ + -DEXEC_PREFIX='"$(exec_prefix)"' \ + -DVERSION='"$(VERSION)"' \ +@@ -582,7 +588,7 @@ + -o $@ $(srcdir)/Modules/getpath.c + + Modules/python.o: $(srcdir)/Modules/python.c +- $(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c ++ $(MAINCC) -c $(PY_CORE_CFLAGS) -o $@ $(srcdir)/Modules/python.c + + Modules/posixmodule.o: $(srcdir)/Modules/posixmodule.c $(srcdir)/Modules/posixmodule.h + +@@ -599,7 +605,7 @@ + touch $(GRAMMAR_C) + + $(PGEN): $(PGENOBJS) +- $(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN) ++ $(CC) $(OPT) $(PY_LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN) + + Parser/grammar.o: $(srcdir)/Parser/grammar.c \ + $(srcdir)/Include/token.h \ +@@ -621,10 +627,10 @@ + Python/compile.o Python/symtable.o Python/ast.o: $(GRAMMAR_H) $(AST_H) + + Python/getplatform.o: $(srcdir)/Python/getplatform.c +- $(CC) -c $(PY_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c ++ $(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c + + Python/importdl.o: $(srcdir)/Python/importdl.c +- $(CC) -c $(PY_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c ++ $(CC) -c $(PY_CORE_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c + + Objects/unicodectype.o: $(srcdir)/Objects/unicodectype.c \ + $(srcdir)/Objects/unicodetype_db.h +@@ -1225,7 +1231,7 @@ + + # Some make's put the object file in the current directory + .c.o: +- $(CC) -c $(PY_CFLAGS) -o $@ $< ++ $(CC) -c $(PY_CORE_CFLAGS) -o $@ $< + + # Run reindent on the library + reindent: +--- a/Modules/makesetup ++++ b/Modules/makesetup +@@ -219,7 +219,7 @@ + case $doconfig in + no) cc="$cc \$(CCSHARED) \$(CFLAGS) \$(CPPFLAGS)";; + *) +- cc="$cc \$(PY_CFLAGS)";; ++ cc="$cc \$(PY_CORE_CFLAGS)";; + esac + rule="$obj: $src; $cc $cpps -c $src -o $obj" + echo "$rule" >>$rulesf +--- a/configure.ac ++++ b/configure.ac +@@ -607,14 +607,13 @@ + fi + fi + +-# If the user set CFLAGS, use this instead of the automatically +-# determined setting +-preset_cflags="$CFLAGS" +-AC_PROG_CC +-if test ! -z "$preset_cflags" +-then +- CFLAGS=$preset_cflags ++# Don't let AC_PROG_CC set the default CFLAGS. It normally sets -g -O2 ++# when the compiler supports them, but we don't always want -O2, and ++# we set -g later. ++if test -z "$CFLAGS"; then ++ CFLAGS= + fi ++AC_PROG_CC + + AC_SUBST(CXX) + AC_SUBST(MAINCC) +--- a/Lib/distutils/sysconfig.py ++++ b/Lib/distutils/sysconfig.py +@@ -319,11 +319,19 @@ + done[n] = v + + # do variable interpolation here +- while notdone: +- for name in notdone.keys(): ++ variables = list(notdone.keys()) ++ ++ # Variables with a 'PY_' prefix in the makefile. These need to ++ # be made available without that prefix through sysconfig. ++ # Special care is needed to ensure that variable expansion works, even ++ # if the expansion uses the name without a prefix. ++ renamed_variables = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS') ++ ++ while len(variables) > 0: ++ for name in tuple(variables): + value = notdone[name] + m = _findvar1_rx.search(value) or _findvar2_rx.search(value) +- if m: ++ if m is not None: + n = m.group(1) + found = True + if n in done: +@@ -334,25 +342,47 @@ + elif n in os.environ: + # do it like make: fall back to environment + item = os.environ[n] ++ ++ elif n in renamed_variables: ++ if name.startswith('PY_') and name[3:] in renamed_variables: ++ item = "" ++ ++ elif 'PY_' + n in notdone: ++ found = False ++ ++ else: ++ item = str(done['PY_' + n]) ++ + else: + done[n] = item = "" ++ + if found: + after = value[m.end():] + value = value[:m.start()] + item + after + if "$" in after: + notdone[name] = value + else: +- try: value = int(value) ++ try: ++ value = int(value) + except ValueError: + done[name] = value.strip() + else: + done[name] = value +- del notdone[name] +- else: +- # bogus variable reference; just drop it since we can't deal +- del notdone[name] ++ variables.remove(name) ++ ++ if name.startswith('PY_') \ ++ and name[3:] in renamed_variables: + +- fp.close() ++ name = name[3:] ++ if name not in done: ++ done[name] = value ++ ++ ++ else: ++ # bogus variable reference (e.g. "prefix=$/opt/python"); ++ # just drop it since we can't deal ++ done[name] = value ++ variables.remove(name) + + # strip spurious spaces + for k, v in done.items(): --- python2.7-2.7.5.orig/debian/patches/doc-nodownload.diff +++ python2.7-2.7.5/debian/patches/doc-nodownload.diff @@ -0,0 +1,13 @@ +# DP: Don't try to download documentation tools + +--- a/Doc/Makefile ++++ b/Doc/Makefile +@@ -57,7 +57,7 @@ + + update: clean checkout + +-build: checkout ++build: + mkdir -p build/$(BUILDER) build/doctrees + $(PYTHON) tools/sphinx-build.py $(ALLSPHINXOPTS) + @echo --- python2.7-2.7.5.orig/debian/patches/cthreads.diff +++ python2.7-2.7.5/debian/patches/cthreads.diff @@ -0,0 +1,39 @@ +# DP: Remove cthreads detection + +--- a/configure.ac ++++ b/configure.ac +@@ -2154,7 +2154,6 @@ + + # Templates for things AC_DEFINEd more than once. + # For a single AC_DEFINE, no template is needed. +-AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package]) + AH_TEMPLATE(_REENTRANT, + [Define to force use of thread-safe errno, h_errno, and other functions]) + AH_TEMPLATE(WITH_THREAD, +@@ -2236,17 +2235,6 @@ + AC_MSG_RESULT($unistd_defines_pthreads) + + AC_DEFINE(_REENTRANT) +- AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD) +- AC_DEFINE(C_THREADS) +- AC_DEFINE(HURD_C_THREADS, 1, +- [Define if you are using Mach cthreads directly under /include]) +- LIBS="$LIBS -lthreads" +- THREADOBJ="Python/thread.o"],[ +- AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD) +- AC_DEFINE(C_THREADS) +- AC_DEFINE(MACH_C_THREADS, 1, +- [Define if you are using Mach cthreads under mach /]) +- THREADOBJ="Python/thread.o"],[ + AC_MSG_CHECKING(for --with-pth) + AC_ARG_WITH([pth], + AS_HELP_STRING([--with-pth], [use GNU pth threading libraries]), +@@ -2301,7 +2289,7 @@ + LIBS="$LIBS -lcma" + THREADOBJ="Python/thread.o"],[ + USE_THREAD_MODULE="#"]) +- ])])])])])])])])])]) ++ ])])])])])])])]) + + AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD) + LIBS="$LIBS -lmpc" --- python2.7-2.7.5.orig/debian/patches/distutils-link.diff +++ python2.7-2.7.5/debian/patches/distutils-link.diff @@ -0,0 +1,18 @@ +# DP: Don't add standard library dirs to library_dirs and runtime_library_dirs. + +--- a/Lib/distutils/unixccompiler.py ++++ b/Lib/distutils/unixccompiler.py +@@ -155,7 +155,12 @@ + objects, output_dir = self._fix_object_args(objects, output_dir) + libraries, library_dirs, runtime_library_dirs = \ + self._fix_lib_args(libraries, library_dirs, runtime_library_dirs) +- ++ # filter out standard library paths, which are not explicitely needed ++ # for linking ++ library_dirs = [dir for dir in library_dirs ++ if not dir in ('/lib', '/lib64', '/usr/lib', '/usr/lib64')] ++ runtime_library_dirs = [dir for dir in runtime_library_dirs ++ if not dir in ('/lib', '/lib64', '/usr/lib', '/usr/lib64')] + lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs, + libraries) + if type(output_dir) not in (StringType, NoneType): --- python2.7-2.7.5.orig/debian/patches/sys-multiarch.diff +++ python2.7-2.7.5/debian/patches/sys-multiarch.diff @@ -0,0 +1,25 @@ +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -1357,6 +1357,11 @@ + + Python/thread.o: @THREADHEADERS@ + ++Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile ++ $(CC) -c $(PY_CORE_CFLAGS) \ ++ -DMULTIARCH='"$(MULTIARCH)"' \ ++ -o $@ $(srcdir)/Python/sysmodule.c ++ + # Declare targets that aren't real files + .PHONY: all build_all sharedmods oldsharedmods test quicktest memtest + .PHONY: install altinstall oldsharedinstall bininstall altbininstall +--- a/Python/sysmodule.c ++++ b/Python/sysmodule.c +@@ -1435,6 +1435,8 @@ + PyFloat_GetInfo()); + SET_SYS_FROM_STRING("long_info", + PyLong_GetInfo()); ++ SET_SYS_FROM_STRING("_multiarch", ++ PyString_FromString(MULTIARCH)); + #ifdef Py_USING_UNICODE + SET_SYS_FROM_STRING("maxunicode", + PyInt_FromLong(PyUnicode_GetMax())); --- python2.7-2.7.5.orig/debian/patches/libre.diff +++ python2.7-2.7.5/debian/patches/libre.diff @@ -0,0 +1,9 @@ +--- Doc/lib/libre.tex~ 2003-07-25 09:29:22.000000000 +0200 ++++ Doc/lib/libre.tex 2003-07-25 09:30:58.000000000 +0200 +@@ -919,5 +919,5 @@ + Starting with Python 2.3, simple uses of the \regexp{*?} pattern are + special-cased to avoid recursion. Thus, the above regular expression + can avoid recursion by being recast as +-\regexp{Begin [a-zA-Z0-9_ ]*?end}. As a further benefit, such regular ++`Begin [a-zA-Z0-9_ ]*?end'. As a further benefit, such regular + expressions will run faster than their recursive equivalents. --- python2.7-2.7.5.orig/debian/patches/do-not-italicize-punctuation.patch +++ python2.7-2.7.5/debian/patches/do-not-italicize-punctuation.patch @@ -0,0 +1,49 @@ +--- a/Misc/python.man ++++ b/Misc/python.man +@@ -290,9 +290,9 @@ + from that file; + when called with + .B \-c +-.I command, ++.IR command , + it executes the Python statement(s) given as +-.I command. ++.IR command . + Here + .I command + may contain multiple statements separated by newlines. +@@ -302,7 +302,7 @@ + .PP + If available, the script name and additional arguments thereafter are + passed to the script in the Python variable +-.I sys.argv , ++.IR sys.argv , + which is a list of strings (you must first + .I import sys + to be able to access it). +@@ -316,14 +316,14 @@ + .I '-c'. + Note that options interpreted by the Python interpreter itself + are not placed in +-.I sys.argv. ++.IR sys.argv . + .PP + In interactive mode, the primary prompt is `>>>'; the second prompt + (which appears when a command is not complete) is `...'. + The prompts can be changed by assignment to + .I sys.ps1 + or +-.I sys.ps2. ++.IR sys.ps2 . + The interpreter quits when it reads an EOF at a prompt. + When an unhandled exception occurs, a stack trace is printed and + control returns to the primary prompt; in non-interactive mode, the +@@ -382,7 +382,7 @@ + inserted in the path in front of $PYTHONPATH. + The search path can be manipulated from within a Python program as the + variable +-.I sys.path . ++.IR sys.path . + .IP PYTHONSTARTUP + If this is the name of a readable file, the Python commands in that + file are executed before the first prompt is displayed in interactive --- python2.7-2.7.5.orig/debian/patches/CVE-2014-1912.diff +++ python2.7-2.7.5/debian/patches/CVE-2014-1912.diff @@ -0,0 +1,44 @@ + +# HG changeset patch +# User Benjamin Peterson +# Date 1389671978 18000 +# Node ID 87673659d8f7ba1623cd4914f09ad3d2ade034e9 +# Parent 2631d33ee7fbd5f0288931ef37872218d511d2e8 +complain when nbytes > buflen to fix possible buffer overflow (closes #20246) + +Index: python2.7-2.7.5/Lib/test/test_socket.py +=================================================================== +--- python2.7-2.7.5.orig/Lib/test/test_socket.py 2014-02-27 09:06:15.849305662 -0500 ++++ python2.7-2.7.5/Lib/test/test_socket.py 2014-02-27 09:06:15.813305661 -0500 +@@ -1616,6 +1616,16 @@ + + _testRecvFromIntoMemoryview = _testRecvFromIntoArray + ++ def testRecvFromIntoSmallBuffer(self): ++ # See issue #20246. ++ buf = bytearray(8) ++ self.assertRaises(ValueError, self.cli_conn.recvfrom_into, buf, 1024) ++ ++ def _testRecvFromIntoSmallBuffer(self): ++ with test_support.check_py3k_warnings(): ++ buf = buffer(MSG*2048) ++ self.serv_conn.send(buf) ++ + + TIPC_STYPE = 2000 + TIPC_LOWER = 200 +Index: python2.7-2.7.5/Modules/socketmodule.c +=================================================================== +--- python2.7-2.7.5.orig/Modules/socketmodule.c 2014-02-27 09:06:15.849305662 -0500 ++++ python2.7-2.7.5/Modules/socketmodule.c 2014-02-27 09:06:15.813305661 -0500 +@@ -2742,6 +2742,10 @@ + if (recvlen == 0) { + /* If nbytes was not specified, use the buffer's length */ + recvlen = buflen; ++ } else if (recvlen > buflen) { ++ PyErr_SetString(PyExc_ValueError, ++ "nbytes is greater than the length of the buffer"); ++ goto error; + } + + readlen = sock_recvfrom_guts(s, buf.buf, recvlen, flags, &addr); --- python2.7-2.7.5.orig/debian/patches/makesetup-bashism.diff +++ python2.7-2.7.5/debian/patches/makesetup-bashism.diff @@ -0,0 +1,13 @@ +# DP: Fix bashism in makesetup shell script + +--- a/Modules/makesetup ++++ b/Modules/makesetup +@@ -281,7 +281,7 @@ + -) ;; + *) sedf="@sed.in.$$" + trap 'rm -f $sedf' 0 1 2 3 +- echo "1i\\" >$sedf ++ printf "1i\\" >$sedf + str="# Generated automatically from $makepre by makesetup." + echo "$str" >>$sedf + echo "s%_MODOBJS_%$OBJS%" >>$sedf --- python2.7-2.7.5.orig/debian/patches/profiled-build.diff +++ python2.7-2.7.5/debian/patches/profiled-build.diff @@ -0,0 +1,28 @@ +# DP: Fix profiled build; don't use Python/thread.gc*, gcc complains + +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -424,19 +424,19 @@ + $(MAKE) build_all_use_profile + + build_all_generate_profile: +- $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-generate" LIBS="$(LIBS) -lgcov" ++ $(MAKE) all PY_CFLAGS="$(PY_CFLAGS) -fprofile-generate" LIBS="$(LIBS) -lgcov" + + run_profile_task: + : # FIXME: can't run for a cross build +- ./$(BUILDPYTHON) $(PROFILE_TASK) ++ -./$(BUILDPYTHON) $(PROFILE_TASK) + + build_all_use_profile: +- $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-use" ++ $(MAKE) all PY_CFLAGS="$(PY_CFLAGS) -fprofile-use -fprofile-correction" + + coverage: + @echo "Building with support for coverage checking:" + $(MAKE) clean +- $(MAKE) all CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov" ++ $(MAKE) all PY_CFLAGS="$(PY_CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov" + + + # Build the interpreter --- python2.7-2.7.5.orig/debian/patches/deb-setup.diff +++ python2.7-2.7.5/debian/patches/deb-setup.diff @@ -0,0 +1,19 @@ +# DP: Don't include /usr/local/include and /usr/local/lib as gcc search paths + +--- a/setup.py ++++ b/setup.py +@@ -436,10 +436,10 @@ + os.unlink(tmpfile) + + def detect_modules(self): +- # Ensure that /usr/local is always used +- if not cross_compiling: +- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') +- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') ++ # On Debian /usr/local is always used, so we don't include it twice ++ #if not cross_compiling: ++ # add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') ++ # add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') + if cross_compiling: + self.add_gcc_paths() + self.add_multiarch_paths() --- python2.7-2.7.5.orig/debian/patches/plat-linux2_mips.diff +++ python2.7-2.7.5/debian/patches/plat-linux2_mips.diff @@ -0,0 +1,88 @@ +Index: Lib/plat-linux2/DLFCN.py +=================================================================== +--- ./Lib/plat-linux2/DLFCN.py (Revision 77754) ++++ ./Lib/plat-linux2/DLFCN.py (Arbeitskopie) +@@ -77,7 +77,7 @@ + RTLD_LAZY = 0x00001 + RTLD_NOW = 0x00002 + RTLD_BINDING_MASK = 0x3 +-RTLD_NOLOAD = 0x00004 +-RTLD_GLOBAL = 0x00100 ++RTLD_NOLOAD = 0x00008 ++RTLD_GLOBAL = 0x00004 + RTLD_LOCAL = 0 + RTLD_NODELETE = 0x01000 +Index: Lib/plat-linux2/IN.py +=================================================================== +--- ./Lib/plat-linux2/IN.py (Revision 77754) ++++ ./Lib/plat-linux2/IN.py (Arbeitskopie) +@@ -436,33 +436,33 @@ + # Included from asm/socket.h + + # Included from asm/sockios.h +-FIOSETOWN = 0x8901 +-SIOCSPGRP = 0x8902 +-FIOGETOWN = 0x8903 +-SIOCGPGRP = 0x8904 +-SIOCATMARK = 0x8905 ++FIOSETOWN = 0x8004667c ++SIOCSPGRP = 0x80047308 ++FIOGETOWN = 0x4004667b ++SIOCGPGRP = 0x40047309 ++SIOCATMARK = 0x40047307 + SIOCGSTAMP = 0x8906 +-SOL_SOCKET = 1 +-SO_DEBUG = 1 +-SO_REUSEADDR = 2 +-SO_TYPE = 3 +-SO_ERROR = 4 +-SO_DONTROUTE = 5 +-SO_BROADCAST = 6 +-SO_SNDBUF = 7 +-SO_RCVBUF = 8 +-SO_KEEPALIVE = 9 +-SO_OOBINLINE = 10 ++SOL_SOCKET = 0xffff ++SO_DEBUG = 0x0001 ++SO_REUSEADDR = 0x0004 ++SO_TYPE = 0x1008 ++SO_ERROR = 0x1007 ++SO_DONTROUTE = 0x0010 ++SO_BROADCAST = 0x0020 ++SO_SNDBUF = 0x1001 ++SO_RCVBUF = 0x1002 ++SO_KEEPALIVE = 0x0008 ++SO_OOBINLINE = 0x0100 + SO_NO_CHECK = 11 + SO_PRIORITY = 12 +-SO_LINGER = 13 ++SO_LINGER = 0x0080 + SO_BSDCOMPAT = 14 +-SO_PASSCRED = 16 +-SO_PEERCRED = 17 +-SO_RCVLOWAT = 18 +-SO_SNDLOWAT = 19 +-SO_RCVTIMEO = 20 +-SO_SNDTIMEO = 21 ++SO_PASSCRED = 17 ++SO_PEERCRED = 18 ++SO_RCVLOWAT = 0x1004 ++SO_SNDLOWAT = 0x1003 ++SO_RCVTIMEO = 0x1006 ++SO_SNDTIMEO = 0x1005 + SO_SECURITY_AUTHENTICATION = 22 + SO_SECURITY_ENCRYPTION_TRANSPORT = 23 + SO_SECURITY_ENCRYPTION_NETWORK = 24 +@@ -472,9 +472,9 @@ + SO_PEERNAME = 28 + SO_TIMESTAMP = 29 + SCM_TIMESTAMP = SO_TIMESTAMP +-SO_ACCEPTCONN = 30 +-SOCK_STREAM = 1 +-SOCK_DGRAM = 2 ++SO_ACCEPTCONN = 0x1009 ++SOCK_STREAM = 2 ++SOCK_DGRAM = 1 + SOCK_RAW = 3 + SOCK_RDM = 4 + SOCK_SEQPACKET = 5 --- python2.7-2.7.5.orig/debian/patches/debug-build.diff +++ python2.7-2.7.5/debian/patches/debug-build.diff @@ -0,0 +1,228 @@ +# DP: Change the interpreter to build and install python extensions +# DP: built with the python-dbg interpreter with a different name into +# DP: the same path (by appending `_d' to the extension name). + +--- a/Lib/distutils/command/build.py ++++ b/Lib/distutils/command/build.py +@@ -91,7 +91,8 @@ + # 'lib.' under the base build directory. We only use one of + # them for a given distribution, though -- + if self.build_purelib is None: +- self.build_purelib = os.path.join(self.build_base, 'lib') ++ self.build_purelib = os.path.join(self.build_base, ++ 'lib' + plat_specifier) + if self.build_platlib is None: + self.build_platlib = os.path.join(self.build_base, + 'lib' + plat_specifier) +--- a/Lib/distutils/sysconfig.py ++++ b/Lib/distutils/sysconfig.py +@@ -90,7 +90,7 @@ + # Include is located in the srcdir + inc_dir = os.path.join(srcdir, "Include") + return inc_dir +- return os.path.join(prefix, "include", "python" + get_python_version()) ++ return os.path.join(prefix, "include", "python" + get_python_version())+(sys.pydebug and "_d" or "") + elif os.name == "nt": + return os.path.join(prefix, "include") + elif os.name == "os2": +@@ -251,7 +251,7 @@ + if python_build: + return os.path.join(project_base, "Makefile") + lib_dir = get_python_lib(plat_specific=1, standard_lib=1) +- return os.path.join(lib_dir, "config", "Makefile") ++ return os.path.join(lib_dir, "config"+(sys.pydebug and "_d" or ""), "Makefile") + + + def parse_config_h(fp, g=None): +--- a/Lib/sysconfig.py ++++ b/Lib/sysconfig.py +@@ -332,7 +332,7 @@ + def _get_makefile_filename(): + if _PYTHON_BUILD: + return os.path.join(_PROJECT_BASE, "Makefile") +- return os.path.join(get_path('platstdlib').replace("/usr/local","/usr",1), "config", "Makefile") ++ return os.path.join(get_path('platstdlib').replace("/usr/local","/usr",1), "config" + (sys.pydebug and "_d" or ""), "Makefile") + + def _generate_posix_vars(): + """Generate the Python module containing build-time variables.""" +@@ -461,7 +461,7 @@ + else: + inc_dir = _PROJECT_BASE + else: +- inc_dir = get_path('platinclude').replace("/usr/local","/usr",1) ++ inc_dir = get_path('platinclude').replace("/usr/local","/usr",1)+(sys.pydebug and "_d" or "") + return os.path.join(inc_dir, 'pyconfig.h') + + def get_scheme_names(): +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -117,8 +117,8 @@ + # Detailed destination directories + BINLIBDEST= $(LIBDIR)/python$(VERSION) + LIBDEST= $(SCRIPTDIR)/python$(VERSION) +-INCLUDEPY= $(INCLUDEDIR)/python$(VERSION) +-CONFINCLUDEPY= $(CONFINCLUDEDIR)/python$(VERSION) ++INCLUDEPY= $(INCLUDEDIR)/python$(VERSION)$(DEBUG_EXT) ++CONFINCLUDEPY= $(CONFINCLUDEDIR)/python$(VERSION)$(DEBUG_EXT) + LIBP= $(LIBDIR)/python$(VERSION) + + # Symbols used for using shared libraries +@@ -132,6 +132,8 @@ + EXE= @EXEEXT@ + BUILDEXE= @BUILDEXEEXT@ + ++DEBUG_EXT= @DEBUG_EXT@ ++ + # Short name and location for Mac OS X Python framework + UNIVERSALSDK=@UNIVERSALSDK@ + PYTHONFRAMEWORK= @PYTHONFRAMEWORK@ +@@ -476,7 +478,7 @@ + $(AR) $(ARFLAGS) $@ $(sort $(MODOBJS)) + $(RANLIB) $@ + +-libpython$(VERSION).so: $(LIBRARY_OBJS) ++libpython$(VERSION)$(DEBUG_EXT).so: $(LIBRARY_OBJS) + if test $(INSTSONAME) != $(LDLIBRARY); then \ + $(BLDSHARED) $(PY_LDFLAGS) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \ + $(LN) -f $(INSTSONAME) $@; \ +@@ -1070,8 +1072,8 @@ + $(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h + + # Install the library and miscellaneous stuff needed for extending/embedding +-# This goes into $(exec_prefix) +-LIBPL= $(LIBP)/config ++# This goes into $(exec_prefix)$(DEBUG_EXT) ++LIBPL= $(LIBP)/config$(DEBUG_EXT) + + # pkgconfig directory + LIBPC= $(LIBDIR)/pkgconfig +--- a/Misc/python-config.in ++++ b/Misc/python-config.in +@@ -45,7 +45,7 @@ + + elif opt in ('--libs', '--ldflags'): + libs = getvar('LIBS').split() + getvar('SYSLIBS').split() +- libs.append('-lpython'+pyver) ++ libs.append('-lpython' + pyver + (sys.pydebug and "_d" or "")) + # add the prefix/lib/pythonX.Y/config dir, but only if there is no + # shared library in prefix/lib/. + if opt == '--ldflags': +--- a/Python/dynload_shlib.c ++++ b/Python/dynload_shlib.c +@@ -46,6 +46,10 @@ + {"module.exe", "rb", C_EXTENSION}, + {"MODULE.EXE", "rb", C_EXTENSION}, + #else ++#ifdef Py_DEBUG ++ {"_d.so", "rb", C_EXTENSION}, ++ {"module_d.so", "rb", C_EXTENSION}, ++#endif + {".so", "rb", C_EXTENSION}, + {"module.so", "rb", C_EXTENSION}, + #endif +--- a/Python/sysmodule.c ++++ b/Python/sysmodule.c +@@ -1506,6 +1506,12 @@ + PyString_FromString("legacy")); + #endif + ++#ifdef Py_DEBUG ++ PyDict_SetItemString(sysdict, "pydebug", Py_True); ++#else ++ PyDict_SetItemString(sysdict, "pydebug", Py_False); ++#endif ++ + #undef SET_SYS_FROM_STRING + if (PyErr_Occurred()) + return NULL; +--- a/configure.ac ++++ b/configure.ac +@@ -737,7 +737,7 @@ + AC_MSG_CHECKING(LIBRARY) + if test -z "$LIBRARY" + then +- LIBRARY='libpython$(VERSION).a' ++ LIBRARY='libpython$(VERSION)$(DEBUG_EXT).a' + fi + AC_MSG_RESULT($LIBRARY) + +@@ -883,8 +883,8 @@ + INSTSONAME="$LDLIBRARY".$SOVERSION + ;; + Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*) +- LDLIBRARY='libpython$(VERSION).so' +- BLDLIBRARY='-L. -lpython$(VERSION)' ++ LDLIBRARY='libpython$(VERSION)$(DEBUG_EXT).so' ++ BLDLIBRARY='-L. -lpython$(VERSION)$(DEBUG_EXT)' + RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} + case $ac_sys_system in + FreeBSD*) +@@ -1027,6 +1027,12 @@ + fi], + [AC_MSG_RESULT(no)]) + ++if test "$Py_DEBUG" = 'true' ++then ++ DEBUG_EXT=_d ++fi ++AC_SUBST(DEBUG_EXT) ++ + # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be + # merged with this chunk of code? + +@@ -1917,7 +1923,7 @@ + esac + ;; + CYGWIN*) SO=.dll;; +- *) SO=.so;; ++ *) SO=$DEBUG_EXT.so;; + esac + else + # this might also be a termcap variable, see #610332 +--- a/Lib/distutils/tests/test_build_ext.py ++++ b/Lib/distutils/tests/test_build_ext.py +@@ -289,8 +289,8 @@ + finally: + os.chdir(old_wd) + self.assertTrue(os.path.exists(so_file)) +- self.assertEqual(os.path.splitext(so_file)[-1], +- sysconfig.get_config_var('SO')) ++ so_ext = sysconfig.get_config_var('SO') ++ self.assertEqual(so_file[len(so_file)-len(so_ext):], so_ext) + so_dir = os.path.dirname(so_file) + self.assertEqual(so_dir, other_tmp_dir) + cmd.compiler = None +@@ -298,8 +298,7 @@ + cmd.run() + so_file = cmd.get_outputs()[0] + self.assertTrue(os.path.exists(so_file)) +- self.assertEqual(os.path.splitext(so_file)[-1], +- sysconfig.get_config_var('SO')) ++ self.assertEqual(so_file[len(so_file)-len(so_ext):], so_ext) + so_dir = os.path.dirname(so_file) + self.assertEqual(so_dir, cmd.build_lib) + +--- a/Lib/distutils/tests/test_build.py ++++ b/Lib/distutils/tests/test_build.py +@@ -20,10 +20,6 @@ + # if not specified, plat_name gets the current platform + self.assertEqual(cmd.plat_name, get_platform()) + +- # build_purelib is build + lib +- wanted = os.path.join(cmd.build_base, 'lib') +- self.assertEqual(cmd.build_purelib, wanted) +- + # build_platlib is 'build/lib.platform-x.x[-pydebug]' + # examples: + # build/lib.macosx-10.3-i386-2.7 +@@ -34,6 +30,10 @@ + wanted = os.path.join(cmd.build_base, 'lib' + plat_spec) + self.assertEqual(cmd.build_platlib, wanted) + ++ # build_purelib is build + lib ++ wanted = os.path.join(cmd.build_base, 'lib' + plat_spec) ++ self.assertEqual(cmd.build_purelib, wanted) ++ + # by default, build_lib = build_purelib + self.assertEqual(cmd.build_lib, cmd.build_purelib) + --- python2.7-2.7.5.orig/debian/patches/hg-updates.diff +++ python2.7-2.7.5/debian/patches/hg-updates.diff @@ -0,0 +1,15459 @@ +# DP: hg updates of the 2.7 release branch (until 2013-09-17). + +# hg diff -r v2.7.5 | filterdiff --exclude=.*ignore --exclude=.hg* --remove-timestamps + +diff -r ab05e7dd2788 Demo/newmetaclasses/Eiffel.py +--- a/Demo/newmetaclasses/Eiffel.py ++++ b/Demo/newmetaclasses/Eiffel.py +@@ -29,7 +29,7 @@ + pre = dict.get("%s_pre" % m) + post = dict.get("%s_post" % m) + if pre or post: +- dict[k] = cls.make_eiffel_method(dict[m], pre, post) ++ dict[m] = cls.make_eiffel_method(dict[m], pre, post) + + class EiffelMetaClass1(EiffelBaseMetaClass): + # an implementation of the "eiffel" meta class that uses nested functions +diff -r ab05e7dd2788 Doc/c-api/allocation.rst +--- a/Doc/c-api/allocation.rst ++++ b/Doc/c-api/allocation.rst +@@ -43,7 +43,7 @@ + Allocate a new Python object using the C structure type *TYPE* and the + Python type object *type*. Fields not defined by the Python object header + are not initialized; the object's reference count will be one. The size of +- the memory allocation is determined from the :attr:`tp_basicsize` field of ++ the memory allocation is determined from the :c:member:`~PyTypeObject.tp_basicsize` field of + the type object. + + +@@ -52,7 +52,7 @@ + Allocate a new Python object using the C structure type *TYPE* and the + Python type object *type*. Fields not defined by the Python object header + are not initialized. The allocated memory allows for the *TYPE* structure +- plus *size* fields of the size given by the :attr:`tp_itemsize` field of ++ plus *size* fields of the size given by the :c:member:`~PyTypeObject.tp_itemsize` field of + *type*. This is useful for implementing objects like tuples, which are + able to determine their size at construction time. Embedding the array of + fields into the same allocation decreases the number of allocations, +@@ -67,7 +67,7 @@ + + Releases memory allocated to an object using :c:func:`PyObject_New` or + :c:func:`PyObject_NewVar`. This is normally called from the +- :attr:`tp_dealloc` handler specified in the object's type. The fields of ++ :c:member:`~PyTypeObject.tp_dealloc` handler specified in the object's type. The fields of + the object should not be accessed after this call as the memory is no + longer a valid Python object. + +diff -r ab05e7dd2788 Doc/c-api/gcsupport.rst +--- a/Doc/c-api/gcsupport.rst ++++ b/Doc/c-api/gcsupport.rst +@@ -15,10 +15,10 @@ + .. An example showing the use of these interfaces can be found in "Supporting the + .. Cycle Collector (XXX not found: ../ext/example-cycle-support.html)". + +-To create a container type, the :attr:`tp_flags` field of the type object must ++To create a container type, the :c:member:`~PyTypeObject.tp_flags` field of the type object must + include the :const:`Py_TPFLAGS_HAVE_GC` and provide an implementation of the +-:attr:`tp_traverse` handler. If instances of the type are mutable, a +-:attr:`tp_clear` implementation must also be provided. ++:c:member:`~PyTypeObject.tp_traverse` handler. If instances of the type are mutable, a ++:c:member:`~PyTypeObject.tp_clear` implementation must also be provided. + + + .. data:: Py_TPFLAGS_HAVE_GC +@@ -68,7 +68,7 @@ + Adds the object *op* to the set of container objects tracked by the + collector. The collector can run at unexpected times so objects must be + valid while being tracked. This should be called once all the fields +- followed by the :attr:`tp_traverse` handler become valid, usually near the ++ followed by the :c:member:`~PyTypeObject.tp_traverse` handler become valid, usually near the + end of the constructor. + + +@@ -97,8 +97,8 @@ + Remove the object *op* from the set of container objects tracked by the + collector. Note that :c:func:`PyObject_GC_Track` can be called again on + this object to add it back to the set of tracked objects. The deallocator +- (:attr:`tp_dealloc` handler) should call this for the object before any of +- the fields used by the :attr:`tp_traverse` handler become invalid. ++ (:c:member:`~PyTypeObject.tp_dealloc` handler) should call this for the object before any of ++ the fields used by the :c:member:`~PyTypeObject.tp_traverse` handler become invalid. + + + .. c:function:: void _PyObject_GC_UNTRACK(PyObject *op) +@@ -106,19 +106,19 @@ + A macro version of :c:func:`PyObject_GC_UnTrack`. It should not be used for + extension modules. + +-The :attr:`tp_traverse` handler accepts a function parameter of this type: ++The :c:member:`~PyTypeObject.tp_traverse` handler accepts a function parameter of this type: + + + .. c:type:: int (*visitproc)(PyObject *object, void *arg) + +- Type of the visitor function passed to the :attr:`tp_traverse` handler. ++ Type of the visitor function passed to the :c:member:`~PyTypeObject.tp_traverse` handler. + The function should be called with an object to traverse as *object* and +- the third parameter to the :attr:`tp_traverse` handler as *arg*. The ++ the third parameter to the :c:member:`~PyTypeObject.tp_traverse` handler as *arg*. The + Python core uses several visitor functions to implement cyclic garbage + detection; it's not expected that users will need to write their own + visitor functions. + +-The :attr:`tp_traverse` handler must have the following type: ++The :c:member:`~PyTypeObject.tp_traverse` handler must have the following type: + + + .. c:type:: int (*traverseproc)(PyObject *self, visitproc visit, void *arg) +@@ -130,15 +130,15 @@ + object argument. If *visit* returns a non-zero value that value should be + returned immediately. + +-To simplify writing :attr:`tp_traverse` handlers, a :c:func:`Py_VISIT` macro is +-provided. In order to use this macro, the :attr:`tp_traverse` implementation ++To simplify writing :c:member:`~PyTypeObject.tp_traverse` handlers, a :c:func:`Py_VISIT` macro is ++provided. In order to use this macro, the :c:member:`~PyTypeObject.tp_traverse` implementation + must name its arguments exactly *visit* and *arg*: + + + .. c:function:: void Py_VISIT(PyObject *o) + + Call the *visit* callback, with arguments *o* and *arg*. If *visit* returns +- a non-zero value, then return it. Using this macro, :attr:`tp_traverse` ++ a non-zero value, then return it. Using this macro, :c:member:`~PyTypeObject.tp_traverse` + handlers look like:: + + static int +@@ -151,7 +151,7 @@ + + .. versionadded:: 2.4 + +-The :attr:`tp_clear` handler must be of the :c:type:`inquiry` type, or *NULL* ++The :c:member:`~PyTypeObject.tp_clear` handler must be of the :c:type:`inquiry` type, or *NULL* + if the object is immutable. + + +diff -r ab05e7dd2788 Doc/c-api/structures.rst +--- a/Doc/c-api/structures.rst ++++ b/Doc/c-api/structures.rst +@@ -293,6 +293,6 @@ + .. c:function:: PyObject* Py_FindMethod(PyMethodDef table[], PyObject *ob, char *name) + + Return a bound method object for an extension type implemented in C. This +- can be useful in the implementation of a :attr:`tp_getattro` or +- :attr:`tp_getattr` handler that does not use the ++ can be useful in the implementation of a :c:member:`~PyTypeObject.tp_getattro` or ++ :c:member:`~PyTypeObject.tp_getattr` handler that does not use the + :c:func:`PyObject_GenericGetAttr` function. +diff -r ab05e7dd2788 Doc/c-api/typeobj.rst +--- a/Doc/c-api/typeobj.rst ++++ b/Doc/c-api/typeobj.rst +@@ -35,7 +35,7 @@ + The type object structure extends the :c:type:`PyVarObject` structure. The + :attr:`ob_size` field is used for dynamic types (created by :func:`type_new`, + usually called from a class statement). Note that :c:data:`PyType_Type` (the +-metatype) initializes :attr:`tp_itemsize`, which means that its instances (i.e. ++metatype) initializes :c:member:`~PyTypeObject.tp_itemsize`, which means that its instances (i.e. + type objects) *must* have the :attr:`ob_size` field. + + +@@ -108,7 +108,7 @@ + should be just the type name. If the module is a submodule of a package, the + full package name is part of the full module name. For example, a type named + :class:`T` defined in module :mod:`M` in subpackage :mod:`Q` in package :mod:`P` +- should have the :attr:`tp_name` initializer ``"P.Q.M.T"``. ++ should have the :c:member:`~PyTypeObject.tp_name` initializer ``"P.Q.M.T"``. + + For dynamically allocated type objects, this should just be the type name, and + the module name explicitly stored in the type dict as the value for key +@@ -119,7 +119,7 @@ + attribute, and everything after the last dot is made accessible as the + :attr:`__name__` attribute. + +- If no dot is present, the entire :attr:`tp_name` field is made accessible as the ++ If no dot is present, the entire :c:member:`~PyTypeObject.tp_name` field is made accessible as the + :attr:`__name__` attribute, and the :attr:`__module__` attribute is undefined + (unless explicitly set in the dictionary, as explained above). This means your + type will be impossible to pickle. +@@ -133,13 +133,13 @@ + These fields allow calculating the size in bytes of instances of the type. + + There are two kinds of types: types with fixed-length instances have a zero +- :attr:`tp_itemsize` field, types with variable-length instances have a non-zero +- :attr:`tp_itemsize` field. For a type with fixed-length instances, all +- instances have the same size, given in :attr:`tp_basicsize`. ++ :c:member:`~PyTypeObject.tp_itemsize` field, types with variable-length instances have a non-zero ++ :c:member:`~PyTypeObject.tp_itemsize` field. For a type with fixed-length instances, all ++ instances have the same size, given in :c:member:`~PyTypeObject.tp_basicsize`. + + For a type with variable-length instances, the instances must have an +- :attr:`ob_size` field, and the instance size is :attr:`tp_basicsize` plus N +- times :attr:`tp_itemsize`, where N is the "length" of the object. The value of ++ :attr:`ob_size` field, and the instance size is :c:member:`~PyTypeObject.tp_basicsize` plus N ++ times :c:member:`~PyTypeObject.tp_itemsize`, where N is the "length" of the object. The value of + N is typically stored in the instance's :attr:`ob_size` field. There are + exceptions: for example, long ints use a negative :attr:`ob_size` to indicate a + negative number, and N is ``abs(ob_size)`` there. Also, the presence of an +@@ -152,21 +152,21 @@ + :c:macro:`PyObject_HEAD` or :c:macro:`PyObject_VAR_HEAD` (whichever is used to + declare the instance struct) and this in turn includes the :attr:`_ob_prev` and + :attr:`_ob_next` fields if they are present. This means that the only correct +- way to get an initializer for the :attr:`tp_basicsize` is to use the ++ way to get an initializer for the :c:member:`~PyTypeObject.tp_basicsize` is to use the + ``sizeof`` operator on the struct used to declare the instance layout. + The basic size does not include the GC header size (this is new in Python 2.2; +- in 2.1 and 2.0, the GC header size was included in :attr:`tp_basicsize`). ++ in 2.1 and 2.0, the GC header size was included in :c:member:`~PyTypeObject.tp_basicsize`). + + These fields are inherited separately by subtypes. If the base type has a +- non-zero :attr:`tp_itemsize`, it is generally not safe to set +- :attr:`tp_itemsize` to a different non-zero value in a subtype (though this ++ non-zero :c:member:`~PyTypeObject.tp_itemsize`, it is generally not safe to set ++ :c:member:`~PyTypeObject.tp_itemsize` to a different non-zero value in a subtype (though this + depends on the implementation of the base type). + + A note about alignment: if the variable items require a particular alignment, +- this should be taken care of by the value of :attr:`tp_basicsize`. Example: +- suppose a type implements an array of ``double``. :attr:`tp_itemsize` is ++ this should be taken care of by the value of :c:member:`~PyTypeObject.tp_basicsize`. Example: ++ suppose a type implements an array of ``double``. :c:member:`~PyTypeObject.tp_itemsize` is + ``sizeof(double)``. It is the programmer's responsibility that +- :attr:`tp_basicsize` is a multiple of ``sizeof(double)`` (assuming this is the ++ :c:member:`~PyTypeObject.tp_basicsize` is a multiple of ``sizeof(double)`` (assuming this is the + alignment requirement for ``double``). + + +@@ -182,10 +182,10 @@ + destructor function should free all references which the instance owns, free all + memory buffers owned by the instance (using the freeing function corresponding + to the allocation function used to allocate the buffer), and finally (as its +- last action) call the type's :attr:`tp_free` function. If the type is not ++ last action) call the type's :c:member:`~PyTypeObject.tp_free` function. If the type is not + subtypable (doesn't have the :const:`Py_TPFLAGS_BASETYPE` flag bit set), it is + permissible to call the object deallocator directly instead of via +- :attr:`tp_free`. The object deallocator should be the one used to allocate the ++ :c:member:`~PyTypeObject.tp_free`. The object deallocator should be the one used to allocate the + instance; this is normally :c:func:`PyObject_Del` if the instance was allocated + using :c:func:`PyObject_New` or :c:func:`PyObject_VarNew`, or + :c:func:`PyObject_GC_Del` if the instance was allocated using +@@ -199,26 +199,26 @@ + An optional pointer to the instance print function. + + The print function is only called when the instance is printed to a *real* file; +- when it is printed to a pseudo-file (like a :class:`StringIO` instance), the +- instance's :attr:`tp_repr` or :attr:`tp_str` function is called to convert it to +- a string. These are also called when the type's :attr:`tp_print` field is +- *NULL*. A type should never implement :attr:`tp_print` in a way that produces +- different output than :attr:`tp_repr` or :attr:`tp_str` would. ++ when it is printed to a pseudo-file (like a :class:`~StringIO.StringIO` instance), the ++ instance's :c:member:`~PyTypeObject.tp_repr` or :c:member:`~PyTypeObject.tp_str` function is called to convert it to ++ a string. These are also called when the type's :c:member:`~PyTypeObject.tp_print` field is ++ *NULL*. A type should never implement :c:member:`~PyTypeObject.tp_print` in a way that produces ++ different output than :c:member:`~PyTypeObject.tp_repr` or :c:member:`~PyTypeObject.tp_str` would. + + The print function is called with the same signature as :c:func:`PyObject_Print`: + ``int tp_print(PyObject *self, FILE *file, int flags)``. The *self* argument is + the instance to be printed. The *file* argument is the stdio file to which it + is to be printed. The *flags* argument is composed of flag bits. The only flag + bit currently defined is :const:`Py_PRINT_RAW`. When the :const:`Py_PRINT_RAW` +- flag bit is set, the instance should be printed the same way as :attr:`tp_str` ++ flag bit is set, the instance should be printed the same way as :c:member:`~PyTypeObject.tp_str` + would format it; when the :const:`Py_PRINT_RAW` flag bit is clear, the instance +- should be printed the same was as :attr:`tp_repr` would format it. It should ++ should be printed the same was as :c:member:`~PyTypeObject.tp_repr` would format it. It should + return ``-1`` and set an exception condition when an error occurred during the + comparison. + +- It is possible that the :attr:`tp_print` field will be deprecated. In any case, +- it is recommended not to define :attr:`tp_print`, but instead to rely on +- :attr:`tp_repr` and :attr:`tp_str` for printing. ++ It is possible that the :c:member:`~PyTypeObject.tp_print` field will be deprecated. In any case, ++ it is recommended not to define :c:member:`~PyTypeObject.tp_print`, but instead to rely on ++ :c:member:`~PyTypeObject.tp_repr` and :c:member:`~PyTypeObject.tp_str` for printing. + + This field is inherited by subtypes. + +@@ -228,13 +228,13 @@ + An optional pointer to the get-attribute-string function. + + This field is deprecated. When it is defined, it should point to a function +- that acts the same as the :attr:`tp_getattro` function, but taking a C string ++ that acts the same as the :c:member:`~PyTypeObject.tp_getattro` function, but taking a C string + instead of a Python string object to give the attribute name. The signature is + the same as for :c:func:`PyObject_GetAttrString`. + +- This field is inherited by subtypes together with :attr:`tp_getattro`: a subtype +- inherits both :attr:`tp_getattr` and :attr:`tp_getattro` from its base type when +- the subtype's :attr:`tp_getattr` and :attr:`tp_getattro` are both *NULL*. ++ This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_getattro`: a subtype ++ inherits both :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject.tp_getattro` from its base type when ++ the subtype's :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject.tp_getattro` are both *NULL*. + + + .. c:member:: setattrfunc PyTypeObject.tp_setattr +@@ -242,13 +242,13 @@ + An optional pointer to the set-attribute-string function. + + This field is deprecated. When it is defined, it should point to a function +- that acts the same as the :attr:`tp_setattro` function, but taking a C string ++ that acts the same as the :c:member:`~PyTypeObject.tp_setattro` function, but taking a C string + instead of a Python string object to give the attribute name. The signature is + the same as for :c:func:`PyObject_SetAttrString`. + +- This field is inherited by subtypes together with :attr:`tp_setattro`: a subtype +- inherits both :attr:`tp_setattr` and :attr:`tp_setattro` from its base type when +- the subtype's :attr:`tp_setattr` and :attr:`tp_setattro` are both *NULL*. ++ This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_setattro`: a subtype ++ inherits both :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` from its base type when ++ the subtype's :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` are both *NULL*. + + + .. c:member:: cmpfunc PyTypeObject.tp_compare +@@ -260,10 +260,10 @@ + *other*, and ``-1`` if *self* less than *other*. It should return ``-1`` and + set an exception condition when an error occurred during the comparison. + +- This field is inherited by subtypes together with :attr:`tp_richcompare` and +- :attr:`tp_hash`: a subtypes inherits all three of :attr:`tp_compare`, +- :attr:`tp_richcompare`, and :attr:`tp_hash` when the subtype's +- :attr:`tp_compare`, :attr:`tp_richcompare`, and :attr:`tp_hash` are all *NULL*. ++ This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_richcompare` and ++ :c:member:`~PyTypeObject.tp_hash`: a subtypes inherits all three of :c:member:`~PyTypeObject.tp_compare`, ++ :c:member:`~PyTypeObject.tp_richcompare`, and :c:member:`~PyTypeObject.tp_hash` when the subtype's ++ :c:member:`~PyTypeObject.tp_compare`, :c:member:`~PyTypeObject.tp_richcompare`, and :c:member:`~PyTypeObject.tp_hash` are all *NULL*. + + + .. c:member:: reprfunc PyTypeObject.tp_repr +@@ -292,7 +292,7 @@ + objects which implement the number protocol. These fields are documented in + :ref:`number-structs`. + +- The :attr:`tp_as_number` field is not inherited, but the contained fields are ++ The :c:member:`~PyTypeObject.tp_as_number` field is not inherited, but the contained fields are + inherited individually. + + +@@ -302,7 +302,7 @@ + objects which implement the sequence protocol. These fields are documented + in :ref:`sequence-structs`. + +- The :attr:`tp_as_sequence` field is not inherited, but the contained fields ++ The :c:member:`~PyTypeObject.tp_as_sequence` field is not inherited, but the contained fields + are inherited individually. + + +@@ -312,7 +312,7 @@ + objects which implement the mapping protocol. These fields are documented in + :ref:`mapping-structs`. + +- The :attr:`tp_as_mapping` field is not inherited, but the contained fields ++ The :c:member:`~PyTypeObject.tp_as_mapping` field is not inherited, but the contained fields + are inherited individually. + + +@@ -336,14 +336,14 @@ + the Python level will result in the ``tp_hash`` slot being set to + :c:func:`PyObject_HashNotImplemented`. + +- When this field is not set, two possibilities exist: if the :attr:`tp_compare` +- and :attr:`tp_richcompare` fields are both *NULL*, a default hash value based on ++ When this field is not set, two possibilities exist: if the :c:member:`~PyTypeObject.tp_compare` ++ and :c:member:`~PyTypeObject.tp_richcompare` fields are both *NULL*, a default hash value based on + the object's address is returned; otherwise, a :exc:`TypeError` is raised. + +- This field is inherited by subtypes together with :attr:`tp_richcompare` and +- :attr:`tp_compare`: a subtypes inherits all three of :attr:`tp_compare`, +- :attr:`tp_richcompare`, and :attr:`tp_hash`, when the subtype's +- :attr:`tp_compare`, :attr:`tp_richcompare` and :attr:`tp_hash` are all *NULL*. ++ This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_richcompare` and ++ :c:member:`~PyTypeObject.tp_compare`: a subtypes inherits all three of :c:member:`~PyTypeObject.tp_compare`, ++ :c:member:`~PyTypeObject.tp_richcompare`, and :c:member:`~PyTypeObject.tp_hash`, when the subtype's ++ :c:member:`~PyTypeObject.tp_compare`, :c:member:`~PyTypeObject.tp_richcompare` and :c:member:`~PyTypeObject.tp_hash` are all *NULL*. + + + .. c:member:: ternaryfunc PyTypeObject.tp_call +@@ -381,9 +381,9 @@ + convenient to set this field to :c:func:`PyObject_GenericGetAttr`, which + implements the normal way of looking for object attributes. + +- This field is inherited by subtypes together with :attr:`tp_getattr`: a subtype +- inherits both :attr:`tp_getattr` and :attr:`tp_getattro` from its base type when +- the subtype's :attr:`tp_getattr` and :attr:`tp_getattro` are both *NULL*. ++ This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_getattr`: a subtype ++ inherits both :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject.tp_getattro` from its base type when ++ the subtype's :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject.tp_getattro` are both *NULL*. + + + .. c:member:: setattrofunc PyTypeObject.tp_setattro +@@ -394,9 +394,9 @@ + convenient to set this field to :c:func:`PyObject_GenericSetAttr`, which + implements the normal way of setting object attributes. + +- This field is inherited by subtypes together with :attr:`tp_setattr`: a subtype +- inherits both :attr:`tp_setattr` and :attr:`tp_setattro` from its base type when +- the subtype's :attr:`tp_setattr` and :attr:`tp_setattro` are both *NULL*. ++ This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_setattr`: a subtype ++ inherits both :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` from its base type when ++ the subtype's :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` are both *NULL*. + + + .. c:member:: PyBufferProcs* PyTypeObject.tp_as_buffer +@@ -405,7 +405,7 @@ + which implement the buffer interface. These fields are documented in + :ref:`buffer-structs`. + +- The :attr:`tp_as_buffer` field is not inherited, but the contained fields are ++ The :c:member:`~PyTypeObject.tp_as_buffer` field is not inherited, but the contained fields are + inherited individually. + + +@@ -414,8 +414,8 @@ + This field is a bit mask of various flags. Some flags indicate variant + semantics for certain situations; others are used to indicate that certain + fields in the type object (or in the extension structures referenced via +- :attr:`tp_as_number`, :attr:`tp_as_sequence`, :attr:`tp_as_mapping`, and +- :attr:`tp_as_buffer`) that were historically not always present are valid; if ++ :c:member:`~PyTypeObject.tp_as_number`, :c:member:`~PyTypeObject.tp_as_sequence`, :c:member:`~PyTypeObject.tp_as_mapping`, and ++ :c:member:`~PyTypeObject.tp_as_buffer`) that were historically not always present are valid; if + such a flag bit is clear, the type fields it guards must not be accessed and + must be considered to have a zero or *NULL* value instead. + +@@ -425,14 +425,14 @@ + inherited if the extension structure is inherited, i.e. the base type's value of + the flag bit is copied into the subtype together with a pointer to the extension + structure. The :const:`Py_TPFLAGS_HAVE_GC` flag bit is inherited together with +- the :attr:`tp_traverse` and :attr:`tp_clear` fields, i.e. if the ++ the :c:member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` fields, i.e. if the + :const:`Py_TPFLAGS_HAVE_GC` flag bit is clear in the subtype and the +- :attr:`tp_traverse` and :attr:`tp_clear` fields in the subtype exist (as ++ :c:member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` fields in the subtype exist (as + indicated by the :const:`Py_TPFLAGS_HAVE_RICHCOMPARE` flag bit) and have *NULL* + values. + + The following bit masks are currently defined; these can be ORed together using +- the ``|`` operator to form the value of the :attr:`tp_flags` field. The macro ++ the ``|`` operator to form the value of the :c:member:`~PyTypeObject.tp_flags` field. The macro + :c:func:`PyType_HasFeature` takes a type and a flags value, *tp* and *f*, and + checks whether ``tp->tp_flags & f`` is non-zero. + +@@ -440,13 +440,13 @@ + .. data:: Py_TPFLAGS_HAVE_GETCHARBUFFER + + If this bit is set, the :c:type:`PyBufferProcs` struct referenced by +- :attr:`tp_as_buffer` has the :attr:`bf_getcharbuffer` field. ++ :c:member:`~PyTypeObject.tp_as_buffer` has the :attr:`bf_getcharbuffer` field. + + + .. data:: Py_TPFLAGS_HAVE_SEQUENCE_IN + + If this bit is set, the :c:type:`PySequenceMethods` struct referenced by +- :attr:`tp_as_sequence` has the :attr:`sq_contains` field. ++ :c:member:`~PyTypeObject.tp_as_sequence` has the :attr:`sq_contains` field. + + + .. data:: Py_TPFLAGS_GC +@@ -458,8 +458,8 @@ + .. data:: Py_TPFLAGS_HAVE_INPLACEOPS + + If this bit is set, the :c:type:`PySequenceMethods` struct referenced by +- :attr:`tp_as_sequence` and the :c:type:`PyNumberMethods` structure referenced by +- :attr:`tp_as_number` contain the fields for in-place operators. In particular, ++ :c:member:`~PyTypeObject.tp_as_sequence` and the :c:type:`PyNumberMethods` structure referenced by ++ :c:member:`~PyTypeObject.tp_as_number` contain the fields for in-place operators. In particular, + this means that the :c:type:`PyNumberMethods` structure has the fields + :attr:`nb_inplace_add`, :attr:`nb_inplace_subtract`, + :attr:`nb_inplace_multiply`, :attr:`nb_inplace_divide`, +@@ -473,7 +473,7 @@ + .. data:: Py_TPFLAGS_CHECKTYPES + + If this bit is set, the binary and ternary operations in the +- :c:type:`PyNumberMethods` structure referenced by :attr:`tp_as_number` accept ++ :c:type:`PyNumberMethods` structure referenced by :c:member:`~PyTypeObject.tp_as_number` accept + arguments of arbitrary object types, and do their own type conversions if + needed. If this bit is clear, those operations require that all arguments have + the current type as their type, and the caller is supposed to perform a coercion +@@ -485,31 +485,31 @@ + + .. data:: Py_TPFLAGS_HAVE_RICHCOMPARE + +- If this bit is set, the type object has the :attr:`tp_richcompare` field, as +- well as the :attr:`tp_traverse` and the :attr:`tp_clear` fields. ++ If this bit is set, the type object has the :c:member:`~PyTypeObject.tp_richcompare` field, as ++ well as the :c:member:`~PyTypeObject.tp_traverse` and the :c:member:`~PyTypeObject.tp_clear` fields. + + + .. data:: Py_TPFLAGS_HAVE_WEAKREFS + +- If this bit is set, the :attr:`tp_weaklistoffset` field is defined. Instances +- of a type are weakly referenceable if the type's :attr:`tp_weaklistoffset` field ++ If this bit is set, the :c:member:`~PyTypeObject.tp_weaklistoffset` field is defined. Instances ++ of a type are weakly referenceable if the type's :c:member:`~PyTypeObject.tp_weaklistoffset` field + has a value greater than zero. + + + .. data:: Py_TPFLAGS_HAVE_ITER + +- If this bit is set, the type object has the :attr:`tp_iter` and +- :attr:`tp_iternext` fields. ++ If this bit is set, the type object has the :c:member:`~PyTypeObject.tp_iter` and ++ :c:member:`~PyTypeObject.tp_iternext` fields. + + + .. data:: Py_TPFLAGS_HAVE_CLASS + + If this bit is set, the type object has several new fields defined starting in +- Python 2.2: :attr:`tp_methods`, :attr:`tp_members`, :attr:`tp_getset`, +- :attr:`tp_base`, :attr:`tp_dict`, :attr:`tp_descr_get`, :attr:`tp_descr_set`, +- :attr:`tp_dictoffset`, :attr:`tp_init`, :attr:`tp_alloc`, :attr:`tp_new`, +- :attr:`tp_free`, :attr:`tp_is_gc`, :attr:`tp_bases`, :attr:`tp_mro`, +- :attr:`tp_cache`, :attr:`tp_subclasses`, and :attr:`tp_weaklist`. ++ Python 2.2: :c:member:`~PyTypeObject.tp_methods`, :c:member:`~PyTypeObject.tp_members`, :c:member:`~PyTypeObject.tp_getset`, ++ :c:member:`~PyTypeObject.tp_base`, :c:member:`~PyTypeObject.tp_dict`, :c:member:`~PyTypeObject.tp_descr_get`, :c:member:`~PyTypeObject.tp_descr_set`, ++ :c:member:`~PyTypeObject.tp_dictoffset`, :c:member:`~PyTypeObject.tp_init`, :c:member:`~PyTypeObject.tp_alloc`, :c:member:`~PyTypeObject.tp_new`, ++ :c:member:`~PyTypeObject.tp_free`, :c:member:`~PyTypeObject.tp_is_gc`, :c:member:`~PyTypeObject.tp_bases`, :c:member:`~PyTypeObject.tp_mro`, ++ :c:member:`~PyTypeObject.tp_cache`, :c:member:`~PyTypeObject.tp_subclasses`, and :c:member:`~PyTypeObject.tp_weaklist`. + + + .. data:: Py_TPFLAGS_HEAPTYPE +@@ -547,7 +547,7 @@ + is set, instances must be created using :c:func:`PyObject_GC_New` and + destroyed using :c:func:`PyObject_GC_Del`. More information in section + :ref:`supporting-cycle-detection`. This bit also implies that the +- GC-related fields :attr:`tp_traverse` and :attr:`tp_clear` are present in ++ GC-related fields :c:member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` are present in + the type object; but those fields also exist when + :const:`Py_TPFLAGS_HAVE_GC` is clear but + :const:`Py_TPFLAGS_HAVE_RICHCOMPARE` is set. +@@ -582,8 +582,8 @@ + about Python's garbage collection scheme can be found in section + :ref:`supporting-cycle-detection`. + +- The :attr:`tp_traverse` pointer is used by the garbage collector to detect +- reference cycles. A typical implementation of a :attr:`tp_traverse` function ++ The :c:member:`~PyTypeObject.tp_traverse` pointer is used by the garbage collector to detect ++ reference cycles. A typical implementation of a :c:member:`~PyTypeObject.tp_traverse` function + simply calls :c:func:`Py_VISIT` on each of the instance's members that are Python + objects. For example, this is function :c:func:`local_traverse` from the + :mod:`thread` extension module:: +@@ -609,9 +609,9 @@ + :c:func:`local_traverse` to have these specific names; don't name them just + anything. + +- This field is inherited by subtypes together with :attr:`tp_clear` and the +- :const:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :attr:`tp_traverse`, and +- :attr:`tp_clear` are all inherited from the base type if they are all zero in ++ This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_clear` and the ++ :const:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :c:member:`~PyTypeObject.tp_traverse`, and ++ :c:member:`~PyTypeObject.tp_clear` are all inherited from the base type if they are all zero in + the subtype *and* the subtype has the :const:`Py_TPFLAGS_HAVE_RICHCOMPARE` flag + bit set. + +@@ -621,17 +621,17 @@ + An optional pointer to a clear function for the garbage collector. This is only + used if the :const:`Py_TPFLAGS_HAVE_GC` flag bit is set. + +- The :attr:`tp_clear` member function is used to break reference cycles in cyclic +- garbage detected by the garbage collector. Taken together, all :attr:`tp_clear` ++ The :c:member:`~PyTypeObject.tp_clear` member function is used to break reference cycles in cyclic ++ garbage detected by the garbage collector. Taken together, all :c:member:`~PyTypeObject.tp_clear` + functions in the system must combine to break all reference cycles. This is +- subtle, and if in any doubt supply a :attr:`tp_clear` function. For example, +- the tuple type does not implement a :attr:`tp_clear` function, because it's ++ subtle, and if in any doubt supply a :c:member:`~PyTypeObject.tp_clear` function. For example, ++ the tuple type does not implement a :c:member:`~PyTypeObject.tp_clear` function, because it's + possible to prove that no reference cycle can be composed entirely of tuples. +- Therefore the :attr:`tp_clear` functions of other types must be sufficient to ++ Therefore the :c:member:`~PyTypeObject.tp_clear` functions of other types must be sufficient to + break any cycle containing a tuple. This isn't immediately obvious, and there's +- rarely a good reason to avoid implementing :attr:`tp_clear`. ++ rarely a good reason to avoid implementing :c:member:`~PyTypeObject.tp_clear`. + +- Implementations of :attr:`tp_clear` should drop the instance's references to ++ Implementations of :c:member:`~PyTypeObject.tp_clear` should drop the instance's references to + those of its members that may be Python objects, and set its pointers to those + members to *NULL*, as in the following example:: + +@@ -656,18 +656,18 @@ + so that *self* knows the contained object can no longer be used. The + :c:func:`Py_CLEAR` macro performs the operations in a safe order. + +- Because the goal of :attr:`tp_clear` functions is to break reference cycles, ++ Because the goal of :c:member:`~PyTypeObject.tp_clear` functions is to break reference cycles, + it's not necessary to clear contained objects like Python strings or Python + integers, which can't participate in reference cycles. On the other hand, it may + be convenient to clear all contained Python objects, and write the type's +- :attr:`tp_dealloc` function to invoke :attr:`tp_clear`. ++ :c:member:`~PyTypeObject.tp_dealloc` function to invoke :c:member:`~PyTypeObject.tp_clear`. + + More information about Python's garbage collection scheme can be found in + section :ref:`supporting-cycle-detection`. + +- This field is inherited by subtypes together with :attr:`tp_traverse` and the +- :const:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :attr:`tp_traverse`, and +- :attr:`tp_clear` are all inherited from the base type if they are all zero in ++ This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_traverse` and the ++ :const:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :c:member:`~PyTypeObject.tp_traverse`, and ++ :c:member:`~PyTypeObject.tp_clear` are all inherited from the base type if they are all zero in + the subtype *and* the subtype has the :const:`Py_TPFLAGS_HAVE_RICHCOMPARE` flag + bit set. + +@@ -688,13 +688,13 @@ + comparisons makes sense (e.g. ``==`` and ``!=``, but not ``<`` and + friends), directly raise :exc:`TypeError` in the rich comparison function. + +- This field is inherited by subtypes together with :attr:`tp_compare` and +- :attr:`tp_hash`: a subtype inherits all three of :attr:`tp_compare`, +- :attr:`tp_richcompare`, and :attr:`tp_hash`, when the subtype's +- :attr:`tp_compare`, :attr:`tp_richcompare`, and :attr:`tp_hash` are all *NULL*. ++ This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_compare` and ++ :c:member:`~PyTypeObject.tp_hash`: a subtype inherits all three of :c:member:`~PyTypeObject.tp_compare`, ++ :c:member:`~PyTypeObject.tp_richcompare`, and :c:member:`~PyTypeObject.tp_hash`, when the subtype's ++ :c:member:`~PyTypeObject.tp_compare`, :c:member:`~PyTypeObject.tp_richcompare`, and :c:member:`~PyTypeObject.tp_hash` are all *NULL*. + + The following constants are defined to be used as the third argument for +- :attr:`tp_richcompare` and for :c:func:`PyObject_RichCompare`: ++ :c:member:`~PyTypeObject.tp_richcompare` and for :c:func:`PyObject_RichCompare`: + + +----------------+------------+ + | Constant | Comparison | +@@ -725,26 +725,26 @@ + instance structure needs to include a field of type :c:type:`PyObject\*` which is + initialized to *NULL*. + +- Do not confuse this field with :attr:`tp_weaklist`; that is the list head for ++ Do not confuse this field with :c:member:`~PyTypeObject.tp_weaklist`; that is the list head for + weak references to the type object itself. + + This field is inherited by subtypes, but see the rules listed below. A subtype + may override this offset; this means that the subtype uses a different weak + reference list head than the base type. Since the list head is always found via +- :attr:`tp_weaklistoffset`, this should not be a problem. ++ :c:member:`~PyTypeObject.tp_weaklistoffset`, this should not be a problem. + + When a type defined by a class statement has no :attr:`__slots__` declaration, + and none of its base types are weakly referenceable, the type is made weakly + referenceable by adding a weak reference list head slot to the instance layout +- and setting the :attr:`tp_weaklistoffset` of that slot's offset. ++ and setting the :c:member:`~PyTypeObject.tp_weaklistoffset` of that slot's offset. + + When a type's :attr:`__slots__` declaration contains a slot named + :attr:`__weakref__`, that slot becomes the weak reference list head for + instances of the type, and the slot's offset is stored in the type's +- :attr:`tp_weaklistoffset`. ++ :c:member:`~PyTypeObject.tp_weaklistoffset`. + + When a type's :attr:`__slots__` declaration does not contain a slot named +- :attr:`__weakref__`, the type inherits its :attr:`tp_weaklistoffset` from its ++ :attr:`__weakref__`, the type inherits its :c:member:`~PyTypeObject.tp_weaklistoffset` from its + base type. + + The next two fields only exist if the :const:`Py_TPFLAGS_HAVE_ITER` flag bit is +@@ -772,7 +772,7 @@ + are iterators (although classic instances always have this function, even if + they don't define a :meth:`next` method). + +- Iterator types should also define the :attr:`tp_iter` function, and that ++ Iterator types should also define the :c:member:`~PyTypeObject.tp_iter` function, and that + function should return the iterator instance itself (not a new iterator + instance). + +@@ -780,7 +780,7 @@ + + This field is inherited by subtypes. + +-The next fields, up to and including :attr:`tp_weaklist`, only exist if the ++The next fields, up to and including :c:member:`~PyTypeObject.tp_weaklist`, only exist if the + :const:`Py_TPFLAGS_HAVE_CLASS` flag bit is set. + + +@@ -790,7 +790,7 @@ + structures, declaring regular methods of this type. + + For each entry in the array, an entry is added to the type's dictionary (see +- :attr:`tp_dict` below) containing a method descriptor. ++ :c:member:`~PyTypeObject.tp_dict` below) containing a method descriptor. + + This field is not inherited by subtypes (methods are inherited through a + different mechanism). +@@ -803,7 +803,7 @@ + this type. + + For each entry in the array, an entry is added to the type's dictionary (see +- :attr:`tp_dict` below) containing a member descriptor. ++ :c:member:`~PyTypeObject.tp_dict` below) containing a member descriptor. + + This field is not inherited by subtypes (members are inherited through a + different mechanism). +@@ -815,7 +815,7 @@ + structures, declaring computed attributes of instances of this type. + + For each entry in the array, an entry is added to the type's dictionary (see +- :attr:`tp_dict` below) containing a getset descriptor. ++ :c:member:`~PyTypeObject.tp_dict` below) containing a getset descriptor. + + This field is not inherited by subtypes (computed attributes are inherited + through a different mechanism). +@@ -894,7 +894,7 @@ + the instance variable dictionary; this offset is used by + :c:func:`PyObject_GenericGetAttr`. + +- Do not confuse this field with :attr:`tp_dict`; that is the dictionary for ++ Do not confuse this field with :c:member:`~PyTypeObject.tp_dict`; that is the dictionary for + attributes of the type object itself. + + If the value of this field is greater than zero, it specifies the offset from +@@ -903,20 +903,20 @@ + offset is more expensive to use, and should only be used when the instance + structure contains a variable-length part. This is used for example to add an + instance variable dictionary to subtypes of :class:`str` or :class:`tuple`. Note +- that the :attr:`tp_basicsize` field should account for the dictionary added to ++ that the :c:member:`~PyTypeObject.tp_basicsize` field should account for the dictionary added to + the end in that case, even though the dictionary is not included in the basic + object layout. On a system with a pointer size of 4 bytes, +- :attr:`tp_dictoffset` should be set to ``-4`` to indicate that the dictionary is ++ :c:member:`~PyTypeObject.tp_dictoffset` should be set to ``-4`` to indicate that the dictionary is + at the very end of the structure. + + The real dictionary offset in an instance can be computed from a negative +- :attr:`tp_dictoffset` as follows:: ++ :c:member:`~PyTypeObject.tp_dictoffset` as follows:: + + dictoffset = tp_basicsize + abs(ob_size)*tp_itemsize + tp_dictoffset + if dictoffset is not aligned on sizeof(void*): + round up to sizeof(void*) + +- where :attr:`tp_basicsize`, :attr:`tp_itemsize` and :attr:`tp_dictoffset` are ++ where :c:member:`~PyTypeObject.tp_basicsize`, :c:member:`~PyTypeObject.tp_itemsize` and :c:member:`~PyTypeObject.tp_dictoffset` are + taken from the type object, and :attr:`ob_size` is taken from the instance. The + absolute value is taken because long ints use the sign of :attr:`ob_size` to + store the sign of the number. (There's never a need to do this calculation +@@ -925,15 +925,15 @@ + This field is inherited by subtypes, but see the rules listed below. A subtype + may override this offset; this means that the subtype instances store the + dictionary at a difference offset than the base type. Since the dictionary is +- always found via :attr:`tp_dictoffset`, this should not be a problem. ++ always found via :c:member:`~PyTypeObject.tp_dictoffset`, this should not be a problem. + + When a type defined by a class statement has no :attr:`__slots__` declaration, + and none of its base types has an instance variable dictionary, a dictionary +- slot is added to the instance layout and the :attr:`tp_dictoffset` is set to ++ slot is added to the instance layout and the :c:member:`~PyTypeObject.tp_dictoffset` is set to + that slot's offset. + + When a type defined by a class statement has a :attr:`__slots__` declaration, +- the type inherits its :attr:`tp_dictoffset` from its base type. ++ the type inherits its :c:member:`~PyTypeObject.tp_dictoffset` from its base type. + + (Adding a slot named :attr:`__dict__` to the :attr:`__slots__` declaration does + not have the expected effect, it just causes confusion. Maybe this should be +@@ -957,15 +957,15 @@ + arguments represent positional and keyword arguments of the call to + :meth:`__init__`. + +- The :attr:`tp_init` function, if not *NULL*, is called when an instance is +- created normally by calling its type, after the type's :attr:`tp_new` function +- has returned an instance of the type. If the :attr:`tp_new` function returns an ++ The :c:member:`~PyTypeObject.tp_init` function, if not *NULL*, is called when an instance is ++ created normally by calling its type, after the type's :c:member:`~PyTypeObject.tp_new` function ++ has returned an instance of the type. If the :c:member:`~PyTypeObject.tp_new` function returns an + instance of some other type that is not a subtype of the original type, no +- :attr:`tp_init` function is called; if :attr:`tp_new` returns an instance of a +- subtype of the original type, the subtype's :attr:`tp_init` is called. (VERSION ++ :c:member:`~PyTypeObject.tp_init` function is called; if :c:member:`~PyTypeObject.tp_new` returns an instance of a ++ subtype of the original type, the subtype's :c:member:`~PyTypeObject.tp_init` is called. (VERSION + NOTE: described here is what is implemented in Python 2.2.1 and later. In +- Python 2.2, the :attr:`tp_init` of the type of the object returned by +- :attr:`tp_new` was always called, if not *NULL*.) ++ Python 2.2, the :c:member:`~PyTypeObject.tp_init` of the type of the object returned by ++ :c:member:`~PyTypeObject.tp_new` was always called, if not *NULL*.) + + This field is inherited by subtypes. + +@@ -982,14 +982,14 @@ + initialization. It should return a pointer to a block of memory of adequate + length for the instance, suitably aligned, and initialized to zeros, but with + :attr:`ob_refcnt` set to ``1`` and :attr:`ob_type` set to the type argument. If +- the type's :attr:`tp_itemsize` is non-zero, the object's :attr:`ob_size` field ++ the type's :c:member:`~PyTypeObject.tp_itemsize` is non-zero, the object's :attr:`ob_size` field + should be initialized to *nitems* and the length of the allocated memory block + should be ``tp_basicsize + nitems*tp_itemsize``, rounded up to a multiple of + ``sizeof(void*)``; otherwise, *nitems* is not used and the length of the block +- should be :attr:`tp_basicsize`. ++ should be :c:member:`~PyTypeObject.tp_basicsize`. + + Do not use this function to do any other instance initialization, not even to +- allocate additional memory; that should be done by :attr:`tp_new`. ++ allocate additional memory; that should be done by :c:member:`~PyTypeObject.tp_new`. + + This field is inherited by static subtypes, but not by dynamic subtypes + (subtypes created by a class statement); in the latter, this field is always set +@@ -1011,20 +1011,20 @@ + + The subtype argument is the type of the object being created; the *args* and + *kwds* arguments represent positional and keyword arguments of the call to the +- type. Note that subtype doesn't have to equal the type whose :attr:`tp_new` ++ type. Note that subtype doesn't have to equal the type whose :c:member:`~PyTypeObject.tp_new` + function is called; it may be a subtype of that type (but not an unrelated + type). + +- The :attr:`tp_new` function should call ``subtype->tp_alloc(subtype, nitems)`` ++ The :c:member:`~PyTypeObject.tp_new` function should call ``subtype->tp_alloc(subtype, nitems)`` + to allocate space for the object, and then do only as much further + initialization as is absolutely necessary. Initialization that can safely be +- ignored or repeated should be placed in the :attr:`tp_init` handler. A good ++ ignored or repeated should be placed in the :c:member:`~PyTypeObject.tp_init` handler. A good + rule of thumb is that for immutable types, all initialization should take place +- in :attr:`tp_new`, while for mutable types, most initialization should be +- deferred to :attr:`tp_init`. ++ in :c:member:`~PyTypeObject.tp_new`, while for mutable types, most initialization should be ++ deferred to :c:member:`~PyTypeObject.tp_init`. + + This field is inherited by subtypes, except it is not inherited by static types +- whose :attr:`tp_base` is *NULL* or ``&PyBaseObject_Type``. The latter exception ++ whose :c:member:`~PyTypeObject.tp_base` is *NULL* or ``&PyBaseObject_Type``. The latter exception + is a precaution so that old extension types don't become callable simply by + being linked with Python 2.2. + +@@ -1057,7 +1057,7 @@ + + The garbage collector needs to know whether a particular object is collectible + or not. Normally, it is sufficient to look at the object's type's +- :attr:`tp_flags` field, and check the :const:`Py_TPFLAGS_HAVE_GC` flag bit. But ++ :c:member:`~PyTypeObject.tp_flags` field, and check the :const:`Py_TPFLAGS_HAVE_GC` flag bit. But + some types have a mixture of statically and dynamically allocated instances, and + the statically allocated instances are not collectible. Such types should + define this function; it should return ``1`` for a collectible instance, and +@@ -1129,7 +1129,7 @@ + + .. c:member:: PyTypeObject* PyTypeObject.tp_next + +- Pointer to the next type object with a non-zero :attr:`tp_allocs` field. ++ Pointer to the next type object with a non-zero :c:member:`~PyTypeObject.tp_allocs` field. + + Also, note that, in a garbage collected Python, tp_dealloc may be called from + any Python thread, not just the thread which created the object (if the object +@@ -1289,13 +1289,13 @@ + + This function is used by :c:func:`PySequence_Concat` and has the same + signature. It is also used by the ``+`` operator, after trying the numeric +- addition via the :attr:`tp_as_number.nb_add` slot. ++ addition via the :c:member:`~PyTypeObject.tp_as_number.nb_add` slot. + + .. c:member:: ssizeargfunc PySequenceMethods.sq_repeat + + This function is used by :c:func:`PySequence_Repeat` and has the same + signature. It is also used by the ``*`` operator, after trying numeric +- multiplication via the :attr:`tp_as_number.nb_mul` slot. ++ multiplication via the :c:member:`~PyTypeObject.tp_as_number.nb_mul` slot. + + .. c:member:: ssizeargfunc PySequenceMethods.sq_item + +@@ -1348,14 +1348,14 @@ + pointer/length pair. These chunks are called :dfn:`segments` and are presumed + to be non-contiguous in memory. + +-If an object does not export the buffer interface, then its :attr:`tp_as_buffer` ++If an object does not export the buffer interface, then its :c:member:`~PyTypeObject.tp_as_buffer` + member in the :c:type:`PyTypeObject` structure should be *NULL*. Otherwise, the +-:attr:`tp_as_buffer` will point to a :c:type:`PyBufferProcs` structure. ++:c:member:`~PyTypeObject.tp_as_buffer` will point to a :c:type:`PyBufferProcs` structure. + + .. note:: + + It is very important that your :c:type:`PyTypeObject` structure uses +- :const:`Py_TPFLAGS_DEFAULT` for the value of the :attr:`tp_flags` member rather ++ :const:`Py_TPFLAGS_DEFAULT` for the value of the :c:member:`~PyTypeObject.tp_flags` member rather + than ``0``. This tells the Python runtime that your :c:type:`PyBufferProcs` + structure contains the :attr:`bf_getcharbuffer` slot. Older versions of Python + did not have this member, so a new Python interpreter using an old extension +@@ -1385,7 +1385,7 @@ + + The last slot is :attr:`bf_getcharbuffer`, of type :c:type:`getcharbufferproc`. + This slot will only be present if the :const:`Py_TPFLAGS_HAVE_GETCHARBUFFER` +- flag is present in the :attr:`tp_flags` field of the object's ++ flag is present in the :c:member:`~PyTypeObject.tp_flags` field of the object's + :c:type:`PyTypeObject`. Before using this slot, the caller should test whether it + is present by using the :c:func:`PyType_HasFeature` function. If the flag is + present, :attr:`bf_getcharbuffer` may be *NULL*, indicating that the object's +diff -r ab05e7dd2788 Doc/data/refcounts.dat +--- a/Doc/data/refcounts.dat ++++ b/Doc/data/refcounts.dat +@@ -932,7 +932,7 @@ + + PyObject_CallMethodObjArgs:PyObject*::+1: + PyObject_CallMethodObjArgs:PyObject*:o:0: +-PyObject_CallMethodObjArgs:char*:name:: ++PyObject_CallMethodObjArgs:PyObject*:name:0: + PyObject_CallMethodObjArgs::...:: + + PyObject_CallObject:PyObject*::+1: +diff -r ab05e7dd2788 Doc/extending/embedding.rst +--- a/Doc/extending/embedding.rst ++++ b/Doc/extending/embedding.rst +@@ -258,37 +258,55 @@ + + .. _link-reqs: + +-Linking Requirements +-==================== ++Compiling and Linking under Unix-like systems ++============================================= + +-While the :program:`configure` script shipped with the Python sources will +-correctly build Python to export the symbols needed by dynamically linked +-extensions, this is not automatically inherited by applications which embed the +-Python library statically, at least on Unix. This is an issue when the +-application is linked to the static runtime library (:file:`libpython.a`) and +-needs to load dynamic extensions (implemented as :file:`.so` files). ++It is not necessarily trivial to find the right flags to pass to your ++compiler (and linker) in order to embed the Python interpreter into your ++application, particularly because Python needs to load library modules ++implemented as C dynamic extensions (:file:`.so` files) linked against ++it. + +-The problem is that some entry points are defined by the Python runtime solely +-for extension modules to use. If the embedding application does not use any of +-these entry points, some linkers will not include those entries in the symbol +-table of the finished executable. Some additional options are needed to inform +-the linker not to remove these symbols. ++To find out the required compiler and linker flags, you can execute the ++:file:`python{X.Y}-config` script which is generated as part of the ++installation process (a :file:`python-config` script may also be ++available). This script has several options, of which the following will ++be directly useful to you: + +-Determining the right options to use for any given platform can be quite +-difficult, but fortunately the Python configuration already has those values. +-To retrieve them from an installed Python interpreter, start an interactive +-interpreter and have a short session like this ++* ``pythonX.Y-config --cflags`` will give you the recommended flags when ++ compiling:: ++ ++ $ /opt/bin/python2.7-config --cflags ++ -I/opt/include/python2.7 -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes ++ ++* ``pythonX.Y-config --ldflags`` will give you the recommended flags when ++ linking:: ++ ++ $ /opt/bin/python2.7-config --ldflags ++ -L/opt/lib/python2.7/config -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic ++ ++.. note:: ++ To avoid confusion between several Python installations (and especially ++ between the system Python and your own compiled Python), it is recommended ++ that you use the absolute path to :file:`python{X.Y}-config`, as in the above ++ example. ++ ++If this procedure doesn't work for you (it is not guaranteed to work for ++all Unix-like platforms; however, we welcome :ref:`bug reports `) ++you will have to read your system's documentation about dynamic linking and/or ++examine Python's :file:`Makefile` (use :func:`sysconfig.get_makefile_filename` ++to find its location) and compilation ++options. In this case, the :mod:`sysconfig` module is a useful tool to ++programmatically extract the configuration values that you will want to ++combine together. For example: + + .. code-block:: python + +- >>> import distutils.sysconfig +- >>> distutils.sysconfig.get_config_var('LINKFORSHARED') ++ >>> import sysconfig ++ >>> sysconfig.get_config_var('LIBS') ++ '-lpthread -ldl -lutil' ++ >>> sysconfig.get_config_var('LINKFORSHARED') + '-Xlinker -export-dynamic' + +-.. index:: module: distutils.sysconfig + +-The contents of the string presented will be the options that should be used. +-If the string is empty, there's no need to add any additional options. The +-:const:`LINKFORSHARED` definition corresponds to the variable of the same name +-in Python's top-level :file:`Makefile`. +- ++.. XXX similar documentation for Windows missing +diff -r ab05e7dd2788 Doc/extending/newtypes.rst +--- a/Doc/extending/newtypes.rst ++++ b/Doc/extending/newtypes.rst +@@ -150,11 +150,11 @@ + .. note:: + + If you want your type to be subclassable from Python, and your type has the same +- :attr:`tp_basicsize` as its base type, you may have problems with multiple ++ :c:member:`~PyTypeObject.tp_basicsize` as its base type, you may have problems with multiple + inheritance. A Python subclass of your type will have to list your type first + in its :attr:`__bases__`, or else it will not be able to call your type's + :meth:`__new__` method without getting an error. You can avoid this problem by +- ensuring that your type has a larger value for :attr:`tp_basicsize` than its ++ ensuring that your type has a larger value for :c:member:`~PyTypeObject.tp_basicsize` than its + base type does. Most of the time, this will be true anyway, because either your + base type will be :class:`object`, or else you will be adding data members to + your base type, and therefore increasing its size. +@@ -174,7 +174,7 @@ + All types should include this constant in their flags. It enables all of the + members defined by the current version of Python. + +-We provide a doc string for the type in :attr:`tp_doc`. :: ++We provide a doc string for the type in :c:member:`~PyTypeObject.tp_doc`. :: + + "Noddy objects", /* tp_doc */ + +@@ -183,12 +183,12 @@ + the module. We'll expand this example later to have more interesting behavior. + + For now, all we want to be able to do is to create new :class:`Noddy` objects. +-To enable object creation, we have to provide a :attr:`tp_new` implementation. ++To enable object creation, we have to provide a :c:member:`~PyTypeObject.tp_new` implementation. + In this case, we can just use the default implementation provided by the API + function :c:func:`PyType_GenericNew`. We'd like to just assign this to the +-:attr:`tp_new` slot, but we can't, for portability sake, On some platforms or ++:c:member:`~PyTypeObject.tp_new` slot, but we can't, for portability sake, On some platforms or + compilers, we can't statically initialize a structure member with a function +-defined in another C module, so, instead, we'll assign the :attr:`tp_new` slot ++defined in another C module, so, instead, we'll assign the :c:member:`~PyTypeObject.tp_new` slot + in the module initialization function just before calling + :c:func:`PyType_Ready`:: + +@@ -283,13 +283,13 @@ + self->ob_type->tp_free((PyObject*)self); + } + +-which is assigned to the :attr:`tp_dealloc` member:: ++which is assigned to the :c:member:`~PyTypeObject.tp_dealloc` member:: + + (destructor)Noddy_dealloc, /*tp_dealloc*/ + + This method decrements the reference counts of the two Python attributes. We use + :c:func:`Py_XDECREF` here because the :attr:`first` and :attr:`last` members +-could be *NULL*. It then calls the :attr:`tp_free` member of the object's type ++could be *NULL*. It then calls the :c:member:`~PyTypeObject.tp_free` member of the object's type + to free the object's memory. Note that the object's type might not be + :class:`NoddyType`, because the object may be an instance of a subclass. + +@@ -323,7 +323,7 @@ + return (PyObject *)self; + } + +-and install it in the :attr:`tp_new` member:: ++and install it in the :c:member:`~PyTypeObject.tp_new` member:: + + Noddy_new, /* tp_new */ + +@@ -344,16 +344,16 @@ + often ignore the arguments, leaving the argument handling to initializer + methods. Note that if the type supports subclassing, the type passed may not be + the type being defined. The new method calls the tp_alloc slot to allocate +-memory. We don't fill the :attr:`tp_alloc` slot ourselves. Rather ++memory. We don't fill the :c:member:`~PyTypeObject.tp_alloc` slot ourselves. Rather + :c:func:`PyType_Ready` fills it for us by inheriting it from our base class, + which is :class:`object` by default. Most types use the default allocation. + + .. note:: + +- If you are creating a co-operative :attr:`tp_new` (one that calls a base type's +- :attr:`tp_new` or :meth:`__new__`), you must *not* try to determine what method ++ If you are creating a co-operative :c:member:`~PyTypeObject.tp_new` (one that calls a base type's ++ :c:member:`~PyTypeObject.tp_new` or :meth:`__new__`), you must *not* try to determine what method + to call using method resolution order at runtime. Always statically determine +- what type you are going to call, and call its :attr:`tp_new` directly, or via ++ what type you are going to call, and call its :c:member:`~PyTypeObject.tp_new` directly, or via + ``type->tp_base->tp_new``. If you do not do this, Python subclasses of your + type that also inherit from other Python-defined classes may not work correctly. + (Specifically, you may not be able to create instances of such subclasses +@@ -390,11 +390,11 @@ + return 0; + } + +-by filling the :attr:`tp_init` slot. :: ++by filling the :c:member:`~PyTypeObject.tp_init` slot. :: + + (initproc)Noddy_init, /* tp_init */ + +-The :attr:`tp_init` slot is exposed in Python as the :meth:`__init__` method. It ++The :c:member:`~PyTypeObject.tp_init` slot is exposed in Python as the :meth:`__init__` method. It + is used to initialize an object after it's created. Unlike the new method, we + can't guarantee that the initializer is called. The initializer isn't called + when unpickling objects and it can be overridden. Our initializer accepts +@@ -424,7 +424,7 @@ + * when we know that deallocation of the object [#]_ will not cause any calls + back into our type's code + +-* when decrementing a reference count in a :attr:`tp_dealloc` handler when ++* when decrementing a reference count in a :c:member:`~PyTypeObject.tp_dealloc` handler when + garbage-collections is not supported [#]_ + + We want to expose our instance variables as attributes. There are a +@@ -440,7 +440,7 @@ + {NULL} /* Sentinel */ + }; + +-and put the definitions in the :attr:`tp_members` slot:: ++and put the definitions in the :c:member:`~PyTypeObject.tp_members` slot:: + + Noddy_members, /* tp_members */ + +@@ -516,7 +516,7 @@ + {NULL} /* Sentinel */ + }; + +-and assign them to the :attr:`tp_methods` slot:: ++and assign them to the :c:member:`~PyTypeObject.tp_methods` slot:: + + Noddy_methods, /* tp_methods */ + +@@ -611,7 +611,7 @@ + {NULL} /* Sentinel */ + }; + +-and register it in the :attr:`tp_getset` slot:: ++and register it in the :c:member:`~PyTypeObject.tp_getset` slot:: + + Noddy_getseters, /* tp_getset */ + +@@ -628,7 +628,7 @@ + {NULL} /* Sentinel */ + }; + +-We also need to update the :attr:`tp_init` handler to only allow strings [#]_ to ++We also need to update the :c:member:`~PyTypeObject.tp_init` handler to only allow strings [#]_ to + be passed:: + + static int +@@ -747,7 +747,7 @@ + + .. note:: + +- Note that the :attr:`tp_traverse` implementation must name its arguments exactly ++ Note that the :c:member:`~PyTypeObject.tp_traverse` implementation must name its arguments exactly + *visit* and *arg* in order to use :c:func:`Py_VISIT`. This is to encourage + uniformity across these boring implementations. + +@@ -784,7 +784,7 @@ + reference count drops to zero, we might cause code to run that calls back into + the object. In addition, because we now support garbage collection, we also + have to worry about code being run that triggers garbage collection. If garbage +-collection is run, our :attr:`tp_traverse` handler could get called. We can't ++collection is run, our :c:member:`~PyTypeObject.tp_traverse` handler could get called. We can't + take a chance of having :c:func:`Noddy_traverse` called when a member's reference + count has dropped to zero and its value hasn't been set to *NULL*. + +@@ -804,8 +804,8 @@ + + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + +-That's pretty much it. If we had written custom :attr:`tp_alloc` or +-:attr:`tp_free` slots, we'd need to modify them for cyclic-garbage collection. ++That's pretty much it. If we had written custom :c:member:`~PyTypeObject.tp_alloc` or ++:c:member:`~PyTypeObject.tp_free` slots, we'd need to modify them for cyclic-garbage collection. + Most extensions will use the versions automatically provided. + + +@@ -864,8 +864,8 @@ + + This pattern is important when writing a type with custom :attr:`new` and + :attr:`dealloc` methods. The :attr:`new` method should not actually create the +-memory for the object with :attr:`tp_alloc`, that will be handled by the base +-class when calling its :attr:`tp_new`. ++memory for the object with :c:member:`~PyTypeObject.tp_alloc`, that will be handled by the base ++class when calling its :c:member:`~PyTypeObject.tp_new`. + + When filling out the :c:func:`PyTypeObject` for the :class:`Shoddy` type, you see + a slot for :c:func:`tp_base`. Due to cross platform compiler issues, you can't +@@ -890,8 +890,8 @@ + } + + Before calling :c:func:`PyType_Ready`, the type structure must have the +-:attr:`tp_base` slot filled in. When we are deriving a new type, it is not +-necessary to fill out the :attr:`tp_alloc` slot with :c:func:`PyType_GenericNew` ++:c:member:`~PyTypeObject.tp_base` slot filled in. When we are deriving a new type, it is not ++necessary to fill out the :c:member:`~PyTypeObject.tp_alloc` slot with :c:func:`PyType_GenericNew` + -- the allocate function from the base type will be inherited. + + After that, calling :c:func:`PyType_Ready` and adding the type object to the +@@ -934,7 +934,7 @@ + + These fields tell the runtime how much memory to allocate when new objects of + this type are created. Python has some built-in support for variable length +-structures (think: strings, lists) which is where the :attr:`tp_itemsize` field ++structures (think: strings, lists) which is where the :c:member:`~PyTypeObject.tp_itemsize` field + comes in. This will be dealt with later. :: + + char *tp_doc; +@@ -1032,13 +1032,13 @@ + expensive. + + These handlers are all optional, and most types at most need to implement the +-:attr:`tp_str` and :attr:`tp_repr` handlers. :: ++:c:member:`~PyTypeObject.tp_str` and :c:member:`~PyTypeObject.tp_repr` handlers. :: + + reprfunc tp_repr; + reprfunc tp_str; + printfunc tp_print; + +-The :attr:`tp_repr` handler should return a string object containing a ++The :c:member:`~PyTypeObject.tp_repr` handler should return a string object containing a + representation of the instance for which it is called. Here is a simple + example:: + +@@ -1049,15 +1049,15 @@ + obj->obj_UnderlyingDatatypePtr->size); + } + +-If no :attr:`tp_repr` handler is specified, the interpreter will supply a +-representation that uses the type's :attr:`tp_name` and a uniquely-identifying ++If no :c:member:`~PyTypeObject.tp_repr` handler is specified, the interpreter will supply a ++representation that uses the type's :c:member:`~PyTypeObject.tp_name` and a uniquely-identifying + value for the object. + +-The :attr:`tp_str` handler is to :func:`str` what the :attr:`tp_repr` handler ++The :c:member:`~PyTypeObject.tp_str` handler is to :func:`str` what the :c:member:`~PyTypeObject.tp_repr` handler + described above is to :func:`repr`; that is, it is called when Python code calls + :func:`str` on an instance of your object. Its implementation is very similar +-to the :attr:`tp_repr` function, but the resulting string is intended for human +-consumption. If :attr:`tp_str` is not specified, the :attr:`tp_repr` handler is ++to the :c:member:`~PyTypeObject.tp_repr` function, but the resulting string is intended for human ++consumption. If :c:member:`~PyTypeObject.tp_str` is not specified, the :c:member:`~PyTypeObject.tp_repr` handler is + used instead. + + Here is a simple example:: +@@ -1152,7 +1152,7 @@ + type object. Each descriptor controls access to one attribute of the instance + object. Each of the tables is optional; if all three are *NULL*, instances of + the type will only have attributes that are inherited from their base type, and +-should leave the :attr:`tp_getattro` and :attr:`tp_setattro` fields *NULL* as ++should leave the :c:member:`~PyTypeObject.tp_getattro` and :c:member:`~PyTypeObject.tp_setattro` fields *NULL* as + well, allowing the base type to handle attributes. + + The tables are declared as three fields of the type object:: +@@ -1161,7 +1161,7 @@ + struct PyMemberDef *tp_members; + struct PyGetSetDef *tp_getset; + +-If :attr:`tp_methods` is not *NULL*, it must refer to an array of ++If :c:member:`~PyTypeObject.tp_methods` is not *NULL*, it must refer to an array of + :c:type:`PyMethodDef` structures. Each entry in the table is an instance of this + structure:: + +@@ -1225,13 +1225,13 @@ + single: WRITE_RESTRICTED + single: RESTRICTED + +-An interesting advantage of using the :attr:`tp_members` table to build ++An interesting advantage of using the :c:member:`~PyTypeObject.tp_members` table to build + descriptors that are used at runtime is that any attribute defined this way can + have an associated doc string simply by providing the text in the table. An + application can use the introspection API to retrieve the descriptor from the + class object, and get the doc string using its :attr:`__doc__` attribute. + +-As with the :attr:`tp_methods` table, a sentinel entry with a :attr:`name` value ++As with the :c:member:`~PyTypeObject.tp_methods` table, a sentinel entry with a :attr:`name` value + of *NULL* is required. + + .. XXX Descriptors need to be explained in more detail somewhere, but not here. +@@ -1257,7 +1257,7 @@ + called, so that if you do need to extend their functionality, you'll understand + what needs to be done. + +-The :attr:`tp_getattr` handler is called when the object requires an attribute ++The :c:member:`~PyTypeObject.tp_getattr` handler is called when the object requires an attribute + look-up. It is called in the same situations where the :meth:`__getattr__` + method of a class would be called. + +@@ -1265,7 +1265,7 @@ + :c:func:`newdatatype_getSize` and :c:func:`newdatatype_setSize` in the example + below), (2) provide a method table listing these functions, and (3) provide a + getattr function that returns the result of a lookup in that table. The method +-table uses the same structure as the :attr:`tp_methods` field of the type ++table uses the same structure as the :c:member:`~PyTypeObject.tp_methods` field of the type + object. + + Here is an example:: +@@ -1284,11 +1284,11 @@ + return Py_FindMethod(newdatatype_methods, (PyObject *)obj, name); + } + +-The :attr:`tp_setattr` handler is called when the :meth:`__setattr__` or ++The :c:member:`~PyTypeObject.tp_setattr` handler is called when the :meth:`__setattr__` or + :meth:`__delattr__` method of a class instance would be called. When an + attribute should be deleted, the third parameter will be *NULL*. Here is an + example that simply raises an exception; if this were really all you wanted, the +-:attr:`tp_setattr` handler should be set to *NULL*. :: ++:c:member:`~PyTypeObject.tp_setattr` handler should be set to *NULL*. :: + + static int + newdatatype_setattr(newdatatypeobject *obj, char *name, PyObject *v) +@@ -1305,7 +1305,7 @@ + + cmpfunc tp_compare; + +-The :attr:`tp_compare` handler is called when comparisons are needed and the ++The :c:member:`~PyTypeObject.tp_compare` handler is called when comparisons are needed and the + object does not implement the specific rich comparison method which matches the + requested comparison. (It is always used if defined and the + :c:func:`PyObject_Compare` or :c:func:`PyObject_Cmp` functions are used, or if +@@ -1316,7 +1316,7 @@ + greater than, respectively; as of Python 2.2, this is no longer allowed. In the + future, other return values may be assigned a different meaning.) + +-A :attr:`tp_compare` handler may raise an exception. In this case it should ++A :c:member:`~PyTypeObject.tp_compare` handler may raise an exception. In this case it should + return a negative value. The caller has to test for the exception using + :c:func:`PyErr_Occurred`. + +@@ -1391,7 +1391,7 @@ + + This function is called when an instance of your data type is "called", for + example, if ``obj1`` is an instance of your data type and the Python script +-contains ``obj1('hello')``, the :attr:`tp_call` handler is invoked. ++contains ``obj1('hello')``, the :c:member:`~PyTypeObject.tp_call` handler is invoked. + + This function takes three arguments: + +@@ -1480,7 +1480,7 @@ + For an object to be weakly referencable, the extension must include a + :c:type:`PyObject\*` field in the instance structure for the use of the weak + reference mechanism; it must be initialized to *NULL* by the object's +-constructor. It must also set the :attr:`tp_weaklistoffset` field of the ++constructor. It must also set the :c:member:`~PyTypeObject.tp_weaklistoffset` field of the + corresponding type object to the offset of the field. For example, the instance + type is defined with the following structure:: + +@@ -1566,7 +1566,7 @@ + .. [#] This is true when we know that the object is a basic type, like a string or a + float. + +-.. [#] We relied on this in the :attr:`tp_dealloc` handler in this example, because our ++.. [#] We relied on this in the :c:member:`~PyTypeObject.tp_dealloc` handler in this example, because our + type doesn't support garbage collection. Even if a type supports garbage + collection, there are calls that can be made to "untrack" the object from + garbage collection, however, these calls are advanced and not covered here. +diff -r ab05e7dd2788 Doc/faq/programming.rst +--- a/Doc/faq/programming.rst ++++ b/Doc/faq/programming.rst +@@ -360,9 +360,9 @@ + Assume you use a for loop to define a few different lambdas (or even plain + functions), e.g.:: + +- squares = [] +- for x in range(5): +- squares.append(lambda: x**2) ++ >>> squares = [] ++ >>> for x in range(5): ++ ... squares.append(lambda: x**2) + + This gives you a list that contains 5 lambdas that calculate ``x**2``. You + might expect that, when called, they would return, respectively, ``0``, ``1``, +@@ -387,9 +387,9 @@ + In order to avoid this, you need to save the values in variables local to the + lambdas, so that they don't rely on the value of the global ``x``:: + +- squares = [] +- for x in range(5): +- squares.append(lambda n=x: n**2) ++ >>> squares = [] ++ >>> for x in range(5): ++ ... squares.append(lambda n=x: n**2) + + Here, ``n=x`` creates a new variable ``n`` local to the lambda and computed + when the lambda is defined so that it has the same value that ``x`` had at +@@ -748,11 +748,11 @@ + Since the comma is not an operator, but a separator between expressions the + above is evaluated as if you had entered:: + +- >>> ("a" in "b"), "a" ++ ("a" in "b"), "a" + + not:: + +- >>> "a" in ("b", "a") ++ "a" in ("b", "a") + + The same is true of the various assignment operators (``=``, ``+=`` etc). They + are not truly operators but syntactic delimiters in assignment statements. +@@ -897,6 +897,7 @@ + You can't, because strings are immutable. If you need an object with this + ability, try converting the string to a list or use the array module:: + ++ >>> import io + >>> s = "Hello, world" + >>> a = list(s) + >>> print a +@@ -910,7 +911,7 @@ + >>> print a + array('c', 'Hello, world') + >>> a[0] = 'y' ; print a +- array('c', 'yello world') ++ array('c', 'yello, world') + >>> a.tostring() + 'yello, world' + +@@ -1172,7 +1173,7 @@ + + You probably tried to make a multidimensional array like this:: + +- A = [[None] * 2] * 3 ++ >>> A = [[None] * 2] * 3 + + This looks correct if you print it:: + +@@ -1204,7 +1205,7 @@ + A = [[None] * w for i in range(h)] + + Or, you can use an extension that provides a matrix datatype; `Numeric Python +-`_ is the best known. ++`_ is the best known. + + + How do I apply a method to a sequence of objects? +@@ -1223,6 +1224,92 @@ + return map(apply, methods, [arguments]*nobjects) + + ++Why does a_tuple[i] += ['item'] raise an exception when the addition works? ++--------------------------------------------------------------------------- ++ ++This is because of a combination of the fact that augmented assignment ++operators are *assignment* operators, and the difference between mutable and ++immutable objects in Python. ++ ++This discussion applies in general when augmented assignment operators are ++applied to elements of a tuple that point to mutable objects, but we'll use ++a ``list`` and ``+=`` as our exemplar. ++ ++If you wrote:: ++ ++ >>> a_tuple = (1, 2) ++ >>> a_tuple[0] += 1 ++ Traceback (most recent call last): ++ ... ++ TypeError: 'tuple' object does not support item assignment ++ ++The reason for the exception should be immediately clear: ``1`` is added to the ++object ``a_tuple[0]`` points to (``1``), producing the result object, ``2``, ++but when we attempt to assign the result of the computation, ``2``, to element ++``0`` of the tuple, we get an error because we can't change what an element of ++a tuple points to. ++ ++Under the covers, what this augmented assignment statement is doing is ++approximately this:: ++ ++ >>> result = a_tuple[0] + 1 ++ >>> a_tuple[0] = result ++ Traceback (most recent call last): ++ ... ++ TypeError: 'tuple' object does not support item assignment ++ ++It is the assignment part of the operation that produces the error, since a ++tuple is immutable. ++ ++When you write something like:: ++ ++ >>> a_tuple = (['foo'], 'bar') ++ >>> a_tuple[0] += ['item'] ++ Traceback (most recent call last): ++ ... ++ TypeError: 'tuple' object does not support item assignment ++ ++The exception is a bit more surprising, and even more surprising is the fact ++that even though there was an error, the append worked:: ++ ++ >>> a_tuple[0] ++ ['foo', 'item'] ++ ++To see why this happens, you need to know that (a) if an object implements an ++``__iadd__`` magic method, it gets called when the ``+=`` augmented assignment ++is executed, and its return value is what gets used in the assignment statement; ++and (b) for lists, ``__iadd__`` is equivalent to calling ``extend`` on the list ++and returning the list. That's why we say that for lists, ``+=`` is a ++"shorthand" for ``list.extend``:: ++ ++ >>> a_list = [] ++ >>> a_list += [1] ++ >>> a_list ++ [1] ++ ++This is equivalent to:: ++ ++ >>> result = a_list.__iadd__([1]) ++ >>> a_list = result ++ ++The object pointed to by a_list has been mutated, and the pointer to the ++mutated object is assigned back to ``a_list``. The end result of the ++assignment is a no-op, since it is a pointer to the same object that ``a_list`` ++was previously pointing to, but the assignment still happens. ++ ++Thus, in our tuple example what is happening is equivalent to:: ++ ++ >>> result = a_tuple[0].__iadd__(['item']) ++ >>> a_tuple[0] = result ++ Traceback (most recent call last): ++ ... ++ TypeError: 'tuple' object does not support item assignment ++ ++The ``__iadd__`` succeeds, and thus the list is extended, but even though ++``result`` points to the same object that ``a_tuple[0]`` already points to, ++that final assignment still results in an error, because tuples are immutable. ++ ++ + Dictionaries + ============ + +@@ -1654,13 +1741,13 @@ + (permissions, free space, etc...) to write the compiled module back to the + directory. + +-Running Python on a top level script is not considered an import and no ``.pyc`` +-will be created. For example, if you have a top-level module ``abc.py`` that +-imports another module ``xyz.py``, when you run abc, ``xyz.pyc`` will be created +-since xyz is imported, but no ``abc.pyc`` file will be created since ``abc.py`` +-isn't being imported. +- +-If you need to create abc.pyc -- that is, to create a .pyc file for a module ++Running Python on a top level script is not considered an import and no ++``.pyc`` will be created. For example, if you have a top-level module ++``foo.py`` that imports another module ``xyz.py``, when you run ``foo``, ++``xyz.pyc`` will be created since ``xyz`` is imported, but no ``foo.pyc`` file ++will be created since ``foo.py`` isn't being imported. ++ ++If you need to create ``foo.pyc`` -- that is, to create a ``.pyc`` file for a module + that is not imported -- you can, using the :mod:`py_compile` and + :mod:`compileall` modules. + +@@ -1668,9 +1755,9 @@ + the ``compile()`` function in that module interactively:: + + >>> import py_compile +- >>> py_compile.compile('abc.py') +- +-This will write the ``.pyc`` to the same location as ``abc.py`` (or you can ++ >>> py_compile.compile('foo.py') # doctest: +SKIP ++ ++This will write the ``.pyc`` to the same location as ``foo.py`` (or you can + override that with the optional parameter ``cfile``). + + You can also automatically compile all files in a directory or directories using +diff -r ab05e7dd2788 Doc/howto/argparse.rst +--- a/Doc/howto/argparse.rst ++++ b/Doc/howto/argparse.rst +@@ -468,7 +468,7 @@ + print answer + + We have introduced another action, "count", +-to count the number of occurences of a specific optional arguments: ++to count the number of occurrences of a specific optional arguments: + + .. code-block:: sh + +diff -r ab05e7dd2788 Doc/howto/logging-cookbook.rst +--- a/Doc/howto/logging-cookbook.rst ++++ b/Doc/howto/logging-cookbook.rst +@@ -97,11 +97,11 @@ + Multiple handlers and formatters + -------------------------------- + +-Loggers are plain Python objects. The :func:`addHandler` method has no minimum +-or maximum quota for the number of handlers you may add. Sometimes it will be +-beneficial for an application to log all messages of all severities to a text +-file while simultaneously logging errors or above to the console. To set this +-up, simply configure the appropriate handlers. The logging calls in the ++Loggers are plain Python objects. The :meth:`~Logger.addHandler` method has no ++minimum or maximum quota for the number of handlers you may add. Sometimes it ++will be beneficial for an application to log all messages of all severities to a ++text file while simultaneously logging errors or above to the console. To set ++this up, simply configure the appropriate handlers. The logging calls in the + application code will remain unchanged. Here is a slight modification to the + previous simple module-based configuration example:: + +@@ -395,8 +395,9 @@ + + Note that there are some security issues with pickle in some scenarios. If + these affect you, you can use an alternative serialization scheme by overriding +-the :meth:`makePickle` method and implementing your alternative there, as +-well as adapting the above script to use your alternative serialization. ++the :meth:`~handlers.SocketHandler.makePickle` method and implementing your ++alternative there, as well as adapting the above script to use your alternative ++serialization. + + + .. _context-info: +@@ -404,6 +405,8 @@ + Adding contextual information to your logging output + ---------------------------------------------------- + ++.. currentmodule:: logging ++ + Sometimes you want logging output to contain contextual information in + addition to the parameters passed to the logging call. For example, in a + networked application, it may be desirable to log client-specific information +@@ -445,9 +448,9 @@ + msg, kwargs = self.process(msg, kwargs) + self.logger.debug(msg, *args, **kwargs) + +-The :meth:`process` method of :class:`LoggerAdapter` is where the contextual +-information is added to the logging output. It's passed the message and +-keyword arguments of the logging call, and it passes back (potentially) ++The :meth:`~LoggerAdapter.process` method of :class:`LoggerAdapter` is where the ++contextual information is added to the logging output. It's passed the message ++and keyword arguments of the logging call, and it passes back (potentially) + modified versions of these to use in the call to the underlying logger. The + default implementation of this method leaves the message alone, but inserts + an 'extra' key in the keyword argument whose value is the dict-like object +@@ -459,70 +462,32 @@ + customized strings with your :class:`Formatter` instances which know about + the keys of the dict-like object. If you need a different method, e.g. if you + want to prepend or append the contextual information to the message string, +-you just need to subclass :class:`LoggerAdapter` and override :meth:`process` +-to do what you need. Here's an example script which uses this class, which +-also illustrates what dict-like behaviour is needed from an arbitrary +-'dict-like' object for use in the constructor:: ++you just need to subclass :class:`LoggerAdapter` and override ++:meth:`~LoggerAdapter.process` to do what you need. Here is a simple example:: + +- import logging ++ class CustomAdapter(logging.LoggerAdapter): ++ """ ++ This example adapter expects the passed in dict-like object to have a ++ 'connid' key, whose value in brackets is prepended to the log message. ++ """ ++ def process(self, msg, kwargs): ++ return '[%s] %s' % (self.extra['connid'], msg), kwargs + +- class ConnInfo: +- """ +- An example class which shows how an arbitrary class can be used as +- the 'extra' context information repository passed to a LoggerAdapter. +- """ ++which you can use like this:: + +- def __getitem__(self, name): +- """ +- To allow this instance to look like a dict. +- """ +- from random import choice +- if name == 'ip': +- result = choice(['127.0.0.1', '192.168.0.1']) +- elif name == 'user': +- result = choice(['jim', 'fred', 'sheila']) +- else: +- result = self.__dict__.get(name, '?') +- return result ++ logger = logging.getLogger(__name__) ++ adapter = CustomAdapter(logger, {'connid': some_conn_id}) + +- def __iter__(self): +- """ +- To allow iteration over keys, which will be merged into +- the LogRecord dict before formatting and output. +- """ +- keys = ['ip', 'user'] +- keys.extend(self.__dict__.keys()) +- return keys.__iter__() ++Then any events that you log to the adapter will have the value of ++``some_conn_id`` prepended to the log messages. + +- if __name__ == '__main__': +- from random import choice +- levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL) +- a1 = logging.LoggerAdapter(logging.getLogger('a.b.c'), +- { 'ip' : '123.231.231.123', 'user' : 'sheila' }) +- logging.basicConfig(level=logging.DEBUG, +- format='%(asctime)-15s %(name)-5s %(levelname)-8s IP: %(ip)-15s User: %(user)-8s %(message)s') +- a1.debug('A debug message') +- a1.info('An info message with %s', 'some parameters') +- a2 = logging.LoggerAdapter(logging.getLogger('d.e.f'), ConnInfo()) +- for x in range(10): +- lvl = choice(levels) +- lvlname = logging.getLevelName(lvl) +- a2.log(lvl, 'A message at %s level with %d %s', lvlname, 2, 'parameters') ++Using objects other than dicts to pass contextual information ++~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +-When this script is run, the output should look something like this:: +- +- 2008-01-18 14:49:54,023 a.b.c DEBUG IP: 123.231.231.123 User: sheila A debug message +- 2008-01-18 14:49:54,023 a.b.c INFO IP: 123.231.231.123 User: sheila An info message with some parameters +- 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 +- 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 +- 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 +- 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 +- 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 +- 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 +- 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 +- 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 +- 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 +- 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 ++You don't need to pass an actual dict to a :class:`LoggerAdapter` - you could ++pass an instance of a class which implements ``__getitem__`` and ``__iter__`` so ++that it looks like a dict to logging. This would be useful if you want to ++generate values dynamically (whereas the values in a dict would be constant). + + + .. _filters-contextual: +@@ -607,25 +572,23 @@ + *multiple processes* is *not* supported, because there is no standard way to + serialize access to a single file across multiple processes in Python. If you + need to log to a single file from multiple processes, one way of doing this is +-to have all the processes log to a :class:`SocketHandler`, and have a separate +-process which implements a socket server which reads from the socket and logs +-to file. (If you prefer, you can dedicate one thread in one of the existing +-processes to perform this function.) :ref:`This section ` +-documents this approach in more detail and includes a working socket receiver +-which can be used as a starting point for you to adapt in your own +-applications. ++to have all the processes log to a :class:`~handlers.SocketHandler`, and have a ++separate process which implements a socket server which reads from the socket ++and logs to file. (If you prefer, you can dedicate one thread in one of the ++existing processes to perform this function.) ++:ref:`This section ` documents this approach in more detail and ++includes a working socket receiver which can be used as a starting point for you ++to adapt in your own applications. + + If you are using a recent version of Python which includes the + :mod:`multiprocessing` module, you could write your own handler which uses the +-:class:`Lock` class from this module to serialize access to the file from +-your processes. The existing :class:`FileHandler` and subclasses do not make +-use of :mod:`multiprocessing` at present, though they may do so in the future. +-Note that at present, the :mod:`multiprocessing` module does not provide ++:class:`~multiprocessing.Lock` class from this module to serialize access to the ++file from your processes. The existing :class:`FileHandler` and subclasses do ++not make use of :mod:`multiprocessing` at present, though they may do so in the ++future. Note that at present, the :mod:`multiprocessing` module does not provide + working lock functionality on all platforms (see + http://bugs.python.org/issue3770). + +-.. currentmodule:: logging.handlers +- + + Using file rotation + ------------------- +@@ -637,7 +600,7 @@ + file and log to that. You may want to keep a certain number of these files, and + when that many files have been created, rotate the files so that the number of + files and the size of the files both remain bounded. For this usage pattern, the +-logging package provides a :class:`RotatingFileHandler`:: ++logging package provides a :class:`~handlers.RotatingFileHandler`:: + + import glob + import logging +@@ -688,7 +651,7 @@ + + Below is an example of a logging configuration dictionary - it's taken from + the `documentation on the Django project `_. +-This dictionary is passed to :func:`~logging.config.dictConfig` to put the configuration into effect:: ++This dictionary is passed to :func:`~config.dictConfig` to put the configuration into effect:: + + LOGGING = { + 'version': 1, +diff -r ab05e7dd2788 Doc/howto/logging.rst +--- a/Doc/howto/logging.rst ++++ b/Doc/howto/logging.rst +@@ -469,12 +469,13 @@ + + :class:`~logging.Handler` objects are responsible for dispatching the + appropriate log messages (based on the log messages' severity) to the handler's +-specified destination. Logger objects can add zero or more handler objects to +-themselves with an :func:`addHandler` method. As an example scenario, an +-application may want to send all log messages to a log file, all log messages +-of error or higher to stdout, and all messages of critical to an email address. +-This scenario requires three individual handlers where each handler is +-responsible for sending messages of a specific severity to a specific location. ++specified destination. :class:`Logger` objects can add zero or more handler ++objects to themselves with an :meth:`~Logger.addHandler` method. As an example ++scenario, an application may want to send all log messages to a log file, all ++log messages of error or higher to stdout, and all messages of critical to an ++email address. This scenario requires three individual handlers where each ++handler is responsible for sending messages of a specific severity to a specific ++location. + + The standard library includes quite a few handler types (see + :ref:`useful-handlers`); the tutorials use mainly :class:`StreamHandler` and +@@ -485,16 +486,17 @@ + developers who are using the built-in handler objects (that is, not creating + custom handlers) are the following configuration methods: + +-* The :meth:`Handler.setLevel` method, just as in logger objects, specifies the ++* The :meth:`~Handler.setLevel` method, just as in logger objects, specifies the + lowest severity that will be dispatched to the appropriate destination. Why + are there two :func:`setLevel` methods? The level set in the logger + determines which severity of messages it will pass to its handlers. The level + set in each handler determines which messages that handler will send on. + +-* :func:`setFormatter` selects a Formatter object for this handler to use. ++* :meth:`~Handler.setFormatter` selects a Formatter object for this handler to ++ use. + +-* :func:`addFilter` and :func:`removeFilter` respectively configure and +- deconfigure filter objects on handlers. ++* :meth:`~Handler.addFilter` and :meth:`~Handler.removeFilter` respectively ++ configure and deconfigure filter objects on handlers. + + Application code should not directly instantiate and use instances of + :class:`Handler`. Instead, the :class:`Handler` class is a base class that +@@ -918,16 +920,16 @@ + use with the % operator and a dictionary. + + For formatting multiple messages in a batch, instances of +-:class:`BufferingFormatter` can be used. In addition to the format string (which +-is applied to each message in the batch), there is provision for header and +-trailer format strings. ++:class:`~handlers.BufferingFormatter` can be used. In addition to the format ++string (which is applied to each message in the batch), there is provision for ++header and trailer format strings. + + When filtering based on logger level and/or handler level is not enough, + instances of :class:`Filter` can be added to both :class:`Logger` and +-:class:`Handler` instances (through their :meth:`addFilter` method). Before +-deciding to process a message further, both loggers and handlers consult all +-their filters for permission. If any filter returns a false value, the message +-is not processed further. ++:class:`Handler` instances (through their :meth:`~Handler.addFilter` method). ++Before deciding to process a message further, both loggers and handlers consult ++all their filters for permission. If any filter returns a false value, the ++message is not processed further. + + The basic :class:`Filter` functionality allows filtering by specific logger + name. If this feature is used, messages sent to the named logger and its +@@ -945,19 +947,20 @@ + cause the application using logging to terminate prematurely. + + :class:`SystemExit` and :class:`KeyboardInterrupt` exceptions are never +-swallowed. Other exceptions which occur during the :meth:`emit` method of a +-:class:`Handler` subclass are passed to its :meth:`handleError` method. ++swallowed. Other exceptions which occur during the :meth:`~Handler.emit` method ++of a :class:`Handler` subclass are passed to its :meth:`~Handler.handleError` ++method. + +-The default implementation of :meth:`handleError` in :class:`Handler` checks +-to see if a module-level variable, :data:`raiseExceptions`, is set. If set, a +-traceback is printed to :data:`sys.stderr`. If not set, the exception is swallowed. ++The default implementation of :meth:`~Handler.handleError` in :class:`Handler` ++checks to see if a module-level variable, :data:`raiseExceptions`, is set. If ++set, a traceback is printed to :data:`sys.stderr`. If not set, the exception is ++swallowed. + + .. note:: The default value of :data:`raiseExceptions` is ``True``. This is + because during development, you typically want to be notified of any + exceptions that occur. It's advised that you set :data:`raiseExceptions` to + ``False`` for production usage. + +-.. currentmodule:: logging + + .. _arbitrary-object-messages: + +@@ -967,11 +970,11 @@ + In the preceding sections and examples, it has been assumed that the message + passed when logging the event is a string. However, this is not the only + possibility. You can pass an arbitrary object as a message, and its +-:meth:`__str__` method will be called when the logging system needs to convert +-it to a string representation. In fact, if you want to, you can avoid ++:meth:`~object.__str__` method will be called when the logging system needs to ++convert it to a string representation. In fact, if you want to, you can avoid + computing a string representation altogether - for example, the +-:class:`SocketHandler` emits an event by pickling it and sending it over the +-wire. ++:class:`~handlers.SocketHandler` emits an event by pickling it and sending it ++over the wire. + + + Optimization +@@ -980,9 +983,10 @@ + Formatting of message arguments is deferred until it cannot be avoided. + However, computing the arguments passed to the logging method can also be + expensive, and you may want to avoid doing it if the logger will just throw +-away your event. To decide what to do, you can call the :meth:`isEnabledFor` +-method which takes a level argument and returns true if the event would be +-created by the Logger for that level of call. You can write code like this:: ++away your event. To decide what to do, you can call the ++:meth:`~Logger.isEnabledFor` method which takes a level argument and returns ++true if the event would be created by the Logger for that level of call. ++You can write code like this:: + + if logger.isEnabledFor(logging.DEBUG): + logger.debug('Message with %s, %s', expensive_func1(), +diff -r ab05e7dd2788 Doc/howto/sockets.rst +--- a/Doc/howto/sockets.rst ++++ b/Doc/howto/sockets.rst +@@ -19,12 +19,6 @@ + Sockets + ======= + +-Sockets are used nearly everywhere, but are one of the most severely +-misunderstood technologies around. This is a 10,000 foot overview of sockets. +-It's not really a tutorial - you'll still have work to do in getting things +-working. It doesn't cover the fine points (and there are a lot of them), but I +-hope it will give you enough background to begin using them decently. +- + I'm only going to talk about INET sockets, but they account for at least 99% of + the sockets in use. And I'll only talk about STREAM sockets - unless you really + know what you're doing (in which case this HOWTO isn't for you!), you'll get +diff -r ab05e7dd2788 Doc/library/array.rst +--- a/Doc/library/array.rst ++++ b/Doc/library/array.rst +@@ -268,9 +268,7 @@ + Packing and unpacking of External Data Representation (XDR) data as used in some + remote procedure call systems. + +- `The Numerical Python Manual `_ ++ `The Numerical Python Documentation `_ + The Numeric Python extension (NumPy) defines another array type; see +- http://numpy.sourceforge.net/ for further information about Numerical Python. +- (A PDF version of the NumPy manual is available at +- http://numpy.sourceforge.net/numdoc/numdoc.pdf). ++ http://www.numpy.org/ for further information about Numerical Python. + +diff -r ab05e7dd2788 Doc/library/ast.rst +--- a/Doc/library/ast.rst ++++ b/Doc/library/ast.rst +@@ -131,10 +131,10 @@ + + .. function:: literal_eval(node_or_string) + +- Safely evaluate an expression node or a string containing a Python +- expression. The string or node provided may only consist of the following +- Python literal structures: strings, numbers, tuples, lists, dicts, booleans, +- and ``None``. ++ Safely evaluate an expression node or a Unicode or *Latin-1* encoded string ++ containing a Python expression. The string or node provided may only consist ++ of the following Python literal structures: strings, numbers, tuples, lists, ++ dicts, booleans, and ``None``. + + This can be used for safely evaluating strings containing Python expressions + from untrusted sources without the need to parse the values oneself. +diff -r ab05e7dd2788 Doc/library/atexit.rst +--- a/Doc/library/atexit.rst ++++ b/Doc/library/atexit.rst +@@ -15,13 +15,14 @@ + + The :mod:`atexit` module defines a single function to register cleanup + functions. Functions thus registered are automatically executed upon normal +-interpreter termination. The order in which the functions are called is not +-defined; if you have cleanup operations that depend on each other, you should +-wrap them in a function and register that one. This keeps :mod:`atexit` simple. ++interpreter termination. :mod:`atexit` runs these functions in the *reverse* ++order in which they were registered; if you register ``A``, ``B``, and ``C``, ++at interpreter termination time they will be run in the order ``C``, ``B``, ++``A``. + +-Note: the functions registered via this module are not called when the program +-is killed by a signal not handled by Python, when a Python fatal internal error +-is detected, or when :func:`os._exit` is called. ++**Note:** The functions registered via this module are not called when the ++program is killed by a signal not handled by Python, when a Python fatal ++internal error is detected, or when :func:`os._exit` is called. + + .. index:: single: exitfunc (in sys) + +diff -r ab05e7dd2788 Doc/library/codecs.rst +--- a/Doc/library/codecs.rst ++++ b/Doc/library/codecs.rst +@@ -653,7 +653,7 @@ + Read one line from the input stream and return the decoded data. + + *size*, if given, is passed as size argument to the stream's +- :meth:`readline` method. ++ :meth:`read` method. + + If *keepends* is false line-endings will be stripped from the lines + returned. +@@ -1098,88 +1098,112 @@ + | utf_8_sig | | all languages | + +-----------------+--------------------------------+--------------------------------+ + +-A number of codecs are specific to Python, so their codec names have no meaning +-outside Python. Some of them don't convert from Unicode strings to byte strings, +-but instead use the property of the Python codecs machinery that any bijective +-function with one argument can be considered as an encoding. ++Python Specific Encodings ++------------------------- + +-For the codecs listed below, the result in the "encoding" direction is always a +-byte string. The result of the "decoding" direction is listed as operand type in +-the table. ++A number of predefined codecs are specific to Python, so their codec names have ++no meaning outside Python. These are listed in the tables below based on the ++expected input and output types (note that while text encodings are the most ++common use case for codecs, the underlying codec infrastructure supports ++arbitrary data transforms rather than just text encodings). For asymmetric ++codecs, the stated purpose describes the encoding direction. + +-.. tabularcolumns:: |l|p{0.3\linewidth}|l|p{0.3\linewidth}| ++The following codecs provide unicode-to-str encoding [#encoding-note]_ and ++str-to-unicode decoding [#decoding-note]_, similar to the Unicode text ++encodings. + +-+--------------------+---------------------------+----------------+---------------------------+ +-| Codec | Aliases | Operand type | Purpose | +-+====================+===========================+================+===========================+ +-| base64_codec | base64, base-64 | byte string | Convert operand to MIME | +-| | | | base64 (the result always | +-| | | | includes a trailing | +-| | | | ``'\n'``) | +-+--------------------+---------------------------+----------------+---------------------------+ +-| bz2_codec | bz2 | byte string | Compress the operand | +-| | | | using bz2 | +-+--------------------+---------------------------+----------------+---------------------------+ +-| hex_codec | hex | byte string | Convert operand to | +-| | | | hexadecimal | +-| | | | representation, with two | +-| | | | digits per byte | +-+--------------------+---------------------------+----------------+---------------------------+ +-| idna | | Unicode string | Implements :rfc:`3490`, | +-| | | | see also | +-| | | | :mod:`encodings.idna` | +-+--------------------+---------------------------+----------------+---------------------------+ +-| mbcs | dbcs | Unicode string | Windows only: Encode | +-| | | | operand according to the | +-| | | | ANSI codepage (CP_ACP) | +-+--------------------+---------------------------+----------------+---------------------------+ +-| palmos | | Unicode string | Encoding of PalmOS 3.5 | +-+--------------------+---------------------------+----------------+---------------------------+ +-| punycode | | Unicode string | Implements :rfc:`3492` | +-+--------------------+---------------------------+----------------+---------------------------+ +-| quopri_codec | quopri, quoted-printable, | byte string | Convert operand to MIME | +-| | quotedprintable | | quoted printable | +-+--------------------+---------------------------+----------------+---------------------------+ +-| raw_unicode_escape | | Unicode string | Produce a string that is | +-| | | | suitable as raw Unicode | +-| | | | literal in Python source | +-| | | | code | +-+--------------------+---------------------------+----------------+---------------------------+ +-| rot_13 | rot13 | Unicode string | Returns the Caesar-cypher | +-| | | | encryption of the operand | +-+--------------------+---------------------------+----------------+---------------------------+ +-| string_escape | | byte string | Produce a string that is | +-| | | | suitable as string | +-| | | | literal in Python source | +-| | | | code | +-+--------------------+---------------------------+----------------+---------------------------+ +-| undefined | | any | Raise an exception for | +-| | | | all conversions. Can be | +-| | | | used as the system | +-| | | | encoding if no automatic | +-| | | | :term:`coercion` between | +-| | | | byte and Unicode strings | +-| | | | is desired. | +-+--------------------+---------------------------+----------------+---------------------------+ +-| unicode_escape | | Unicode string | Produce a string that is | +-| | | | suitable as Unicode | +-| | | | literal in Python source | +-| | | | code | +-+--------------------+---------------------------+----------------+---------------------------+ +-| unicode_internal | | Unicode string | Return the internal | +-| | | | representation of the | +-| | | | operand | +-+--------------------+---------------------------+----------------+---------------------------+ +-| uu_codec | uu | byte string | Convert the operand using | +-| | | | uuencode | +-+--------------------+---------------------------+----------------+---------------------------+ +-| zlib_codec | zip, zlib | byte string | Compress the operand | +-| | | | using gzip | +-+--------------------+---------------------------+----------------+---------------------------+ ++.. tabularcolumns:: |l|L|L| ++ +++--------------------+---------------------------+---------------------------+ ++| Codec | Aliases | Purpose | +++====================+===========================+===========================+ ++| idna | | Implements :rfc:`3490`, | ++| | | see also | ++| | | :mod:`encodings.idna` | +++--------------------+---------------------------+---------------------------+ ++| mbcs | dbcs | Windows only: Encode | ++| | | operand according to the | ++| | | ANSI codepage (CP_ACP) | +++--------------------+---------------------------+---------------------------+ ++| palmos | | Encoding of PalmOS 3.5 | +++--------------------+---------------------------+---------------------------+ ++| punycode | | Implements :rfc:`3492` | +++--------------------+---------------------------+---------------------------+ ++| raw_unicode_escape | | Produce a string that is | ++| | | suitable as raw Unicode | ++| | | literal in Python source | ++| | | code | +++--------------------+---------------------------+---------------------------+ ++| rot_13 | rot13 | Returns the Caesar-cypher | ++| | | encryption of the operand | +++--------------------+---------------------------+---------------------------+ ++| undefined | | Raise an exception for | ++| | | all conversions. Can be | ++| | | used as the system | ++| | | encoding if no automatic | ++| | | :term:`coercion` between | ++| | | byte and Unicode strings | ++| | | is desired. | +++--------------------+---------------------------+---------------------------+ ++| unicode_escape | | Produce a string that is | ++| | | suitable as Unicode | ++| | | literal in Python source | ++| | | code | +++--------------------+---------------------------+---------------------------+ ++| unicode_internal | | Return the internal | ++| | | representation of the | ++| | | operand | +++--------------------+---------------------------+---------------------------+ + + .. versionadded:: 2.3 + The ``idna`` and ``punycode`` encodings. + ++The following codecs provide str-to-str encoding and decoding ++[#decoding-note]_. ++ ++.. tabularcolumns:: |l|L|L|L| ++ +++--------------------+---------------------------+---------------------------+------------------------------+ ++| Codec | Aliases | Purpose | Encoder/decoder | +++====================+===========================+===========================+==============================+ ++| base64_codec | base64, base-64 | Convert operand to MIME | :meth:`base64.b64encode`, | ++| | | base64 (the result always | :meth:`base64.b64decode` | ++| | | includes a trailing | | ++| | | ``'\n'``) | | +++--------------------+---------------------------+---------------------------+------------------------------+ ++| bz2_codec | bz2 | Compress the operand | :meth:`bz2.compress`, | ++| | | using bz2 | :meth:`bz2.decompress` | +++--------------------+---------------------------+---------------------------+------------------------------+ ++| hex_codec | hex | Convert operand to | :meth:`base64.b16encode`, | ++| | | hexadecimal | :meth:`base64.b16decode` | ++| | | representation, with two | | ++| | | digits per byte | | +++--------------------+---------------------------+---------------------------+------------------------------+ ++| quopri_codec | quopri, quoted-printable, | Convert operand to MIME | :meth:`quopri.encodestring`, | ++| | quotedprintable | quoted printable | :meth:`quopri.decodestring` | +++--------------------+---------------------------+---------------------------+------------------------------+ ++| string_escape | | Produce a string that is | | ++| | | suitable as string | | ++| | | literal in Python source | | ++| | | code | | +++--------------------+---------------------------+---------------------------+------------------------------+ ++| uu_codec | uu | Convert the operand using | :meth:`uu.encode`, | ++| | | uuencode | :meth:`uu.decode` | +++--------------------+---------------------------+---------------------------+------------------------------+ ++| zlib_codec | zip, zlib | Compress the operand | :meth:`zlib.compress`, | ++| | | using gzip | :meth:`zlib.decompress` | +++--------------------+---------------------------+---------------------------+------------------------------+ ++ ++.. [#encoding-note] str objects are also accepted as input in place of unicode ++ objects. They are implicitly converted to unicode by decoding them using ++ the default encoding. If this conversion fails, it may lead to encoding ++ operations raising :exc:`UnicodeDecodeError`. ++ ++.. [#decoding-note] unicode objects are also accepted as input in place of str ++ objects. They are implicitly converted to str by encoding them using the ++ default encoding. If this conversion fails, it may lead to decoding ++ operations raising :exc:`UnicodeEncodeError`. ++ + + :mod:`encodings.idna` --- Internationalized Domain Names in Applications + ------------------------------------------------------------------------ +diff -r ab05e7dd2788 Doc/library/collections.rst +--- a/Doc/library/collections.rst ++++ b/Doc/library/collections.rst +@@ -639,6 +639,12 @@ + 'Return self as a plain tuple. Used by copy and pickle.' + return tuple(self) + ++ __dict__ = _property(_asdict) ++ ++ def __getstate__(self): ++ 'Exclude the OrderedDict from pickling' ++ pass ++ + x = _property(_itemgetter(0), doc='Alias for field number 0') + + y = _property(_itemgetter(1), doc='Alias for field number 1') +diff -r ab05e7dd2788 Doc/library/ctypes.rst +--- a/Doc/library/ctypes.rst ++++ b/Doc/library/ctypes.rst +@@ -1333,7 +1333,7 @@ + like ``find_library("c")`` will fail and return ``None``. + + If wrapping a shared library with :mod:`ctypes`, it *may* be better to determine +-the shared library name at development type, and hardcode that into the wrapper ++the shared library name at development time, and hardcode that into the wrapper + module instead of using :func:`find_library` to locate the library at runtime. + + +diff -r ab05e7dd2788 Doc/library/datetime.rst +--- a/Doc/library/datetime.rst ++++ b/Doc/library/datetime.rst +@@ -551,8 +551,9 @@ + .. method:: date.strftime(format) + + Return a string representing the date, controlled by an explicit format string. +- Format codes referring to hours, minutes or seconds will see 0 values. See +- section :ref:`strftime-strptime-behavior`. ++ Format codes referring to hours, minutes or seconds will see 0 values. For a ++ complete list of formatting directives, see section ++ :ref:`strftime-strptime-behavior`. + + + .. method:: date.__format__(format) +@@ -730,7 +731,8 @@ + *format*. This is equivalent to ``datetime(*(time.strptime(date_string, + format)[0:6]))``. :exc:`ValueError` is raised if the date_string and format + can't be parsed by :func:`time.strptime` or if it returns a value which isn't a +- time tuple. See section :ref:`strftime-strptime-behavior`. ++ time tuple. For a complete list of formatting directives, see section ++ :ref:`strftime-strptime-behavior`. + + .. versionadded:: 2.5 + +@@ -1050,7 +1052,8 @@ + .. method:: datetime.strftime(format) + + Return a string representing the date and time, controlled by an explicit format +- string. See section :ref:`strftime-strptime-behavior`. ++ string. For a complete list of formatting directives, see section ++ :ref:`strftime-strptime-behavior`. + + + .. method:: datetime.__format__(format) +@@ -1283,7 +1286,8 @@ + .. method:: time.strftime(format) + + Return a string representing the time, controlled by an explicit format string. +- See section :ref:`strftime-strptime-behavior`. ++ For a complete list of formatting directives, see section ++ :ref:`strftime-strptime-behavior`. + + + .. method:: time.__format__(format) +@@ -1597,27 +1601,6 @@ + microseconds should not be used, as :class:`date` objects have no such + values. If they're used anyway, ``0`` is substituted for them. + +-.. versionadded:: 2.6 +- :class:`.time` and :class:`.datetime` objects support a ``%f`` format code +- which expands to the number of microseconds in the object, zero-padded on +- the left to six places. +- +-For a naive object, the ``%z`` and ``%Z`` format codes are replaced by empty +-strings. +- +-For an aware object: +- +-``%z`` +- :meth:`utcoffset` is transformed into a 5-character string of the form +HHMM or +- -HHMM, where HH is a 2-digit string giving the number of UTC offset hours, and +- MM is a 2-digit string giving the number of UTC offset minutes. For example, if +- :meth:`utcoffset` returns ``timedelta(hours=-3, minutes=-30)``, ``%z`` is +- replaced with the string ``'-0330'``. +- +-``%Z`` +- If :meth:`tzname` returns ``None``, ``%Z`` is replaced by an empty string. +- Otherwise ``%Z`` is replaced by the returned value, which must be a string. +- + The full set of format codes supported varies across platforms, because Python + calls the platform C library's :func:`strftime` function, and platform + variations are common. +@@ -1630,119 +1613,154 @@ + The exact range of years for which :meth:`strftime` works also varies across + platforms. Regardless of platform, years before 1900 cannot be used. + +-+-----------+--------------------------------+-------+ +-| Directive | Meaning | Notes | +-+===========+================================+=======+ +-| ``%a`` | Locale's abbreviated weekday | | +-| | name. | | +-+-----------+--------------------------------+-------+ +-| ``%A`` | Locale's full weekday name. | | +-+-----------+--------------------------------+-------+ +-| ``%b`` | Locale's abbreviated month | | +-| | name. | | +-+-----------+--------------------------------+-------+ +-| ``%B`` | Locale's full month name. | | +-+-----------+--------------------------------+-------+ +-| ``%c`` | Locale's appropriate date and | | +-| | time representation. | | +-+-----------+--------------------------------+-------+ +-| ``%d`` | Day of the month as a decimal | | +-| | number [01,31]. | | +-+-----------+--------------------------------+-------+ +-| ``%f`` | Microsecond as a decimal | \(1) | +-| | number [0,999999], zero-padded | | +-| | on the left | | +-+-----------+--------------------------------+-------+ +-| ``%H`` | Hour (24-hour clock) as a | | +-| | decimal number [00,23]. | | +-+-----------+--------------------------------+-------+ +-| ``%I`` | Hour (12-hour clock) as a | | +-| | decimal number [01,12]. | | +-+-----------+--------------------------------+-------+ +-| ``%j`` | Day of the year as a decimal | | +-| | number [001,366]. | | +-+-----------+--------------------------------+-------+ +-| ``%m`` | Month as a decimal number | | +-| | [01,12]. | | +-+-----------+--------------------------------+-------+ +-| ``%M`` | Minute as a decimal number | | +-| | [00,59]. | | +-+-----------+--------------------------------+-------+ +-| ``%p`` | Locale's equivalent of either | \(2) | +-| | AM or PM. | | +-+-----------+--------------------------------+-------+ +-| ``%S`` | Second as a decimal number | \(3) | +-| | [00,61]. | | +-+-----------+--------------------------------+-------+ +-| ``%U`` | Week number of the year | \(4) | +-| | (Sunday as the first day of | | +-| | the week) as a decimal number | | +-| | [00,53]. All days in a new | | +-| | year preceding the first | | +-| | Sunday are considered to be in | | +-| | week 0. | | +-+-----------+--------------------------------+-------+ +-| ``%w`` | Weekday as a decimal number | | +-| | [0(Sunday),6]. | | +-+-----------+--------------------------------+-------+ +-| ``%W`` | Week number of the year | \(4) | +-| | (Monday as the first day of | | +-| | the week) as a decimal number | | +-| | [00,53]. All days in a new | | +-| | year preceding the first | | +-| | Monday are considered to be in | | +-| | week 0. | | +-+-----------+--------------------------------+-------+ +-| ``%x`` | Locale's appropriate date | | +-| | representation. | | +-+-----------+--------------------------------+-------+ +-| ``%X`` | Locale's appropriate time | | +-| | representation. | | +-+-----------+--------------------------------+-------+ +-| ``%y`` | Year without century as a | | +-| | decimal number [00,99]. | | +-+-----------+--------------------------------+-------+ +-| ``%Y`` | Year with century as a decimal | | +-| | number. | | +-+-----------+--------------------------------+-------+ +-| ``%z`` | UTC offset in the form +HHMM | \(5) | +-| | or -HHMM (empty string if the | | +-| | the object is naive). | | +-+-----------+--------------------------------+-------+ +-| ``%Z`` | Time zone name (empty string | | +-| | if the object is naive). | | +-+-----------+--------------------------------+-------+ +-| ``%%`` | A literal ``'%'`` character. | | +-+-----------+--------------------------------+-------+ +++-----------+--------------------------------+------------------------+-------+ ++| Directive | Meaning | Example | Notes | +++===========+================================+========================+=======+ ++| ``%a`` | Weekday as locale's || Sun, Mon, ..., Sat | \(1) | ++| | abbreviated name. | (en_US); | | ++| | || So, Mo, ..., Sa | | ++| | | (de_DE) | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%A`` | Weekday as locale's full name. || Sunday, Monday, ..., | \(1) | ++| | | Saturday (en_US); | | ++| | || Sonntag, Montag, ..., | | ++| | | Samstag (de_DE) | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%w`` | Weekday as a decimal number, | 0, 1, ..., 6 | | ++| | where 0 is Sunday and 6 is | | | ++| | Saturday. | | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%d`` | Day of the month as a | 01, 02, ..., 31 | | ++| | zero-padded decimal number. | | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%b`` | Month as locale's abbreviated || Jan, Feb, ..., Dec | \(1) | ++| | name. | (en_US); | | ++| | || Jan, Feb, ..., Dez | | ++| | | (de_DE) | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%B`` | Month as locale's full name. || January, February, | \(1) | ++| | | ..., December (en_US);| | ++| | || Januar, Februar, ..., | | ++| | | Dezember (de_DE) | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%m`` | Month as a zero-padded | 01, 02, ..., 12 | | ++| | decimal number. | | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%y`` | Year without century as a | 00, 01, ..., 99 | | ++| | zero-padded decimal number. | | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%Y`` | Year with century as a decimal | 1970, 1988, 2001, 2013 | | ++| | number. | | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%H`` | Hour (24-hour clock) as a | 00, 01, ..., 23 | | ++| | zero-padded decimal number. | | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%I`` | Hour (12-hour clock) as a | 01, 02, ..., 12 | | ++| | zero-padded decimal number. | | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%p`` | Locale's equivalent of either || AM, PM (en_US); | \(1), | ++| | AM or PM. || am, pm (de_DE) | \(2) | +++-----------+--------------------------------+------------------------+-------+ ++| ``%M`` | Minute as a zero-padded | 00, 01, ..., 59 | | ++| | decimal number. | | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%S`` | Second as a zero-padded | 00, 01, ..., 59 | \(3) | ++| | decimal number. | | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%f`` | Microsecond as a decimal | 000000, 000001, ..., | \(4) | ++| | number, zero-padded on the | 999999 | | ++| | left. | | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%z`` | UTC offset in the form +HHMM | (empty), +0000, -0400, | \(5) | ++| | or -HHMM (empty string if the | +1030 | | ++| | the object is naive). | | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%Z`` | Time zone name (empty string | (empty), UTC, EST, CST | | ++| | if the object is naive). | | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%j`` | Day of the year as a | 001, 002, ..., 366 | | ++| | zero-padded decimal number. | | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%U`` | Week number of the year | 00, 01, ..., 53 | \(6) | ++| | (Sunday as the first day of | | | ++| | the week) as a zero padded | | | ++| | decimal number. All days in a | | | ++| | new year preceding the first | | | ++| | Sunday are considered to be in | | | ++| | week 0. | | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%W`` | Week number of the year | 00, 01, ..., 53 | \(6) | ++| | (Monday as the first day of | | | ++| | the week) as a decimal number. | | | ++| | All days in a new year | | | ++| | preceding the first Monday | | | ++| | are considered to be in | | | ++| | week 0. | | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%c`` | Locale's appropriate date and || Tue Aug 16 21:30:00 | \(1) | ++| | time representation. | 1988 (en_US); | | ++| | || Di 16 Aug 21:30:00 | | ++| | | 1988 (de_DE) | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%x`` | Locale's appropriate date || 08/16/88 (None); | \(1) | ++| | representation. || 08/16/1988 (en_US); | | ++| | || 16.08.1988 (de_DE) | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%X`` | Locale's appropriate time || 21:30:00 (en_US); | \(1) | ++| | representation. || 21:30:00 (de_DE) | | +++-----------+--------------------------------+------------------------+-------+ ++| ``%%`` | A literal ``'%'`` character. | % | | +++-----------+--------------------------------+------------------------+-------+ + + Notes: + + (1) +- When used with the :meth:`strptime` method, the ``%f`` directive +- accepts from one to six digits and zero pads on the right. ``%f`` is +- an extension to the set of format characters in the C standard (but +- implemented separately in datetime objects, and therefore always +- available). ++ Because the format depends on the current locale, care should be taken when ++ making assumptions about the output value. Field orderings will vary (for ++ example, "month/day/year" versus "day/month/year"), and the output may ++ contain Unicode characters encoded using the locale's default encoding (for ++ example, if the current locale is ``js_JP``, the default encoding could be ++ any one of ``eucJP``, ``SJIS``, or ``utf-8``; use :meth:`locale.getlocale` ++ to determine the current locale's encoding). + + (2) + When used with the :meth:`strptime` method, the ``%p`` directive only affects + the output hour field if the ``%I`` directive is used to parse the hour. + + (3) +- The range really is ``0`` to ``61``; according to the Posix standard this +- accounts for leap seconds and the (very rare) double leap seconds. +- The :mod:`time` module may produce and does accept leap seconds since +- it is based on the Posix standard, but the :mod:`datetime` module +- does not accept leap seconds in :meth:`strptime` input nor will it +- produce them in :func:`strftime` output. ++ Unlike the :mod:`time` module, the :mod:`datetime` module does not support ++ leap seconds. + + (4) +- When used with the :meth:`strptime` method, ``%U`` and ``%W`` are only used in +- calculations when the day of the week and the year are specified. ++ ``%f`` is an extension to the set of format characters in the C standard ++ (but implemented separately in datetime objects, and therefore always ++ available). When used with the :meth:`strptime` method, the ``%f`` ++ directive accepts from one to six digits and zero pads on the right. ++ ++ .. versionadded:: 2.6 + + (5) +- For example, if :meth:`utcoffset` returns ``timedelta(hours=-3, minutes=-30)``, +- ``%z`` is replaced with the string ``'-0330'``. ++ For a naive object, the ``%z`` and ``%Z`` format codes are replaced by empty ++ strings. ++ ++ For an aware object: ++ ++ ``%z`` ++ :meth:`utcoffset` is transformed into a 5-character string of the form ++ +HHMM or -HHMM, where HH is a 2-digit string giving the number of UTC ++ offset hours, and MM is a 2-digit string giving the number of UTC offset ++ minutes. For example, if :meth:`utcoffset` returns ++ ``timedelta(hours=-3, minutes=-30)``, ``%z`` is replaced with the string ++ ``'-0330'``. ++ ++ ``%Z`` ++ If :meth:`tzname` returns ``None``, ``%Z`` is replaced by an empty ++ string. Otherwise ``%Z`` is replaced by the returned value, which must ++ be a string. ++ ++(6) ++ When used with the :meth:`strptime` method, ``%U`` and ``%W`` are only used ++ in calculations when the day of the week and the year are specified. + + + .. rubric:: Footnotes +diff -r ab05e7dd2788 Doc/library/email.charset.rst +--- a/Doc/library/email.charset.rst ++++ b/Doc/library/email.charset.rst +@@ -249,5 +249,5 @@ + + *charset* is the canonical name of a character set. *codecname* is the name of a + Python codec, as appropriate for the second argument to the :func:`unicode` +- built-in, or to the :meth:`encode` method of a Unicode string. ++ built-in, or to the :meth:`~unicode.encode` method of a Unicode string. + +diff -r ab05e7dd2788 Doc/library/email.errors.rst +--- a/Doc/library/email.errors.rst ++++ b/Doc/library/email.errors.rst +@@ -25,7 +25,8 @@ + + Raised under some error conditions when parsing the :rfc:`2822` headers of a + message, this class is derived from :exc:`MessageParseError`. It can be raised +- from the :meth:`Parser.parse` or :meth:`Parser.parsestr` methods. ++ from the :meth:`Parser.parse ` or ++ :meth:`Parser.parsestr ` methods. + + Situations where it can be raised include finding an envelope header after the + first :rfc:`2822` header of the message, finding a continuation line before the +@@ -37,7 +38,8 @@ + + Raised under some error conditions when parsing the :rfc:`2822` headers of a + message, this class is derived from :exc:`MessageParseError`. It can be raised +- from the :meth:`Parser.parse` or :meth:`Parser.parsestr` methods. ++ from the :meth:`Parser.parse ` or ++ :meth:`Parser.parsestr ` methods. + + Situations where it can be raised include not being able to find the starting or + terminating boundary in a :mimetype:`multipart/\*` message when strict parsing +@@ -46,19 +48,20 @@ + + .. exception:: MultipartConversionError() + +- Raised when a payload is added to a :class:`Message` object using +- :meth:`add_payload`, but the payload is already a scalar and the message's +- :mailheader:`Content-Type` main type is not either :mimetype:`multipart` or +- missing. :exc:`MultipartConversionError` multiply inherits from +- :exc:`MessageError` and the built-in :exc:`TypeError`. ++ Raised when a payload is added to a :class:`~email.message.Message` object ++ using :meth:`add_payload`, but the payload is already a scalar and the ++ message's :mailheader:`Content-Type` main type is not either ++ :mimetype:`multipart` or missing. :exc:`MultipartConversionError` multiply ++ inherits from :exc:`MessageError` and the built-in :exc:`TypeError`. + +- Since :meth:`Message.add_payload` is deprecated, this exception is rarely raised +- in practice. However the exception may also be raised if the :meth:`attach` ++ Since :meth:`Message.add_payload` is deprecated, this exception is rarely ++ raised in practice. However the exception may also be raised if the ++ :meth:`~email.message.Message.attach` + method is called on an instance of a class derived from + :class:`~email.mime.nonmultipart.MIMENonMultipart` (e.g. + :class:`~email.mime.image.MIMEImage`). + +-Here's the list of the defects that the :class:`~email.mime.parser.FeedParser` ++Here's the list of the defects that the :class:`~email.parser.FeedParser` + can find while parsing messages. Note that the defects are added to the message + where the problem was found, so for example, if a message nested inside a + :mimetype:`multipart/alternative` had a malformed header, that nested message +@@ -86,7 +89,7 @@ + or was otherwise malformed. + + * :class:`MultipartInvariantViolationDefect` -- A message claimed to be a +- :mimetype:`multipart`, but no subparts were found. Note that when a message has +- this defect, its :meth:`is_multipart` method may return false even though its +- content type claims to be :mimetype:`multipart`. ++ :mimetype:`multipart`, but no subparts were found. Note that when a message ++ has this defect, its :meth:`~email.message.Message.is_multipart` method may ++ return false even though its content type claims to be :mimetype:`multipart`. + +diff -r ab05e7dd2788 Doc/library/email.header.rst +--- a/Doc/library/email.header.rst ++++ b/Doc/library/email.header.rst +@@ -103,7 +103,7 @@ + not provoke a :exc:`UnicodeError` is used. + + Optional *errors* is passed through to any :func:`unicode` or +- :func:`ustr.encode` call, and defaults to "strict". ++ :meth:`unicode.encode` call, and defaults to "strict". + + + .. method:: encode([splitchars]) +diff -r ab05e7dd2788 Doc/library/email.iterators.rst +--- a/Doc/library/email.iterators.rst ++++ b/Doc/library/email.iterators.rst +@@ -6,8 +6,9 @@ + + + Iterating over a message object tree is fairly easy with the +-:meth:`Message.walk` method. The :mod:`email.iterators` module provides some +-useful higher level iterations over message object trees. ++:meth:`Message.walk ` method. The ++:mod:`email.iterators` module provides some useful higher level iterations over ++message object trees. + + + .. function:: body_line_iterator(msg[, decode]) +@@ -16,9 +17,11 @@ + string payloads line-by-line. It skips over all the subpart headers, and it + skips over any subpart with a payload that isn't a Python string. This is + somewhat equivalent to reading the flat text representation of the message from +- a file using :meth:`readline`, skipping over all the intervening headers. ++ a file using :meth:`~io.TextIOBase.readline`, skipping over all the ++ intervening headers. + +- Optional *decode* is passed through to :meth:`Message.get_payload`. ++ Optional *decode* is passed through to :meth:`Message.get_payload ++ `. + + + .. function:: typed_subpart_iterator(msg[, maintype[, subtype]]) +diff -r ab05e7dd2788 Doc/library/email.message.rst +--- a/Doc/library/email.message.rst ++++ b/Doc/library/email.message.rst +@@ -48,8 +48,8 @@ + Note that this method is provided as a convenience and may not always + format the message the way you want. For example, by default it mangles + lines that begin with ``From``. For more flexibility, instantiate a +- :class:`~email.generator.Generator` instance and use its :meth:`flatten` +- method directly. For example:: ++ :class:`~email.generator.Generator` instance and use its ++ :meth:`~email.generator.Generator.flatten` method directly. For example:: + + from cStringIO import StringIO + from email.generator import Generator +@@ -494,8 +494,8 @@ + + Set the ``boundary`` parameter of the :mailheader:`Content-Type` header to + *boundary*. :meth:`set_boundary` will always quote *boundary* if +- necessary. A :exc:`HeaderParseError` is raised if the message object has +- no :mailheader:`Content-Type` header. ++ necessary. A :exc:`~email.errors.HeaderParseError` is raised if the ++ message object has no :mailheader:`Content-Type` header. + + Note that using this method is subtly different than deleting the old + :mailheader:`Content-Type` header and adding a new one with the new +@@ -589,7 +589,8 @@ + + .. versionchanged:: 2.5 + You do not need to set the epilogue to the empty string in order for the +- :class:`Generator` to print a newline at the end of the file. ++ :class:`~email.generator.Generator` to print a newline at the end of the ++ file. + + + .. attribute:: defects +diff -r ab05e7dd2788 Doc/library/email.mime.rst +--- a/Doc/library/email.mime.rst ++++ b/Doc/library/email.mime.rst +@@ -35,7 +35,8 @@ + *_maintype* is the :mailheader:`Content-Type` major type (e.g. :mimetype:`text` + or :mimetype:`image`), and *_subtype* is the :mailheader:`Content-Type` minor + type (e.g. :mimetype:`plain` or :mimetype:`gif`). *_params* is a parameter +- key/value dictionary and is passed directly to :meth:`Message.add_header`. ++ key/value dictionary and is passed directly to :meth:`Message.add_header ++ `. + + The :class:`MIMEBase` class always adds a :mailheader:`Content-Type` header + (based on *_maintype*, *_subtype*, and *_params*), and a +@@ -50,8 +51,9 @@ + + A subclass of :class:`~email.mime.base.MIMEBase`, this is an intermediate base + class for MIME messages that are not :mimetype:`multipart`. The primary +- purpose of this class is to prevent the use of the :meth:`attach` method, +- which only makes sense for :mimetype:`multipart` messages. If :meth:`attach` ++ purpose of this class is to prevent the use of the ++ :meth:`~email.message.Message.attach` method, which only makes sense for ++ :mimetype:`multipart` messages. If :meth:`~email.message.Message.attach` + is called, a :exc:`~email.errors.MultipartConversionError` exception is raised. + + .. versionadded:: 2.2.2 +@@ -76,7 +78,8 @@ + + *_subparts* is a sequence of initial subparts for the payload. It must be + possible to convert this sequence to a list. You can always attach new subparts +- to the message by using the :meth:`Message.attach` method. ++ to the message by using the :meth:`Message.attach ++ ` method. + + Additional parameters for the :mailheader:`Content-Type` header are taken from + the keyword arguments, or passed into the *_params* argument, which is a keyword +@@ -99,8 +102,10 @@ + + Optional *_encoder* is a callable (i.e. function) which will perform the actual + encoding of the data for transport. This callable takes one argument, which is +- the :class:`MIMEApplication` instance. It should use :meth:`get_payload` and +- :meth:`set_payload` to change the payload to encoded form. It should also add ++ the :class:`MIMEApplication` instance. It should use ++ :meth:`~email.message.Message.get_payload` and ++ :meth:`~email.message.Message.set_payload` to change the payload to encoded ++ form. It should also add + any :mailheader:`Content-Transfer-Encoding` or other headers to the message + object as necessary. The default encoding is base64. See the + :mod:`email.encoders` module for a list of the built-in encoders. +@@ -127,8 +132,10 @@ + + Optional *_encoder* is a callable (i.e. function) which will perform the actual + encoding of the audio data for transport. This callable takes one argument, +- which is the :class:`MIMEAudio` instance. It should use :meth:`get_payload` and +- :meth:`set_payload` to change the payload to encoded form. It should also add ++ which is the :class:`MIMEAudio` instance. It should use ++ :meth:`~email.message.Message.get_payload` and ++ :meth:`~email.message.Message.set_payload` to change the payload to encoded ++ form. It should also add + any :mailheader:`Content-Transfer-Encoding` or other headers to the message + object as necessary. The default encoding is base64. See the + :mod:`email.encoders` module for a list of the built-in encoders. +@@ -153,8 +160,10 @@ + + Optional *_encoder* is a callable (i.e. function) which will perform the actual + encoding of the image data for transport. This callable takes one argument, +- which is the :class:`MIMEImage` instance. It should use :meth:`get_payload` and +- :meth:`set_payload` to change the payload to encoded form. It should also add ++ which is the :class:`MIMEImage` instance. It should use ++ :meth:`~email.message.Message.get_payload` and ++ :meth:`~email.message.Message.set_payload` to change the payload to encoded ++ form. It should also add + any :mailheader:`Content-Transfer-Encoding` or other headers to the message + object as necessary. The default encoding is base64. See the + :mod:`email.encoders` module for a list of the built-in encoders. +diff -r ab05e7dd2788 Doc/library/email.parser.rst +--- a/Doc/library/email.parser.rst ++++ b/Doc/library/email.parser.rst +@@ -7,7 +7,8 @@ + + Message object structures can be created in one of two ways: they can be created + from whole cloth by instantiating :class:`~email.message.Message` objects and +-stringing them together via :meth:`attach` and :meth:`set_payload` calls, or they ++stringing them together via :meth:`~email.message.Message.attach` and ++:meth:`~email.message.Message.set_payload` calls, or they + can be created by parsing a flat text representation of the email message. + + The :mod:`email` package provides a standard parser that understands most email +@@ -16,8 +17,9 @@ + :class:`~email.message.Message` instance of the object structure. For simple, + non-MIME messages the payload of this root object will likely be a string + containing the text of the message. For MIME messages, the root object will +-return ``True`` from its :meth:`is_multipart` method, and the subparts can be +-accessed via the :meth:`get_payload` and :meth:`walk` methods. ++return ``True`` from its :meth:`~email.message.Message.is_multipart` method, and ++the subparts can be accessed via the :meth:`~email.message.Message.get_payload` ++and :meth:`~email.message.Message.walk` methods. + + There are actually two parser interfaces available for use, the classic + :class:`Parser` API and the incremental :class:`FeedParser` API. The classic +@@ -127,7 +129,8 @@ + + Read all the data from the file-like object *fp*, parse the resulting + text, and return the root message object. *fp* must support both the +- :meth:`readline` and the :meth:`read` methods on file-like objects. ++ :meth:`~io.TextIOBase.readline` and the :meth:`~io.TextIOBase.read` ++ methods on file-like objects. + + The text contained in *fp* must be formatted as a block of :rfc:`2822` + style headers and header continuation lines, optionally preceded by a +@@ -147,7 +150,7 @@ + + Similar to the :meth:`parse` method, except it takes a string object + instead of a file-like object. Calling this method on a string is exactly +- equivalent to wrapping *text* in a :class:`StringIO` instance first and ++ equivalent to wrapping *text* in a :class:`~StringIO.StringIO` instance first and + calling :meth:`parse`. + + Optional *headersonly* is as with the :meth:`parse` method. +@@ -165,7 +168,7 @@ + + Return a message object structure from a string. This is exactly equivalent to + ``Parser().parsestr(s)``. Optional *_class* and *strict* are interpreted as +- with the :class:`Parser` class constructor. ++ with the :class:`~email.parser.Parser` class constructor. + + .. versionchanged:: 2.2.2 + The *strict* flag was added. +@@ -175,7 +178,7 @@ + + Return a message object structure tree from an open file object. This is + exactly equivalent to ``Parser().parse(fp)``. Optional *_class* and *strict* +- are interpreted as with the :class:`Parser` class constructor. ++ are interpreted as with the :class:`~email.parser.Parser` class constructor. + + .. versionchanged:: 2.2.2 + The *strict* flag was added. +@@ -193,32 +196,35 @@ + + * Most non-\ :mimetype:`multipart` type messages are parsed as a single message + object with a string payload. These objects will return ``False`` for +- :meth:`is_multipart`. Their :meth:`get_payload` method will return a string +- object. ++ :meth:`~email.message.Message.is_multipart`. Their ++ :meth:`~email.message.Message.get_payload` method will return a string object. + + * All :mimetype:`multipart` type messages will be parsed as a container message + object with a list of sub-message objects for their payload. The outer +- container message will return ``True`` for :meth:`is_multipart` and their +- :meth:`get_payload` method will return the list of :class:`~email.message.Message` +- subparts. ++ container message will return ``True`` for ++ :meth:`~email.message.Message.is_multipart` and their ++ :meth:`~email.message.Message.get_payload` method will return the list of ++ :class:`~email.message.Message` subparts. + + * Most messages with a content type of :mimetype:`message/\*` (e.g. + :mimetype:`message/delivery-status` and :mimetype:`message/rfc822`) will also be + parsed as container object containing a list payload of length 1. Their +- :meth:`is_multipart` method will return ``True``. The single element in the +- list payload will be a sub-message object. ++ :meth:`~email.message.Message.is_multipart` method will return ``True``. ++ The single element in the list payload will be a sub-message object. + + * Some non-standards compliant messages may not be internally consistent about + their :mimetype:`multipart`\ -edness. Such messages may have a + :mailheader:`Content-Type` header of type :mimetype:`multipart`, but their +- :meth:`is_multipart` method may return ``False``. If such messages were parsed +- with the :class:`FeedParser`, they will have an instance of the +- :class:`MultipartInvariantViolationDefect` class in their *defects* attribute +- list. See :mod:`email.errors` for details. ++ :meth:`~email.message.Message.is_multipart` method may return ``False``. ++ If such messages were parsed with the :class:`~email.parser.FeedParser`, ++ they will have an instance of the ++ :class:`~email.errors.MultipartInvariantViolationDefect` class in their ++ *defects* attribute list. See :mod:`email.errors` for details. + + .. rubric:: Footnotes + + .. [#] As of email package version 3.0, introduced in Python 2.4, the classic +- :class:`Parser` was re-implemented in terms of the :class:`FeedParser`, so the +- semantics and results are identical between the two parsers. ++ :class:`~email.parser.Parser` was re-implemented in terms of the ++ :class:`~email.parser.FeedParser`, so the semantics and results are ++ identical between the two parsers. + +diff -r ab05e7dd2788 Doc/library/email.rst +--- a/Doc/library/email.rst ++++ b/Doc/library/email.rst +@@ -112,14 +112,15 @@ + *Note that the version 3 names will continue to work until Python 2.6*. + + * The :mod:`email.mime.application` module was added, which contains the +- :class:`MIMEApplication` class. ++ :class:`~email.mime.application.MIMEApplication` class. + + * Methods that were deprecated in version 3 have been removed. These include + :meth:`Generator.__call__`, :meth:`Message.get_type`, + :meth:`Message.get_main_type`, :meth:`Message.get_subtype`. + + * Fixes have been added for :rfc:`2231` support which can change some of the +- return types for :func:`Message.get_param` and friends. Under some ++ return types for :func:`Message.get_param ` ++ and friends. Under some + circumstances, values which used to return a 3-tuple now return simple strings + (specifically, if all extended parameter segments were unencoded, there is no + language and charset designation expected, so the return type is now a simple +@@ -128,23 +129,24 @@ + + Here are the major differences between :mod:`email` version 3 and version 2: + +-* The :class:`FeedParser` class was introduced, and the :class:`Parser` class +- was implemented in terms of the :class:`FeedParser`. All parsing therefore is ++* The :class:`~email.parser.FeedParser` class was introduced, and the ++ :class:`~email.parser.Parser` class was implemented in terms of the ++ :class:`~email.parser.FeedParser`. All parsing therefore is + non-strict, and parsing will make a best effort never to raise an exception. + Problems found while parsing messages are stored in the message's *defect* + attribute. + + * All aspects of the API which raised :exc:`DeprecationWarning`\ s in version 2 + have been removed. These include the *_encoder* argument to the +- :class:`MIMEText` constructor, the :meth:`Message.add_payload` method, the +- :func:`Utils.dump_address_pair` function, and the functions :func:`Utils.decode` +- and :func:`Utils.encode`. ++ :class:`~email.mime.text.MIMEText` constructor, the ++ :meth:`Message.add_payload` method, the :func:`Utils.dump_address_pair` ++ function, and the functions :func:`Utils.decode` and :func:`Utils.encode`. + + * New :exc:`DeprecationWarning`\ s have been added to: + :meth:`Generator.__call__`, :meth:`Message.get_type`, + :meth:`Message.get_main_type`, :meth:`Message.get_subtype`, and the *strict* +- argument to the :class:`Parser` class. These are expected to be removed in +- future versions. ++ argument to the :class:`~email.parser.Parser` class. These are expected to ++ be removed in future versions. + + * Support for Pythons earlier than 2.3 has been removed. + +@@ -152,53 +154,61 @@ + + * The :mod:`email.Header` and :mod:`email.Charset` modules have been added. + +-* The pickle format for :class:`Message` instances has changed. Since this was +- never (and still isn't) formally defined, this isn't considered a backward +- incompatibility. However if your application pickles and unpickles +- :class:`Message` instances, be aware that in :mod:`email` version 2, +- :class:`Message` instances now have private variables *_charset* and +- *_default_type*. ++* The pickle format for :class:`~email.message.Message` instances has changed. ++ Since this was never (and still isn't) formally defined, this isn't ++ considered a backward incompatibility. However if your application pickles ++ and unpickles :class:`~email.message.Message` instances, be aware that in ++ :mod:`email` version 2, :class:`~email.message.Message` instances now have ++ private variables *_charset* and *_default_type*. + +-* Several methods in the :class:`Message` class have been deprecated, or their +- signatures changed. Also, many new methods have been added. See the +- documentation for the :class:`Message` class for details. The changes should be +- completely backward compatible. ++* Several methods in the :class:`~email.message.Message` class have been ++ deprecated, or their signatures changed. Also, many new methods have been ++ added. See the documentation for the :class:`~email.message.Message` class ++ for details. The changes should be completely backward compatible. + + * The object structure has changed in the face of :mimetype:`message/rfc822` +- content types. In :mod:`email` version 1, such a type would be represented by a +- scalar payload, i.e. the container message's :meth:`is_multipart` returned +- false, :meth:`get_payload` was not a list object, but a single :class:`Message` +- instance. ++ content types. In :mod:`email` version 1, such a type would be represented ++ by a scalar payload, i.e. the container message's ++ :meth:`~email.message.Message.is_multipart` returned false, ++ :meth:`~email.message.Message.get_payload` was not a list object, but a ++ single :class:`~email.message.Message` instance. + + This structure was inconsistent with the rest of the package, so the object + representation for :mimetype:`message/rfc822` content types was changed. In + :mod:`email` version 2, the container *does* return ``True`` from +- :meth:`is_multipart`, and :meth:`get_payload` returns a list containing a single +- :class:`Message` item. ++ :meth:`~email.message.Message.is_multipart`, and ++ :meth:`~email.message.Message.get_payload` returns a list containing a single ++ :class:`~email.message.Message` item. + +- Note that this is one place that backward compatibility could not be completely +- maintained. However, if you're already testing the return type of +- :meth:`get_payload`, you should be fine. You just need to make sure your code +- doesn't do a :meth:`set_payload` with a :class:`Message` instance on a container +- with a content type of :mimetype:`message/rfc822`. ++ Note that this is one place that backward compatibility could not be ++ completely maintained. However, if you're already testing the return type of ++ :meth:`~email.message.Message.get_payload`, you should be fine. You just need ++ to make sure your code doesn't do a :meth:`~email.message.Message.set_payload` ++ with a :class:`~email.message.Message` instance on a container with a content ++ type of :mimetype:`message/rfc822`. + +-* The :class:`Parser` constructor's *strict* argument was added, and its +- :meth:`parse` and :meth:`parsestr` methods grew a *headersonly* argument. The +- *strict* flag was also added to functions :func:`email.message_from_file` and +- :func:`email.message_from_string`. ++* The :class:`~email.parser.Parser` constructor's *strict* argument was added, ++ and its :meth:`~email.parser.Parser.parse` and ++ :meth:`~email.parser.Parser.parsestr` methods grew a *headersonly* argument. ++ The *strict* flag was also added to functions :func:`email.message_from_file` ++ and :func:`email.message_from_string`. + +-* :meth:`Generator.__call__` is deprecated; use :meth:`Generator.flatten` +- instead. The :class:`Generator` class has also grown the :meth:`clone` method. ++* :meth:`Generator.__call__` is deprecated; use :meth:`Generator.flatten ++ ` instead. The ++ :class:`~email.generator.Generator` class has also grown the ++ :meth:`~email.generator.Generator.clone` method. + +-* The :class:`DecodedGenerator` class in the :mod:`email.Generator` module was +- added. ++* The :class:`~email.generator.DecodedGenerator` class in the ++ :mod:`email.generator` module was added. + +-* The intermediate base classes :class:`MIMENonMultipart` and +- :class:`MIMEMultipart` have been added, and interposed in the class hierarchy +- for most of the other MIME-related derived classes. ++* The intermediate base classes ++ :class:`~email.mime.nonmultipart.MIMENonMultipart` and ++ :class:`~email.mime.multipart.MIMEMultipart` have been added, and interposed ++ in the class hierarchy for most of the other MIME-related derived classes. + +-* The *_encoder* argument to the :class:`MIMEText` constructor has been +- deprecated. Encoding now happens implicitly based on the *_charset* argument. ++* The *_encoder* argument to the :class:`~email.mime.text.MIMEText` constructor ++ has been deprecated. Encoding now happens implicitly based on the ++ *_charset* argument. + + * The following functions in the :mod:`email.Utils` module have been deprecated: + :func:`dump_address_pairs`, :func:`decode`, and :func:`encode`. The following +@@ -231,17 +241,22 @@ + + * :func:`messageFromFile` has been renamed to :func:`message_from_file`. + +-The :class:`Message` class has the following differences: ++The :class:`~email.message.Message` class has the following differences: + +-* The method :meth:`asString` was renamed to :meth:`as_string`. ++* The method :meth:`asString` was renamed to ++ :meth:`~email.message.Message.as_string`. + +-* The method :meth:`ismultipart` was renamed to :meth:`is_multipart`. ++* The method :meth:`ismultipart` was renamed to ++ :meth:`~email.message.Message.is_multipart`. + +-* The :meth:`get_payload` method has grown a *decode* optional argument. ++* The :meth:`~email.message.Message.get_payload` method has grown a *decode* ++ optional argument. + +-* The method :meth:`getall` was renamed to :meth:`get_all`. ++* The method :meth:`getall` was renamed to ++ :meth:`~email.message.Message.get_all`. + +-* The method :meth:`addheader` was renamed to :meth:`add_header`. ++* The method :meth:`addheader` was renamed to ++ :meth:`~email.message.Message.add_header`. + + * The method :meth:`gettype` was renamed to :meth:`get_type`. + +@@ -249,48 +264,57 @@ + + * The method :meth:`getsubtype` was renamed to :meth:`get_subtype`. + +-* The method :meth:`getparams` was renamed to :meth:`get_params`. Also, whereas +- :meth:`getparams` returned a list of strings, :meth:`get_params` returns a list +- of 2-tuples, effectively the key/value pairs of the parameters, split on the +- ``'='`` sign. ++* The method :meth:`getparams` was renamed to ++ :meth:`~email.message.Message.get_params`. Also, whereas :meth:`getparams` ++ returned a list of strings, :meth:`~email.message.Message.get_params` returns ++ a list of 2-tuples, effectively the key/value pairs of the parameters, split ++ on the ``'='`` sign. + +-* The method :meth:`getparam` was renamed to :meth:`get_param`. ++* The method :meth:`getparam` was renamed to ++ :meth:`~email.message.Message.get_param`. + +-* The method :meth:`getcharsets` was renamed to :meth:`get_charsets`. ++* The method :meth:`getcharsets` was renamed to ++ :meth:`~email.message.Message.get_charsets`. + +-* The method :meth:`getfilename` was renamed to :meth:`get_filename`. ++* The method :meth:`getfilename` was renamed to ++ :meth:`~email.message.Message.get_filename`. + +-* The method :meth:`getboundary` was renamed to :meth:`get_boundary`. ++* The method :meth:`getboundary` was renamed to ++ :meth:`~email.message.Message.get_boundary`. + +-* The method :meth:`setboundary` was renamed to :meth:`set_boundary`. ++* The method :meth:`setboundary` was renamed to ++ :meth:`~email.message.Message.set_boundary`. + + * The method :meth:`getdecodedpayload` was removed. To get similar +- functionality, pass the value 1 to the *decode* flag of the get_payload() +- method. ++ functionality, pass the value 1 to the *decode* flag of the ++ :meth:`~email.message.Message.get_payload` method. + + * The method :meth:`getpayloadastext` was removed. Similar functionality is +- supported by the :class:`DecodedGenerator` class in the :mod:`email.generator` ++ supported by the :class:`~email.generator.DecodedGenerator` class in the ++ :mod:`email.generator` module. ++ ++* The method :meth:`getbodyastext` was removed. You can get similar ++ functionality by creating an iterator with ++ :func:`~email.iterators.typed_subpart_iterator` in the :mod:`email.iterators` + module. + +-* The method :meth:`getbodyastext` was removed. You can get similar +- functionality by creating an iterator with :func:`typed_subpart_iterator` in the +- :mod:`email.iterators` module. ++The :class:`~email.parser.Parser` class has no differences in its public ++interface. It does have some additional smarts to recognize ++:mimetype:`message/delivery-status` type messages, which it represents as a ++:class:`~email.message.Message` instance containing separate ++:class:`~email.message.Message` subparts for each header block in the delivery ++status notification [#]_. + +-The :class:`Parser` class has no differences in its public interface. It does +-have some additional smarts to recognize :mimetype:`message/delivery-status` +-type messages, which it represents as a :class:`Message` instance containing +-separate :class:`Message` subparts for each header block in the delivery status +-notification [#]_. +- +-The :class:`Generator` class has no differences in its public interface. There +-is a new class in the :mod:`email.generator` module though, called +-:class:`DecodedGenerator` which provides most of the functionality previously +-available in the :meth:`Message.getpayloadastext` method. ++The :class:`~email.generator.Generator` class has no differences in its public ++interface. There is a new class in the :mod:`email.generator` module though, ++called :class:`~email.generator.DecodedGenerator` which provides most of the ++functionality previously available in the :meth:`Message.getpayloadastext` ++method. + + The following modules and classes have been changed: + +-* The :class:`MIMEBase` class constructor arguments *_major* and *_minor* have +- changed to *_maintype* and *_subtype* respectively. ++* The :class:`~email.mime.base.MIMEBase` class constructor arguments *_major* ++ and *_minor* have changed to *_maintype* and *_subtype* respectively. + + * The ``Image`` class/module has been renamed to ``MIMEImage``. The *_minor* + argument has been renamed to *_subtype*. +@@ -303,7 +327,8 @@ + but that clashed with the Python standard library module :mod:`rfc822` on some + case-insensitive file systems. + +- Also, the :class:`MIMEMessage` class now represents any kind of MIME message ++ Also, the :class:`~email.mime.message.MIMEMessage` class now represents any ++ kind of MIME message + with main type :mimetype:`message`. It takes an optional argument *_subtype* + which is used to set the MIME subtype. *_subtype* defaults to + :mimetype:`rfc822`. +@@ -313,8 +338,8 @@ + :mod:`email.utils` module. + + The ``MsgReader`` class/module has been removed. Its functionality is most +-closely supported in the :func:`body_line_iterator` function in the +-:mod:`email.iterators` module. ++closely supported in the :func:`~email.iterators.body_line_iterator` function ++in the :mod:`email.iterators` module. + + .. rubric:: Footnotes + +diff -r ab05e7dd2788 Doc/library/email.util.rst +--- a/Doc/library/email.util.rst ++++ b/Doc/library/email.util.rst +@@ -41,8 +41,8 @@ + + This method returns a list of 2-tuples of the form returned by ``parseaddr()``. + *fieldvalues* is a sequence of header field values as might be returned by +- :meth:`Message.get_all`. Here's a simple example that gets all the recipients +- of a message:: ++ :meth:`Message.get_all `. Here's a simple ++ example that gets all the recipients of a message:: + + from email.utils import getaddresses + +@@ -130,7 +130,8 @@ + .. function:: collapse_rfc2231_value(value[, errors[, fallback_charset]]) + + When a header parameter is encoded in :rfc:`2231` format, +- :meth:`Message.get_param` may return a 3-tuple containing the character set, ++ :meth:`Message.get_param ` may return a ++ 3-tuple containing the character set, + language, and value. :func:`collapse_rfc2231_value` turns this into a unicode + string. Optional *errors* is passed to the *errors* argument of the built-in + :func:`unicode` function; it defaults to ``replace``. Optional +@@ -152,11 +153,12 @@ + + .. versionchanged:: 2.4 + The :func:`decode` function has been removed; use the +- :meth:`Header.decode_header` method instead. ++ :meth:`Header.decode_header ` method ++ instead. + + .. versionchanged:: 2.4 +- The :func:`encode` function has been removed; use the :meth:`Header.encode` +- method instead. ++ The :func:`encode` function has been removed; use the :meth:`Header.encode ++ ` method instead. + + .. rubric:: Footnotes + +diff -r ab05e7dd2788 Doc/library/fileinput.rst +--- a/Doc/library/fileinput.rst ++++ b/Doc/library/fileinput.rst +@@ -50,7 +50,7 @@ + The following function is the primary interface of this module: + + +-.. function:: input([files[, inplace[, backup[, mode[, openhook]]]]]) ++.. function:: input([files[, inplace[, backup[, bufsize[, mode[, openhook]]]]]]) + + Create an instance of the :class:`FileInput` class. The instance will be used + as global state for the functions of this module, and is also returned to use +@@ -122,7 +122,7 @@ + available for subclassing as well: + + +-.. class:: FileInput([files[, inplace[, backup[, mode[, openhook]]]]]) ++.. class:: FileInput([files[, inplace[, backup[,bufsize[, mode[, openhook]]]]]]) + + Class :class:`FileInput` is the implementation; its methods :meth:`filename`, + :meth:`fileno`, :meth:`lineno`, :meth:`filelineno`, :meth:`isfirstline`, +diff -r ab05e7dd2788 Doc/library/functions.rst +--- a/Doc/library/functions.rst ++++ b/Doc/library/functions.rst +@@ -199,8 +199,10 @@ + + Compile the *source* into a code or AST object. Code objects can be executed + by an :keyword:`exec` statement or evaluated by a call to :func:`eval`. +- *source* can either be a string or an AST object. Refer to the :mod:`ast` +- module documentation for information on how to work with AST objects. ++ *source* can either be a Unicode string, a *Latin-1* encoded string or an ++ AST object. ++ Refer to the :mod:`ast` module documentation for information on how to work ++ with AST objects. + + The *filename* argument should give the file from which the code was read; + pass some recognizable value if it wasn't read from a file (``''`` is +@@ -388,9 +390,9 @@ + + .. function:: eval(expression[, globals[, locals]]) + +- The arguments are a string and optional globals and locals. If provided, +- *globals* must be a dictionary. If provided, *locals* can be any mapping +- object. ++ The arguments are a Unicode or *Latin-1* encoded string and optional ++ globals and locals. If provided, *globals* must be a dictionary. ++ If provided, *locals* can be any mapping object. + + .. versionchanged:: 2.4 + formerly *locals* was required to be a dictionary. +diff -r ab05e7dd2788 Doc/library/gc.rst +--- a/Doc/library/gc.rst ++++ b/Doc/library/gc.rst +@@ -132,8 +132,8 @@ + + Return a list of objects directly referred to by any of the arguments. The + referents returned are those objects visited by the arguments' C-level +- :attr:`tp_traverse` methods (if any), and may not be all objects actually +- directly reachable. :attr:`tp_traverse` methods are supported only by objects ++ :c:member:`~PyTypeObject.tp_traverse` methods (if any), and may not be all objects actually ++ directly reachable. :c:member:`~PyTypeObject.tp_traverse` methods are supported only by objects + that support garbage collection, and are only required to visit objects that may + be involved in a cycle. So, for example, if an integer is directly reachable + from an argument, that integer object may or may not appear in the result list. +diff -r ab05e7dd2788 Doc/library/gzip.rst +--- a/Doc/library/gzip.rst ++++ b/Doc/library/gzip.rst +@@ -33,7 +33,7 @@ + given a non-trivial value. + + The new class instance is based on *fileobj*, which can be a regular file, a +- :class:`StringIO` object, or any other object which simulates a file. It ++ :class:`~StringIO.StringIO` object, or any other object which simulates a file. It + defaults to ``None``, in which case *filename* is opened to provide a file + object. + +@@ -65,9 +65,9 @@ + + Calling a :class:`GzipFile` object's :meth:`close` method does not close + *fileobj*, since you might wish to append more material after the compressed +- data. This also allows you to pass a :class:`StringIO` object opened for ++ data. This also allows you to pass a :class:`~StringIO.StringIO` object opened for + writing as *fileobj*, and retrieve the resulting memory buffer using the +- :class:`StringIO` object's :meth:`getvalue` method. ++ :class:`StringIO` object's :meth:`~StringIO.StringIO.getvalue` method. + + :class:`GzipFile` supports iteration and the :keyword:`with` statement. + +diff -r ab05e7dd2788 Doc/library/heapq.rst +--- a/Doc/library/heapq.rst ++++ b/Doc/library/heapq.rst +@@ -260,7 +260,7 @@ + the sort is going on, provided that the inserted items are not "better" than the + last 0'th element you extracted. This is especially useful in simulation + contexts, where the tree holds all incoming events, and the "win" condition +-means the smallest scheduled time. When an event schedule other events for ++means the smallest scheduled time. When an event schedules other events for + execution, they are scheduled into the future, so they can easily go into the + heap. So, a heap is a good structure for implementing schedulers (this is what + I used for my MIDI sequencer :-). +diff -r ab05e7dd2788 Doc/library/idle.rst +--- a/Doc/library/idle.rst ++++ b/Doc/library/idle.rst +@@ -33,8 +33,8 @@ + File menu + ^^^^^^^^^ + +-New window +- create a new editing window ++New file ++ create a new file editing window + + Open... + open an existing file +diff -r ab05e7dd2788 Doc/library/json.rst +--- a/Doc/library/json.rst ++++ b/Doc/library/json.rst +@@ -348,6 +348,8 @@ + those with character codes in the 0-31 range, including ``'\t'`` (tab), + ``'\n'``, ``'\r'`` and ``'\0'``. + ++ If the data being deserialized is not a valid JSON document, a ++ :exc:`ValueError` will be raised. + + .. method:: decode(s) + +diff -r ab05e7dd2788 Doc/library/logging.config.rst +--- a/Doc/library/logging.config.rst ++++ b/Doc/library/logging.config.rst +@@ -17,6 +17,10 @@ + * :ref:`Advanced Tutorial ` + * :ref:`Logging Cookbook ` + ++**Source code:** :source:`Lib/logging/config.py` ++ ++-------------- ++ + This section describes the API for configuring the logging module. + + .. _logging-config-api: +@@ -104,8 +108,9 @@ + configurations. If no port is specified, the module's default + :const:`DEFAULT_LOGGING_CONFIG_PORT` is used. Logging configurations will be + sent as a file suitable for processing by :func:`fileConfig`. Returns a +- :class:`Thread` instance on which you can call :meth:`start` to start the +- server, and which you can :meth:`join` when appropriate. To stop the server, ++ :class:`~threading.Thread` instance on which you can call ++ :meth:`~threading.Thread.start` to start the server, and which you can ++ :meth:`~threading.Thread.join` when appropriate. To stop the server, + call :func:`stopListening`. + + To send a configuration to the socket, read in the configuration file and +@@ -169,11 +174,11 @@ + + * *formatters* - the corresponding value will be a dict in which each + key is a formatter id and each value is a dict describing how to +- configure the corresponding Formatter instance. ++ configure the corresponding :class:`~logging.Formatter` instance. + + The configuring dict is searched for keys ``format`` and ``datefmt`` + (with defaults of ``None``) and these are used to construct a +- :class:`logging.Formatter` instance. ++ :class:`~logging.Formatter` instance. + + * *filters* - the corresponding value will be a dict in which each key + is a filter id and each value is a dict describing how to configure +@@ -711,8 +716,9 @@ + + The ``class`` entry is optional. It indicates the name of the formatter's class + (as a dotted module and class name.) This option is useful for instantiating a +-:class:`Formatter` subclass. Subclasses of :class:`Formatter` can present +-exception tracebacks in an expanded or condensed format. ++:class:`~logging.Formatter` subclass. Subclasses of ++:class:`~logging.Formatter` can present exception tracebacks in an expanded or ++condensed format. + + .. note:: Due to the use of :func:`eval` as described above, there are + potential security risks which result from using the :func:`listen` to send +diff -r ab05e7dd2788 Doc/library/logging.handlers.rst +--- a/Doc/library/logging.handlers.rst ++++ b/Doc/library/logging.handlers.rst +@@ -17,6 +17,10 @@ + * :ref:`Advanced Tutorial ` + * :ref:`Logging Cookbook ` + ++**Source code:** :source:`Lib/logging/handlers.py` ++ ++-------------- ++ + .. currentmodule:: logging + + The following useful handlers are provided in the package. Note that three of +@@ -53,8 +57,8 @@ + .. method:: flush() + + Flushes the stream by calling its :meth:`flush` method. Note that the +- :meth:`close` method is inherited from :class:`Handler` and so does +- no output, so an explicit :meth:`flush` call may be needed at times. ++ :meth:`close` method is inherited from :class:`~logging.Handler` and so ++ does no output, so an explicit :meth:`flush` call may be needed at times. + + .. _file-handler: + +@@ -142,8 +146,8 @@ + This handler is not appropriate for use under Windows, because under Windows + open log files cannot be moved or renamed - logging opens the files with + exclusive locks - and so there is no need for such a handler. Furthermore, +-*ST_INO* is not supported under Windows; :func:`stat` always returns zero for +-this value. ++*ST_INO* is not supported under Windows; :func:`~os.stat` always returns zero ++for this value. + + + .. class:: WatchedFileHandler(filename[,mode[, encoding[, delay]]]) +@@ -305,7 +309,8 @@ + binary format. If there is an error with the socket, silently drops the + packet. If the connection was previously lost, re-establishes the + connection. To unpickle the record at the receiving end into a +- :class:`LogRecord`, use the :func:`makeLogRecord` function. ++ :class:`~logging.LogRecord`, use the :func:`~logging.makeLogRecord` ++ function. + + + .. method:: handleError() +@@ -383,7 +388,8 @@ + Pickles the record's attribute dictionary and writes it to the socket in + binary format. If there is an error with the socket, silently drops the + packet. To unpickle the record at the receiving end into a +- :class:`LogRecord`, use the :func:`makeLogRecord` function. ++ :class:`~logging.LogRecord`, use the :func:`~logging.makeLogRecord` ++ function. + + + .. method:: makeSocket() +diff -r ab05e7dd2788 Doc/library/logging.rst +--- a/Doc/library/logging.rst ++++ b/Doc/library/logging.rst +@@ -20,6 +20,9 @@ + * :ref:`Advanced Tutorial ` + * :ref:`Logging Cookbook ` + ++**Source code:** :source:`Lib/logging/__init__.py` ++ ++-------------- + + .. versionadded:: 2.3 + +diff -r ab05e7dd2788 Doc/library/mailbox.rst +--- a/Doc/library/mailbox.rst ++++ b/Doc/library/mailbox.rst +@@ -661,7 +661,7 @@ + + In Babyl mailboxes, the headers of a message are not stored contiguously + with the body of the message. To generate a file-like representation, the +- headers and body are copied together into a :class:`StringIO` instance ++ headers and body are copied together into a :class:`~StringIO.StringIO` instance + (from the :mod:`StringIO` module), which has an API identical to that of a + file. As a result, the file-like object is truly independent of the + underlying mailbox but does not save memory compared to a string +diff -r ab05e7dd2788 Doc/library/mimewriter.rst +--- a/Doc/library/mimewriter.rst ++++ b/Doc/library/mimewriter.rst +@@ -24,7 +24,7 @@ + + Return a new instance of the :class:`MimeWriter` class. The only argument + passed, *fp*, is a file object to be used for writing. Note that a +- :class:`StringIO` object could also be used. ++ :class:`~StringIO.StringIO` object could also be used. + + + .. _mimewriter-objects: +diff -r ab05e7dd2788 Doc/library/mmap.rst +--- a/Doc/library/mmap.rst ++++ b/Doc/library/mmap.rst +@@ -152,8 +152,9 @@ + + .. method:: close() + +- Close the file. Subsequent calls to other methods of the object will +- result in an exception being raised. ++ Closes the mmap. Subsequent calls to other methods of the object will ++ result in a ValueError exception being raised. This will not close ++ the open file. + + + .. method:: find(string[, start[, end]]) +diff -r ab05e7dd2788 Doc/library/multiprocessing.rst +--- a/Doc/library/multiprocessing.rst ++++ b/Doc/library/multiprocessing.rst +@@ -287,6 +287,9 @@ + print result.get(timeout=1) # prints "100" unless your computer is *very* slow + print pool.map(f, range(10)) # prints "[0, 1, 4,..., 81]" + ++Note that the methods of a pool should only ever be used by the ++process which created it. ++ + + Reference + --------- +@@ -379,7 +382,7 @@ + Unix daemons or services, they are normal processes that will be + terminated (and not joined) if non-daemonic processes have exited. + +- In addition to the :class:`Threading.Thread` API, :class:`Process` objects ++ In addition to the :class:`threading.Thread` API, :class:`Process` objects + also support the following attributes and methods: + + .. attribute:: pid +@@ -398,7 +401,7 @@ + The process's authentication key (a byte string). + + When :mod:`multiprocessing` is initialized the main process is assigned a +- random string using :func:`os.random`. ++ random string using :func:`os.urandom`. + + When a :class:`Process` object is created, it will inherit the + authentication key of its parent process, although this may be changed by +@@ -423,9 +426,9 @@ + acquired a lock or semaphore etc. then terminating it is liable to + cause other processes to deadlock. + +- Note that the :meth:`start`, :meth:`join`, :meth:`is_alive` and +- :attr:`exit_code` methods should only be called by the process that created +- the process object. ++ Note that the :meth:`start`, :meth:`join`, :meth:`is_alive`, ++ :meth:`terminate` and :attr:`exitcode` methods should only be called by ++ the process that created the process object. + + Example usage of some of the methods of :class:`Process`: + +@@ -486,6 +489,24 @@ + the :mod:`multiprocessing` namespace so you need to import them from + :mod:`Queue`. + ++.. note:: ++ ++ When an object is put on a queue, the object is pickled and a ++ background thread later flushes the pickled data to an underlying ++ pipe. This has some consequences which are a little surprising, ++ but should not cause any practical difficulties -- if they really ++ bother you then you can instead use a queue created with a ++ :ref:`manager `. ++ ++ (1) After putting an object on an empty queue there may be an ++ infinitesimal delay before the queue's :meth:`~Queue.empty` ++ method returns :const:`False` and :meth:`~Queue.get_nowait` can ++ return without raising :exc:`Queue.Empty`. ++ ++ (2) If multiple processes are enqueuing objects, it is possible for ++ the objects to be received at the other end out-of-order. ++ However, objects enqueued by the same process will always be in ++ the expected order with respect to each other. + + .. warning:: + +@@ -497,7 +518,8 @@ + .. warning:: + + As mentioned above, if a child process has put items on a queue (and it has +- not used :meth:`JoinableQueue.cancel_join_thread`), then that process will ++ not used :meth:`JoinableQueue.cancel_join_thread ++ `), then that process will + not terminate until all buffered items have been flushed to the pipe. + + This means that if you try joining that process you may get a deadlock unless +@@ -609,6 +631,13 @@ + the background thread from being joined automatically when the process + exits -- see :meth:`join_thread`. + ++ A better name for this method might be ++ ``allow_exit_without_flush()``. It is likely to cause enqueued ++ data to lost, and you almost certainly will not need to use it. ++ It is really only there if you need the current process to exit ++ immediately without waiting to flush enqueued data to the ++ underlying pipe, and you don't care about lost data. ++ + + .. class:: multiprocessing.queues.SimpleQueue() + +@@ -639,7 +668,7 @@ + call to :meth:`task_done` tells the queue that the processing on the task + is complete. + +- If a :meth:`~Queue.join` is currently blocking, it will resume when all ++ If a :meth:`~Queue.Queue.join` is currently blocking, it will resume when all + items have been processed (meaning that a :meth:`task_done` call was + received for every item that had been :meth:`~Queue.put` into the queue). + +@@ -655,7 +684,7 @@ + queue. The count goes down whenever a consumer thread calls + :meth:`task_done` to indicate that the item was retrieved and all work on + it is complete. When the count of unfinished tasks drops to zero, +- :meth:`~Queue.join` unblocks. ++ :meth:`~Queue.Queue.join` unblocks. + + + Miscellaneous +@@ -1021,8 +1050,9 @@ + array. + + If *lock* is ``True`` (the default) then a new lock object is created to +- synchronize access to the value. If *lock* is a :class:`Lock` or +- :class:`RLock` object then that will be used to synchronize access to the ++ synchronize access to the value. If *lock* is a ++ :class:`~multiprocessing.Lock` or :class:`~multiprocessing.RLock` object ++ then that will be used to synchronize access to the + value. If *lock* is ``False`` then access to the returned object will not be + automatically protected by a lock, so it will not necessarily be + "process-safe". +@@ -1036,8 +1066,8 @@ + object. + + If *lock* is ``True`` (the default) then a new lock object is created to +- synchronize access to the value. If *lock* is a :class:`Lock` or +- :class:`RLock` object then that will be used to synchronize access to the ++ synchronize access to the value. If *lock* is a :class:`~multiprocessing.Lock` or ++ :class:`~multiprocessing.RLock` object then that will be used to synchronize access to the + value. If *lock* is ``False`` then access to the returned object will not be + automatically protected by a lock, so it will not necessarily be + "process-safe". +@@ -1219,8 +1249,8 @@ + :attr:`proxytype._exposed_` is used instead if it exists.) In the case + where no exposed list is specified, all "public methods" of the shared + object will be accessible. (Here a "public method" means any attribute +- which has a :meth:`__call__` method and whose name does not begin with +- ``'_'``.) ++ which has a :meth:`~object.__call__` method and whose name does not begin ++ with ``'_'``.) + + *method_to_typeid* is a mapping used to specify the return type of those + exposed methods which should return a proxy. It maps method names to +@@ -1581,6 +1611,9 @@ + *initializer* is not ``None`` then each worker process will call + ``initializer(*initargs)`` when it starts. + ++ Note that the methods of the pool object should only be called by ++ the process which created the pool. ++ + .. versionadded:: 2.7 + *maxtasksperchild* is the number of tasks a worker process can complete + before it will exit and be replaced with a fresh worker process, to enable +@@ -1727,7 +1760,8 @@ + :synopsis: API for dealing with sockets. + + Usually message passing between processes is done using queues or by using +-:class:`Connection` objects returned by :func:`Pipe`. ++:class:`~multiprocessing.Connection` objects returned by ++:func:`~multiprocessing.Pipe`. + + However, the :mod:`multiprocessing.connection` module allows some extra + flexibility. It basically gives a high level message oriented API for dealing +@@ -1793,7 +1827,8 @@ + private temporary directory created using :func:`tempfile.mkstemp`. + + If the listener object uses a socket then *backlog* (1 by default) is passed +- to the :meth:`listen` method of the socket once it has been bound. ++ to the :meth:`~socket.socket.listen` method of the socket once it has been ++ bound. + + If *authenticate* is ``True`` (``False`` by default) or *authkey* is not + ``None`` then digest authentication is used. +@@ -1810,8 +1845,9 @@ + .. method:: accept() + + Accept a connection on the bound socket or named pipe of the listener +- object and return a :class:`Connection` object. If authentication is +- attempted and fails, then :exc:`AuthenticationError` is raised. ++ object and return a :class:`~multiprocessing.Connection` object. If ++ authentication is attempted and fails, then ++ :exc:`~multiprocessing.AuthenticationError` is raised. + + .. method:: close() + +@@ -1907,7 +1943,8 @@ + Authentication keys + ~~~~~~~~~~~~~~~~~~~ + +-When one uses :meth:`Connection.recv`, the data received is automatically ++When one uses :meth:`Connection.recv `, the ++data received is automatically + unpickled. Unfortunately unpickling data from an untrusted source is a security + risk. Therefore :class:`Listener` and :func:`Client` use the :mod:`hmac` module + to provide digest authentication. +@@ -2056,9 +2093,10 @@ + + On Unix when a process finishes but has not been joined it becomes a zombie. + There should never be very many because each time a new process starts (or +- :func:`active_children` is called) all completed processes which have not +- yet been joined will be joined. Also calling a finished process's +- :meth:`Process.is_alive` will join the process. Even so it is probably good ++ :func:`~multiprocessing.active_children` is called) all completed processes ++ which have not yet been joined will be joined. Also calling a finished ++ process's :meth:`Process.is_alive ` will ++ join the process. Even so it is probably good + practice to explicitly join all the processes that you start. + + Better to inherit than pickle/unpickle +@@ -2071,13 +2109,15 @@ + + Avoid terminating processes + +- Using the :meth:`Process.terminate` method to stop a process is liable to ++ Using the :meth:`Process.terminate ` ++ method to stop a process is liable to + cause any shared resources (such as locks, semaphores, pipes and queues) + currently being used by the process to become broken or unavailable to other + processes. + + Therefore it is probably best to only consider using +- :meth:`Process.terminate` on processes which never use any shared resources. ++ :meth:`Process.terminate ` on processes ++ which never use any shared resources. + + Joining processes that use queues + +@@ -2161,7 +2201,7 @@ + resulting in a bad file descriptor error, but introduces a potential danger + to applications which replace :func:`sys.stdin` with a "file-like object" + with output buffering. This danger is that if multiple processes call +- :func:`close()` on this file-like object, it could result in the same ++ :meth:`~io.IOBase.close()` on this file-like object, it could result in the same + data being flushed to the object multiple times, resulting in corruption. + + If you write a file-like object and implement your own caching, you can +@@ -2190,14 +2230,16 @@ + as the ``target`` argument on Windows --- just define a function and use + that instead. + +- Also, if you subclass :class:`Process` then make sure that instances will be +- picklable when the :meth:`Process.start` method is called. ++ Also, if you subclass :class:`~multiprocessing.Process` then make sure that ++ instances will be picklable when the :meth:`Process.start ++ ` method is called. + + Global variables + + Bear in mind that if code run in a child process tries to access a global + variable, then the value it sees (if any) may not be the same as the value +- in the parent process at the time that :meth:`Process.start` was called. ++ in the parent process at the time that :meth:`Process.start ++ ` was called. + + However, global variables which are just module level constants cause no + problems. +@@ -2252,7 +2294,7 @@ + .. literalinclude:: ../includes/mp_newtype.py + + +-Using :class:`Pool`: ++Using :class:`~multiprocessing.pool.Pool`: + + .. literalinclude:: ../includes/mp_pool.py + +diff -r ab05e7dd2788 Doc/library/netrc.rst +--- a/Doc/library/netrc.rst ++++ b/Doc/library/netrc.rst +@@ -25,6 +25,12 @@ + no argument is given, the file :file:`.netrc` in the user's home directory will + be read. Parse errors will raise :exc:`NetrcParseError` with diagnostic + information including the file name, line number, and terminating token. ++ If no argument is specified on a POSIX system, the presence of passwords in ++ the :file:`.netrc` file will raise a :exc:`NetrcParseError` if the file ++ ownership or permissions are insecure (owned by a user other than the user ++ running the process, or accessible for read or write by any other user). ++ This implements security behavior equivalent to that of ftp and other ++ programs that use :file:`.netrc`. + + + .. exception:: NetrcParseError +diff -r ab05e7dd2788 Doc/library/os.path.rst +--- a/Doc/library/os.path.rst ++++ b/Doc/library/os.path.rst +@@ -236,8 +236,10 @@ + + .. function:: relpath(path[, start]) + +- Return a relative filepath to *path* either from the current directory or from +- an optional *start* point. ++ Return a relative filepath to *path* either from the current directory or ++ from an optional *start* directory. This is a path computation: the ++ filesystem is not accessed to confirm the existence or nature of *path* or ++ *start*. + + *start* defaults to :attr:`os.curdir`. + +diff -r ab05e7dd2788 Doc/library/os.rst +--- a/Doc/library/os.rst ++++ b/Doc/library/os.rst +@@ -737,8 +737,6 @@ + Return ``True`` if the file descriptor *fd* is open and connected to a + tty(-like) device, else ``False``. + +- Availability: Unix. +- + + .. function:: lseek(fd, pos, how) + +diff -r ab05e7dd2788 Doc/library/profile.rst +--- a/Doc/library/profile.rst ++++ b/Doc/library/profile.rst +@@ -267,14 +267,16 @@ + Directly using the :class:`Profile` class allows formatting profile results + without writing the profile data to a file:: + +- import cProfile, pstats, io ++ import cProfile, pstats, StringIO + pr = cProfile.Profile() + pr.enable() +- ... do something ... ++ # ... do something ... + pr.disable() +- s = io.StringIO() +- ps = pstats.Stats(pr, stream=s) +- ps.print_results() ++ s = StringIO.StringIO() ++ sortby = 'cumulative' ++ ps = pstats.Stats(pr, stream=s).sort_stats(sortby) ++ ps.print_stats() ++ print s.getvalue() + + .. method:: enable() + +diff -r ab05e7dd2788 Doc/library/queue.rst +--- a/Doc/library/queue.rst ++++ b/Doc/library/queue.rst +@@ -60,13 +60,15 @@ + + .. exception:: Empty + +- Exception raised when non-blocking :meth:`get` (or :meth:`get_nowait`) is called ++ Exception raised when non-blocking :meth:`~Queue.get` (or ++ :meth:`~Queue.get_nowait`) is called + on a :class:`Queue` object which is empty. + + + .. exception:: Full + +- Exception raised when non-blocking :meth:`put` (or :meth:`put_nowait`) is called ++ Exception raised when non-blocking :meth:`~Queue.put` (or ++ :meth:`~Queue.put_nowait`) is called + on a :class:`Queue` object which is full. + + .. seealso:: +diff -r ab05e7dd2788 Doc/library/random.rst +--- a/Doc/library/random.rst ++++ b/Doc/library/random.rst +@@ -60,6 +60,13 @@ + uses the system function :func:`os.urandom` to generate random numbers + from sources provided by the operating system. + ++.. warning:: ++ ++ The pseudo-random generators of this module should not be used for ++ security purposes. Use :func:`os.urandom` or :class:`SystemRandom` if ++ you require a cryptographically secure pseudo-random number generator. ++ ++ + Bookkeeping functions: + + +diff -r ab05e7dd2788 Doc/library/select.rst +--- a/Doc/library/select.rst ++++ b/Doc/library/select.rst +@@ -63,7 +63,7 @@ + This is a straightforward interface to the Unix :c:func:`select` system call. + The first three arguments are sequences of 'waitable objects': either + integers representing file descriptors or objects with a parameterless method +- named :meth:`fileno` returning such an integer: ++ named :meth:`~io.IOBase.fileno` returning such an integer: + + * *rlist*: wait until ready for reading + * *wlist*: wait until ready for writing +@@ -88,8 +88,8 @@ + Among the acceptable object types in the sequences are Python file objects (e.g. + ``sys.stdin``, or objects returned by :func:`open` or :func:`os.popen`), socket + objects returned by :func:`socket.socket`. You may also define a :dfn:`wrapper` +- class yourself, as long as it has an appropriate :meth:`fileno` method (that +- really returns a file descriptor, not just a random integer). ++ class yourself, as long as it has an appropriate :meth:`~io.IOBase.fileno` ++ method (that really returns a file descriptor, not just a random integer). + + .. note:: + +@@ -207,10 +207,10 @@ + .. method:: poll.register(fd[, eventmask]) + + Register a file descriptor with the polling object. Future calls to the +- :meth:`poll` method will then check whether the file descriptor has any pending +- I/O events. *fd* can be either an integer, or an object with a :meth:`fileno` +- method that returns an integer. File objects implement :meth:`fileno`, so they +- can also be used as the argument. ++ :meth:`poll` method will then check whether the file descriptor has any ++ pending I/O events. *fd* can be either an integer, or an object with a ++ :meth:`~io.IOBase.fileno` method that returns an integer. File objects ++ implement :meth:`!fileno`, so they can also be used as the argument. + + *eventmask* is an optional bitmask describing the type of events you want to + check for, and can be a combination of the constants :const:`POLLIN`, +@@ -251,7 +251,7 @@ + + Remove a file descriptor being tracked by a polling object. Just like the + :meth:`register` method, *fd* can be an integer or an object with a +- :meth:`fileno` method that returns an integer. ++ :meth:`~io.IOBase.fileno` method that returns an integer. + + Attempting to remove a file descriptor that was never registered causes a + :exc:`KeyError` exception to be raised. +diff -r ab05e7dd2788 Doc/library/smtplib.rst +--- a/Doc/library/smtplib.rst ++++ b/Doc/library/smtplib.rst +@@ -24,12 +24,15 @@ + + A :class:`SMTP` instance encapsulates an SMTP connection. It has methods + that support a full repertoire of SMTP and ESMTP operations. If the optional +- host and port parameters are given, the SMTP :meth:`connect` method is called +- with those parameters during initialization. If the :meth:`connect` call +- returns anything other than a success code, an :exc:`SMTPConnectError` is +- raised. The optional *timeout* parameter specifies a timeout in seconds for +- blocking operations like the connection attempt (if not specified, the +- global default timeout setting will be used). ++ host and port parameters are given, the SMTP :meth:`connect` method is ++ called with those parameters during initialization. If specified, ++ *local_hostname* is used as the FQDN of the local host in the HELO/EHLO ++ command. Otherwise, the local hostname is found using ++ :func:`socket.getfqdn`. If the :meth:`connect` call returns anything other ++ than a success code, an :exc:`SMTPConnectError` is raised. The optional ++ *timeout* parameter specifies a timeout in seconds for blocking operations ++ like the connection attempt (if not specified, the global default timeout ++ setting will be used). + + For normal use, you should only require the initialization/connect, + :meth:`sendmail`, and :meth:`~smtplib.quit` methods. +@@ -45,12 +48,13 @@ + :class:`SMTP`. :class:`SMTP_SSL` should be used for situations where SSL is + required from the beginning of the connection and using :meth:`starttls` is + not appropriate. If *host* is not specified, the local host is used. If +- *port* is omitted, the standard SMTP-over-SSL port (465) is used. *keyfile* +- and *certfile* are also optional, and can contain a PEM formatted private key +- and certificate chain file for the SSL connection. The optional *timeout* +- parameter specifies a timeout in seconds for blocking operations like the +- connection attempt (if not specified, the global default timeout setting +- will be used). ++ *port* is omitted, the standard SMTP-over-SSL port (465) is used. ++ *local_hostname* has the same meaning as it does for the :class:`SMTP` ++ class. *keyfile* and *certfile* are also optional, and can contain a PEM ++ formatted private key and certificate chain file for the SSL connection. The ++ optional *timeout* parameter specifies a timeout in seconds for blocking ++ operations like the connection attempt (if not specified, the global default ++ timeout setting will be used). + + .. versionadded:: 2.6 + +@@ -58,13 +62,15 @@ + .. class:: LMTP([host[, port[, local_hostname]]]) + + The LMTP protocol, which is very similar to ESMTP, is heavily based on the +- standard SMTP client. It's common to use Unix sockets for LMTP, so our :meth:`connect` +- method must support that as well as a regular host:port server. To specify a +- Unix socket, you must use an absolute path for *host*, starting with a '/'. ++ standard SMTP client. It's common to use Unix sockets for LMTP, so our ++ :meth:`connect` method must support that as well as a regular host:port ++ server. *local_hostname* has the same meaning as it does for the ++ :class:`SMTP` class. To specify a Unix socket, you must use an absolute ++ path for *host*, starting with a '/'. + +- Authentication is supported, using the regular SMTP mechanism. When using a Unix +- socket, LMTP generally don't support or require any authentication, but your +- mileage might vary. ++ Authentication is supported, using the regular SMTP mechanism. When using a ++ Unix socket, LMTP generally don't support or require any authentication, but ++ your mileage might vary. + + .. versionadded:: 2.6 + +@@ -73,7 +79,7 @@ + + .. exception:: SMTPException + +- The base exception class for all the other excpetions provided by this ++ The base exception class for all the other exceptions provided by this + module. + + +diff -r ab05e7dd2788 Doc/library/stdtypes.rst +--- a/Doc/library/stdtypes.rst ++++ b/Doc/library/stdtypes.rst +@@ -614,7 +614,7 @@ + iterators for those iteration types. (An example of an object supporting + multiple forms of iteration would be a tree structure which supports both + breadth-first and depth-first traversal.) This method corresponds to the +- :attr:`tp_iter` slot of the type structure for Python objects in the Python/C ++ :c:member:`~PyTypeObject.tp_iter` slot of the type structure for Python objects in the Python/C + API. + + The iterator objects themselves are required to support the following two +@@ -625,7 +625,7 @@ + + Return the iterator object itself. This is required to allow both containers + and iterators to be used with the :keyword:`for` and :keyword:`in` statements. +- This method corresponds to the :attr:`tp_iter` slot of the type structure for ++ This method corresponds to the :c:member:`~PyTypeObject.tp_iter` slot of the type structure for + Python objects in the Python/C API. + + +@@ -633,7 +633,7 @@ + + Return the next item from the container. If there are no further items, raise + the :exc:`StopIteration` exception. This method corresponds to the +- :attr:`tp_iternext` slot of the type structure for Python objects in the ++ :c:member:`~PyTypeObject.tp_iternext` slot of the type structure for Python objects in the + Python/C API. + + Python defines several iterator objects to support iteration over general and +@@ -743,10 +743,10 @@ + +------------------+--------------------------------+----------+ + | ``max(s)`` | largest item of *s* | | + +------------------+--------------------------------+----------+ +-| ``s.index(i)`` | index of the first occurence | | ++| ``s.index(i)`` | index of the first occurrence | | + | | of *i* in *s* | | + +------------------+--------------------------------+----------+ +-| ``s.count(i)`` | total number of occurences of | | ++| ``s.count(i)`` | total number of occurrences of | | + | | *i* in *s* | | + +------------------+--------------------------------+----------+ + +diff -r ab05e7dd2788 Doc/library/subprocess.rst +--- a/Doc/library/subprocess.rst ++++ b/Doc/library/subprocess.rst +@@ -74,7 +74,7 @@ + Run command with arguments. Wait for command to complete. If the return + code was zero then return, otherwise raise :exc:`CalledProcessError`. The + :exc:`CalledProcessError` object will have the return code in the +- :attr:`returncode` attribute. ++ :attr:`~CalledProcessError.returncode` attribute. + + The arguments shown above are merely the most common ones, described below + in :ref:`frequently-used-arguments` (hence the slightly odd notation in +@@ -114,8 +114,8 @@ + + If the return code was non-zero it raises a :exc:`CalledProcessError`. The + :exc:`CalledProcessError` object will have the return code in the +- :attr:`returncode` attribute and any output in the :attr:`output` +- attribute. ++ :attr:`~CalledProcessError.returncode` attribute and any output in the ++ :attr:`~CalledProcessError.output` attribute. + + The arguments shown above are merely the most common ones, described below + in :ref:`frequently-used-arguments` (hence the slightly odd notation in +@@ -462,14 +462,14 @@ + + .. method:: Popen.poll() + +- Check if child process has terminated. Set and return :attr:`returncode` +- attribute. ++ Check if child process has terminated. Set and return ++ :attr:`~Popen.returncode` attribute. + + + .. method:: Popen.wait() + +- Wait for child process to terminate. Set and return :attr:`returncode` +- attribute. ++ Wait for child process to terminate. Set and return ++ :attr:`~Popen.returncode` attribute. + + .. warning:: + +@@ -695,8 +695,8 @@ + + In addition, the replacements using :func:`check_output` will fail with a + :exc:`CalledProcessError` if the requested operation produces a non-zero +- return code. The output is still available as the ``output`` attribute of +- the raised exception. ++ return code. The output is still available as the ++ :attr:`~CalledProcessError.output` attribute of the raised exception. + + In the following examples, we assume that the relevant functions have already + been imported from the :mod:`subprocess` module. +diff -r ab05e7dd2788 Doc/library/tempfile.rst +--- a/Doc/library/tempfile.rst ++++ b/Doc/library/tempfile.rst +@@ -93,7 +93,7 @@ + causes the file to roll over to an on-disk file regardless of its size. + + The returned object is a file-like object whose :attr:`_file` attribute +- is either a :class:`StringIO` object or a true file object, depending on ++ is either a :class:`~StringIO.StringIO` object or a true file object, depending on + whether :func:`rollover` has been called. This file-like object can be + used in a :keyword:`with` statement, just like a normal file. + +diff -r ab05e7dd2788 Doc/library/threading.rst +--- a/Doc/library/threading.rst ++++ b/Doc/library/threading.rst +@@ -167,7 +167,7 @@ + + Set a trace function for all threads started from the :mod:`threading` module. + The *func* will be passed to :func:`sys.settrace` for each thread, before its +- :meth:`run` method is called. ++ :meth:`~Thread.run` method is called. + + .. versionadded:: 2.3 + +@@ -178,7 +178,7 @@ + + Set a profile function for all threads started from the :mod:`threading` module. + The *func* will be passed to :func:`sys.setprofile` for each thread, before its +- :meth:`run` method is called. ++ :meth:`~Thread.run` method is called. + + .. versionadded:: 2.3 + +@@ -742,10 +742,11 @@ + of time has passed --- a timer. :class:`Timer` is a subclass of :class:`Thread` + and as such also functions as an example of creating custom threads. + +-Timers are started, as with threads, by calling their :meth:`start` method. The +-timer can be stopped (before its action has begun) by calling the :meth:`cancel` +-method. The interval the timer will wait before executing its action may not be +-exactly the same as the interval specified by the user. ++Timers are started, as with threads, by calling their :meth:`~Timer.start` ++method. The timer can be stopped (before its action has begun) by calling the ++:meth:`~Timer.cancel` method. The interval the timer will wait before ++executing its action may not be exactly the same as the interval specified by ++the user. + + For example:: + +diff -r ab05e7dd2788 Doc/library/unittest.rst +--- a/Doc/library/unittest.rst ++++ b/Doc/library/unittest.rst +@@ -916,8 +916,8 @@ + | :meth:`assertRaises(exc, fun, *args, **kwds) | ``fun(*args, **kwds)`` raises *exc* | | + | ` | | | + +---------------------------------------------------------+--------------------------------------+------------+ +- | :meth:`assertRaisesRegexp(exc, re, fun, *args, **kwds) | ``fun(*args, **kwds)`` raises *exc* | 2.7 | +- | ` | and the message matches *re* | | ++ | :meth:`assertRaisesRegexp(exc, r, fun, *args, **kwds) | ``fun(*args, **kwds)`` raises *exc* | 2.7 | ++ | ` | and the message matches regex *r* | | + +---------------------------------------------------------+--------------------------------------+------------+ + + .. method:: assertRaises(exception, callable, *args, **kwds) +@@ -958,7 +958,7 @@ + a regular expression object or a string containing a regular expression + suitable for use by :func:`re.search`. Examples:: + +- self.assertRaisesRegexp(ValueError, 'invalid literal for.*XYZ$', ++ self.assertRaisesRegexp(ValueError, "invalid literal for.*XYZ'$", + int, 'XYZ') + + or:: +@@ -993,10 +993,10 @@ + | :meth:`assertLessEqual(a, b) | ``a <= b`` | 2.7 | + | ` | | | + +---------------------------------------+--------------------------------+--------------+ +- | :meth:`assertRegexpMatches(s, re) | ``regex.search(s)`` | 2.7 | ++ | :meth:`assertRegexpMatches(s, r) | ``r.search(s)`` | 2.7 | + | ` | | | + +---------------------------------------+--------------------------------+--------------+ +- | :meth:`assertNotRegexpMatches(s, re) | ``not regex.search(s)`` | 2.7 | ++ | :meth:`assertNotRegexpMatches(s, r) | ``not r.search(s)`` | 2.7 | + | ` | | | + +---------------------------------------+--------------------------------+--------------+ + | :meth:`assertItemsEqual(a, b) | sorted(a) == sorted(b) and | 2.7 | +@@ -1017,7 +1017,7 @@ + like the :func:`round` function) and not *significant digits*. + + If *delta* is supplied instead of *places* then the difference +- between *first* and *second* must be less (or more) than *delta*. ++ between *first* and *second* must be less or equal to (or greater than) *delta*. + + Supplying both *delta* and *places* raises a ``TypeError``. + +@@ -1603,8 +1603,7 @@ + + A list containing 2-tuples of :class:`TestCase` instances and strings + holding formatted tracebacks. Each tuple represents a test where a failure +- was explicitly signalled using the :meth:`TestCase.fail\*` or +- :meth:`TestCase.assert\*` methods. ++ was explicitly signalled using the :meth:`TestCase.assert\*` methods. + + .. versionchanged:: 2.2 + Contains formatted tracebacks instead of :func:`sys.exc_info` results. +@@ -1704,7 +1703,7 @@ + + .. method:: addError(test, err) + +- Called when the test case *test* raises an unexpected exception *err* is a ++ Called when the test case *test* raises an unexpected exception. *err* is a + tuple of the form returned by :func:`sys.exc_info`: ``(type, value, + traceback)``. + +diff -r ab05e7dd2788 Doc/library/xml.dom.minidom.rst +--- a/Doc/library/xml.dom.minidom.rst ++++ b/Doc/library/xml.dom.minidom.rst +@@ -58,7 +58,7 @@ + .. function:: parseString(string[, parser]) + + Return a :class:`Document` that represents the *string*. This method creates a +- :class:`StringIO` object for the string and passes that on to :func:`parse`. ++ :class:`~StringIO.StringIO` object for the string and passes that on to :func:`parse`. + + Both functions return a :class:`Document` object representing the content of the + document. +diff -r ab05e7dd2788 Doc/library/xml.dom.rst +--- a/Doc/library/xml.dom.rst ++++ b/Doc/library/xml.dom.rst +@@ -441,14 +441,15 @@ + + In addition, the Python DOM interface requires that some additional support is + provided to allow :class:`NodeList` objects to be used as Python sequences. All +-:class:`NodeList` implementations must include support for :meth:`__len__` and +-:meth:`__getitem__`; this allows iteration over the :class:`NodeList` in ++:class:`NodeList` implementations must include support for ++:meth:`~object.__len__` and ++:meth:`~object.__getitem__`; this allows iteration over the :class:`NodeList` in + :keyword:`for` statements and proper support for the :func:`len` built-in + function. + + If a DOM implementation supports modification of the document, the +-:class:`NodeList` implementation must also support the :meth:`__setitem__` and +-:meth:`__delitem__` methods. ++:class:`NodeList` implementation must also support the ++:meth:`~object.__setitem__` and :meth:`~object.__delitem__` methods. + + + .. _dom-documenttype-objects: +diff -r ab05e7dd2788 Doc/library/xml.etree.elementtree.rst +--- a/Doc/library/xml.etree.elementtree.rst ++++ b/Doc/library/xml.etree.elementtree.rst +@@ -680,8 +680,9 @@ + or contents. + + :class:`Element` objects also support the following sequence type methods +- for working with subelements: :meth:`__delitem__`, :meth:`__getitem__`, +- :meth:`__setitem__`, :meth:`__len__`. ++ for working with subelements: :meth:`~object.__delitem__`, ++ :meth:`~object.__getitem__`, :meth:`~object.__setitem__`, ++ :meth:`~object.__len__`. + + Caution: Elements with no subelements will test as ``False``. This behavior + will change in future versions. Use specific ``len(elem)`` or ``elem is +diff -r ab05e7dd2788 Doc/library/xml.sax.handler.rst +--- a/Doc/library/xml.sax.handler.rst ++++ b/Doc/library/xml.sax.handler.rst +@@ -240,7 +240,8 @@ + Signals the start of an element in non-namespace mode. + + The *name* parameter contains the raw XML 1.0 name of the element type as a +- string and the *attrs* parameter holds an object of the :class:`Attributes` ++ string and the *attrs* parameter holds an object of the ++ :class:`~xml.sax.xmlreader.Attributes` + interface (see :ref:`attributes-objects`) containing the attributes of + the element. The object passed as *attrs* may be re-used by the parser; holding + on to a reference to it is not a reliable way to keep a copy of the attributes. +@@ -263,7 +264,8 @@ + The *name* parameter contains the name of the element type as a ``(uri, + localname)`` tuple, the *qname* parameter contains the raw XML 1.0 name used in + the source document, and the *attrs* parameter holds an instance of the +- :class:`AttributesNS` interface (see :ref:`attributes-ns-objects`) ++ :class:`~xml.sax.xmlreader.AttributesNS` interface (see ++ :ref:`attributes-ns-objects`) + containing the attributes of the element. If no namespace is associated with + the element, the *uri* component of *name* will be ``None``. The object passed + as *attrs* may be re-used by the parser; holding on to a reference to it is not +@@ -379,8 +381,9 @@ + -------------------- + + Objects with this interface are used to receive error and warning information +-from the :class:`XMLReader`. If you create an object that implements this +-interface, then register the object with your :class:`XMLReader`, the parser ++from the :class:`~xml.sax.xmlreader.XMLReader`. If you create an object that ++implements this interface, then register the object with your ++:class:`~xml.sax.xmlreader.XMLReader`, the parser + will call the methods in your object to report all warnings and errors. There + are three levels of errors available: warnings, (possibly) recoverable errors, + and unrecoverable errors. All methods take a :exc:`SAXParseException` as the +diff -r ab05e7dd2788 Doc/library/xml.sax.reader.rst +--- a/Doc/library/xml.sax.reader.rst ++++ b/Doc/library/xml.sax.reader.rst +@@ -109,47 +109,50 @@ + + .. method:: XMLReader.getContentHandler() + +- Return the current :class:`ContentHandler`. ++ Return the current :class:`~xml.sax.handler.ContentHandler`. + + + .. method:: XMLReader.setContentHandler(handler) + +- Set the current :class:`ContentHandler`. If no :class:`ContentHandler` is set, +- content events will be discarded. ++ Set the current :class:`~xml.sax.handler.ContentHandler`. If no ++ :class:`~xml.sax.handler.ContentHandler` is set, content events will be ++ discarded. + + + .. method:: XMLReader.getDTDHandler() + +- Return the current :class:`DTDHandler`. ++ Return the current :class:`~xml.sax.handler.DTDHandler`. + + + .. method:: XMLReader.setDTDHandler(handler) + +- Set the current :class:`DTDHandler`. If no :class:`DTDHandler` is set, DTD ++ Set the current :class:`~xml.sax.handler.DTDHandler`. If no ++ :class:`~xml.sax.handler.DTDHandler` is set, DTD + events will be discarded. + + + .. method:: XMLReader.getEntityResolver() + +- Return the current :class:`EntityResolver`. ++ Return the current :class:`~xml.sax.handler.EntityResolver`. + + + .. method:: XMLReader.setEntityResolver(handler) + +- Set the current :class:`EntityResolver`. If no :class:`EntityResolver` is set, ++ Set the current :class:`~xml.sax.handler.EntityResolver`. If no ++ :class:`~xml.sax.handler.EntityResolver` is set, + attempts to resolve an external entity will result in opening the system + identifier for the entity, and fail if it is not available. + + + .. method:: XMLReader.getErrorHandler() + +- Return the current :class:`ErrorHandler`. ++ Return the current :class:`~xml.sax.handler.ErrorHandler`. + + + .. method:: XMLReader.setErrorHandler(handler) + +- Set the current error handler. If no :class:`ErrorHandler` is set, errors will +- be raised as exceptions, and warnings will be printed. ++ Set the current error handler. If no :class:`~xml.sax.handler.ErrorHandler` ++ is set, errors will be raised as exceptions, and warnings will be printed. + + + .. method:: XMLReader.setLocale(locale) +@@ -326,8 +329,13 @@ + --------------------------------- + + :class:`Attributes` objects implement a portion of the mapping protocol, +-including the methods :meth:`copy`, :meth:`get`, :meth:`has_key`, :meth:`items`, +-:meth:`keys`, and :meth:`values`. The following methods are also provided: ++including the methods :meth:`~collections.abc.Mapping.copy`, ++:meth:`~collections.abc.Mapping.get`, ++:meth:`~collections.abc.Mapping.has_key`, ++:meth:`~collections.abc.Mapping.items`, ++:meth:`~collections.abc.Mapping.keys`, ++and :meth:`~collections.abc.Mapping.values`. The following methods ++are also provided: + + + .. method:: Attributes.getLength() +diff -r ab05e7dd2788 Doc/library/xml.sax.rst +--- a/Doc/library/xml.sax.rst ++++ b/Doc/library/xml.sax.rst +@@ -29,7 +29,8 @@ + + .. function:: make_parser([parser_list]) + +- Create and return a SAX :class:`XMLReader` object. The first parser found will ++ Create and return a SAX :class:`~xml.sax.xmlreader.XMLReader` object. The ++ first parser found will + be used. If *parser_list* is provided, it must be a sequence of strings which + name modules that have a function named :func:`create_parser`. Modules listed + in *parser_list* will be used before modules in the default list of parsers. +@@ -39,8 +40,9 @@ + + Create a SAX parser and use it to parse a document. The document, passed in as + *filename_or_stream*, can be a filename or a file object. The *handler* +- parameter needs to be a SAX :class:`ContentHandler` instance. If +- *error_handler* is given, it must be a SAX :class:`ErrorHandler` instance; if ++ parameter needs to be a SAX :class:`~handler.ContentHandler` instance. If ++ *error_handler* is given, it must be a SAX :class:`~handler.ErrorHandler` ++ instance; if + omitted, :exc:`SAXParseException` will be raised on all errors. There is no + return value; all work must be done by the *handler* passed in. + +@@ -65,10 +67,12 @@ + instantiated by the application itself. Since Python does not have an explicit + notion of interface, they are formally introduced as classes, but applications + may use implementations which do not inherit from the provided classes. The +-:class:`InputSource`, :class:`Locator`, :class:`Attributes`, +-:class:`AttributesNS`, and :class:`XMLReader` interfaces are defined in the ++:class:`~xml.sax.xmlreader.InputSource`, :class:`~xml.sax.xmlreader.Locator`, ++:class:`~xml.sax.xmlreader.Attributes`, :class:`~xml.sax.xmlreader.AttributesNS`, ++and :class:`~xml.sax.xmlreader.XMLReader` interfaces are defined in the + module :mod:`xml.sax.xmlreader`. The handler interfaces are defined in +-:mod:`xml.sax.handler`. For convenience, :class:`InputSource` (which is often ++:mod:`xml.sax.handler`. For convenience, ++:class:`~xml.sax.xmlreader.InputSource` (which is often + instantiated directly) and the handler classes are also available from + :mod:`xml.sax`. These interfaces are described below. + +@@ -81,7 +85,8 @@ + Encapsulate an XML error or warning. This class can contain basic error or + warning information from either the XML parser or the application: it can be + subclassed to provide additional functionality or to add localization. Note +- that although the handlers defined in the :class:`ErrorHandler` interface ++ that although the handlers defined in the ++ :class:`~xml.sax.handler.ErrorHandler` interface + receive instances of this exception, it is not required to actually raise the + exception --- it is also useful as a container for information. + +@@ -94,22 +99,26 @@ + + .. exception:: SAXParseException(msg, exception, locator) + +- Subclass of :exc:`SAXException` raised on parse errors. Instances of this class +- are passed to the methods of the SAX :class:`ErrorHandler` interface to provide +- information about the parse error. This class supports the SAX :class:`Locator` +- interface as well as the :class:`SAXException` interface. ++ Subclass of :exc:`SAXException` raised on parse errors. Instances of this ++ class are passed to the methods of the SAX ++ :class:`~xml.sax.handler.ErrorHandler` interface to provide information ++ about the parse error. This class supports the SAX ++ :class:`~xml.sax.xmlreader.Locator` interface as well as the ++ :class:`SAXException` interface. + + + .. exception:: SAXNotRecognizedException(msg[, exception]) + +- Subclass of :exc:`SAXException` raised when a SAX :class:`XMLReader` is ++ Subclass of :exc:`SAXException` raised when a SAX ++ :class:`~xml.sax.xmlreader.XMLReader` is + confronted with an unrecognized feature or property. SAX applications and + extensions may use this class for similar purposes. + + + .. exception:: SAXNotSupportedException(msg[, exception]) + +- Subclass of :exc:`SAXException` raised when a SAX :class:`XMLReader` is asked to ++ Subclass of :exc:`SAXException` raised when a SAX ++ :class:`~xml.sax.xmlreader.XMLReader` is asked to + enable a feature that is not supported, or to set a property to a value that the + implementation does not support. SAX applications and extensions may use this + class for similar purposes. +diff -r ab05e7dd2788 Doc/library/xml.sax.utils.rst +--- a/Doc/library/xml.sax.utils.rst ++++ b/Doc/library/xml.sax.utils.rst +@@ -59,7 +59,8 @@ + + .. class:: XMLGenerator([out[, encoding]]) + +- This class implements the :class:`ContentHandler` interface by writing SAX ++ This class implements the :class:`~xml.sax.handler.ContentHandler` interface ++ by writing SAX + events back into an XML document. In other words, using an :class:`XMLGenerator` + as the content handler will reproduce the original document being parsed. *out* + should be a file-like object which will default to *sys.stdout*. *encoding* is +@@ -68,7 +69,8 @@ + + .. class:: XMLFilterBase(base) + +- This class is designed to sit between an :class:`XMLReader` and the client ++ This class is designed to sit between an ++ :class:`~xml.sax.xmlreader.XMLReader` and the client + application's event handlers. By default, it does nothing but pass requests up + to the reader and events on to the handlers unmodified, but subclasses can + override specific methods to modify the event stream or the configuration +@@ -77,9 +79,10 @@ + + .. function:: prepare_input_source(source[, base]) + +- This function takes an input source and an optional base URL and returns a fully +- resolved :class:`InputSource` object ready for reading. The input source can be +- given as a string, a file-like object, or an :class:`InputSource` object; +- parsers will use this function to implement the polymorphic *source* argument to +- their :meth:`parse` method. ++ This function takes an input source and an optional base URL and returns a ++ fully resolved :class:`~xml.sax.xmlreader.InputSource` object ready for ++ reading. The input source can be given as a string, a file-like object, or ++ an :class:`~xml.sax.xmlreader.InputSource` object; parsers will use this ++ function to implement the polymorphic *source* argument to their ++ :meth:`parse` method. + +diff -r ab05e7dd2788 Doc/reference/lexical_analysis.rst +--- a/Doc/reference/lexical_analysis.rst ++++ b/Doc/reference/lexical_analysis.rst +@@ -529,8 +529,7 @@ + (2) + Any Unicode character can be encoded this way, but characters outside the Basic + Multilingual Plane (BMP) will be encoded using a surrogate pair if Python is +- compiled to use 16-bit code units (the default). Individual code units which +- form parts of a surrogate pair can be encoded using this escape sequence. ++ compiled to use 16-bit code units (the default). + + (3) + As in Standard C, up to three octal digits are accepted. +diff -r ab05e7dd2788 Doc/reference/simple_stmts.rst +--- a/Doc/reference/simple_stmts.rst ++++ b/Doc/reference/simple_stmts.rst +@@ -981,15 +981,16 @@ + exec_stmt: "exec" `or_expr` ["in" `expression` ["," `expression`]] + + This statement supports dynamic execution of Python code. The first expression +-should evaluate to either a string, an open file object, a code object, or a +-tuple. If it is a string, the string is parsed as a suite of Python statements +-which is then executed (unless a syntax error occurs). [#]_ If it is an open +-file, the file is parsed until EOF and executed. If it is a code object, it is +-simply executed. For the interpretation of a tuple, see below. In all cases, +-the code that's executed is expected to be valid as file input (see section +-:ref:`file-input`). Be aware that the :keyword:`return` and :keyword:`yield` +-statements may not be used outside of function definitions even within the +-context of code passed to the :keyword:`exec` statement. ++should evaluate to either a Unicode string, a *Latin-1* encoded string, an open ++file object, a code object, or a tuple. If it is a string, the string is parsed ++as a suite of Python statements which is then executed (unless a syntax error ++occurs). [#]_ If it is an open file, the file is parsed until EOF and executed. ++If it is a code object, it is simply executed. For the interpretation of a ++tuple, see below. In all cases, the code that's executed is expected to be ++valid as file input (see section :ref:`file-input`). Be aware that the ++:keyword:`return` and :keyword:`yield` statements may not be used outside of ++function definitions even within the context of code passed to the ++:keyword:`exec` statement. + + In all cases, if the optional parts are omitted, the code is executed in the + current scope. If only the first expression after ``in`` is specified, +diff -r ab05e7dd2788 Doc/tutorial/inputoutput.rst +--- a/Doc/tutorial/inputoutput.rst ++++ b/Doc/tutorial/inputoutput.rst +@@ -215,10 +215,6 @@ + >>> print 'The value of PI is approximately %5.3f.' % math.pi + The value of PI is approximately 3.142. + +-Since :meth:`str.format` is quite new, a lot of Python code still uses the ``%`` +-operator. However, because this old style of formatting will eventually be +-removed from the language, :meth:`str.format` should generally be used. +- + More information can be found in the :ref:`string-formatting` section. + + +diff -r ab05e7dd2788 Doc/whatsnew/2.2.rst +--- a/Doc/whatsnew/2.2.rst ++++ b/Doc/whatsnew/2.2.rst +@@ -450,9 +450,9 @@ + Python classes can define an :meth:`__iter__` method, which should create and + return a new iterator for the object; if the object is its own iterator, this + method can just return ``self``. In particular, iterators will usually be their +-own iterators. Extension types implemented in C can implement a :attr:`tp_iter` ++own iterators. Extension types implemented in C can implement a :c:member:`~PyTypeObject.tp_iter` + function in order to return an iterator, and extension types that want to behave +-as iterators can define a :attr:`tp_iternext` function. ++as iterators can define a :c:member:`~PyTypeObject.tp_iternext` function. + + So, after all this, what do iterators actually do? They have one required + method, :meth:`next`, which takes no arguments and returns the next value. When +@@ -478,7 +478,7 @@ + In 2.2, Python's :keyword:`for` statement no longer expects a sequence; it + expects something for which :func:`iter` will return an iterator. For backward + compatibility and convenience, an iterator is automatically constructed for +-sequences that don't implement :meth:`__iter__` or a :attr:`tp_iter` slot, so ++sequences that don't implement :meth:`__iter__` or a :c:member:`~PyTypeObject.tp_iter` slot, so + ``for i in [1,2,3]`` will still work. Wherever the Python interpreter loops + over a sequence, it's been changed to use the iterator protocol. This means you + can do things like this:: +diff -r ab05e7dd2788 Include/datetime.h +--- a/Include/datetime.h ++++ b/Include/datetime.h +@@ -42,7 +42,7 @@ + + typedef struct + { +- PyObject_HEAD /* a pure abstract base clase */ ++ PyObject_HEAD /* a pure abstract base class */ + } PyDateTime_TZInfo; + + +diff -r ab05e7dd2788 Include/patchlevel.h +--- a/Include/patchlevel.h ++++ b/Include/patchlevel.h +@@ -27,7 +27,7 @@ + #define PY_RELEASE_SERIAL 0 + + /* Version as a string */ +-#define PY_VERSION "2.7.5" ++#define PY_VERSION "2.7.5+" + /*--end constants--*/ + + /* Subversion Revision number of this file (not of the repository). Empty +diff -r ab05e7dd2788 Lib/Cookie.py +--- a/Lib/Cookie.py ++++ b/Lib/Cookie.py +@@ -238,7 +238,7 @@ + # a two-way quoting algorithm. Any non-text character is translated + # into a 4 character sequence: a forward-slash followed by the + # three-digit octal equivalent of the character. Any '\' or '"' is +-# quoted with a preceeding '\' slash. ++# quoted with a preceding '\' slash. + # + # These are taken from RFC2068 and RFC2109. + # _LegalChars is the list of chars which don't require "'s +diff -r ab05e7dd2788 Lib/Queue.py +--- a/Lib/Queue.py ++++ b/Lib/Queue.py +@@ -109,7 +109,7 @@ + + If optional args 'block' is true and 'timeout' is None (the default), + block if necessary until a free slot is available. If 'timeout' is +- a positive number, it blocks at most 'timeout' seconds and raises ++ a non-negative number, it blocks at most 'timeout' seconds and raises + the Full exception if no free slot was available within that time. + Otherwise ('block' is false), put an item on the queue if a free slot + is immediately available, else raise the Full exception ('timeout' +@@ -125,7 +125,7 @@ + while self._qsize() == self.maxsize: + self.not_full.wait() + elif timeout < 0: +- raise ValueError("'timeout' must be a positive number") ++ raise ValueError("'timeout' must be a non-negative number") + else: + endtime = _time() + timeout + while self._qsize() == self.maxsize: +@@ -152,7 +152,7 @@ + + If optional args 'block' is true and 'timeout' is None (the default), + block if necessary until an item is available. If 'timeout' is +- a positive number, it blocks at most 'timeout' seconds and raises ++ a non-negative number, it blocks at most 'timeout' seconds and raises + the Empty exception if no item was available within that time. + Otherwise ('block' is false), return an item if one is immediately + available, else raise the Empty exception ('timeout' is ignored +@@ -167,7 +167,7 @@ + while not self._qsize(): + self.not_empty.wait() + elif timeout < 0: +- raise ValueError("'timeout' must be a positive number") ++ raise ValueError("'timeout' must be a non-negative number") + else: + endtime = _time() + timeout + while not self._qsize(): +diff -r ab05e7dd2788 Lib/SimpleHTTPServer.py +--- a/Lib/SimpleHTTPServer.py ++++ b/Lib/SimpleHTTPServer.py +@@ -149,6 +149,8 @@ + # abandon query parameters + path = path.split('?',1)[0] + path = path.split('#',1)[0] ++ # Don't forget explicit trailing slash when normalizing. Issue17324 ++ trailing_slash = True if path.rstrip().endswith('/') else False + path = posixpath.normpath(urllib.unquote(path)) + words = path.split('/') + words = filter(None, words) +@@ -158,6 +160,8 @@ + head, word = os.path.split(word) + if word in (os.curdir, os.pardir): continue + path = os.path.join(path, word) ++ if trailing_slash: ++ path += '/' + return path + + def copyfile(self, source, outputfile): +diff -r ab05e7dd2788 Lib/_osx_support.py +--- a/Lib/_osx_support.py ++++ b/Lib/_osx_support.py +@@ -53,7 +53,7 @@ + + + def _read_output(commandstring): +- """Output from succesful command execution or None""" ++ """Output from successful command execution or None""" + # Similar to os.popen(commandstring, "r").read(), + # but without actually using os.popen because that + # function is not usable during python bootstrap. +@@ -68,7 +68,7 @@ + + with contextlib.closing(fp) as fp: + cmd = "%s 2>/dev/null >'%s'" % (commandstring, fp.name) +- return fp.read().decode('utf-8').strip() if not os.system(cmd) else None ++ return fp.read().strip() if not os.system(cmd) else None + + + def _find_build_tool(toolname): +@@ -152,7 +152,7 @@ + # are not installed. + # + # Futhermore, the compiler that can be used varies between +- # Xcode releases. Upto Xcode 4 it was possible to use 'gcc-4.2' ++ # Xcode releases. Up to Xcode 4 it was possible to use 'gcc-4.2' + # as the compiler, after that 'clang' should be used because + # gcc-4.2 is either not present, or a copy of 'llvm-gcc' that + # miscompiles Python. +@@ -192,7 +192,7 @@ + + if cc != oldcc: + # Found a replacement compiler. +- # Modify config vars using new compiler, if not already explictly ++ # Modify config vars using new compiler, if not already explicitly + # overriden by an env variable, preserving additional arguments. + for cv in _COMPILER_CONFIG_VARS: + if cv in _config_vars and cv not in os.environ: +@@ -274,7 +274,7 @@ + # compile an extension using an SDK that is not present + # on the current machine it is better to not use an SDK + # than to fail. This is particularly important with +- # the standalong Command Line Tools alternative to a ++ # the standalone Command Line Tools alternative to a + # full-blown Xcode install since the CLT packages do not + # provide SDKs. If the SDK is not present, it is assumed + # that the header files and dev libs have been installed +@@ -378,7 +378,7 @@ + compilers are present, i.e. when installing pure + Python dists. Customization of compiler paths + and detection of unavailable archs is deferred +- until the first extention module build is ++ until the first extension module build is + requested (in distutils.sysconfig.customize_compiler). + + Currently called from distutils.sysconfig +diff -r ab05e7dd2788 Lib/_strptime.py +--- a/Lib/_strptime.py ++++ b/Lib/_strptime.py +@@ -222,7 +222,7 @@ + """Convert a list to a regex string for matching a directive. + + Want possible matching values to be from longest to shortest. This +- prevents the possibility of a match occuring for a value that also ++ prevents the possibility of a match occurring for a value that also + a substring of a larger value that should have matched (e.g., 'abc' + matching when 'abcdef' should have been the match). + +diff -r ab05e7dd2788 Lib/_weakrefset.py +--- a/Lib/_weakrefset.py ++++ b/Lib/_weakrefset.py +@@ -171,6 +171,12 @@ + return NotImplemented + return self.data == set(ref(item) for item in other) + ++ def __ne__(self, other): ++ opposite = self.__eq__(other) ++ if opposite is NotImplemented: ++ return NotImplemented ++ return not opposite ++ + def symmetric_difference(self, other): + newset = self.copy() + newset.symmetric_difference_update(other) +diff -r ab05e7dd2788 Lib/aifc.py +--- a/Lib/aifc.py ++++ b/Lib/aifc.py +@@ -123,7 +123,7 @@ + compression type, and then write audio frames using writeframesraw. + When all frames have been written, either call writeframes('') or + close() to patch up the sizes in the header. +-Marks can be added anytime. If there are any marks, ypu must call ++Marks can be added anytime. If there are any marks, you must call + close() after all frames have been written. + The close() method is called automatically when the class instance + is destroyed. +@@ -953,23 +953,27 @@ + sys.argv.append('/usr/demos/data/audio/bach.aiff') + fn = sys.argv[1] + f = open(fn, 'r') +- print "Reading", fn +- print "nchannels =", f.getnchannels() +- print "nframes =", f.getnframes() +- print "sampwidth =", f.getsampwidth() +- print "framerate =", f.getframerate() +- print "comptype =", f.getcomptype() +- print "compname =", f.getcompname() +- if sys.argv[2:]: +- gn = sys.argv[2] +- print "Writing", gn +- g = open(gn, 'w') +- g.setparams(f.getparams()) +- while 1: +- data = f.readframes(1024) +- if not data: +- break +- g.writeframes(data) +- g.close() ++ try: ++ print "Reading", fn ++ print "nchannels =", f.getnchannels() ++ print "nframes =", f.getnframes() ++ print "sampwidth =", f.getsampwidth() ++ print "framerate =", f.getframerate() ++ print "comptype =", f.getcomptype() ++ print "compname =", f.getcompname() ++ if sys.argv[2:]: ++ gn = sys.argv[2] ++ print "Writing", gn ++ g = open(gn, 'w') ++ try: ++ g.setparams(f.getparams()) ++ while 1: ++ data = f.readframes(1024) ++ if not data: ++ break ++ g.writeframes(data) ++ finally: ++ g.close() ++ print "Done." ++ finally: + f.close() +- print "Done." +diff -r ab05e7dd2788 Lib/calendar.py +--- a/Lib/calendar.py ++++ b/Lib/calendar.py +@@ -220,7 +220,7 @@ + def yeardatescalendar(self, year, width=3): + """ + Return the data for the specified year ready for formatting. The return +- value is a list of month rows. Each month row contains upto width months. ++ value is a list of month rows. Each month row contains up to width months. + Each month contains between 4 and 6 weeks and each week contains 1-7 + days. Days are datetime.date objects. + """ +diff -r ab05e7dd2788 Lib/cgi.py +--- a/Lib/cgi.py ++++ b/Lib/cgi.py +@@ -697,6 +697,9 @@ + if not line: + self.done = -1 + break ++ if delim == "\r": ++ line = delim + line ++ delim = "" + if line[:2] == "--" and last_line_lfend: + strippedline = line.strip() + if strippedline == next: +@@ -713,6 +716,12 @@ + delim = "\n" + line = line[:-1] + last_line_lfend = True ++ elif line[-1] == "\r": ++ # We may interrupt \r\n sequences if they span the 2**16 ++ # byte boundary ++ delim = "\r" ++ line = line[:-1] ++ last_line_lfend = False + else: + delim = "" + last_line_lfend = False +diff -r ab05e7dd2788 Lib/collections.py +--- a/Lib/collections.py ++++ b/Lib/collections.py +@@ -270,6 +270,12 @@ + 'Return self as a plain tuple. Used by copy and pickle.' + return tuple(self) + ++ __dict__ = _property(_asdict) ++ ++ def __getstate__(self): ++ 'Exclude the OrderedDict from pickling' ++ pass ++ + {field_defs} + ''' + +@@ -363,7 +369,7 @@ + result = namespace[typename] + + # For pickling to work, the __module__ variable needs to be set to the frame +- # where the named tuple is created. Bypass this step in enviroments where ++ # where the named tuple is created. Bypass this step in environments where + # sys._getframe is not defined (Jython for example) or sys._getframe is not + # defined for arguments greater than 0 (IronPython). + try: +diff -r ab05e7dd2788 Lib/compiler/pyassem.py +--- a/Lib/compiler/pyassem.py ++++ b/Lib/compiler/pyassem.py +@@ -125,7 +125,7 @@ + # Make sure every block appears in dominators, even if no + # other block must precede it. + dominators.setdefault(b, set()) +- # preceeding blocks dominate following blocks ++ # preceding blocks dominate following blocks + for c in b.get_followers(): + while 1: + dominators.setdefault(c, set()).add(b) +diff -r ab05e7dd2788 Lib/csv.py +--- a/Lib/csv.py ++++ b/Lib/csv.py +@@ -261,8 +261,9 @@ + + # if we see an extra quote between delimiters, we've got a + # double quoted format +- dq_regexp = re.compile(r"((%(delim)s)|^)\W*%(quote)s[^%(delim)s\n]*%(quote)s[^%(delim)s\n]*%(quote)s\W*((%(delim)s)|$)" % \ +- {'delim':delim, 'quote':quotechar}, re.MULTILINE) ++ dq_regexp = re.compile( ++ r"((%(delim)s)|^)\W*%(quote)s[^%(delim)s\n]*%(quote)s[^%(delim)s\n]*%(quote)s\W*((%(delim)s)|$)" % \ ++ {'delim':re.escape(delim), 'quote':quotechar}, re.MULTILINE) + + + +diff -r ab05e7dd2788 Lib/ctypes/test/runtests.py +--- a/Lib/ctypes/test/runtests.py ++++ b/Lib/ctypes/test/runtests.py +@@ -2,7 +2,7 @@ + + Run all tests found in this directory, and print a summary of the results. + Command line flags: +- -q quiet mode: don't prnt anything while the tests are running ++ -q quiet mode: don't print anything while the tests are running + -r run tests repeatedly, look for refcount leaks + -u + Add resources to the lits of allowed resources. '*' allows all +diff -r ab05e7dd2788 Lib/ctypes/test/test_cfuncs.py +--- a/Lib/ctypes/test/test_cfuncs.py ++++ b/Lib/ctypes/test/test_cfuncs.py +@@ -188,7 +188,7 @@ + self.assertEqual(self._dll.tv_i(-42), None) + self.assertEqual(self.S(), -42) + +-# The following repeates the above tests with stdcall functions (where ++# The following repeats the above tests with stdcall functions (where + # they are available) + try: + WinDLL +diff -r ab05e7dd2788 Lib/ctypes/test/test_integers.py +--- a/Lib/ctypes/test/test_integers.py ++++ b/Lib/ctypes/test/test_integers.py +@@ -1,4 +1,4 @@ +-# superseeded by test_numbers.py ++# superseded by test_numbers.py + import unittest + + if __name__ == '__main__': +diff -r ab05e7dd2788 Lib/ctypes/test/test_numbers.py +--- a/Lib/ctypes/test/test_numbers.py ++++ b/Lib/ctypes/test/test_numbers.py +@@ -212,7 +212,7 @@ + + def test_init(self): + # c_int() can be initialized from Python's int, and c_int. +- # Not from c_long or so, which seems strange, abd should ++ # Not from c_long or so, which seems strange, abc should + # probably be changed: + self.assertRaises(TypeError, c_int, c_long(42)) + +diff -r ab05e7dd2788 Lib/ctypes/test/test_refcounts.py +--- a/Lib/ctypes/test/test_refcounts.py ++++ b/Lib/ctypes/test/test_refcounts.py +@@ -41,7 +41,7 @@ + # this is the standard refcount for func + self.assertEqual(grc(func), 2) + +- # the CFuncPtr instance holds atr least one refcount on func: ++ # the CFuncPtr instance holds at least one refcount on func: + f = OtherCallback(func) + self.assertTrue(grc(func) > 2) + +@@ -58,7 +58,7 @@ + x = X() + x.a = OtherCallback(func) + +- # the CFuncPtr instance holds atr least one refcount on func: ++ # the CFuncPtr instance holds at least one refcount on func: + self.assertTrue(grc(func) > 2) + + # and may release it again +@@ -71,7 +71,7 @@ + + f = OtherCallback(func) + +- # the CFuncPtr instance holds atr least one refcount on func: ++ # the CFuncPtr instance holds at least one refcount on func: + self.assertTrue(grc(func) > 2) + + # create a cycle +diff -r ab05e7dd2788 Lib/ctypes/test/test_structures.py +--- a/Lib/ctypes/test/test_structures.py ++++ b/Lib/ctypes/test/test_structures.py +@@ -108,7 +108,7 @@ + def test_emtpy(self): + # I had problems with these + # +- # Although these are patological cases: Empty Structures! ++ # Although these are pathological cases: Empty Structures! + class X(Structure): + _fields_ = [] + +diff -r ab05e7dd2788 Lib/ctypes/util.py +--- a/Lib/ctypes/util.py ++++ b/Lib/ctypes/util.py +@@ -93,7 +93,7 @@ + fdout, ccout = tempfile.mkstemp() + os.close(fdout) + cmd = 'if type gcc >/dev/null 2>&1; then CC=gcc; elif type cc >/dev/null 2>&1; then CC=cc;else exit 10; fi;' \ +- '$CC -Wl,-t -o ' + ccout + ' 2>&1 -l' + name ++ 'LANG=C LC_ALL=C $CC -Wl,-t -o ' + ccout + ' 2>&1 -l' + name + try: + f = os.popen(cmd) + try: +diff -r ab05e7dd2788 Lib/decimal.py +--- a/Lib/decimal.py ++++ b/Lib/decimal.py +@@ -25,7 +25,7 @@ + + and IEEE standard 854-1987: + +- www.cs.berkeley.edu/~ejr/projects/754/private/drafts/854-1987/dir.html ++ http://en.wikipedia.org/wiki/IEEE_854-1987 + + Decimal floating point has finite precision with arbitrarily large bounds. + +diff -r ab05e7dd2788 Lib/difflib.py +--- a/Lib/difflib.py ++++ b/Lib/difflib.py +@@ -586,7 +586,7 @@ + def get_grouped_opcodes(self, n=3): + """ Isolate change clusters by eliminating ranges with no changes. + +- Return a generator of groups with upto n lines of context. ++ Return a generator of groups with up to n lines of context. + Each group is in the same format as returned by get_opcodes(). + + >>> from pprint import pprint +@@ -1361,7 +1361,7 @@ + linejunk -- passed on to ndiff (see ndiff documentation) + charjunk -- passed on to ndiff (see ndiff documentation) + +- This function returns an interator which returns a tuple: ++ This function returns an iterator which returns a tuple: + (from line tuple, to line tuple, boolean flag) + + from/to line tuple -- (line num, line text) +@@ -1963,7 +1963,7 @@ + self._make_prefix() + + # change tabs to spaces before it gets more difficult after we insert +- # markkup ++ # markup + fromlines,tolines = self._tab_newline_replace(fromlines,tolines) + + # create diffs iterator which generates side by side from/to data +diff -r ab05e7dd2788 Lib/distutils/command/sdist.py +--- a/Lib/distutils/command/sdist.py ++++ b/Lib/distutils/command/sdist.py +@@ -183,7 +183,7 @@ + depends on the user's options. + """ + # new behavior when using a template: +- # the file list is recalculated everytime because ++ # the file list is recalculated every time because + # even if MANIFEST.in or setup.py are not changed + # the user might have added some files in the tree that + # need to be included. +diff -r ab05e7dd2788 Lib/distutils/sysconfig.py +--- a/Lib/distutils/sysconfig.py ++++ b/Lib/distutils/sysconfig.py +@@ -175,9 +175,15 @@ + 'CCSHARED', 'LDSHARED', 'SO', 'AR', + 'ARFLAGS') + +- newcc = None + if 'CC' in os.environ: +- cc = os.environ['CC'] ++ newcc = os.environ['CC'] ++ if (sys.platform == 'darwin' ++ and 'LDSHARED' not in os.environ ++ and ldshared.startswith(cc)): ++ # On OS X, if CC is overridden, use that as the default ++ # command for LDSHARED as well ++ ldshared = newcc + ldshared[len(cc):] ++ cc = newcc + if 'CXX' in os.environ: + cxx = os.environ['CXX'] + if 'LDSHARED' in os.environ: +diff -r ab05e7dd2788 Lib/distutils/tests/test_build_clib.py +--- a/Lib/distutils/tests/test_build_clib.py ++++ b/Lib/distutils/tests/test_build_clib.py +@@ -77,7 +77,7 @@ + + cmd.compiler = FakeCompiler() + +- # build_libraries is also doing a bit of typoe checking ++ # build_libraries is also doing a bit of typo checking + lib = [('name', {'sources': 'notvalid'})] + self.assertRaises(DistutilsSetupError, cmd.build_libraries, lib) + +diff -r ab05e7dd2788 Lib/distutils/tests/test_unixccompiler.py +--- a/Lib/distutils/tests/test_unixccompiler.py ++++ b/Lib/distutils/tests/test_unixccompiler.py +@@ -1,7 +1,8 @@ + """Tests for distutils.unixccompiler.""" ++import os + import sys + import unittest +-from test.test_support import run_unittest ++from test.test_support import EnvironmentVarGuard, run_unittest + + from distutils import sysconfig + from distutils.unixccompiler import UnixCCompiler +@@ -122,6 +123,37 @@ + sysconfig.get_config_var = gcv + self.assertEqual(self.cc.rpath_foo(), '-R/foo') + ++ @unittest.skipUnless(sys.platform == 'darwin', 'test only relevant for OS X') ++ def test_osx_cc_overrides_ldshared(self): ++ # Issue #18080: ++ # ensure that setting CC env variable also changes default linker ++ def gcv(v): ++ if v == 'LDSHARED': ++ return 'gcc-4.2 -bundle -undefined dynamic_lookup ' ++ return 'gcc-4.2' ++ sysconfig.get_config_var = gcv ++ with EnvironmentVarGuard() as env: ++ env['CC'] = 'my_cc' ++ del env['LDSHARED'] ++ sysconfig.customize_compiler(self.cc) ++ self.assertEqual(self.cc.linker_so[0], 'my_cc') ++ ++ @unittest.skipUnless(sys.platform == 'darwin', 'test only relevant for OS X') ++ def test_osx_explict_ldshared(self): ++ # Issue #18080: ++ # ensure that setting CC env variable does not change ++ # explicit LDSHARED setting for linker ++ def gcv(v): ++ if v == 'LDSHARED': ++ return 'gcc-4.2 -bundle -undefined dynamic_lookup ' ++ return 'gcc-4.2' ++ sysconfig.get_config_var = gcv ++ with EnvironmentVarGuard() as env: ++ env['CC'] = 'my_cc' ++ env['LDSHARED'] = 'my_ld -bundle -dynamic' ++ sysconfig.customize_compiler(self.cc) ++ self.assertEqual(self.cc.linker_so[0], 'my_ld') ++ + + def test_suite(): + return unittest.makeSuite(UnixCCompilerTestCase) +diff -r ab05e7dd2788 Lib/doctest.py +--- a/Lib/doctest.py ++++ b/Lib/doctest.py +@@ -424,7 +424,7 @@ + zero-based, with respect to the beginning of the DocTest. + + - indent: The example's indentation in the DocTest string. +- I.e., the number of space characters that preceed the ++ I.e., the number of space characters that precede the + example's first prompt. + + - options: A dictionary mapping from option flags to True or +@@ -564,7 +564,7 @@ + # Want consists of any non-blank lines that do not start with PS1. + (?P (?:(?![ ]*$) # Not a blank line + (?![ ]*>>>) # Not a line starting with PS1 +- .*$\n? # But any other line ++ .+$\n? # But any other line + )*) + ''', re.MULTILINE | re.VERBOSE) + +@@ -895,7 +895,7 @@ + if '__name__' not in globs: + globs['__name__'] = '__main__' # provide a default module name + +- # Recursively expore `obj`, extracting DocTests. ++ # Recursively explore `obj`, extracting DocTests. + tests = [] + self._find(tests, obj, name, module, source_lines, globs, {}) + # Sort the tests by alpha order of names, for consistency in +diff -r ab05e7dd2788 Lib/email/charset.py +--- a/Lib/email/charset.py ++++ b/Lib/email/charset.py +@@ -183,7 +183,7 @@ + header encoding. Charset.SHORTEST is not allowed for + body_encoding. + +- output_charset: Some character sets must be converted before the can be ++ output_charset: Some character sets must be converted before they can be + used in email headers or bodies. If the input_charset is + one of them, this attribute will contain the name of the + charset output will be converted to. Otherwise, it will +diff -r ab05e7dd2788 Lib/fileinput.py +--- a/Lib/fileinput.py ++++ b/Lib/fileinput.py +@@ -90,12 +90,11 @@ + + def input(files=None, inplace=0, backup="", bufsize=0, + mode="r", openhook=None): +- """input([files[, inplace[, backup[, mode[, openhook]]]]]) ++ """Return an instance of the FileInput class, which can be iterated. + +- Create an instance of the FileInput class. The instance will be used +- as global state for the functions of this module, and is also returned +- to use during iteration. The parameters to this function will be passed +- along to the constructor of the FileInput class. ++ The parameters are passed to the constructor of the FileInput class. ++ The returned instance, in addition to being an iterator, ++ keeps global state for the functions of this module,. + """ + global _state + if _state and _state._file: +@@ -182,7 +181,7 @@ + return _state.isstdin() + + class FileInput: +- """class FileInput([files[, inplace[, backup[, mode[, openhook]]]]]) ++ """FileInput([files[, inplace[, backup[, bufsize[, mode[, openhook]]]]]]) + + Class FileInput is the implementation of the module; its methods + filename(), lineno(), fileline(), isfirstline(), isstdin(), fileno(), +diff -r ab05e7dd2788 Lib/genericpath.py +--- a/Lib/genericpath.py ++++ b/Lib/genericpath.py +@@ -22,7 +22,7 @@ + + + # This follows symbolic links, so both islink() and isdir() can be true +-# for the same path ono systems that support symlinks ++# for the same path on systems that support symlinks + def isfile(path): + """Test whether a path is a regular file""" + try: +diff -r ab05e7dd2788 Lib/heapq.py +--- a/Lib/heapq.py ++++ b/Lib/heapq.py +@@ -366,6 +366,7 @@ + + ''' + _heappop, _heapreplace, _StopIteration = heappop, heapreplace, StopIteration ++ _len = len + + h = [] + h_append = h.append +@@ -377,17 +378,21 @@ + pass + heapify(h) + +- while 1: ++ while _len(h) > 1: + try: +- while 1: +- v, itnum, next = s = h[0] # raises IndexError when h is empty ++ while True: ++ v, itnum, next = s = h[0] + yield v + s[0] = next() # raises StopIteration when exhausted + _heapreplace(h, s) # restore heap condition + except _StopIteration: + _heappop(h) # remove empty iterator +- except IndexError: +- return ++ if h: ++ # fast case when only a single iterator remains ++ v, itnum, next = h[0] ++ yield v ++ for v in next.__self__: ++ yield v + + # Extend the implementations of nsmallest and nlargest to use a key= argument + _nsmallest = nsmallest +diff -r ab05e7dd2788 Lib/idlelib/AutoComplete.py +--- a/Lib/idlelib/AutoComplete.py ++++ b/Lib/idlelib/AutoComplete.py +@@ -156,12 +156,9 @@ + if not comp_lists[0]: + return + self.autocompletewindow = self._make_autocomplete_window() +- self.autocompletewindow.show_window(comp_lists, +- "insert-%dc" % len(comp_start), +- complete, +- mode, +- userWantsWin) +- return True ++ return not self.autocompletewindow.show_window( ++ comp_lists, "insert-%dc" % len(comp_start), ++ complete, mode, userWantsWin) + + def fetch_completions(self, what, mode): + """Return a pair of lists of completions for something. The first list +diff -r ab05e7dd2788 Lib/idlelib/AutoCompleteWindow.py +--- a/Lib/idlelib/AutoCompleteWindow.py ++++ b/Lib/idlelib/AutoCompleteWindow.py +@@ -157,13 +157,14 @@ + self.start = self.widget.get(self.startindex, "insert") + if complete: + completed = self._complete_string(self.start) ++ start = self.start + self._change_start(completed) + i = self._binary_search(completed) + if self.completions[i] == completed and \ + (i == len(self.completions)-1 or + self.completions[i+1][:len(completed)] != completed): + # There is exactly one matching completion +- return ++ return completed == start + self.userwantswindow = userWantsWin + self.lasttypedstart = self.start + +diff -r ab05e7dd2788 Lib/idlelib/Bindings.py +--- a/Lib/idlelib/Bindings.py ++++ b/Lib/idlelib/Bindings.py +@@ -15,7 +15,7 @@ + menudefs = [ + # underscore prefixes character to underscore + ('file', [ +- ('_New Window', '<>'), ++ ('_New File', '<>'), + ('_Open...', '<>'), + ('Open _Module...', '<>'), + ('Class _Browser', '<>'), +@@ -98,6 +98,10 @@ + # menu + del menudefs[-1][1][0:2] + ++ # Remove the 'Configure' entry from the options menu, it is in the ++ # application menu as 'Preferences' ++ del menudefs[-2][1][0:2] ++ + default_keydefs = idleConf.GetCurrentKeySet() + + del sys +diff -r ab05e7dd2788 Lib/idlelib/CallTips.py +--- a/Lib/idlelib/CallTips.py ++++ b/Lib/idlelib/CallTips.py +@@ -163,7 +163,7 @@ + if fob.func_code.co_flags & 0x8: + items.append("***") + arg_text = ", ".join(items) +- arg_text = "(%s)" % re.sub("\.\d+", "", arg_text) ++ arg_text = "(%s)" % re.sub("(?", arg_text) + # See if we can use the docstring + doc = getattr(ob, "__doc__", "") + if doc: +@@ -223,4 +223,6 @@ + tests = (t1, t2, t3, t4, t5, t6, t7, + TC, tc.t1, tc.t2, tc.t3, tc.t4, tc.t5, tc.t6, tc.t7) + +- test(tests) ++ # test(tests) ++ from unittest import main ++ main('idlelib.idle_test.test_calltips', verbosity=2, exit=False) +diff -r ab05e7dd2788 Lib/idlelib/Delegator.py +--- a/Lib/idlelib/Delegator.py ++++ b/Lib/idlelib/Delegator.py +@@ -4,30 +4,22 @@ + + def __init__(self, delegate=None): + self.delegate = delegate +- self.__cache = {} ++ self.__cache = set() + + def __getattr__(self, name): + attr = getattr(self.delegate, name) # May raise AttributeError + setattr(self, name, attr) +- self.__cache[name] = attr ++ self.__cache.add(name) + return attr + + def resetcache(self): +- for key in self.__cache.keys(): ++ for key in self.__cache: + try: + delattr(self, key) + except AttributeError: + pass + self.__cache.clear() + +- def cachereport(self): +- keys = self.__cache.keys() +- keys.sort() +- print keys +- + def setdelegate(self, delegate): + self.resetcache() + self.delegate = delegate +- +- def getdelegate(self): +- return self.delegate +diff -r ab05e7dd2788 Lib/idlelib/EditorWindow.py +--- a/Lib/idlelib/EditorWindow.py ++++ b/Lib/idlelib/EditorWindow.py +@@ -346,6 +346,36 @@ + self.askinteger = tkSimpleDialog.askinteger + self.showerror = tkMessageBox.showerror + ++ self._highlight_workaround() # Fix selection tags on Windows ++ ++ def _highlight_workaround(self): ++ # On Windows, Tk removes painting of the selection ++ # tags which is different behavior than on Linux and Mac. ++ # See issue14146 for more information. ++ if not sys.platform.startswith('win'): ++ return ++ ++ text = self.text ++ text.event_add("<>", "") ++ text.event_add("<>", "") ++ def highlight_fix(focus): ++ sel_range = text.tag_ranges("sel") ++ if sel_range: ++ if focus == 'out': ++ HILITE_CONFIG = idleConf.GetHighlight( ++ idleConf.CurrentTheme(), 'hilite') ++ text.tag_config("sel_fix", HILITE_CONFIG) ++ text.tag_raise("sel_fix") ++ text.tag_add("sel_fix", *sel_range) ++ elif focus == 'in': ++ text.tag_remove("sel_fix", "1.0", "end") ++ ++ text.bind("<>", ++ lambda ev: highlight_fix("out")) ++ text.bind("<>", ++ lambda ev: highlight_fix("in")) ++ ++ + def _filename_to_unicode(self, filename): + """convert filename to unicode in order to display it in Tk""" + if isinstance(filename, unicode) or not filename: +@@ -437,7 +467,6 @@ + ] + + if macosxSupport.runningAsOSXApp(): +- del menu_specs[-3] + menu_specs[-2] = ("windows", "_Window") + + +@@ -660,7 +689,7 @@ + # XXX Ought to insert current file's directory in front of path + try: + (f, file, (suffix, mode, type)) = _find_module(name) +- except (NameError, ImportError), msg: ++ except (NameError, ImportError) as msg: + tkMessageBox.showerror("Import error", str(msg), parent=self.text) + return + if type != imp.PY_SOURCE: +@@ -804,7 +833,11 @@ + menuEventDict[menu[0]][prepstr(item[0])[1]] = item[1] + for menubarItem in self.menudict.keys(): + menu = self.menudict[menubarItem] +- end = menu.index(END) + 1 ++ end = menu.index(END) ++ if end is None: ++ # Skip empty menus ++ continue ++ end += 1 + for index in range(0, end): + if menu.type(index) == 'command': + accel = menu.entrycget(index, 'accelerator') +@@ -861,11 +894,8 @@ + "Load and update the recent files list and menus" + rf_list = [] + if os.path.exists(self.recent_files_path): +- rf_list_file = open(self.recent_files_path,'r') +- try: ++ with open(self.recent_files_path, 'r') as rf_list_file: + rf_list = rf_list_file.readlines() +- finally: +- rf_list_file.close() + if new_file: + new_file = os.path.abspath(new_file) + '\n' + if new_file in rf_list: +diff -r ab05e7dd2788 Lib/idlelib/FormatParagraph.py +--- a/Lib/idlelib/FormatParagraph.py ++++ b/Lib/idlelib/FormatParagraph.py +@@ -1,18 +1,19 @@ +-# Extension to format a paragraph ++"""Extension to format a paragraph or selection to a max width. + +-# Does basic, standard text formatting, and also understands Python +-# comment blocks. Thus, for editing Python source code, this +-# extension is really only suitable for reformatting these comment +-# blocks or triple-quoted strings. ++Does basic, standard text formatting, and also understands Python ++comment blocks. Thus, for editing Python source code, this ++extension is really only suitable for reformatting these comment ++blocks or triple-quoted strings. + +-# Known problems with comment reformatting: +-# * If there is a selection marked, and the first line of the +-# selection is not complete, the block will probably not be detected +-# as comments, and will have the normal "text formatting" rules +-# applied. +-# * If a comment block has leading whitespace that mixes tabs and +-# spaces, they will not be considered part of the same block. +-# * Fancy comments, like this bulleted list, arent handled :-) ++Known problems with comment reformatting: ++* If there is a selection marked, and the first line of the ++ selection is not complete, the block will probably not be detected ++ as comments, and will have the normal "text formatting" rules ++ applied. ++* If a comment block has leading whitespace that mixes tabs and ++ spaces, they will not be considered part of the same block. ++* Fancy comments, like this bulleted list, aren't handled :-) ++""" + + import re + from idlelib.configHandler import idleConf +@@ -32,41 +33,31 @@ + self.editwin = None + + def format_paragraph_event(self, event): +- maxformatwidth = int(idleConf.GetOption('main','FormatParagraph', +- 'paragraph', type='int')) ++ """Formats paragraph to a max width specified in idleConf. ++ ++ If text is selected, format_paragraph_event will start breaking lines ++ at the max width, starting from the beginning selection. ++ ++ If no text is selected, format_paragraph_event uses the current ++ cursor location to determine the paragraph (lines of text surrounded ++ by blank lines) and formats it. ++ """ ++ maxformatwidth = idleConf.GetOption( ++ 'main', 'FormatParagraph', 'paragraph', type='int') + text = self.editwin.text + first, last = self.editwin.get_selection_indices() + if first and last: + data = text.get(first, last) +- comment_header = '' ++ comment_header = get_comment_header(data) + else: + first, last, comment_header, data = \ + find_paragraph(text, text.index("insert")) + if comment_header: +- # Reformat the comment lines - convert to text sans header. +- lines = data.split("\n") +- lines = map(lambda st, l=len(comment_header): st[l:], lines) +- data = "\n".join(lines) +- # Reformat to maxformatwidth chars or a 20 char width, whichever is greater. +- format_width = max(maxformatwidth - len(comment_header), 20) +- newdata = reformat_paragraph(data, format_width) +- # re-split and re-insert the comment header. +- newdata = newdata.split("\n") +- # If the block ends in a \n, we dont want the comment +- # prefix inserted after it. (Im not sure it makes sense to +- # reformat a comment block that isnt made of complete +- # lines, but whatever!) Can't think of a clean solution, +- # so we hack away +- block_suffix = "" +- if not newdata[-1]: +- block_suffix = "\n" +- newdata = newdata[:-1] +- builder = lambda item, prefix=comment_header: prefix+item +- newdata = '\n'.join(map(builder, newdata)) + block_suffix ++ newdata = reformat_comment(data, maxformatwidth, comment_header) + else: +- # Just a normal text format + newdata = reformat_paragraph(data, maxformatwidth) + text.tag_remove("sel", "1.0", "end") ++ + if newdata != data: + text.mark_set("insert", first) + text.undo_block_start() +@@ -79,31 +70,44 @@ + return "break" + + def find_paragraph(text, mark): ++ """Returns the start/stop indices enclosing the paragraph that mark is in. ++ ++ Also returns the comment format string, if any, and paragraph of text ++ between the start/stop indices. ++ """ + lineno, col = map(int, mark.split(".")) +- line = text.get("%d.0" % lineno, "%d.0 lineend" % lineno) ++ line = text.get("%d.0" % lineno, "%d.end" % lineno) ++ ++ # Look for start of next paragraph if the index passed in is a blank line + while text.compare("%d.0" % lineno, "<", "end") and is_all_white(line): + lineno = lineno + 1 +- line = text.get("%d.0" % lineno, "%d.0 lineend" % lineno) ++ line = text.get("%d.0" % lineno, "%d.end" % lineno) + first_lineno = lineno + comment_header = get_comment_header(line) + comment_header_len = len(comment_header) ++ ++ # Once start line found, search for end of paragraph (a blank line) + while get_comment_header(line)==comment_header and \ + not is_all_white(line[comment_header_len:]): + lineno = lineno + 1 +- line = text.get("%d.0" % lineno, "%d.0 lineend" % lineno) ++ line = text.get("%d.0" % lineno, "%d.end" % lineno) + last = "%d.0" % lineno +- # Search back to beginning of paragraph ++ ++ # Search back to beginning of paragraph (first blank line before) + lineno = first_lineno - 1 +- line = text.get("%d.0" % lineno, "%d.0 lineend" % lineno) ++ line = text.get("%d.0" % lineno, "%d.end" % lineno) + while lineno > 0 and \ + get_comment_header(line)==comment_header and \ + not is_all_white(line[comment_header_len:]): + lineno = lineno - 1 +- line = text.get("%d.0" % lineno, "%d.0 lineend" % lineno) ++ line = text.get("%d.0" % lineno, "%d.end" % lineno) + first = "%d.0" % (lineno+1) ++ + return first, last, comment_header, text.get(first, last) + ++# This should perhaps be replaced with textwrap.wrap + def reformat_paragraph(data, limit): ++ """Return data reformatted to specified width (limit).""" + lines = data.split("\n") + i = 0 + n = len(lines) +@@ -126,7 +130,7 @@ + if not word: + continue # Can happen when line ends in whitespace + if len((partial + word).expandtabs()) > limit and \ +- partial != indent1: ++ partial != indent1: + new.append(partial.rstrip()) + partial = indent2 + partial = partial + word + " " +@@ -138,13 +142,50 @@ + new.extend(lines[i:]) + return "\n".join(new) + ++def reformat_comment(data, limit, comment_header): ++ """Return data reformatted to specified width with comment header.""" ++ ++ # Remove header from the comment lines ++ lc = len(comment_header) ++ data = "\n".join(line[lc:] for line in data.split("\n")) ++ # Reformat to maxformatwidth chars or a 20 char width, ++ # whichever is greater. ++ format_width = max(limit - len(comment_header), 20) ++ newdata = reformat_paragraph(data, format_width) ++ # re-split and re-insert the comment header. ++ newdata = newdata.split("\n") ++ # If the block ends in a \n, we dont want the comment prefix ++ # inserted after it. (Im not sure it makes sense to reformat a ++ # comment block that is not made of complete lines, but whatever!) ++ # Can't think of a clean solution, so we hack away ++ block_suffix = "" ++ if not newdata[-1]: ++ block_suffix = "\n" ++ newdata = newdata[:-1] ++ return '\n'.join(comment_header+line for line in newdata) + block_suffix ++ + def is_all_white(line): ++ """Return True if line is empty or all whitespace.""" ++ + return re.match(r"^\s*$", line) is not None + + def get_indent(line): +- return re.match(r"^(\s*)", line).group() ++ """Return the initial space or tab indent of line.""" ++ return re.match(r"^([ \t]*)", line).group() + + def get_comment_header(line): +- m = re.match(r"^(\s*#*)", line) ++ """Return string with leading whitespace and '#' from line or ''. ++ ++ A null return indicates that the line is not a comment line. A non- ++ null return, such as ' #', will be used to find the other lines of ++ a comment block with the same indent. ++ """ ++ m = re.match(r"^([ \t]*#*)", line) + if m is None: return "" + return m.group(1) ++ ++if __name__ == "__main__": ++ from test import support; support.use_resources = ['gui'] ++ import unittest ++ unittest.main('idlelib.idle_test.test_formatparagraph', ++ verbosity=2, exit=False) +diff -r ab05e7dd2788 Lib/idlelib/GrepDialog.py +--- a/Lib/idlelib/GrepDialog.py ++++ b/Lib/idlelib/GrepDialog.py +@@ -81,36 +81,24 @@ + hits = 0 + for fn in list: + try: +- f = open(fn) +- except IOError, msg: ++ with open(fn) as f: ++ for lineno, line in enumerate(f, 1): ++ if line[-1:] == '\n': ++ line = line[:-1] ++ if prog.search(line): ++ sys.stdout.write("%s: %s: %s\n" % ++ (fn, lineno, line)) ++ hits += 1 ++ except IOError as msg: + print msg +- continue +- lineno = 0 +- while 1: +- block = f.readlines(100000) +- if not block: +- break +- for line in block: +- lineno = lineno + 1 +- if line[-1:] == '\n': +- line = line[:-1] +- if prog.search(line): +- sys.stdout.write("%s: %s: %s\n" % (fn, lineno, line)) +- hits = hits + 1 +- if hits: +- if hits == 1: +- s = "" +- else: +- s = "s" +- print "Found", hits, "hit%s." % s +- print "(Hint: right-click to open locations.)" +- else: +- print "No hits." ++ print(("Hits found: %s\n" ++ "(Hint: right-click to open locations.)" ++ % hits) if hits else "No hits.") + + def findfiles(self, dir, base, rec): + try: + names = os.listdir(dir or os.curdir) +- except os.error, msg: ++ except os.error as msg: + print msg + return [] + list = [] +@@ -131,3 +119,9 @@ + if self.top: + self.top.grab_release() + self.top.withdraw() ++ ++if __name__ == "__main__": ++ # A human test is a bit tricky since EditorWindow() imports this module. ++ # Hence Idle must be restarted after editing this file for a live test. ++ import unittest ++ unittest.main('idlelib.idle_test.test_grep', verbosity=2, exit=False) +diff -r ab05e7dd2788 Lib/idlelib/IOBinding.py +--- a/Lib/idlelib/IOBinding.py ++++ b/Lib/idlelib/IOBinding.py +@@ -71,7 +71,7 @@ + + encoding = encoding.lower() + +-coding_re = re.compile("coding[:=]\s*([-\w_.]+)") ++coding_re = re.compile(r'^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)') + + class EncodingMessage(SimpleDialog): + "Inform user that an encoding declaration is needed." +@@ -125,11 +125,12 @@ + Raise LookupError if the encoding is declared but unknown. + """ + # Only consider the first two lines +- str = str.split("\n")[:2] +- str = "\n".join(str) +- +- match = coding_re.search(str) +- if not match: ++ str = str.split("\n", 2)[:2] ++ for line in lst: ++ match = coding_re.match(line) ++ if match is not None: ++ break ++ else: + return None + name = match.group(1) + # Check whether the encoding is known +@@ -248,10 +249,9 @@ + try: + # open the file in binary mode so that we can handle + # end-of-line convention ourselves. +- f = open(filename,'rb') +- chars = f.read() +- f.close() +- except IOError, msg: ++ with open(filename, 'rb') as f: ++ chars = f.read() ++ except IOError as msg: + tkMessageBox.showerror("I/O Error", str(msg), master=self.text) + return False + +@@ -294,7 +294,7 @@ + # Next look for coding specification + try: + enc = coding_spec(chars) +- except LookupError, name: ++ except LookupError as name: + tkMessageBox.showerror( + title="Error loading the file", + message="The encoding '%s' is not known to this Python "\ +@@ -383,12 +383,10 @@ + if self.eol_convention != "\n": + chars = chars.replace("\n", self.eol_convention) + try: +- f = open(filename, "wb") +- f.write(chars) +- f.flush() +- f.close() ++ with open(filename, "wb") as f: ++ f.write(chars) + return True +- except IOError, msg: ++ except IOError as msg: + tkMessageBox.showerror("I/O Error", str(msg), + master=self.text) + return False +@@ -408,7 +406,7 @@ + try: + enc = coding_spec(chars) + failed = None +- except LookupError, msg: ++ except LookupError as msg: + failed = msg + enc = None + if enc: +diff -r ab05e7dd2788 Lib/idlelib/IdleHistory.py +--- a/Lib/idlelib/IdleHistory.py ++++ b/Lib/idlelib/IdleHistory.py +@@ -1,81 +1,93 @@ ++"Implement Idle Shell history mechanism with History class" ++ + from idlelib.configHandler import idleConf + + class History: ++ ''' Implement Idle Shell history mechanism. + +- def __init__(self, text, output_sep = "\n"): ++ store - Store source statement (called from PyShell.resetoutput). ++ fetch - Fetch stored statement matching prefix already entered. ++ history_next - Bound to <> event (default Alt-N). ++ history_prev - Bound to <> event (default Alt-P). ++ ''' ++ def __init__(self, text): ++ '''Initialize data attributes and bind event methods. ++ ++ .text - Idle wrapper of tk Text widget, with .bell(). ++ .history - source statements, possibly with multiple lines. ++ .prefix - source already entered at prompt; filters history list. ++ .pointer - index into history. ++ .cyclic - wrap around history list (or not). ++ ''' + self.text = text + self.history = [] +- self.history_prefix = None +- self.history_pointer = None +- self.output_sep = output_sep ++ self.prefix = None ++ self.pointer = None + self.cyclic = idleConf.GetOption("main", "History", "cyclic", 1, "bool") + text.bind("<>", self.history_prev) + text.bind("<>", self.history_next) + + def history_next(self, event): +- self.history_do(0) ++ "Fetch later statement; start with ealiest if cyclic." ++ self.fetch(reverse=False) + return "break" + + def history_prev(self, event): +- self.history_do(1) ++ "Fetch earlier statement; start with most recent." ++ self.fetch(reverse=True) + return "break" + +- def _get_source(self, start, end): +- # Get source code from start index to end index. Lines in the +- # text control may be separated by sys.ps2 . +- lines = self.text.get(start, end).split(self.output_sep) +- return "\n".join(lines) ++ def fetch(self, reverse): ++ '''Fetch statememt and replace current line in text widget. + +- def _put_source(self, where, source): +- output = self.output_sep.join(source.split("\n")) +- self.text.insert(where, output) +- +- def history_do(self, reverse): ++ Set prefix and pointer as needed for successive fetches. ++ Reset them to None, None when returning to the start line. ++ Sound bell when return to start line or cannot leave a line ++ because cyclic is False. ++ ''' + nhist = len(self.history) +- pointer = self.history_pointer +- prefix = self.history_prefix ++ pointer = self.pointer ++ prefix = self.prefix + if pointer is not None and prefix is not None: + if self.text.compare("insert", "!=", "end-1c") or \ +- self._get_source("iomark", "end-1c") != self.history[pointer]: ++ self.text.get("iomark", "end-1c") != self.history[pointer]: + pointer = prefix = None ++ self.text.mark_set("insert", "end-1c") # != after cursor move + if pointer is None or prefix is None: +- prefix = self._get_source("iomark", "end-1c") ++ prefix = self.text.get("iomark", "end-1c") + if reverse: +- pointer = nhist ++ pointer = nhist # will be decremented + else: + if self.cyclic: +- pointer = -1 +- else: ++ pointer = -1 # will be incremented ++ else: # abort history_next + self.text.bell() + return + nprefix = len(prefix) + while 1: +- if reverse: +- pointer = pointer - 1 +- else: +- pointer = pointer + 1 ++ pointer += -1 if reverse else 1 + if pointer < 0 or pointer >= nhist: + self.text.bell() +- if not self.cyclic and pointer < 0: ++ if not self.cyclic and pointer < 0: # abort history_prev + return + else: +- if self._get_source("iomark", "end-1c") != prefix: ++ if self.text.get("iomark", "end-1c") != prefix: + self.text.delete("iomark", "end-1c") +- self._put_source("iomark", prefix) ++ self.text.insert("iomark", prefix) + pointer = prefix = None + break + item = self.history[pointer] + if item[:nprefix] == prefix and len(item) > nprefix: + self.text.delete("iomark", "end-1c") +- self._put_source("iomark", item) ++ self.text.insert("iomark", item) + break +- self.text.mark_set("insert", "end-1c") + self.text.see("insert") + self.text.tag_remove("sel", "1.0", "end") +- self.history_pointer = pointer +- self.history_prefix = prefix ++ self.pointer = pointer ++ self.prefix = prefix + +- def history_store(self, source): ++ def store(self, source): ++ "Store Shell input statement into history list." + source = source.strip() + if len(source) > 2: + # avoid duplicates +@@ -84,5 +96,11 @@ + except ValueError: + pass + self.history.append(source) +- self.history_pointer = None +- self.history_prefix = None ++ self.pointer = None ++ self.prefix = None ++ ++if __name__ == "__main__": ++ from test import test_support as support ++ support.use_resources = ['gui'] ++ from unittest import main ++ main('idlelib.idle_test.test_idlehistory', verbosity=2, exit=False) +diff -r ab05e7dd2788 Lib/idlelib/PathBrowser.py +--- a/Lib/idlelib/PathBrowser.py ++++ b/Lib/idlelib/PathBrowser.py +@@ -92,4 +92,5 @@ + mainloop() + + if __name__ == "__main__": +- main() ++ from unittest import main ++ main('idlelib.idle_test.test_pathbrowser', verbosity=2, exit=False) +diff -r ab05e7dd2788 Lib/idlelib/PyShell.py +--- a/Lib/idlelib/PyShell.py ++++ b/Lib/idlelib/PyShell.py +@@ -50,35 +50,55 @@ + # internal warnings to the console. ScriptBinding.check_syntax() will + # temporarily redirect the stream to the shell window to display warnings when + # checking user's code. +-global warning_stream +-warning_stream = sys.__stderr__ +-try: +- import warnings +-except ImportError: +- pass +-else: +- def idle_showwarning(message, category, filename, lineno, +- file=None, line=None): +- if file is None: +- file = warning_stream +- try: +- file.write(warnings.formatwarning(message, category, filename, +- lineno, line=line)) +- except IOError: +- pass ## file (probably __stderr__) is invalid, warning dropped. +- warnings.showwarning = idle_showwarning +- def idle_formatwarning(message, category, filename, lineno, line=None): +- """Format warnings the IDLE way""" +- s = "\nWarning (from warnings module):\n" +- s += ' File \"%s\", line %s\n' % (filename, lineno) +- if line is None: +- line = linecache.getline(filename, lineno) +- line = line.strip() +- if line: +- s += " %s\n" % line +- s += "%s: %s\n>>> " % (category.__name__, message) +- return s +- warnings.formatwarning = idle_formatwarning ++warning_stream = sys.__stderr__ # None, at least on Windows, if no console. ++import warnings ++ ++def idle_formatwarning(message, category, filename, lineno, line=None): ++ """Format warnings the IDLE way.""" ++ ++ s = "\nWarning (from warnings module):\n" ++ s += ' File \"%s\", line %s\n' % (filename, lineno) ++ if line is None: ++ line = linecache.getline(filename, lineno) ++ line = line.strip() ++ if line: ++ s += " %s\n" % line ++ s += "%s: %s\n" % (category.__name__, message) ++ return s ++ ++def idle_showwarning( ++ message, category, filename, lineno, file=None, line=None): ++ """Show Idle-format warning (after replacing warnings.showwarning). ++ ++ The differences are the formatter called, the file=None replacement, ++ which can be None, the capture of the consequence AttributeError, ++ and the output of a hard-coded prompt. ++ """ ++ if file is None: ++ file = warning_stream ++ try: ++ file.write(idle_formatwarning( ++ message, category, filename, lineno, line=line)) ++ file.write(">>> ") ++ except (AttributeError, IOError): ++ pass # if file (probably __stderr__) is invalid, skip warning. ++ ++_warnings_showwarning = None ++ ++def capture_warnings(capture): ++ "Replace warning.showwarning with idle_showwarning, or reverse." ++ ++ global _warnings_showwarning ++ if capture: ++ if _warnings_showwarning is None: ++ _warnings_showwarning = warnings.showwarning ++ warnings.showwarning = idle_showwarning ++ else: ++ if _warnings_showwarning is not None: ++ warnings.showwarning = _warnings_showwarning ++ _warnings_showwarning = None ++ ++capture_warnings(True) + + def extended_linecache_checkcache(filename=None, + orig_checkcache=linecache.checkcache): +@@ -370,6 +390,7 @@ + self.port = PORT + self.original_compiler_flags = self.compile.compiler.flags + ++ _afterid = None + rpcclt = None + rpcpid = None + +@@ -409,7 +430,7 @@ + try: + self.rpcclt = MyRPCClient(addr) + break +- except socket.error, err: ++ except socket.error as err: + pass + else: + self.display_port_binding_error() +@@ -430,7 +451,7 @@ + self.rpcclt.listening_sock.settimeout(10) + try: + self.rpcclt.accept() +- except socket.timeout, err: ++ except socket.timeout as err: + self.display_no_subprocess_error() + return None + self.rpcclt.register("console", self.tkconsole) +@@ -465,7 +486,7 @@ + self.spawn_subprocess() + try: + self.rpcclt.accept() +- except socket.timeout, err: ++ except socket.timeout as err: + self.display_no_subprocess_error() + return None + self.transfer_path(with_cwd=with_cwd) +@@ -497,6 +518,8 @@ + threading.Thread(target=self.__request_interrupt).start() + + def kill_subprocess(self): ++ if self._afterid is not None: ++ self.tkconsole.text.after_cancel(self._afterid) + try: + self.rpcclt.close() + except AttributeError: # no socket +@@ -569,8 +592,8 @@ + pass + # Reschedule myself + if not self.tkconsole.closing: +- self.tkconsole.text.after(self.tkconsole.pollinterval, +- self.poll_subprocess) ++ self._afterid = self.tkconsole.text.after( ++ self.tkconsole.pollinterval, self.poll_subprocess) + + debugger = None + +@@ -844,7 +867,6 @@ + ] + + if macosxSupport.runningAsOSXApp(): +- del menu_specs[-3] + menu_specs[-2] = ("windows", "_Window") + + +@@ -988,10 +1010,6 @@ + self.stop_readline() + self.canceled = True + self.closing = True +- # Wait for poll_subprocess() rescheduling to stop +- self.text.after(2 * self.pollinterval, self.close2) +- +- def close2(self): + return EditorWindow.close(self) + + def _close(self): +@@ -1260,7 +1278,7 @@ + def resetoutput(self): + source = self.text.get("iomark", "end-1c") + if self.history: +- self.history.history_store(source) ++ self.history.store(source) + if self.text.get("end-2c") != "\n": + self.text.insert("end-1c", "\n") + self.text.mark_set("iomark", "end-1c") +@@ -1430,6 +1448,7 @@ + def main(): + global flist, root, use_subprocess + ++ capture_warnings(True) + use_subprocess = True + enable_shell = False + enable_edit = False +@@ -1439,7 +1458,7 @@ + startup = False + try: + opts, args = getopt.getopt(sys.argv[1:], "c:deihnr:st:") +- except getopt.error, msg: ++ except getopt.error as msg: + sys.stderr.write("Error: %s\n" % str(msg)) + sys.stderr.write(usage_msg) + sys.exit(2) +@@ -1562,7 +1581,10 @@ + while flist.inversedict: # keep IDLE running while files are open. + root.mainloop() + root.destroy() ++ capture_warnings(False) + + if __name__ == "__main__": + sys.modules['PyShell'] = sys.modules['__main__'] + main() ++ ++capture_warnings(False) # Make sure turned off; see issue 18081 +diff -r ab05e7dd2788 Lib/idlelib/RstripExtension.py +--- a/Lib/idlelib/RstripExtension.py ++++ b/Lib/idlelib/RstripExtension.py +@@ -1,13 +1,9 @@ + 'Provides "Strip trailing whitespace" under the "Format" menu.' + +-__author__ = "Roger D. Serwy " +- + class RstripExtension: + + menudefs = [ +- ('format', [None, +- ('Strip trailing whitespace', '<>'), +- ]),] ++ ('format', [None, ('Strip trailing whitespace', '<>'), ] ), ] + + def __init__(self, editwin): + self.editwin = editwin +@@ -20,10 +16,18 @@ + + undo.undo_block_start() + +- end_line = int(float(text.index('end'))) + 1 ++ end_line = int(float(text.index('end'))) + for cur in range(1, end_line): +- txt = text.get('%i.0' % cur, '%i.0 lineend' % cur) ++ txt = text.get('%i.0' % cur, '%i.end' % cur) ++ raw = len(txt) + cut = len(txt.rstrip()) +- text.delete('%i.%i' % (cur, cut), '%i.0 lineend' % cur) ++ # Since text.delete() marks file as changed, even if not, ++ # only call it when needed to actually delete something. ++ if cut < raw: ++ text.delete('%i.%i' % (cur, cut), '%i.end' % cur) + + undo.undo_block_stop() ++ ++if __name__ == "__main__": ++ import unittest ++ unittest.main('idlelib.idle_test.test_rstrip', verbosity=2, exit=False) +diff -r ab05e7dd2788 Lib/idlelib/ScriptBinding.py +--- a/Lib/idlelib/ScriptBinding.py ++++ b/Lib/idlelib/ScriptBinding.py +@@ -70,13 +70,13 @@ + f = open(filename, 'r') + try: + tabnanny.process_tokens(tokenize.generate_tokens(f.readline)) +- except tokenize.TokenError, msg: ++ except tokenize.TokenError as msg: + msgtxt, (lineno, start) = msg + self.editwin.gotoline(lineno) + self.errorbox("Tabnanny Tokenizing Error", + "Token Error: %s" % msgtxt) + return False +- except tabnanny.NannyNag, nag: ++ except tabnanny.NannyNag as nag: + # The error messages from tabnanny are too confusing... + self.editwin.gotoline(nag.get_lineno()) + self.errorbox("Tab/space error", indent_message) +@@ -87,9 +87,8 @@ + self.shell = shell = self.flist.open_shell() + saved_stream = shell.get_warning_stream() + shell.set_warning_stream(shell.stderr) +- f = open(filename, 'r') +- source = f.read() +- f.close() ++ with open(filename, 'r') as f: ++ source = f.read() + if '\r' in source: + source = re.sub(r"\r\n", "\n", source) + source = re.sub(r"\r", "\n", source) +@@ -101,7 +100,7 @@ + try: + # If successful, return the compiled code + return compile(source, filename, "exec") +- except (SyntaxError, OverflowError, ValueError), err: ++ except (SyntaxError, OverflowError, ValueError) as err: + try: + msg, (errorfilename, lineno, offset, line) = err + if not errorfilename: +@@ -152,16 +151,16 @@ + dirname = os.path.dirname(filename) + # XXX Too often this discards arguments the user just set... + interp.runcommand("""if 1: +- _filename = %r ++ __file__ = {filename!r} + import sys as _sys + from os.path import basename as _basename + if (not _sys.argv or +- _basename(_sys.argv[0]) != _basename(_filename)): +- _sys.argv = [_filename] ++ _basename(_sys.argv[0]) != _basename(__file__)): ++ _sys.argv = [__file__] + import os as _os +- _os.chdir(%r) +- del _filename, _sys, _basename, _os +- \n""" % (filename, dirname)) ++ _os.chdir({dirname!r}) ++ del _sys, _basename, _os ++ \n""".format(filename=filename, dirname=dirname)) + interp.prepend_syspath(filename) + # XXX KBK 03Jul04 When run w/o subprocess, runtime warnings still + # go to __stderr__. With subprocess, they go to the shell. +diff -r ab05e7dd2788 Lib/idlelib/SearchDialog.py +--- a/Lib/idlelib/SearchDialog.py ++++ b/Lib/idlelib/SearchDialog.py +@@ -24,13 +24,12 @@ + + def create_widgets(self): + f = SearchDialogBase.create_widgets(self) +- self.make_button("Find", self.default_command, 1) ++ self.make_button("Find Next", self.default_command, 1) + + def default_command(self, event=None): + if not self.engine.getprog(): + return +- if self.find_again(self.text): +- self.close() ++ self.find_again(self.text) + + def find_again(self, text): + if not self.engine.getpat(): +diff -r ab05e7dd2788 Lib/idlelib/SearchDialogBase.py +--- a/Lib/idlelib/SearchDialogBase.py ++++ b/Lib/idlelib/SearchDialogBase.py +@@ -1,6 +1,23 @@ ++'''Define SearchDialogBase used by Search, Replace, and Grep dialogs.''' + from Tkinter import * + + class SearchDialogBase: ++ '''Create most of a modal search dialog (make_frame, create_widgets). ++ ++ The wide left column contains: ++ 1 or 2 text entry lines (create_entries, make_entry); ++ a row of standard radiobuttons (create_option_buttons); ++ a row of dialog specific radiobuttons (create_other_buttons). ++ ++ The narrow right column contains command buttons ++ (create_command_buttons, make_button). ++ These are bound to functions that execute the command. ++ ++ Except for command buttons, this base class is not limited to ++ items common to all three subclasses. Rather, it is the Find dialog ++ minus the "Find Next" command and its execution function. ++ The other dialogs override methods to replace and add widgets. ++ ''' + + title = "Search Dialog" + icon = "Search" +diff -r ab05e7dd2788 Lib/idlelib/SearchEngine.py +--- a/Lib/idlelib/SearchEngine.py ++++ b/Lib/idlelib/SearchEngine.py +@@ -1,26 +1,34 @@ ++'''Define SearchEngine for search dialogs.''' + import re +-from Tkinter import * ++from Tkinter import StringVar, BooleanVar, TclError + import tkMessageBox + + def get(root): ++ '''Return the singleton SearchEngine instance for the process. ++ ++ The single SearchEngine saves settings between dialog instances. ++ If there is not a SearchEngine already, make one. ++ ''' + if not hasattr(root, "_searchengine"): + root._searchengine = SearchEngine(root) +- # XXX This will never garbage-collect -- who cares ++ # This creates a cycle that persists until root is deleted. + return root._searchengine + + class SearchEngine: ++ """Handles searching a text widget for Find, Replace, and Grep.""" + + def __init__(self, root): +- self.root = root +- # State shared by search, replace, and grep; +- # the search dialogs bind these to UI elements. +- self.patvar = StringVar(root) # search pattern +- self.revar = BooleanVar(root) # regular expression? +- self.casevar = BooleanVar(root) # match case? +- self.wordvar = BooleanVar(root) # match whole word? +- self.wrapvar = BooleanVar(root) # wrap around buffer? +- self.wrapvar.set(1) # (on by default) +- self.backvar = BooleanVar(root) # search backwards? ++ '''Initialize Variables that save search state. ++ ++ The dialogs bind these to the UI elements present in the dialogs. ++ ''' ++ self.root = root # need for report_error() ++ self.patvar = StringVar(root, '') # search pattern ++ self.revar = BooleanVar(root, False) # regular expression? ++ self.casevar = BooleanVar(root, False) # match case? ++ self.wordvar = BooleanVar(root, False) # match whole word? ++ self.wrapvar = BooleanVar(root, True) # wrap around buffer? ++ self.backvar = BooleanVar(root, False) # search backwards? + + # Access methods + +@@ -47,15 +55,23 @@ + + # Higher level access methods + ++ def setcookedpat(self, pat): ++ "Set pattern after escaping if re." ++ # called only in SearchDialog.py: 66 ++ if self.isre(): ++ pat = re.escape(pat) ++ self.setpat(pat) ++ + def getcookedpat(self): + pat = self.getpat() +- if not self.isre(): ++ if not self.isre(): # if True, see setcookedpat + pat = re.escape(pat) + if self.isword(): + pat = r"\b%s\b" % pat + return pat + + def getprog(self): ++ "Return compiled cooked search pattern." + pat = self.getpat() + if not pat: + self.report_error(pat, "Empty regular expression") +@@ -66,7 +82,7 @@ + flags = flags | re.IGNORECASE + try: + prog = re.compile(pat, flags) +- except re.error, what: ++ except re.error as what: + try: + msg, col = what + except: +@@ -77,40 +93,33 @@ + return prog + + def report_error(self, pat, msg, col=-1): +- # Derived class could overrid this with something fancier ++ # Derived class could override this with something fancier + msg = "Error: " + str(msg) + if pat: +- msg = msg + "\np\Pattern: " + str(pat) ++ msg = msg + "\nPattern: " + str(pat) + if col >= 0: + msg = msg + "\nOffset: " + str(col) + tkMessageBox.showerror("Regular expression error", + msg, master=self.root) + +- def setcookedpat(self, pat): +- if self.isre(): +- pat = re.escape(pat) +- self.setpat(pat) ++ def search_text(self, text, prog=None, ok=0): ++ '''Return (lineno, matchobj) or None for forward/backward search. + +- def search_text(self, text, prog=None, ok=0): +- """Search a text widget for the pattern. ++ This function calls the right function with the right arguments. ++ It directly return the result of that call. + +- If prog is given, it should be the precompiled pattern. +- Return a tuple (lineno, matchobj); None if not found. ++ Text is a text widget. Prog is a precompiled pattern. ++ The ok parameteris a bit complicated as it has two effects. + +- This obeys the wrap and direction (back) settings. ++ If there is a selection, the search begin at either end, ++ depending on the direction setting and ok, with ok meaning that ++ the search starts with the selection. Otherwise, search begins ++ at the insert mark. + +- The search starts at the selection (if there is one) or +- at the insert mark (otherwise). If the search is forward, +- it starts at the right of the selection; for a backward +- search, it starts at the left end. An empty match exactly +- at either end of the selection (or at the insert mark if +- there is no selection) is ignored unless the ok flag is true +- -- this is done to guarantee progress. ++ To aid progress, the search functions do not return an empty ++ match at the starting position unless ok is True. ++ ''' + +- If the search is allowed to wrap around, it will return the +- original selection if (and only if) it is the only match. +- +- """ + if not prog: + prog = self.getprog() + if not prog: +@@ -179,15 +188,19 @@ + col = len(chars) - 1 + return None + +-# Helper to search backwards in a string. +-# (Optimized for the case where the pattern isn't found.) ++def search_reverse(prog, chars, col): ++ '''Search backwards and return an re match object or None. + +-def search_reverse(prog, chars, col): ++ This is done by searching forwards until there is no match. ++ Prog: compiled re object with a search method returning a match. ++ Chars: line of text, without \n. ++ Col: stop index for the search; the limit for match.end(). ++ ''' + m = prog.search(chars) + if not m: + return None + found = None +- i, j = m.span() ++ i, j = m.span() # m.start(), m.end() == match slice indexes + while i < col and j <= col: + found = m + if i == j: +@@ -198,10 +211,9 @@ + i, j = m.span() + return found + +-# Helper to get selection end points, defaulting to insert mark. +-# Return a tuple of indices ("line.col" strings). +- + def get_selection(text): ++ '''Return tuple of 'line.col' indexes from selection or insert mark. ++ ''' + try: + first = text.index("sel.first") + last = text.index("sel.last") +@@ -213,8 +225,12 @@ + last = first + return first, last + +-# Helper to parse a text index into a (line, col) tuple. +- + def get_line_col(index): ++ '''Return (line, col) tuple of ints from 'line.col' string.''' + line, col = map(int, index.split(".")) # Fails on invalid index + return line, col ++ ++if __name__ == "__main__": ++ from test import support; support.use_resources = ['gui'] ++ import unittest ++ unittest.main('idlelib.idle_test.test_searchengine', verbosity=2, exit=False) +diff -r ab05e7dd2788 Lib/idlelib/configSectionNameDialog.py +--- a/Lib/idlelib/configSectionNameDialog.py ++++ b/Lib/idlelib/configSectionNameDialog.py +@@ -1,97 +1,100 @@ + """ + Dialog that allows user to specify a new config file section name. + Used to get new highlight theme and keybinding set names. ++The 'return value' for the dialog, used two placed in configDialog.py, ++is the .result attribute set in the Ok and Cancel methods. + """ + from Tkinter import * + import tkMessageBox +- + class GetCfgSectionNameDialog(Toplevel): +- def __init__(self,parent,title,message,usedNames): ++ def __init__(self, parent, title, message, used_names): + """ + message - string, informational message to display +- usedNames - list, list of names already in use for validity check ++ used_names - string collection, names already in use for validity check + """ + Toplevel.__init__(self, parent) + self.configure(borderwidth=5) +- self.resizable(height=FALSE,width=FALSE) ++ self.resizable(height=FALSE, width=FALSE) + self.title(title) + self.transient(parent) + self.grab_set() + self.protocol("WM_DELETE_WINDOW", self.Cancel) + self.parent = parent +- self.message=message +- self.usedNames=usedNames +- self.result='' +- self.CreateWidgets() +- self.withdraw() #hide while setting geometry ++ self.message = message ++ self.used_names = used_names ++ self.create_widgets() ++ self.withdraw() #hide while setting geometry + self.update_idletasks() + #needs to be done here so that the winfo_reqwidth is valid + self.messageInfo.config(width=self.frameMain.winfo_reqwidth()) +- self.geometry("+%d+%d" % +- ((parent.winfo_rootx()+((parent.winfo_width()/2) +- -(self.winfo_reqwidth()/2)), +- parent.winfo_rooty()+((parent.winfo_height()/2) +- -(self.winfo_reqheight()/2)) )) ) #centre dialog over parent +- self.deiconify() #geometry set, unhide ++ self.geometry( ++ "+%d+%d" % ( ++ parent.winfo_rootx() + ++ (parent.winfo_width()/2 - self.winfo_reqwidth()/2), ++ parent.winfo_rooty() + ++ (parent.winfo_height()/2 - self.winfo_reqheight()/2) ++ ) ) #centre dialog over parent ++ self.deiconify() #geometry set, unhide + self.wait_window() ++ def create_widgets(self): ++ self.name = StringVar(self.parent) ++ self.fontSize = StringVar(self.parent) ++ self.frameMain = Frame(self, borderwidth=2, relief=SUNKEN) ++ self.frameMain.pack(side=TOP, expand=TRUE, fill=BOTH) ++ self.messageInfo = Message(self.frameMain, anchor=W, justify=LEFT, ++ padx=5, pady=5, text=self.message) #,aspect=200) ++ entryName = Entry(self.frameMain, textvariable=self.name, width=30) ++ entryName.focus_set() ++ self.messageInfo.pack(padx=5, pady=5) #, expand=TRUE, fill=BOTH) ++ entryName.pack(padx=5, pady=5) ++ frameButtons = Frame(self, pady=2) ++ frameButtons.pack(side=BOTTOM) ++ self.buttonOk = Button(frameButtons, text='Ok', ++ width=8, command=self.Ok) ++ self.buttonOk.pack(side=LEFT, padx=5) ++ self.buttonCancel = Button(frameButtons, text='Cancel', ++ width=8, command=self.Cancel) ++ self.buttonCancel.pack(side=RIGHT, padx=5) + +- def CreateWidgets(self): +- self.name=StringVar(self) +- self.fontSize=StringVar(self) +- self.frameMain = Frame(self,borderwidth=2,relief=SUNKEN) +- self.frameMain.pack(side=TOP,expand=TRUE,fill=BOTH) +- self.messageInfo=Message(self.frameMain,anchor=W,justify=LEFT,padx=5,pady=5, +- text=self.message)#,aspect=200) +- entryName=Entry(self.frameMain,textvariable=self.name,width=30) +- entryName.focus_set() +- self.messageInfo.pack(padx=5,pady=5)#,expand=TRUE,fill=BOTH) +- entryName.pack(padx=5,pady=5) +- frameButtons=Frame(self) +- frameButtons.pack(side=BOTTOM,fill=X) +- self.buttonOk = Button(frameButtons,text='Ok', +- width=8,command=self.Ok) +- self.buttonOk.grid(row=0,column=0,padx=5,pady=5) +- self.buttonCancel = Button(frameButtons,text='Cancel', +- width=8,command=self.Cancel) +- self.buttonCancel.grid(row=0,column=1,padx=5,pady=5) +- +- def NameOk(self): +- #simple validity check for a sensible +- #ConfigParser file section name +- nameOk=1 +- name=self.name.get() +- name.strip() ++ def name_ok(self): ++ ''' After stripping entered name, check that it is a sensible ++ ConfigParser file section name. Return it if it is, '' if not. ++ ''' ++ name = self.name.get().strip() + if not name: #no name specified + tkMessageBox.showerror(title='Name Error', + message='No name specified.', parent=self) +- nameOk=0 + elif len(name)>30: #name too long + tkMessageBox.showerror(title='Name Error', + message='Name too long. It should be no more than '+ + '30 characters.', parent=self) +- nameOk=0 +- elif name in self.usedNames: ++ name = '' ++ elif name in self.used_names: + tkMessageBox.showerror(title='Name Error', + message='This name is already in use.', parent=self) +- nameOk=0 +- return nameOk ++ name = '' ++ return name ++ def Ok(self, event=None): ++ name = self.name_ok() ++ if name: ++ self.result = name ++ self.destroy() ++ def Cancel(self, event=None): ++ self.result = '' ++ self.destroy() ++if __name__ == '__main__': ++ import unittest ++ unittest.main('idlelib.idle_test.test_config_name', verbosity=2, exit=False) + +- def Ok(self, event=None): +- if self.NameOk(): +- self.result=self.name.get().strip() +- self.destroy() +- +- def Cancel(self, event=None): +- self.result='' +- self.destroy() +- +-if __name__ == '__main__': +- #test the dialog +- root=Tk() ++ # also human test the dialog ++ root = Tk() + def run(): +- keySeq='' + dlg=GetCfgSectionNameDialog(root,'Get Name', +- 'The information here should need to be word wrapped. Test.') ++ "After the text entered with [Ok] is stripped, , " ++ "'abc', or more that 30 chars are errors. " ++ "Close with a valid entry (printed), [Cancel], or [X]", ++ {'abc'}) + print dlg.result +- Button(root,text='Dialog',command=run).pack() ++ Message(root, text='').pack() # will be needed for oher dialog tests ++ Button(root, text='Click to begin dialog test', command=run).pack() + root.mainloop() +diff -r ab05e7dd2788 Lib/idlelib/help.txt +--- a/Lib/idlelib/help.txt ++++ b/Lib/idlelib/help.txt +@@ -5,7 +5,7 @@ + + File Menu: + +- New Window -- Create a new editing window ++ New File -- Create a new editing window + Open... -- Open an existing file + Recent Files... -- Open a list of recent files + Open Module... -- Open an existing module (searches sys.path) +diff -r ab05e7dd2788 Lib/idlelib/idle_test/README.txt +--- /dev/null ++++ b/Lib/idlelib/idle_test/README.txt +@@ -0,0 +1,108 @@ ++README FOR IDLE TESTS IN IDLELIB.IDLE_TEST ++ ++ ++1. Test Files ++ ++The idle directory, idlelib, has over 60 xyz.py files. The idle_test ++subdirectory should contain a test_xyy.py for each. (For test modules, make ++'xyz' lower case, and possibly shorten it.) Each file should start with the ++something like the following template, with the blanks after after '.' and 'as', ++and before and after '_' filled in. ++--- ++import unittest ++from test.support import requires ++import idlelib. as ++ ++class _Test(unittest.TestCase): ++ ++ def test_(self): ++ ++if __name__ == '__main__': ++ unittest.main(verbosity=2, exit=2) ++--- ++Idle tests are run with unittest; do not use regrtest's test_main. ++ ++Once test_xyy is written, the following should go at the end of xyy.py, ++with xyz (lowercased) added after 'test_'. ++--- ++if __name__ == "__main__": ++ from test import support; support.use_resources = ['gui'] ++ import unittest ++ unittest.main('idlelib.idle_test.test_', verbosity=2, exit=False) ++--- ++ ++ ++2. Gui Tests ++ ++Gui tests need 'requires' and 'use_resources' from test.support ++(test.test_support in 2.7). A test is a gui test if it creates a Tk root or ++master object either directly or indirectly by instantiating a tkinter or ++idle class. For the benefit of buildbot machines that do not have a graphics ++screen, gui tests must be 'guarded' by "requires('gui')" in a setUp ++function or method. This will typically be setUpClass. ++ ++All gui objects must be destroyed by the end of the test, perhaps in a tearDown ++function. Creating the Tk root directly in a setUp allows a reference to be saved ++so it can be properly destroyed in the corresponding tearDown. ++--- ++ @classmethod ++ def setUpClass(cls): ++ requires('gui') ++ cls.root = tk.Tk() ++ ++ @classmethod ++ def tearDownClass(cls): ++ cls.root.destroy() ++--- ++ ++Support.requires('gui') returns true if it is either called in a main module ++(which never happens on buildbots) or if use_resources contains 'gui'. ++Use_resources is set by test.regrtest but not by unittest. So when running ++tests in another module with unittest, we set it ourselves, as in the xyz.py ++template above. ++ ++Since non-gui tests always run, but gui tests only sometimes, tests of non-gui ++operations should best avoid needing a gui. Methods that make incidental use of ++tkinter (tk) variables and messageboxes can do this by using the mock classes in ++idle_test/mock_tk.py. There is also a mock text that will handle some uses of the ++tk Text widget. ++ ++ ++3. Running Tests ++ ++Assume that xyz.py and test_xyz.py end with the "if __name__" statements given ++above. In Idle, pressing F5 in an editor window with either loaded will run all ++tests in the test_xyz file with the version of Python running Idle. The test ++report and any tracebacks will appear in the Shell window. The options in these ++"if __name__" statements are appropriate for developers running (as opposed to ++importing) either of the files during development: verbosity=2 lists all test ++methods in the file; exit=False avoids a spurious sys.exit traceback that would ++otherwise occur when running in Idle. The following command lines also run ++all test methods, including gui tests, in test_xyz.py. (The exceptions are that ++idlelib and idlelib.idle start Idle and idlelib.PyShell should (issue 18330).) ++ ++python -m idlelib.xyz # With the capitalization of the xyz module ++python -m idlelib.idle_test.test_xyz ++ ++To run all idle_test/test_*.py tests, either interactively ++('>>>', with unittest imported) or from a command line, use one of the ++following. (Notes: unittest does not run gui tests; in 2.7, 'test ' (with the ++space) is 'test.regrtest '; where present, -v and -ugui can be omitted.) ++ ++>>> unittest.main('idlelib.idle_test', verbosity=2, exit=False) ++python -m unittest -v idlelib.idle_test ++python -m test -v -ugui test_idle ++python -m test.test_idle ++ ++The idle tests are 'discovered' by idlelib.idle_test.__init__.load_tests, ++which is also imported into test.test_idle. Normally, neither file should be ++changed when working on individual test modules. The third command runs runs ++unittest indirectly through regrtest. The same happens when the entire test ++suite is run with 'python -m test'. So that command must work for buildbots ++to stay green. Idle tests must not disturb the environment in a way that ++makes other tests fail (issue 18081). ++ ++To run an individual Testcase or test method, extend the dotted name given to ++unittest on the command line. (But gui tests will not this way.) ++ ++python -m unittest -v idlelib.idle_test.text_xyz.Test_case.test_meth +diff -r ab05e7dd2788 Lib/idlelib/idle_test/__init__.py +--- /dev/null ++++ b/Lib/idlelib/idle_test/__init__.py +@@ -0,0 +1,9 @@ ++from os.path import dirname ++ ++def load_tests(loader, standard_tests, pattern): ++ this_dir = dirname(__file__) ++ top_dir = dirname(dirname(this_dir)) ++ package_tests = loader.discover(start_dir=this_dir, pattern='test*.py', ++ top_level_dir=top_dir) ++ standard_tests.addTests(package_tests) ++ return standard_tests +diff -r ab05e7dd2788 Lib/idlelib/idle_test/mock_idle.py +--- /dev/null ++++ b/Lib/idlelib/idle_test/mock_idle.py +@@ -0,0 +1,27 @@ ++'''Mock classes that imitate idlelib modules or classes. ++ ++Attributes and methods will be added as needed for tests. ++''' ++ ++from idlelib.idle_test.mock_tk import Text ++ ++class Editor(object): ++ '''Minimally imitate EditorWindow.EditorWindow class. ++ ''' ++ def __init__(self, flist=None, filename=None, key=None, root=None): ++ self.text = Text() ++ self.undo = UndoDelegator() ++ ++ def get_selection_indices(self): ++ first = self.text.index('1.0') ++ last = self.text.index('end') ++ return first, last ++ ++class UndoDelegator(object): ++ '''Minimally imitate UndoDelegator,UndoDelegator class. ++ ''' ++ # A real undo block is only needed for user interaction. ++ def undo_block_start(*args): ++ pass ++ def undo_block_stop(*args): ++ pass +diff -r ab05e7dd2788 Lib/idlelib/idle_test/mock_tk.py +--- /dev/null ++++ b/Lib/idlelib/idle_test/mock_tk.py +@@ -0,0 +1,279 @@ ++"""Classes that replace tkinter gui objects used by an object being tested. ++ ++A gui object is anything with a master or parent paramenter, which is typically ++required in spite of what the doc strings say. ++""" ++ ++class Var(object): ++ "Use for String/Int/BooleanVar: incomplete" ++ def __init__(self, master=None, value=None, name=None): ++ self.master = master ++ self.value = value ++ self.name = name ++ def set(self, value): ++ self.value = value ++ def get(self): ++ return self.value ++ ++class Mbox_func(object): ++ """Generic mock for messagebox functions, which all have the same signature. ++ ++ Instead of displaying a message box, the mock's call method saves the ++ arguments as instance attributes, which test functions can then examime. ++ """ ++ def __init__(self): ++ self.result = None # The return for all show funcs ++ def __call__(self, title, message, *args, **kwds): ++ # Save all args for possible examination by tester ++ self.title = title ++ self.message = message ++ self.args = args ++ self.kwds = kwds ++ return self.result # Set by tester for ask functions ++ ++class Mbox(object): ++ """Mock for tkinter.messagebox with an Mbox_func for each function. ++ ++ This module was 'tkMessageBox' in 2.x; hence the 'import as' in 3.x. ++ Example usage in test_module.py for testing functions in module.py: ++ --- ++from idlelib.idle_test.mock_tk import Mbox ++import module ++ ++orig_mbox = module.tkMessageBox ++showerror = Mbox.showerror # example, for attribute access in test methods ++ ++class Test(unittest.TestCase): ++ ++ @classmethod ++ def setUpClass(cls): ++ module.tkMessageBox = Mbox ++ ++ @classmethod ++ def tearDownClass(cls): ++ module.tkMessageBox = orig_mbox ++ --- ++ For 'ask' functions, set func.result return value before calling the method ++ that uses the message function. When tkMessageBox functions are the ++ only gui alls in a method, this replacement makes the method gui-free, ++ """ ++ askokcancel = Mbox_func() # True or False ++ askquestion = Mbox_func() # 'yes' or 'no' ++ askretrycancel = Mbox_func() # True or False ++ askyesno = Mbox_func() # True or False ++ askyesnocancel = Mbox_func() # True, False, or None ++ showerror = Mbox_func() # None ++ showinfo = Mbox_func() # None ++ showwarning = Mbox_func() # None ++ ++from _tkinter import TclError ++ ++class Text(object): ++ """A semi-functional non-gui replacement for tkinter.Text text editors. ++ ++ The mock's data model is that a text is a list of \n-terminated lines. ++ The mock adds an empty string at the beginning of the list so that the ++ index of actual lines start at 1, as with Tk. The methods never see this. ++ Tk initializes files with a terminal \n that cannot be deleted. It is ++ invisible in the sense that one cannot move the cursor beyond it. ++ ++ This class is only tested (and valid) with strings of ascii chars. ++ For testing, we are not concerned with Tk Text's treatment of, ++ for instance, 0-width characters or character + accent. ++ """ ++ def __init__(self, master=None, cnf={}, **kw): ++ '''Initialize mock, non-gui, text-only Text widget. ++ ++ At present, all args are ignored. Almost all affect visual behavior. ++ There are just a few Text-only options that affect text behavior. ++ ''' ++ self.data = ['', '\n'] ++ ++ def index(self, index): ++ "Return string version of index decoded according to current text." ++ return "%s.%s" % self._decode(index, endflag=1) ++ ++ def _decode(self, index, endflag=0): ++ """Return a (line, char) tuple of int indexes into self.data. ++ ++ This implements .index without converting the result back to a string. ++ The result is contrained by the number of lines and linelengths of ++ self.data. For many indexes, the result is initially (1, 0). ++ ++ The input index may have any of several possible forms: ++ * line.char float: converted to 'line.char' string; ++ * 'line.char' string, where line and char are decimal integers; ++ * 'line.char lineend', where lineend='lineend' (and char is ignored); ++ * 'line.end', where end='end' (same as above); ++ * 'insert', the positions before terminal \n; ++ * 'end', whose meaning depends on the endflag passed to ._endex. ++ * 'sel.first' or 'sel.last', where sel is a tag -- not implemented. ++ """ ++ if isinstance(index, (float, bytes)): ++ index = str(index) ++ try: ++ index=index.lower() ++ except AttributeError: ++ raise TclError('bad text index "%s"' % index) ++ ++ lastline = len(self.data) - 1 # same as number of text lines ++ if index == 'insert': ++ return lastline, len(self.data[lastline]) - 1 ++ elif index == 'end': ++ return self._endex(endflag) ++ ++ line, char = index.split('.') ++ line = int(line) ++ ++ # Out of bounds line becomes first or last ('end') index ++ if line < 1: ++ return 1, 0 ++ elif line > lastline: ++ return self._endex(endflag) ++ ++ linelength = len(self.data[line]) -1 # position before/at \n ++ if char.endswith(' lineend') or char == 'end': ++ return line, linelength ++ # Tk requires that ignored chars before ' lineend' be valid int ++ ++ # Out of bounds char becomes first or last index of line ++ char = int(char) ++ if char < 0: ++ char = 0 ++ elif char > linelength: ++ char = linelength ++ return line, char ++ ++ def _endex(self, endflag): ++ '''Return position for 'end' or line overflow corresponding to endflag. ++ ++ -1: position before terminal \n; for .insert(), .delete ++ 0: position after terminal \n; for .get, .delete index 1 ++ 1: same viewed as beginning of non-existent next line (for .index) ++ ''' ++ n = len(self.data) ++ if endflag == 1: ++ return n, 0 ++ else: ++ n -= 1 ++ return n, len(self.data[n]) + endflag ++ ++ ++ def insert(self, index, chars): ++ "Insert chars before the character at index." ++ ++ if not chars: # ''.splitlines() is [], not [''] ++ return ++ chars = chars.splitlines(True) ++ if chars[-1][-1] == '\n': ++ chars.append('') ++ line, char = self._decode(index, -1) ++ before = self.data[line][:char] ++ after = self.data[line][char:] ++ self.data[line] = before + chars[0] ++ self.data[line+1:line+1] = chars[1:] ++ self.data[line+len(chars)-1] += after ++ ++ ++ def get(self, index1, index2=None): ++ "Return slice from index1 to index2 (default is 'index1+1')." ++ ++ startline, startchar = self._decode(index1) ++ if index2 is None: ++ endline, endchar = startline, startchar+1 ++ else: ++ endline, endchar = self._decode(index2) ++ ++ if startline == endline: ++ return self.data[startline][startchar:endchar] ++ else: ++ lines = [self.data[startline][startchar:]] ++ for i in range(startline+1, endline): ++ lines.append(self.data[i]) ++ lines.append(self.data[endline][:endchar]) ++ return ''.join(lines) ++ ++ ++ def delete(self, index1, index2=None): ++ '''Delete slice from index1 to index2 (default is 'index1+1'). ++ ++ Adjust default index2 ('index+1) for line ends. ++ Do not delete the terminal \n at the very end of self.data ([-1][-1]). ++ ''' ++ startline, startchar = self._decode(index1, -1) ++ if index2 is None: ++ if startchar < len(self.data[startline])-1: ++ # not deleting \n ++ endline, endchar = startline, startchar+1 ++ elif startline < len(self.data) - 1: ++ # deleting non-terminal \n, convert 'index1+1 to start of next line ++ endline, endchar = startline+1, 0 ++ else: ++ # do not delete terminal \n if index1 == 'insert' ++ return ++ else: ++ endline, endchar = self._decode(index2, -1) ++ # restricting end position to insert position excludes terminal \n ++ ++ if startline == endline and startchar < endchar: ++ self.data[startline] = self.data[startline][:startchar] + \ ++ self.data[startline][endchar:] ++ elif startline < endline: ++ self.data[startline] = self.data[startline][:startchar] + \ ++ self.data[endline][endchar:] ++ startline += 1 ++ for i in range(startline, endline+1): ++ del self.data[startline] ++ ++ def compare(self, index1, op, index2): ++ line1, char1 = self._decode(index1) ++ line2, char2 = self._decode(index2) ++ if op == '<': ++ return line1 < line2 or line1 == line2 and char1 < char2 ++ elif op == '<=': ++ return line1 < line2 or line1 == line2 and char1 <= char2 ++ elif op == '>': ++ return line1 > line2 or line1 == line2 and char1 > char2 ++ elif op == '>=': ++ return line1 > line2 or line1 == line2 and char1 >= char2 ++ elif op == '==': ++ return line1 == line2 and char1 == char2 ++ elif op == '!=': ++ return line1 != line2 or char1 != char2 ++ else: ++ raise TclError('''bad comparison operator "%s":''' ++ '''must be <, <=, ==, >=, >, or !=''' % op) ++ ++ # The following Text methods normally do something and return None. ++ # Whether doing nothing is sufficient for a test will depend on the test. ++ ++ def mark_set(self, name, index): ++ "Set mark *name* before the character at index." ++ pass ++ ++ def mark_unset(self, *markNames): ++ "Delete all marks in markNames." ++ ++ def tag_remove(self, tagName, index1, index2=None): ++ "Remove tag tagName from all characters between index1 and index2." ++ pass ++ ++ # The following Text methods affect the graphics screen and return None. ++ # Doing nothing should always be sufficient for tests. ++ ++ def scan_dragto(self, x, y): ++ "Adjust the view of the text according to scan_mark" ++ ++ def scan_mark(self, x, y): ++ "Remember the current X, Y coordinates." ++ ++ def see(self, index): ++ "Scroll screen to make the character at INDEX is visible." ++ pass ++ ++ # The following is a Misc method inherited by Text. ++ # It should properly go in a Misc mock, but is included here for now. ++ ++ def bind(sequence=None, func=None, add=None): ++ "Bind to this widget at event sequence a call to function func." ++ pass +diff -r ab05e7dd2788 Lib/idlelib/idle_test/test_calltips.py +--- /dev/null ++++ b/Lib/idlelib/idle_test/test_calltips.py +@@ -0,0 +1,20 @@ ++import unittest ++import idlelib.CallTips as ct ++CTi = ct.CallTips() ++ ++class Get_entityTest(unittest.TestCase): ++ # In 3.x, get_entity changed from 'instance method' to module function ++ # since 'self' not used. Use dummy instance until change 2.7 also. ++ def test_bad_entity(self): ++ self.assertIsNone(CTi.get_entity('1/0')) ++ def test_good_entity(self): ++ self.assertIs(CTi.get_entity('int'), int) ++ ++class Py2Test(unittest.TestCase): ++ def test_paramtuple_float(self): ++ # 18539: (a,b) becomes '.0' in code object; change that but not float ++ def f((a,b), c=0.0): pass ++ self.assertEqual(ct.get_arg_text(f), '(, c=0.0)') ++ ++if __name__ == '__main__': ++ unittest.main(verbosity=2, exit=False) +diff -r ab05e7dd2788 Lib/idlelib/idle_test/test_config_name.py +--- /dev/null ++++ b/Lib/idlelib/idle_test/test_config_name.py +@@ -0,0 +1,75 @@ ++"""Unit tests for idlelib.configSectionNameDialog""" ++import unittest ++from idlelib.idle_test.mock_tk import Var, Mbox ++from idlelib import configSectionNameDialog as name_dialog_module ++ ++name_dialog = name_dialog_module.GetCfgSectionNameDialog ++ ++class Dummy_name_dialog(object): ++ # Mock for testing the following methods of name_dialog ++ name_ok = name_dialog.name_ok.im_func ++ Ok = name_dialog.Ok.im_func ++ Cancel = name_dialog.Cancel.im_func ++ # Attributes, constant or variable, needed for tests ++ used_names = ['used'] ++ name = Var() ++ result = None ++ destroyed = False ++ def destroy(self): ++ self.destroyed = True ++ ++# name_ok calls Mbox.showerror if name is not ok ++orig_mbox = name_dialog_module.tkMessageBox ++showerror = Mbox.showerror ++ ++class ConfigNameTest(unittest.TestCase): ++ dialog = Dummy_name_dialog() ++ ++ @classmethod ++ def setUpClass(cls): ++ name_dialog_module.tkMessageBox = Mbox ++ ++ @classmethod ++ def tearDownClass(cls): ++ name_dialog_module.tkMessageBox = orig_mbox ++ ++ def test_blank_name(self): ++ self.dialog.name.set(' ') ++ self.assertEqual(self.dialog.name_ok(), '') ++ self.assertEqual(showerror.title, 'Name Error') ++ self.assertIn('No', showerror.message) ++ ++ def test_used_name(self): ++ self.dialog.name.set('used') ++ self.assertEqual(self.dialog.name_ok(), '') ++ self.assertEqual(showerror.title, 'Name Error') ++ self.assertIn('use', showerror.message) ++ ++ def test_long_name(self): ++ self.dialog.name.set('good'*8) ++ self.assertEqual(self.dialog.name_ok(), '') ++ self.assertEqual(showerror.title, 'Name Error') ++ self.assertIn('too long', showerror.message) ++ ++ def test_good_name(self): ++ self.dialog.name.set(' good ') ++ showerror.title = 'No Error' # should not be called ++ self.assertEqual(self.dialog.name_ok(), 'good') ++ self.assertEqual(showerror.title, 'No Error') ++ ++ def test_ok(self): ++ self.dialog.destroyed = False ++ self.dialog.name.set('good') ++ self.dialog.Ok() ++ self.assertEqual(self.dialog.result, 'good') ++ self.assertTrue(self.dialog.destroyed) ++ ++ def test_cancel(self): ++ self.dialog.destroyed = False ++ self.dialog.Cancel() ++ self.assertEqual(self.dialog.result, '') ++ self.assertTrue(self.dialog.destroyed) ++ ++ ++if __name__ == '__main__': ++ unittest.main(verbosity=2, exit=False) +diff -r ab05e7dd2788 Lib/idlelib/idle_test/test_delegator.py +--- /dev/null ++++ b/Lib/idlelib/idle_test/test_delegator.py +@@ -0,0 +1,37 @@ ++import unittest ++from idlelib.Delegator import Delegator ++ ++class DelegatorTest(unittest.TestCase): ++ ++ def test_mydel(self): ++ # test a simple use scenario ++ ++ # initialize ++ mydel = Delegator(int) ++ self.assertIs(mydel.delegate, int) ++ self.assertEqual(mydel._Delegator__cache, set()) ++ ++ # add an attribute: ++ self.assertRaises(AttributeError, mydel.__getattr__, 'xyz') ++ bl = mydel.bit_length ++ self.assertIs(bl, int.bit_length) ++ self.assertIs(mydel.__dict__['bit_length'], int.bit_length) ++ self.assertEqual(mydel._Delegator__cache, {'bit_length'}) ++ ++ # add a second attribute ++ mydel.numerator ++ self.assertEqual(mydel._Delegator__cache, {'bit_length', 'numerator'}) ++ ++ # delete the second (which, however, leaves it in the name cache) ++ del mydel.numerator ++ self.assertNotIn('numerator', mydel.__dict__) ++ self.assertIn('numerator', mydel._Delegator__cache) ++ ++ # reset by calling .setdelegate, which calls .resetcache ++ mydel.setdelegate(float) ++ self.assertIs(mydel.delegate, float) ++ self.assertNotIn('bit_length', mydel.__dict__) ++ self.assertEqual(mydel._Delegator__cache, set()) ++ ++if __name__ == '__main__': ++ unittest.main(verbosity=2, exit=2) +diff -r ab05e7dd2788 Lib/idlelib/idle_test/test_formatparagraph.py +--- /dev/null ++++ b/Lib/idlelib/idle_test/test_formatparagraph.py +@@ -0,0 +1,374 @@ ++# Test the functions and main class method of FormatParagraph.py ++import unittest ++from idlelib import FormatParagraph as fp ++from idlelib.EditorWindow import EditorWindow ++from Tkinter import Tk, Text, TclError ++from test.test_support import requires ++ ++ ++class Is_Get_Test(unittest.TestCase): ++ """Test the is_ and get_ functions""" ++ test_comment = '# This is a comment' ++ test_nocomment = 'This is not a comment' ++ trailingws_comment = '# This is a comment ' ++ leadingws_comment = ' # This is a comment' ++ leadingws_nocomment = ' This is not a comment' ++ ++ def test_is_all_white(self): ++ self.assertTrue(fp.is_all_white('')) ++ self.assertTrue(fp.is_all_white('\t\n\r\f\v')) ++ self.assertFalse(fp.is_all_white(self.test_comment)) ++ ++ def test_get_indent(self): ++ Equal = self.assertEqual ++ Equal(fp.get_indent(self.test_comment), '') ++ Equal(fp.get_indent(self.trailingws_comment), '') ++ Equal(fp.get_indent(self.leadingws_comment), ' ') ++ Equal(fp.get_indent(self.leadingws_nocomment), ' ') ++ ++ def test_get_comment_header(self): ++ Equal = self.assertEqual ++ # Test comment strings ++ Equal(fp.get_comment_header(self.test_comment), '#') ++ Equal(fp.get_comment_header(self.trailingws_comment), '#') ++ Equal(fp.get_comment_header(self.leadingws_comment), ' #') ++ # Test non-comment strings ++ Equal(fp.get_comment_header(self.leadingws_nocomment), ' ') ++ Equal(fp.get_comment_header(self.test_nocomment), '') ++ ++ ++class FindTest(unittest.TestCase): ++ """Test the find_paragraph function in FormatParagraph. ++ ++ Using the runcase() function, find_paragraph() is called with 'mark' set at ++ multiple indexes before and inside the test paragraph. ++ ++ It appears that code with the same indentation as a quoted string is grouped ++ as part of the same paragraph, which is probably incorrect behavior. ++ """ ++ ++ @classmethod ++ def setUpClass(cls): ++ from idlelib.idle_test.mock_tk import Text ++ cls.text = Text() ++ ++ def runcase(self, inserttext, stopline, expected): ++ # Check that find_paragraph returns the expected paragraph when ++ # the mark index is set to beginning, middle, end of each line ++ # up to but not including the stop line ++ text = self.text ++ text.insert('1.0', inserttext) ++ for line in range(1, stopline): ++ linelength = int(text.index("%d.end" % line).split('.')[1]) ++ for col in (0, linelength//2, linelength): ++ tempindex = "%d.%d" % (line, col) ++ self.assertEqual(fp.find_paragraph(text, tempindex), expected) ++ text.delete('1.0', 'end') ++ ++ def test_find_comment(self): ++ comment = ( ++ "# Comment block with no blank lines before\n" ++ "# Comment line\n" ++ "\n") ++ self.runcase(comment, 3, ('1.0', '3.0', '#', comment[0:58])) ++ ++ comment = ( ++ "\n" ++ "# Comment block with whitespace line before and after\n" ++ "# Comment line\n" ++ "\n") ++ self.runcase(comment, 4, ('2.0', '4.0', '#', comment[1:70])) ++ ++ comment = ( ++ "\n" ++ " # Indented comment block with whitespace before and after\n" ++ " # Comment line\n" ++ "\n") ++ self.runcase(comment, 4, ('2.0', '4.0', ' #', comment[1:82])) ++ ++ comment = ( ++ "\n" ++ "# Single line comment\n" ++ "\n") ++ self.runcase(comment, 3, ('2.0', '3.0', '#', comment[1:23])) ++ ++ comment = ( ++ "\n" ++ " # Single line comment with leading whitespace\n" ++ "\n") ++ self.runcase(comment, 3, ('2.0', '3.0', ' #', comment[1:51])) ++ ++ comment = ( ++ "\n" ++ "# Comment immediately followed by code\n" ++ "x = 42\n" ++ "\n") ++ self.runcase(comment, 3, ('2.0', '3.0', '#', comment[1:40])) ++ ++ comment = ( ++ "\n" ++ " # Indented comment immediately followed by code\n" ++ "x = 42\n" ++ "\n") ++ self.runcase(comment, 3, ('2.0', '3.0', ' #', comment[1:53])) ++ ++ comment = ( ++ "\n" ++ "# Comment immediately followed by indented code\n" ++ " x = 42\n" ++ "\n") ++ self.runcase(comment, 3, ('2.0', '3.0', '#', comment[1:49])) ++ ++ def test_find_paragraph(self): ++ teststring = ( ++ '"""String with no blank lines before\n' ++ 'String line\n' ++ '"""\n' ++ '\n') ++ self.runcase(teststring, 4, ('1.0', '4.0', '', teststring[0:53])) ++ ++ teststring = ( ++ "\n" ++ '"""String with whitespace line before and after\n' ++ 'String line.\n' ++ '"""\n' ++ '\n') ++ self.runcase(teststring, 5, ('2.0', '5.0', '', teststring[1:66])) ++ ++ teststring = ( ++ '\n' ++ ' """Indented string with whitespace before and after\n' ++ ' Comment string.\n' ++ ' """\n' ++ '\n') ++ self.runcase(teststring, 5, ('2.0', '5.0', ' ', teststring[1:85])) ++ ++ teststring = ( ++ '\n' ++ '"""Single line string."""\n' ++ '\n') ++ self.runcase(teststring, 3, ('2.0', '3.0', '', teststring[1:27])) ++ ++ teststring = ( ++ '\n' ++ ' """Single line string with leading whitespace."""\n' ++ '\n') ++ self.runcase(teststring, 3, ('2.0', '3.0', ' ', teststring[1:55])) ++ ++ ++class ReformatFunctionTest(unittest.TestCase): ++ """Test the reformat_paragraph function without the editor window.""" ++ ++ def test_reformat_paragrah(self): ++ Equal = self.assertEqual ++ reform = fp.reformat_paragraph ++ hw = "O hello world" ++ Equal(reform(' ', 1), ' ') ++ Equal(reform("Hello world", 20), "Hello world") ++ ++ # Test without leading newline ++ Equal(reform(hw, 1), "O\nhello\nworld") ++ Equal(reform(hw, 6), "O\nhello\nworld") ++ Equal(reform(hw, 7), "O hello\nworld") ++ Equal(reform(hw, 12), "O hello\nworld") ++ Equal(reform(hw, 13), "O hello world") ++ ++ # Test with leading newline ++ hw = "\nO hello world" ++ Equal(reform(hw, 1), "\nO\nhello\nworld") ++ Equal(reform(hw, 6), "\nO\nhello\nworld") ++ Equal(reform(hw, 7), "\nO hello\nworld") ++ Equal(reform(hw, 12), "\nO hello\nworld") ++ Equal(reform(hw, 13), "\nO hello world") ++ ++ ++class ReformatCommentTest(unittest.TestCase): ++ """Test the reformat_comment function without the editor window.""" ++ ++ def test_reformat_comment(self): ++ Equal = self.assertEqual ++ ++ # reformat_comment formats to a minimum of 20 characters ++ test_string = ( ++ " \"\"\"this is a test of a reformat for a triple quoted string" ++ " will it reformat to less than 70 characters for me?\"\"\"") ++ result = fp.reformat_comment(test_string, 70, " ") ++ expected = ( ++ " \"\"\"this is a test of a reformat for a triple quoted string will it\n" ++ " reformat to less than 70 characters for me?\"\"\"") ++ Equal(result, expected) ++ ++ test_comment = ( ++ "# this is a test of a reformat for a triple quoted string will " ++ "it reformat to less than 70 characters for me?") ++ result = fp.reformat_comment(test_comment, 70, "#") ++ expected = ( ++ "# this is a test of a reformat for a triple quoted string will it\n" ++ "# reformat to less than 70 characters for me?") ++ Equal(result, expected) ++ ++ ++class FormatClassTest(unittest.TestCase): ++ def test_init_close(self): ++ instance = fp.FormatParagraph('editor') ++ self.assertEqual(instance.editwin, 'editor') ++ instance.close() ++ self.assertEqual(instance.editwin, None) ++ ++ ++# For testing format_paragraph_event, Initialize FormatParagraph with ++# a mock Editor with .text and .get_selection_indices. The text must ++# be a Text wrapper that adds two methods ++ ++# A real EditorWindow creates unneeded, time-consuming baggage and ++# sometimes emits shutdown warnings like this: ++# "warning: callback failed in WindowList ++# : invalid command name ".55131368.windows". ++# Calling EditorWindow._close in tearDownClass prevents this but causes ++# other problems (windows left open). ++ ++class TextWrapper: ++ def __init__(self, master): ++ self.text = Text(master=master) ++ def __getattr__(self, name): ++ return getattr(self.text, name) ++ def undo_block_start(self): pass ++ def undo_block_stop(self): pass ++ ++class Editor: ++ def __init__(self, root): ++ self.text = TextWrapper(root) ++ get_selection_indices = EditorWindow. get_selection_indices.im_func ++ ++class FormatEventTest(unittest.TestCase): ++ """Test the formatting of text inside a Text widget. ++ ++ This is done with FormatParagraph.format.paragraph_event, ++ which calls functions in the module as appropriate. ++ """ ++ test_string = ( ++ " '''this is a test of a reformat for a triple " ++ "quoted string will it reformat to less than 70 " ++ "characters for me?'''\n") ++ multiline_test_string = ( ++ " '''The first line is under the max width.\n" ++ " The second line's length is way over the max width. It goes " ++ "on and on until it is over 100 characters long.\n" ++ " Same thing with the third line. It is also way over the max " ++ "width, but FormatParagraph will fix it.\n" ++ " '''\n") ++ multiline_test_comment = ( ++ "# The first line is under the max width.\n" ++ "# The second line's length is way over the max width. It goes on " ++ "and on until it is over 100 characters long.\n" ++ "# Same thing with the third line. It is also way over the max " ++ "width, but FormatParagraph will fix it.\n" ++ "# The fourth line is short like the first line.") ++ ++ @classmethod ++ def setUpClass(cls): ++ requires('gui') ++ cls.root = Tk() ++ editor = Editor(root=cls.root) ++ cls.text = editor.text.text # Test code does not need the wrapper. ++ cls.formatter = fp.FormatParagraph(editor).format_paragraph_event ++ # Sets the insert mark just after the re-wrapped and inserted text. ++ ++ @classmethod ++ def tearDownClass(cls): ++ cls.root.destroy() ++ ++ def test_short_line(self): ++ self.text.insert('1.0', "Short line\n") ++ self.formatter("Dummy") ++ self.assertEqual(self.text.get('1.0', 'insert'), "Short line\n" ) ++ self.text.delete('1.0', 'end') ++ ++ def test_long_line(self): ++ text = self.text ++ ++ # Set cursor ('insert' mark) to '1.0', within text. ++ text.insert('1.0', self.test_string) ++ text.mark_set('insert', '1.0') ++ self.formatter('ParameterDoesNothing') ++ result = text.get('1.0', 'insert') ++ # find function includes \n ++ expected = ( ++" '''this is a test of a reformat for a triple quoted string will it\n" ++" reformat to less than 70 characters for me?'''\n") # yes ++ self.assertEqual(result, expected) ++ text.delete('1.0', 'end') ++ ++ # Select from 1.11 to line end. ++ text.insert('1.0', self.test_string) ++ text.tag_add('sel', '1.11', '1.end') ++ self.formatter('ParameterDoesNothing') ++ result = text.get('1.0', 'insert') ++ # selection excludes \n ++ expected = ( ++" '''this is a test of a reformat for a triple quoted string will it reformat\n" ++" to less than 70 characters for me?'''") # no ++ self.assertEqual(result, expected) ++ text.delete('1.0', 'end') ++ ++ def test_multiple_lines(self): ++ text = self.text ++ # Select 2 long lines. ++ text.insert('1.0', self.multiline_test_string) ++ text.tag_add('sel', '2.0', '4.0') ++ self.formatter('ParameterDoesNothing') ++ result = text.get('2.0', 'insert') ++ expected = ( ++" The second line's length is way over the max width. It goes on and\n" ++" on until it is over 100 characters long. Same thing with the third\n" ++" line. It is also way over the max width, but FormatParagraph will\n" ++" fix it.\n") ++ self.assertEqual(result, expected) ++ text.delete('1.0', 'end') ++ ++ def test_comment_block(self): ++ text = self.text ++ ++ # Set cursor ('insert') to '1.0', within block. ++ text.insert('1.0', self.multiline_test_comment) ++ self.formatter('ParameterDoesNothing') ++ result = text.get('1.0', 'insert') ++ expected = ( ++"# The first line is under the max width. The second line's length is\n" ++"# way over the max width. It goes on and on until it is over 100\n" ++"# characters long. Same thing with the third line. It is also way over\n" ++"# the max width, but FormatParagraph will fix it. The fourth line is\n" ++"# short like the first line.\n") ++ self.assertEqual(result, expected) ++ text.delete('1.0', 'end') ++ ++ # Select line 2, verify line 1 unaffected. ++ text.insert('1.0', self.multiline_test_comment) ++ text.tag_add('sel', '2.0', '3.0') ++ self.formatter('ParameterDoesNothing') ++ result = text.get('1.0', 'insert') ++ expected = ( ++"# The first line is under the max width.\n" ++"# The second line's length is way over the max width. It goes on and\n" ++"# on until it is over 100 characters long.\n") ++ self.assertEqual(result, expected) ++ text.delete('1.0', 'end') ++ ++# The following block worked with EditorWindow but fails with the mock. ++# Lines 2 and 3 get pasted together even though the previous block left ++# the previous line alone. More investigation is needed. ++## # Select lines 3 and 4 ++## text.insert('1.0', self.multiline_test_comment) ++## text.tag_add('sel', '3.0', '5.0') ++## self.formatter('ParameterDoesNothing') ++## result = text.get('3.0', 'insert') ++## expected = ( ++##"# Same thing with the third line. It is also way over the max width,\n" ++##"# but FormatParagraph will fix it. The fourth line is short like the\n" ++##"# first line.\n") ++## self.assertEqual(result, expected) ++## text.delete('1.0', 'end') ++ ++ ++if __name__ == '__main__': ++ unittest.main(verbosity=2, exit=2) +diff -r ab05e7dd2788 Lib/idlelib/idle_test/test_grep.py +--- /dev/null ++++ b/Lib/idlelib/idle_test/test_grep.py +@@ -0,0 +1,82 @@ ++""" !Changing this line will break Test_findfile.test_found! ++Non-gui unit tests for idlelib.GrepDialog methods. ++dummy_command calls grep_it calls findfiles. ++An exception raised in one method will fail callers. ++Otherwise, tests are mostly independent. ++*** Currently only test grep_it. ++""" ++import unittest ++from test.test_support import captured_stdout, findfile ++from idlelib.idle_test.mock_tk import Var ++from idlelib.GrepDialog import GrepDialog ++import re ++ ++__file__ = findfile('idlelib/idle_test') + '/test_grep.py' ++ ++class Dummy_searchengine: ++ '''GrepDialog.__init__ calls parent SearchDiabolBase which attaches the ++ passed in SearchEngine instance as attribute 'engine'. Only a few of the ++ many possible self.engine.x attributes are needed here. ++ ''' ++ def getpat(self): ++ return self._pat ++ ++searchengine = Dummy_searchengine() ++ ++class Dummy_grep: ++ # Methods tested ++ #default_command = GrepDialog.default_command ++ grep_it = GrepDialog.grep_it.im_func ++ findfiles = GrepDialog.findfiles.im_func ++ # Other stuff needed ++ recvar = Var(False) ++ engine = searchengine ++ def close(self): # gui method ++ pass ++ ++grep = Dummy_grep() ++ ++class FindfilesTest(unittest.TestCase): ++ # findfiles is really a function, not a method, could be iterator ++ # test that filename return filename ++ # test that idlelib has many .py files ++ # test that recursive flag adds idle_test .py files ++ pass ++ ++class Grep_itTest(unittest.TestCase): ++ # Test captured reports with 0 and some hits. ++ # Should test file names, but Windows reports have mixed / and \ separators ++ # from incomplete replacement, so 'later'. ++ ++ def report(self, pat): ++ grep.engine._pat = pat ++ with captured_stdout() as s: ++ grep.grep_it(re.compile(pat), __file__) ++ lines = s.getvalue().split('\n') ++ lines.pop() # remove bogus '' after last \n ++ return lines ++ ++ def test_unfound(self): ++ pat = 'xyz*'*7 ++ lines = self.report(pat) ++ self.assertEqual(len(lines), 2) ++ self.assertIn(pat, lines[0]) ++ self.assertEqual(lines[1], 'No hits.') ++ ++ def test_found(self): ++ ++ pat = '""" !Changing this line will break Test_findfile.test_found!' ++ lines = self.report(pat) ++ self.assertEqual(len(lines), 5) ++ self.assertIn(pat, lines[0]) ++ self.assertIn('py: 1:', lines[1]) # line number 1 ++ self.assertIn('2', lines[3]) # hits found 2 ++ self.assertTrue(lines[4].startswith('(Hint:')) ++ ++class Default_commandTest(unittest.TestCase): ++ # To write this, mode OutputWindow import to top of GrepDialog ++ # so it can be replaced by captured_stdout in class setup/teardown. ++ pass ++ ++if __name__ == '__main__': ++ unittest.main(verbosity=2, exit=False) +diff -r ab05e7dd2788 Lib/idlelib/idle_test/test_idlehistory.py +--- /dev/null ++++ b/Lib/idlelib/idle_test/test_idlehistory.py +@@ -0,0 +1,166 @@ ++import unittest ++from test.test_support import requires ++ ++import Tkinter as tk ++from Tkinter import Text as tkText ++from idlelib.idle_test.mock_tk import Text as mkText ++from idlelib.IdleHistory import History ++from idlelib.configHandler import idleConf ++ ++line1 = 'a = 7' ++line2 = 'b = a' ++ ++class StoreTest(unittest.TestCase): ++ '''Tests History.__init__ and History.store with mock Text''' ++ ++ @classmethod ++ def setUpClass(cls): ++ cls.text = mkText() ++ cls.history = History(cls.text) ++ ++ def tearDown(self): ++ self.text.delete('1.0', 'end') ++ self.history.history = [] ++ ++ def test_init(self): ++ self.assertIs(self.history.text, self.text) ++ self.assertEqual(self.history.history, []) ++ self.assertIsNone(self.history.prefix) ++ self.assertIsNone(self.history.pointer) ++ self.assertEqual(self.history.cyclic, ++ idleConf.GetOption("main", "History", "cyclic", 1, "bool")) ++ ++ def test_store_short(self): ++ self.history.store('a') ++ self.assertEqual(self.history.history, []) ++ self.history.store(' a ') ++ self.assertEqual(self.history.history, []) ++ ++ def test_store_dup(self): ++ self.history.store(line1) ++ self.assertEqual(self.history.history, [line1]) ++ self.history.store(line2) ++ self.assertEqual(self.history.history, [line1, line2]) ++ self.history.store(line1) ++ self.assertEqual(self.history.history, [line2, line1]) ++ ++ def test_store_reset(self): ++ self.history.prefix = line1 ++ self.history.pointer = 0 ++ self.history.store(line2) ++ self.assertIsNone(self.history.prefix) ++ self.assertIsNone(self.history.pointer) ++ ++ ++class TextWrapper: ++ def __init__(self, master): ++ self.text = tkText(master=master) ++ self._bell = False ++ def __getattr__(self, name): ++ return getattr(self.text, name) ++ def bell(self): ++ self._bell = True ++ ++class FetchTest(unittest.TestCase): ++ '''Test History.fetch with wrapped tk.Text. ++ ''' ++ @classmethod ++ def setUpClass(cls): ++ requires('gui') ++ cls.root = tk.Tk() ++ ++ def setUp(self): ++ self.text = text = TextWrapper(self.root) ++ text.insert('1.0', ">>> ") ++ text.mark_set('iomark', '1.4') ++ text.mark_gravity('iomark', 'left') ++ self.history = History(text) ++ self.history.history = [line1, line2] ++ ++ @classmethod ++ def tearDownClass(cls): ++ cls.root.destroy() ++ ++ def fetch_test(self, reverse, line, prefix, index, bell=False): ++ # Perform one fetch as invoked by Alt-N or Alt-P ++ # Test the result. The line test is the most important. ++ # The last two are diagnostic of fetch internals. ++ History = self.history ++ History.fetch(reverse) ++ ++ Equal = self.assertEqual ++ Equal(self.text.get('iomark', 'end-1c'), line) ++ Equal(self.text._bell, bell) ++ if bell: ++ self.text._bell = False ++ Equal(History.prefix, prefix) ++ Equal(History.pointer, index) ++ Equal(self.text.compare("insert", '==', "end-1c"), 1) ++ ++ def test_fetch_prev_cyclic(self): ++ prefix = '' ++ test = self.fetch_test ++ test(True, line2, prefix, 1) ++ test(True, line1, prefix, 0) ++ test(True, prefix, None, None, bell=True) ++ ++ def test_fetch_next_cyclic(self): ++ prefix = '' ++ test = self.fetch_test ++ test(False, line1, prefix, 0) ++ test(False, line2, prefix, 1) ++ test(False, prefix, None, None, bell=True) ++ ++ # Prefix 'a' tests skip line2, which starts with 'b' ++ def test_fetch_prev_prefix(self): ++ prefix = 'a' ++ self.text.insert('iomark', prefix) ++ self.fetch_test(True, line1, prefix, 0) ++ self.fetch_test(True, prefix, None, None, bell=True) ++ ++ def test_fetch_next_prefix(self): ++ prefix = 'a' ++ self.text.insert('iomark', prefix) ++ self.fetch_test(False, line1, prefix, 0) ++ self.fetch_test(False, prefix, None, None, bell=True) ++ ++ def test_fetch_prev_noncyclic(self): ++ prefix = '' ++ self.history.cyclic = False ++ test = self.fetch_test ++ test(True, line2, prefix, 1) ++ test(True, line1, prefix, 0) ++ test(True, line1, prefix, 0, bell=True) ++ ++ def test_fetch_next_noncyclic(self): ++ prefix = '' ++ self.history.cyclic = False ++ test = self.fetch_test ++ test(False, prefix, None, None, bell=True) ++ test(True, line2, prefix, 1) ++ test(False, prefix, None, None, bell=True) ++ test(False, prefix, None, None, bell=True) ++ ++ def test_fetch_cursor_move(self): ++ # Move cursor after fetch ++ self.history.fetch(reverse=True) # initialization ++ self.text.mark_set('insert', 'iomark') ++ self.fetch_test(True, line2, None, None, bell=True) ++ ++ def test_fetch_edit(self): ++ # Edit after fetch ++ self.history.fetch(reverse=True) # initialization ++ self.text.delete('iomark', 'insert', ) ++ self.text.insert('iomark', 'a =') ++ self.fetch_test(True, line1, 'a =', 0) # prefix is reset ++ ++ def test_history_prev_next(self): ++ # Minimally test functions bound to events ++ self.history.history_prev('dummy event') ++ self.assertEqual(self.history.pointer, 1) ++ self.history.history_next('dummy event') ++ self.assertEqual(self.history.pointer, None) ++ ++ ++if __name__ == '__main__': ++ unittest.main(verbosity=2, exit=2) +diff -r ab05e7dd2788 Lib/idlelib/idle_test/test_pathbrowser.py +--- /dev/null ++++ b/Lib/idlelib/idle_test/test_pathbrowser.py +@@ -0,0 +1,12 @@ ++import unittest ++import idlelib.PathBrowser as PathBrowser ++ ++class PathBrowserTest(unittest.TestCase): ++ ++ def test_DirBrowserTreeItem(self): ++ # Issue16226 - make sure that getting a sublist works ++ d = PathBrowser.DirBrowserTreeItem('') ++ d.GetSubList() ++ ++if __name__ == '__main__': ++ unittest.main(verbosity=2, exit=False) +diff -r ab05e7dd2788 Lib/idlelib/idle_test/test_rstrip.py +--- /dev/null ++++ b/Lib/idlelib/idle_test/test_rstrip.py +@@ -0,0 +1,49 @@ ++import unittest ++import idlelib.RstripExtension as rs ++from idlelib.idle_test.mock_idle import Editor ++ ++class rstripTest(unittest.TestCase): ++ ++ def test_rstrip_line(self): ++ editor = Editor() ++ text = editor.text ++ do_rstrip = rs.RstripExtension(editor).do_rstrip ++ ++ do_rstrip() ++ self.assertEqual(text.get('1.0', 'insert'), '') ++ text.insert('1.0', ' ') ++ do_rstrip() ++ self.assertEqual(text.get('1.0', 'insert'), '') ++ text.insert('1.0', ' \n') ++ do_rstrip() ++ self.assertEqual(text.get('1.0', 'insert'), '\n') ++ ++ def test_rstrip_multiple(self): ++ editor = Editor() ++ # Uncomment following to verify that test passes with real widgets. ++## from idlelib.EditorWindow import EditorWindow as Editor ++## from tkinter import Tk ++## editor = Editor(root=Tk()) ++ text = editor.text ++ do_rstrip = rs.RstripExtension(editor).do_rstrip ++ ++ original = ( ++ "Line with an ending tab \n" ++ "Line ending in 5 spaces \n" ++ "Linewithnospaces\n" ++ " indented line\n" ++ " indented line with trailing space \n" ++ " ") ++ stripped = ( ++ "Line with an ending tab\n" ++ "Line ending in 5 spaces\n" ++ "Linewithnospaces\n" ++ " indented line\n" ++ " indented line with trailing space\n") ++ ++ text.insert('1.0', original) ++ do_rstrip() ++ self.assertEqual(text.get('1.0', 'insert'), stripped) ++ ++if __name__ == '__main__': ++ unittest.main(verbosity=2, exit=False) +diff -r ab05e7dd2788 Lib/idlelib/idle_test/test_searchengine.py +--- /dev/null ++++ b/Lib/idlelib/idle_test/test_searchengine.py +@@ -0,0 +1,326 @@ ++'''Test functions and SearchEngine class in SearchEngine.py.''' ++ ++# With mock replacements, the module does not use any gui widgets. ++# The use of tk.Text is avoided (for now, until mock Text is improved) ++# by patching instances with an index function returning what is needed. ++# This works because mock Text.get does not use .index. ++ ++import re ++import unittest ++from test.test_support import requires ++from Tkinter import BooleanVar, StringVar, TclError # ,Tk, Text ++import tkMessageBox ++from idlelib import SearchEngine as se ++from idlelib.idle_test.mock_tk import Var, Mbox ++from idlelib.idle_test.mock_tk import Text as mockText ++ ++def setUpModule(): ++ # Replace s-e module tkinter imports other than non-gui TclError. ++ se.BooleanVar = Var ++ se.StringVar = Var ++ se.tkMessageBox = Mbox ++ ++def tearDownModule(): ++ # Restore 'just in case', though other tests should also replace. ++ se.BooleanVar = BooleanVar ++ se.StringVar = StringVar ++ se.tkMessageBox = tkMessageBox ++ ++ ++class Mock: ++ def __init__(self, *args, **kwargs): pass ++ ++class GetTest(unittest.TestCase): ++ # SearchEngine.get returns singleton created & saved on first call. ++ def test_get(self): ++ saved_Engine = se.SearchEngine ++ se.SearchEngine = Mock # monkey-patch class ++ try: ++ root = Mock() ++ engine = se.get(root) ++ self.assertIsInstance(engine, se.SearchEngine) ++ self.assertIs(root._searchengine, engine) ++ self.assertIs(se.get(root), engine) ++ finally: ++ se.SearchEngine = saved_Engine # restore class to module ++ ++class GetLineColTest(unittest.TestCase): ++ # Test simple text-independent helper function ++ def test_get_line_col(self): ++ self.assertEqual(se.get_line_col('1.0'), (1, 0)) ++ self.assertEqual(se.get_line_col('1.11'), (1, 11)) ++ ++ self.assertRaises(ValueError, se.get_line_col, ('1.0 lineend')) ++ self.assertRaises(ValueError, se.get_line_col, ('end')) ++ ++class GetSelectionTest(unittest.TestCase): ++ # Test text-dependent helper function. ++## # Need gui for text.index('sel.first/sel.last/insert'). ++## @classmethod ++## def setUpClass(cls): ++## requires('gui') ++## cls.root = Tk() ++## ++## @classmethod ++## def tearDownClass(cls): ++## cls.root.destroy() ++ ++ def test_get_selection(self): ++ # text = Text(master=self.root) ++ text = mockText() ++ text.insert('1.0', 'Hello World!') ++ ++ # fix text.index result when called in get_selection ++ def sel(s): ++ # select entire text, cursor irrelevant ++ if s == 'sel.first': return '1.0' ++ if s == 'sel.last': return '1.12' ++ raise TclError ++ text.index = sel # replaces .tag_add('sel', '1.0, '1.12') ++ self.assertEqual(se.get_selection(text), ('1.0', '1.12')) ++ ++ def mark(s): ++ # no selection, cursor after 'Hello' ++ if s == 'insert': return '1.5' ++ raise TclError ++ text.index = mark # replaces .mark_set('insert', '1.5') ++ self.assertEqual(se.get_selection(text), ('1.5', '1.5')) ++ ++ ++class ReverseSearchTest(unittest.TestCase): ++ # Test helper function that searches backwards within a line. ++ def test_search_reverse(self): ++ Equal = self.assertEqual ++ line = "Here is an 'is' test text." ++ prog = re.compile('is') ++ Equal(se.search_reverse(prog, line, len(line)).span(), (12, 14)) ++ Equal(se.search_reverse(prog, line, 14).span(), (12, 14)) ++ Equal(se.search_reverse(prog, line, 13).span(), (5, 7)) ++ Equal(se.search_reverse(prog, line, 7).span(), (5, 7)) ++ Equal(se.search_reverse(prog, line, 6), None) ++ ++ ++class SearchEngineTest(unittest.TestCase): ++ # Test class methods that do not use Text widget. ++ ++ def setUp(self): ++ self.engine = se.SearchEngine(root=None) ++ # Engine.root is only used to create error message boxes. ++ # The mock replacement ignores the root argument. ++ ++ def test_is_get(self): ++ engine = self.engine ++ Equal = self.assertEqual ++ ++ Equal(engine.getpat(), '') ++ engine.setpat('hello') ++ Equal(engine.getpat(), 'hello') ++ ++ Equal(engine.isre(), False) ++ engine.revar.set(1) ++ Equal(engine.isre(), True) ++ ++ Equal(engine.iscase(), False) ++ engine.casevar.set(1) ++ Equal(engine.iscase(), True) ++ ++ Equal(engine.isword(), False) ++ engine.wordvar.set(1) ++ Equal(engine.isword(), True) ++ ++ Equal(engine.iswrap(), True) ++ engine.wrapvar.set(0) ++ Equal(engine.iswrap(), False) ++ ++ Equal(engine.isback(), False) ++ engine.backvar.set(1) ++ Equal(engine.isback(), True) ++ ++ def test_setcookedpat(self): ++ engine = self.engine ++ engine.setcookedpat('\s') ++ self.assertEqual(engine.getpat(), '\s') ++ engine.revar.set(1) ++ engine.setcookedpat('\s') ++ self.assertEqual(engine.getpat(), r'\\s') ++ ++ def test_getcookedpat(self): ++ engine = self.engine ++ Equal = self.assertEqual ++ ++ Equal(engine.getcookedpat(), '') ++ engine.setpat('hello') ++ Equal(engine.getcookedpat(), 'hello') ++ engine.wordvar.set(True) ++ Equal(engine.getcookedpat(), r'\bhello\b') ++ engine.wordvar.set(False) ++ ++ engine.setpat('\s') ++ Equal(engine.getcookedpat(), r'\\s') ++ engine.revar.set(True) ++ Equal(engine.getcookedpat(), '\s') ++ ++ def test_getprog(self): ++ engine = self.engine ++ Equal = self.assertEqual ++ ++ engine.setpat('Hello') ++ temppat = engine.getprog() ++ Equal(temppat.pattern, re.compile('Hello', re.IGNORECASE).pattern) ++ engine.casevar.set(1) ++ temppat = engine.getprog() ++ Equal(temppat.pattern, re.compile('Hello').pattern, 0) ++ ++ engine.setpat('') ++ Equal(engine.getprog(), None) ++ engine.setpat('+') ++ engine.revar.set(1) ++ Equal(engine.getprog(), None) ++ self.assertEqual(Mbox.showerror.message, ++ 'Error: nothing to repeat\nPattern: +') ++ ++ def test_report_error(self): ++ showerror = Mbox.showerror ++ Equal = self.assertEqual ++ pat = '[a-z' ++ msg = 'unexpected end of regular expression' ++ ++ Equal(self.engine.report_error(pat, msg), None) ++ Equal(showerror.title, 'Regular expression error') ++ expected_message = ("Error: " + msg + "\nPattern: [a-z") ++ Equal(showerror.message, expected_message) ++ ++ Equal(self.engine.report_error(pat, msg, 5), None) ++ Equal(showerror.title, 'Regular expression error') ++ expected_message += "\nOffset: 5" ++ Equal(showerror.message, expected_message) ++ ++ ++class SearchTest(unittest.TestCase): ++ # Test that search_text makes right call to right method. ++ ++ @classmethod ++ def setUpClass(cls): ++## requires('gui') ++## cls.root = Tk() ++## cls.text = Text(master=cls.root) ++ cls.text = mockText() ++ test_text = ( ++ 'First line\n' ++ 'Line with target\n' ++ 'Last line\n') ++ cls.text.insert('1.0', test_text) ++ cls.pat = re.compile('target') ++ ++ cls.engine = se.SearchEngine(None) ++ cls.engine.search_forward = lambda *args: ('f', args) ++ cls.engine.search_backward = lambda *args: ('b', args) ++ ++## @classmethod ++## def tearDownClass(cls): ++## cls.root.destroy() ++ ++ def test_search(self): ++ Equal = self.assertEqual ++ engine = self.engine ++ search = engine.search_text ++ text = self.text ++ pat = self.pat ++ ++ engine.patvar.set(None) ++ #engine.revar.set(pat) ++ Equal(search(text), None) ++ ++ def mark(s): ++ # no selection, cursor after 'Hello' ++ if s == 'insert': return '1.5' ++ raise TclError ++ text.index = mark ++ Equal(search(text, pat), ('f', (text, pat, 1, 5, True, False))) ++ engine.wrapvar.set(False) ++ Equal(search(text, pat), ('f', (text, pat, 1, 5, False, False))) ++ engine.wrapvar.set(True) ++ engine.backvar.set(True) ++ Equal(search(text, pat), ('b', (text, pat, 1, 5, True, False))) ++ engine.backvar.set(False) ++ ++ def sel(s): ++ if s == 'sel.first': return '2.10' ++ if s == 'sel.last': return '2.16' ++ raise TclError ++ text.index = sel ++ Equal(search(text, pat), ('f', (text, pat, 2, 16, True, False))) ++ Equal(search(text, pat, True), ('f', (text, pat, 2, 10, True, True))) ++ engine.backvar.set(True) ++ Equal(search(text, pat), ('b', (text, pat, 2, 10, True, False))) ++ Equal(search(text, pat, True), ('b', (text, pat, 2, 16, True, True))) ++ ++ ++class ForwardBackwardTest(unittest.TestCase): ++ # Test that search_forward method finds the target. ++## @classmethod ++## def tearDownClass(cls): ++## cls.root.destroy() ++ ++ @classmethod ++ def setUpClass(cls): ++ cls.engine = se.SearchEngine(None) ++## requires('gui') ++## cls.root = Tk() ++## cls.text = Text(master=cls.root) ++ cls.text = mockText() ++ # search_backward calls index('end-1c') ++ cls.text.index = lambda index: '4.0' ++ test_text = ( ++ 'First line\n' ++ 'Line with target\n' ++ 'Last line\n') ++ cls.text.insert('1.0', test_text) ++ cls.pat = re.compile('target') ++ cls.res = (2, (10, 16)) # line, slice indexes of 'target' ++ cls.failpat = re.compile('xyz') # not in text ++ cls.emptypat = re.compile('\w*') # empty match possible ++ ++ def make_search(self, func): ++ def search(pat, line, col, wrap, ok=0): ++ res = func(self.text, pat, line, col, wrap, ok) ++ # res is (line, matchobject) or None ++ return (res[0], res[1].span()) if res else res ++ return search ++ ++ def test_search_forward(self): ++ # search for non-empty match ++ Equal = self.assertEqual ++ forward = self.make_search(self.engine.search_forward) ++ pat = self.pat ++ Equal(forward(pat, 1, 0, True), self.res) ++ Equal(forward(pat, 3, 0, True), self.res) # wrap ++ Equal(forward(pat, 3, 0, False), None) # no wrap ++ Equal(forward(pat, 2, 10, False), self.res) ++ ++ Equal(forward(self.failpat, 1, 0, True), None) ++ Equal(forward(self.emptypat, 2, 9, True, ok=True), (2, (9, 9))) ++ #Equal(forward(self.emptypat, 2, 9, True), self.res) ++ # While the initial empty match is correctly ignored, skipping ++ # the rest of the line and returning (3, (0,4)) seems buggy - tjr. ++ Equal(forward(self.emptypat, 2, 10, True), self.res) ++ ++ def test_search_backward(self): ++ # search for non-empty match ++ Equal = self.assertEqual ++ backward = self.make_search(self.engine.search_backward) ++ pat = self.pat ++ Equal(backward(pat, 3, 5, True), self.res) ++ Equal(backward(pat, 2, 0, True), self.res) # wrap ++ Equal(backward(pat, 2, 0, False), None) # no wrap ++ Equal(backward(pat, 2, 16, False), self.res) ++ ++ Equal(backward(self.failpat, 3, 9, True), None) ++ Equal(backward(self.emptypat, 2, 10, True, ok=True), (2, (9,9))) ++ # Accepted because 9 < 10, not because ok=True. ++ # It is not clear that ok=True is useful going back - tjr ++ Equal(backward(self.emptypat, 2, 9, True), (2, (5, 9))) ++ ++ ++if __name__ == '__main__': ++ unittest.main(verbosity=2, exit=2) +diff -r ab05e7dd2788 Lib/idlelib/idle_test/test_text.py +--- /dev/null ++++ b/Lib/idlelib/idle_test/test_text.py +@@ -0,0 +1,227 @@ ++# Test mock_tk.Text class against tkinter.Text class by running same tests with both. ++import unittest ++from test.test_support import requires ++ ++from _tkinter import TclError ++import Tkinter as tk ++ ++class TextTest(object): ++ ++ hw = 'hello\nworld' # usual initial insert after initialization ++ hwn = hw+'\n' # \n present at initialization, before insert ++ ++ Text = None ++ def setUp(self): ++ self.text = self.Text() ++ ++ def test_init(self): ++ self.assertEqual(self.text.get('1.0'), '\n') ++ self.assertEqual(self.text.get('end'), '') ++ ++ def test_index_empty(self): ++ index = self.text.index ++ ++ for dex in (-1.0, 0.3, '1.-1', '1.0', '1.0 lineend', '1.end', '1.33', ++ 'insert'): ++ self.assertEqual(index(dex), '1.0') ++ ++ for dex in 'end', 2.0, '2.1', '33.44': ++ self.assertEqual(index(dex), '2.0') ++ ++ def test_index_data(self): ++ index = self.text.index ++ self.text.insert('1.0', self.hw) ++ ++ for dex in -1.0, 0.3, '1.-1', '1.0': ++ self.assertEqual(index(dex), '1.0') ++ ++ for dex in '1.0 lineend', '1.end', '1.33': ++ self.assertEqual(index(dex), '1.5') ++ ++ for dex in 'end', '33.44': ++ self.assertEqual(index(dex), '3.0') ++ ++ def test_get(self): ++ get = self.text.get ++ Equal = self.assertEqual ++ self.text.insert('1.0', self.hw) ++ ++ Equal(get('end'), '') ++ Equal(get('end', 'end'), '') ++ Equal(get('1.0'), 'h') ++ Equal(get('1.0', '1.1'), 'h') ++ Equal(get('1.0', '1.3'), 'hel') ++ Equal(get('1.1', '1.3'), 'el') ++ Equal(get('1.0', '1.0 lineend'), 'hello') ++ Equal(get('1.0', '1.10'), 'hello') ++ Equal(get('1.0 lineend'), '\n') ++ Equal(get('1.1', '2.3'), 'ello\nwor') ++ Equal(get('1.0', '2.5'), self.hw) ++ Equal(get('1.0', 'end'), self.hwn) ++ Equal(get('0.0', '5.0'), self.hwn) ++ ++ def test_insert(self): ++ insert = self.text.insert ++ get = self.text.get ++ Equal = self.assertEqual ++ ++ insert('1.0', self.hw) ++ Equal(get('1.0', 'end'), self.hwn) ++ ++ insert('1.0', '') # nothing ++ Equal(get('1.0', 'end'), self.hwn) ++ ++ insert('1.0', '*') ++ Equal(get('1.0', 'end'), '*hello\nworld\n') ++ ++ insert('1.0 lineend', '*') ++ Equal(get('1.0', 'end'), '*hello*\nworld\n') ++ ++ insert('2.3', '*') ++ Equal(get('1.0', 'end'), '*hello*\nwor*ld\n') ++ ++ insert('end', 'x') ++ Equal(get('1.0', 'end'), '*hello*\nwor*ldx\n') ++ ++ insert('1.4', 'x\n') ++ Equal(get('1.0', 'end'), '*helx\nlo*\nwor*ldx\n') ++ ++ def test_no_delete(self): ++ # if index1 == 'insert' or 'end' or >= end, there is no deletion ++ delete = self.text.delete ++ get = self.text.get ++ Equal = self.assertEqual ++ self.text.insert('1.0', self.hw) ++ ++ delete('insert') ++ Equal(get('1.0', 'end'), self.hwn) ++ ++ delete('end') ++ Equal(get('1.0', 'end'), self.hwn) ++ ++ delete('insert', 'end') ++ Equal(get('1.0', 'end'), self.hwn) ++ ++ delete('insert', '5.5') ++ Equal(get('1.0', 'end'), self.hwn) ++ ++ delete('1.4', '1.0') ++ Equal(get('1.0', 'end'), self.hwn) ++ ++ delete('1.4', '1.4') ++ Equal(get('1.0', 'end'), self.hwn) ++ ++ def test_delete_char(self): ++ delete = self.text.delete ++ get = self.text.get ++ Equal = self.assertEqual ++ self.text.insert('1.0', self.hw) ++ ++ delete('1.0') ++ Equal(get('1.0', '1.end'), 'ello') ++ ++ delete('1.0', '1.1') ++ Equal(get('1.0', '1.end'), 'llo') ++ ++ # delete \n and combine 2 lines into 1 ++ delete('1.end') ++ Equal(get('1.0', '1.end'), 'lloworld') ++ ++ self.text.insert('1.3', '\n') ++ delete('1.10') ++ Equal(get('1.0', '1.end'), 'lloworld') ++ ++ self.text.insert('1.3', '\n') ++ delete('1.3', '2.0') ++ Equal(get('1.0', '1.end'), 'lloworld') ++ ++ def test_delete_slice(self): ++ delete = self.text.delete ++ get = self.text.get ++ Equal = self.assertEqual ++ self.text.insert('1.0', self.hw) ++ ++ delete('1.0', '1.0 lineend') ++ Equal(get('1.0', 'end'), '\nworld\n') ++ ++ delete('1.0', 'end') ++ Equal(get('1.0', 'end'), '\n') ++ ++ self.text.insert('1.0', self.hw) ++ delete('1.0', '2.0') ++ Equal(get('1.0', 'end'), 'world\n') ++ ++ delete('1.0', 'end') ++ Equal(get('1.0', 'end'), '\n') ++ ++ self.text.insert('1.0', self.hw) ++ delete('1.2', '2.3') ++ Equal(get('1.0', 'end'), 'held\n') ++ ++ def test_multiple_lines(self): # insert and delete ++ self.text.insert('1.0', 'hello') ++ ++ self.text.insert('1.3', '1\n2\n3\n4\n5') ++ self.assertEqual(self.text.get('1.0', 'end'), 'hel1\n2\n3\n4\n5lo\n') ++ ++ self.text.delete('1.3', '5.1') ++ self.assertEqual(self.text.get('1.0', 'end'), 'hello\n') ++ ++ def test_compare(self): ++ compare = self.text.compare ++ Equal = self.assertEqual ++ # need data so indexes not squished to 1,0 ++ self.text.insert('1.0', 'First\nSecond\nThird\n') ++ ++ self.assertRaises(TclError, compare, '2.2', 'op', '2.2') ++ ++ for op, less1, less0, equal, greater0, greater1 in ( ++ ('<', True, True, False, False, False), ++ ('<=', True, True, True, False, False), ++ ('>', False, False, False, True, True), ++ ('>=', False, False, True, True, True), ++ ('==', False, False, True, False, False), ++ ('!=', True, True, False, True, True), ++ ): ++ Equal(compare('1.1', op, '2.2'), less1, op) ++ Equal(compare('2.1', op, '2.2'), less0, op) ++ Equal(compare('2.2', op, '2.2'), equal, op) ++ Equal(compare('2.3', op, '2.2'), greater0, op) ++ Equal(compare('3.3', op, '2.2'), greater1, op) ++ ++ ++class MockTextTest(TextTest, unittest.TestCase): ++ ++ @classmethod ++ def setUpClass(cls): ++ from idlelib.idle_test.mock_tk import Text ++ cls.Text = Text ++ ++ def test_decode(self): ++ # test endflags (-1, 0) not tested by test_index (which uses +1) ++ decode = self.text._decode ++ Equal = self.assertEqual ++ self.text.insert('1.0', self.hw) ++ ++ Equal(decode('end', -1), (2, 5)) ++ Equal(decode('3.1', -1), (2, 5)) ++ Equal(decode('end', 0), (2, 6)) ++ Equal(decode('3.1', 0), (2, 6)) ++ ++ ++class TkTextTest(TextTest, unittest.TestCase): ++ ++ @classmethod ++ def setUpClass(cls): ++ requires('gui') ++ from Tkinter import Tk, Text ++ cls.Text = Text ++ cls.root = Tk() ++ ++ @classmethod ++ def tearDownClass(cls): ++ cls.root.destroy() ++ ++ ++if __name__ == '__main__': ++ unittest.main(verbosity=2, exit=False) +diff -r ab05e7dd2788 Lib/idlelib/idle_test/test_warning.py +--- /dev/null ++++ b/Lib/idlelib/idle_test/test_warning.py +@@ -0,0 +1,73 @@ ++'''Test warnings replacement in PyShell.py and run.py. ++ ++This file could be expanded to include traceback overrides ++(in same two modules). If so, change name. ++Revise if output destination changes (http://bugs.python.org/issue18318). ++Make sure warnings module is left unaltered (http://bugs.python.org/issue18081). ++''' ++ ++import unittest ++from test.test_support import captured_stderr ++ ++import warnings ++# Try to capture default showwarning before Idle modules are imported. ++showwarning = warnings.showwarning ++# But if we run this file within idle, we are in the middle of the run.main loop ++# and default showwarnings has already been replaced. ++running_in_idle = 'idle' in showwarning.__name__ ++ ++from idlelib import run ++from idlelib import PyShell as shell ++ ++# The following was generated from PyShell.idle_formatwarning ++# and checked as matching expectation. ++idlemsg = ''' ++Warning (from warnings module): ++ File "test_warning.py", line 99 ++ Line of code ++UserWarning: Test ++''' ++shellmsg = idlemsg + ">>> " ++ ++class RunWarnTest(unittest.TestCase): ++ ++ @unittest.skipIf(running_in_idle, "Does not work when run within Idle.") ++ def test_showwarnings(self): ++ self.assertIs(warnings.showwarning, showwarning) ++ run.capture_warnings(True) ++ self.assertIs(warnings.showwarning, run.idle_showwarning_subproc) ++ run.capture_warnings(False) ++ self.assertIs(warnings.showwarning, showwarning) ++ ++ def test_run_show(self): ++ with captured_stderr() as f: ++ run.idle_showwarning_subproc( ++ 'Test', UserWarning, 'test_warning.py', 99, f, 'Line of code') ++ # The following uses .splitlines to erase line-ending differences ++ self.assertEqual(idlemsg.splitlines(), f.getvalue().splitlines()) ++ ++class ShellWarnTest(unittest.TestCase): ++ ++ @unittest.skipIf(running_in_idle, "Does not work when run within Idle.") ++ def test_showwarnings(self): ++ self.assertIs(warnings.showwarning, showwarning) ++ shell.capture_warnings(True) ++ self.assertIs(warnings.showwarning, shell.idle_showwarning) ++ shell.capture_warnings(False) ++ self.assertIs(warnings.showwarning, showwarning) ++ ++ def test_idle_formatter(self): ++ # Will fail if format changed without regenerating idlemsg ++ s = shell.idle_formatwarning( ++ 'Test', UserWarning, 'test_warning.py', 99, 'Line of code') ++ self.assertEqual(idlemsg, s) ++ ++ def test_shell_show(self): ++ with captured_stderr() as f: ++ shell.idle_showwarning( ++ 'Test', UserWarning, 'test_warning.py', 99, f, 'Line of code') ++ self.assertEqual(shellmsg.splitlines(), f.getvalue().splitlines()) ++ ++ ++if __name__ == '__main__': ++ unittest.main(verbosity=2, exit=False) +diff -r ab05e7dd2788 Lib/idlelib/run.py +--- a/Lib/idlelib/run.py ++++ b/Lib/idlelib/run.py +@@ -22,24 +22,38 @@ + + LOCALHOST = '127.0.0.1' + +-try: +- import warnings +-except ImportError: +- pass +-else: +- def idle_formatwarning_subproc(message, category, filename, lineno, +- line=None): +- """Format warnings the IDLE way""" +- s = "\nWarning (from warnings module):\n" +- s += ' File \"%s\", line %s\n' % (filename, lineno) +- if line is None: +- line = linecache.getline(filename, lineno) +- line = line.strip() +- if line: +- s += " %s\n" % line +- s += "%s: %s\n" % (category.__name__, message) +- return s +- warnings.formatwarning = idle_formatwarning_subproc ++import warnings ++ ++def idle_showwarning_subproc( ++ message, category, filename, lineno, file=None, line=None): ++ """Show Idle-format warning after replacing warnings.showwarning. ++ ++ The only difference is the formatter called. ++ """ ++ if file is None: ++ file = sys.stderr ++ try: ++ file.write(PyShell.idle_formatwarning( ++ message, category, filename, lineno, line)) ++ except IOError: ++ pass # the file (probably stderr) is invalid - this warning gets lost. ++ ++_warnings_showwarning = None ++ ++def capture_warnings(capture): ++ "Replace warning.showwarning with idle_showwarning_subproc, or reverse." ++ ++ global _warnings_showwarning ++ if capture: ++ if _warnings_showwarning is None: ++ _warnings_showwarning = warnings.showwarning ++ warnings.showwarning = idle_showwarning_subproc ++ else: ++ if _warnings_showwarning is not None: ++ warnings.showwarning = _warnings_showwarning ++ _warnings_showwarning = None ++ ++capture_warnings(True) + + # Thread shared globals: Establish a queue between a subthread (which handles + # the socket) and the main thread (which runs user code), plus global +@@ -78,6 +92,8 @@ + except: + print>>sys.stderr, "IDLE Subprocess: no IP port passed in sys.argv." + return ++ ++ capture_warnings(True) + sys.argv[:] = [""] + sockthread = threading.Thread(target=manage_socket, + name='SockThread', +@@ -104,6 +120,7 @@ + exit_now = True + continue + except SystemExit: ++ capture_warnings(False) + raise + except: + type, value, tb = sys.exc_info() +@@ -123,7 +140,7 @@ + try: + server = MyRPCServer(address, MyHandler) + break +- except socket.error, err: ++ except socket.error as err: + print>>sys.__stderr__,"IDLE Subprocess: socket error: "\ + + err.args[1] + ", retrying...." + else: +@@ -219,6 +236,7 @@ + del sys.exitfunc + except AttributeError: + pass ++ capture_warnings(False) + sys.exit(0) + + class MyRPCServer(rpc.RPCServer): +@@ -352,3 +370,5 @@ + sys.last_value = val + item = StackViewer.StackTreeItem(flist, tb) + return RemoteObjectBrowser.remote_object_tree_item(item) ++ ++capture_warnings(False) # Make sure turned off; see issue 18081 +diff -r ab05e7dd2788 Lib/inspect.py +--- a/Lib/inspect.py ++++ b/Lib/inspect.py +@@ -165,7 +165,7 @@ + """Return true if the object is a generator. + + Generator objects provide these attributes: +- __iter__ defined to support interation over container ++ __iter__ defined to support iteration over container + close raises a new GeneratorExit exception inside the + generator to terminate the iteration + gi_code code object +@@ -728,7 +728,8 @@ + for parent in c.__bases__: + if not parent in children: + children[parent] = [] +- children[parent].append(c) ++ if c not in children[parent]: ++ children[parent].append(c) + if unique and parent in classes: break + elif c not in roots: + roots.append(c) +diff -r ab05e7dd2788 Lib/lib-tk/Tkinter.py +--- a/Lib/lib-tk/Tkinter.py ++++ b/Lib/lib-tk/Tkinter.py +@@ -1347,7 +1347,7 @@ + value = words[i+1] + if not value: + value = None +- elif '.' in value: ++ elif '.' in str(value): + value = getdouble(value) + else: + value = getint(value) +@@ -1736,7 +1736,7 @@ + # ensure that self.tk is always _something_. + self.tk = None + if baseName is None: +- import sys, os ++ import os + baseName = os.path.basename(sys.argv[0]) + baseName, ext = os.path.splitext(baseName) + if ext not in ('.py', '.pyc', '.pyo'): +@@ -1880,7 +1880,7 @@ + for i in range(0, len(words), 2): + key = words[i][1:] + value = words[i+1] +- if value[:1] == '.': ++ if str(value)[:1] == '.': + value = self._nametowidget(value) + dict[key] = value + return dict +@@ -1931,7 +1931,7 @@ + for i in range(0, len(words), 2): + key = words[i][1:] + value = words[i+1] +- if value[:1] == '.': ++ if str(value)[:1] == '.': + value = self._nametowidget(value) + dict[key] = value + return dict +@@ -1980,7 +1980,7 @@ + for i in range(0, len(words), 2): + key = words[i][1:] + value = words[i+1] +- if value[:1] == '.': ++ if str(value)[:1] == '.': + value = self._nametowidget(value) + dict[key] = value + return dict +diff -r ab05e7dd2788 Lib/lib-tk/test/test_ttk/test_widgets.py +--- a/Lib/lib-tk/test/test_ttk/test_widgets.py ++++ b/Lib/lib-tk/test/test_ttk/test_widgets.py +@@ -26,8 +26,8 @@ + def test_identify(self): + self.widget.update_idletasks() + self.assertEqual(self.widget.identify( +- int(self.widget.winfo_width() / 2), +- int(self.widget.winfo_height() / 2) ++ self.widget.winfo_width() // 2, ++ self.widget.winfo_height() // 2 + ), "label") + self.assertEqual(self.widget.identify(-1, -1), "") + +@@ -104,7 +104,7 @@ + + cbtn['command'] = '' + res = cbtn.invoke() +- self.assertEqual(res, '') ++ self.assertEqual(str(res), '') + self.assertFalse(len(success) > 1) + self.assertEqual(cbtn['offvalue'], + cbtn.tk.globalgetvar(cbtn['variable'])) +@@ -452,7 +452,7 @@ + + cbtn2['command'] = '' + res = cbtn2.invoke() +- self.assertEqual(res, '') ++ self.assertEqual(str(res), '') + self.assertFalse(len(success) > 1) + self.assertEqual(cbtn2['value'], myvar.get()) + self.assertEqual(myvar.get(), +diff -r ab05e7dd2788 Lib/lib-tk/turtle.py +--- a/Lib/lib-tk/turtle.py ++++ b/Lib/lib-tk/turtle.py +@@ -1233,7 +1233,7 @@ + self._delayvalue = int(delay) + + def _incrementudc(self): +- """Increment upadate counter.""" ++ """Increment update counter.""" + if not TurtleScreen._RUNNING: + TurtleScreen._RUNNNING = True + raise Terminator +@@ -2439,7 +2439,7 @@ + self.screen = TurtleScreen(canvas) + RawTurtle.screens.append(self.screen) + else: +- raise TurtleGraphicsError("bad cavas argument %s" % canvas) ++ raise TurtleGraphicsError("bad canvas argument %s" % canvas) + + screen = self.screen + TNavigator.__init__(self, screen.mode()) +@@ -2684,7 +2684,7 @@ + def shapesize(self, stretch_wid=None, stretch_len=None, outline=None): + """Set/return turtle's stretchfactors/outline. Set resizemode to "user". + +- Optinonal arguments: ++ Optional arguments: + stretch_wid : positive number + stretch_len : positive number + outline : positive number +@@ -2975,7 +2975,7 @@ + + def _goto(self, end): + """Move the pen to the point end, thereby drawing a line +- if pen is down. All other methodes for turtle movement depend ++ if pen is down. All other methods for turtle movement depend + on this one. + """ + ## Version mit undo-stuff +diff -r ab05e7dd2788 Lib/lib2to3/fixes/fix_itertools.py +--- a/Lib/lib2to3/fixes/fix_itertools.py ++++ b/Lib/lib2to3/fixes/fix_itertools.py +@@ -34,8 +34,8 @@ + # Remove the 'itertools' + prefix = it.prefix + it.remove() +- # Replace the node wich contains ('.', 'function') with the +- # function (to be consistant with the second part of the pattern) ++ # Replace the node which contains ('.', 'function') with the ++ # function (to be consistent with the second part of the pattern) + dot.remove() + func.parent.replace(func) + +diff -r ab05e7dd2788 Lib/lib2to3/fixes/fix_metaclass.py +--- a/Lib/lib2to3/fixes/fix_metaclass.py ++++ b/Lib/lib2to3/fixes/fix_metaclass.py +@@ -71,7 +71,7 @@ + def fixup_simple_stmt(parent, i, stmt_node): + """ if there is a semi-colon all the parts count as part of the same + simple_stmt. We just want the __metaclass__ part so we move +- everything efter the semi-colon into its own simple_stmt node ++ everything after the semi-colon into its own simple_stmt node + """ + for semi_ind, node in enumerate(stmt_node.children): + if node.type == token.SEMI: # *sigh* +diff -r ab05e7dd2788 Lib/lib2to3/pgen2/tokenize.py +--- a/Lib/lib2to3/pgen2/tokenize.py ++++ b/Lib/lib2to3/pgen2/tokenize.py +@@ -236,7 +236,7 @@ + startline = False + toks_append(tokval) + +-cookie_re = re.compile("coding[:=]\s*([-\w.]+)") ++cookie_re = re.compile(r'^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)') + + def _get_normal_name(orig_enc): + """Imitates get_normal_name in tokenizer.c.""" +@@ -281,11 +281,10 @@ + line_string = line.decode('ascii') + except UnicodeDecodeError: + return None +- +- matches = cookie_re.findall(line_string) +- if not matches: ++ match = cookie_re.match(line_string) ++ if not match: + return None +- encoding = _get_normal_name(matches[0]) ++ encoding = _get_normal_name(match.group(1)) + try: + codec = lookup(encoding) + except LookupError: +diff -r ab05e7dd2788 Lib/lib2to3/tests/data/false_encoding.py +--- /dev/null ++++ b/Lib/lib2to3/tests/data/false_encoding.py +@@ -0,0 +1,2 @@ ++#!/usr/bin/env python ++print '#coding=0' +diff -r ab05e7dd2788 Lib/lib2to3/tests/test_parser.py +--- a/Lib/lib2to3/tests/test_parser.py ++++ b/Lib/lib2to3/tests/test_parser.py +@@ -73,7 +73,7 @@ + self.invalid_syntax("raise E from") + + +-# Adapated from Python 3's Lib/test/test_grammar.py:GrammarTests.testFuncdef ++# Adaptated from Python 3's Lib/test/test_grammar.py:GrammarTests.testFuncdef + class TestFunctionAnnotations(GrammarTest): + def test_1(self): + self.validate("""def f(x) -> list: pass""") +diff -r ab05e7dd2788 Lib/lib2to3/tests/test_refactor.py +--- a/Lib/lib2to3/tests/test_refactor.py ++++ b/Lib/lib2to3/tests/test_refactor.py +@@ -271,6 +271,10 @@ + fn = os.path.join(TEST_DATA_DIR, "different_encoding.py") + self.check_file_refactoring(fn) + ++ def test_false_file_encoding(self): ++ fn = os.path.join(TEST_DATA_DIR, "false_encoding.py") ++ data = self.check_file_refactoring(fn) ++ + def test_bom(self): + fn = os.path.join(TEST_DATA_DIR, "bom.py") + data = self.check_file_refactoring(fn) +diff -r ab05e7dd2788 Lib/logging/__init__.py +--- a/Lib/logging/__init__.py ++++ b/Lib/logging/__init__.py +@@ -893,6 +893,7 @@ + self.baseFilename = os.path.abspath(filename) + self.mode = mode + self.encoding = encoding ++ self.delay = delay + if delay: + #We don't open the stream, but we still need to call the + #Handler constructor to set level, formatter, lock etc. +diff -r ab05e7dd2788 Lib/logging/handlers.py +--- a/Lib/logging/handlers.py ++++ b/Lib/logging/handlers.py +@@ -137,9 +137,11 @@ + dfn = self.baseFilename + ".1" + if os.path.exists(dfn): + os.remove(dfn) +- os.rename(self.baseFilename, dfn) +- #print "%s -> %s" % (self.baseFilename, dfn) +- self.stream = self._open() ++ # Issue 18940: A file may not have been created if delay is True. ++ if os.path.exists(self.baseFilename): ++ os.rename(self.baseFilename, dfn) ++ if not self.delay: ++ self.stream = self._open() + + def shouldRollover(self, record): + """ +@@ -343,17 +345,14 @@ + dfn = self.baseFilename + "." + time.strftime(self.suffix, timeTuple) + if os.path.exists(dfn): + os.remove(dfn) +- os.rename(self.baseFilename, dfn) ++ # Issue 18940: A file may not have been created if delay is True. ++ if os.path.exists(self.baseFilename): ++ os.rename(self.baseFilename, dfn) + if self.backupCount > 0: +- # find the oldest log file and delete it +- #s = glob.glob(self.baseFilename + ".20*") +- #if len(s) > self.backupCount: +- # s.sort() +- # os.remove(s[0]) + for s in self.getFilesToDelete(): + os.remove(s) +- #print "%s -> %s" % (self.baseFilename, dfn) +- self.stream = self._open() ++ if not self.delay: ++ self.stream = self._open() + newRolloverAt = self.computeRollover(currentTime) + while newRolloverAt <= currentTime: + newRolloverAt = newRolloverAt + self.interval +@@ -856,6 +855,7 @@ + try: + self.socket.send(msg) + except socket.error: ++ self.socket.close() # See issue 17981 + self._connect_unixsocket(self.address) + self.socket.send(msg) + elif self.socktype == socket.SOCK_DGRAM: +diff -r ab05e7dd2788 Lib/modulefinder.py +--- a/Lib/modulefinder.py ++++ b/Lib/modulefinder.py +@@ -516,7 +516,7 @@ + # Print modules that may be missing, but then again, maybe not... + if maybe: + print +- print "Submodules thay appear to be missing, but could also be", ++ print "Submodules that appear to be missing, but could also be", + print "global names in the parent package:" + for name in maybe: + mods = self.badmodules[name].keys() +diff -r ab05e7dd2788 Lib/multiprocessing/connection.py +--- a/Lib/multiprocessing/connection.py ++++ b/Lib/multiprocessing/connection.py +@@ -270,7 +270,14 @@ + self._unlink = None + + def accept(self): +- s, self._last_accepted = self._socket.accept() ++ while True: ++ try: ++ s, self._last_accepted = self._socket.accept() ++ except socket.error as e: ++ if e.args[0] != errno.EINTR: ++ raise ++ else: ++ break + s.setblocking(True) + fd = duplicate(s.fileno()) + conn = _multiprocessing.Connection(fd) +@@ -287,15 +294,16 @@ + ''' + Return a connection object connected to the socket given by `address` + ''' +- family = address_type(address) +- s = socket.socket( getattr(socket, family) ) +- s.setblocking(True) ++ family = getattr(socket, address_type(address)) + t = _init_timeout() + + while 1: ++ s = socket.socket(family) ++ s.setblocking(True) + try: + s.connect(address) + except socket.error, e: ++ s.close() + if e.args[0] != errno.ECONNREFUSED or _check_timeout(t): + debug('failed to connect to address %s', address) + raise +diff -r ab05e7dd2788 Lib/multiprocessing/forking.py +--- a/Lib/multiprocessing/forking.py ++++ b/Lib/multiprocessing/forking.py +@@ -367,7 +367,7 @@ + + def main(): + ''' +- Run code specifed by data received over pipe ++ Run code specified by data received over pipe + ''' + assert is_forking(sys.argv) + +diff -r ab05e7dd2788 Lib/multiprocessing/managers.py +--- a/Lib/multiprocessing/managers.py ++++ b/Lib/multiprocessing/managers.py +@@ -763,6 +763,7 @@ + elif kind == '#PROXY': + exposed, token = result + proxytype = self._manager._registry[token.typeid][-1] ++ token.address = self._token.address + proxy = proxytype( + token, self._serializer, manager=self._manager, + authkey=self._authkey, exposed=exposed +diff -r ab05e7dd2788 Lib/multiprocessing/synchronize.py +--- a/Lib/multiprocessing/synchronize.py ++++ b/Lib/multiprocessing/synchronize.py +@@ -226,7 +226,7 @@ + num_waiters = (self._sleeping_count._semlock._get_value() - + self._woken_count._semlock._get_value()) + except Exception: +- num_waiters = 'unkown' ++ num_waiters = 'unknown' + return '' % (self._lock, num_waiters) + + def wait(self, timeout=None): +diff -r ab05e7dd2788 Lib/netrc.py +--- a/Lib/netrc.py ++++ b/Lib/netrc.py +@@ -2,7 +2,7 @@ + + # Module and documentation by Eric S. Raymond, 21 Dec 1998 + +-import os, shlex ++import os, stat, shlex, pwd + + __all__ = ["netrc", "NetrcParseError"] + +@@ -21,6 +21,7 @@ + + class netrc: + def __init__(self, file=None): ++ default_netrc = file is None + if file is None: + try: + file = os.path.join(os.environ['HOME'], ".netrc") +@@ -29,9 +30,9 @@ + self.hosts = {} + self.macros = {} + with open(file) as fp: +- self._parse(file, fp) ++ self._parse(file, fp, default_netrc) + +- def _parse(self, file, fp): ++ def _parse(self, file, fp, default_netrc): + lexer = shlex.shlex(fp) + lexer.wordchars += r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~""" + lexer.commenters = lexer.commenters.replace('#', '') +@@ -88,6 +89,26 @@ + elif tt == 'account': + account = lexer.get_token() + elif tt == 'password': ++ if os.name == 'posix' and default_netrc: ++ prop = os.fstat(fp.fileno()) ++ if prop.st_uid != os.getuid(): ++ try: ++ fowner = pwd.getpwuid(prop.st_uid)[0] ++ except KeyError: ++ fowner = 'uid %s' % prop.st_uid ++ try: ++ user = pwd.getpwuid(os.getuid())[0] ++ except KeyError: ++ user = 'uid %s ' % os.getuid() ++ raise NetrcParseError( ++ ("~/.netrc file owner (%s) does not match" ++ " current user (%s)") % (fowner, user), ++ file, lexer.lineno) ++ if (prop.st_mode & (stat.S_IRWXG | stat.S_IRWXO)): ++ raise NetrcParseError( ++ "~/.netrc access too permissive: access" ++ " permissions must restrict access to only" ++ " the owner", file, lexer.lineno) + password = lexer.get_token() + else: + raise NetrcParseError("bad follower token %r" % tt, +diff -r ab05e7dd2788 Lib/optparse.py +--- a/Lib/optparse.py ++++ b/Lib/optparse.py +@@ -1471,7 +1471,7 @@ + """_match_long_opt(opt : string) -> string + + Determine which long option string 'opt' matches, ie. which one +- it is an unambiguous abbrevation for. Raises BadOptionError if ++ it is an unambiguous abbreviation for. Raises BadOptionError if + 'opt' doesn't unambiguously match any long option string. + """ + return _match_abbrev(opt, self._long_opt) +diff -r ab05e7dd2788 Lib/pdb.py +--- a/Lib/pdb.py ++++ b/Lib/pdb.py +@@ -1095,7 +1095,7 @@ + def help_run(self): + print """run [args...] + Restart the debugged python program. If a string is supplied, it is +-splitted with "shlex" and the result is used as the new sys.argv. ++split with "shlex" and the result is used as the new sys.argv. + History, breakpoints, actions and debugger options are preserved. + "restart" is an alias for "run".""" + +diff -r ab05e7dd2788 Lib/pickletools.py +--- a/Lib/pickletools.py ++++ b/Lib/pickletools.py +@@ -804,7 +804,7 @@ + obtype=StackObject, + doc="""An object representing a contiguous slice of the stack. + +- This is used in conjuction with markobject, to represent all ++ This is used in conjunction with markobject, to represent all + of the stack following the topmost markobject. For example, + the POP_MARK opcode changes the stack from + +@@ -1929,7 +1929,7 @@ + + stack = [] # crude emulation of unpickler stack + if memo is None: +- memo = {} # crude emulation of unpicker memo ++ memo = {} # crude emulation of unpickler memo + maxproto = -1 # max protocol number seen + markstack = [] # bytecode positions of MARK opcodes + indentchunk = ' ' * indentlevel +diff -r ab05e7dd2788 Lib/plat-mac/EasyDialogs.py +--- a/Lib/plat-mac/EasyDialogs.py ++++ b/Lib/plat-mac/EasyDialogs.py +@@ -243,8 +243,15 @@ + + + ++# The deprecated Carbon QuickDraw APIs are no longer available as of ++# OS X 10.8. Raise an ImportError here in that case so that callers ++# of EasyDialogs, like BuildApplet, will do the right thing. + +-screenbounds = Qd.GetQDGlobalsScreenBits().bounds ++try: ++ screenbounds = Qd.GetQDGlobalsScreenBits().bounds ++except AttributeError: ++ raise ImportError("QuickDraw APIs not available") ++ + screenbounds = screenbounds[0]+4, screenbounds[1]+4, \ + screenbounds[2]-4, screenbounds[3]-4 + +diff -r ab05e7dd2788 Lib/platform.py +--- a/Lib/platform.py ++++ b/Lib/platform.py +@@ -228,7 +228,7 @@ + return 'OpenLinux',pkg[1],id + + if os.path.isdir('/usr/lib/setup'): +- # Check for slackware verson tag file (thanks to Greg Andruk) ++ # Check for slackware version tag file (thanks to Greg Andruk) + verfiles = os.listdir('/usr/lib/setup') + for n in range(len(verfiles)-1, -1, -1): + if verfiles[n][:14] != 'slack-version-': +@@ -280,7 +280,7 @@ + if m is not None: + return tuple(m.groups()) + +- # Unkown format... take the first two words ++ # Unknown format... take the first two words + l = string.split(string.strip(firstline)) + if l: + version = l[0] +@@ -800,7 +800,7 @@ + versioninfo, machine) with versioninfo being a tuple (version, + dev_stage, non_release_version). + +- Entries which cannot be determined are set to the paramter values ++ Entries which cannot be determined are set to the parameter values + which default to ''. All tuple entries are strings. + """ + +diff -r ab05e7dd2788 Lib/poplib.py +--- a/Lib/poplib.py ++++ b/Lib/poplib.py +@@ -321,7 +321,7 @@ + + hostname - the hostname of the pop3 over ssl server + port - port number +- keyfile - PEM formatted file that countains your private key ++ keyfile - PEM formatted file that contains your private key + certfile - PEM formatted certificate chain file + + See the methods of the parent class POP3 for more documentation. +diff -r ab05e7dd2788 Lib/random.py +--- a/Lib/random.py ++++ b/Lib/random.py +@@ -278,6 +278,8 @@ + + Optional arg random is a 0-argument function returning a random + float in [0.0, 1.0); by default, the standard random.random. ++ ++ Do not supply the 'int' argument. + """ + + if random is None: +diff -r ab05e7dd2788 Lib/rlcompleter.py +--- a/Lib/rlcompleter.py ++++ b/Lib/rlcompleter.py +@@ -116,7 +116,7 @@ + """Compute matches when text contains a dot. + + Assuming the text is of the form NAME.NAME....[NAME], and is +- evaluatable in self.namespace, it will be evaluated and its attributes ++ evaluable in self.namespace, it will be evaluated and its attributes + (as revealed by dir()) are used as possible completions. (For class + instances, class members are also considered.) + +diff -r ab05e7dd2788 Lib/robotparser.py +--- a/Lib/robotparser.py ++++ b/Lib/robotparser.py +@@ -160,6 +160,7 @@ + if path == '' and not allowance: + # an empty value means allow all + allowance = True ++ path = urlparse.urlunparse(urlparse.urlparse(path)) + self.path = urllib.quote(path) + self.allowance = allowance + +diff -r ab05e7dd2788 Lib/smtplib.py +--- a/Lib/smtplib.py ++++ b/Lib/smtplib.py +@@ -238,10 +238,11 @@ + If specified, `host' is the name of the remote host to which to + connect. If specified, `port' specifies the port to which to connect. + By default, smtplib.SMTP_PORT is used. If a host is specified the +- connect method is called, and if it returns anything other than +- a success code an SMTPConnectError is raised. If specified, +- `local_hostname` is used as the FQDN of the local host. By default, +- the local hostname is found using socket.getfqdn(). ++ connect method is called, and if it returns anything other than a ++ success code an SMTPConnectError is raised. If specified, ++ `local_hostname` is used as the FQDN of the local host for the ++ HELO/EHLO command. Otherwise, the local hostname is found using ++ socket.getfqdn(). + + """ + self.timeout = timeout +@@ -759,12 +760,15 @@ + if _have_ssl: + + class SMTP_SSL(SMTP): +- """ This is a subclass derived from SMTP that connects over an SSL encrypted +- socket (to use this class you need a socket module that was compiled with SSL +- support). If host is not specified, '' (the local host) is used. If port is +- omitted, the standard SMTP-over-SSL port (465) is used. keyfile and certfile +- are also optional - they can contain a PEM formatted private key and +- certificate chain file for the SSL connection. ++ """ This is a subclass derived from SMTP that connects over an SSL ++ encrypted socket (to use this class you need a socket module that was ++ compiled with SSL support). If host is not specified, '' (the local ++ host) is used. If port is omitted, the standard SMTP-over-SSL port ++ (465) is used. local_hostname has the same meaning as it does in the ++ SMTP class. keyfile and certfile are also optional - they can contain ++ a PEM formatted private key and certificate chain file for the SSL ++ connection. ++ + """ + + default_port = SMTP_SSL_PORT +@@ -795,9 +799,10 @@ + """LMTP - Local Mail Transfer Protocol + + The LMTP protocol, which is very similar to ESMTP, is heavily based +- on the standard SMTP client. It's common to use Unix sockets for LMTP, +- so our connect() method must support that as well as a regular +- host:port server. To specify a Unix socket, you must use an absolute ++ on the standard SMTP client. It's common to use Unix sockets for ++ LMTP, so our connect() method must support that as well as a regular ++ host:port server. local_hostname has the same meaning as it does in ++ the SMTP class. To specify a Unix socket, you must use an absolute + path as the host, starting with a '/'. + + Authentication is supported, using the regular SMTP mechanism. When +diff -r ab05e7dd2788 Lib/sqlite3/test/regression.py +--- a/Lib/sqlite3/test/regression.py ++++ b/Lib/sqlite3/test/regression.py +@@ -159,7 +159,8 @@ + + def CheckCursorConstructorCallCheck(self): + """ +- Verifies that cursor methods check wether base class __init__ was called. ++ Verifies that cursor methods check whether base class __init__ was ++ called. + """ + class Cursor(sqlite.Cursor): + def __init__(self, con): +@@ -177,7 +178,8 @@ + + def CheckConnectionConstructorCallCheck(self): + """ +- Verifies that connection methods check wether base class __init__ was called. ++ Verifies that connection methods check whether base class __init__ was ++ called. + """ + class Connection(sqlite.Connection): + def __init__(self, name): +diff -r ab05e7dd2788 Lib/sqlite3/test/types.py +--- a/Lib/sqlite3/test/types.py ++++ b/Lib/sqlite3/test/types.py +@@ -244,7 +244,7 @@ + self.assertEqual(type(value), float) + + def CheckNumber2(self): +- """Checks wether converter names are cut off at '(' characters""" ++ """Checks whether converter names are cut off at '(' characters""" + self.cur.execute("insert into test(n2) values (5)") + value = self.cur.execute("select n2 from test").fetchone()[0] + # if the converter is not used, it's an int instead of a float +diff -r ab05e7dd2788 Lib/sre_compile.py +--- a/Lib/sre_compile.py ++++ b/Lib/sre_compile.py +@@ -355,8 +355,6 @@ + def _simple(av): + # check if av is a "simple" operator + lo, hi = av[2].getwidth() +- if lo == 0 and hi == MAXREPEAT: +- raise error, "nothing to repeat" + return lo == hi == 1 and av[2][0][0] != SUBPATTERN + + def _compile_info(code, pattern, flags): +diff -r ab05e7dd2788 Lib/sre_parse.py +--- a/Lib/sre_parse.py ++++ b/Lib/sre_parse.py +@@ -142,12 +142,12 @@ + # determine the width (min, max) for this subpattern + if self.width: + return self.width +- lo = hi = 0L ++ lo = hi = 0 + UNITCODES = (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY) + REPEATCODES = (MIN_REPEAT, MAX_REPEAT) + for op, av in self.data: + if op is BRANCH: +- i = sys.maxint ++ i = MAXREPEAT - 1 + j = 0 + for av in av[1]: + l, h = av.getwidth() +@@ -165,14 +165,14 @@ + hi = hi + j + elif op in REPEATCODES: + i, j = av[2].getwidth() +- lo = lo + long(i) * av[0] +- hi = hi + long(j) * av[1] ++ lo = lo + i * av[0] ++ hi = hi + j * av[1] + elif op in UNITCODES: + lo = lo + 1 + hi = hi + 1 + elif op == SUCCESS: + break +- self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint)) ++ self.width = min(lo, MAXREPEAT - 1), min(hi, MAXREPEAT) + return self.width + + class Tokenizer: +diff -r ab05e7dd2788 Lib/subprocess.py +--- a/Lib/subprocess.py ++++ b/Lib/subprocess.py +@@ -2,8 +2,6 @@ + # + # For more information about this module, see PEP 324. + # +-# This module should remain compatible with Python 2.2, see PEP 291. +-# + # Copyright (c) 2003-2005 by Peter Astrand + # + # Licensed to PSF under a Contributor Agreement. +@@ -145,7 +143,7 @@ + started to execute, will be re-raised in the parent. Additionally, + the exception object will have one extra attribute called + 'child_traceback', which is a string containing traceback information +-from the childs point of view. ++from the child's point of view. + + The most common exception raised is OSError. This occurs, for + example, when trying to execute a non-existent file. Applications +@@ -700,12 +698,12 @@ + + (p2cread, p2cwrite, + c2pread, c2pwrite, +- errread, errwrite) = self._get_handles(stdin, stdout, stderr) ++ errread, errwrite), to_close = self._get_handles(stdin, stdout, stderr) + + try: + self._execute_child(args, executable, preexec_fn, close_fds, + cwd, env, universal_newlines, +- startupinfo, creationflags, shell, ++ startupinfo, creationflags, shell, to_close, + p2cread, p2cwrite, + c2pread, c2pwrite, + errread, errwrite) +@@ -713,18 +711,12 @@ + # Preserve original exception in case os.close raises. + exc_type, exc_value, exc_trace = sys.exc_info() + +- to_close = [] +- # Only close the pipes we created. +- if stdin == PIPE: +- to_close.extend((p2cread, p2cwrite)) +- if stdout == PIPE: +- to_close.extend((c2pread, c2pwrite)) +- if stderr == PIPE: +- to_close.extend((errread, errwrite)) +- + for fd in to_close: + try: +- os.close(fd) ++ if mswindows: ++ fd.Close() ++ else: ++ os.close(fd) + except EnvironmentError: + pass + +@@ -818,8 +810,9 @@ + """Construct and return tuple with IO objects: + p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite + """ ++ to_close = set() + if stdin is None and stdout is None and stderr is None: +- return (None, None, None, None, None, None) ++ return (None, None, None, None, None, None), to_close + + p2cread, p2cwrite = None, None + c2pread, c2pwrite = None, None +@@ -837,6 +830,10 @@ + # Assuming file-like object + p2cread = msvcrt.get_osfhandle(stdin.fileno()) + p2cread = self._make_inheritable(p2cread) ++ # We just duplicated the handle, it has to be closed at the end ++ to_close.add(p2cread) ++ if stdin == PIPE: ++ to_close.add(p2cwrite) + + if stdout is None: + c2pwrite = _subprocess.GetStdHandle(_subprocess.STD_OUTPUT_HANDLE) +@@ -850,6 +847,10 @@ + # Assuming file-like object + c2pwrite = msvcrt.get_osfhandle(stdout.fileno()) + c2pwrite = self._make_inheritable(c2pwrite) ++ # We just duplicated the handle, it has to be closed at the end ++ to_close.add(c2pwrite) ++ if stdout == PIPE: ++ to_close.add(c2pread) + + if stderr is None: + errwrite = _subprocess.GetStdHandle(_subprocess.STD_ERROR_HANDLE) +@@ -865,10 +866,14 @@ + # Assuming file-like object + errwrite = msvcrt.get_osfhandle(stderr.fileno()) + errwrite = self._make_inheritable(errwrite) ++ # We just duplicated the handle, it has to be closed at the end ++ to_close.add(errwrite) ++ if stderr == PIPE: ++ to_close.add(errread) + + return (p2cread, p2cwrite, + c2pread, c2pwrite, +- errread, errwrite) ++ errread, errwrite), to_close + + + def _make_inheritable(self, handle): +@@ -897,7 +902,7 @@ + + def _execute_child(self, args, executable, preexec_fn, close_fds, + cwd, env, universal_newlines, +- startupinfo, creationflags, shell, ++ startupinfo, creationflags, shell, to_close, + p2cread, p2cwrite, + c2pread, c2pwrite, + errread, errwrite): +@@ -936,6 +941,10 @@ + # kill children. + creationflags |= _subprocess.CREATE_NEW_CONSOLE + ++ def _close_in_parent(fd): ++ fd.Close() ++ to_close.remove(fd) ++ + # Start the process + try: + hp, ht, pid, tid = _subprocess.CreateProcess(executable, args, +@@ -960,11 +969,11 @@ + # pipe will not close when the child process exits and the + # ReadFile will hang. + if p2cread is not None: +- p2cread.Close() ++ _close_in_parent(p2cread) + if c2pwrite is not None: +- c2pwrite.Close() ++ _close_in_parent(c2pwrite) + if errwrite is not None: +- errwrite.Close() ++ _close_in_parent(errwrite) + + # Retain the process handle, but close the thread handle + self._child_created = True +@@ -1090,6 +1099,7 @@ + """Construct and return tuple with IO objects: + p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite + """ ++ to_close = set() + p2cread, p2cwrite = None, None + c2pread, c2pwrite = None, None + errread, errwrite = None, None +@@ -1098,6 +1108,7 @@ + pass + elif stdin == PIPE: + p2cread, p2cwrite = self.pipe_cloexec() ++ to_close.update((p2cread, p2cwrite)) + elif isinstance(stdin, int): + p2cread = stdin + else: +@@ -1108,6 +1119,7 @@ + pass + elif stdout == PIPE: + c2pread, c2pwrite = self.pipe_cloexec() ++ to_close.update((c2pread, c2pwrite)) + elif isinstance(stdout, int): + c2pwrite = stdout + else: +@@ -1118,6 +1130,7 @@ + pass + elif stderr == PIPE: + errread, errwrite = self.pipe_cloexec() ++ to_close.update((errread, errwrite)) + elif stderr == STDOUT: + errwrite = c2pwrite + elif isinstance(stderr, int): +@@ -1128,7 +1141,7 @@ + + return (p2cread, p2cwrite, + c2pread, c2pwrite, +- errread, errwrite) ++ errread, errwrite), to_close + + + def _set_cloexec_flag(self, fd, cloexec=True): +@@ -1172,7 +1185,7 @@ + + def _execute_child(self, args, executable, preexec_fn, close_fds, + cwd, env, universal_newlines, +- startupinfo, creationflags, shell, ++ startupinfo, creationflags, shell, to_close, + p2cread, p2cwrite, + c2pread, c2pwrite, + errread, errwrite): +@@ -1191,6 +1204,10 @@ + if executable is None: + executable = args[0] + ++ def _close_in_parent(fd): ++ os.close(fd) ++ to_close.remove(fd) ++ + # For transferring possible exec failure from child to parent + # The first char specifies the exception type: 0 means + # OSError, 1 means some other error. +@@ -1249,16 +1266,17 @@ + os.close(fd) + closed.add(fd) + +- # Close all other fds, if asked for +- if close_fds: +- self._close_fds(but=errpipe_write) +- + if cwd is not None: + os.chdir(cwd) + + if preexec_fn: + preexec_fn() + ++ # Close all other fds, if asked for - after ++ # preexec_fn(), which may open FDs. ++ if close_fds: ++ self._close_fds(but=errpipe_write) ++ + if env is None: + os.execvp(executable, args) + else: +@@ -1284,17 +1302,17 @@ + # be sure the FD is closed no matter what + os.close(errpipe_write) + +- if p2cread is not None and p2cwrite is not None: +- os.close(p2cread) +- if c2pwrite is not None and c2pread is not None: +- os.close(c2pwrite) +- if errwrite is not None and errread is not None: +- os.close(errwrite) +- + # Wait for exec to fail or succeed; possibly raising exception + # Exception limited to 1M + data = _eintr_retry_call(os.read, errpipe_read, 1048576) + finally: ++ if p2cread is not None and p2cwrite is not None: ++ _close_in_parent(p2cread) ++ if c2pwrite is not None and c2pread is not None: ++ _close_in_parent(c2pwrite) ++ if errwrite is not None and errread is not None: ++ _close_in_parent(errwrite) ++ + # be sure the FD is closed no matter what + os.close(errpipe_read) + +diff -r ab05e7dd2788 Lib/tarfile.py +--- a/Lib/tarfile.py ++++ b/Lib/tarfile.py +@@ -330,7 +330,7 @@ + """General exception for extract errors.""" + pass + class ReadError(TarError): +- """Exception for unreadble tar archives.""" ++ """Exception for unreadable tar archives.""" + pass + class CompressionError(TarError): + """Exception for unavailable compression methods.""" +diff -r ab05e7dd2788 Lib/tempfile.py +--- a/Lib/tempfile.py ++++ b/Lib/tempfile.py +@@ -242,6 +242,10 @@ + except OSError, e: + if e.errno == _errno.EEXIST: + continue # try again ++ if _os.name == 'nt' and e.errno == _errno.EACCES: ++ # On windows, when a directory with the chosen name already ++ # exists, EACCES error code is returned instead of EEXIST. ++ continue + raise + + raise IOError, (_errno.EEXIST, "No usable temporary file name found") +@@ -612,7 +616,7 @@ + return rv + + def xreadlines(self, *args): +- try: +- return self._file.xreadlines(*args) +- except AttributeError: ++ if hasattr(self._file, 'xreadlines'): # real file ++ return iter(self._file) ++ else: # StringIO() + return iter(self._file.readlines(*args)) +diff -r ab05e7dd2788 Lib/test/inspect_fodder.py +--- a/Lib/test/inspect_fodder.py ++++ b/Lib/test/inspect_fodder.py +@@ -49,6 +49,8 @@ + class MalodorousPervert(StupidGit): + pass + ++Tit = MalodorousPervert ++ + class ParrotDroppings: + pass + +diff -r ab05e7dd2788 Lib/test/leakers/test_ctypes.py +--- a/Lib/test/leakers/test_ctypes.py ++++ b/Lib/test/leakers/test_ctypes.py +@@ -1,6 +1,5 @@ + + # Taken from Lib/ctypes/test/test_keeprefs.py, PointerToStructure.test(). +-# When this leak is fixed, remember to remove from Misc/build.sh LEAKY_TESTS. + + from ctypes import Structure, c_int, POINTER + import gc +diff -r ab05e7dd2788 Lib/test/nullbytecert.pem +--- /dev/null ++++ b/Lib/test/nullbytecert.pem +@@ -0,0 +1,90 @@ ++Certificate: ++ Data: ++ Version: 3 (0x2) ++ Serial Number: 0 (0x0) ++ Signature Algorithm: sha1WithRSAEncryption ++ Issuer: C=US, ST=Oregon, L=Beaverton, O=Python Software Foundation, OU=Python Core Development, CN=null.python.org\x00example.org/emailAddress=python-dev@python.org ++ Validity ++ Not Before: Aug 7 13:11:52 2013 GMT ++ Not After : Aug 7 13:12:52 2013 GMT ++ Subject: C=US, ST=Oregon, L=Beaverton, O=Python Software Foundation, OU=Python Core Development, CN=null.python.org\x00example.org/emailAddress=python-dev@python.org ++ Subject Public Key Info: ++ Public Key Algorithm: rsaEncryption ++ Public-Key: (2048 bit) ++ Modulus: ++ 00:b5:ea:ed:c9:fb:46:7d:6f:3b:76:80:dd:3a:f3: ++ 03:94:0b:a7:a6:db:ec:1d:df:ff:23:74:08:9d:97: ++ 16:3f:a3:a4:7b:3e:1b:0e:96:59:25:03:a7:26:e2: ++ 88:a9:cf:79:cd:f7:04:56:b0:ab:79:32:6e:59:c1: ++ 32:30:54:eb:58:a8:cb:91:f0:42:a5:64:27:cb:d4: ++ 56:31:88:52:ad:cf:bd:7f:f0:06:64:1f:cc:27:b8: ++ a3:8b:8c:f3:d8:29:1f:25:0b:f5:46:06:1b:ca:02: ++ 45:ad:7b:76:0a:9c:bf:bb:b9:ae:0d:16:ab:60:75: ++ ae:06:3e:9c:7c:31:dc:92:2f:29:1a:e0:4b:0c:91: ++ 90:6c:e9:37:c5:90:d7:2a:d7:97:15:a3:80:8f:5d: ++ 7b:49:8f:54:30:d4:97:2c:1c:5b:37:b5:ab:69:30: ++ 68:43:d3:33:78:4b:02:60:f5:3c:44:80:a1:8f:e7: ++ f0:0f:d1:5e:87:9e:46:cf:62:fc:f9:bf:0c:65:12: ++ f1:93:c8:35:79:3f:c8:ec:ec:47:f5:ef:be:44:d5: ++ ae:82:1e:2d:9a:9f:98:5a:67:65:e1:74:70:7c:cb: ++ d3:c2:ce:0e:45:49:27:dc:e3:2d:d4:fb:48:0e:2f: ++ 9e:77:b8:14:46:c0:c4:36:ca:02:ae:6a:91:8c:da: ++ 2f:85 ++ Exponent: 65537 (0x10001) ++ X509v3 extensions: ++ X509v3 Basic Constraints: critical ++ CA:FALSE ++ X509v3 Subject Key Identifier: ++ 88:5A:55:C0:52:FF:61:CD:52:A3:35:0F:EA:5A:9C:24:38:22:F7:5C ++ X509v3 Key Usage: ++ Digital Signature, Non Repudiation, Key Encipherment ++ X509v3 Subject Alternative Name: ++ ************************************************************* ++ WARNING: The values for DNS, email and URI are WRONG. OpenSSL ++ doesn't print the text after a NULL byte. ++ ************************************************************* ++ DNS:altnull.python.org, email:null@python.org, URI:http://null.python.org, IP Address:192.0.2.1, IP Address:2001:DB8:0:0:0:0:0:1 ++ Signature Algorithm: sha1WithRSAEncryption ++ ac:4f:45:ef:7d:49:a8:21:70:8e:88:59:3e:d4:36:42:70:f5: ++ a3:bd:8b:d7:a8:d0:58:f6:31:4a:b1:a4:a6:dd:6f:d9:e8:44: ++ 3c:b6:0a:71:d6:7f:b1:08:61:9d:60:ce:75:cf:77:0c:d2:37: ++ 86:02:8d:5e:5d:f9:0f:71:b4:16:a8:c1:3d:23:1c:f1:11:b3: ++ 56:6e:ca:d0:8d:34:94:e6:87:2a:99:f2:ae:ae:cc:c2:e8:86: ++ de:08:a8:7f:c5:05:fa:6f:81:a7:82:e6:d0:53:9d:34:f4:ac: ++ 3e:40:fe:89:57:7a:29:a4:91:7e:0b:c6:51:31:e5:10:2f:a4: ++ 60:76:cd:95:51:1a:be:8b:a1:b0:fd:ad:52:bd:d7:1b:87:60: ++ d2:31:c7:17:c4:18:4f:2d:08:25:a3:a7:4f:b7:92:ca:e2:f5: ++ 25:f1:54:75:81:9d:b3:3d:61:a2:f7:da:ed:e1:c6:6f:2c:60: ++ 1f:d8:6f:c5:92:05:ab:c9:09:62:49:a9:14:ad:55:11:cc:d6: ++ 4a:19:94:99:97:37:1d:81:5f:8b:cf:a3:a8:96:44:51:08:3d: ++ 0b:05:65:12:eb:b6:70:80:88:48:72:4f:c6:c2:da:cf:cd:8e: ++ 5b:ba:97:2f:60:b4:96:56:49:5e:3a:43:76:63:04:be:2a:f6: ++ c1:ca:a9:94 ++-----BEGIN CERTIFICATE----- ++MIIE2DCCA8CgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBxTELMAkGA1UEBhMCVVMx ++DzANBgNVBAgMBk9yZWdvbjESMBAGA1UEBwwJQmVhdmVydG9uMSMwIQYDVQQKDBpQ ++eXRob24gU29mdHdhcmUgRm91bmRhdGlvbjEgMB4GA1UECwwXUHl0aG9uIENvcmUg ++RGV2ZWxvcG1lbnQxJDAiBgNVBAMMG251bGwucHl0aG9uLm9yZwBleGFtcGxlLm9y ++ZzEkMCIGCSqGSIb3DQEJARYVcHl0aG9uLWRldkBweXRob24ub3JnMB4XDTEzMDgw ++NzEzMTE1MloXDTEzMDgwNzEzMTI1MlowgcUxCzAJBgNVBAYTAlVTMQ8wDQYDVQQI ++DAZPcmVnb24xEjAQBgNVBAcMCUJlYXZlcnRvbjEjMCEGA1UECgwaUHl0aG9uIFNv ++ZnR3YXJlIEZvdW5kYXRpb24xIDAeBgNVBAsMF1B5dGhvbiBDb3JlIERldmVsb3Bt ++ZW50MSQwIgYDVQQDDBtudWxsLnB5dGhvbi5vcmcAZXhhbXBsZS5vcmcxJDAiBgkq ++hkiG9w0BCQEWFXB5dGhvbi1kZXZAcHl0aG9uLm9yZzCCASIwDQYJKoZIhvcNAQEB ++BQADggEPADCCAQoCggEBALXq7cn7Rn1vO3aA3TrzA5QLp6bb7B3f/yN0CJ2XFj+j ++pHs+Gw6WWSUDpybiiKnPec33BFawq3kyblnBMjBU61ioy5HwQqVkJ8vUVjGIUq3P ++vX/wBmQfzCe4o4uM89gpHyUL9UYGG8oCRa17dgqcv7u5rg0Wq2B1rgY+nHwx3JIv ++KRrgSwyRkGzpN8WQ1yrXlxWjgI9de0mPVDDUlywcWze1q2kwaEPTM3hLAmD1PESA ++oY/n8A/RXoeeRs9i/Pm/DGUS8ZPINXk/yOzsR/XvvkTVroIeLZqfmFpnZeF0cHzL ++08LODkVJJ9zjLdT7SA4vnne4FEbAxDbKAq5qkYzaL4UCAwEAAaOB0DCBzTAMBgNV ++HRMBAf8EAjAAMB0GA1UdDgQWBBSIWlXAUv9hzVKjNQ/qWpwkOCL3XDALBgNVHQ8E ++BAMCBeAwgZAGA1UdEQSBiDCBhYIeYWx0bnVsbC5weXRob24ub3JnAGV4YW1wbGUu ++Y29tgSBudWxsQHB5dGhvbi5vcmcAdXNlckBleGFtcGxlLm9yZ4YpaHR0cDovL251 ++bGwucHl0aG9uLm9yZwBodHRwOi8vZXhhbXBsZS5vcmeHBMAAAgGHECABDbgAAAAA ++AAAAAAAAAAEwDQYJKoZIhvcNAQEFBQADggEBAKxPRe99SaghcI6IWT7UNkJw9aO9 ++i9eo0Fj2MUqxpKbdb9noRDy2CnHWf7EIYZ1gznXPdwzSN4YCjV5d+Q9xtBaowT0j ++HPERs1ZuytCNNJTmhyqZ8q6uzMLoht4IqH/FBfpvgaeC5tBTnTT0rD5A/olXeimk ++kX4LxlEx5RAvpGB2zZVRGr6LobD9rVK91xuHYNIxxxfEGE8tCCWjp0+3ksri9SXx ++VHWBnbM9YaL32u3hxm8sYB/Yb8WSBavJCWJJqRStVRHM1koZlJmXNx2BX4vPo6iW ++RFEIPQsFZRLrtnCAiEhyT8bC2s/Njlu6ly9gtJZWSV46Q3ZjBL4q9sHKqZQ= ++-----END CERTIFICATE----- +diff -r ab05e7dd2788 Lib/test/test_ast.py +--- a/Lib/test/test_ast.py ++++ b/Lib/test/test_ast.py +@@ -18,7 +18,7 @@ + + + # These tests are compiled through "exec" +-# There should be atleast one test per statement ++# There should be at least one test per statement + exec_tests = [ + # None + "None", +diff -r ab05e7dd2788 Lib/test/test_asyncore.py +--- a/Lib/test/test_asyncore.py ++++ b/Lib/test/test_asyncore.py +@@ -10,7 +10,7 @@ + import struct + + from test import test_support +-from test.test_support import TESTFN, run_unittest, unlink ++from test.test_support import TESTFN, run_unittest, unlink, HOST + from StringIO import StringIO + + try: +@@ -18,7 +18,6 @@ + except ImportError: + threading = None + +-HOST = test_support.HOST + + class dummysocket: + def __init__(self): +diff -r ab05e7dd2788 Lib/test/test_cgi.py +--- a/Lib/test/test_cgi.py ++++ b/Lib/test/test_cgi.py +@@ -266,6 +266,29 @@ + got = getattr(fs.list[x], k) + self.assertEqual(got, exp) + ++ def test_fieldstorage_multipart_maxline(self): ++ # Issue #18167 ++ maxline = 1 << 16 ++ self.maxDiff = None ++ def check(content): ++ data = """ ++---123 ++Content-Disposition: form-data; name="upload"; filename="fake.txt" ++Content-Type: text/plain ++ ++%s ++---123-- ++""".replace('\n', '\r\n') % content ++ environ = { ++ 'CONTENT_LENGTH': str(len(data)), ++ 'CONTENT_TYPE': 'multipart/form-data; boundary=-123', ++ 'REQUEST_METHOD': 'POST', ++ } ++ self.assertEqual(gen_result(data, environ), {'upload': content}) ++ check('x' * (maxline - 1)) ++ check('x' * (maxline - 1) + '\r') ++ check('x' * (maxline - 1) + '\r' + 'y' * (maxline - 1)) ++ + _qs_result = { + 'key1': 'value1', + 'key2': ['value2x', 'value2y'], +diff -r ab05e7dd2788 Lib/test/test_codeccallbacks.py +--- a/Lib/test/test_codeccallbacks.py ++++ b/Lib/test/test_codeccallbacks.py +@@ -66,15 +66,34 @@ + # replace unencodable characters which numeric character entities. + # For ascii, latin-1 and charmaps this is completely implemented + # in C and should be reasonably fast. +- s = u"\u30b9\u30d1\u30e2 \xe4nd eggs" ++ s = u"\u30b9\u30d1\u30e2 \xe4nd egg\u0161" + self.assertEqual( + s.encode("ascii", "xmlcharrefreplace"), +- "スパモ änd eggs" ++ "スパモ änd eggš" + ) + self.assertEqual( + s.encode("latin-1", "xmlcharrefreplace"), +- "スパモ \xe4nd eggs" ++ "スパモ \xe4nd eggš" + ) ++ self.assertEqual( ++ s.encode("iso-8859-15", "xmlcharrefreplace"), ++ "スパモ \xe4nd egg\xa8" ++ ) ++ ++ def test_xmlcharrefreplace_with_surrogates(self): ++ tests = [(u'\U0001f49d', '💝'), ++ (u'\ud83d', '�'), ++ (u'\udc9d', '�'), ++ (u'\ud83d\udc9d', '💝' if len(u'\U0001f49d') > 1 else ++ '��'), ++ ] ++ for encoding in ['ascii', 'latin1', 'iso-8859-15']: ++ for s, exp in tests: ++ self.assertEqual(s.encode(encoding, 'xmlcharrefreplace'), ++ exp, msg='%r.encode(%r)' % (s, encoding)) ++ self.assertEqual((s+'X').encode(encoding, 'xmlcharrefreplace'), ++ exp+'X', ++ msg='%r.encode(%r)' % (s + 'X', encoding)) + + def test_xmlcharnamereplace(self): + # This time use a named character entity for unencodable +diff -r ab05e7dd2788 Lib/test/test_collections.py +--- a/Lib/test/test_collections.py ++++ b/Lib/test/test_collections.py +@@ -17,6 +17,43 @@ + + TestNT = namedtuple('TestNT', 'x y z') # type used for pickle tests + ++py273_named_tuple_pickle = '''\ ++ccopy_reg ++_reconstructor ++p0 ++(ctest.test_collections ++TestNT ++p1 ++c__builtin__ ++tuple ++p2 ++(I10 ++I20 ++I30 ++tp3 ++tp4 ++Rp5 ++ccollections ++OrderedDict ++p6 ++((lp7 ++(lp8 ++S'x' ++p9 ++aI10 ++aa(lp10 ++S'y' ++p11 ++aI20 ++aa(lp12 ++S'z' ++p13 ++aI30 ++aatp14 ++Rp15 ++b. ++''' ++ + class TestNamedTuple(unittest.TestCase): + + def test_factory(self): +@@ -78,12 +115,12 @@ + self.assertRaises(TypeError, eval, 'Point(XXX=1, y=2)', locals()) # wrong keyword argument + self.assertRaises(TypeError, eval, 'Point(x=1)', locals()) # missing keyword argument + self.assertEqual(repr(p), 'Point(x=11, y=22)') +- self.assertNotIn('__dict__', dir(p)) # verify instance has no dict + self.assertNotIn('__weakref__', dir(p)) + self.assertEqual(p, Point._make([11, 22])) # test _make classmethod + self.assertEqual(p._fields, ('x', 'y')) # test _fields attribute + self.assertEqual(p._replace(x=1), (1, 22)) # test _replace method + self.assertEqual(p._asdict(), dict(x=11, y=22)) # test _asdict method ++ self.assertEqual(vars(p), p._asdict()) # verify that vars() works + + try: + p._replace(x=1, error=2) +@@ -215,6 +252,11 @@ + # test __getnewargs__ + self.assertEqual(t.__getnewargs__(), values) + ++ def test_pickling_bug_18015(self): ++ # http://bugs.python.org/issue18015 ++ pt = pickle.loads(py273_named_tuple_pickle) ++ self.assertEqual(pt.x, 10) ++ + class ABCTestCase(unittest.TestCase): + + def validate_abstract_methods(self, abc, *names): +diff -r ab05e7dd2788 Lib/test/test_cookielib.py +--- a/Lib/test/test_cookielib.py ++++ b/Lib/test/test_cookielib.py +@@ -329,7 +329,7 @@ + ## commas and equals are commonly appear in the cookie value). This also + ## means that if you fold multiple Set-Cookie header fields into one, + ## comma-separated list, it'll be a headache to parse (at least my head +-## starts hurting everytime I think of that code). ++## starts hurting every time I think of that code). + ## - Expires: You'll get all sorts of date formats in the expires, + ## including emtpy expires attributes ("expires="). Be as flexible as you + ## can, and certainly don't expect the weekday to be there; if you can't +diff -r ab05e7dd2788 Lib/test/test_csv.py +--- a/Lib/test/test_csv.py ++++ b/Lib/test/test_csv.py +@@ -914,7 +914,7 @@ + 'Tommy''s Place':'Blue Island':'IL':'12/28/02':'Blue Sunday/White Crow' + 'Stonecutters ''Seafood'' and Chop House':'Lemont':'IL':'12/19/02':'Week Back' + """ +- header = '''\ ++ header1 = '''\ + "venue","city","state","date","performers" + ''' + sample3 = '''\ +@@ -933,10 +933,35 @@ + sample6 = "a|b|c\r\nd|e|f\r\n" + sample7 = "'a'|'b'|'c'\r\n'd'|e|f\r\n" + ++# Issue 18155: Use a delimiter that is a special char to regex: ++ ++ header2 = '''\ ++"venue"+"city"+"state"+"date"+"performers" ++''' ++ sample8 = """\ ++Harry's+ Arlington Heights+ IL+ 2/1/03+ Kimi Hayes ++Shark City+ Glendale Heights+ IL+ 12/28/02+ Prezence ++Tommy's Place+ Blue Island+ IL+ 12/28/02+ Blue Sunday/White Crow ++Stonecutters Seafood and Chop House+ Lemont+ IL+ 12/19/02+ Week Back ++""" ++ sample9 = """\ ++'Harry''s'+ Arlington Heights'+ 'IL'+ '2/1/03'+ 'Kimi Hayes' ++'Shark City'+ Glendale Heights'+' IL'+ '12/28/02'+ 'Prezence' ++'Tommy''s Place'+ Blue Island'+ 'IL'+ '12/28/02'+ 'Blue Sunday/White Crow' ++'Stonecutters ''Seafood'' and Chop House'+ 'Lemont'+ 'IL'+ '12/19/02'+ 'Week Back' ++""" ++ + def test_has_header(self): + sniffer = csv.Sniffer() + self.assertEqual(sniffer.has_header(self.sample1), False) +- self.assertEqual(sniffer.has_header(self.header+self.sample1), True) ++ self.assertEqual(sniffer.has_header(self.header1 + self.sample1), ++ True) ++ ++ def test_has_header_regex_special_delimiter(self): ++ sniffer = csv.Sniffer() ++ self.assertEqual(sniffer.has_header(self.sample8), False) ++ self.assertEqual(sniffer.has_header(self.header2 + self.sample8), ++ True) + + def test_sniff(self): + sniffer = csv.Sniffer() +@@ -970,13 +995,24 @@ + dialect = sniffer.sniff(self.sample7) + self.assertEqual(dialect.delimiter, "|") + self.assertEqual(dialect.quotechar, "'") ++ dialect = sniffer.sniff(self.sample8) ++ self.assertEqual(dialect.delimiter, '+') ++ dialect = sniffer.sniff(self.sample9) ++ self.assertEqual(dialect.delimiter, '+') ++ self.assertEqual(dialect.quotechar, "'") + + def test_doublequote(self): + sniffer = csv.Sniffer() +- dialect = sniffer.sniff(self.header) ++ dialect = sniffer.sniff(self.header1) ++ self.assertFalse(dialect.doublequote) ++ dialect = sniffer.sniff(self.header2) + self.assertFalse(dialect.doublequote) + dialect = sniffer.sniff(self.sample2) + self.assertTrue(dialect.doublequote) ++ dialect = sniffer.sniff(self.sample8) ++ self.assertFalse(dialect.doublequote) ++ dialect = sniffer.sniff(self.sample9) ++ self.assertTrue(dialect.doublequote) + + if not hasattr(sys, "gettotalrefcount"): + if test_support.verbose: print "*** skipping leakage tests ***" +diff -r ab05e7dd2788 Lib/test/test_curses.py +--- a/Lib/test/test_curses.py ++++ b/Lib/test/test_curses.py +@@ -250,6 +250,26 @@ + except curses.panel.error: + pass + ++def test_userptr_memory_leak(stdscr): ++ w = curses.newwin(10, 10) ++ p = curses.panel.new_panel(w) ++ obj = object() ++ nrefs = sys.getrefcount(obj) ++ for i in range(100): ++ p.set_userptr(obj) ++ ++ p.set_userptr(None) ++ if sys.getrefcount(obj) != nrefs: ++ raise RuntimeError, "set_userptr leaked references" ++ ++def test_userptr_segfault(stdscr): ++ panel = curses.panel.new_panel(stdscr) ++ class A: ++ def __del__(self): ++ panel.set_userptr(None) ++ panel.set_userptr(A()) ++ panel.set_userptr(None) ++ + def test_resize_term(stdscr): + if hasattr(curses, 'resizeterm'): + lines, cols = curses.LINES, curses.COLS +@@ -268,6 +288,8 @@ + module_funcs(stdscr) + window_funcs(stdscr) + test_userptr_without_set(stdscr) ++ test_userptr_memory_leak(stdscr) ++ test_userptr_segfault(stdscr) + test_resize_term(stdscr) + test_issue6243(stdscr) + finally: +diff -r ab05e7dd2788 Lib/test/test_datetime.py +--- a/Lib/test/test_datetime.py ++++ b/Lib/test/test_datetime.py +@@ -124,7 +124,7 @@ + self.assertEqual(derived.tzname(None), 'cookie') + + ############################################################################# +-# Base clase for testing a particular aspect of timedelta, time, date and ++# Base class for testing a particular aspect of timedelta, time, date and + # datetime comparisons. + + class HarmlessMixedComparison: +diff -r ab05e7dd2788 Lib/test/test_dictviews.py +--- a/Lib/test/test_dictviews.py ++++ b/Lib/test/test_dictviews.py +@@ -112,6 +112,13 @@ + self.assertEqual(d1.viewkeys() ^ set(d3.viewkeys()), + {'a', 'b', 'd', 'e'}) + ++ self.assertEqual(d1.viewkeys() - d1.viewkeys(), set()) ++ self.assertEqual(d1.viewkeys() - d2.viewkeys(), {'a'}) ++ self.assertEqual(d1.viewkeys() - d3.viewkeys(), {'a', 'b'}) ++ self.assertEqual(d1.viewkeys() - set(d1.viewkeys()), set()) ++ self.assertEqual(d1.viewkeys() - set(d2.viewkeys()), {'a'}) ++ self.assertEqual(d1.viewkeys() - set(d3.viewkeys()), {'a', 'b'}) ++ + def test_items_set_operations(self): + d1 = {'a': 1, 'b': 2} + d2 = {'a': 2, 'b': 2} +@@ -144,6 +151,19 @@ + self.assertEqual(d1.viewitems() ^ d3.viewitems(), + {('a', 1), ('b', 2), ('d', 4), ('e', 5)}) + ++ self.assertEqual(d1.viewitems() - d1.viewitems(), set()) ++ self.assertEqual(d1.viewitems() - d2.viewitems(), {('a', 1)}) ++ self.assertEqual(d1.viewitems() - d3.viewitems(), {('a', 1), ('b', 2)}) ++ self.assertEqual(d1.viewitems() - set(d1.viewitems()), set()) ++ self.assertEqual(d1.viewitems() - set(d2.viewitems()), {('a', 1)}) ++ self.assertEqual(d1.viewitems() - set(d3.viewitems()), ++ {('a', 1), ('b', 2)}) ++ ++ def test_recursive_repr(self): ++ d = {} ++ d[42] = d.viewvalues() ++ self.assertRaises(RuntimeError, repr, d) ++ + + + +diff -r ab05e7dd2788 Lib/test/test_fcntl.py +--- a/Lib/test/test_fcntl.py ++++ b/Lib/test/test_fcntl.py +@@ -11,7 +11,7 @@ + from test.test_support import (verbose, TESTFN, unlink, run_unittest, + import_module) + +-# Skip test if no fnctl module. ++# Skip test if no fcntl module. + fcntl = import_module('fcntl') + + +diff -r ab05e7dd2788 Lib/test/test_file.py +--- a/Lib/test/test_file.py ++++ b/Lib/test/test_file.py +@@ -154,16 +154,6 @@ + f.close() + self.fail('%r is an invalid file mode' % mode) + +- def testStdin(self): +- # This causes the interpreter to exit on OSF1 v5.1. +- if sys.platform != 'osf1V5': +- self.assertRaises((IOError, ValueError), sys.stdin.seek, -1) +- else: +- print(( +- ' Skipping sys.stdin.seek(-1), it may crash the interpreter.' +- ' Test manually.'), file=sys.__stdout__) +- self.assertRaises((IOError, ValueError), sys.stdin.truncate) +- + def testBadModeArgument(self): + # verify that we get a sensible error message for bad mode argument + bad_mode = "qwerty" +diff -r ab05e7dd2788 Lib/test/test_fileio.py +--- a/Lib/test/test_fileio.py ++++ b/Lib/test/test_fileio.py +@@ -305,7 +305,7 @@ + finally: + os.unlink(TESTFN) + +- def testModeStrings(self): ++ def testInvalidModeStrings(self): + # check invalid mode strings + for mode in ("", "aU", "wU+", "rw", "rt"): + try: +@@ -316,6 +316,21 @@ + f.close() + self.fail('%r is an invalid file mode' % mode) + ++ def testModeStrings(self): ++ # test that the mode attribute is correct for various mode strings ++ # given as init args ++ try: ++ for modes in [('w', 'wb'), ('wb', 'wb'), ('wb+', 'rb+'), ++ ('w+b', 'rb+'), ('a', 'ab'), ('ab', 'ab'), ++ ('ab+', 'ab+'), ('a+b', 'ab+'), ('r', 'rb'), ++ ('rb', 'rb'), ('rb+', 'rb+'), ('r+b', 'rb+')]: ++ # read modes are last so that TESTFN will exist first ++ with _FileIO(TESTFN, modes[0]) as f: ++ self.assertEqual(f.mode, modes[1]) ++ finally: ++ if os.path.exists(TESTFN): ++ os.unlink(TESTFN) ++ + def testUnicodeOpen(self): + # verify repr works for unicode too + f = _FileIO(str(TESTFN), "w") +diff -r ab05e7dd2788 Lib/test/test_format.py +--- a/Lib/test/test_format.py ++++ b/Lib/test/test_format.py +@@ -302,6 +302,23 @@ + def test_main(): + test_support.run_unittest(FormatTest) + ++ def test_precision(self): ++ INT_MAX = 2147483647 ++ ++ f = 1.2 ++ self.assertEqual(format(f, ".0f"), "1") ++ self.assertEqual(format(f, ".3f"), "1.200") ++ with self.assertRaises(ValueError) as cm: ++ format(f, ".%sf" % (INT_MAX + 1)) ++ self.assertEqual(str(cm.exception), "precision too big") ++ ++ c = complex(f) ++ self.assertEqual(format(f, ".0f"), "1") ++ self.assertEqual(format(f, ".3f"), "1.200") ++ with self.assertRaises(ValueError) as cm: ++ format(f, ".%sf" % (INT_MAX + 1)) ++ self.assertEqual(str(cm.exception), "precision too big") ++ + + if __name__ == "__main__": + unittest.main() +diff -r ab05e7dd2788 Lib/test/test_ftplib.py +--- a/Lib/test/test_ftplib.py ++++ b/Lib/test/test_ftplib.py +@@ -17,7 +17,7 @@ + + from unittest import TestCase + from test import test_support +-from test.test_support import HOST ++from test.test_support import HOST, HOSTv6 + threading = test_support.import_module('threading') + + +@@ -474,6 +474,14 @@ + def test_rmd(self): + self.client.rmd('foo') + ++ def test_cwd(self): ++ dir = self.client.cwd('/foo') ++ self.assertEqual(dir, '250 cwd ok') ++ ++ def test_mkd(self): ++ dir = self.client.mkd('/foo') ++ self.assertEqual(dir, '/foo') ++ + def test_pwd(self): + dir = self.client.pwd() + self.assertEqual(dir, 'pwd ok') +@@ -554,7 +562,7 @@ + class TestIPv6Environment(TestCase): + + def setUp(self): +- self.server = DummyFTPServer((HOST, 0), af=socket.AF_INET6) ++ self.server = DummyFTPServer((HOSTv6, 0), af=socket.AF_INET6) + self.server.start() + self.client = ftplib.FTP() + self.client.connect(self.server.host, self.server.port) +@@ -705,7 +713,7 @@ + self.assertTrue(socket.getdefaulttimeout() is None) + socket.setdefaulttimeout(30) + try: +- ftp = ftplib.FTP("localhost") ++ ftp = ftplib.FTP(HOST) + finally: + socket.setdefaulttimeout(None) + self.assertEqual(ftp.sock.gettimeout(), 30) +@@ -717,7 +725,7 @@ + self.assertTrue(socket.getdefaulttimeout() is None) + socket.setdefaulttimeout(30) + try: +- ftp = ftplib.FTP("localhost", timeout=None) ++ ftp = ftplib.FTP(HOST, timeout=None) + finally: + socket.setdefaulttimeout(None) + self.assertTrue(ftp.sock.gettimeout() is None) +diff -r ab05e7dd2788 Lib/test/test_heapq.py +--- a/Lib/test/test_heapq.py ++++ b/Lib/test/test_heapq.py +@@ -158,6 +158,15 @@ + self.assertEqual(sorted(chain(*inputs)), list(self.module.merge(*inputs))) + self.assertEqual(list(self.module.merge()), []) + ++ def test_merge_does_not_suppress_index_error(self): ++ # Issue 19018: Heapq.merge suppresses IndexError from user generator ++ def iterable(): ++ s = list(range(10)) ++ for i in range(20): ++ yield s[i] # IndexError when i > 10 ++ with self.assertRaises(IndexError): ++ list(self.module.merge(iterable(), iterable())) ++ + def test_merge_stability(self): + class Int(int): + pass +diff -r ab05e7dd2788 Lib/test/test_httpservers.py +--- a/Lib/test/test_httpservers.py ++++ b/Lib/test/test_httpservers.py +@@ -313,6 +313,9 @@ + #constructs the path relative to the root directory of the HTTPServer + response = self.request(self.tempdir_name + '/test') + self.check_status_and_reason(response, 200, data=self.data) ++ # check for trailing "/" which should return 404. See Issue17324 ++ response = self.request(self.tempdir_name + '/test/') ++ self.check_status_and_reason(response, 404) + response = self.request(self.tempdir_name + '/') + self.check_status_and_reason(response, 200) + response = self.request(self.tempdir_name) +diff -r ab05e7dd2788 Lib/test/test_idle.py +--- /dev/null ++++ b/Lib/test/test_idle.py +@@ -0,0 +1,31 @@ ++import unittest ++from test import test_support as support ++from test.test_support import import_module, use_resources ++ ++# Skip test if _thread or _tkinter wasn't built or idlelib was deleted. ++import_module('threading') # imported by idlelib.PyShell, imports _thread ++tk = import_module('Tkinter') # imports _tkinter ++idletest = import_module('idlelib.idle_test') ++ ++# If buildbot improperly sets gui resource (#18365, #18441), remove it ++# so requires('gui') tests are skipped while non-gui tests still run. ++# If there is a problem with Macs, see #18441, msg 193805 ++if use_resources and 'gui' in use_resources: ++ try: ++ root = tk.Tk() ++ root.destroy() ++ except tk.TclError: ++ while 'gui' in use_resources: ++ use_resources.remove('gui') ++ ++# Without test_main present, regrtest.runtest_inner (line1219) calls ++# unittest.TestLoader().loadTestsFromModule(this_module) which calls ++# load_tests() if it finds it. (Unittest.main does the same.) ++load_tests = idletest.load_tests ++ ++if __name__ == '__main__': ++ # Until unittest supports resources, we emulate regrtest's -ugui ++ # so loaded tests run the same as if textually present here. ++ # If any Idle test ever needs another resource, add it to the list. ++ support.use_resources = ['gui'] # use_resources is initially None ++ unittest.main(verbosity=2, exit=False) +diff -r ab05e7dd2788 Lib/test/test_inspect.py +--- a/Lib/test/test_inspect.py ++++ b/Lib/test/test_inspect.py +@@ -220,8 +220,23 @@ + [('FesteringGob', mod.FesteringGob), + ('MalodorousPervert', mod.MalodorousPervert), + ('ParrotDroppings', mod.ParrotDroppings), +- ('StupidGit', mod.StupidGit)]) +- tree = inspect.getclasstree([cls[1] for cls in classes], 1) ++ ('StupidGit', mod.StupidGit), ++ ('Tit', mod.MalodorousPervert), ++ ]) ++ tree = inspect.getclasstree([cls[1] for cls in classes]) ++ self.assertEqual(tree, ++ [(mod.ParrotDroppings, ()), ++ [(mod.FesteringGob, (mod.MalodorousPervert, ++ mod.ParrotDroppings)) ++ ], ++ (mod.StupidGit, ()), ++ [(mod.MalodorousPervert, (mod.StupidGit,)), ++ [(mod.FesteringGob, (mod.MalodorousPervert, ++ mod.ParrotDroppings)) ++ ] ++ ] ++ ]) ++ tree = inspect.getclasstree([cls[1] for cls in classes], True) + self.assertEqual(tree, + [(mod.ParrotDroppings, ()), + (mod.StupidGit, ()), +diff -r ab05e7dd2788 Lib/test/test_kqueue.py +--- a/Lib/test/test_kqueue.py ++++ b/Lib/test/test_kqueue.py +@@ -70,13 +70,13 @@ + self.assertEqual(ev, ev) + self.assertNotEqual(ev, other) + +- bignum = sys.maxsize * 2 + 1 +- ev = select.kevent(bignum, 1, 2, 3, sys.maxsize, bignum) ++ bignum = 0x7fff ++ ev = select.kevent(bignum, 1, 2, 3, bignum - 1, bignum) + self.assertEqual(ev.ident, bignum) + self.assertEqual(ev.filter, 1) + self.assertEqual(ev.flags, 2) + self.assertEqual(ev.fflags, 3) +- self.assertEqual(ev.data, sys.maxsize) ++ self.assertEqual(ev.data, bignum - 1) + self.assertEqual(ev.udata, bignum) + self.assertEqual(ev, ev) + self.assertNotEqual(ev, other) +diff -r ab05e7dd2788 Lib/test/test_mmap.py +--- a/Lib/test/test_mmap.py ++++ b/Lib/test/test_mmap.py +@@ -470,14 +470,10 @@ + f = open (TESTFN, 'w+b') + f.close() + with open(TESTFN, "rb") as f : +- try: +- m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) +- m.close() +- self.fail("should not have been able to mmap empty file") +- except ValueError as e: +- self.assertEqual(e.message, "cannot mmap an empty file") +- except: +- self.fail("unexpected exception: " + str(e)) ++ self.assertRaisesRegexp(ValueError, ++ "cannot mmap an empty file", ++ mmap.mmap, f.fileno(), 0, ++ access=mmap.ACCESS_READ) + + def test_offset (self): + f = open (TESTFN, 'w+b') +diff -r ab05e7dd2788 Lib/test/test_multiprocessing.py +--- a/Lib/test/test_multiprocessing.py ++++ b/Lib/test/test_multiprocessing.py +@@ -1385,7 +1385,7 @@ + authkey = os.urandom(32) + + manager = QueueManager( +- address=('localhost', 0), authkey=authkey, serializer=SERIALIZER ++ address=(test.test_support.HOST, 0), authkey=authkey, serializer=SERIALIZER + ) + manager.start() + +@@ -1423,7 +1423,7 @@ + def test_rapid_restart(self): + authkey = os.urandom(32) + manager = QueueManager( +- address=('localhost', 0), authkey=authkey, serializer=SERIALIZER) ++ address=(test.test_support.HOST, 0), authkey=authkey, serializer=SERIALIZER) + srvr = manager.get_server() + addr = srvr.address + # Close the connection.Listener socket which gets opened as a part +@@ -2461,12 +2461,80 @@ + self.assertLessEqual(new_size, old_size) + + # ++# Issue #17097: EINTR should be ignored by recv(), send(), accept() etc ++# ++ ++class TestIgnoreEINTR(unittest.TestCase): ++ ++ @classmethod ++ def _test_ignore(cls, conn): ++ def handler(signum, frame): ++ pass ++ signal.signal(signal.SIGUSR1, handler) ++ conn.send('ready') ++ x = conn.recv() ++ conn.send(x) ++ conn.send_bytes(b'x'*(1024*1024)) # sending 1 MB should block ++ ++ @unittest.skipUnless(hasattr(signal, 'SIGUSR1'), 'requires SIGUSR1') ++ def test_ignore(self): ++ conn, child_conn = multiprocessing.Pipe() ++ try: ++ p = multiprocessing.Process(target=self._test_ignore, ++ args=(child_conn,)) ++ p.daemon = True ++ p.start() ++ child_conn.close() ++ self.assertEqual(conn.recv(), 'ready') ++ time.sleep(0.1) ++ os.kill(p.pid, signal.SIGUSR1) ++ time.sleep(0.1) ++ conn.send(1234) ++ self.assertEqual(conn.recv(), 1234) ++ time.sleep(0.1) ++ os.kill(p.pid, signal.SIGUSR1) ++ self.assertEqual(conn.recv_bytes(), b'x'*(1024*1024)) ++ time.sleep(0.1) ++ p.join() ++ finally: ++ conn.close() ++ ++ @classmethod ++ def _test_ignore_listener(cls, conn): ++ def handler(signum, frame): ++ pass ++ signal.signal(signal.SIGUSR1, handler) ++ l = multiprocessing.connection.Listener() ++ conn.send(l.address) ++ a = l.accept() ++ a.send('welcome') ++ ++ @unittest.skipUnless(hasattr(signal, 'SIGUSR1'), 'requires SIGUSR1') ++ def test_ignore_listener(self): ++ conn, child_conn = multiprocessing.Pipe() ++ try: ++ p = multiprocessing.Process(target=self._test_ignore_listener, ++ args=(child_conn,)) ++ p.daemon = True ++ p.start() ++ child_conn.close() ++ address = conn.recv() ++ time.sleep(0.1) ++ os.kill(p.pid, signal.SIGUSR1) ++ time.sleep(0.1) ++ client = multiprocessing.connection.Client(address) ++ self.assertEqual(client.recv(), 'welcome') ++ p.join() ++ finally: ++ conn.close() ++ ++# + # + # + + testcases_other = [OtherTest, TestInvalidHandle, TestInitializers, + TestStdinBadfiledescriptor, TestTimeouts, TestNoForkBomb, +- TestFlags, TestForkAwareThreadLock] ++ TestFlags, TestForkAwareThreadLock, TestIgnoreEINTR] + + # + # +diff -r ab05e7dd2788 Lib/test/test_netrc.py +--- a/Lib/test/test_netrc.py ++++ b/Lib/test/test_netrc.py +@@ -5,9 +5,6 @@ + + class NetrcTestCase(unittest.TestCase): + +- def tearDown(self): +- os.unlink(temp_filename) +- + def make_nrc(self, test_data): + test_data = textwrap.dedent(test_data) + mode = 'w' +@@ -15,6 +12,7 @@ + mode += 't' + with open(temp_filename, mode) as fp: + fp.write(test_data) ++ self.addCleanup(os.unlink, temp_filename) + return netrc.netrc(temp_filename) + + def test_default(self): +@@ -103,6 +101,28 @@ + """, '#pass') + + ++ @unittest.skipUnless(os.name == 'posix', 'POSIX only test') ++ def test_security(self): ++ # This test is incomplete since we are normally not run as root and ++ # therefore can't test the file ownership being wrong. ++ d = test_support.TESTFN ++ os.mkdir(d) ++ self.addCleanup(test_support.rmtree, d) ++ fn = os.path.join(d, '.netrc') ++ with open(fn, 'wt') as f: ++ f.write("""\ ++ machine foo.domain.com login bar password pass ++ default login foo password pass ++ """) ++ with test_support.EnvironmentVarGuard() as environ: ++ environ.set('HOME', d) ++ os.chmod(fn, 0600) ++ nrc = netrc.netrc() ++ self.assertEqual(nrc.hosts['foo.domain.com'], ++ ('bar', None, 'pass')) ++ os.chmod(fn, 0o622) ++ self.assertRaises(netrc.NetrcParseError, netrc.netrc) ++ + def test_main(): + test_support.run_unittest(NetrcTestCase) + +diff -r ab05e7dd2788 Lib/test/test_normalization.py +--- a/Lib/test/test_normalization.py ++++ b/Lib/test/test_normalization.py +@@ -57,7 +57,7 @@ + c1,c2,c3,c4,c5 = [unistr(x) for x in line.split(';')[:-1]] + except RangeError: + # Skip unsupported characters; +- # try atleast adding c1 if we are in part1 ++ # try at least adding c1 if we are in part1 + if part == "@Part1": + try: + c1 = unistr(line.split(';')[0]) +diff -r ab05e7dd2788 Lib/test/test_openpty.py +--- a/Lib/test/test_openpty.py ++++ b/Lib/test/test_openpty.py +@@ -10,6 +10,8 @@ + class OpenptyTest(unittest.TestCase): + def test(self): + master, slave = os.openpty() ++ self.addCleanup(os.close, master) ++ self.addCleanup(os.close, slave) + if not os.isatty(slave): + self.fail("Slave-end of pty is not a terminal.") + +diff -r ab05e7dd2788 Lib/test/test_os.py +--- a/Lib/test/test_os.py ++++ b/Lib/test/test_os.py +@@ -10,8 +10,13 @@ + import signal + import subprocess + import time ++try: ++ import resource ++except ImportError: ++ resource = None + + from test import test_support ++from test.script_helper import assert_python_ok + import mmap + import uuid + +@@ -563,9 +568,36 @@ + data2 = self.get_urandom_subprocess(16) + self.assertNotEqual(data1, data2) + ++ @unittest.skipUnless(resource, "test requires the resource module") ++ def test_urandom_failure(self): ++ # Check urandom() failing when it is not able to open /dev/random. ++ # We spawn a new process to make the test more robust (if getrlimit() ++ # failed to restore the file descriptor limit after this, the whole ++ # test suite would crash; this actually happened on the OS X Tiger ++ # buildbot). ++ code = """if 1: ++ import errno ++ import os ++ import resource ++ ++ soft_limit, hard_limit = resource.getrlimit(resource.RLIMIT_NOFILE) ++ resource.setrlimit(resource.RLIMIT_NOFILE, (1, hard_limit)) ++ try: ++ os.urandom(16) ++ except OSError as e: ++ assert e.errno == errno.EMFILE, e.errno ++ else: ++ raise AssertionError("OSError not raised") ++ """ ++ assert_python_ok('-c', code) ++ ++ ++class ExecvpeTests(unittest.TestCase): ++ + def test_execvpe_with_bad_arglist(self): + self.assertRaises(ValueError, os.execvpe, 'notepad', [], None) + ++ + class Win32ErrorTests(unittest.TestCase): + def test_rename(self): + self.assertRaises(WindowsError, os.rename, test_support.TESTFN, test_support.TESTFN+".bak") +@@ -852,6 +884,7 @@ + MakedirTests, + DevNullTests, + URandomTests, ++ ExecvpeTests, + Win32ErrorTests, + TestInvalidFD, + PosixUidGidTests, +diff -r ab05e7dd2788 Lib/test/test_pep263.py +--- a/Lib/test/test_pep263.py ++++ b/Lib/test/test_pep263.py +@@ -41,6 +41,24 @@ + # two bytes in common with the UTF-8 BOM + self.assertRaises(SyntaxError, eval, '\xef\xbb\x20') + ++ def test_error_message(self): ++ compile('# -*- coding: iso-8859-15 -*-\n', 'dummy', 'exec') ++ compile('\xef\xbb\xbf\n', 'dummy', 'exec') ++ compile('\xef\xbb\xbf# -*- coding: utf-8 -*-\n', 'dummy', 'exec') ++ with self.assertRaisesRegexp(SyntaxError, 'fake'): ++ compile('# -*- coding: fake -*-\n', 'dummy', 'exec') ++ with self.assertRaisesRegexp(SyntaxError, 'iso-8859-15'): ++ compile('\xef\xbb\xbf# -*- coding: iso-8859-15 -*-\n', ++ 'dummy', 'exec') ++ with self.assertRaisesRegexp(SyntaxError, 'BOM'): ++ compile('\xef\xbb\xbf# -*- coding: iso-8859-15 -*-\n', ++ 'dummy', 'exec') ++ with self.assertRaisesRegexp(SyntaxError, 'fake'): ++ compile('\xef\xbb\xbf# -*- coding: fake -*-\n', 'dummy', 'exec') ++ with self.assertRaisesRegexp(SyntaxError, 'BOM'): ++ compile('\xef\xbb\xbf# -*- coding: fake -*-\n', 'dummy', 'exec') ++ ++ + def test_main(): + test_support.run_unittest(PEP263Test) + +diff -r ab05e7dd2788 Lib/test/test_poll.py +--- a/Lib/test/test_poll.py ++++ b/Lib/test/test_poll.py +@@ -1,8 +1,16 @@ + # Test case for the os.poll() function + +-import os, select, random, unittest ++import os ++import random ++import select + import _testcapi +-from test.test_support import TESTFN, run_unittest ++try: ++ import threading ++except ImportError: ++ threading = None ++import time ++import unittest ++from test.test_support import TESTFN, run_unittest, reap_threads + + try: + select.poll +@@ -160,6 +168,36 @@ + self.assertRaises(OverflowError, pollster.poll, _testcapi.INT_MAX + 1) + self.assertRaises(OverflowError, pollster.poll, _testcapi.UINT_MAX + 1) + ++ @unittest.skipUnless(threading, 'Threading required for this test.') ++ @reap_threads ++ def test_threaded_poll(self): ++ r, w = os.pipe() ++ self.addCleanup(os.close, r) ++ self.addCleanup(os.close, w) ++ rfds = [] ++ for i in range(10): ++ fd = os.dup(r) ++ self.addCleanup(os.close, fd) ++ rfds.append(fd) ++ pollster = select.poll() ++ for fd in rfds: ++ pollster.register(fd, select.POLLIN) ++ ++ t = threading.Thread(target=pollster.poll) ++ t.start() ++ try: ++ time.sleep(0.5) ++ # trigger ufds array reallocation ++ for fd in rfds: ++ pollster.unregister(fd) ++ pollster.register(w, select.POLLOUT) ++ self.assertRaises(RuntimeError, pollster.poll) ++ finally: ++ # and make the call to poll() from the thread return ++ os.write(w, b'spam') ++ t.join() ++ ++ + def test_main(): + run_unittest(PollTests) + +diff -r ab05e7dd2788 Lib/test/test_pydoc.py +--- a/Lib/test/test_pydoc.py ++++ b/Lib/test/test_pydoc.py +@@ -4,15 +4,17 @@ + import __builtin__ + import re + import pydoc ++import contextlib + import inspect + import keyword ++import pkgutil + import unittest + import xml.etree + import test.test_support + from collections import namedtuple + from test.script_helper import assert_python_ok + from test.test_support import ( +- TESTFN, rmtree, reap_children, captured_stdout) ++ TESTFN, rmtree, reap_children, captured_stdout, captured_stderr) + + from test import pydoc_mod + +@@ -228,7 +230,30 @@ + print '\n' + ''.join(diffs) + + +-class PyDocDocTest(unittest.TestCase): ++class PydocBaseTest(unittest.TestCase): ++ ++ def _restricted_walk_packages(self, walk_packages, path=None): ++ """ ++ A version of pkgutil.walk_packages() that will restrict itself to ++ a given path. ++ """ ++ default_path = path or [os.path.dirname(__file__)] ++ def wrapper(path=None, prefix='', onerror=None): ++ return walk_packages(path or default_path, prefix, onerror) ++ return wrapper ++ ++ @contextlib.contextmanager ++ def restrict_walk_packages(self, path=None): ++ walk_packages = pkgutil.walk_packages ++ pkgutil.walk_packages = self._restricted_walk_packages(walk_packages, ++ path) ++ try: ++ yield ++ finally: ++ pkgutil.walk_packages = walk_packages ++ ++ ++class PydocDocTest(unittest.TestCase): + + @unittest.skipIf(sys.flags.optimize >= 2, + "Docstrings are omitted with -O2 and above") +@@ -303,7 +328,7 @@ + "") + + +-class PydocImportTest(unittest.TestCase): ++class PydocImportTest(PydocBaseTest): + + def setUp(self): + self.test_dir = os.mkdir(TESTFN) +@@ -338,8 +363,19 @@ + badsyntax = os.path.join(pkgdir, "__init__") + os.extsep + "py" + with open(badsyntax, 'w') as f: + f.write("invalid python syntax = $1\n") +- result = run_pydoc('zqwykjv', '-k', PYTHONPATH=TESTFN) +- self.assertEqual('', result) ++ with self.restrict_walk_packages(path=[TESTFN]): ++ with captured_stdout() as out: ++ with captured_stderr() as err: ++ pydoc.apropos('xyzzy') ++ # No result, no error ++ self.assertEqual(out.getvalue(), '') ++ self.assertEqual(err.getvalue(), '') ++ # The package name is still matched ++ with captured_stdout() as out: ++ with captured_stderr() as err: ++ pydoc.apropos('syntaxerr') ++ self.assertEqual(out.getvalue().strip(), 'syntaxerr') ++ self.assertEqual(err.getvalue(), '') + + def test_apropos_with_unreadable_dir(self): + # Issue 7367 - pydoc -k failed when unreadable dir on path +@@ -348,8 +384,13 @@ + self.addCleanup(os.rmdir, self.unreadable_dir) + # Note, on Windows the directory appears to be still + # readable so this is not really testing the issue there +- result = run_pydoc('zqwykjv', '-k', PYTHONPATH=TESTFN) +- self.assertEqual('', result) ++ with self.restrict_walk_packages(path=[TESTFN]): ++ with captured_stdout() as out: ++ with captured_stderr() as err: ++ pydoc.apropos('SOMEKEY') ++ # No result, no error ++ self.assertEqual(out.getvalue(), '') ++ self.assertEqual(err.getvalue(), '') + + + class TestDescriptions(unittest.TestCase): +@@ -412,7 +453,7 @@ + + def test_main(): + try: +- test.test_support.run_unittest(PyDocDocTest, ++ test.test_support.run_unittest(PydocDocTest, + PydocImportTest, + TestDescriptions, + TestHelper) +diff -r ab05e7dd2788 Lib/test/test_re.py +--- a/Lib/test/test_re.py ++++ b/Lib/test/test_re.py +@@ -897,6 +897,26 @@ + with self.assertRaisesRegexp(sre_constants.error, '\?foo'): + re.compile('(?P)') + ++ def test_issue17998(self): ++ for reps in '*', '+', '?', '{1}': ++ for mod in '', '?': ++ pattern = '.' + reps + mod + 'yz' ++ self.assertEqual(re.compile(pattern, re.S).findall('xyz'), ++ ['xyz'], msg=pattern) ++ pattern = pattern.encode() ++ self.assertEqual(re.compile(pattern, re.S).findall(b'xyz'), ++ [b'xyz'], msg=pattern) ++ ++ ++ def test_bug_2537(self): ++ # issue 2537: empty submatches ++ for outer_op in ('{0,}', '*', '+', '{1,187}'): ++ for inner_op in ('{0,}', '*', '?'): ++ r = re.compile("^((x|y)%s)%s" % (inner_op, outer_op)) ++ m = r.match("xyyzy") ++ self.assertEqual(m.group(0), "xyy") ++ self.assertEqual(m.group(1), "") ++ self.assertEqual(m.group(2), "y") + + def run_re_tests(): + from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR +diff -r ab05e7dd2788 Lib/test/test_robotparser.py +--- a/Lib/test/test_robotparser.py ++++ b/Lib/test/test_robotparser.py +@@ -228,6 +228,18 @@ + + RobotTest(15, doc, good, bad) + ++# 16. Empty query (issue #17403). Normalizing the url first. ++doc = """ ++User-agent: * ++Allow: /some/path? ++Disallow: /another/path? ++""" ++ ++good = ['/some/path?'] ++bad = ['/another/path?'] ++ ++RobotTest(16, doc, good, bad) ++ + + class NetworkTestCase(unittest.TestCase): + +diff -r ab05e7dd2788 Lib/test/test_sax.py +--- a/Lib/test/test_sax.py ++++ b/Lib/test/test_sax.py +@@ -284,6 +284,26 @@ + + self.assertEqual(result.getvalue(), start + " ") + ++ def test_xmlgen_encoding_bytes(self): ++ encodings = ('iso-8859-15', 'utf-8', ++ 'utf-16be', 'utf-16le', ++ 'utf-32be', 'utf-32le') ++ for encoding in encodings: ++ result = self.ioclass() ++ gen = XMLGenerator(result, encoding=encoding) ++ ++ gen.startDocument() ++ gen.startElement("doc", {"a": u'\u20ac'}) ++ gen.characters(u"\u20ac".encode(encoding)) ++ gen.ignorableWhitespace(" ".encode(encoding)) ++ gen.endElement("doc") ++ gen.endDocument() ++ ++ self.assertEqual(result.getvalue(), ( ++ u'\n' ++ u'\u20ac ' % encoding ++ ).encode(encoding, 'xmlcharrefreplace')) ++ + def test_xmlgen_ns(self): + result = self.ioclass() + gen = XMLGenerator(result) +diff -r ab05e7dd2788 Lib/test/test_socket.py +--- a/Lib/test/test_socket.py ++++ b/Lib/test/test_socket.py +@@ -665,6 +665,9 @@ + socket.getaddrinfo(None, 0, socket.AF_UNSPEC, socket.SOCK_STREAM, 0, + socket.AI_PASSIVE) + ++ # Issue 17269 ++ if hasattr(socket, 'AI_NUMERICSERV'): ++ socket.getaddrinfo("localhost", None, 0, 0, 0, socket.AI_NUMERICSERV) + + def check_sendall_interrupted(self, with_timeout): + # socketpair() is not stricly required, but it makes things easier. +@@ -685,11 +688,12 @@ + c.settimeout(1.5) + with self.assertRaises(ZeroDivisionError): + signal.alarm(1) +- c.sendall(b"x" * (1024**2)) ++ c.sendall(b"x" * test_support.SOCK_MAX_SIZE) + if with_timeout: + signal.signal(signal.SIGALRM, ok_handler) + signal.alarm(1) +- self.assertRaises(socket.timeout, c.sendall, b"x" * (1024**2)) ++ self.assertRaises(socket.timeout, c.sendall, ++ b"x" * test_support.SOCK_MAX_SIZE) + finally: + signal.signal(signal.SIGALRM, old_alarm) + c.close() +diff -r ab05e7dd2788 Lib/test/test_ssl.py +--- a/Lib/test/test_ssl.py ++++ b/Lib/test/test_ssl.py +@@ -25,6 +25,7 @@ + HOST = test_support.HOST + CERTFILE = None + SVN_PYTHON_ORG_ROOT_CERT = None ++NULLBYTECERT = None + + def handle_error(prefix): + exc_format = ' '.join(traceback.format_exception(*sys.exc_info())) +@@ -123,6 +124,35 @@ + ('DNS', 'projects.forum.nokia.com')) + ) + ++ def test_parse_cert_CVE_2013_4238(self): ++ p = ssl._ssl._test_decode_cert(NULLBYTECERT) ++ if test_support.verbose: ++ sys.stdout.write("\n" + pprint.pformat(p) + "\n") ++ subject = ((('countryName', 'US'),), ++ (('stateOrProvinceName', 'Oregon'),), ++ (('localityName', 'Beaverton'),), ++ (('organizationName', 'Python Software Foundation'),), ++ (('organizationalUnitName', 'Python Core Development'),), ++ (('commonName', 'null.python.org\x00example.org'),), ++ (('emailAddress', 'python-dev@python.org'),)) ++ self.assertEqual(p['subject'], subject) ++ self.assertEqual(p['issuer'], subject) ++ if ssl.OPENSSL_VERSION_INFO >= (0, 9, 8): ++ san = (('DNS', 'altnull.python.org\x00example.com'), ++ ('email', 'null@python.org\x00user@example.org'), ++ ('URI', 'http://null.python.org\x00http://example.org'), ++ ('IP Address', '192.0.2.1'), ++ ('IP Address', '2001:DB8:0:0:0:0:0:1\n')) ++ else: ++ # OpenSSL 0.9.7 doesn't support IPv6 addresses in subjectAltName ++ san = (('DNS', 'altnull.python.org\x00example.com'), ++ ('email', 'null@python.org\x00user@example.org'), ++ ('URI', 'http://null.python.org\x00http://example.org'), ++ ('IP Address', '192.0.2.1'), ++ ('IP Address', '')) ++ ++ self.assertEqual(p['subjectAltName'], san) ++ + def test_DER_to_PEM(self): + with open(SVN_PYTHON_ORG_ROOT_CERT, 'r') as f: + pem = f.read() +@@ -1360,7 +1390,7 @@ + + + def test_main(verbose=False): +- global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, NOKIACERT ++ global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, NOKIACERT, NULLBYTECERT + CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, + "keycert.pem") + SVN_PYTHON_ORG_ROOT_CERT = os.path.join( +@@ -1368,10 +1398,13 @@ + "https_svn_python_org_root.pem") + NOKIACERT = os.path.join(os.path.dirname(__file__) or os.curdir, + "nokia.pem") ++ NULLBYTECERT = os.path.join(os.path.dirname(__file__) or os.curdir, ++ "nullbytecert.pem") + + if (not os.path.exists(CERTFILE) or + not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT) or +- not os.path.exists(NOKIACERT)): ++ not os.path.exists(NOKIACERT) or ++ not os.path.exists(NULLBYTECERT)): + raise test_support.TestFailed("Can't read certificate files!") + + tests = [BasicTests, BasicSocketTests] +diff -r ab05e7dd2788 Lib/test/test_stat.py +--- /dev/null ++++ b/Lib/test/test_stat.py +@@ -0,0 +1,175 @@ ++import unittest ++import os ++from test.test_support import TESTFN, run_unittest ++import stat ++ ++class TestFilemode(unittest.TestCase): ++ file_flags = {'SF_APPEND', 'SF_ARCHIVED', 'SF_IMMUTABLE', 'SF_NOUNLINK', ++ 'SF_SNAPSHOT', 'UF_APPEND', 'UF_COMPRESSED', 'UF_HIDDEN', ++ 'UF_IMMUTABLE', 'UF_NODUMP', 'UF_NOUNLINK', 'UF_OPAQUE'} ++ ++ formats = {'S_IFBLK', 'S_IFCHR', 'S_IFDIR', 'S_IFIFO', 'S_IFLNK', ++ 'S_IFREG', 'S_IFSOCK'} ++ ++ format_funcs = {'S_ISBLK', 'S_ISCHR', 'S_ISDIR', 'S_ISFIFO', 'S_ISLNK', ++ 'S_ISREG', 'S_ISSOCK'} ++ ++ stat_struct = { ++ 'ST_MODE': 0, ++ 'ST_INO': 1, ++ 'ST_DEV': 2, ++ 'ST_NLINK': 3, ++ 'ST_UID': 4, ++ 'ST_GID': 5, ++ 'ST_SIZE': 6, ++ 'ST_ATIME': 7, ++ 'ST_MTIME': 8, ++ 'ST_CTIME': 9} ++ ++ # permission bit value are defined by POSIX ++ permission_bits = { ++ 'S_ISUID': 0o4000, ++ 'S_ISGID': 0o2000, ++ 'S_ENFMT': 0o2000, ++ 'S_ISVTX': 0o1000, ++ 'S_IRWXU': 0o700, ++ 'S_IRUSR': 0o400, ++ 'S_IREAD': 0o400, ++ 'S_IWUSR': 0o200, ++ 'S_IWRITE': 0o200, ++ 'S_IXUSR': 0o100, ++ 'S_IEXEC': 0o100, ++ 'S_IRWXG': 0o070, ++ 'S_IRGRP': 0o040, ++ 'S_IWGRP': 0o020, ++ 'S_IXGRP': 0o010, ++ 'S_IRWXO': 0o007, ++ 'S_IROTH': 0o004, ++ 'S_IWOTH': 0o002, ++ 'S_IXOTH': 0o001} ++ ++ def setUp(self): ++ try: ++ os.remove(TESTFN) ++ except OSError: ++ try: ++ os.rmdir(TESTFN) ++ except OSError: ++ pass ++ tearDown = setUp ++ ++ def get_mode(self, fname=TESTFN, lstat=True): ++ if lstat: ++ st_mode = os.lstat(fname).st_mode ++ else: ++ st_mode = os.stat(fname).st_mode ++ return st_mode ++ ++ def assertS_IS(self, name, mode): ++ # test format, lstrip is for S_IFIFO ++ fmt = getattr(stat, "S_IF" + name.lstrip("F")) ++ self.assertEqual(stat.S_IFMT(mode), fmt) ++ # test that just one function returns true ++ testname = "S_IS" + name ++ for funcname in self.format_funcs: ++ func = getattr(stat, funcname, None) ++ if func is None: ++ if funcname == testname: ++ raise ValueError(funcname) ++ continue ++ if funcname == testname: ++ self.assertTrue(func(mode)) ++ else: ++ self.assertFalse(func(mode)) ++ ++ def test_mode(self): ++ with open(TESTFN, 'w'): ++ pass ++ if os.name == 'posix': ++ os.chmod(TESTFN, 0o700) ++ st_mode = self.get_mode() ++ self.assertS_IS("REG", st_mode) ++ self.assertEqual(stat.S_IMODE(st_mode), ++ stat.S_IRWXU) ++ ++ os.chmod(TESTFN, 0o070) ++ st_mode = self.get_mode() ++ self.assertS_IS("REG", st_mode) ++ self.assertEqual(stat.S_IMODE(st_mode), ++ stat.S_IRWXG) ++ ++ os.chmod(TESTFN, 0o007) ++ st_mode = self.get_mode() ++ self.assertS_IS("REG", st_mode) ++ self.assertEqual(stat.S_IMODE(st_mode), ++ stat.S_IRWXO) ++ ++ os.chmod(TESTFN, 0o444) ++ st_mode = self.get_mode() ++ self.assertS_IS("REG", st_mode) ++ self.assertEqual(stat.S_IMODE(st_mode), 0o444) ++ else: ++ os.chmod(TESTFN, 0o700) ++ st_mode = self.get_mode() ++ self.assertS_IS("REG", st_mode) ++ self.assertEqual(stat.S_IFMT(st_mode), ++ stat.S_IFREG) ++ ++ def test_directory(self): ++ os.mkdir(TESTFN) ++ os.chmod(TESTFN, 0o700) ++ st_mode = self.get_mode() ++ self.assertS_IS("DIR", st_mode) ++ ++ @unittest.skipUnless(hasattr(os, 'symlink'), 'os.symlink not available') ++ def test_link(self): ++ try: ++ os.symlink(os.getcwd(), TESTFN) ++ except (OSError, NotImplementedError) as err: ++ raise unittest.SkipTest(str(err)) ++ else: ++ st_mode = self.get_mode() ++ self.assertS_IS("LNK", st_mode) ++ ++ @unittest.skipUnless(hasattr(os, 'mkfifo'), 'os.mkfifo not available') ++ def test_fifo(self): ++ os.mkfifo(TESTFN, 0o700) ++ st_mode = self.get_mode() ++ self.assertS_IS("FIFO", st_mode) ++ ++ @unittest.skipUnless(os.name == 'posix', 'requires Posix') ++ def test_devices(self): ++ if os.path.exists(os.devnull): ++ st_mode = self.get_mode(os.devnull, lstat=False) ++ self.assertS_IS("CHR", st_mode) ++ # Linux block devices, BSD has no block devices anymore ++ for blockdev in ("/dev/sda", "/dev/hda"): ++ if os.path.exists(blockdev): ++ st_mode = self.get_mode(blockdev, lstat=False) ++ self.assertS_IS("BLK", st_mode) ++ break ++ ++ def test_module_attributes(self): ++ for key, value in self.stat_struct.items(): ++ modvalue = getattr(stat, key) ++ self.assertEqual(value, modvalue, key) ++ for key, value in self.permission_bits.items(): ++ modvalue = getattr(stat, key) ++ self.assertEqual(value, modvalue, key) ++ for key in self.file_flags: ++ modvalue = getattr(stat, key) ++ self.assertIsInstance(modvalue, int) ++ for key in self.formats: ++ modvalue = getattr(stat, key) ++ self.assertIsInstance(modvalue, int) ++ for key in self.format_funcs: ++ func = getattr(stat, key) ++ self.assertTrue(callable(func)) ++ self.assertEqual(func(0), 0) ++ ++ ++def test_main(): ++ run_unittest(TestFilemode) ++ ++if __name__ == '__main__': ++ test_main() +diff -r ab05e7dd2788 Lib/test/test_subprocess.py +--- a/Lib/test/test_subprocess.py ++++ b/Lib/test/test_subprocess.py +@@ -14,6 +14,10 @@ + import resource + except ImportError: + resource = None ++try: ++ import threading ++except ImportError: ++ threading = None + + mswindows = (sys.platform == "win32") + +@@ -629,6 +633,36 @@ + if c.exception.errno not in (errno.ENOENT, errno.EACCES): + raise c.exception + ++ @unittest.skipIf(threading is None, "threading required") ++ def test_double_close_on_error(self): ++ # Issue #18851 ++ fds = [] ++ def open_fds(): ++ for i in range(20): ++ fds.extend(os.pipe()) ++ time.sleep(0.001) ++ t = threading.Thread(target=open_fds) ++ t.start() ++ try: ++ with self.assertRaises(EnvironmentError): ++ subprocess.Popen(['nonexisting_i_hope'], ++ stdin=subprocess.PIPE, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE) ++ finally: ++ t.join() ++ exc = None ++ for fd in fds: ++ # If a double close occurred, some of those fds will ++ # already have been closed by mistake, and os.close() ++ # here will raise. ++ try: ++ os.close(fd) ++ except OSError as e: ++ exc = e ++ if exc is not None: ++ raise exc ++ + def test_handles_closed_on_exception(self): + # If CreateProcess exits with an error, ensure the + # duplicate output handles are released +@@ -783,7 +817,7 @@ + + def _execute_child( + self, args, executable, preexec_fn, close_fds, cwd, env, +- universal_newlines, startupinfo, creationflags, shell, ++ universal_newlines, startupinfo, creationflags, shell, to_close, + p2cread, p2cwrite, + c2pread, c2pwrite, + errread, errwrite): +@@ -791,7 +825,7 @@ + subprocess.Popen._execute_child( + self, args, executable, preexec_fn, close_fds, + cwd, env, universal_newlines, +- startupinfo, creationflags, shell, ++ startupinfo, creationflags, shell, to_close, + p2cread, p2cwrite, + c2pread, c2pwrite, + errread, errwrite) +@@ -806,7 +840,8 @@ + self._testcase.assertNotIn( + fd, (p2cwrite, c2pread, errread)) + finally: +- map(os.close, devzero_fds) ++ for fd in devzero_fds: ++ os.close(fd) + + @unittest.skipIf(not os.path.exists("/dev/zero"), "/dev/zero required.") + def test_preexec_errpipe_does_not_double_close_pipes(self): +diff -r ab05e7dd2788 Lib/test/test_support.py +--- a/Lib/test/test_support.py ++++ b/Lib/test/test_support.py +@@ -184,7 +184,7 @@ + + if sys.platform.startswith("win"): + def _waitfor(func, pathname, waitall=False): +- # Peform the operation ++ # Perform the operation + func(pathname) + # Now setup the wait loop + if waitall: +@@ -200,7 +200,7 @@ + # required when contention occurs. + timeout = 0.001 + while timeout < 1.0: +- # Note we are only testing for the existance of the file(s) in ++ # Note we are only testing for the existence of the file(s) in + # the contents of the directory regardless of any security or + # access rights. If we have made it this far, we have sufficient + # permissions to do that much using Python's equivalent of the +@@ -290,7 +290,12 @@ + msg = "Use of the `%s' resource not enabled" % resource + raise ResourceDenied(msg) + +-HOST = 'localhost' ++ ++# Don't use "localhost", since resolving it uses the DNS under recent ++# Windows versions (see issue #18792). ++HOST = "127.0.0.1" ++HOSTv6 = "::1" ++ + + def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM): + """Returns an unused port that should be suitable for binding. This is +@@ -406,8 +411,14 @@ + # Windows limit seems to be around 512 B, and many Unix kernels have a + # 64 KiB pipe buffer size or 16 * PAGE_SIZE: take a few megs to be sure. + # (see issue #17835 for a discussion of this number). +-PIPE_MAX_SIZE = 4 *1024 * 1024 + 1 ++PIPE_MAX_SIZE = 4 * 1024 * 1024 + 1 + ++# A constant likely larger than the underlying OS socket buffer size, to make ++# writes blocking. ++# The socket buffer sizes can usually be tuned system-wide (e.g. through sysctl ++# on Linux), or on a per-socket basis (SO_SNDBUF/SO_RCVBUF). See issue #18643 ++# for a discussion of this number). ++SOCK_MAX_SIZE = 16 * 1024 * 1024 + 1 + + try: + unicode +diff -r ab05e7dd2788 Lib/test/test_tcl.py +--- a/Lib/test/test_tcl.py ++++ b/Lib/test/test_tcl.py +@@ -3,6 +3,7 @@ + import unittest + import sys + import os ++import _testcapi + from test import test_support + from subprocess import Popen, PIPE + +@@ -12,6 +13,14 @@ + from Tkinter import Tcl + from _tkinter import TclError + ++tcl_version = _tkinter.TCL_VERSION.split('.') ++try: ++ for i in range(len(tcl_version)): ++ tcl_version[i] = int(tcl_version[i]) ++except ValueError: ++ pass ++tcl_version = tuple(tcl_version) ++ + + class TkinterTest(unittest.TestCase): + +@@ -184,9 +193,93 @@ + self.assertEqual(passValue(f), f) + self.assertEqual(passValue((1, '2', (3.4,))), (1, '2', (3.4,))) + ++ def test_splitlist(self): ++ splitlist = self.interp.tk.splitlist ++ call = self.interp.tk.call ++ self.assertRaises(TypeError, splitlist) ++ self.assertRaises(TypeError, splitlist, 'a', 'b') ++ self.assertRaises(TypeError, splitlist, 2) ++ testcases = [ ++ ('2', ('2',)), ++ ('', ()), ++ ('{}', ('',)), ++ ('""', ('',)), ++ ('a\n b\t\r c\n ', ('a', 'b', 'c')), ++ (u'a\n b\t\r c\n ', ('a', 'b', 'c')), ++ ('a \xe2\x82\xac', ('a', '\xe2\x82\xac')), ++ (u'a \u20ac', ('a', '\xe2\x82\xac')), ++ ('a {b c}', ('a', 'b c')), ++ (r'a b\ c', ('a', 'b c')), ++ (('a', 'b c'), ('a', 'b c')), ++ ('a 2', ('a', '2')), ++ (('a', 2), ('a', 2)), ++ ('a 3.4', ('a', '3.4')), ++ (('a', 3.4), ('a', 3.4)), ++ ((), ()), ++ (call('list', 1, '2', (3.4,)), (1, '2', (3.4,))), ++ ] ++ if tcl_version >= (8, 5): ++ testcases += [ ++ (call('dict', 'create', 1, u'\u20ac', '\xe2\x82\xac', (3.4,)), ++ (1, u'\u20ac', u'\u20ac', (3.4,))), ++ ] ++ for arg, res in testcases: ++ self.assertEqual(splitlist(arg), res) ++ self.assertRaises(TclError, splitlist, '{') ++ ++ def test_split(self): ++ split = self.interp.tk.split ++ call = self.interp.tk.call ++ self.assertRaises(TypeError, split) ++ self.assertRaises(TypeError, split, 'a', 'b') ++ self.assertRaises(TypeError, split, 2) ++ testcases = [ ++ ('2', '2'), ++ ('', ''), ++ ('{}', ''), ++ ('""', ''), ++ ('{', '{'), ++ ('a\n b\t\r c\n ', ('a', 'b', 'c')), ++ (u'a\n b\t\r c\n ', ('a', 'b', 'c')), ++ ('a \xe2\x82\xac', ('a', '\xe2\x82\xac')), ++ (u'a \u20ac', ('a', '\xe2\x82\xac')), ++ ('a {b c}', ('a', ('b', 'c'))), ++ (r'a b\ c', ('a', ('b', 'c'))), ++ (('a', 'b c'), ('a', ('b', 'c'))), ++ (('a', u'b c'), ('a', ('b', 'c'))), ++ ('a 2', ('a', '2')), ++ (('a', 2), ('a', 2)), ++ ('a 3.4', ('a', '3.4')), ++ (('a', 3.4), ('a', 3.4)), ++ (('a', (2, 3.4)), ('a', (2, 3.4))), ++ ((), ()), ++ (call('list', 1, '2', (3.4,)), (1, '2', (3.4,))), ++ ] ++ if tcl_version >= (8, 5): ++ testcases += [ ++ (call('dict', 'create', 12, u'\u20ac', '\xe2\x82\xac', (3.4,)), ++ (12, u'\u20ac', u'\u20ac', (3.4,))), ++ ] ++ for arg, res in testcases: ++ self.assertEqual(split(arg), res) ++ ++ ++class BigmemTclTest(unittest.TestCase): ++ ++ def setUp(self): ++ self.interp = Tcl() ++ ++ @unittest.skipUnless(_testcapi.INT_MAX < _testcapi.PY_SSIZE_T_MAX, ++ "needs UINT_MAX < SIZE_MAX") ++ @test_support.precisionbigmemtest(size=_testcapi.INT_MAX + 1, memuse=5, ++ dry_run=False) ++ def test_huge_string(self, size): ++ value = ' ' * size ++ self.assertRaises(OverflowError, self.interp.call, 'set', '_', value) ++ + + def test_main(): +- test_support.run_unittest(TclTest, TkinterTest) ++ test_support.run_unittest(TclTest, TkinterTest, BigmemTclTest) + + if __name__ == "__main__": + test_main() +diff -r ab05e7dd2788 Lib/test/test_telnetlib.py +--- a/Lib/test/test_telnetlib.py ++++ b/Lib/test/test_telnetlib.py +@@ -92,6 +92,14 @@ + self.assertEqual(telnet.sock.gettimeout(), 30) + telnet.sock.close() + ++ def testGetters(self): ++ # Test telnet getter methods ++ telnet = telnetlib.Telnet(HOST, self.port, timeout=30) ++ t_sock = telnet.sock ++ self.assertEqual(telnet.get_socket(), t_sock) ++ self.assertEqual(telnet.fileno(), t_sock.fileno()) ++ telnet.sock.close() ++ + def _read_setUp(self): + self.evt = threading.Event() + self.dataq = Queue.Queue() +diff -r ab05e7dd2788 Lib/test/test_tempfile.py +--- a/Lib/test/test_tempfile.py ++++ b/Lib/test/test_tempfile.py +@@ -8,6 +8,7 @@ + import sys + import re + import warnings ++import contextlib + + import unittest + from test import test_support as support +@@ -270,6 +271,22 @@ + test_classes.append(test__get_candidate_names) + + ++@contextlib.contextmanager ++def _inside_empty_temp_dir(): ++ dir = tempfile.mkdtemp() ++ try: ++ with support.swap_attr(tempfile, 'tempdir', dir): ++ yield ++ finally: ++ support.rmtree(dir) ++ ++ ++def _mock_candidate_names(*names): ++ return support.swap_attr(tempfile, ++ '_get_candidate_names', ++ lambda: iter(names)) ++ ++ + class test__mkstemp_inner(TC): + """Test the internal function _mkstemp_inner.""" + +@@ -386,6 +403,37 @@ + self.do_create(bin=0).write("blat\n") + # XXX should test that the file really is a text file + ++ def default_mkstemp_inner(self): ++ return tempfile._mkstemp_inner(tempfile.gettempdir(), ++ tempfile.template, ++ '', ++ tempfile._bin_openflags) ++ ++ def test_collision_with_existing_file(self): ++ # _mkstemp_inner tries another name when a file with ++ # the chosen name already exists ++ with _inside_empty_temp_dir(), \ ++ _mock_candidate_names('aaa', 'aaa', 'bbb'): ++ (fd1, name1) = self.default_mkstemp_inner() ++ os.close(fd1) ++ self.assertTrue(name1.endswith('aaa')) ++ ++ (fd2, name2) = self.default_mkstemp_inner() ++ os.close(fd2) ++ self.assertTrue(name2.endswith('bbb')) ++ ++ def test_collision_with_existing_directory(self): ++ # _mkstemp_inner tries another name when a directory with ++ # the chosen name already exists ++ with _inside_empty_temp_dir(), \ ++ _mock_candidate_names('aaa', 'aaa', 'bbb'): ++ dir = tempfile.mkdtemp() ++ self.assertTrue(dir.endswith('aaa')) ++ ++ (fd, name) = self.default_mkstemp_inner() ++ os.close(fd) ++ self.assertTrue(name.endswith('bbb')) ++ + test_classes.append(test__mkstemp_inner) + + +@@ -561,6 +609,27 @@ + finally: + os.rmdir(dir) + ++ def test_collision_with_existing_file(self): ++ # mkdtemp tries another name when a file with ++ # the chosen name already exists ++ with _inside_empty_temp_dir(), \ ++ _mock_candidate_names('aaa', 'aaa', 'bbb'): ++ file = tempfile.NamedTemporaryFile(delete=False) ++ file.close() ++ self.assertTrue(file.name.endswith('aaa')) ++ dir = tempfile.mkdtemp() ++ self.assertTrue(dir.endswith('bbb')) ++ ++ def test_collision_with_existing_directory(self): ++ # mkdtemp tries another name when a directory with ++ # the chosen name already exists ++ with _inside_empty_temp_dir(), \ ++ _mock_candidate_names('aaa', 'aaa', 'bbb'): ++ dir1 = tempfile.mkdtemp() ++ self.assertTrue(dir1.endswith('aaa')) ++ dir2 = tempfile.mkdtemp() ++ self.assertTrue(dir2.endswith('bbb')) ++ + test_classes.append(test_mkdtemp) + + +diff -r ab05e7dd2788 Lib/test/test_threading.py +--- a/Lib/test/test_threading.py ++++ b/Lib/test/test_threading.py +@@ -443,6 +443,29 @@ + self.assertEqual(out, '') + self.assertEqual(err, '') + ++ @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") ++ def test_is_alive_after_fork(self): ++ # Try hard to trigger #18418: is_alive() could sometimes be True on ++ # threads that vanished after a fork. ++ old_interval = sys.getcheckinterval() ++ ++ # Make the bug more likely to manifest. ++ sys.setcheckinterval(10) ++ ++ try: ++ for i in range(20): ++ t = threading.Thread(target=lambda: None) ++ t.start() ++ pid = os.fork() ++ if pid == 0: ++ os._exit(1 if t.is_alive() else 0) ++ else: ++ t.join() ++ pid, status = os.waitpid(pid, 0) ++ self.assertEqual(0, status) ++ finally: ++ sys.setcheckinterval(old_interval) ++ + + class ThreadJoinOnShutdown(BaseTestCase): + +diff -r ab05e7dd2788 Lib/test/test_unicode.py +--- a/Lib/test/test_unicode.py ++++ b/Lib/test/test_unicode.py +@@ -1658,6 +1658,18 @@ + self.assertEqual(unicode_encodedecimal(u"123\u20ac\u0660", "replace"), + b'123?0') + ++ def test_encode_decimal_with_surrogates(self): ++ from _testcapi import unicode_encodedecimal ++ tests = [(u'\U0001f49d', '💝'), ++ (u'\ud83d', '�'), ++ (u'\udc9d', '�'), ++ (u'\ud83d\udc9d', '💝' if len(u'\U0001f49d') > 1 else ++ '��'), ++ ] ++ for s, exp in tests: ++ self.assertEqual( ++ unicode_encodedecimal(u"123" + s, "xmlcharrefreplace"), ++ '123' + exp) + + def test_main(): + test_support.run_unittest(__name__) +diff -r ab05e7dd2788 Lib/test/test_urllib.py +--- a/Lib/test/test_urllib.py ++++ b/Lib/test/test_urllib.py +@@ -227,13 +227,13 @@ + 'file://localhost/a/missing/file.py') + fd, tmp_file = tempfile.mkstemp() + tmp_fileurl = 'file://localhost/' + tmp_file.replace(os.path.sep, '/') ++ self.assertTrue(os.path.exists(tmp_file)) + try: +- self.assertTrue(os.path.exists(tmp_file)) + fp = urllib.urlopen(tmp_fileurl) ++ fp.close() + finally: + os.close(fd) +- fp.close() +- os.unlink(tmp_file) ++ os.unlink(tmp_file) + + self.assertFalse(os.path.exists(tmp_file)) + self.assertRaises(IOError, urllib.urlopen, tmp_fileurl) +@@ -812,7 +812,7 @@ + # Everywhere else they work ok, but on those machines, sometimes + # fail in one of the tests, sometimes in other. I have a linux, and + # the tests go ok. +-# If anybody has one of the problematic enviroments, please help! ++# If anybody has one of the problematic environments, please help! + # . Facundo + # + # def server(evt): +diff -r ab05e7dd2788 Lib/test/test_uuid.py +--- a/Lib/test/test_uuid.py ++++ b/Lib/test/test_uuid.py +@@ -1,5 +1,6 @@ +-from unittest import TestCase ++import unittest + from test import test_support ++import os + import uuid + + def importable(name): +@@ -9,7 +10,7 @@ + except: + return False + +-class TestUUID(TestCase): ++class TestUUID(unittest.TestCase): + last_node = None + source2node = {} + +@@ -299,24 +300,22 @@ + else: + TestUUID.last_node = node + ++ @unittest.skipUnless(os.name == 'posix', 'requires Posix') + def test_ifconfig_getnode(self): +- import sys +- import os +- if os.name == 'posix': +- node = uuid._ifconfig_getnode() +- if node is not None: +- self.check_node(node, 'ifconfig') ++ node = uuid._ifconfig_getnode() ++ if node is not None: ++ self.check_node(node, 'ifconfig') + ++ @unittest.skipUnless(os.name == 'nt', 'requires Windows') + def test_ipconfig_getnode(self): +- import os +- if os.name == 'nt': +- node = uuid._ipconfig_getnode() +- if node is not None: +- self.check_node(node, 'ipconfig') ++ node = uuid._ipconfig_getnode() ++ if node is not None: ++ self.check_node(node, 'ipconfig') + ++ @unittest.skipUnless(importable('win32wnet'), 'requires win32wnet') ++ @unittest.skipUnless(importable('netbios'), 'requires netbios') + def test_netbios_getnode(self): +- if importable('win32wnet') and importable('netbios'): +- self.check_node(uuid._netbios_getnode(), 'netbios') ++ self.check_node(uuid._netbios_getnode(), 'netbios') + + def test_random_getnode(self): + node = uuid._random_getnode() +@@ -324,22 +323,20 @@ + self.assertTrue(node & 0x010000000000) + self.assertTrue(node < (1L << 48)) + ++ @unittest.skipUnless(os.name == 'posix', 'requires Posix') ++ @unittest.skipUnless(importable('ctypes'), 'requires ctypes') + def test_unixdll_getnode(self): +- import sys +- import os +- if importable('ctypes') and os.name == 'posix': +- try: # Issues 1481, 3581: _uuid_generate_time() might be None. +- self.check_node(uuid._unixdll_getnode(), 'unixdll') +- except TypeError: +- pass ++ try: # Issues 1481, 3581: _uuid_generate_time() might be None. ++ self.check_node(uuid._unixdll_getnode(), 'unixdll') ++ except TypeError: ++ pass + ++ @unittest.skipUnless(os.name == 'nt', 'requires Windows') ++ @unittest.skipUnless(importable('ctypes'), 'requires ctypes') + def test_windll_getnode(self): +- import os +- if importable('ctypes') and os.name == 'nt': +- self.check_node(uuid._windll_getnode(), 'windll') ++ self.check_node(uuid._windll_getnode(), 'windll') + + def test_getnode(self): +- import sys + node1 = uuid.getnode() + self.check_node(node1, "getnode1") + +@@ -349,13 +346,8 @@ + + self.assertEqual(node1, node2) + ++ @unittest.skipUnless(importable('ctypes'), 'requires ctypes') + def test_uuid1(self): +- # uuid1 requires ctypes. +- try: +- import ctypes +- except ImportError: +- return +- + equal = self.assertEqual + + # Make sure uuid1() generates UUIDs that are actually version 1. +@@ -408,13 +400,8 @@ + equal(u, uuid.UUID(v)) + equal(str(u), v) + ++ @unittest.skipUnless(importable('ctypes'), 'requires ctypes') + def test_uuid4(self): +- # uuid4 requires ctypes. +- try: +- import ctypes +- except ImportError: +- return +- + equal = self.assertEqual + + # Make sure uuid4() generates UUIDs that are actually version 4. +@@ -446,12 +433,8 @@ + equal(u, uuid.UUID(v)) + equal(str(u), v) + ++ @unittest.skipUnless(os.name == 'posix', 'requires Posix') + def testIssue8621(self): +- import os +- import sys +- if os.name != 'posix': +- return +- + # On at least some versions of OSX uuid.uuid4 generates + # the same sequence of UUIDs in the parent and any + # children started using fork. +@@ -465,6 +448,7 @@ + + else: + os.close(fds[1]) ++ self.addCleanup(os.close, fds[0]) + parent_value = uuid.uuid4().hex + os.waitpid(pid, 0) + child_value = os.read(fds[0], 100) +diff -r ab05e7dd2788 Lib/test/test_wait4.py +--- a/Lib/test/test_wait4.py ++++ b/Lib/test/test_wait4.py +@@ -3,6 +3,7 @@ + + import os + import time ++import sys + from test.fork_wait import ForkWait + from test.test_support import run_unittest, reap_children, get_attribute + +@@ -13,10 +14,15 @@ + + class Wait4Test(ForkWait): + def wait_impl(self, cpid): ++ option = os.WNOHANG ++ if sys.platform.startswith('aix'): ++ # Issue #11185: wait4 is broken on AIX and will always return 0 ++ # with WNOHANG. ++ option = 0 + for i in range(10): + # wait4() shouldn't hang, but some of the buildbots seem to hang + # in the forking tests. This is an attempt to fix the problem. +- spid, status, rusage = os.wait4(cpid, os.WNOHANG) ++ spid, status, rusage = os.wait4(cpid, option) + if spid == cpid: + break + time.sleep(1.0) +diff -r ab05e7dd2788 Lib/test/test_weakset.py +--- a/Lib/test/test_weakset.py ++++ b/Lib/test/test_weakset.py +@@ -351,6 +351,12 @@ + self.assertFalse(self.s == tuple(self.items)) + self.assertFalse(self.s == 1) + ++ def test_ne(self): ++ self.assertTrue(self.s != set(self.items)) ++ s1 = WeakSet() ++ s2 = WeakSet() ++ self.assertFalse(s1 != s2) ++ + def test_weak_destroy_while_iterating(self): + # Issue #7105: iterators shouldn't crash when a key is implicitly removed + # Create new items to be sure no-one else holds a reference +diff -r ab05e7dd2788 Lib/test/test_xml_etree.py +--- a/Lib/test/test_xml_etree.py ++++ b/Lib/test/test_xml_etree.py +@@ -883,6 +883,12 @@ + >>> check_encoding("iso-8859-15") + >>> check_encoding("cp437") + >>> check_encoding("mac-roman") ++ >>> check_encoding("gbk") ++ Traceback (most recent call last): ++ ValueError: multi-byte encodings are not supported ++ >>> check_encoding("cp037") ++ Traceback (most recent call last): ++ ParseError: unknown encoding: line 1, column 30 + """ + ET.XML("" % encoding) + +@@ -1769,6 +1775,16 @@ + + """ + ++def bug_18347(): ++ """ ++ ++ >>> e = ET.XML('text') ++ >>> serialize(e) ++ 'text' ++ >>> serialize(e, method="html") ++ 'text' ++ """ ++ + # -------------------------------------------------------------------- + # reported on bugs.python.org + +diff -r ab05e7dd2788 Lib/threading.py +--- a/Lib/threading.py ++++ b/Lib/threading.py +@@ -1220,7 +1220,7 @@ + new_active = {} + current = current_thread() + with _active_limbo_lock: +- for thread in _active.itervalues(): ++ for thread in _enumerate(): + # Any lock/condition variable may be currently locked or in an + # invalid state, so we reinitialize them. + if hasattr(thread, '_reset_internal_locks'): +diff -r ab05e7dd2788 Lib/unittest/__init__.py +--- a/Lib/unittest/__init__.py ++++ b/Lib/unittest/__init__.py +@@ -11,7 +11,7 @@ + + import unittest + +- class IntegerArithmenticTestCase(unittest.TestCase): ++ class IntegerArithmeticTestCase(unittest.TestCase): + def testAdd(self): ## test method names begin 'test*' + self.assertEqual((1 + 2), 3) + self.assertEqual(0 + 1, 1) +diff -r ab05e7dd2788 Lib/unittest/loader.py +--- a/Lib/unittest/loader.py ++++ b/Lib/unittest/loader.py +@@ -106,7 +106,9 @@ + elif (isinstance(obj, types.UnboundMethodType) and + isinstance(parent, type) and + issubclass(parent, case.TestCase)): +- return self.suiteClass([parent(obj.__name__)]) ++ name = parts[-1] ++ inst = parent(name) ++ return self.suiteClass([inst]) + elif isinstance(obj, suite.TestSuite): + return obj + elif hasattr(obj, '__call__'): +diff -r ab05e7dd2788 Lib/unittest/test/test_assertions.py +--- a/Lib/unittest/test/test_assertions.py ++++ b/Lib/unittest/test/test_assertions.py +@@ -33,6 +33,10 @@ + self.assertNotAlmostEqual(1.1, 1.0, delta=0.05) + self.assertNotAlmostEqual(1.0, 1.1, delta=0.05) + ++ self.assertAlmostEqual(1.0, 1.0, delta=0.5) ++ self.assertRaises(self.failureException, self.assertNotAlmostEqual, ++ 1.0, 1.0, delta=0.5) ++ + self.assertRaises(self.failureException, self.assertAlmostEqual, + 1.1, 1.0, delta=0.05) + self.assertRaises(self.failureException, self.assertNotAlmostEqual, +diff -r ab05e7dd2788 Lib/unittest/test/test_loader.py +--- a/Lib/unittest/test/test_loader.py ++++ b/Lib/unittest/test/test_loader.py +@@ -324,7 +324,7 @@ + # Does loadTestsFromName raise TypeError when the `module` argument + # isn't a module object? + # +- # XXX Accepts the not-a-module object, ignorning the object's type ++ # XXX Accepts the not-a-module object, ignoring the object's type + # This should raise an exception or the method name should be changed + # + # XXX Some people are relying on this, so keep it for now +@@ -1281,6 +1281,21 @@ + loader = unittest.TestLoader() + self.assertTrue(loader.suiteClass is unittest.TestSuite) + ++ # Make sure the dotted name resolution works even if the actual ++ # function doesn't have the same name as is used to find it. ++ def test_loadTestsFromName__function_with_different_name_than_method(self): ++ # lambdas have the name ''. ++ m = types.ModuleType('m') ++ class MyTestCase(unittest.TestCase): ++ test = lambda: 1 ++ m.testcase_1 = MyTestCase ++ ++ loader = unittest.TestLoader() ++ suite = loader.loadTestsFromNames(['testcase_1.test'], m) ++ self.assertIsInstance(suite, loader.suiteClass) ++ ++ ref_suite = unittest.TestSuite([MyTestCase('test')]) ++ self.assertEqual(list(suite), [ref_suite]) + + if __name__ == '__main__': + unittest.main() +diff -r ab05e7dd2788 Lib/unittest/test/test_runner.py +--- a/Lib/unittest/test/test_runner.py ++++ b/Lib/unittest/test/test_runner.py +@@ -159,7 +159,7 @@ + + # This used to raise an exception due to TextTestResult not passing + # on arguments in its __init__ super call +- ATextResult(None, None, None) ++ ATextResult(None, None, 1) + + + def testBufferAndFailfast(self): +diff -r ab05e7dd2788 Lib/urllib.py +--- a/Lib/urllib.py ++++ b/Lib/urllib.py +@@ -819,7 +819,10 @@ + """Return the IP address of the current host.""" + global _thishost + if _thishost is None: +- _thishost = socket.gethostbyname(socket.gethostname()) ++ try: ++ _thishost = socket.gethostbyname(socket.gethostname()) ++ except socket.gaierror: ++ _thishost = socket.gethostbyname('localhost') + return _thishost + + _ftperrors = None +@@ -870,8 +873,8 @@ + self.ftp = ftplib.FTP() + self.ftp.connect(self.host, self.port, self.timeout) + self.ftp.login(self.user, self.passwd) +- for dir in self.dirs: +- self.ftp.cwd(dir) ++ _target = '/'.join(self.dirs) ++ self.ftp.cwd(_target) + + def retrfile(self, file, type): + import ftplib +diff -r ab05e7dd2788 Lib/uuid.py +--- a/Lib/uuid.py ++++ b/Lib/uuid.py +@@ -408,6 +408,8 @@ + _uuid_generate_random = lib.uuid_generate_random + if hasattr(lib, 'uuid_generate_time'): + _uuid_generate_time = lib.uuid_generate_time ++ if _uuid_generate_random is not None: ++ break # found everything we were looking for + + # The uuid_generate_* functions are broken on MacOS X 10.5, as noted + # in issue #8621 the function generates the same sequence of values +diff -r ab05e7dd2788 Lib/xml/etree/ElementTree.py +--- a/Lib/xml/etree/ElementTree.py ++++ b/Lib/xml/etree/ElementTree.py +@@ -988,15 +988,15 @@ + # FIXME: handle boolean attributes + write(" %s=\"%s\"" % (qnames[k], v)) + write(">") +- tag = tag.lower() ++ ltag = tag.lower() + if text: +- if tag == "script" or tag == "style": ++ if ltag == "script" or ltag == "style": + write(_encode(text, encoding)) + else: + write(_escape_cdata(text, encoding)) + for e in elem: + _serialize_html(write, e, encoding, qnames, None) +- if tag not in HTML_EMPTY: ++ if ltag not in HTML_EMPTY: + write("") + if elem.tail: + write(_escape_cdata(elem.tail, encoding)) +diff -r ab05e7dd2788 Lib/xml/sax/saxutils.py +--- a/Lib/xml/sax/saxutils.py ++++ b/Lib/xml/sax/saxutils.py +@@ -180,10 +180,14 @@ + self._write(u'' % self._qname(name)) + + def characters(self, content): +- self._write(escape(unicode(content))) ++ if not isinstance(content, unicode): ++ content = unicode(content, self._encoding) ++ self._write(escape(content)) + + def ignorableWhitespace(self, content): +- self._write(unicode(content)) ++ if not isinstance(content, unicode): ++ content = unicode(content, self._encoding) ++ self._write(content) + + def processingInstruction(self, target, data): + self._write(u'' % (target, data)) +diff -r ab05e7dd2788 Mac/BuildScript/build-installer.py +--- a/Mac/BuildScript/build-installer.py ++++ b/Mac/BuildScript/build-installer.py +@@ -108,7 +108,7 @@ + ### There are some issues with the SDK selection below here, + ### The resulting binary doesn't work on all platforms that + ### it should. Always default to the 10.4u SDK until that +-### isue is resolved. ++### issue is resolved. + ### + ##if int(os.uname()[2].split('.')[0]) == 8: + ## # Explicitly use the 10.4u (universal) SDK when +@@ -1015,7 +1015,7 @@ + os.chdir(curdir) + + if PYTHON_3: +- # Remove the 'Current' link, that way we don't accidently mess ++ # Remove the 'Current' link, that way we don't accidentally mess + # with an already installed version of python 2 + os.unlink(os.path.join(rootDir, 'Library', 'Frameworks', + 'Python.framework', 'Versions', 'Current')) +diff -r ab05e7dd2788 Mac/Makefile.in +--- a/Mac/Makefile.in ++++ b/Mac/Makefile.in +@@ -202,15 +202,22 @@ + cd IDLE && make install + + install_BuildApplet: +- $(RUNSHARED) @ARCH_RUN_32BIT@ $(BUILDPYTHON) $(srcdir)/scripts/BuildApplet.py \ +- --destroot "$(DESTDIR)" \ +- --python=$(prefix)/Resources/Python.app/Contents/MacOS/Python \ +- --output "$(DESTDIR)$(PYTHONAPPSDIR)/Build Applet.app" \ +- $(srcdir)/scripts/BuildApplet.py +-ifneq ($(LIPO_32BIT_FLAGS),) +- rm "$(DESTDIR)$(PYTHONAPPSDIR)/Build Applet.app/Contents/MacOS/Python" +- lipo $(LIPO_32BIT_FLAGS) -output "$(DESTDIR)$(PYTHONAPPSDIR)/Build Applet.app/Contents/MacOS/Python" $(BUILDPYTHON) +-endif ++ if ! $(RUNSHARED) @ARCH_RUN_32BIT@ $(BUILDPYTHON) \ ++ -c 'import EasyDialogs' 2>/dev/null ; then \ ++ echo "EasyDialogs not available in this Python - skipping Build Applet.app" ; \ ++ else \ ++ $(RUNSHARED) @ARCH_RUN_32BIT@ $(BUILDPYTHON) $(srcdir)/scripts/BuildApplet.py \ ++ --destroot "$(DESTDIR)" \ ++ --python=$(prefix)/Resources/Python.app/Contents/MacOS/Python \ ++ --output "$(DESTDIR)$(PYTHONAPPSDIR)/Build Applet.app" \ ++ $(srcdir)/scripts/BuildApplet.py && \ ++ if [ -n "$(LIPO_32BIT_FLAGS)" ] ; then \ ++ rm "$(DESTDIR)$(PYTHONAPPSDIR)/Build Applet.app/Contents/MacOS/Python" && \ ++ lipo $(LIPO_32BIT_FLAGS) \ ++ -output "$(DESTDIR)$(PYTHONAPPSDIR)/Build Applet.app/Contents/MacOS/Python" \ ++ $(BUILDPYTHON) ; \ ++ fi \ ++ fi + + MACLIBDEST=$(LIBDEST)/plat-mac + MACTOOLSDEST=$(prefix)/Mac/Tools +diff -r ab05e7dd2788 Mac/PythonLauncher/FileSettings.h +--- a/Mac/PythonLauncher/FileSettings.h ++++ b/Mac/PythonLauncher/FileSettings.h +@@ -45,18 +45,13 @@ + + (id)getFactorySettingsForFileType: (NSString *)filetype; + + (id)newSettingsForFileType: (NSString *)filetype; + +-//- (id)init; + - (id)initForFileType: (NSString *)filetype; + - (id)initForFSDefaultFileType: (NSString *)filetype; + - (id)initForDefaultFileType: (NSString *)filetype; +-//- (id)initWithFileSettings: (FileSettings *)source; + + - (void)updateFromSource: (id )source; + - (NSString *)commandLineForScript: (NSString *)script; + +-//- (void)applyFactorySettingsForFileType: (NSString *)filetype; +-//- (void)saveDefaults; +-//- (void)applyUserDefaults: (NSString *)filetype; + - (void)applyValuesFromDict: (NSDictionary *)dict; + - (void)reset; + - (NSArray *) interpreters; +diff -r ab05e7dd2788 Mac/PythonLauncher/FileSettings.m +--- a/Mac/PythonLauncher/FileSettings.m ++++ b/Mac/PythonLauncher/FileSettings.m +@@ -14,7 +14,7 @@ + { + static FileSettings *fsdefault_py, *fsdefault_pyw, *fsdefault_pyc; + FileSettings **curdefault; +- ++ + if ([filetype isEqualToString: @"Python Script"]) { + curdefault = &fsdefault_py; + } else if ([filetype isEqualToString: @"Python GUI Script"]) { +@@ -36,7 +36,7 @@ + { + static FileSettings *default_py, *default_pyw, *default_pyc; + FileSettings **curdefault; +- ++ + if ([filetype isEqualToString: @"Python Script"]) { + curdefault = &default_py; + } else if ([filetype isEqualToString: @"Python GUI Script"]) { +@@ -57,7 +57,7 @@ + + (id)newSettingsForFileType: (NSString *)filetype + { + FileSettings *cur; +- ++ + cur = [FileSettings new]; + [cur initForFileType: filetype]; + return [cur retain]; +@@ -67,7 +67,7 @@ + { + self = [super init]; + if (!self) return self; +- ++ + interpreter = [source->interpreter retain]; + honourhashbang = source->honourhashbang; + debug = source->debug; +@@ -81,36 +81,30 @@ + with_terminal = source->with_terminal; + prefskey = source->prefskey; + if (prefskey) [prefskey retain]; +- ++ + return self; + } + + - (id)initForFileType: (NSString *)filetype + { + FileSettings *defaults; +- ++ + defaults = [FileSettings getDefaultsForFileType: filetype]; + self = [self initWithFileSettings: defaults]; + origsource = [defaults retain]; + return self; + } + +-//- (id)init +-//{ +-// self = [self initForFileType: @"Python Script"]; +-// return self; +-//} +- + - (id)initForFSDefaultFileType: (NSString *)filetype + { + int i; + NSString *filename; + NSDictionary *dict; + static NSDictionary *factorySettings; +- ++ + self = [super init]; + if (!self) return self; +- ++ + if (factorySettings == NULL) { + NSBundle *bdl = [NSBundle mainBundle]; + NSString *path = [ bdl pathForResource: @"factorySettings" +@@ -149,18 +143,18 @@ + { + NSUserDefaults *defaults; + NSDictionary *dict; +- ++ + defaults = [NSUserDefaults standardUserDefaults]; + dict = [defaults dictionaryForKey: filetype]; + if (!dict) + return; + [self applyValuesFromDict: dict]; + } +- ++ + - (id)initForDefaultFileType: (NSString *)filetype + { + FileSettings *fsdefaults; +- ++ + fsdefaults = [FileSettings getFactorySettingsForFileType: filetype]; + self = [self initWithFileSettings: fsdefaults]; + if (!self) return self; +@@ -220,7 +214,7 @@ + - (void)applyValuesFromDict: (NSDictionary *)dict + { + id value; +- ++ + value = [dict objectForKey: @"interpreter"]; + if (value) interpreter = [value retain]; + value = [dict objectForKey: @"honourhashbang"]; +@@ -247,12 +241,12 @@ + + - (NSString*)_replaceSingleQuotes: (NSString*)string + { +- /* Replace all single-quotes by '"'"', that way shellquoting will +- * be correct when the result value is delimited using single quotes. +- */ +- NSArray* components = [string componentsSeparatedByString:@"'"]; ++ /* Replace all single-quotes by '"'"', that way shellquoting will ++ * be correct when the result value is delimited using single quotes. ++ */ ++ NSArray* components = [string componentsSeparatedByString:@"'"]; + +- return [components componentsJoinedByString:@"'\"'\"'"]; ++ return [components componentsJoinedByString:@"'\"'\"'"]; + } + + - (NSString *)commandLineForScript: (NSString *)script +@@ -265,7 +259,7 @@ + + script_dir = [script substringToIndex: + [script length]-[[script lastPathComponent] length]]; +- ++ + if (honourhashbang && + (fp=fopen([script fileSystemRepresentation], "r")) && + fgets(hashbangbuf, sizeof(hashbangbuf), fp) && +@@ -278,7 +272,7 @@ + } + if (!cur_interp) + cur_interp = interpreter; +- ++ + return [NSString stringWithFormat: + @"cd '%@' && '%@'%s%s%s%s%s%s %@ '%@' %@ %s", + [self _replaceSingleQuotes:script_dir], +@@ -297,7 +291,7 @@ + + - (NSArray *) interpreters { return interpreters;}; + +-// FileSettingsSource protocol ++// FileSettingsSource protocol + - (NSString *) interpreter { return interpreter;}; + - (BOOL) honourhashbang { return honourhashbang; }; + - (BOOL) debug { return debug;}; +diff -r ab05e7dd2788 Mac/PythonLauncher/MyAppDelegate.m +--- a/Mac/PythonLauncher/MyAppDelegate.m ++++ b/Mac/PythonLauncher/MyAppDelegate.m +@@ -33,7 +33,7 @@ + + - (BOOL)shouldShowUI + { +- // if this call comes before applicationDidFinishLaunching: we ++ // if this call comes before applicationDidFinishLaunching: we + // should terminate immedeately after starting the script. + if (!initial_action_done) + should_terminate = YES; +@@ -62,7 +62,7 @@ + static NSString *extensions[] = { @"py", @"pyw", @"pyc", NULL}; + NSString **ext_p; + int i; +- ++ + if ([[NSUserDefaults standardUserDefaults] boolForKey: @"SkipFileBindingTest"]) + return; + ourUrl = [NSURL fileURLWithPath: [[NSBundle mainBundle] bundlePath]]; +@@ -92,5 +92,5 @@ + } + } + } +- ++ + @end +diff -r ab05e7dd2788 Mac/PythonLauncher/MyDocument.m +--- a/Mac/PythonLauncher/MyDocument.m ++++ b/Mac/PythonLauncher/MyDocument.m +@@ -16,7 +16,7 @@ + { + self = [super init]; + if (self) { +- ++ + // Add your subclass-specific initialization here. + // If an error occurs here, send a [self dealloc] message and return nil. + script = [@".py" retain]; +@@ -37,20 +37,17 @@ + { + NSApplication *app = [NSApplication sharedApplication]; + [super close]; +- if ([[app delegate] shouldTerminate]) ++ if ([(MyAppDelegate*)[app delegate] shouldTerminate]) + [app terminate: self]; + } + + - (void)load_defaults + { +-// if (settings) [settings release]; + settings = [FileSettings newSettingsForFileType: filetype]; + } + + - (void)update_display + { +-// [[self window] setTitle: script]; +- + [interpreter setStringValue: [settings interpreter]]; + [honourhashbang setState: [settings honourhashbang]]; + [debug setState: [settings debug]]; +@@ -62,7 +59,7 @@ + [others setStringValue: [settings others]]; + [scriptargs setStringValue: [settings scriptargs]]; + [with_terminal setState: [settings with_terminal]]; +- ++ + [commandline setStringValue: [settings commandLineForScript: script]]; + } + +@@ -75,8 +72,8 @@ + { + const char *cmdline; + int sts; +- +- cmdline = [[settings commandLineForScript: script] cString]; ++ ++ cmdline = [[settings commandLineForScript: script] UTF8String]; + if ([settings with_terminal]) { + sts = doscript(cmdline); + } else { +@@ -107,14 +104,13 @@ + { + // Insert code here to read your document from the given data. You can also choose to override -loadFileWrapperRepresentation:ofType: or -readFromFile:ofType: instead. + BOOL show_ui; +- +- // ask the app delegate whether we should show the UI or not. +- show_ui = [[[NSApplication sharedApplication] delegate] shouldShowUI]; ++ ++ // ask the app delegate whether we should show the UI or not. ++ show_ui = [(MyAppDelegate*)[[NSApplication sharedApplication] delegate] shouldShowUI]; + [script release]; + script = [fileName retain]; + [filetype release]; + filetype = [type retain]; +-// if (settings) [settings release]; + settings = [FileSettings newSettingsForFileType: filetype]; + if (show_ui) { + [self update_display]; +@@ -152,7 +148,7 @@ + [self update_display]; + } + +-// FileSettingsSource protocol ++// FileSettingsSource protocol + - (NSString *) interpreter { return [interpreter stringValue];}; + - (BOOL) honourhashbang { return [honourhashbang state];}; + - (BOOL) debug { return [debug state];}; +diff -r ab05e7dd2788 Mac/PythonLauncher/PreferencesWindowController.m +--- a/Mac/PythonLauncher/PreferencesWindowController.m ++++ b/Mac/PythonLauncher/PreferencesWindowController.m +@@ -5,7 +5,7 @@ + + getPreferencesWindow + { + static PreferencesWindowController *_singleton; +- ++ + if (!_singleton) + _singleton = [[PreferencesWindowController alloc] init]; + [_singleton showWindow: _singleton]; +@@ -21,15 +21,13 @@ + - (void)load_defaults + { + NSString *title = [filetype titleOfSelectedItem]; +- ++ + settings = [FileSettings getDefaultsForFileType: title]; + } + + - (void)update_display + { +-// [[self window] setTitle: script]; +- +- [interpreter reloadData]; ++ [interpreter reloadData]; + [interpreter setStringValue: [settings interpreter]]; + [honourhashbang setState: [settings honourhashbang]]; + [debug setState: [settings debug]]; +@@ -41,7 +39,6 @@ + [others setStringValue: [settings others]]; + [with_terminal setState: [settings with_terminal]]; + // Not scriptargs, it isn't for preferences +- + [commandline setStringValue: [settings commandLineForScript: @""]]; + } + +@@ -75,7 +72,7 @@ + [self update_display]; + } + +-// FileSettingsSource protocol ++// FileSettingsSource protocol + - (NSString *) interpreter { return [interpreter stringValue];}; + - (BOOL) honourhashbang { return [honourhashbang state]; }; + - (BOOL) debug { return [debug state];}; +@@ -98,23 +95,23 @@ + // NSComboBoxDataSource protocol + - (unsigned int)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)aString + { +- NSArray *interp_list = [settings interpreters]; ++ NSArray *interp_list = [settings interpreters]; + unsigned int rv = [interp_list indexOfObjectIdenticalTo: aString]; +- return rv; ++ return rv; + } + + - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index + { +- NSArray *interp_list = [settings interpreters]; ++ NSArray *interp_list = [settings interpreters]; + id rv = [interp_list objectAtIndex: index]; +- return rv; ++ return rv; + } + + - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox + { +- NSArray *interp_list = [settings interpreters]; ++ NSArray *interp_list = [settings interpreters]; + int rv = [interp_list count]; +- return rv; ++ return rv; + } + + +diff -r ab05e7dd2788 Mac/PythonLauncher/doscript.h +--- a/Mac/PythonLauncher/doscript.h ++++ b/Mac/PythonLauncher/doscript.h +@@ -9,4 +9,4 @@ + + #include + +-extern int doscript(const char *command); +\ No newline at end of file ++extern int doscript(const char *command); +diff -r ab05e7dd2788 Mac/PythonLauncher/doscript.m +--- a/Mac/PythonLauncher/doscript.m ++++ b/Mac/PythonLauncher/doscript.m +@@ -11,49 +11,49 @@ + #import + #import "doscript.h" + +-extern int ++extern int + doscript(const char *command) + { +- char *bundleID = "com.apple.Terminal"; +- AppleEvent evt, res; +- AEDesc desc; +- OSStatus err; ++ char *bundleID = "com.apple.Terminal"; ++ AppleEvent evt, res; ++ AEDesc desc; ++ OSStatus err; + +- [[NSWorkspace sharedWorkspace] launchApplication:@"/Applications/Utilities/Terminal.app/"]; ++ [[NSWorkspace sharedWorkspace] launchApplication:@"/Applications/Utilities/Terminal.app/"]; + +- // Build event +- err = AEBuildAppleEvent(kAECoreSuite, kAEDoScript, +- typeApplicationBundleID, +- bundleID, strlen(bundleID), +- kAutoGenerateReturnID, +- kAnyTransactionID, +- &evt, NULL, +- "'----':utf8(@)", strlen(command), +- command); +- if (err) { +- NSLog(@"AEBuildAppleEvent failed: %d\n", err); +- return err; +- } ++ // Build event ++ err = AEBuildAppleEvent(kAECoreSuite, kAEDoScript, ++ typeApplicationBundleID, ++ bundleID, strlen(bundleID), ++ kAutoGenerateReturnID, ++ kAnyTransactionID, ++ &evt, NULL, ++ "'----':utf8(@)", strlen(command), ++ command); ++ if (err) { ++ NSLog(@"AEBuildAppleEvent failed: %ld\n", (long)err); ++ return err; ++ } + +- // Send event and check for any Apple Event Manager errors +- err = AESendMessage(&evt, &res, kAEWaitReply, kAEDefaultTimeout); +- AEDisposeDesc(&evt); +- if (err) { +- NSLog(@"AESendMessage failed: %d\n", err); +- return err; +- } +- // Check for any application errors +- err = AEGetParamDesc(&res, keyErrorNumber, typeSInt32, &desc); +- AEDisposeDesc(&res); +- if (!err) { +- AEGetDescData(&desc, &err, sizeof(err)); +- NSLog(@"Terminal returned an error: %d", err); +- AEDisposeDesc(&desc); +- } else if (err == errAEDescNotFound) { +- err = noErr; +- } else { +- NSLog(@"AEGetPArmDesc returned an error: %d", err); +- } ++ // Send event and check for any Apple Event Manager errors ++ err = AESendMessage(&evt, &res, kAEWaitReply, kAEDefaultTimeout); ++ AEDisposeDesc(&evt); ++ if (err) { ++ NSLog(@"AESendMessage failed: %ld\n", (long)err); ++ return err; ++ } ++ // Check for any application errors ++ err = AEGetParamDesc(&res, keyErrorNumber, typeSInt32, &desc); ++ AEDisposeDesc(&res); ++ if (!err) { ++ AEGetDescData(&desc, &err, sizeof(err)); ++ NSLog(@"Terminal returned an error: %ld", (long)err); ++ AEDisposeDesc(&desc); ++ } else if (err == errAEDescNotFound) { ++ err = noErr; ++ } else { ++ NSLog(@"AEGetPArmDesc returned an error: %ld", (long)err); ++ } + +- return err; ++ return err; + } +diff -r ab05e7dd2788 Mac/PythonLauncher/main.m +--- a/Mac/PythonLauncher/main.m ++++ b/Mac/PythonLauncher/main.m +@@ -11,7 +11,7 @@ + + int main(int argc, const char *argv[]) + { +- char *home = getenv("HOME"); +- if (home) chdir(home); ++ char *home = getenv("HOME"); ++ if (home) chdir(home); + return NSApplicationMain(argc, argv); + } +diff -r ab05e7dd2788 Mac/README +--- a/Mac/README ++++ b/Mac/README +@@ -209,9 +209,11 @@ + through PythonLauncher's preferences dialog. + + "BuildApplet.app" creates an applet from a Python script. Drop the script on it +-and out comes a full-featured MacOS application. There is much more to this, +-to be supplied later. Some useful (but outdated) info can be found in +-Mac/Demo. ++and out comes a full-featured MacOS application. BuildApplet.app is now ++deprecated and has been removed in Python 3. As of OS X 10.8, Xcode 4 no ++longer supplies the headers for the deprecated QuickDraw APIs used by ++the EasyDialogs module making BuildApplet unusable as an app. It will ++not be built by the Mac/Makefile in this case. + + The commandline scripts /usr/local/bin/python and pythonw can be used to run + non-GUI and GUI python scripts from the command line, respectively. +diff -r ab05e7dd2788 Makefile.pre.in +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -1295,11 +1295,11 @@ + Modules/ld_so_aix Modules/python.exp Misc/python.pc + -rm -f python*-gdb.py + -rm -f pybuilddir.txt +- find $(srcdir) '(' -name '*.fdc' -o -name '*~' \ +- -o -name '[@,#]*' -o -name '*.old' \ +- -o -name '*.orig' -o -name '*.rej' \ +- -o -name '*.bak' ')' \ +- -exec rm -f {} ';' ++ find $(srcdir)/[a-zA-Z]* '(' -name '*.fdc' -o -name '*~' \ ++ -o -name '[@,#]*' -o -name '*.old' \ ++ -o -name '*.orig' -o -name '*.rej' \ ++ -o -name '*.bak' ')' \ ++ -exec rm -f {} ';' + + # Check for smelly exported symbols (not starting with Py/_Py) + smelly: all +diff -r ab05e7dd2788 Misc/ACKS +--- a/Misc/ACKS ++++ b/Misc/ACKS +@@ -110,6 +110,7 @@ + Matthew Boedicker + Robin Boerdijk + David Bolen ++Wouter Bolsterlee + Gawain Bolton + Gregory Bond + Jurjen Bos +@@ -124,6 +125,7 @@ + Georg Brandl + Christopher Brannon + Terrence Brannon ++Erik Bray + Brian Brazil + Dave Brennan + Tom Bridgman +@@ -170,6 +172,7 @@ + Mitch Chapman + Greg Chapman + Brad Chapman ++Yogesh Chaudhari + David Chaum + Nicolas Chauvat + Michael Chermside +@@ -229,6 +232,7 @@ + Ben Darnell + Kushal Das + Jonathan Dasteel ++A. Jesse Jiryu Davis + John DeGood + Ned Deily + Vincent Delft +@@ -270,6 +274,7 @@ + Maxim Dzumanenko + Walter Dörwald + Hans Eckardt ++David Edelsohn + Grant Edwards + John Ehresman + Eric Eisner +@@ -309,6 +314,7 @@ + Frederik Fix + Matt Fleming + Hernán Martínez Foffani ++Artem Fokin + Arnaud Fontaine + Michael Foord + Amaury Forgeot d'Arc +@@ -316,6 +322,7 @@ + John Fouhy + Stefan Franke + Martin Franklin ++Bruce Frederiksen + Robin Friedrich + Bradley Froehle + Ivan Frohne +@@ -478,6 +485,7 @@ + Jack Jansen + Bill Janssen + Thomas Jarosch ++Rajagopalasarma Jayakrishnan + Drew Jenkins + Flemming Kjær Jensen + Philip H. Jensen +@@ -501,6 +509,7 @@ + Sijin Joseph + Andreas Jung + Tattoo Mabonzo K. ++Sarah K. + Bohuslav Kabrda + Bob Kahn + Kurt B. Kaiser +@@ -542,6 +551,7 @@ + Greg Kochanski + Damon Kohler + Marko Kohtala ++Vajrasky Kok + Guido Kollerie + Peter A. Koren + Joseph Koshy +@@ -594,6 +604,7 @@ + Luke Kenneth Casson Leighton + Tshepang Lekhonkhobe + Marc-André Lemburg ++Mateusz Lenik + John Lenton + Kostyantyn Leschenko + Christopher Tur Lesniewski-Laas +@@ -623,6 +634,7 @@ + Lukas Lueg + Loren Luke + Fredrik Lundh ++Zhongyue Luo + Mark Lutz + Jim Lynch + Mikael Lyngvig +@@ -739,6 +751,7 @@ + Kevin O'Connor + Tim O'Malley + Zooko O'Whielacronx ++Elena Oat + Pascal Oberndoerfer + Jeffrey Ollie + Adam Olsen +@@ -903,6 +916,7 @@ + Arvin Schnell + Scott Schram + Chad J. Schroeder ++Christian Schubert + Sam Schulenburg + Stefan Schwarzer + Dietmar Schwertberger +@@ -924,6 +938,7 @@ + Ha Shao + Mark Shannon + Richard Shapiro ++Vlad Shcherbina + Justin Sheehy + Charlie Shepherd + Bruce Sherwood +@@ -934,6 +949,7 @@ + Joel Shprentz + Itamar Shtull-Trauring + Yue Shuaijie ++Terrel Shumway + Eric Siegerman + Paul Sijben + Tim Silk +@@ -941,6 +957,7 @@ + Ionel Simionescu + Kirill Simonov + Nathan Paul Simons ++Guilherme Simões + Ravi Sinha + Janne Sinkkonen + Ng Pheng Siong +@@ -955,6 +972,7 @@ + Rafal Smotrzyk + Dirk Soede + Paul Sokolovsky ++Evgeny Sologubov + Cody Somerville + Clay Spence + Stefan Sperling +@@ -1005,6 +1023,7 @@ + Victor Terrón + Richard M. Tew + Tobias Thelen ++Févry Thibault + Lowe Thiderman + Nicolas M. Thiéry + James Thomas +@@ -1033,6 +1052,7 @@ + Stephen Turner + Theodore Turocy + Bill Tutt ++Fraser Tweedale + Doobee R. Tzeck + Eren Türkay + Lionel Ulmer +@@ -1045,6 +1065,7 @@ + Kyle VanderBeek + Atul Varma + Dmitry Vasiliev ++Sebastian Ortiz Vasquez + Alexandre Vassalotti + Frank Vercruesse + Mike Verdone +@@ -1058,6 +1079,7 @@ + Norman Vine + Frank Visser + Johannes Vogel ++Alex Volkov + Martijn Vries + Niki W. Waibel + Wojtek Walczak +@@ -1075,6 +1097,7 @@ + Henrik Weber + Corran Webster + Glyn Webster ++Phil Webster + Stefan Wehr + Zack Weinberg + Bob Weiner +@@ -1136,6 +1159,7 @@ + Milan Zamazal + Artur Zaprzala + Mike Zarnstorff ++Yury V. Zaytsev + Siebren van der Zee + Nickolai Zeldovich + Uwe Zessin +diff -r ab05e7dd2788 Misc/NEWS +--- a/Misc/NEWS ++++ b/Misc/NEWS +@@ -1,6 +1,282 @@ + Python News + +++++++++++ + ++What's New in Python 2.7.6? ++=========================== ++ ++*Release date: XXXX-XX-XX* ++ ++Core and Builtins ++----------------- ++ ++- Issue #13461: Fix a crash in the "replace" error handler on 64-bit platforms. ++ Patch by Yogesh Chaudhari. ++ ++- Issue #15866: The xmlcharrefreplace error handler no more produces two XML ++ entities for a non-BMP character on narrow build. ++ ++- Issue #18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise ++ OverflowError when an argument of %c format is out of range. ++ ++- Issue #18137: Detect integer overflow on precision in float.__format__() ++ and complex.__format__(). ++ ++- Issue #18038: SyntaxError raised during compilation sources with illegal ++ encoding now always contains an encoding name. ++ ++- Issue #18019: Fix crash in the repr of dictionaries containing their own ++ views. ++ ++- Issue #18427: str.replace could crash the interpreter with huge strings. ++ ++Library ++------- ++ ++- Issue #14984: On POSIX systems, when netrc is called without a filename ++ argument (and therefore is reading the user's $HOME/.netrc file), it now ++ enforces the same security rules as typical ftp clients: the .netrc file must ++ be owned by the user that owns the process and must not be readable by any ++ other user. ++ ++- Issue #17324: Fix http.server's request handling case on trailing '/'. Patch ++ contributed by Vajrasky Kok. ++ ++- Issue #19018: The heapq.merge() function no longer suppresses IndexError ++ in the underlying iterables. ++ ++- Issue #18784: The uuid module no more attempts to load libc via ctypes.CDLL, ++ if all necessary functions are already found in libuuid. ++ Patch by Evgeny Sologubov. ++ ++- Issue #14971: unittest test discovery no longer gets confused when a function ++ has a different __name__ than its name in the TestCase class dictionary. ++ ++- Issue #18672: Fixed format specifiers for Py_ssize_t in debugging output in ++ the _sre module. ++ ++- Issue #18830: inspect.getclasstree() no more produces duplicated entries even ++ when input list contains duplicates. ++ ++- Issue #18909: Fix _tkinter.tkapp.interpaddr() on Windows 64-bit, don't cast ++ 64-bit pointer to long (32 bits). ++ ++- Issue #18876: The FileIO.mode attribute now better reflects the actual mode ++ under which the file was opened. Patch by Erik Bray. ++ ++- Issue #18851: Avoid a double close of subprocess pipes when the child ++ process fails starting. ++ ++- Issue #18418: After fork(), reinit all threads states, not only active ones. ++ Patch by A. Jesse Jiryu Davis. ++ ++- Issue #11973: Fix a problem in kevent. The flags and fflags fields are now ++ properly handled as unsigned. ++ ++- Issue #16809: Fixed some tkinter incompabilities with Tcl/Tk 8.6. ++ ++- Issue #16809: Tkinter's splitlist() and split() methods now accept Tcl_Obj ++ argument. ++ ++- Issue #17119: Fixed integer overflows when processing large Unicode strings ++ and tuples in the tkinter module. ++ ++- Issue #15233: Python now guarantees that callables registered with the atexit ++ module will be called in a deterministic order. ++ ++- Issue #18747: Re-seed OpenSSL's pseudo-random number generator after fork. ++ A pthread_atfork() parent handler is used to seed the PRNG with pid, time ++ and some stack data. ++ ++- Issue #8865: Concurrent invocation of select.poll.poll() now raises a ++ RuntimeError exception. Patch by Christian Schubert. ++ ++- Issue #13461: Fix a crash in the TextIOWrapper.tell method on 64-bit ++ platforms. Patch by Yogesh Chaudhari. ++ ++- Issue #18777: The ssl module now uses the new CRYPTO_THREADID API of ++ OpenSSL 1.0.0+ instead of the deprecated CRYPTO id callback function. ++ ++- Issue #18768: Correct doc string of RAND_edg(). Patch by Vajrasky Kok. ++ ++- Issue #18178: Fix ctypes on BSD. dlmalloc.c was compiled twice which broke ++ malloc weak symbols. ++ ++- Issue #18709: Fix CVE-2013-4238. The SSL module now handles NULL bytes ++ inside subjectAltName correctly. Formerly the module has used OpenSSL's ++ GENERAL_NAME_print() function to get the string represention of ASN.1 ++ strings for ``rfc822Name`` (email), ``dNSName`` (DNS) and ++ ``uniformResourceIdentifier`` (URI). ++ ++- Issue #18756: Improve error reporting in os.urandom() when the failure ++ is due to something else than /dev/urandom not existing (for example, ++ exhausting the file descriptor limit). ++ ++- Fix tkinter regression introduced by the security fix in issue #16248. ++ ++- Issue #18676: Change 'positive' to 'non-negative' in queue.py put and get ++ docstrings and ValueError messages. Patch by Zhongyue Luo ++ ++- Issue #17998: Fix an internal error in regular expression engine. ++ ++- Issue #17557: Fix os.getgroups() to work with the modified behavior of ++ getgroups(2) on OS X 10.8. Original patch by Mateusz Lenik. ++ ++- Issue #18455: multiprocessing should not retry connect() with same socket. ++ ++- Issue #18513: Fix behaviour of cmath.rect w.r.t. signed zeros on OS X 10.8 + ++ gcc. ++ ++- Issue #18101: Tcl.split() now process Unicode strings nested in a tuple as it ++ do with byte strings. ++ ++- Issue #18347: ElementTree's html serializer now preserves the case of ++ closing tags. ++ ++- Issue #17261: Ensure multiprocessing's proxies use proper address. ++ ++- Issue #17097: Make multiprocessing ignore EINTR. ++ ++- Issue #18155: The csv module now correctly handles csv files that use ++ a delimiter character that has a special meaning in regexes, instead of ++ throwing an exception. ++ ++- Issue #18135: ssl.SSLSocket.write() now raises an OverflowError if the input ++ string in longer than 2 gigabytes. The ssl module does not support partial ++ write. ++ ++- Issue #18167: cgi.FieldStorage no longer fails to handle multipart/form-data ++ when \r\n appears at end of 65535 bytes without other newlines. ++ ++- Issue #17403: urllib.parse.robotparser normalizes the urls before adding to ++ ruleline. This helps in handling certain types invalid urls in a conservative ++ manner. Patch contributed by Mher Movsisyan. ++ ++- Implement inequality on weakref.WeakSet. ++ ++- Issue #17981: Closed socket on error in SysLogHandler. ++ ++- Issue #18015: Fix unpickling of 2.7.3 and 2.7.4 namedtuples. ++ ++- Issue #17754: Make ctypes.util.find_library() independent of the locale. ++ ++- Fix typos in the multiprocessing module. ++ ++- Issue #17269: Workaround for socket.getaddrinfo crash on MacOS X ++ with port None or "0" and flags AI_NUMERICSERV. ++ ++- Issue #18080: When building a C extension module on OS X, if the compiler ++ is overriden with the CC environment variable, use the new compiler as ++ the default for linking if LDSHARED is not also overriden. This restores ++ Distutils behavior introduced in 2.7.3 and inadvertently dropped in 2.7.4. ++ ++- Issue #18071: C extension module builds on OS X could fail with TypeError ++ if the Xcode command line tools were not installed. ++ ++- Issue #18113: Fixed a refcount leak in the curses.panel module's ++ set_userptr() method. Reported by Atsuo Ishimoto. ++ ++- Issue #18849: Fixed a Windows-specific tempfile bug where collision with an ++ existing directory caused mkstemp and related APIs to fail instead of ++ retrying. Report and fix by Vlad Shcherbina. ++ ++ ++Tools/Demos ++----------- ++ ++- Issue #18873: 2to3 and the findnocoding.py script now detect Python source ++ code encoding only in comment lines. ++ ++- Issue #18817: Fix a resource warning in Lib/aifc.py demo. ++ ++- Issue #18439: Make patchcheck work on Windows for ACKS, NEWS. ++ ++- Issue #18448: Fix a typo in Demo/newmetaclasses/Eiffel.py. ++ ++- Issue #12990: The "Python Launcher" on OSX could not launch python scripts ++ that have paths that include wide characters. ++ ++Build ++----- ++ ++- Issue #16067: Add description into MSI file to replace installer's temporary name. ++ ++- Issue #18256: Compilation fix for recent AIX releases. Patch by ++ David Edelsohn. ++ ++- Issue #18098: The deprecated OS X Build Applet.app fails to build on ++ OS X 10.8 systems because the Apple-deprecated QuickDraw headers have ++ been removed from Xcode 4. Skip building it in this case. ++ ++IDLE ++---- ++ ++- Issue #18873: IDLE now detects Python source code encoding only in comment ++ lines. ++ ++- Issue #18988: The "Tab" key now works when a word is already autocompleted. ++ ++- Issue #18489: Add tests for SearchEngine. Original patch by Phil Webster. ++ ++- Issue #18429: Format / Format Paragraph, now works when comment blocks ++ are selected. As with text blocks, this works best when the selection ++ only includes complete lines. ++ ++- Issue #18226: Add docstrings and unittests for FormatParagraph.py. ++ Original patches by Todd Rovito and Phil Webster. ++ ++- Issue #18279: Format - Strip trailing whitespace no longer marks a file as ++ changed when it has not been changed. This fix followed the addition of a ++ test file originally written by Phil Webster (the issue's main goal). ++ ++- Issue #18539: Calltips now work for float default arguments. ++ ++- Issue #7136: In the Idle File menu, "New Window" is renamed "New File". ++ Patch by Tal Einat, Roget Serwy, and Todd Rovito. ++ ++- Issue #8515: Set __file__ when run file in IDLE. ++ Initial patch by Bruce Frederiksen. ++ ++- Issue #5492: Avoid traceback when exiting IDLE caused by a race condition. ++ ++- Issue #17511: Keep IDLE find dialog open after clicking "Find Next". ++ Original patch by Sarah K. ++ ++- Issue #15392: Create a unittest framework for IDLE. ++ Preliminary patch by Rajagopalasarma Jayakrishnan ++ See Lib/idlelib/idle_test/README.txt for how to run Idle tests. ++ ++- Issue #14146: Highlight source line while debugging on Windows. ++ ++- Issue #17532: Always include Options menu for IDLE on OS X. ++ Patch by Guilherme Simões. ++ ++Tests ++----- ++ ++- Issue #18792: Use "127.0.0.1" or "::1" instead of "localhost" as much as ++ possible, since "localhost" goes through a DNS lookup under recent Windows ++ versions. ++ ++- Issue #18357: add tests for dictview set difference. ++ Patch by Fraser Tweedale. ++ ++- Issue #11185: Fix test_wait4 under AIX. Patch by Sébastien Sablé. ++ ++- Issue #18094: test_uuid no more reports skipped tests as passed. ++ ++- Issue #11995: test_pydoc doesn't import all sys.path modules anymore. ++ ++Documentation ++------------- ++ ++- Issue #18718: datetime documentation contradictory on leap second support. ++ ++- Issue #17701: Improving strftime documentation. ++ ++- Issue #17844: Refactor a documentation of Python specific encodings. ++ Add links to encoders and decoders for binary-to-binary codecs. ++ ++ + What's New in Python 2.7.5? + =========================== + +@@ -9,7 +285,7 @@ + Core and Builtins + ----------------- + +-- Issue #15535: Fixed regression in the pickling of named tuples by ++- Issue #15535: Fixed regression in the pickling of named tuples by + removing the __dict__ property introduced in 2.7.4. + + - Issue #17857: Prevent build failures with pre-3.5.0 versions of sqlite3, +@@ -26,6 +302,12 @@ + Library + ------- + ++- Issue #17979: Fixed the re module in build with --disable-unicode. ++ ++- Issue #17606: Fixed support of encoded byte strings in the XMLGenerator ++ .characters() and ignorableWhitespace() methods. Original patch by Sebastian ++ Ortiz Vasquez. ++ + - Issue #16601: Restarting iteration over tarfile no more continues from where + it left off. Patch by Michael Birtwell. + +@@ -3251,7 +3533,7 @@ + - Issue #1285086: Speed up ``urllib.quote()`` and urllib.unquote for simple + cases. + +-- Issue #8688: Distutils now recalculates MANIFEST everytime. ++- Issue #8688: Distutils now recalculates MANIFEST every time. + + - Issue #5099: The ``__del__()`` method of ``subprocess.Popen`` (and the methods + it calls) referenced global objects, causing errors to pop up during +@@ -6107,7 +6389,7 @@ + - Issue #3547: Fixed ctypes structures bitfields of varying integer + sizes. + +-- Issue #3879: A regression in urllib.getproxies_enviroment was fixed. ++- Issue #3879: A regression in urllib.getproxies_environment was fixed. + + - Issue #3863: Disabled a unit test of fork being called from a thread + when running on platforms known to exhibit OS bugs when attempting that. +diff -r ab05e7dd2788 Modules/_collectionsmodule.c +--- a/Modules/_collectionsmodule.c ++++ b/Modules/_collectionsmodule.c +@@ -8,9 +8,13 @@ + */ + + /* The block length may be set to any number over 1. Larger numbers +- * reduce the number of calls to the memory allocator but take more +- * memory. Ideally, BLOCKLEN should be set with an eye to the +- * length of a cache line. ++ * reduce the number of calls to the memory allocator, give faster ++ * indexing and rotation, and reduce the link::data overhead ratio. ++ * ++ * Ideally, the block length will be set to two less than some ++ * multiple of the cache-line length (so that the full block ++ * including the leftlink and rightlink will fit neatly into ++ * cache lines). + */ + + #define BLOCKLEN 62 +@@ -46,9 +50,9 @@ + */ + + typedef struct BLOCK { ++ PyObject *data[BLOCKLEN]; ++ struct BLOCK *rightlink; + struct BLOCK *leftlink; +- struct BLOCK *rightlink; +- PyObject *data[BLOCKLEN]; + } block; + + #define MAXFREEBLOCKS 10 +@@ -58,13 +62,8 @@ + static block * + newblock(block *leftlink, block *rightlink, Py_ssize_t len) { + block *b; +- /* To prevent len from overflowing PY_SSIZE_T_MAX on 64-bit machines, we +- * refuse to allocate new blocks if the current len is dangerously +- * close. There is some extra margin to prevent spurious arithmetic +- * overflows at various places. The following check ensures that +- * the blocks allocated to the deque, in the worst case, can only +- * have PY_SSIZE_T_MAX-2 entries in total. +- */ ++ /* To prevent len from overflowing PY_SSIZE_T_MAX on 32-bit machines, we ++ * refuse to allocate new blocks if the current len is nearing overflow. */ + if (len >= PY_SSIZE_T_MAX - 2*BLOCKLEN) { + PyErr_SetString(PyExc_OverflowError, + "cannot add more blocks to the deque"); +@@ -103,8 +102,8 @@ + Py_ssize_t leftindex; /* in range(BLOCKLEN) */ + Py_ssize_t rightindex; /* in range(BLOCKLEN) */ + Py_ssize_t len; ++ long state; /* incremented whenever the indices move */ + Py_ssize_t maxlen; +- long state; /* incremented whenever the indices move */ + PyObject *weakreflist; /* List of weak references */ + } dequeobject; + +diff -r ab05e7dd2788 Modules/_ctypes/callproc.c +--- a/Modules/_ctypes/callproc.c ++++ b/Modules/_ctypes/callproc.c +@@ -75,6 +75,10 @@ + + #include + #include "ctypes.h" ++#ifdef HAVE_ALLOCA_H ++/* AIX needs alloca.h for alloca() */ ++#include ++#endif + + #if defined(_DEBUG) || defined(__MINGW32__) + /* Don't use structured exception handling on Windows if this is defined. +diff -r ab05e7dd2788 Modules/_ctypes/libffi/fficonfig.py.in +--- a/Modules/_ctypes/libffi/fficonfig.py.in ++++ b/Modules/_ctypes/libffi/fficonfig.py.in +@@ -1,7 +1,6 @@ + ffi_sources = """ + src/prep_cif.c + src/closures.c +-src/dlmalloc.c + """.split() + + ffi_platforms = { +diff -r ab05e7dd2788 Modules/_curses_panel.c +--- a/Modules/_curses_panel.c ++++ b/Modules/_curses_panel.c +@@ -293,9 +293,18 @@ + static PyObject * + PyCursesPanel_set_panel_userptr(PyCursesPanelObject *self, PyObject *obj) + { ++ PyObject *oldobj; ++ int rc; ++ PyCursesInitialised; + Py_INCREF(obj); +- return PyCursesCheckERR(set_panel_userptr(self->pan, (void*)obj), +- "set_panel_userptr"); ++ oldobj = (PyObject *) panel_userptr(self->pan); ++ rc = set_panel_userptr(self->pan, (void*)obj); ++ if (rc == ERR) { ++ /* In case of an ncurses error, decref the new object again */ ++ Py_DECREF(obj); ++ } ++ Py_XDECREF(oldobj); ++ return PyCursesCheckERR(rc, "set_panel_userptr"); + } + + static PyObject * +diff -r ab05e7dd2788 Modules/_elementtree.c +--- a/Modules/_elementtree.c ++++ b/Modules/_elementtree.c +@@ -2427,6 +2427,8 @@ + + if (PyUnicode_GET_SIZE(u) != 256) { + Py_DECREF(u); ++ PyErr_SetString(PyExc_ValueError, ++ "multi-byte encodings are not supported"); + return XML_STATUS_ERROR; + } + +diff -r ab05e7dd2788 Modules/_io/fileio.c +--- a/Modules/_io/fileio.c ++++ b/Modules/_io/fileio.c +@@ -47,6 +47,7 @@ + int fd; + unsigned int readable : 1; + unsigned int writable : 1; ++ unsigned int appending : 1; + signed int seekable : 2; /* -1 means unknown */ + unsigned int closefd : 1; + PyObject *weakreflist; +@@ -124,6 +125,7 @@ + self->fd = -1; + self->readable = 0; + self->writable = 0; ++ self->appending = 0; + self->seekable = -1; + self->closefd = 1; + self->weakreflist = NULL; +@@ -184,7 +186,7 @@ + Py_UNICODE *widename = NULL; + #endif + int ret = 0; +- int rwa = 0, plus = 0, append = 0; ++ int rwa = 0, plus = 0; + int flags = 0; + int fd = -1; + int closefd = 1; +@@ -279,8 +281,8 @@ + goto bad_mode; + rwa = 1; + self->writable = 1; +- flags |= O_CREAT; +- append = 1; ++ self->appending = 1; ++ flags |= O_APPEND | O_CREAT; + break; + case 'b': + break; +@@ -311,11 +313,6 @@ + flags |= O_BINARY; + #endif + +-#ifdef O_APPEND +- if (append) +- flags |= O_APPEND; +-#endif +- + if (fd >= 0) { + if (check_fd(fd)) + goto error; +@@ -356,7 +353,7 @@ + if (PyObject_SetAttrString((PyObject *)self, "name", nameobj) < 0) + goto error; + +- if (append) { ++ if (self->appending) { + /* For consistent behaviour, we explicitly seek to the + end of file (otherwise, it might be done only on the + first write()). */ +@@ -898,7 +895,13 @@ + static char * + mode_string(fileio *self) + { +- if (self->readable) { ++ if (self->appending) { ++ if (self->readable) ++ return "ab+"; ++ else ++ return "ab"; ++ } ++ else if (self->readable) { + if (self->writable) + return "rb+"; + else +diff -r ab05e7dd2788 Modules/_io/textio.c +--- a/Modules/_io/textio.c ++++ b/Modules/_io/textio.c +@@ -2271,7 +2271,7 @@ + int dec_flags; + + PyObject *decoded = PyObject_CallMethod( +- self->decoder, "decode", "s#", input, 1); ++ self->decoder, "decode", "s#", input, (Py_ssize_t)1); + if (check_decoded(decoded) < 0) + goto fail; + chars_decoded += PyUnicode_GET_SIZE(decoded); +diff -r ab05e7dd2788 Modules/_multiprocessing/multiprocessing.c +--- a/Modules/_multiprocessing/multiprocessing.c ++++ b/Modules/_multiprocessing/multiprocessing.c +@@ -63,7 +63,7 @@ + break; + default: + PyErr_Format(PyExc_RuntimeError, +- "unkown error number %d", num); ++ "unknown error number %d", num); + } + return NULL; + } +diff -r ab05e7dd2788 Modules/_multiprocessing/socket_connection.c +--- a/Modules/_multiprocessing/socket_connection.c ++++ b/Modules/_multiprocessing/socket_connection.c +@@ -23,6 +23,21 @@ + #endif + + /* ++ * Wrapper for PyErr_CheckSignals() which can be called without the GIL ++ */ ++ ++static int ++check_signals(void) ++{ ++ PyGILState_STATE state; ++ int res; ++ state = PyGILState_Ensure(); ++ res = PyErr_CheckSignals(); ++ PyGILState_Release(state); ++ return res; ++} ++ ++/* + * Send string to file descriptor + */ + +@@ -34,8 +49,14 @@ + + while (length > 0) { + res = WRITE(h, p, length); +- if (res < 0) ++ if (res < 0) { ++ if (errno == EINTR) { ++ if (check_signals() < 0) ++ return MP_EXCEPTION_HAS_BEEN_SET; ++ continue; ++ } + return MP_SOCKET_ERROR; ++ } + length -= res; + p += res; + } +@@ -56,12 +77,16 @@ + + while (remaining > 0) { + temp = READ(h, p, remaining); +- if (temp <= 0) { +- if (temp == 0) +- return remaining == length ? +- MP_END_OF_FILE : MP_EARLY_END_OF_FILE; +- else +- return temp; ++ if (temp < 0) { ++ if (errno == EINTR) { ++ if (check_signals() < 0) ++ return MP_EXCEPTION_HAS_BEEN_SET; ++ continue; ++ } ++ return temp; ++ } ++ else if (temp == 0) { ++ return remaining == length ? MP_END_OF_FILE : MP_EARLY_END_OF_FILE; + } + remaining -= temp; + p += temp; +@@ -171,9 +196,16 @@ + p.revents = 0; + + if (timeout < 0) { +- res = poll(&p, 1, -1); ++ do { ++ res = poll(&p, 1, -1); ++ } while (res < 0 && errno == EINTR); + } else { + res = poll(&p, 1, (int)(timeout * 1000 + 0.5)); ++ if (res < 0 && errno == EINTR) { ++ /* We were interrupted by a signal. Just indicate a ++ timeout even though we are early. */ ++ return FALSE; ++ } + } + + if (res < 0) { +@@ -209,12 +241,19 @@ + FD_SET((SOCKET)conn->handle, &rfds); + + if (timeout < 0.0) { +- res = select((int)conn->handle+1, &rfds, NULL, NULL, NULL); ++ do { ++ res = select((int)conn->handle+1, &rfds, NULL, NULL, NULL); ++ } while (res < 0 && errno == EINTR); + } else { + struct timeval tv; + tv.tv_sec = (long)timeout; + tv.tv_usec = (long)((timeout - tv.tv_sec) * 1e6 + 0.5); + res = select((int)conn->handle+1, &rfds, NULL, NULL, &tv); ++ if (res < 0 && errno == EINTR) { ++ /* We were interrupted by a signal. Just indicate a ++ timeout even though we are early. */ ++ return FALSE; ++ } + } + + if (res < 0) { +diff -r ab05e7dd2788 Modules/_sre.c +--- a/Modules/_sre.c ++++ b/Modules/_sre.c +@@ -272,7 +272,7 @@ + if (cursize < minsize) { + void* stack; + cursize = minsize+minsize/4+1024; +- TRACE(("allocate/grow stack %d\n", cursize)); ++ TRACE(("allocate/grow stack %" PY_FORMAT_SIZE_T "d\n", cursize)); + stack = PyMem_REALLOC(state->data_stack, cursize); + if (!stack) { + data_stack_dealloc(state); +@@ -592,12 +592,13 @@ + if (!i) + break; + } +- TRACE(("|%p|%p|COUNT %d\n", pattern, ptr, ++ TRACE(("|%p|%p|COUNT %" PY_FORMAT_SIZE_T "d\n", pattern, ptr, + (SRE_CHAR*) state->ptr - ptr)); + return (SRE_CHAR*) state->ptr - ptr; + } + +- TRACE(("|%p|%p|COUNT %d\n", pattern, ptr, ptr - (SRE_CHAR*) state->ptr)); ++ TRACE(("|%p|%p|COUNT %" PY_FORMAT_SIZE_T "d\n", pattern, ptr, ++ ptr - (SRE_CHAR*) state->ptr)); + return ptr - (SRE_CHAR*) state->ptr; + } + +@@ -684,7 +685,8 @@ + #define DATA_STACK_ALLOC(state, type, ptr) \ + do { \ + alloc_pos = state->data_stack_base; \ +- TRACE(("allocating %s in %d (%d)\n", \ ++ TRACE(("allocating %s in %" PY_FORMAT_SIZE_T "d " \ ++ "(%" PY_FORMAT_SIZE_T "d)\n", \ + SFY(type), alloc_pos, sizeof(type))); \ + if (sizeof(type) > state->data_stack_size - alloc_pos) { \ + int j = data_stack_grow(state, sizeof(type)); \ +@@ -698,13 +700,14 @@ + + #define DATA_STACK_LOOKUP_AT(state, type, ptr, pos) \ + do { \ +- TRACE(("looking up %s at %d\n", SFY(type), pos)); \ ++ TRACE(("looking up %s at %" PY_FORMAT_SIZE_T "d\n", SFY(type), pos)); \ + ptr = (type*)(state->data_stack+pos); \ + } while (0) + + #define DATA_STACK_PUSH(state, data, size) \ + do { \ +- TRACE(("copy data in %p to %d (%d)\n", \ ++ TRACE(("copy data in %p to %" PY_FORMAT_SIZE_T "d " \ ++ "(%" PY_FORMAT_SIZE_T "d)\n", \ + data, state->data_stack_base, size)); \ + if (size > state->data_stack_size - state->data_stack_base) { \ + int j = data_stack_grow(state, size); \ +@@ -718,7 +721,8 @@ + + #define DATA_STACK_POP(state, data, size, discard) \ + do { \ +- TRACE(("copy data to %p from %d (%d)\n", \ ++ TRACE(("copy data to %p from %" PY_FORMAT_SIZE_T "d " \ ++ "(%" PY_FORMAT_SIZE_T "d)\n", \ + data, state->data_stack_base-size, size)); \ + memcpy(data, state->data_stack+state->data_stack_base-size, size); \ + if (discard) \ +@@ -727,7 +731,8 @@ + + #define DATA_STACK_POP_DISCARD(state, size) \ + do { \ +- TRACE(("discard data from %d (%d)\n", \ ++ TRACE(("discard data from %" PY_FORMAT_SIZE_T "d " \ ++ "(%" PY_FORMAT_SIZE_T "d)\n", \ + state->data_stack_base-size, size)); \ + state->data_stack_base -= size; \ + } while(0) +@@ -831,8 +836,9 @@ + /* optimization info block */ + /* <1=skip> <2=flags> <3=min> ... */ + if (ctx->pattern[3] && (end - ctx->ptr) < ctx->pattern[3]) { +- TRACE(("reject (got %d chars, need %d)\n", +- (end - ctx->ptr), ctx->pattern[3])); ++ TRACE(("reject (got %" PY_FORMAT_SIZE_T "d chars, " ++ "need %" PY_FORMAT_SIZE_T "d)\n", ++ (end - ctx->ptr), (Py_ssize_t) ctx->pattern[3])); + RETURN_FAILURE; + } + ctx->pattern += ctx->pattern[1] + 1; +@@ -1028,7 +1034,7 @@ + TRACE(("|%p|%p|REPEAT_ONE %d %d\n", ctx->pattern, ctx->ptr, + ctx->pattern[1], ctx->pattern[2])); + +- if (ctx->pattern[1] > end - ctx->ptr) ++ if ((Py_ssize_t) ctx->pattern[1] > end - ctx->ptr) + RETURN_FAILURE; /* cannot match */ + + state->ptr = ctx->ptr; +@@ -1111,7 +1117,7 @@ + TRACE(("|%p|%p|MIN_REPEAT_ONE %d %d\n", ctx->pattern, ctx->ptr, + ctx->pattern[1], ctx->pattern[2])); + +- if (ctx->pattern[1] > end - ctx->ptr) ++ if ((Py_ssize_t) ctx->pattern[1] > end - ctx->ptr) + RETURN_FAILURE; /* cannot match */ + + state->ptr = ctx->ptr; +@@ -1207,10 +1213,10 @@ + + ctx->count = ctx->u.rep->count+1; + +- TRACE(("|%p|%p|MAX_UNTIL %d\n", ctx->pattern, ++ TRACE(("|%p|%p|MAX_UNTIL %" PY_FORMAT_SIZE_T "d\n", ctx->pattern, + ctx->ptr, ctx->count)); + +- if (ctx->count < ctx->u.rep->pattern[1]) { ++ if (ctx->count < (Py_ssize_t) ctx->u.rep->pattern[1]) { + /* not enough matches */ + ctx->u.rep->count = ctx->count; + DO_JUMP(JUMP_MAX_UNTIL_1, jump_max_until_1, +@@ -1224,7 +1230,7 @@ + RETURN_FAILURE; + } + +- if ((ctx->count < ctx->u.rep->pattern[2] || ++ if ((ctx->count < (Py_ssize_t) ctx->u.rep->pattern[2] || + ctx->u.rep->pattern[2] == SRE_MAXREPEAT) && + state->ptr != ctx->u.rep->last_ptr) { + /* we may have enough matches, but if we can +@@ -1270,10 +1276,10 @@ + + ctx->count = ctx->u.rep->count+1; + +- TRACE(("|%p|%p|MIN_UNTIL %d %p\n", ctx->pattern, ++ TRACE(("|%p|%p|MIN_UNTIL %" PY_FORMAT_SIZE_T "d %p\n", ctx->pattern, + ctx->ptr, ctx->count, ctx->u.rep->pattern)); + +- if (ctx->count < ctx->u.rep->pattern[1]) { ++ if (ctx->count < (Py_ssize_t) ctx->u.rep->pattern[1]) { + /* not enough matches */ + ctx->u.rep->count = ctx->count; + DO_JUMP(JUMP_MIN_UNTIL_1, jump_min_until_1, +@@ -1302,7 +1308,7 @@ + + LASTMARK_RESTORE(); + +- if ((ctx->count >= ctx->u.rep->pattern[2] ++ if ((ctx->count >= (Py_ssize_t) ctx->u.rep->pattern[2] + && ctx->u.rep->pattern[2] != SRE_MAXREPEAT) || + state->ptr == ctx->u.rep->last_ptr) + RETURN_FAILURE; +@@ -1483,7 +1489,8 @@ + TRACE(("|%p|%p|JUMP_ASSERT_NOT\n", ctx->pattern, ctx->ptr)); + goto jump_assert_not; + case JUMP_NONE: +- TRACE(("|%p|%p|RETURN %d\n", ctx->pattern, ctx->ptr, ret)); ++ TRACE(("|%p|%p|RETURN %" PY_FORMAT_SIZE_T "d\n", ctx->pattern, ++ ctx->ptr, ret)); + break; + } + +@@ -1532,7 +1539,8 @@ + pattern += 1 + pattern[1]; + } + +- TRACE(("prefix = %p %d %d\n", prefix, prefix_len, prefix_skip)); ++ TRACE(("prefix = %p %" PY_FORMAT_SIZE_T "d %" PY_FORMAT_SIZE_T "d\n", ++ prefix, prefix_len, prefix_skip)); + TRACE(("charset = %p\n", charset)); + + #if defined(USE_FAST_SEARCH) +diff -r ab05e7dd2788 Modules/_ssl.c +--- a/Modules/_ssl.c ++++ b/Modules/_ssl.c +@@ -18,6 +18,11 @@ + + #ifdef WITH_THREAD + #include "pythread.h" ++ ++#ifdef HAVE_PTHREAD_ATFORK ++# include ++#endif ++ + #define PySSL_BEGIN_ALLOW_THREADS { \ + PyThreadState *_save = NULL; \ + if (_ssl_locks_count>0) {_save = PyEval_SaveThread();} +@@ -686,7 +691,7 @@ + + int i, j; + PyObject *peer_alt_names = Py_None; +- PyObject *v, *t; ++ PyObject *v = NULL, *t; + X509_EXTENSION *ext = NULL; + GENERAL_NAMES *names = NULL; + GENERAL_NAME *name; +@@ -738,13 +743,16 @@ + ext->value->length)); + + for(j = 0; j < sk_GENERAL_NAME_num(names); j++) { +- + /* get a rendering of each name in the set of names */ ++ int gntype; ++ ASN1_STRING *as = NULL; + + name = sk_GENERAL_NAME_value(names, j); +- if (name->type == GEN_DIRNAME) { +- +- /* we special-case DirName as a tuple of tuples of attributes */ ++ gntype = name->type; ++ switch (gntype) { ++ case GEN_DIRNAME: ++ /* we special-case DirName as a tuple of ++ tuples of attributes */ + + t = PyTuple_New(2); + if (t == NULL) { +@@ -764,11 +772,61 @@ + goto fail; + } + PyTuple_SET_ITEM(t, 1, v); ++ break; + +- } else { ++ case GEN_EMAIL: ++ case GEN_DNS: ++ case GEN_URI: ++ /* GENERAL_NAME_print() doesn't handle NULL bytes in ASN1_string ++ correctly, CVE-2013-4238 */ ++ t = PyTuple_New(2); ++ if (t == NULL) ++ goto fail; ++ switch (gntype) { ++ case GEN_EMAIL: ++ v = PyString_FromString("email"); ++ as = name->d.rfc822Name; ++ break; ++ case GEN_DNS: ++ v = PyString_FromString("DNS"); ++ as = name->d.dNSName; ++ break; ++ case GEN_URI: ++ v = PyString_FromString("URI"); ++ as = name->d.uniformResourceIdentifier; ++ break; ++ } ++ if (v == NULL) { ++ Py_DECREF(t); ++ goto fail; ++ } ++ PyTuple_SET_ITEM(t, 0, v); ++ v = PyString_FromStringAndSize((char *)ASN1_STRING_data(as), ++ ASN1_STRING_length(as)); ++ if (v == NULL) { ++ Py_DECREF(t); ++ goto fail; ++ } ++ PyTuple_SET_ITEM(t, 1, v); ++ break; + ++ default: + /* for everything else, we use the OpenSSL print form */ +- ++ switch (gntype) { ++ /* check for new general name type */ ++ case GEN_OTHERNAME: ++ case GEN_X400: ++ case GEN_EDIPARTY: ++ case GEN_IPADD: ++ case GEN_RID: ++ break; ++ default: ++ if (PyErr_Warn(PyExc_RuntimeWarning, ++ "Unknown general name type") == -1) { ++ goto fail; ++ } ++ break; ++ } + (void) BIO_reset(biobuf); + GENERAL_NAME_print(biobuf, name); + len = BIO_gets(biobuf, buf, sizeof(buf)-1); +@@ -794,6 +852,7 @@ + goto fail; + } + PyTuple_SET_ITEM(t, 1, v); ++ break; + } + + /* and add that rendering to the list */ +@@ -1192,6 +1251,12 @@ + if (!PyArg_ParseTuple(args, "s*:write", &buf)) + return NULL; + ++ if (buf.len > INT_MAX) { ++ PyErr_Format(PyExc_OverflowError, ++ "string longer than %d bytes", INT_MAX); ++ goto error; ++ } ++ + /* just in case the blocking state of the socket has been changed */ + nonblocking = (self->Socket->sock_timeout >= 0.0); + BIO_set_nbio(SSL_get_rbio(self->ssl), nonblocking); +@@ -1213,7 +1278,7 @@ + } + do { + PySSL_BEGIN_ALLOW_THREADS +- len = SSL_write(self->ssl, buf.buf, buf.len); ++ len = SSL_write(self->ssl, buf.buf, (int)buf.len); + err = SSL_get_error(self->ssl, len); + PySSL_END_ALLOW_THREADS + if (PyErr_CheckSignals()) { +@@ -1395,7 +1460,7 @@ + * Otherwise OpenSSL might read in too much data, + * eating clear text data that happens to be + * transmitted after the SSL shutdown. +- * Should be safe to call repeatedly everytime this ++ * Should be safe to call repeatedly every time this + * function is used and the shutdown_seen_zero != 0 + * condition is met. + */ +@@ -1559,9 +1624,68 @@ + \n\ + Queries the entropy gather daemon (EGD) on the socket named by 'path'.\n\ + Returns number of bytes read. Raises SSLError if connection to EGD\n\ +-fails or if it does provide enough data to seed PRNG."); ++fails or if it does not provide enough data to seed PRNG."); + ++/* Seed OpenSSL's PRNG at fork(), http://bugs.python.org/issue18747 ++ * ++ * The parent handler seeds the PRNG from pseudo-random data like pid, the ++ * current time (miliseconds or seconds) and an uninitialized array. ++ * The array contains stack variables that are impossible to predict ++ * on most systems, e.g. function return address (subject to ASLR), the ++ * stack protection canary and automatic variables. ++ * The code is inspired by Apache's ssl_rand_seed() function. ++ * ++ * Note: ++ * The code uses pthread_atfork() until Python has a proper atfork API. The ++ * handlers are not removed from the child process. A parent handler is used ++ * instead of a child handler because fork() is supposed to be async-signal ++ * safe but the handler calls unsafe functions. ++ */ ++ ++#if defined(HAVE_PTHREAD_ATFORK) && defined(WITH_THREAD) ++#define PYSSL_RAND_ATFORK 1 ++ ++static void ++PySSL_RAND_atfork_parent(void) ++{ ++ struct { ++ char stack[128]; /* uninitialized (!) stack data, 128 is an ++ arbitrary number. */ ++ pid_t pid; /* current pid */ ++ time_t time; /* current time */ ++ } seed; ++ ++#ifdef WITH_VALGRIND ++ VALGRIND_MAKE_MEM_DEFINED(seed.stack, sizeof(seed.stack)); + #endif ++ seed.pid = getpid(); ++ seed.time = time(NULL); ++ RAND_add((unsigned char *)&seed, sizeof(seed), 0.0); ++} ++ ++static int ++PySSL_RAND_atfork(void) ++{ ++ static int registered = 0; ++ int retval; ++ ++ if (registered) ++ return 0; ++ ++ retval = pthread_atfork(NULL, /* prepare */ ++ PySSL_RAND_atfork_parent, /* parent */ ++ NULL); /* child */ ++ if (retval != 0) { ++ PyErr_SetFromErrno(PyExc_OSError); ++ return -1; ++ } ++ registered = 1; ++ return 0; ++} ++#endif /* HAVE_PTHREAD_ATFORK */ ++ ++#endif /* HAVE_OPENSSL_RAND */ ++ + + /* List of functions exported by this module. */ + +@@ -1589,9 +1713,21 @@ + + static PyThread_type_lock *_ssl_locks = NULL; + +-static unsigned long _ssl_thread_id_function (void) { ++#if OPENSSL_VERSION_NUMBER >= 0x10000000 ++/* use new CRYPTO_THREADID API. */ ++static void ++_ssl_threadid_callback(CRYPTO_THREADID *id) ++{ ++ CRYPTO_THREADID_set_numeric(id, ++ (unsigned long)PyThread_get_thread_ident()); ++} ++#else ++/* deprecated CRYPTO_set_id_callback() API. */ ++static unsigned long ++_ssl_thread_id_function (void) { + return PyThread_get_thread_ident(); + } ++#endif + + static void _ssl_thread_locking_function (int mode, int n, const char *file, int line) { + /* this function is needed to perform locking on shared data +@@ -1642,7 +1778,11 @@ + } + } + CRYPTO_set_locking_callback(_ssl_thread_locking_function); ++#if OPENSSL_VERSION_NUMBER >= 0x10000000 ++ CRYPTO_THREADID_set_callback(_ssl_threadid_callback); ++#else + CRYPTO_set_id_callback(_ssl_thread_id_function); ++#endif + } + return 1; + } +@@ -1757,4 +1897,9 @@ + r = PyString_FromString(SSLeay_version(SSLEAY_VERSION)); + if (r == NULL || PyModule_AddObject(m, "OPENSSL_VERSION", r)) + return; ++ ++#ifdef PYSSL_RAND_ATFORK ++ if (PySSL_RAND_atfork() == -1) ++ return; ++#endif + } +diff -r ab05e7dd2788 Modules/_testcapimodule.c +--- a/Modules/_testcapimodule.c ++++ b/Modules/_testcapimodule.c +@@ -1118,7 +1118,7 @@ + if (!PyArg_ParseTuple(args, "u#|s", &unicode, &length, &errors)) + return NULL; + +- decimal_length = length * 7; /* len('€') */ ++ decimal_length = length * 10; /* len('􏿿') */ + decimal = PyBytes_FromStringAndSize(NULL, decimal_length); + if (decimal == NULL) + return NULL; +diff -r ab05e7dd2788 Modules/_tkinter.c +--- a/Modules/_tkinter.c ++++ b/Modules/_tkinter.c +@@ -47,6 +47,10 @@ + #define PyBool_FromLong PyInt_FromLong + #endif + ++#define CHECK_SIZE(size, elemsize) \ ++ ((size_t)(size) <= (size_t)INT_MAX && \ ++ (size_t)(size) <= UINT_MAX / (size_t)(elemsize)) ++ + /* Starting with Tcl 8.4, many APIs offer const-correctness. Unfortunately, + making _tkinter correct for this API means to break earlier + versions. USE_COMPAT_CONST allows to make _tkinter work with both 8.4 and +@@ -378,7 +382,7 @@ + char **argv = NULL; + int fvStore[ARGSZ]; + int *fv = NULL; +- int argc = 0, fvc = 0, i; ++ Py_ssize_t argc = 0, fvc = 0, i; + char *res = NULL; + + if (!(tmp = PyList_New(0))) +@@ -400,8 +404,12 @@ + argc = PyTuple_Size(args); + + if (argc > ARGSZ) { +- argv = (char **)ckalloc(argc * sizeof(char *)); +- fv = (int *)ckalloc(argc * sizeof(int)); ++ if (!CHECK_SIZE(argc, sizeof(char *))) { ++ PyErr_SetString(PyExc_OverflowError, "tuple is too long"); ++ goto finally; ++ } ++ argv = (char **)ckalloc((size_t)argc * sizeof(char *)); ++ fv = (int *)ckalloc((size_t)argc * sizeof(int)); + if (argv == NULL || fv == NULL) { + PyErr_NoMemory(); + goto finally; +@@ -547,6 +555,33 @@ + return Split(PyString_AsString(arg)); + /* Fall through, returning arg. */ + } ++ else if (PyUnicode_Check(arg)) { ++ int argc; ++ char **argv; ++ char *list; ++ PyObject *s = PyUnicode_AsUTF8String(arg); ++ ++ if (s == NULL) { ++ Py_INCREF(arg); ++ return arg; ++ } ++ list = PyString_AsString(s); ++ ++ if (list == NULL || ++ Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) { ++ Py_DECREF(s); ++ Py_INCREF(arg); ++ return arg; ++ } ++ Tcl_Free(FREECAST argv); ++ if (argc > 1) { ++ PyObject *v = Split(list); ++ Py_DECREF(s); ++ return v; ++ } ++ Py_DECREF(s); ++ /* Fall through, returning arg. */ ++ } + Py_INCREF(arg); + return arg; + } +@@ -956,12 +991,18 @@ + else if (PyFloat_Check(value)) + return Tcl_NewDoubleObj(PyFloat_AS_DOUBLE(value)); + else if (PyTuple_Check(value)) { +- Tcl_Obj **argv = (Tcl_Obj**) +- ckalloc(PyTuple_Size(value)*sizeof(Tcl_Obj*)); +- int i; ++ Tcl_Obj **argv; ++ Py_ssize_t size, i; ++ ++ size = PyTuple_Size(value); ++ if (!CHECK_SIZE(size, sizeof(Tcl_Obj *))) { ++ PyErr_SetString(PyExc_OverflowError, "tuple is too long"); ++ return NULL; ++ } ++ argv = (Tcl_Obj **) ckalloc(((size_t)size) * sizeof(Tcl_Obj *)); + if(!argv) + return 0; +- for(i=0;i= size) + outbuf = (Tcl_UniChar*)ckalloc(allocsize); + /* Else overflow occurred, and we take the next exit */ +@@ -1171,7 +1217,7 @@ + Tkapp_CallArgs(PyObject *args, Tcl_Obj** objStore, int *pobjc) + { + Tcl_Obj **objv = objStore; +- int objc = 0, i; ++ Py_ssize_t objc = 0, i; + if (args == NULL) + /* do nothing */; + +@@ -1186,7 +1232,11 @@ + objc = PyTuple_Size(args); + + if (objc > ARGSZ) { +- objv = (Tcl_Obj **)ckalloc(objc * sizeof(char *)); ++ if (!CHECK_SIZE(objc, sizeof(Tcl_Obj *))) { ++ PyErr_SetString(PyExc_OverflowError, "tuple is too long"); ++ return NULL; ++ } ++ objv = (Tcl_Obj **)ckalloc(((size_t)objc) * sizeof(Tcl_Obj *)); + if (objv == NULL) { + PyErr_NoMemory(); + objc = 0; +@@ -1954,16 +2004,35 @@ + char *list; + int argc; + char **argv; +- PyObject *v; ++ PyObject *arg, *v; + int i; + +- if (PyTuple_Size(args) == 1) { +- v = PyTuple_GetItem(args, 0); +- if (PyTuple_Check(v)) { +- Py_INCREF(v); +- return v; ++ if (!PyArg_ParseTuple(args, "O:splitlist", &arg)) ++ return NULL; ++ if (PyTclObject_Check(arg)) { ++ int objc; ++ Tcl_Obj **objv; ++ if (Tcl_ListObjGetElements(Tkapp_Interp(self), ++ ((PyTclObject*)arg)->value, ++ &objc, &objv) == TCL_ERROR) { ++ return Tkinter_Error(self); + } ++ if (!(v = PyTuple_New(objc))) ++ return NULL; ++ for (i = 0; i < objc; i++) { ++ PyObject *s = FromObj(self, objv[i]); ++ if (!s || PyTuple_SetItem(v, i, s)) { ++ Py_DECREF(v); ++ return NULL; ++ } ++ } ++ return v; + } ++ if (PyTuple_Check(arg)) { ++ Py_INCREF(arg); ++ return arg; ++ } ++ + if (!PyArg_ParseTuple(args, "et:splitlist", "utf-8", &list)) + return NULL; + +@@ -1994,16 +2063,38 @@ + static PyObject * + Tkapp_Split(PyObject *self, PyObject *args) + { +- PyObject *v; ++ PyObject *arg, *v; + char *list; + +- if (PyTuple_Size(args) == 1) { +- PyObject* o = PyTuple_GetItem(args, 0); +- if (PyTuple_Check(o)) { +- o = SplitObj(o); +- return o; ++ if (!PyArg_ParseTuple(args, "O:split", &arg)) ++ return NULL; ++ if (PyTclObject_Check(arg)) { ++ Tcl_Obj *value = ((PyTclObject*)arg)->value; ++ int objc; ++ Tcl_Obj **objv; ++ int i; ++ if (Tcl_ListObjGetElements(Tkapp_Interp(self), value, ++ &objc, &objv) == TCL_ERROR) { ++ return FromObj(self, value); + } ++ if (objc == 0) ++ return PyString_FromString(""); ++ if (objc == 1) ++ return FromObj(self, objv[0]); ++ if (!(v = PyTuple_New(objc))) ++ return NULL; ++ for (i = 0; i < objc; i++) { ++ PyObject *s = FromObj(self, objv[i]); ++ if (!s || PyTuple_SetItem(v, i, s)) { ++ Py_DECREF(v); ++ return NULL; ++ } ++ } ++ return v; + } ++ if (PyTuple_Check(arg)) ++ return SplitObj(arg); ++ + if (!PyArg_ParseTuple(args, "et:split", "utf-8", &list)) + return NULL; + v = Split(list); +@@ -2723,7 +2814,7 @@ + if (!PyArg_ParseTuple(args, ":interpaddr")) + return NULL; + +- return PyInt_FromLong((long)Tkapp_Interp(self)); ++ return PyLong_FromVoidPtr(Tkapp_Interp(self)); + } + + static PyObject * +diff -r ab05e7dd2788 Modules/cmathmodule.c +--- a/Modules/cmathmodule.c ++++ b/Modules/cmathmodule.c +@@ -1006,6 +1006,13 @@ + else + errno = 0; + } ++ else if (phi == 0.0) { ++ /* Workaround for buggy results with phi=-0.0 on OS X 10.8. See ++ bugs.python.org/issue18513. */ ++ z.real = r; ++ z.imag = r * phi; ++ errno = 0; ++ } + else { + z.real = r * cos(phi); + z.imag = r * sin(phi); +diff -r ab05e7dd2788 Modules/grpmodule.c +--- a/Modules/grpmodule.c ++++ b/Modules/grpmodule.c +@@ -11,7 +11,7 @@ + {"gr_name", "group name"}, + {"gr_passwd", "password"}, + {"gr_gid", "group id"}, +- {"gr_mem", "group memebers"}, ++ {"gr_mem", "group members"}, + {0} + }; + +diff -r ab05e7dd2788 Modules/itertoolsmodule.c +--- a/Modules/itertoolsmodule.c ++++ b/Modules/itertoolsmodule.c +@@ -3426,10 +3426,10 @@ + Return a count object whose .next() method returns consecutive values.\n\ + Equivalent to:\n\n\ + def count(firstval=0, step=1):\n\ +- x = firstval\n\ +- while 1:\n\ +- yield x\n\ +- x += step\n"); ++ x = firstval\n\ ++ while 1:\n\ ++ yield x\n\ ++ x += step\n"); + + static PyTypeObject count_type = { + PyVarObject_HEAD_INIT(NULL, 0) +diff -r ab05e7dd2788 Modules/posixmodule.c +--- a/Modules/posixmodule.c ++++ b/Modules/posixmodule.c +@@ -4054,6 +4054,34 @@ + gid_t* alt_grouplist = grouplist; + int n; + ++#ifdef __APPLE__ ++ /* Issue #17557: As of OS X 10.8, getgroups(2) no longer raises EINVAL if ++ * there are more groups than can fit in grouplist. Therefore, on OS X ++ * always first call getgroups with length 0 to get the actual number ++ * of groups. ++ */ ++ n = getgroups(0, NULL); ++ if (n < 0) { ++ return posix_error(); ++ } else if (n <= MAX_GROUPS) { ++ /* groups will fit in existing array */ ++ alt_grouplist = grouplist; ++ } else { ++ alt_grouplist = PyMem_Malloc(n * sizeof(gid_t)); ++ if (alt_grouplist == NULL) { ++ errno = EINVAL; ++ return posix_error(); ++ } ++ } ++ ++ n = getgroups(n, alt_grouplist); ++ if (n == -1) { ++ if (alt_grouplist != grouplist) { ++ PyMem_Free(alt_grouplist); ++ } ++ return posix_error(); ++ } ++#else + n = getgroups(MAX_GROUPS, grouplist); + if (n < 0) { + if (errno == EINVAL) { +@@ -4080,6 +4108,8 @@ + return posix_error(); + } + } ++#endif ++ + result = PyList_New(n); + if (result != NULL) { + int i; +diff -r ab05e7dd2788 Modules/pyexpat.c +--- a/Modules/pyexpat.c ++++ b/Modules/pyexpat.c +@@ -1252,6 +1252,13 @@ + if (_u_string == NULL) + return result; + ++ if (PyUnicode_GET_SIZE(_u_string) != 256) { ++ Py_DECREF(_u_string); ++ PyErr_SetString(PyExc_ValueError, ++ "multi-byte encodings are not supported"); ++ return result; ++ } ++ + for (i = 0; i < 256; i++) { + /* Stupid to access directly, but fast */ + Py_UNICODE c = _u_string->str[i]; +diff -r ab05e7dd2788 Modules/selectmodule.c +--- a/Modules/selectmodule.c ++++ b/Modules/selectmodule.c +@@ -318,6 +318,7 @@ + int ufd_uptodate; + int ufd_len; + struct pollfd *ufds; ++ int poll_running; + } pollObject; + + static PyTypeObject poll_Type; +@@ -513,16 +514,27 @@ + return NULL; + } + ++ /* Avoid concurrent poll() invocation, issue 8865 */ ++ if (self->poll_running) { ++ PyErr_SetString(PyExc_RuntimeError, ++ "concurrent poll() invocation"); ++ return NULL; ++ } ++ + /* Ensure the ufd array is up to date */ + if (!self->ufd_uptodate) + if (update_ufd_array(self) == 0) + return NULL; + ++ self->poll_running = 1; ++ + /* call poll() */ + Py_BEGIN_ALLOW_THREADS + poll_result = poll(self->ufds, self->ufd_len, timeout); + Py_END_ALLOW_THREADS + ++ self->poll_running = 0; ++ + if (poll_result < 0) { + PyErr_SetFromErrno(SelectError); + return NULL; +@@ -599,6 +611,7 @@ + array pointed to by ufds matches the contents of the dictionary. */ + self->ufd_uptodate = 0; + self->ufds = NULL; ++ self->poll_running = 0; + self->dict = PyDict_New(); + if (self->dict == NULL) { + Py_DECREF(self); +@@ -1257,7 +1270,7 @@ + PyObject *pfd; + static char *kwlist[] = {"ident", "filter", "flags", "fflags", + "data", "udata", NULL}; +- static char *fmt = "O|hhi" DATA_FMT_UNIT UINTPTRT_FMT_UNIT ":kevent"; ++ static char *fmt = "O|hHI" DATA_FMT_UNIT UINTPTRT_FMT_UNIT ":kevent"; + + EV_SET(&(self->e), 0, EVFILT_READ, EV_ADD, 0, 0, 0); /* defaults */ + +diff -r ab05e7dd2788 Modules/socketmodule.c +--- a/Modules/socketmodule.c ++++ b/Modules/socketmodule.c +@@ -4179,6 +4179,15 @@ + "getaddrinfo() argument 2 must be integer or string"); + goto err; + } ++#if defined(__APPLE__) && defined(AI_NUMERICSERV) ++ if ((flags & AI_NUMERICSERV) && (pptr == NULL || (pptr[0] == '0' && pptr[1] == 0))) { ++ /* On OSX upto at least OSX 10.8 getaddrinfo crashes ++ * if AI_NUMERICSERV is set and the servname is NULL or "0". ++ * This workaround avoids a segfault in libsystem. ++ */ ++ pptr = "00"; ++ } ++#endif + memset(&hints, 0, sizeof(hints)); + hints.ai_family = family; + hints.ai_socktype = socktype; +diff -r ab05e7dd2788 Modules/sre.h +--- a/Modules/sre.h ++++ b/Modules/sre.h +@@ -20,14 +20,14 @@ + # if SIZEOF_SIZE_T > 4 + # define SRE_MAXREPEAT (~(SRE_CODE)0) + # else +-# define SRE_MAXREPEAT ((SRE_CODE)PY_SSIZE_T_MAX + 1u) ++# define SRE_MAXREPEAT ((SRE_CODE)PY_SSIZE_T_MAX) + # endif + #else +-# define SRE_CODE unsigned long +-# if SIZEOF_SIZE_T > SIZEOF_LONG ++# define SRE_CODE unsigned int ++# if SIZEOF_SIZE_T > SIZEOF_INT + # define SRE_MAXREPEAT (~(SRE_CODE)0) + # else +-# define SRE_MAXREPEAT ((SRE_CODE)PY_SSIZE_T_MAX + 1u) ++# define SRE_MAXREPEAT ((SRE_CODE)PY_SSIZE_T_MAX) + # endif + #endif + +diff -r ab05e7dd2788 Modules/unicodedata.c +--- a/Modules/unicodedata.c ++++ b/Modules/unicodedata.c +@@ -506,7 +506,7 @@ + + stackptr = 0; + isize = PyUnicode_GET_SIZE(input); +- /* Overallocate atmost 10 characters. */ ++ /* Overallocate at most 10 characters. */ + space = (isize > 10 ? 10 : isize) + isize; + result = PyUnicode_FromUnicode(NULL, space); + if (!result) +@@ -520,7 +520,7 @@ + while(stackptr) { + Py_UNICODE code = stack[--stackptr]; + /* Hangul Decomposition adds three characters in +- a single step, so we need atleast that much room. */ ++ a single step, so we need at least that much room. */ + if (space < 3) { + Py_ssize_t newsize = PyString_GET_SIZE(result) + 10; + space += 10; +diff -r ab05e7dd2788 Objects/dictobject.c +--- a/Objects/dictobject.c ++++ b/Objects/dictobject.c +@@ -2919,6 +2919,10 @@ + return NULL; + + seq_str = PyObject_Repr(seq); ++ if (seq_str == NULL) { ++ Py_DECREF(seq); ++ return NULL; ++ } + result = PyString_FromFormat("%s(%s)", Py_TYPE(dv)->tp_name, + PyString_AS_STRING(seq_str)); + Py_DECREF(seq_str); +diff -r ab05e7dd2788 Objects/listsort.txt +--- a/Objects/listsort.txt ++++ b/Objects/listsort.txt +@@ -60,6 +60,7 @@ + /sort: ascending data + 3sort: ascending, then 3 random exchanges + +sort: ascending, then 10 random at the end ++ %sort: ascending, then randomly replace 1% of elements w/ random values + ~sort: many duplicates + =sort: all equal + !sort: worst case scenario +@@ -99,11 +100,13 @@ + The algorithms are effectively identical in these cases, except that + timsort does one less compare in \sort. + +- Now for the more interesting cases. lg(n!) is the information-theoretic +- limit for the best any comparison-based sorting algorithm can do on +- average (across all permutations). When a method gets significantly +- below that, it's either astronomically lucky, or is finding exploitable +- structure in the data. ++ Now for the more interesting cases. Where lg(x) is the logarithm of x to ++ the base 2 (e.g., lg(8)=3), lg(n!) is the information-theoretic limit for ++ the best any comparison-based sorting algorithm can do on average (across ++ all permutations). When a method gets significantly below that, it's ++ either astronomically lucky, or is finding exploitable structure in the ++ data. ++ + + n lg(n!) *sort 3sort +sort %sort ~sort !sort + ------- ------- ------ ------- ------- ------ ------- -------- +@@ -250,7 +253,7 @@ + ---------------- + If N < 64, minrun is N. IOW, binary insertion sort is used for the whole + array then; it's hard to beat that given the overheads of trying something +-fancier. ++fancier (see note BINSORT). + + When N is a power of 2, testing on random data showed that minrun values of + 16, 32, 64 and 128 worked about equally well. At 256 the data-movement cost +@@ -378,10 +381,10 @@ + + Merge Memory + ------------ +-Merging adjacent runs of lengths A and B in-place is very difficult. +-Theoretical constructions are known that can do it, but they're too difficult +-and slow for practical use. But if we have temp memory equal to min(A, B), +-it's easy. ++Merging adjacent runs of lengths A and B in-place, and in linear time, is ++difficult. Theoretical constructions are known that can do it, but they're ++too difficult and slow for practical use. But if we have temp memory equal ++to min(A, B), it's easy. + + If A is smaller (function merge_lo), copy A to a temp array, leave B alone, + and then we can do the obvious merge algorithm left to right, from the temp +@@ -456,10 +459,10 @@ + + After finding such a k, the region of uncertainty is reduced to 2**(k-1) - 1 + consecutive elements, and a straight binary search requires exactly k-1 +-additional comparisons to nail it. Then we copy all the B's up to that +-point in one chunk, and then copy A[0]. Note that no matter where A[0] +-belongs in B, the combination of galloping + binary search finds it in no +-more than about 2*lg(B) comparisons. ++additional comparisons to nail it (see note REGION OF UNCERTAINTY). Then we ++copy all the B's up to that point in one chunk, and then copy A[0]. Note ++that no matter where A[0] belongs in B, the combination of galloping + binary ++search finds it in no more than about 2*lg(B) comparisons. + + If we did a straight binary search, we could find it in no more than + ceiling(lg(B+1)) comparisons -- but straight binary search takes that many +@@ -572,11 +575,11 @@ + The description above was for merge_lo. merge_hi has to merge "from the + other end", and really needs to gallop starting at the last element in a run + instead of the first. Galloping from the first still works, but does more +-comparisons than it should (this is significant -- I timed it both ways). +-For this reason, the gallop_left() and gallop_right() functions have a +-"hint" argument, which is the index at which galloping should begin. So +-galloping can actually start at any index, and proceed at offsets of 1, 3, +-7, 15, ... or -1, -3, -7, -15, ... from the starting index. ++comparisons than it should (this is significant -- I timed it both ways). For ++this reason, the gallop_left() and gallop_right() (see note LEFT OR RIGHT) ++functions have a "hint" argument, which is the index at which galloping ++should begin. So galloping can actually start at any index, and proceed at ++offsets of 1, 3, 7, 15, ... or -1, -3, -7, -15, ... from the starting index. + + In the code as I type it's always called with either 0 or n-1 (where n is + the # of elements in a run). It's tempting to try to do something fancier, +@@ -675,3 +678,78 @@ + [2, 1]. Gratifyingly, timsort doesn't do any special-casing, so had to be + taught how to deal with mixtures of ascending and descending runs + efficiently in all cases. ++ ++ ++NOTES ++----- ++ ++BINSORT ++A "binary insertion sort" is just like a textbook insertion sort, but instead ++of locating the correct position of the next item via linear (one at a time) ++search, an equivalent to Python's bisect.bisect_right is used to find the ++correct position in logarithmic time. Most texts don't mention this ++variation, and those that do usually say it's not worth the bother: insertion ++sort remains quadratic (expected and worst cases) either way. Speeding the ++search doesn't reduce the quadratic data movement costs. ++ ++But in CPython's case, comparisons are extraordinarily expensive compared to ++moving data, and the details matter. Moving objects is just copying ++pointers. Comparisons can be arbitrarily expensive (can invoke arbitary ++user-supplied Python code), but even in simple cases (like 3 < 4) _all_ ++decisions are made at runtime: what's the type of the left comparand? the ++type of the right? do they need to be coerced to a common type? where's the ++code to compare these types? And so on. Even the simplest Python comparison ++triggers a large pile of C-level pointer dereferences, conditionals, and ++function calls. ++ ++So cutting the number of compares is almost always measurably helpful in ++CPython, and the savings swamp the quadratic-time data movement costs for ++reasonable minrun values. ++ ++ ++LEFT OR RIGHT ++gallop_left() and gallop_right() are akin to the Python bisect module's ++bisect_left() and bisect_right(): they're the same unless the slice they're ++searching contains a (at least one) value equal to the value being searched ++for. In that case, gallop_left() returns the position immediately before the ++leftmost equal value, and gallop_right() the position immediately after the ++rightmost equal value. The distinction is needed to preserve stability. In ++general, when merging adjacent runs A and B, gallop_left is used to search ++thru B for where an element from A belongs, and gallop_right to search thru A ++for where an element from B belongs. ++ ++ ++REGION OF UNCERTAINTY ++Two kinds of confusion seem to be common about the claim that after finding ++a k such that ++ ++ B[2**(k-1) - 1] < A[0] <= B[2**k - 1] ++ ++then a binary search requires exactly k-1 tries to find A[0]'s proper ++location. For concreteness, say k=3, so B[3] < A[0] <= B[7]. ++ ++The first confusion takes the form "OK, then the region of uncertainty is at ++indices 3, 4, 5, 6 and 7: that's 5 elements, not the claimed 2**(k-1) - 1 = ++3"; or the region is viewed as a Python slice and the objection is "but that's ++the slice B[3:7], so has 7-3 = 4 elements". Resolution: we've already ++compared A[0] against B[3] and against B[7], so A[0]'s correct location is ++already known wrt _both_ endpoints. What remains is to find A[0]'s correct ++location wrt B[4], B[5] and B[6], which spans 3 elements. Or in general, the ++slice (leaving off both endpoints) (2**(k-1)-1)+1 through (2**k-1)-1 ++inclusive = 2**(k-1) through (2**k-1)-1 inclusive, which has ++ (2**k-1)-1 - 2**(k-1) + 1 = ++ 2**k-1 - 2**(k-1) = ++ 2*2**k-1 - 2**(k-1) = ++ (2-1)*2**(k-1) - 1 = ++ 2**(k-1) - 1 ++elements. ++ ++The second confusion: "k-1 = 2 binary searches can find the correct location ++among 2**(k-1) = 4 elements, but you're only applying it to 3 elements: we ++could make this more efficient by arranging for the region of uncertainty to ++span 2**(k-1) elements." Resolution: that confuses "elements" with ++"locations". In a slice with N elements, there are N+1 _locations_. In the ++example, with the region of uncertainty B[4], B[5], B[6], there are 4 ++locations: before B[4], between B[4] and B[5], between B[5] and B[6], and ++after B[6]. In general, across 2**(k-1)-1 elements, there are 2**(k-1) ++locations. That's why k-1 binary searches are necessary and sufficient. +diff -r ab05e7dd2788 Objects/setobject.c +--- a/Objects/setobject.c ++++ b/Objects/setobject.c +@@ -212,7 +212,6 @@ + set_insert_key(register PySetObject *so, PyObject *key, long hash) + { + register setentry *entry; +- typedef setentry *(*lookupfunc)(PySetObject *, PyObject *, long); + + assert(so->lookup != NULL); + entry = so->lookup(so, key, hash); +diff -r ab05e7dd2788 Objects/stringlib/formatter.h +--- a/Objects/stringlib/formatter.h ++++ b/Objects/stringlib/formatter.h +@@ -928,7 +928,7 @@ + Py_ssize_t n_total; + int has_decimal; + double val; +- Py_ssize_t precision = format->precision; ++ Py_ssize_t precision; + Py_ssize_t default_precision = 6; + STRINGLIB_CHAR type = format->type; + int add_pct = 0; +@@ -947,6 +947,12 @@ + from a hard-code pseudo-locale */ + LocaleInfo locale; + ++ if (format->precision > INT_MAX) { ++ PyErr_SetString(PyExc_ValueError, "precision too big"); ++ goto done; ++ } ++ precision = (int)format->precision; ++ + /* Alternate is not allowed on floats. */ + if (format->alternate) { + PyErr_SetString(PyExc_ValueError, +@@ -1078,7 +1084,7 @@ + Py_ssize_t n_im_total; + int re_has_decimal; + int im_has_decimal; +- Py_ssize_t precision = format->precision; ++ Py_ssize_t precision; + Py_ssize_t default_precision = 6; + STRINGLIB_CHAR type = format->type; + STRINGLIB_CHAR *p_re; +@@ -1107,6 +1113,12 @@ + from a hard-code pseudo-locale */ + LocaleInfo locale; + ++ if (format->precision > INT_MAX) { ++ PyErr_SetString(PyExc_ValueError, "precision too big"); ++ goto done; ++ } ++ precision = (int)format->precision; ++ + /* Alternate is not allowed on complex. */ + if (format->alternate) { + PyErr_SetString(PyExc_ValueError, +diff -r ab05e7dd2788 Objects/stringobject.c +--- a/Objects/stringobject.c ++++ b/Objects/stringobject.c +@@ -882,9 +882,9 @@ + size -= chunk_size; + } + #ifdef __VMS +- if (size) fwrite(data, (int)size, 1, fp); ++ if (size) fwrite(data, (size_t)size, 1, fp); + #else +- fwrite(data, 1, (int)size, fp); ++ fwrite(data, 1, (size_t)size, fp); + #endif + Py_END_ALLOW_THREADS + return 0; +@@ -1255,7 +1255,6 @@ + PyStringObject *a = (PyStringObject*) o1; + PyStringObject *b = (PyStringObject*) o2; + return Py_SIZE(a) == Py_SIZE(b) +- && *a->ob_sval == *b->ob_sval + && memcmp(a->ob_sval, b->ob_sval, Py_SIZE(a)) == 0; + } + +@@ -2332,7 +2331,7 @@ + } + + Py_LOCAL_INLINE(Py_ssize_t) +-countchar(const char *target, int target_len, char c, Py_ssize_t maxcount) ++countchar(const char *target, Py_ssize_t target_len, char c, Py_ssize_t maxcount) + { + Py_ssize_t count=0; + const char *start=target; +diff -r ab05e7dd2788 Objects/unicodeobject.c +--- a/Objects/unicodeobject.c ++++ b/Objects/unicodeobject.c +@@ -547,6 +547,37 @@ + return PyUnicode_FromStringAndSize(u, size); + } + ++/* _Py_UNICODE_NEXT is a private macro used to retrieve the character pointed ++ * by 'ptr', possibly combining surrogate pairs on narrow builds. ++ * 'ptr' and 'end' must be Py_UNICODE*, with 'ptr' pointing at the character ++ * that should be returned and 'end' pointing to the end of the buffer. ++ * ('end' is used on narrow builds to detect a lone surrogate at the ++ * end of the buffer that should be returned unchanged.) ++ * The ptr and end arguments should be side-effect free and ptr must an lvalue. ++ * The type of the returned char is always Py_UCS4. ++ * ++ * Note: the macro advances ptr to next char, so it might have side-effects ++ * (especially if used with other macros). ++ */ ++ ++/* helper macros used by _Py_UNICODE_NEXT */ ++#define _Py_UNICODE_IS_HIGH_SURROGATE(ch) (0xD800 <= ch && ch <= 0xDBFF) ++#define _Py_UNICODE_IS_LOW_SURROGATE(ch) (0xDC00 <= ch && ch <= 0xDFFF) ++/* Join two surrogate characters and return a single Py_UCS4 value. */ ++#define _Py_UNICODE_JOIN_SURROGATES(high, low) \ ++ (((((Py_UCS4)(high) & 0x03FF) << 10) | \ ++ ((Py_UCS4)(low) & 0x03FF)) + 0x10000) ++ ++#ifdef Py_UNICODE_WIDE ++#define _Py_UNICODE_NEXT(ptr, end) *(ptr)++ ++#else ++#define _Py_UNICODE_NEXT(ptr, end) \ ++ (((_Py_UNICODE_IS_HIGH_SURROGATE(*(ptr)) && (ptr) < (end)) && \ ++ _Py_UNICODE_IS_LOW_SURROGATE((ptr)[1])) ? \ ++ ((ptr) += 2,_Py_UNICODE_JOIN_SURROGATES((ptr)[-2], (ptr)[-1])) : \ ++ (Py_UCS4)*(ptr)++) ++#endif ++ + #ifdef HAVE_WCHAR_H + + #if (Py_UNICODE_SIZE == 2) && defined(SIZEOF_WCHAR_T) && (SIZEOF_WCHAR_T == 4) +@@ -740,8 +771,25 @@ + + switch (*f) { + case 'c': +- (void)va_arg(count, int); ++ { ++ int ordinal = va_arg(count, int); ++#ifdef Py_UNICODE_WIDE ++ if (ordinal < 0 || ordinal > 0x10ffff) { ++ PyErr_SetString(PyExc_OverflowError, ++ "%c arg not in range(0x110000) " ++ "(wide Python build)"); ++ goto fail; ++ } ++#else ++ if (ordinal < 0 || ordinal > 0xffff) { ++ PyErr_SetString(PyExc_OverflowError, ++ "%c arg not in range(0x10000) " ++ "(narrow Python build)"); ++ goto fail; ++ } ++#endif + /* fall through... */ ++ } + case '%': + n++; + break; +@@ -3625,26 +3673,22 @@ + case 4: /* xmlcharrefreplace */ + respos = str-PyString_AS_STRING(res); + /* determine replacement size (temporarily (mis)uses p) */ +- for (p = collstart, repsize = 0; p < collend; ++p) { +- if (*p<10) ++ for (p = collstart, repsize = 0; p < collend;) { ++ Py_UCS4 ch = _Py_UNICODE_NEXT(p, collend); ++ if (ch < 10) + repsize += 2+1+1; +- else if (*p<100) ++ else if (ch < 100) + repsize += 2+2+1; +- else if (*p<1000) ++ else if (ch < 1000) + repsize += 2+3+1; +- else if (*p<10000) ++ else if (ch < 10000) + repsize += 2+4+1; +-#ifndef Py_UNICODE_WIDE +- else ++ else if (ch < 100000) + repsize += 2+5+1; +-#else +- else if (*p<100000) +- repsize += 2+5+1; +- else if (*p<1000000) ++ else if (ch < 1000000) + repsize += 2+6+1; + else + repsize += 2+7+1; +-#endif + } + requiredsize = respos+repsize+(endp-collend); + if (requiredsize > ressize) { +@@ -3656,8 +3700,9 @@ + ressize = requiredsize; + } + /* generate replacement (temporarily (mis)uses p) */ +- for (p = collstart; p < collend; ++p) { +- str += sprintf(str, "&#%d;", (int)*p); ++ for (p = collstart; p < collend;) { ++ Py_UCS4 ch = _Py_UNICODE_NEXT(p, collend); ++ str += sprintf(str, "&#%d;", (int)ch); + } + p = collend; + break; +@@ -4632,11 +4677,20 @@ + *inpos = collendpos; + break; + case 4: /* xmlcharrefreplace */ +- /* generate replacement (temporarily (mis)uses p) */ +- for (collpos = collstartpos; collpos < collendpos; ++collpos) { ++ /* generate replacement */ ++ for (collpos = collstartpos; collpos < collendpos;) { + char buffer[2+29+1+1]; + char *cp; +- sprintf(buffer, "&#%d;", (int)p[collpos]); ++ Py_UCS4 ch = p[collpos++]; ++#ifndef Py_UNICODE_WIDE ++ if ((0xD800 <= ch && ch <= 0xDBFF) && ++ (collpos < collendpos) && ++ (0xDC00 <= p[collpos] && p[collpos] <= 0xDFFF)) { ++ ch = ((((ch & 0x03FF) << 10) | ++ ((Py_UCS4)p[collpos++] & 0x03FF)) + 0x10000); ++ } ++#endif ++ sprintf(buffer, "&#%d;", (int)ch); + for (cp = buffer; *cp; ++cp) { + x = charmapencode_output(*cp, mapping, res, respos); + if (x==enc_EXCEPTION) +@@ -5051,10 +5105,11 @@ + break; + case 4: /* xmlcharrefreplace */ + /* generate replacement (temporarily (mis)uses p) */ +- for (p = collstart; p < collend; ++p) { ++ for (p = collstart; p < collend;) { + char buffer[2+29+1+1]; + char *cp; +- sprintf(buffer, "&#%d;", (int)*p); ++ Py_UCS4 ch = _Py_UNICODE_NEXT(p, collend); ++ sprintf(buffer, "&#%d;", (int)ch); + if (charmaptranslate_makespace(&res, &str, + (str-PyUnicode_AS_UNICODE(res))+strlen(buffer)+(endp-collend))) + goto onError; +@@ -5205,8 +5260,10 @@ + break; + case 4: /* xmlcharrefreplace */ + /* generate replacement (temporarily (mis)uses p) */ +- for (p = collstart; p < collend; ++p) +- output += sprintf(output, "&#%d;", (int)*p); ++ for (p = collstart; p < collend;) { ++ Py_UCS4 ch = _Py_UNICODE_NEXT(p, collend); ++ output += sprintf(output, "&#%d;", ch); ++ } + p = collend; + break; + default: +diff -r ab05e7dd2788 PC/_subprocess.c +--- a/PC/_subprocess.c ++++ b/PC/_subprocess.c +@@ -331,7 +331,7 @@ + PyObject* values; + char* p; + +- /* convert environment dictionary to windows enviroment string */ ++ /* convert environment dictionary to windows environment string */ + if (! PyMapping_Check(environment)) { + PyErr_SetString( + PyExc_TypeError, "environment must be dictionary or None"); +diff -r ab05e7dd2788 PCbuild/readme.txt +--- a/PCbuild/readme.txt ++++ b/PCbuild/readme.txt +@@ -262,7 +262,7 @@ + In addition, you need the Visual Studio plugin for external C compilers, + from http://sf.net/projects/vsextcomp. The plugin will wrap cl.exe, to + locate the proper target compiler, and convert compiler options +-accordingly. The project files require atleast version 0.9. ++accordingly. The project files require at least version 0.9. + + Building for AMD64 + ------------------ +diff -r ab05e7dd2788 Parser/asdl_c.py +--- a/Parser/asdl_c.py ++++ b/Parser/asdl_c.py +@@ -977,7 +977,7 @@ + + + class StaticVisitor(PickleVisitor): +- CODE = '''Very simple, always emit this static code. Overide CODE''' ++ CODE = '''Very simple, always emit this static code. Override CODE''' + + def visit(self, object): + self.emit(self.CODE, 0, reflow=False) +diff -r ab05e7dd2788 Parser/tokenizer.c +--- a/Parser/tokenizer.c ++++ b/Parser/tokenizer.c +@@ -277,8 +277,11 @@ + tok->encoding = cs; + tok->decoding_state = -1; + } +- else ++ else { ++ PyErr_Format(PyExc_SyntaxError, ++ "encoding problem: %s", cs); + PyMem_FREE(cs); ++ } + #else + /* Without Unicode support, we cannot + process the coding spec. Since there +@@ -289,15 +292,12 @@ + } + } else { /* then, compare cs with BOM */ + r = (strcmp(tok->encoding, cs) == 0); ++ if (!r) ++ PyErr_Format(PyExc_SyntaxError, ++ "encoding problem: %s with BOM", cs); + PyMem_FREE(cs); + } + } +- if (!r) { +- cs = tok->encoding; +- if (!cs) +- cs = "with BOM"; +- PyErr_Format(PyExc_SyntaxError, "encoding problem: %s", cs); +- } + return r; + } + +diff -r ab05e7dd2788 Python/bltinmodule.c +--- a/Python/bltinmodule.c ++++ b/Python/bltinmodule.c +@@ -2434,9 +2434,9 @@ + PyDoc_STRVAR(sum_doc, + "sum(sequence[, start]) -> value\n\ + \n\ +-Returns the sum of a sequence of numbers (NOT strings) plus the value\n\ ++Return the sum of a sequence of numbers (NOT strings) plus the value\n\ + of parameter 'start' (which defaults to 0). When the sequence is\n\ +-empty, returns start."); ++empty, return start."); + + + static PyObject * +diff -r ab05e7dd2788 Python/codecs.c +--- a/Python/codecs.c ++++ b/Python/codecs.c +@@ -521,7 +521,7 @@ + Py_UNICODE res = Py_UNICODE_REPLACEMENT_CHARACTER; + if (PyUnicodeDecodeError_GetEnd(exc, &end)) + return NULL; +- return Py_BuildValue("(u#n)", &res, 1, end); ++ return Py_BuildValue("(u#n)", &res, (Py_ssize_t)1, end); + } + else if (PyObject_IsInstance(exc, PyExc_UnicodeTranslateError)) { + PyObject *res; +@@ -556,6 +556,7 @@ + PyObject *res; + Py_UNICODE *p; + Py_UNICODE *startp; ++ Py_UNICODE *e; + Py_UNICODE *outp; + int ressize; + if (PyUnicodeEncodeError_GetStart(exc, &start)) +@@ -565,26 +566,31 @@ + if (!(object = PyUnicodeEncodeError_GetObject(exc))) + return NULL; + startp = PyUnicode_AS_UNICODE(object); +- for (p = startp+start, ressize = 0; p < startp+end; ++p) { +- if (*p<10) ++ e = startp + end; ++ for (p = startp+start, ressize = 0; p < e;) { ++ Py_UCS4 ch = *p++; ++#ifndef Py_UNICODE_WIDE ++ if ((0xD800 <= ch && ch <= 0xDBFF) && ++ (p < e) && ++ (0xDC00 <= *p && *p <= 0xDFFF)) { ++ ch = ((((ch & 0x03FF) << 10) | ++ ((Py_UCS4)*p++ & 0x03FF)) + 0x10000); ++ } ++#endif ++ if (ch < 10) + ressize += 2+1+1; +- else if (*p<100) ++ else if (ch < 100) + ressize += 2+2+1; +- else if (*p<1000) ++ else if (ch < 1000) + ressize += 2+3+1; +- else if (*p<10000) ++ else if (ch < 10000) + ressize += 2+4+1; +-#ifndef Py_UNICODE_WIDE +- else ++ else if (ch < 100000) + ressize += 2+5+1; +-#else +- else if (*p<100000) +- ressize += 2+5+1; +- else if (*p<1000000) ++ else if (ch < 1000000) + ressize += 2+6+1; + else + ressize += 2+7+1; +-#endif + } + /* allocate replacement */ + res = PyUnicode_FromUnicode(NULL, ressize); +@@ -593,40 +599,41 @@ + return NULL; + } + /* generate replacement */ +- for (p = startp+start, outp = PyUnicode_AS_UNICODE(res); +- p < startp+end; ++p) { +- Py_UNICODE c = *p; ++ for (p = startp+start, outp = PyUnicode_AS_UNICODE(res); p < e;) { + int digits; + int base; ++ Py_UCS4 ch = *p++; ++#ifndef Py_UNICODE_WIDE ++ if ((0xD800 <= ch && ch <= 0xDBFF) && ++ (p < startp+end) && ++ (0xDC00 <= *p && *p <= 0xDFFF)) { ++ ch = ((((ch & 0x03FF) << 10) | ++ ((Py_UCS4)*p++ & 0x03FF)) + 0x10000); ++ } ++#endif + *outp++ = '&'; + *outp++ = '#'; +- if (*p<10) { ++ if (ch < 10) { + digits = 1; + base = 1; + } +- else if (*p<100) { ++ else if (ch < 100) { + digits = 2; + base = 10; + } +- else if (*p<1000) { ++ else if (ch < 1000) { + digits = 3; + base = 100; + } +- else if (*p<10000) { ++ else if (ch < 10000) { + digits = 4; + base = 1000; + } +-#ifndef Py_UNICODE_WIDE +- else { ++ else if (ch < 100000) { + digits = 5; + base = 10000; + } +-#else +- else if (*p<100000) { +- digits = 5; +- base = 10000; +- } +- else if (*p<1000000) { ++ else if (ch < 1000000) { + digits = 6; + base = 100000; + } +@@ -634,10 +641,9 @@ + digits = 7; + base = 1000000; + } +-#endif + while (digits-->0) { +- *outp++ = '0' + c/base; +- c %= base; ++ *outp++ = '0' + ch/base; ++ ch %= base; + base /= 10; + } + *outp++ = ';'; +diff -r ab05e7dd2788 Python/marshal.c +--- a/Python/marshal.c ++++ b/Python/marshal.c +@@ -88,7 +88,7 @@ + } + + static void +-w_string(char *s, Py_ssize_t n, WFILE *p) ++w_string(const char *s, Py_ssize_t n, WFILE *p) + { + if (p->fp != NULL) { + fwrite(s, 1, n, p->fp); +@@ -141,6 +141,13 @@ + # define W_SIZE w_long + #endif + ++static void ++w_pstring(const char *s, Py_ssize_t n, WFILE *p) ++{ ++ W_SIZE(n, p); ++ w_string(s, n, p); ++} ++ + /* We assume that Python longs are stored internally in base some power of + 2**15; for the sake of portability we'll always read and write them in base + exactly 2**15. */ +@@ -338,9 +345,7 @@ + else { + w_byte(TYPE_STRING, p); + } +- n = PyString_GET_SIZE(v); +- W_SIZE(n, p); +- w_string(PyString_AS_STRING(v), n, p); ++ w_pstring(PyBytes_AS_STRING(v), PyString_GET_SIZE(v), p); + } + #ifdef Py_USING_UNICODE + else if (PyUnicode_CheckExact(v)) { +@@ -352,9 +357,7 @@ + return; + } + w_byte(TYPE_UNICODE, p); +- n = PyString_GET_SIZE(utf8); +- W_SIZE(n, p); +- w_string(PyString_AS_STRING(utf8), n, p); ++ w_pstring(PyString_AS_STRING(utf8), PyString_GET_SIZE(utf8), p); + Py_DECREF(utf8); + } + #endif +@@ -441,8 +444,7 @@ + PyBufferProcs *pb = v->ob_type->tp_as_buffer; + w_byte(TYPE_STRING, p); + n = (*pb->bf_getreadbuffer)(v, 0, (void **)&s); +- W_SIZE(n, p); +- w_string(s, n, p); ++ w_pstring(s, n, p); + } + else { + w_byte(TYPE_UNKNOWN, p); +diff -r ab05e7dd2788 Python/random.c +--- a/Python/random.c ++++ b/Python/random.c +@@ -165,8 +165,12 @@ + Py_END_ALLOW_THREADS + if (fd < 0) + { +- PyErr_SetString(PyExc_NotImplementedError, +- "/dev/urandom (or equivalent) not found"); ++ if (errno == ENOENT || errno == ENXIO || ++ errno == ENODEV || errno == EACCES) ++ PyErr_SetString(PyExc_NotImplementedError, ++ "/dev/urandom (or equivalent) not found"); ++ else ++ PyErr_SetFromErrno(PyExc_OSError); + return -1; + } + +diff -r ab05e7dd2788 Python/sysmodule.c +--- a/Python/sysmodule.c ++++ b/Python/sysmodule.c +@@ -219,7 +219,7 @@ + \n\ + Exit the interpreter by raising SystemExit(status).\n\ + If the status is omitted or None, it defaults to zero (i.e., success).\n\ +-If the status is numeric, it will be used as the system exit status.\n\ ++If the status is an integer, it will be used as the system exit status.\n\ + If it is another kind of object, it will be printed and the system\n\ + exit status will be one (i.e., failure)." + ); +diff -r ab05e7dd2788 Python/thread_pthread.h +--- a/Python/thread_pthread.h ++++ b/Python/thread_pthread.h +@@ -145,6 +145,7 @@ + PyThread__init_thread(void) + { + #if defined(_AIX) && defined(__GNUC__) ++ extern void pthread_init(void); + pthread_init(); + #endif + } +@@ -394,6 +395,7 @@ + pthread_lock *thelock = (pthread_lock *)lock; + int status, error = 0; + ++ (void) error; /* silence unused-but-set-variable warning */ + dprintf(("PyThread_free_lock(%p) called\n", lock)); + + status = pthread_mutex_destroy( &thelock->mut ); +@@ -445,6 +447,7 @@ + pthread_lock *thelock = (pthread_lock *)lock; + int status, error = 0; + ++ (void) error; /* silence unused-but-set-variable warning */ + dprintf(("PyThread_release_lock(%p) called\n", lock)); + + status = pthread_mutex_lock( &thelock->mut ); +diff -r ab05e7dd2788 README +--- a/README ++++ b/README +@@ -89,6 +89,13 @@ + primarily for documentation authors, translators, and people with special + formatting requirements. + ++If you would like to contribute to the development of Python, relevant ++documentation is available at: ++ ++ http://docs.python.org/devguide/ ++ ++For information about building Python's documentation, refer to Doc/README.txt. ++ + + Web sites + --------- +diff -r ab05e7dd2788 Tools/freeze/checkextensions_win32.py +--- a/Tools/freeze/checkextensions_win32.py ++++ b/Tools/freeze/checkextensions_win32.py +@@ -3,7 +3,7 @@ + Under Windows it is unlikely the .obj files are of use, as special compiler options + are needed (primarily to toggle the behavior of "public" symbols. + +-I dont consider it worth parsing the MSVC makefiles for compiler options. Even if ++I don't consider it worth parsing the MSVC makefiles for compiler options. Even if + we get it just right, a specific freeze application may have specific compiler + options anyway (eg, to enable or disable specific functionality) + +@@ -14,7 +14,7 @@ + your own). + * This description can include: + - The MSVC .dsp file for the extension. The .c source file names +- are extraced from there. ++ are extracted from there. + - Specific compiler/linker options + - Flag to indicate if Unicode compilation is expected. + +diff -r ab05e7dd2788 Tools/freeze/makefreeze.py +--- a/Tools/freeze/makefreeze.py ++++ b/Tools/freeze/makefreeze.py +@@ -62,7 +62,7 @@ + outfp.write('\t{"%s", M_%s, %d},\n' % (mod, mangled, size)) + outfp.write('\n') + # The following modules have a NULL code pointer, indicating +- # that the prozen program should not search for them on the host ++ # that the frozen program should not search for them on the host + # system. Importing them will *always* raise an ImportError. + # The zero value size is never used. + for mod in fail_import: +diff -r ab05e7dd2788 Tools/gdb/libpython.py +--- a/Tools/gdb/libpython.py ++++ b/Tools/gdb/libpython.py +@@ -617,7 +617,7 @@ + def iteritems(self): + ''' + Yields a sequence of (PyObjectPtr key, PyObjectPtr value) pairs, +- analagous to dict.iteritems() ++ analogous to dict.iteritems() + ''' + for i in safe_range(self.field('ma_mask') + 1): + ep = self.field('ma_table') + i +diff -r ab05e7dd2788 Tools/i18n/msgfmt.py +--- a/Tools/i18n/msgfmt.py ++++ b/Tools/i18n/msgfmt.py +@@ -144,7 +144,7 @@ + # This is a message with plural forms + elif l.startswith('msgid_plural'): + if section != ID: +- print >> sys.stderr, 'msgid_plural not preceeded by msgid on %s:%d' %\ ++ print >> sys.stderr, 'msgid_plural not preceded by msgid on %s:%d' %\ + (infile, lno) + sys.exit(1) + l = l[12:] +diff -r ab05e7dd2788 Tools/msi/msi.py +--- a/Tools/msi/msi.py ++++ b/Tools/msi/msi.py +@@ -1392,7 +1392,10 @@ + # certname (from config.py) should be (a substring of) + # the certificate subject, e.g. "Python Software Foundation" + if certname: +- os.system('signtool sign /n "%s" /t http://timestamp.verisign.com/scripts/timestamp.dll %s' % (certname, msiname)) ++ os.system('signtool sign /n "%s" ' ++ '/t http://timestamp.verisign.com/scripts/timestamp.dll ' ++ '/d "Python %s" ' ++ '%s' % (certname, full_current_version, msiname)) + + if pdbzip: + build_pdbzip() +diff -r ab05e7dd2788 Tools/msi/msilib.py +--- a/Tools/msi/msilib.py ++++ b/Tools/msi/msilib.py +@@ -305,7 +305,7 @@ + t.create(db) + # Fill the validation table + add_data(db, "_Validation", schema._Validation_records) +- # Initialize the summary information, allowing atmost 20 properties ++ # Initialize the summary information, allowing at most 20 properties + si = db.GetSummaryInformation(20) + si.SetProperty(PID_TITLE, "Installation Database") + si.SetProperty(PID_SUBJECT, ProductName) +diff -r ab05e7dd2788 Tools/msi/uuids.py +--- a/Tools/msi/uuids.py ++++ b/Tools/msi/uuids.py +@@ -60,4 +60,7 @@ + '2.7.3150':'{C0C31BCC-56FB-42a7-8766-D29E1BD74C7C}', # 2.7.3 + '2.7.4121':'{47F45F45-72D7-4e54-AF41-26767EDE95CF}', # 2.7.4rc1 + '2.7.4150':'{84ADC96C-B7E0-4938-9D6E-2B640D5DA224}', # 2.7.4 ++ '2.7.5150':'{DBDD570E-0952-475f-9453-AB88F3DD5659}', # 2.7.5 ++ '2.7.6121':'{D1EBC07F-A7B1-4163-83DB-AE813CEF392F}', # 2.7.6rc1 ++ '2.7.6150':'{C3CC4DF5-39A5-4027-B136-2B3E1F5AB6E2}', # 2.7.6 + } +diff -r ab05e7dd2788 Tools/pybench/CommandLine.py +--- a/Tools/pybench/CommandLine.py ++++ b/Tools/pybench/CommandLine.py +@@ -458,7 +458,7 @@ + handler = getattr(self, handlername) + except AttributeError: + if value == '': +- # count the number of occurances ++ # count the number of occurrences + if values.has_key(optionname): + values[optionname] = values[optionname] + 1 + else: +diff -r ab05e7dd2788 Tools/pybench/systimes.py +--- a/Tools/pybench/systimes.py ++++ b/Tools/pybench/systimes.py +@@ -5,7 +5,7 @@ + + This module implements various different strategies for measuring + performance timings. It tries to choose the best available method +- based on the platforma and available tools. ++ based on the platform and available tools. + + On Windows, it is recommended to have the Mark Hammond win32 + package installed. Alternatively, the Thomas Heller ctypes +diff -r ab05e7dd2788 Tools/pynche/DetailsViewer.py +--- a/Tools/pynche/DetailsViewer.py ++++ b/Tools/pynche/DetailsViewer.py +@@ -26,7 +26,7 @@ + other side. Thus if red were at 238 and 25 were added to it, red + would have the value 7. + +- Preseve Distance ++ Preserve Distance + When the increment or decrement would send any of the tied variations + out of bounds, all tied variations are wrapped as one, so as to + preserve the distance between them. Thus if green and blue were tied, +diff -r ab05e7dd2788 Tools/scripts/findnocoding.py +--- a/Tools/scripts/findnocoding.py ++++ b/Tools/scripts/findnocoding.py +@@ -32,13 +32,13 @@ + "no sophisticated Python source file search will be done.") + + +-decl_re = re.compile(r"coding[=:]\s*([-\w.]+)") ++decl_re = re.compile(r'^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)') + + def get_declaration(line): +- match = decl_re.search(line) ++ match = decl_re.match(line) + if match: + return match.group(1) +- return '' ++ return b'' + + def has_correct_encoding(text, codec): + try: +diff -r ab05e7dd2788 Tools/scripts/fixnotice.py +--- a/Tools/scripts/fixnotice.py ++++ b/Tools/scripts/fixnotice.py +@@ -2,7 +2,7 @@ + + """(Ostensibly) fix copyright notices in files. + +-Actually, this sript will simply replace a block of text in a file from one ++Actually, this script will simply replace a block of text in a file from one + string to another. It will only do this once though, i.e. not globally + throughout the file. It writes a backup file and then does an os.rename() + dance for atomicity. +diff -r ab05e7dd2788 Tools/scripts/ifdef.py +--- a/Tools/scripts/ifdef.py ++++ b/Tools/scripts/ifdef.py +@@ -9,11 +9,11 @@ + # options. On standard output it writes a copy of the input file(s) + # minus those code sections that are suppressed by the selected + # combination of defined/undefined symbols. The #if(n)def/#else/#else +-# lines themselfs (if the #if(n)def tests for one of the mentioned ++# lines themselves (if the #if(n)def tests for one of the mentioned + # names) are removed as well. + + # Features: Arbitrary nesting of recognized and unrecognized +-# preprocesor statements works correctly. Unrecognized #if* commands ++# preprocessor statements works correctly. Unrecognized #if* commands + # are left in place, so it will never remove too much, only too + # little. It does accept whitespace around the '#' character. + +diff -r ab05e7dd2788 Tools/scripts/patchcheck.py +--- a/Tools/scripts/patchcheck.py ++++ b/Tools/scripts/patchcheck.py +@@ -144,13 +144,13 @@ + @status("Misc/ACKS updated", modal=True) + def credit_given(file_paths): + """Check if Misc/ACKS has been changed.""" +- return 'Misc/ACKS' in file_paths ++ return os.path.join('Misc', 'ACKS') in file_paths + + + @status("Misc/NEWS updated", modal=True) + def reported_news(file_paths): + """Check if Misc/NEWS has been changed.""" +- return 'Misc/NEWS' in file_paths ++ return os.path.join('Misc', 'NEWS') in file_paths + + + def main(): +@@ -158,7 +158,8 @@ + python_files = [fn for fn in file_paths if fn.endswith('.py')] + c_files = [fn for fn in file_paths if fn.endswith(('.c', '.h'))] + doc_files = [fn for fn in file_paths if fn.startswith('Doc')] +- special_files = {'Misc/ACKS', 'Misc/NEWS'} & set(file_paths) ++ misc_files = {os.path.join('Misc', 'ACKS'), os.path.join('Misc', 'NEWS')}\ ++ & set(file_paths) + # PEP 8 whitespace rules enforcement. + normalize_whitespace(python_files) + # C rules enforcement. +@@ -168,9 +169,9 @@ + # Docs updated. + docs_modified(doc_files) + # Misc/ACKS changed. +- credit_given(special_files) ++ credit_given(misc_files) + # Misc/NEWS changed. +- reported_news(special_files) ++ reported_news(misc_files) + + # Test suite run and passed. + if python_files or c_files: +diff -r ab05e7dd2788 Tools/scripts/pathfix.py +--- a/Tools/scripts/pathfix.py ++++ b/Tools/scripts/pathfix.py +@@ -135,7 +135,7 @@ + except os.error, msg: + err('%s: rename failed (%r)\n' % (filename, msg)) + return 1 +- # Return succes ++ # Return success + return 0 + + def fixline(line): +diff -r ab05e7dd2788 configure.ac +--- a/configure.ac ++++ b/configure.ac +@@ -145,6 +145,7 @@ + AC_SUBST(UNIVERSALSDK) + + AC_SUBST(ARCH_RUN_32BIT) ++ARCH_RUN_32BIT="" + + UNIVERSAL_ARCHS="32-bit" + AC_SUBST(LIPO_32BIT_FLAGS) +@@ -1518,7 +1519,7 @@ + sys/termio.h sys/time.h \ + sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \ + sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ +-bluetooth/bluetooth.h linux/tipc.h spawn.h util.h) ++bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h) + AC_HEADER_DIRENT + AC_HEADER_MAJOR + +@@ -1801,7 +1802,6 @@ + esac + + +-ARCH_RUN_32BIT="" + AC_SUBST(LIBTOOL_CRUFT) + case $ac_sys_system/$ac_sys_release in + Darwin/@<:@01567@:>@\..*) +@@ -2569,6 +2569,7 @@ + [Define if pthread_sigmask() does not work on your system.]) + ;; + esac]) ++ AC_CHECK_FUNCS(pthread_atfork) + fi + + +diff -r ab05e7dd2788 pyconfig.h.in +--- a/pyconfig.h.in ++++ b/pyconfig.h.in +@@ -55,6 +55,9 @@ + /* Define to 1 if you have the `alarm' function. */ + #undef HAVE_ALARM + ++/* Define to 1 if you have the header file. */ ++#undef HAVE_ALLOCA_H ++ + /* Define this if your time.h defines altzone. */ + #undef HAVE_ALTZONE + +@@ -517,6 +520,9 @@ + /* Define if you have GNU PTH threads. */ + #undef HAVE_PTH + ++/* Define to 1 if you have the `pthread_atfork' function. */ ++#undef HAVE_PTHREAD_ATFORK ++ + /* Defined for Solaris 2.6 bug in pthread header. */ + #undef HAVE_PTHREAD_DESTRUCTOR + +diff -r ab05e7dd2788 setup.py +--- a/setup.py ++++ b/setup.py +@@ -437,9 +437,11 @@ + + def detect_modules(self): + # Ensure that /usr/local is always used +- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') +- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') +- self.add_gcc_paths() ++ if not cross_compiling: ++ add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') ++ add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') ++ if cross_compiling: ++ self.add_gcc_paths() + self.add_multiarch_paths() + + # Add paths specified in the environment variables LDFLAGS and --- python2.7-2.7.5.orig/debian/patches/ncursesw-incdir.diff +++ python2.7-2.7.5/debian/patches/ncursesw-incdir.diff @@ -0,0 +1,66 @@ +# DP: use the correct include directory when linking with ncursesw. + +--- a/setup.py ++++ b/setup.py +@@ -1346,13 +1346,17 @@ + # Curses support, requiring the System V version of curses, often + # provided by the ncurses library. + panel_library = 'panel' ++ curses_incs = None + if curses_library.startswith('ncurses'): + if curses_library == 'ncursesw': + # Bug 1464056: If _curses.so links with ncursesw, + # _curses_panel.so must link with panelw. + panel_library = 'panelw' + curses_libs = [curses_library] ++ curses_incs = find_file('curses.h', inc_dirs, ++ [os.path.join(d, 'ncursesw') for d in inc_dirs]) + exts.append( Extension('_curses', ['_cursesmodule.c'], ++ include_dirs = curses_incs, + libraries = curses_libs) ) + elif curses_library == 'curses' and host_platform != 'darwin': + # OSX has an old Berkeley curses, not good enough for +@@ -1373,6 +1377,7 @@ + if (module_enabled(exts, '_curses') and + self.compiler.find_library_file(lib_dirs, panel_library)): + exts.append( Extension('_curses_panel', ['_curses_panel.c'], ++ include_dirs = curses_incs, + libraries = [panel_library] + curses_libs) ) + else: + missing.append('_curses_panel') +--- a/configure.ac ++++ b/configure.ac +@@ -1513,6 +1513,8 @@ + + # checks for header files + AC_HEADER_STDC ++ac_save_cppflags="$CPPFLAGS" ++CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" + AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \ + fcntl.h grp.h \ + ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \ +@@ -1534,6 +1536,7 @@ + #include + #endif + ]) ++CPPFLAGS=$ac_save_cppflags + + # On Linux, netlink.h requires asm/types.h + AC_CHECK_HEADERS(linux/netlink.h,,,[ +@@ -4282,6 +4285,8 @@ + [Define if you have struct stat.st_mtimensec]) + fi + ++ac_save_cppflags="$CPPFLAGS" ++CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" + # On HP/UX 11.0, mvwdelch is a block with a return statement + AC_MSG_CHECKING(whether mvwdelch is an expression) + AC_CACHE_VAL(ac_cv_mvwdelch_is_expression, +@@ -4336,6 +4341,7 @@ + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no)] + ) ++CPPFLAGS=$ac_save_cppflags + + AC_MSG_NOTICE([checking for device files]) + --- python2.7-2.7.5.orig/debian/patches/plat-linux2_hppa.diff +++ python2.7-2.7.5/debian/patches/plat-linux2_hppa.diff @@ -0,0 +1,72 @@ +Index: Lib/plat-linux2/IN.py +=================================================================== +--- ./Lib/plat-linux2/IN.py (Revision 77754) ++++ ./Lib/plat-linux2/IN.py (Arbeitskopie) +@@ -442,37 +442,37 @@ + SIOCGPGRP = 0x8904 + SIOCATMARK = 0x8905 + SIOCGSTAMP = 0x8906 +-SOL_SOCKET = 1 +-SO_DEBUG = 1 +-SO_REUSEADDR = 2 +-SO_TYPE = 3 +-SO_ERROR = 4 +-SO_DONTROUTE = 5 +-SO_BROADCAST = 6 +-SO_SNDBUF = 7 +-SO_RCVBUF = 8 +-SO_KEEPALIVE = 9 +-SO_OOBINLINE = 10 +-SO_NO_CHECK = 11 +-SO_PRIORITY = 12 +-SO_LINGER = 13 +-SO_BSDCOMPAT = 14 +-SO_PASSCRED = 16 +-SO_PEERCRED = 17 +-SO_RCVLOWAT = 18 +-SO_SNDLOWAT = 19 +-SO_RCVTIMEO = 20 +-SO_SNDTIMEO = 21 +-SO_SECURITY_AUTHENTICATION = 22 +-SO_SECURITY_ENCRYPTION_TRANSPORT = 23 +-SO_SECURITY_ENCRYPTION_NETWORK = 24 +-SO_BINDTODEVICE = 25 +-SO_ATTACH_FILTER = 26 +-SO_DETACH_FILTER = 27 +-SO_PEERNAME = 28 +-SO_TIMESTAMP = 29 ++SOL_SOCKET = 0xffff ++SO_DEBUG = 0x0001 ++SO_REUSEADDR = 0x0004 ++SO_TYPE = 0x1008 ++SO_ERROR = 0x1007 ++SO_DONTROUTE = 0x0010 ++SO_BROADCAST = 0x0020 ++SO_SNDBUF = 0x1001 ++SO_RCVBUF = 0x1002 ++SO_KEEPALIVE = 0x0008 ++SO_OOBINLINE = 0x0100 ++SO_NO_CHECK = 0x400b ++SO_PRIORITY = 0x400c ++SO_LINGER = 0x0080 ++SO_BSDCOMPAT = 0x400e ++SO_PASSCRED = 0x4010 ++SO_PEERCRED = 0x4011 ++SO_RCVLOWAT = 0x1004 ++SO_SNDLOWAT = 0x1003 ++SO_RCVTIMEO = 0x1006 ++SO_SNDTIMEO = 0x1005 ++SO_SECURITY_AUTHENTICATION = 0x4016 ++SO_SECURITY_ENCRYPTION_TRANSPORT = 0x4017 ++SO_SECURITY_ENCRYPTION_NETWORK = 0x4018 ++SO_BINDTODEVICE = 0x4019 ++SO_ATTACH_FILTER = 0x401a ++SO_DETACH_FILTER = 0x401b ++SO_PEERNAME = 0x2000 ++SO_TIMESTAMP = 0x4012 + SCM_TIMESTAMP = SO_TIMESTAMP +-SO_ACCEPTCONN = 30 ++SO_ACCEPTCONN = 0x401c + SOCK_STREAM = 1 + SOCK_DGRAM = 2 + SOCK_RAW = 3 --- python2.7-2.7.5.orig/debian/patches/link-opt.diff +++ python2.7-2.7.5/debian/patches/link-opt.diff @@ -0,0 +1,24 @@ +# DP: Call the linker with -O1 -Bsymbolic-functions + +--- a/configure.ac ++++ b/configure.ac +@@ -2024,8 +2024,8 @@ + fi + ;; + Linux*|GNU*|QNX*) +- LDSHARED='$(CC) -shared' +- LDCXXSHARED='$(CXX) -shared';; ++ LDSHARED='$(CC) -shared -Wl,-O1 -Wl,-Bsymbolic-functions' ++ LDCXXSHARED='$(CXX) -shared -Wl,-O1 -Wl,-Bsymbolic-functions';; + BSD/OS*/4*) + LDSHARED="gcc -shared" + LDCXXSHARED="g++ -shared";; +@@ -2127,7 +2127,7 @@ + LINKFORSHARED="-Wl,-E -Wl,+s";; + # LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";; + BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";; +- Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";; ++ Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions";; + # -u libsys_s pulls in all symbols in libsys + Darwin/*) + # -u _PyMac_Error is needed to pull in the mac toolbox glue, --- python2.7-2.7.5.orig/debian/patches/lib2to3-no-pickled-grammar.diff +++ python2.7-2.7.5/debian/patches/lib2to3-no-pickled-grammar.diff @@ -0,0 +1,14 @@ +--- a/Lib/lib2to3/pgen2/driver.py ++++ b/Lib/lib2to3/pgen2/driver.py +@@ -119,7 +119,10 @@ + if force or not _newer(gp, gt): + logger.info("Generating grammar tables from %s", gt) + g = pgen.generate_grammar(gt) +- if save: ++ # the pickle files mismatch, when built on different architectures. ++ # don't save these for now. An alternative solution might be to ++ # include the multiarch triplet into the file name ++ if False: + logger.info("Writing grammar tables to %s", gp) + try: + g.dump(gp) --- python2.7-2.7.5.orig/debian/patches/plat-linux2_alpha.diff +++ python2.7-2.7.5/debian/patches/plat-linux2_alpha.diff @@ -0,0 +1,73 @@ +Index: Lib/plat-linux2/IN.py +=================================================================== +--- ./Lib/plat-linux2/IN.py (Revision 77754) ++++ ./Lib/plat-linux2/IN.py (Arbeitskopie) +@@ -436,43 +436,43 @@ + # Included from asm/socket.h + + # Included from asm/sockios.h +-FIOSETOWN = 0x8901 +-SIOCSPGRP = 0x8902 +-FIOGETOWN = 0x8903 +-SIOCGPGRP = 0x8904 +-SIOCATMARK = 0x8905 ++FIOSETOWN = 0x8004667c ++SIOCSPGRP = 0x80047308 ++FIOGETOWN = 0x4004667b ++SIOCGPGRP = 0x40047309 ++SIOCATMARK = 0x40047307 + SIOCGSTAMP = 0x8906 +-SOL_SOCKET = 1 +-SO_DEBUG = 1 +-SO_REUSEADDR = 2 +-SO_TYPE = 3 +-SO_ERROR = 4 +-SO_DONTROUTE = 5 +-SO_BROADCAST = 6 +-SO_SNDBUF = 7 +-SO_RCVBUF = 8 +-SO_KEEPALIVE = 9 +-SO_OOBINLINE = 10 ++SOL_SOCKET = 0xffff ++SO_DEBUG = 0x0001 ++SO_REUSEADDR = 0x0004 ++SO_TYPE = 0x1008 ++SO_ERROR = 0x1007 ++SO_DONTROUTE = 0x0010 ++SO_BROADCAST = 0x0020 ++SO_SNDBUF = 0x1001 ++SO_RCVBUF = 0x1002 ++SO_KEEPALIVE = 0x0008 ++SO_OOBINLINE = 0x0100 + SO_NO_CHECK = 11 + SO_PRIORITY = 12 +-SO_LINGER = 13 ++SO_LINGER = 0x0080 + SO_BSDCOMPAT = 14 + SO_PASSCRED = 16 + SO_PEERCRED = 17 +-SO_RCVLOWAT = 18 +-SO_SNDLOWAT = 19 +-SO_RCVTIMEO = 20 +-SO_SNDTIMEO = 21 +-SO_SECURITY_AUTHENTICATION = 22 +-SO_SECURITY_ENCRYPTION_TRANSPORT = 23 +-SO_SECURITY_ENCRYPTION_NETWORK = 24 ++SO_RCVLOWAT = 0x1010 ++SO_SNDLOWAT = 0x1011 ++SO_RCVTIMEO = 0x1012 ++SO_SNDTIMEO = 0x1013 ++SO_SECURITY_AUTHENTICATION = 19 ++SO_SECURITY_ENCRYPTION_TRANSPORT = 20 ++SO_SECURITY_ENCRYPTION_NETWORK = 21 + SO_BINDTODEVICE = 25 + SO_ATTACH_FILTER = 26 + SO_DETACH_FILTER = 27 + SO_PEERNAME = 28 + SO_TIMESTAMP = 29 + SCM_TIMESTAMP = SO_TIMESTAMP +-SO_ACCEPTCONN = 30 ++SO_ACCEPTCONN = 0x1014 + SOCK_STREAM = 1 + SOCK_DGRAM = 2 + SOCK_RAW = 3 --- python2.7-2.7.5.orig/debian/tests/control +++ python2.7-2.7.5/debian/tests/control @@ -0,0 +1,9 @@ +Tests: testsuite +Depends: build-essential, python2.7-dev, libpython2.7-testsuite, python-gdbm +# test_zipfile wants to write +Restrictions: needs-root + +Tests: testsuite-dbg +Depends: build-essential, python2.7-dev, python2.7-dbg, libpython2.7-testsuite, python-gdbm-dbg +# test_zipfile wants to write +Restrictions: needs-root --- python2.7-2.7.5.orig/debian/tests/testsuite +++ python2.7-2.7.5/debian/tests/testsuite @@ -0,0 +1,101 @@ +#!/bin/sh + +set -e + +if [ "$(whoami)" = root ]; then + # stop apport + stop apport 2>/dev/null || true + sed -i '/^enabled=/s/=.*/=0/' /etc/default/apport 2>/dev/null + # don't change anything when runnning as nobody + if [ -n "$SUDO_USER" ]; then + if [ -n "$TMPDIR" ] && [ -d "$TMPDIR" ]; then + chown -R $SUDO_USER $TMPDIR + fi + if [ -n "$ADTTMP" ] && [ -d "$ADTTMP" ]; then + chown -R $SUDO_USER $ADTTMP + fi + fi + su_user=${SUDO_USER:-nobody} +fi +# no root access needed after this point + +if status apport | grep -q start; then + echo >&2 "apport is running. needs to be disabled before running the tests" + exit 1 +fi + +export LANG=C +arch=$(dpkg --print-architecture) + +TESTPYTHON="python2.7 -E -Wd -3 -tt /usr/lib/python2.7/test/regrtest.py" +TESTOPTS="-w -uall,-network,-urlfetch,-gui,-xpickle" +TESTEXCLUSIONS="-x" + +# test_curses: error: copywin() returned ERR +TESTEXCLUSIONS="$TESTEXCLUSIONS test_curses" + +# test_distutils: Issue 17752, many failures in installed location +TESTEXCLUSIONS="$TESTEXCLUSIONS test_distutils" + +# test_gdb: not run for the optimized build +TESTEXCLUSIONS="$TESTEXCLUSIONS test_gdb" + +# test_pydoc: Issue 17773, failing tests +TESTEXCLUSIONS="$TESTEXCLUSIONS test_pydoc" + +# test_tools: not relevant for installed version +TESTEXCLUSIONS="$TESTEXCLUSIONS test_tools" + +# test_zipfile: Issue 17753, requires write access to test and email.test +TESTEXCLUSIONS="$TESTEXCLUSIONS test_zipfile" + +# test_subprocess: Issue 17757, two failing tests +TESTEXCLUSIONS="$TESTEXCLUSIONS test_subprocess" + +# test_uuid: fails, but not on the buildd. need to investigate +TESTEXCLUSIONS="$TESTEXCLUSIONS test_uuid" + +if [ "$su_user" = nobody ]; then + log=/dev/null + # test_site: Issue 17758, fails to create HOME + TESTEXCLUSIONS="$TESTEXCLUSIONS test_site" +else + log=testsuite.log +fi + +# run some tests separately in it's own run. These succeed locally, +# but fail on the test setup. +SEPARATE_TESTS= +case "$arch" in + amd64) + ;; + i386) + SEPARATE_TESTS="$SEPARATE_TESTS test_io" + ;; +esac + +script=$(dirname $(dirname $0))/script.py +if [ -f "$script" ]; then + cmd1="python2.7 $script \"$log\" \"$TESTPYTHON $TESTOPTS $TESTEXCLUSIONS $SEPARATE_TESTS\"" + cmd2="python2.7 $script \"$log\" \"$TESTPYTHON $TESTOPTS $SEPARATE_TESTS\"" +else + cmd1="$TESTPYTHON $TESTOPTS $TESTEXCLUSIONS $SEPARATE_TESTS" + cmd2="$TESTPYTHON $TESTOPTS $SEPARATE_TESTS" +fi + +echo "Running the python testsuite with the standard interpreter:" +if [ "$(whoami)" = root ]; then + echo "su -c $cmd1 $su_user" + su -c "$cmd1" $su_user + if [ -n "$SEPARATE_TESTS" ]; then + echo "su -c $cmd2 $su_user" + su -c "$cmd2" $su_user + fi +else + echo "$cmd1" + eval $cmd1 + if [ -n "$SEPARATE_TESTS" ]; then + echo "$cmd2" + eval $cmd2 + fi +fi --- python2.7-2.7.5.orig/debian/tests/testsuite-dbg +++ python2.7-2.7.5/debian/tests/testsuite-dbg @@ -0,0 +1,72 @@ +#!/bin/sh + +set -e + +if [ "$(whoami)" = root ]; then + # stop apport + stop apport 2>/dev/null || true + sed -i '/^enabled=/s/=.*/=0/' /etc/default/apport 2>/dev/null + # don't change anything when runnning as nobody + if [ -n "$SUDO_USER" ]; then + if [ -n "$TMPDIR" ] && [ -d "$TMPDIR" ]; then + chown -R $SUDO_USER $TMPDIR + fi + if [ -n "$ADTTMP" ] && [ -d "$ADTTMP" ]; then + chown -R $SUDO_USER $ADTTMP + fi + fi + su_user=${SUDO_USER:-nobody} +fi +# no root access needed after this point + +if status apport | grep -q start; then + echo >&2 "apport is running. needs to be disabled before running the tests" + exit 1 +fi + +export LANG=C + +TESTPYTHON="python2.7-dbg -E -Wd -3 -tt /usr/lib/python2.7/test/regrtest.py" +TESTOPTS="-w -uall,-network,-urlfetch,-gui,-xpickle" +TESTEXCLUSIONS="-x" + +# test_curses: error: copywin() returned ERR +TESTEXCLUSIONS="$TESTEXCLUSIONS test_curses" + +# test_distutils: Issue 17752, many failures in installed location +TESTEXCLUSIONS="$TESTEXCLUSIONS test_distutils" + +# test_pydoc: Issue 17773, failing tests +TESTEXCLUSIONS="$TESTEXCLUSIONS test_pydoc" + +# test_tools: not relevant for installed version +TESTEXCLUSIONS="$TESTEXCLUSIONS test_tools" + +# test_zipfile: Issue 17753, requires write access to test and email.test +TESTEXCLUSIONS="$TESTEXCLUSIONS test_zipfile" + +# test_subprocess: Issue 17757, two failing tests +TESTEXCLUSIONS="$TESTEXCLUSIONS test_subprocess" + +if [ "$su_user" = nobody ]; then + log=/dev/null + # test_site: Issue 17758, fails to create HOME + TESTEXCLUSIONS="$TESTEXCLUSIONS test_site" +else + log=testsuite-dbg.log +fi + +script=$(dirname $(dirname $0))/script.py +if [ -f "$script" ]; then + cmd="python2.7 $script \"$log\" \"$TESTPYTHON $TESTOPTS $TESTEXCLUSIONS\"" +else + cmd="$TESTPYTHON $TESTOPTS $TESTEXCLUSIONS" +fi +echo "Running the python testsuite with the debug enabled interpreter:" +if [ "$(whoami)" = root ]; then + echo "su -c $cmd $su_user" + su -c "$cmd" $su_user +else + echo "$cmd" + eval $cmd +fi