From fdrake@sourceforge.net Wed May 1 04:22:26 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Tue, 30 Apr 2002 20:22:26 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libpty.tex,1.4,1.4.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv3874/lib Modified Files: Tag: release21-maint libpty.tex Log Message: Add missing right-parenthesis. Index: libpty.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpty.tex,v retrieving revision 1.4 retrieving revision 1.4.4.1 diff -C2 -d -r1.4 -r1.4.4.1 *** libpty.tex 1 Dec 2000 15:25:23 -0000 1.4 --- libpty.tex 1 May 2002 03:22:23 -0000 1.4.4.1 *************** *** 24,28 **** return value is the \var{pid} of the child, and \var{fd} is a file descriptor connected to the child's controlling terminal (and also ! to the child's standard input and output. \end{funcdesc} --- 24,28 ---- return value is the \var{pid} of the child, and \var{fd} is a file descriptor connected to the child's controlling terminal (and also ! to the child's standard input and output). \end{funcdesc} From fdrake@sourceforge.net Wed May 1 04:22:50 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Tue, 30 Apr 2002 20:22:50 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libpty.tex,1.4,1.4.22.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv3922/lib Modified Files: Tag: release22-maint libpty.tex Log Message: Add missing right-parenthesis. Index: libpty.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpty.tex,v retrieving revision 1.4 retrieving revision 1.4.22.1 diff -C2 -d -r1.4 -r1.4.22.1 *** libpty.tex 1 Dec 2000 15:25:23 -0000 1.4 --- libpty.tex 1 May 2002 03:22:48 -0000 1.4.22.1 *************** *** 24,28 **** return value is the \var{pid} of the child, and \var{fd} is a file descriptor connected to the child's controlling terminal (and also ! to the child's standard input and output. \end{funcdesc} --- 24,28 ---- return value is the \var{pid} of the child, and \var{fd} is a file descriptor connected to the child's controlling terminal (and also ! to the child's standard input and output). \end{funcdesc} From fdrake@sourceforge.net Wed May 1 04:23:05 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Tue, 30 Apr 2002 20:23:05 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libpty.tex,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv3978/lib Modified Files: libpty.tex Log Message: Add missing right-parenthesis. Index: libpty.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpty.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** libpty.tex 1 Dec 2000 15:25:23 -0000 1.4 --- libpty.tex 1 May 2002 03:23:03 -0000 1.5 *************** *** 24,28 **** return value is the \var{pid} of the child, and \var{fd} is a file descriptor connected to the child's controlling terminal (and also ! to the child's standard input and output. \end{funcdesc} --- 24,28 ---- return value is the \var{pid} of the child, and \var{fd} is a file descriptor connected to the child's controlling terminal (and also ! to the child's standard input and output). \end{funcdesc} From fdrake@sourceforge.net Wed May 1 04:31:44 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Tue, 30 Apr 2002 20:31:44 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.83,1.84 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv5751/lib Modified Files: libos.tex Log Message: Explain what os.read() returns at end of file. This closes SF bug #550409. Applying to release21-maint & release22-maint. Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -d -r1.83 -r1.84 *** libos.tex 26 Apr 2002 20:59:40 -0000 1.83 --- libos.tex 1 May 2002 03:31:42 -0000 1.84 *************** *** 472,476 **** \begin{funcdesc}{read}{fd, n} Read at most \var{n} bytes from file descriptor \var{fd}. ! Return a string containing the bytes read. Availability: Macintosh, \UNIX, Windows. --- 472,478 ---- \begin{funcdesc}{read}{fd, n} Read at most \var{n} bytes from file descriptor \var{fd}. ! Return a string containing the bytes read. If the end of the file ! referred to by \var{fd} has been reached, an empty string is ! returned. Availability: Macintosh, \UNIX, Windows. From fdrake@sourceforge.net Wed May 1 04:32:27 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Tue, 30 Apr 2002 20:32:27 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.74.2.1.2.2,1.74.2.1.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv5856/lib Modified Files: Tag: release22-maint libos.tex Log Message: Explain what os.read() returns at end of file. This closes SF bug #550409. Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.74.2.1.2.2 retrieving revision 1.74.2.1.2.3 diff -C2 -d -r1.74.2.1.2.2 -r1.74.2.1.2.3 *** libos.tex 26 Apr 2002 20:59:55 -0000 1.74.2.1.2.2 --- libos.tex 1 May 2002 03:32:25 -0000 1.74.2.1.2.3 *************** *** 471,475 **** \begin{funcdesc}{read}{fd, n} Read at most \var{n} bytes from file descriptor \var{fd}. ! Return a string containing the bytes read. Availability: Macintosh, \UNIX, Windows. --- 471,477 ---- \begin{funcdesc}{read}{fd, n} Read at most \var{n} bytes from file descriptor \var{fd}. ! Return a string containing the bytes read. If the end of the file ! referred to by \var{fd} has been reached, an empty string is ! returned. Availability: Macintosh, \UNIX, Windows. From fdrake@sourceforge.net Wed May 1 04:33:04 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Tue, 30 Apr 2002 20:33:04 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.53.4.6,1.53.4.7 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv5943/lib Modified Files: Tag: release21-maint libos.tex Log Message: Explain what os.read() returns at end of file. This closes SF bug #550409. Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.53.4.6 retrieving revision 1.53.4.7 diff -C2 -d -r1.53.4.6 -r1.53.4.7 *** libos.tex 22 Jun 2001 15:41:58 -0000 1.53.4.6 --- libos.tex 1 May 2002 03:33:02 -0000 1.53.4.7 *************** *** 454,458 **** \begin{funcdesc}{read}{fd, n} Read at most \var{n} bytes from file descriptor \var{fd}. ! Return a string containing the bytes read. Availability: Macintosh, \UNIX{}, Windows. --- 454,460 ---- \begin{funcdesc}{read}{fd, n} Read at most \var{n} bytes from file descriptor \var{fd}. ! Return a string containing the bytes read. If the end of the file ! referred to by \var{fd} has been reached, an empty string is ! returned. Availability: Macintosh, \UNIX{}, Windows. From fdrake@sourceforge.net Wed May 1 18:25:06 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Wed, 01 May 2002 10:25:06 -0700 Subject: [Python-checkins] python/dist/src/Doc/tools findcsyms,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory usw-pr-cvs1:/tmp/cvs-serv21713/tools Modified Files: findcsyms Log Message: list_documented_items(): Basic implementation. This still does not work well since ctags does not do a good job with the Python headers, appearantly due to the DL_IMPORT macro. ;-( Index: findcsyms =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/findcsyms,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** findcsyms 16 Apr 2002 21:27:17 -0000 1.1 --- findcsyms 1 May 2002 17:25:04 -0000 1.2 *************** *** 3,6 **** --- 3,7 ---- import errno import os + import re import sys *************** *** 26,33 **** if fn.endswith(".h") and fn not in EXCLUDES] def list_documented_items(): """Return a list of everything that's already documented.""" ! docdir = os.path.join(srcdir, "Doc") ! return [] def split_documented(all, documented): --- 27,62 ---- if fn.endswith(".h") and fn not in EXCLUDES] + + def matcher(pattern): + return re.compile(pattern).match + + MATCHERS = [ + matcher(r"\\begin\{cfuncdesc\}\{[^{]*\}\{(?P[^{]*)\}"), + matcher(r"\\cfuncline\{[^{]*\}\{(?P[^{]*)\}"), + matcher(r"\\begin\{ctypedesc\}(\[[^{]*\])?\{(?P[^{]*)\}"), + matcher(r"\\begin\{cvardesc\}\{[^{]*\}\{(?P[^{]*)\}"), + matcher(r"\\begin\{cmemberdesc\}\{[^{]*\}\{(?P[^{]*)\}"), + matcher(r"\\cmemberline\{[^{]*\}\{(?P[^{]*)\}"), + matcher(r"\\begin\{csimplemacrodesc\}\{(?P[^{]*)\}"), + ] + + def list_documented_items(): """Return a list of everything that's already documented.""" ! apidir = os.path.join(srcdir, "Doc", "api") ! files = [fn for fn in os.listdir(apidir) if fn.endswith(".tex")] ! L = [] ! for fn in files: ! fullname = os.path.join(apidir, fn) ! for line in open(fullname): ! line = line.lstrip() ! if not line.startswith("\\"): ! continue ! for matcher in MATCHERS: ! m = matcher(line) ! if m: ! L.append(m.group("sym")) ! break ! return L def split_documented(all, documented): *************** *** 71,76 **** documented = list_documented_items() ! cmd = ("ctags -f - --file-scope=no --c-types=-mv " ! "-Istaticforward -Istatichere " + _spcjoin(headers)) fp = os.popen(cmd) --- 100,105 ---- documented = list_documented_items() ! cmd = ("ctags -f - --file-scope=no --c-types=dgpstux " ! "-Istaticforward -Istatichere=static " + _spcjoin(headers)) fp = os.popen(cmd) From fdrake@sourceforge.net Wed May 1 21:33:55 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Wed, 01 May 2002 13:33:55 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libpickle.tex,1.34,1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv19196/Doc/lib Modified Files: libpickle.tex Log Message: Add Pickler.clear_memo() so the pickle and cPickle modules are more similar. Index: libpickle.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpickle.tex,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** libpickle.tex 22 Mar 2002 22:16:03 -0000 1.34 --- libpickle.tex 1 May 2002 20:33:53 -0000 1.35 *************** *** 238,245 **** method is useful when re-using picklers. ! \strong{Note:} \method{clear_memo()} is only available on the picklers ! created by \module{cPickle}. In the \module{pickle} module, picklers ! have an instance variable called \member{memo} which is a Python ! dictionary. So to clear the memo for a \module{pickle} module pickler, you could do the following: --- 238,246 ---- method is useful when re-using picklers. ! \begin{notice} ! Prior to Python 2.3, \method{clear_memo()} was only available on the ! picklers created by \refmodule{cPickle}. In the \module{pickle} module, ! picklers have an instance variable called \member{memo} which is a ! Python dictionary. So to clear the memo for a \module{pickle} module pickler, you could do the following: *************** *** 247,250 **** --- 248,255 ---- mypickler.memo.clear() \end{verbatim} + + Code that does not need to support older versions of Python should + simply use \method{clear_memo()}. + \end{notice} \end{methoddesc} From fdrake@sourceforge.net Wed May 1 21:33:55 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Wed, 01 May 2002 13:33:55 -0700 Subject: [Python-checkins] python/dist/src/Lib pickle.py,1.60,1.61 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv19196/Lib Modified Files: pickle.py Log Message: Add Pickler.clear_memo() so the pickle and cPickle modules are more similar. Index: pickle.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** pickle.py 5 Apr 2002 19:30:07 -0000 1.60 --- pickle.py 1 May 2002 20:33:53 -0000 1.61 *************** *** 116,119 **** --- 116,122 ---- self.bin = bin + def clear_memo(self): + self.memo.clear() + def dump(self, object): self.save(object) From fdrake@sourceforge.net Wed May 1 21:33:56 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Wed, 01 May 2002 13:33:56 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.398,1.399 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv19196/Misc Modified Files: NEWS Log Message: Add Pickler.clear_memo() so the pickle and cPickle modules are more similar. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.398 retrieving revision 1.399 diff -C2 -d -r1.398 -r1.399 *** NEWS 29 Apr 2002 01:37:32 -0000 1.398 --- NEWS 1 May 2002 20:33:53 -0000 1.399 *************** *** 100,103 **** --- 100,106 ---- Library + - The pickle.Pickler class grew a clear_memo() method to mimic that + provided by cPickle.Pickler. + - difflib's SequenceMatcher class now does a dynamic analysis of which elements are so frequent as to constitute noise. For From fdrake@sourceforge.net Wed May 1 21:36:45 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Wed, 01 May 2002 13:36:45 -0700 Subject: [Python-checkins] python/dist/src/Modules cPickle.c,2.83,2.84 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv20067/Modules Modified Files: cPickle.c Log Message: Pickler_clear_memo(): convert to METH_NOARGS. Index: cPickle.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cPickle.c,v retrieving revision 2.83 retrieving revision 2.84 diff -C2 -d -r2.83 -r2.84 *** cPickle.c 27 Apr 2002 18:44:29 -0000 2.83 --- cPickle.c 1 May 2002 20:36:39 -0000 2.84 *************** *** 2121,2126 **** Pickle_clear_memo(Picklerobject *self, PyObject *args) { - if (!PyArg_ParseTuple(args,":clear_memo")) - return NULL; if (self->memo) PyDict_Clear(self->memo); --- 2121,2124 ---- *************** *** 2291,2297 **** {"dump", (PyCFunction)Pickler_dump, METH_VARARGS, "dump(object) --" ! "Write an object in pickle format to the object's pickle stream\n" ! }, ! {"clear_memo", (PyCFunction)Pickle_clear_memo, METH_VARARGS, "clear_memo() -- Clear the picklers memo"}, {"getvalue", (PyCFunction)Pickle_getvalue, METH_VARARGS, --- 2289,2294 ---- {"dump", (PyCFunction)Pickler_dump, METH_VARARGS, "dump(object) --" ! "Write an object in pickle format to the object's pickle stream"}, ! {"clear_memo", (PyCFunction)Pickle_clear_memo, METH_NOARGS, "clear_memo() -- Clear the picklers memo"}, {"getvalue", (PyCFunction)Pickle_getvalue, METH_VARARGS, From fdrake@sourceforge.net Wed May 1 23:03:43 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Wed, 01 May 2002 15:03:43 -0700 Subject: [Python-checkins] python/dist/src/Doc/html style.css,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/html In directory usw-pr-cvs1:/tmp/cvs-serv15375/html Modified Files: style.css Log Message: Added more style for major warnings. Index: style.css =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/html/style.css,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** style.css 15 Apr 2002 18:41:31 -0000 1.21 --- style.css 1 May 2002 22:03:40 -0000 1.22 *************** *** 62,65 **** --- 62,74 ---- font-size: 110%; } + div.warning { background-color: #fffaf0; + border: thin solid black; + padding: 0.5em; + margin-left: 2em; + margin-right: 2em; } + + div.warning .label { font-size: 110%; + margin-right: 0.5em; } + .release-info { font-style: italic; } From fdrake@sourceforge.net Wed May 1 23:05:32 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Wed, 01 May 2002 15:05:32 -0700 Subject: [Python-checkins] python/dist/src/Doc/doc doc.tex,1.63,1.64 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/doc In directory usw-pr-cvs1:/tmp/cvs-serv16077/doc Modified Files: doc.tex Log Message: Added some notes on setting up the documentation tools on Cygwin. Index: doc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/doc/doc.tex,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** doc.tex 19 Apr 2002 04:50:44 -0000 1.63 --- doc.tex 1 May 2002 22:05:30 -0000 1.64 *************** *** 1756,1759 **** --- 1756,1799 ---- + \subsection{Working on Cygwin \label{cygwin}} + + \begin{notice}[warning] + This section is a work in progress. It really doesn't work + yet. If anyone knows Cygwin and wants to help, send email to + \email{python-docs@python.org}. + \end{notice} + + Installing the required tools under Cygwin under Cygwin can be a + little tedious, if only because many packages are more difficult + to install under Cygwin. + + Using the Cygwin installer, make sure your Cygwin installation + includes Perl, Python, and the \TeX{} packages. Perl and Python + are located under \menuselection{Interpreters} in the installer + The \TeX{} packages are located in the \menuselection{Text} + section; installing the tetex-beta, texmf, texmf-base, and + texmf-extra ensures that all the required packages are available. + (There may be a more minimal set, but I've not spent time trying + to minimize the installation.) + + The netpbm package is used by \LaTeX2HTML, and \emph{must} be + installed before \LaTeX2HTML can be successfully installed, even + though they will never be used for most Python documentation. + References to download locations are located in the \ulink{netpbm + README}{http://netpbm.sourceforge.net/README}. Install according + to the instructions. + + \LaTeX2HTML can be installed from the source archive, but only + after munging one of the files in the distribution. Edit the file + \file{L2hos.pm} in the top level of the unpacked distribution; + near the bottom of the file, change the text + \code{\$\textasciicircum{}O} with the text \code{'unix'}. Proceed + using this command to build and install the software: + + \begin{verbatim} + % configure && make install + \end{verbatim} + + \section{Future Directions \label{futures}} From fdrake@sourceforge.net Thu May 2 05:27:22 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Wed, 01 May 2002 21:27:22 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_types.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv3075/Lib/test Modified Files: test_types.py Log Message: Buffer-object repitition and concatenation has worked all along; add a test to make avoid regression. Index: test_types.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** test_types.py 16 Apr 2002 01:38:40 -0000 1.28 --- test_types.py 2 May 2002 04:27:20 -0000 1.29 *************** *** 523,526 **** --- 523,532 ---- if a == b: raise TestFailed, 'buffers should not be equal' + if str(b) != ('asdf' * 5): + raise TestFailed, 'repeated buffer has wrong content' + if str(a * 0) != '': + raise TestFailed, 'repeated buffer zero times has wrong content' + if str(a + buffer('def')) != 'asdfdef': + raise TestFailed, 'concatenation of buffers yields wrong content' try: a[1] = 'g' From fdrake@sourceforge.net Thu May 2 05:49:50 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Wed, 01 May 2002 21:49:50 -0700 Subject: [Python-checkins] python/dist/src/Lib/test/output test_types,1.1,1.1.30.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv6400/Lib/test/output Modified Files: Tag: release22-maint test_types Log Message: Backport buffer() tests trunk to avoid regression failures. Index: test_types =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_types,v retrieving revision 1.1 retrieving revision 1.1.30.1 diff -C2 -d -r1.1 -r1.1.30.1 *** test_types 10 Dec 1996 23:20:09 -0000 1.1 --- test_types 2 May 2002 04:49:48 -0000 1.1.30.1 *************** *** 14,15 **** --- 14,16 ---- 6.5.3a Additional list operations 6.6 Mappings == Dictionaries + 6.7 Buffers From fdrake@sourceforge.net Thu May 2 05:49:50 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Wed, 01 May 2002 21:49:50 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_types.py,1.25,1.25.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv6400/Lib/test Modified Files: Tag: release22-maint test_types.py Log Message: Backport buffer() tests trunk to avoid regression failures. Index: test_types.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v retrieving revision 1.25 retrieving revision 1.25.4.1 diff -C2 -d -r1.25 -r1.25.4.1 *** test_types.py 20 Dec 2001 06:18:15 -0000 1.25 --- test_types.py 2 May 2002 04:49:47 -0000 1.25.4.1 *************** *** 398,399 **** --- 398,428 ---- except TypeError: pass else: raise TestFailed, 'type(), w/4 args expected TypeError' + + print '6.7 Buffers' + try: buffer('asdf', -1) + except ValueError: pass + else: raise TestFailed, "buffer('asdf', -1) should raise ValueError" + + try: buffer(None) + except TypeError: pass + else: raise TestFailed, "buffer(None) should raise TypeError" + + a = buffer('asdf') + hash(a) + b = a * 5 + if a == b: + raise TestFailed, 'buffers should not be equal' + if str(b) != ('asdf' * 5): + raise TestFailed, 'repeated buffer has wrong content' + if str(a * 0) != '': + raise TestFailed, 'repeated buffer zero times has wrong content' + if str(a + buffer('def')) != 'asdfdef': + raise TestFailed, 'concatenation of buffers yields wrong content' + + try: a[1] = 'g' + except TypeError: pass + else: raise TestFailed, "buffer assignment should raise TypeError" + + try: a[0:1] = 'g' + except TypeError: pass + else: raise TestFailed, "buffer slice assignment should raise TypeError" From fdrake@sourceforge.net Thu May 2 05:50:49 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Wed, 01 May 2002 21:50:49 -0700 Subject: [Python-checkins] python/dist/src/Doc/texinputs boilerplate.tex,1.70.2.1.2.5,1.70.2.1.2.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory usw-pr-cvs1:/tmp/cvs-serv6621/Doc/texinputs Modified Files: Tag: release22-maint boilerplate.tex Log Message: Revise version/date information since we're not about to hit a release. Index: boilerplate.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/boilerplate.tex,v retrieving revision 1.70.2.1.2.5 retrieving revision 1.70.2.1.2.6 diff -C2 -d -r1.70.2.1.2.5 -r1.70.2.1.2.6 *** boilerplate.tex 1 Apr 2002 22:49:51 -0000 1.70.2.1.2.5 --- boilerplate.tex 2 May 2002 04:50:47 -0000 1.70.2.1.2.6 *************** *** 6,11 **** } ! \date{April 10, 2002} % XXX update before release! \release{2.2.1} % software release, not documentation ! \setreleaseinfo{} % empty for final release \setshortversion{2.2} % major.minor only for software --- 6,11 ---- } ! \date{\today} % XXX update before release! \release{2.2.1} % software release, not documentation ! \setreleaseinfo{+} % empty for final release \setshortversion{2.2} % major.minor only for software From fdrake@sourceforge.net Thu May 2 05:51:39 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Wed, 01 May 2002 21:51:39 -0700 Subject: [Python-checkins] python/dist/src/Doc Makefile,1.235.2.1.2.7,1.235.2.1.2.8 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory usw-pr-cvs1:/tmp/cvs-serv6759/Doc Modified Files: Tag: release22-maint Makefile Log Message: Revise version/date information since we're not about to hit a release. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile,v retrieving revision 1.235.2.1.2.7 retrieving revision 1.235.2.1.2.8 diff -C2 -d -r1.235.2.1.2.7 -r1.235.2.1.2.8 *** Makefile 17 Apr 2002 03:31:31 -0000 1.235.2.1.2.7 --- Makefile 2 May 2002 04:51:37 -0000 1.235.2.1.2.8 *************** *** 67,71 **** # This is the *documentation* release, and is used to construct the file # names of the downloadable tarballs. ! RELEASE=2.2.1 PYTHON= python --- 67,71 ---- # This is the *documentation* release, and is used to construct the file # names of the downloadable tarballs. ! RELEASE=2.2.1+ PYTHON= python From fdrake@sourceforge.net Thu May 2 06:26:35 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Wed, 01 May 2002 22:26:35 -0700 Subject: [Python-checkins] python/dist/src/Doc Makefile,1.218.2.6,1.218.2.7 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory usw-pr-cvs1:/tmp/cvs-serv12689/Doc Modified Files: Tag: release21-maint Makefile Log Message: Revise version/date information since we're not about to hit a release. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile,v retrieving revision 1.218.2.6 retrieving revision 1.218.2.7 diff -C2 -d -r1.218.2.6 -r1.218.2.7 *** Makefile 8 Apr 2002 18:27:53 -0000 1.218.2.6 --- Makefile 2 May 2002 05:26:33 -0000 1.218.2.7 *************** *** 68,72 **** # This is the *documentation* release, and is used to construct the file # names of the downloadable tarballs. ! RELEASE=2.1.3 PYTHON= python --- 68,72 ---- # This is the *documentation* release, and is used to construct the file # names of the downloadable tarballs. ! RELEASE=2.1.3+ PYTHON= python From fdrake@sourceforge.net Thu May 2 06:26:35 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Wed, 01 May 2002 22:26:35 -0700 Subject: [Python-checkins] python/dist/src/Doc/texinputs boilerplate.tex,1.58.2.8,1.58.2.9 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory usw-pr-cvs1:/tmp/cvs-serv12689/Doc/texinputs Modified Files: Tag: release21-maint boilerplate.tex Log Message: Revise version/date information since we're not about to hit a release. Index: boilerplate.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/boilerplate.tex,v retrieving revision 1.58.2.8 retrieving revision 1.58.2.9 diff -C2 -d -r1.58.2.8 -r1.58.2.9 *** boilerplate.tex 8 Apr 2002 18:31:27 -0000 1.58.2.8 --- boilerplate.tex 2 May 2002 05:26:33 -0000 1.58.2.9 *************** *** 6,11 **** } ! \date{April 8, 2002} % XXX update before release! \release{2.1.3} % software release, not documentation ! \setreleaseinfo{} % empty for final release \setshortversion{2.1} % major.minor only for software --- 6,11 ---- } ! \date{\today} % XXX update before release! \release{2.1.3} % software release, not documentation ! \setreleaseinfo{+} % empty for final release \setshortversion{2.1} % major.minor only for software From fdrake@sourceforge.net Thu May 2 06:27:30 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Wed, 01 May 2002 22:27:30 -0700 Subject: [Python-checkins] python/dist/src/Lib/test/output test_types,1.1,1.1.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv12861/Lib/test/output Modified Files: Tag: release21-maint test_types Log Message: Backport buffer() tests from trunk to avoid regression failures. Index: test_types =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_types,v retrieving revision 1.1 retrieving revision 1.1.10.1 diff -C2 -d -r1.1 -r1.1.10.1 *** test_types 10 Dec 1996 23:20:09 -0000 1.1 --- test_types 2 May 2002 05:27:28 -0000 1.1.10.1 *************** *** 14,15 **** --- 14,16 ---- 6.5.3a Additional list operations 6.6 Mappings == Dictionaries + 6.7 Buffers From fdrake@sourceforge.net Thu May 2 06:27:30 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Wed, 01 May 2002 22:27:30 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_types.py,1.19,1.19.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv12861/Lib/test Modified Files: Tag: release21-maint test_types.py Log Message: Backport buffer() tests from trunk to avoid regression failures. Index: test_types.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v retrieving revision 1.19 retrieving revision 1.19.4.1 diff -C2 -d -r1.19 -r1.19.4.1 *** test_types.py 12 Dec 2000 23:11:42 -0000 1.19 --- test_types.py 2 May 2002 05:27:28 -0000 1.19.4.1 *************** *** 290,291 **** --- 290,320 ---- if a: raise TestFailed, 'a not empty after popitems: %s' % str(a) if b: raise TestFailed, 'b not empty after popitems: %s' % str(b) + + print '6.7 Buffers' + try: buffer('asdf', -1) + except ValueError: pass + else: raise TestFailed, "buffer('asdf', -1) should raise ValueError" + + try: buffer(None) + except TypeError: pass + else: raise TestFailed, "buffer(None) should raise TypeError" + + a = buffer('asdf') + hash(a) + b = a * 5 + if a == b: + raise TestFailed, 'buffers should not be equal' + if str(b) != ('asdf' * 5): + raise TestFailed, 'repeated buffer has wrong content' + if str(a * 0) != '': + raise TestFailed, 'repeated buffer zero times has wrong content' + if str(a + buffer('def')) != 'asdfdef': + raise TestFailed, 'concatenation of buffers yields wrong content' + + try: a[1] = 'g' + except TypeError: pass + else: raise TestFailed, "buffer assignment should raise TypeError" + + try: a[0:1] = 'g' + except TypeError: pass + else: raise TestFailed, "buffer slice assignment should raise TypeError" From fdrake@sourceforge.net Thu May 2 06:56:07 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Wed, 01 May 2002 22:56:07 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex,1.89,1.90 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv19805/lib Modified Files: libstdtypes.tex Log Message: Correct information on support for repietition & concatenation for buffer and xrange objects. This closes SF bug #550555. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** libstdtypes.tex 30 Apr 2002 14:54:47 -0000 1.89 --- libstdtypes.tex 2 May 2002 05:56:04 -0000 1.90 *************** *** 394,406 **** Buffer objects are not directly supported by Python syntax, but can be created by calling the builtin function ! \function{buffer()}.\bifuncindex{buffer}. They don't support ! concatenation or repetition. \obindex{buffer} Xrange objects are similar to buffers in that there is no specific ! syntax to create them, but they are created using the \function{xrange()} ! function.\bifuncindex{xrange} They don't support slicing, ! concatenation or repetition, and using \code{in}, \code{not in}, ! \function{min()} or \function{max()} on them is inefficient. \obindex{xrange} --- 394,408 ---- Buffer objects are not directly supported by Python syntax, but can be created by calling the builtin function ! \function{buffer()}.\bifuncindex{buffer}. They support ! concatenation and repetition, but the result is a new string object ! rather than a new buffer object. \obindex{buffer} Xrange objects are similar to buffers in that there is no specific ! syntax to create them, but they are created using the ! \function{xrange()} function.\bifuncindex{xrange} They don't support ! slicing or concatenation, but do support repetition, and using ! \code{in}, \code{not in}, \function{min()} or \function{max()} on them ! is inefficient. \obindex{xrange} From fdrake@sourceforge.net Thu May 2 06:57:09 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Wed, 01 May 2002 22:57:09 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex,1.80.6.6,1.80.6.7 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv20004/lib Modified Files: Tag: release22-maint libstdtypes.tex Log Message: Correct information on support for repietition & concatenation for buffer and xrange objects. This closes SF bug #550555. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.80.6.6 retrieving revision 1.80.6.7 diff -C2 -d -r1.80.6.6 -r1.80.6.7 *** libstdtypes.tex 30 Apr 2002 14:54:31 -0000 1.80.6.6 --- libstdtypes.tex 2 May 2002 05:57:07 -0000 1.80.6.7 *************** *** 389,401 **** Buffer objects are not directly supported by Python syntax, but can be created by calling the builtin function ! \function{buffer()}.\bifuncindex{buffer}. They don't support ! concatenation or repetition. \obindex{buffer} Xrange objects are similar to buffers in that there is no specific ! syntax to create them, but they are created using the \function{xrange()} ! function.\bifuncindex{xrange} They don't support slicing, ! concatenation or repetition, and using \code{in}, \code{not in}, ! \function{min()} or \function{max()} on them is inefficient. \obindex{xrange} --- 389,403 ---- Buffer objects are not directly supported by Python syntax, but can be created by calling the builtin function ! \function{buffer()}.\bifuncindex{buffer}. They support ! concatenation and repetition, but the result is a new string object ! rather than a new buffer object. \obindex{buffer} Xrange objects are similar to buffers in that there is no specific ! syntax to create them, but they are created using the ! \function{xrange()} function.\bifuncindex{xrange} They don't support ! slicing or concatenation, but do support repetition, and using ! \code{in}, \code{not in}, \function{min()} or \function{max()} on them ! is inefficient. \obindex{xrange} From fdrake@sourceforge.net Thu May 2 06:59:17 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Wed, 01 May 2002 22:59:17 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex,1.52.4.4,1.52.4.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv20518/lib Modified Files: Tag: release21-maint libstdtypes.tex Log Message: Add information on support for repietition & concatenation for buffer and xrange objects, and generally present these in the same way that more recent documentation releases present them (for ease of maintenance). This closes SF bug #550555. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.52.4.4 retrieving revision 1.52.4.5 diff -C2 -d -r1.52.4.4 -r1.52.4.5 *** libstdtypes.tex 30 Apr 2002 14:54:15 -0000 1.52.4.4 --- libstdtypes.tex 2 May 2002 05:59:15 -0000 1.52.4.5 *************** *** 329,344 **** or without enclosing parentheses, but an empty tuple must have the enclosing parentheses, e.g., \code{a, b, c} or \code{()}. A single ! item tuple must have a trailing comma, e.g., \code{(d,)}. Buffers are ! not directly supported by Python syntax, but can be created by calling the ! builtin function \function{buffer()}.\bifuncindex{buffer} XRanges ! objects are similar to buffers in that there is no specific syntax to ! create them, but they are created using the \function{xrange()} ! function.\bifuncindex{xrange} \obindex{sequence} \obindex{string} \obindex{Unicode} - \obindex{buffer} \obindex{tuple} \obindex{list} \obindex{xrange} --- 329,352 ---- or without enclosing parentheses, but an empty tuple must have the enclosing parentheses, e.g., \code{a, b, c} or \code{()}. A single ! item tuple must have a trailing comma, e.g., \code{(d,)}. \obindex{sequence} \obindex{string} \obindex{Unicode} \obindex{tuple} \obindex{list} + + Buffers are not directly supported by Python syntax, but can be + created by calling the builtin function + \function{buffer()}.\bifuncindex{buffer} They support + concatenation and repetition, but the result is a new string object + rather than a new buffer object. + \obindex{buffer} + + Xrange objects are similar to buffers in that there is no specific + syntax to create them, but they are created using the + \function{xrange()} function.\bifuncindex{xrange} They don't support + slicing or concatenation, but do support repetition, and using + \code{in}, \code{not in}, \function{min()} or \function{max()} on them + is inefficient. \obindex{xrange} From thomas.heller@ion-tof.com Thu May 2 08:18:40 2002 From: thomas.heller@ion-tof.com (Thomas Heller) Date: Thu, 2 May 2002 09:18:40 +0200 Subject: [Python-checkins] python/dist/src/Doc/tools findcsyms,1.1,1.2 References: Message-ID: <062a01c1f1a9$95ccf990$e000a8c0@thomasnotebook> From: > This still does not work well since ctags does not do a good job with the > Python headers, appearantly due to the DL_IMPORT macro. ;-( You could try the '-IDL_IMPORT+' flag to ctags: -Itokenlist ... If a token is suffixed with a '+' character, ctags will also ignore any parenthesis-enclosed argument list which may immediately follow the token in the source files. Thomas From fdrake@acm.org Thu May 2 12:32:51 2002 From: fdrake@acm.org (Fred L. Drake, Jr.) Date: Thu, 2 May 2002 07:32:51 -0400 Subject: [Python-checkins] python/dist/src/Doc/tools findcsyms,1.1,1.2 In-Reply-To: <062a01c1f1a9$95ccf990$e000a8c0@thomasnotebook> References: <062a01c1f1a9$95ccf990$e000a8c0@thomasnotebook> Message-ID: <15569.9187.630827.742330@grendel.zope.com> Thomas Heller writes: > You could try the '-IDL_IMPORT+' flag to ctags: I tried that, but it doesn't seem to help. ;-( -Fred -- Fred L. Drake, Jr. PythonLabs at Zope Corporation From loewis@sourceforge.net Thu May 2 13:16:31 2002 From: loewis@sourceforge.net (loewis@sourceforge.net) Date: Thu, 02 May 2002 05:16:31 -0700 Subject: [Python-checkins] python/dist/src/Modules _localemodule.c,2.30,2.31 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv10052 Modified Files: _localemodule.c Log Message: Guard gettext and friends with HAVE_LIBINTL_H. Fixes #549907. Index: _localemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v retrieving revision 2.30 retrieving revision 2.31 diff -C2 -d -r2.30 -r2.31 *** _localemodule.c 19 Apr 2002 21:04:41 -0000 2.30 --- _localemodule.c 2 May 2002 12:16:29 -0000 2.31 *************** *** 640,644 **** METH_VARARGS, nl_langinfo__doc__}, #endif ! #ifdef HAVE_LANGINFO_H {"gettext",(PyCFunction)PyIntl_gettext,METH_VARARGS, gettext__doc__}, --- 640,644 ---- METH_VARARGS, nl_langinfo__doc__}, #endif ! #ifdef HAVE_LIBINTL_H {"gettext",(PyCFunction)PyIntl_gettext,METH_VARARGS, gettext__doc__}, From montanaro@sourceforge.net Thu May 2 14:03:25 2002 From: montanaro@sourceforge.net (montanaro@sourceforge.net) Date: Thu, 02 May 2002 06:03:25 -0700 Subject: [Python-checkins] python/dist/src/Objects floatobject.c,2.111,2.112 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv29623 Modified Files: floatobject.c Log Message: clarify message when raising TypeError to indicate that float() accepts strings or numbers Index: floatobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v retrieving revision 2.111 retrieving revision 2.112 diff -C2 -d -r2.111 -r2.112 *** floatobject.c 9 Mar 2002 04:58:24 -0000 2.111 --- floatobject.c 2 May 2002 13:03:22 -0000 2.112 *************** *** 124,128 **** else if (PyObject_AsCharBuffer(v, &s, &len)) { PyErr_SetString(PyExc_TypeError, ! "float() needs a string argument"); return NULL; } --- 124,128 ---- else if (PyObject_AsCharBuffer(v, &s, &len)) { PyErr_SetString(PyExc_TypeError, ! "float() argument must be a string or a number"); return NULL; } From akuchling@sourceforge.net Thu May 2 15:31:57 2002 From: akuchling@sourceforge.net (akuchling@sourceforge.net) Date: Thu, 02 May 2002 07:31:57 -0700 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.160,1.161 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory usw-pr-cvs1:/tmp/cvs-serv26832 Modified Files: tut.tex Log Message: Message for NameError has changed Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.160 retrieving revision 1.161 diff -C2 -d -r1.160 -r1.161 *** tut.tex 26 Apr 2002 20:29:44 -0000 1.160 --- tut.tex 2 May 2002 14:31:55 -0000 1.161 *************** *** 3091,3095 **** Traceback (most recent call last): File "", line 1, in ? ! NameError: spam >>> '2' + 2 Traceback (most recent call last): --- 3091,3095 ---- Traceback (most recent call last): File "", line 1, in ? ! NameError: name 'spam' is not defined >>> '2' + 2 Traceback (most recent call last): From akuchling@sourceforge.net Thu May 2 15:37:16 2002 From: akuchling@sourceforge.net (akuchling@sourceforge.net) Date: Thu, 02 May 2002 07:37:16 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew20.tex,1.44,1.45 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv28602 Modified Files: whatsnew20.tex Log Message: Note that NameError's message also changed in 2.0 Index: whatsnew20.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew20.tex,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** whatsnew20.tex 18 Apr 2002 02:18:27 -0000 1.44 --- whatsnew20.tex 2 May 2002 14:37:14 -0000 1.45 *************** *** 767,774 **** equivalent to \code{\e x56}. ! The \exception{AttributeError} exception has a more friendly error message, ! whose text will be something like \code{'Spam' instance has no attribute 'eggs'}. ! Previously the error message was just the missing attribute name \code{eggs}, and ! code written to take advantage of this fact will break in 2.0. Some work has been done to make integers and long integers a bit more --- 767,776 ---- equivalent to \code{\e x56}. ! The \exception{AttributeError} and \exception{NameError} exceptions ! have a more friendly error message, whose text will be something like ! \code{'Spam' instance has no attribute 'eggs'} or \code{name 'eggs' is ! not defined}. Previously the error message was just the missing ! attribute name \code{eggs}, and code written to take advantage of this ! fact will break in 2.0. Some work has been done to make integers and long integers a bit more *************** *** 1326,1333 **** The authors would like to thank the following people for offering ! suggestions on various drafts of this article: David Bolen, Mark Hammond, Gregg Hauser, ! Jeremy Hylton, Fredrik Lundh, Detlef Lannert, Aahz Maruch, Skip ! Montanaro, Vladimir Marangozov, Guido van Rossum, Neil Schemenauer, ! and Russ Schmidt. \end{document} --- 1328,1335 ---- The authors would like to thank the following people for offering ! suggestions on various drafts of this article: David Bolen, Mark ! Hammond, Gregg Hauser, Jeremy Hylton, Fredrik Lundh, Detlef Lannert, ! Aahz Maruch, Skip Montanaro, Vladimir Marangozov, Tobias Polzin, Guido ! van Rossum, Neil Schemenauer, and Russ Schmidt. \end{document} From akuchling@sourceforge.net Thu May 2 15:48:28 2002 From: akuchling@sourceforge.net (akuchling@sourceforge.net) Date: Thu, 02 May 2002 07:48:28 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew20.tex,1.45,1.46 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv32617 Modified Files: whatsnew20.tex Log Message: Correct Moshe's e-mail address Point to PEP 100 for MAL's Unicode proposal Fix URL for XML HOWTO Bump version number Index: whatsnew20.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew20.tex,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** whatsnew20.tex 2 May 2002 14:37:14 -0000 1.45 --- whatsnew20.tex 2 May 2002 14:48:26 -0000 1.46 *************** *** 4,10 **** \title{What's New in Python 2.0} ! \release{1.01} \author{A.M. Kuchling and Moshe Zadka} ! \authoraddress{\email{akuchlin@mems-exchange.org}, \email{moshez@math.huji.ac.il} } \begin{document} \maketitle\tableofcontents --- 4,10 ---- \title{What's New in Python 2.0} ! \release{1.02} \author{A.M. Kuchling and Moshe Zadka} ! \authoraddress{\email{akuchlin@mems-exchange.org}, \email{moshez@twistedmatrix.com} } \begin{document} \maketitle\tableofcontents *************** *** 153,161 **** mostly implemented by Marc-Andr\'e Lemburg, based on a Unicode string type implementation by Fredrik Lundh. A detailed explanation of the ! interface is in the file \file{Misc/unicode.txt} in the Python source ! distribution; it's also available on the Web at ! \url{http://starship.python.net/crew/lemburg/unicode-proposal.txt}. ! This article will simply cover the most significant points about the Unicode ! interfaces. In Python source code, Unicode strings are written as --- 153,159 ---- mostly implemented by Marc-Andr\'e Lemburg, based on a Unicode string type implementation by Fredrik Lundh. A detailed explanation of the ! interface was written up as \pep{100}, ``Python Unicode Integration''. ! This article will simply cover the most significant points about the ! Unicode interfaces. In Python source code, Unicode strings are written as *************** *** 1035,1039 **** For more information, consult the Python documentation, or the XML ! HOWTO at \url{http://www.python.org/doc/howto/xml/}. \subsection{DOM Support} --- 1033,1037 ---- For more information, consult the Python documentation, or the XML ! HOWTO at \url{http://pyxml.sourceforge.net/topics/howto/xml-howto.html}. \subsection{DOM Support} From fdrake@sourceforge.net Thu May 2 17:05:29 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 09:05:29 -0700 Subject: [Python-checkins] python/dist/src/Objects rangeobject.c,2.33,2.34 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv32230/Objects Modified Files: rangeobject.c Log Message: Fix attribute access for the xrange objects. The tp_getattr and tp_getattro handlers were both set, but were not compatible. This change uses only the tp_getattro handler with a more "modern" approach. This fixes SF bug #551285. Index: rangeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/rangeobject.c,v retrieving revision 2.33 retrieving revision 2.34 diff -C2 -d -r2.33 -r2.34 *** rangeobject.c 12 Apr 2002 02:44:55 -0000 2.33 --- rangeobject.c 2 May 2002 16:05:27 -0000 2.34 *************** *** 265,296 **** static PyObject * ! range_getattr(rangeobject *r, char *name) { ! PyObject *result; ! static PyMethodDef range_methods[] = { ! {"tolist", (PyCFunction)range_tolist, METH_NOARGS, ! "tolist() -> list\n" ! "Return a list object with the same values.\n" ! "(This method is deprecated; use list() instead.)"}, ! {NULL, NULL} ! }; ! static struct memberlist range_members[] = { ! {"step", T_LONG, offsetof(rangeobject, step), RO}, ! {"start", T_LONG, offsetof(rangeobject, start), RO}, ! {"stop", T_LONG, 0, RO}, ! {NULL, 0, 0, 0} ! }; ! result = Py_FindMethod(range_methods, (PyObject *) r, name); ! if (result == NULL) { ! PyErr_Clear(); ! if (strcmp("stop", name) == 0) ! result = PyInt_FromLong(r->start + (r->len * r->step)); ! else ! result = PyMember_Get((char *)r, range_members, name); ! if (result) ! WARN("xrange object's 'start', 'stop' and 'step' " ! "attributes are deprecated"); } return result; --- 265,303 ---- static PyObject * ! range_get_stop(rangeobject *self, void *closure) { ! return PyInt_FromLong(self->start + (self->len * self->step)); ! } ! static PyMethodDef range_methods[] = { ! {"tolist", (PyCFunction)range_tolist, METH_NOARGS, ! "tolist() -> list\n" ! "Return a list object with the same values.\n" ! "(This method is deprecated; use list() instead.)"}, ! {NULL, NULL} ! }; ! static PyMemberDef range_members[] = { ! {"step", T_LONG, offsetof(rangeobject, step), RO, ! "Interval between indexes of the slice; also known as the 'stride'."}, ! {"start", T_LONG, offsetof(rangeobject, start), RO, ! "First index of the slice."}, ! {NULL, 0, 0, 0} ! }; ! ! static PyGetSetDef range_getsets[] = { ! {"stop", (getter)range_get_stop, NULL, ! ""}, ! {NULL}, ! }; ! ! static PyObject * ! range_getattro(rangeobject *self, PyObject *name) ! { ! PyObject *result; ! result = PyObject_GenericGetAttr((PyObject *)self, name); ! if (result && PyInt_CheckExact(result)) { ! WARN("xrange object's 'start', 'stop' and 'step' " ! "attributes are deprecated"); } return result; *************** *** 316,320 **** (destructor)range_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! (getattrfunc)range_getattr, /*tp_getattr*/ 0, /*tp_setattr*/ (cmpfunc)range_compare, /*tp_compare*/ --- 323,327 ---- (destructor)range_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! 0, /*tp_getattr*/ 0, /*tp_setattr*/ (cmpfunc)range_compare, /*tp_compare*/ *************** *** 326,330 **** 0, /*tp_call*/ 0, /*tp_str*/ ! PyObject_GenericGetAttr, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ --- 333,337 ---- 0, /*tp_call*/ 0, /*tp_str*/ ! (getattrofunc)range_getattro, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ *************** *** 337,343 **** 0, /* tp_iter */ 0, /* tp_iternext */ ! 0, /* tp_methods */ ! 0, /* tp_members */ ! 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ --- 344,350 ---- 0, /* tp_iter */ 0, /* tp_iternext */ ! range_methods, /* tp_methods */ ! range_members, /* tp_members */ ! range_getsets, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ From fdrake@sourceforge.net Thu May 2 17:05:42 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 09:05:42 -0700 Subject: [Python-checkins] python/dist/src/Objects rangeobject.c,2.30.6.1,2.30.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv32327/Objects Modified Files: Tag: release22-maint rangeobject.c Log Message: Fix attribute access for the xrange objects. The tp_getattr and tp_getattro handlers were both set, but were not compatible. This change uses only the tp_getattro handler with a more "modern" approach. This fixes SF bug #551285. Index: rangeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/rangeobject.c,v retrieving revision 2.30.6.1 retrieving revision 2.30.6.2 diff -C2 -d -r2.30.6.1 -r2.30.6.2 *** rangeobject.c 6 Feb 2002 17:06:02 -0000 2.30.6.1 --- rangeobject.c 2 May 2002 16:05:40 -0000 2.30.6.2 *************** *** 265,296 **** static PyObject * ! range_getattr(rangeobject *r, char *name) { ! PyObject *result; ! static PyMethodDef range_methods[] = { ! {"tolist", (PyCFunction)range_tolist, METH_NOARGS, ! "tolist() -> list\n" ! "Return a list object with the same values.\n" ! "(This method is deprecated; use list() instead.)"}, ! {NULL, NULL} ! }; ! static struct memberlist range_members[] = { ! {"step", T_LONG, offsetof(rangeobject, step), RO}, ! {"start", T_LONG, offsetof(rangeobject, start), RO}, ! {"stop", T_LONG, 0, RO}, ! {NULL, 0, 0, 0} ! }; ! result = Py_FindMethod(range_methods, (PyObject *) r, name); ! if (result == NULL) { ! PyErr_Clear(); ! if (strcmp("stop", name) == 0) ! result = PyInt_FromLong(r->start + (r->len * r->step)); ! else ! result = PyMember_Get((char *)r, range_members, name); ! if (result) ! WARN("xrange object's 'start', 'stop' and 'step' " ! "attributes are deprecated"); } return result; --- 265,303 ---- static PyObject * ! range_get_stop(rangeobject *self, void *closure) { ! return PyInt_FromLong(self->start + (self->len * self->step)); ! } ! static PyMethodDef range_methods[] = { ! {"tolist", (PyCFunction)range_tolist, METH_NOARGS, ! "tolist() -> list\n" ! "Return a list object with the same values.\n" ! "(This method is deprecated; use list() instead.)"}, ! {NULL, NULL} ! }; ! static PyMemberDef range_members[] = { ! {"step", T_LONG, offsetof(rangeobject, step), RO, ! "Interval between indexes of the slice; also known as the 'stride'."}, ! {"start", T_LONG, offsetof(rangeobject, start), RO, ! "First index of the slice."}, ! {NULL, 0, 0, 0} ! }; ! ! static PyGetSetDef range_getsets[] = { ! {"stop", (getter)range_get_stop, NULL, ! ""}, ! {NULL}, ! }; ! ! static PyObject * ! range_getattro(rangeobject *self, PyObject *name) ! { ! PyObject *result; ! result = PyObject_GenericGetAttr((PyObject *)self, name); ! if (result && PyInt_CheckExact(result)) { ! WARN("xrange object's 'start', 'stop' and 'step' " ! "attributes are deprecated"); } return result; *************** *** 316,320 **** (destructor)range_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! (getattrfunc)range_getattr, /*tp_getattr*/ 0, /*tp_setattr*/ (cmpfunc)range_compare, /*tp_compare*/ --- 323,327 ---- (destructor)range_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! 0, /*tp_getattr*/ 0, /*tp_setattr*/ (cmpfunc)range_compare, /*tp_compare*/ *************** *** 326,330 **** 0, /*tp_call*/ 0, /*tp_str*/ ! PyObject_GenericGetAttr, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ --- 333,337 ---- 0, /*tp_call*/ 0, /*tp_str*/ ! (getattrofunc)range_getattro, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ *************** *** 337,343 **** 0, /* tp_iter */ 0, /* tp_iternext */ ! 0, /* tp_methods */ ! 0, /* tp_members */ ! 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ --- 344,350 ---- 0, /* tp_iter */ 0, /* tp_iternext */ ! range_methods, /* tp_methods */ ! range_members, /* tp_members */ ! range_getsets, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ From fdrake@sourceforge.net Thu May 2 17:07:47 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 09:07:47 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_b2.py,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv650/Lib/test Modified Files: test_b2.py Log Message: Added regression tests for xrange object attributes. See SF bug #551285. Index: test_b2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b2.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** test_b2.py 26 Feb 2002 22:39:23 -0000 1.31 --- test_b2.py 2 May 2002 16:07:44 -0000 1.32 *************** *** 290,297 **** --- 290,320 ---- print 'xrange' + import warnings + warnings.filterwarnings('ignore', r".*xrange", DeprecationWarning) if tuple(xrange(10)) != tuple(range(10)): raise TestFailed, 'xrange(10)' if tuple(xrange(5,10)) != tuple(range(5,10)): raise TestFailed, 'xrange(5,10)' if tuple(xrange(0,10,2)) != tuple(range(0,10,2)): raise TestFailed, 'xrange(0,10,2)' + r = xrange(10) + if r.tolist() != range(10): raise TestFailed, 'xrange(10).tolist()' + if r.start != 0: raise TestFailed, 'xrange(10).start' + if r.stop != 10: raise TestFailed, 'xrange(10).stop' + if r.step != 1: raise TestFailed, 'xrange(10).step' + r = xrange(3, 10) + if r.tolist() != range(3, 10): raise TestFailed, 'xrange(3, 10).tolist()' + if r.start != 3: raise TestFailed, 'xrange(3, 10).start' + if r.stop != 10: raise TestFailed, 'xrange(3, 10).stop' + if r.step != 1: raise TestFailed, 'xrange(3, 10).step' + r = xrange(3, 10, 2) + if r.tolist() != range(3, 10, 2): raise TestFailed, 'xrange(3, 10, 2).tolist()' + if r.start != 3: raise TestFailed, 'xrange(3, 10, 2).start' + if r.stop != 11: raise TestFailed, 'xrange(3, 10, 2).stop' + if r.step != 2: raise TestFailed, 'xrange(3, 10, 2).step' + r = xrange(10, 3, -1) + if r.tolist() != range(10, 3, -1): + raise TestFailed, 'xrange(10, 3, -1).tolist()' + if r.start != 10: raise TestFailed, 'xrange(10, 3, -1).start' + if r.stop != 3: raise TestFailed, 'xrange(10, 3, -1).stop' + if r.step != -1: raise TestFailed, 'xrange(10, 3, -1).step' print 'zip' From fdrake@sourceforge.net Thu May 2 17:08:01 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 09:08:01 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_b2.py,1.29.6.1,1.29.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv742/Lib/test Modified Files: Tag: release22-maint test_b2.py Log Message: Added regression tests for xrange object attributes. See SF bug #551285. Index: test_b2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b2.py,v retrieving revision 1.29.6.1 retrieving revision 1.29.6.2 diff -C2 -d -r1.29.6.1 -r1.29.6.2 *** test_b2.py 28 Feb 2002 10:14:24 -0000 1.29.6.1 --- test_b2.py 2 May 2002 16:07:59 -0000 1.29.6.2 *************** *** 270,277 **** --- 270,300 ---- print 'xrange' + import warnings + warnings.filterwarnings('ignore', r".*xrange", DeprecationWarning) if tuple(xrange(10)) != tuple(range(10)): raise TestFailed, 'xrange(10)' if tuple(xrange(5,10)) != tuple(range(5,10)): raise TestFailed, 'xrange(5,10)' if tuple(xrange(0,10,2)) != tuple(range(0,10,2)): raise TestFailed, 'xrange(0,10,2)' + r = xrange(10) + if r.tolist() != range(10): raise TestFailed, 'xrange(10).tolist()' + if r.start != 0: raise TestFailed, 'xrange(10).start' + if r.stop != 10: raise TestFailed, 'xrange(10).stop' + if r.step != 1: raise TestFailed, 'xrange(10).step' + r = xrange(3, 10) + if r.tolist() != range(3, 10): raise TestFailed, 'xrange(3, 10).tolist()' + if r.start != 3: raise TestFailed, 'xrange(3, 10).start' + if r.stop != 10: raise TestFailed, 'xrange(3, 10).stop' + if r.step != 1: raise TestFailed, 'xrange(3, 10).step' + r = xrange(3, 10, 2) + if r.tolist() != range(3, 10, 2): raise TestFailed, 'xrange(3, 10, 2).tolist()' + if r.start != 3: raise TestFailed, 'xrange(3, 10, 2).start' + if r.stop != 11: raise TestFailed, 'xrange(3, 10, 2).stop' + if r.step != 2: raise TestFailed, 'xrange(3, 10, 2).step' + r = xrange(10, 3, -1) + if r.tolist() != range(10, 3, -1): + raise TestFailed, 'xrange(10, 3, -1).tolist()' + if r.start != 10: raise TestFailed, 'xrange(10, 3, -1).start' + if r.stop != 3: raise TestFailed, 'xrange(10, 3, -1).stop' + if r.step != -1: raise TestFailed, 'xrange(10, 3, -1).step' print 'zip' From fdrake@sourceforge.net Thu May 2 17:25:32 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 09:25:32 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_b2.py,1.24,1.24.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv8684/Lib/test Modified Files: Tag: release21-maint test_b2.py Log Message: Added regression tests for xrange object attributes. See SF bug #551285. Index: test_b2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b2.py,v retrieving revision 1.24 retrieving revision 1.24.4.1 diff -C2 -d -r1.24 -r1.24.4.1 *** test_b2.py 19 Jan 2001 21:57:52 -0000 1.24 --- test_b2.py 2 May 2002 16:25:30 -0000 1.24.4.1 *************** *** 255,258 **** --- 255,279 ---- if tuple(xrange(0,10,2)) != tuple(range(0,10,2)): raise TestFailed, 'xrange(0,10,2)' + r = xrange(10) + if r.tolist() != range(10): raise TestFailed, 'xrange(10).tolist()' + if r.start != 0: raise TestFailed, 'xrange(10).start' + if r.stop != 10: raise TestFailed, 'xrange(10).stop' + if r.step != 1: raise TestFailed, 'xrange(10).step' + r = xrange(3, 10) + if r.tolist() != range(3, 10): raise TestFailed, 'xrange(3, 10).tolist()' + if r.start != 3: raise TestFailed, 'xrange(3, 10).start' + if r.stop != 10: raise TestFailed, 'xrange(3, 10).stop' + if r.step != 1: raise TestFailed, 'xrange(3, 10).step' + r = xrange(3, 10, 2) + if r.tolist() != range(3, 10, 2): raise TestFailed, 'xrange(3, 10, 2).tolist()' + if r.start != 3: raise TestFailed, 'xrange(3, 10, 2).start' + if r.stop != 11: raise TestFailed, 'xrange(3, 10, 2).stop' + if r.step != 2: raise TestFailed, 'xrange(3, 10, 2).step' + r = xrange(10, 3, -1) + if r.tolist() != range(10, 3, -1): + raise TestFailed, 'xrange(10, 3, -1).tolist()' + if r.start != 10: raise TestFailed, 'xrange(10, 3, -1).start' + if r.stop != 3: raise TestFailed, 'xrange(10, 3, -1).stop' + if r.step != -1: raise TestFailed, 'xrange(10, 3, -1).step' # regression tests for SourceForge bug #121695 def _range_test(r): From fdrake@sourceforge.net Thu May 2 17:37:34 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 09:37:34 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_b2.py,1.24.4.1,1.24.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv12536/Lib/test Modified Files: Tag: release21-maint test_b2.py Log Message: Update a SourceForge issue number; IDs less than 200000 are no longer valid. (The issues were re-numbered, not lost.) Index: test_b2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b2.py,v retrieving revision 1.24.4.1 retrieving revision 1.24.4.2 diff -C2 -d -r1.24.4.1 -r1.24.4.2 *** test_b2.py 2 May 2002 16:25:30 -0000 1.24.4.1 --- test_b2.py 2 May 2002 16:37:31 -0000 1.24.4.2 *************** *** 276,280 **** if r.stop != 3: raise TestFailed, 'xrange(10, 3, -1).stop' if r.step != -1: raise TestFailed, 'xrange(10, 3, -1).step' ! # regression tests for SourceForge bug #121695 def _range_test(r): verify(r.start != r.stop, 'Test not valid for passed-in xrange object.') --- 276,280 ---- if r.stop != 3: raise TestFailed, 'xrange(10, 3, -1).stop' if r.step != -1: raise TestFailed, 'xrange(10, 3, -1).step' ! # regression tests for SourceForge bug #221965 def _range_test(r): verify(r.start != r.stop, 'Test not valid for passed-in xrange object.') From loewis@sourceforge.net Thu May 2 18:39:32 2002 From: loewis@sourceforge.net (loewis@sourceforge.net) Date: Thu, 02 May 2002 10:39:32 -0700 Subject: [Python-checkins] python/dist/src/Lib os.py,1.55,1.56 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv32525 Modified Files: os.py Log Message: Patch 550804: Make os.environ.copy() return a copy. Index: os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/os.py,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** os.py 4 Apr 2002 22:55:58 -0000 1.55 --- os.py 2 May 2002 17:39:19 -0000 1.56 *************** *** 413,416 **** --- 413,418 ---- for k, v in dict.items(): self[k] = v + def copy(self): + return dict(self) else: # Where Env Var Names Can Be Mixed Case *************** *** 433,436 **** --- 435,440 ---- unsetenv(key) del self.data[key] + def copy(self): + return dict(self) From fdrake@sourceforge.net Thu May 2 18:54:04 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 10:54:04 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex,1.80.6.7,1.80.6.8 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv4751/lib Modified Files: Tag: release22-maint libstdtypes.tex Log Message: Remove extra period produced by previous change. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.80.6.7 retrieving revision 1.80.6.8 diff -C2 -d -r1.80.6.7 -r1.80.6.8 *** libstdtypes.tex 2 May 2002 05:57:07 -0000 1.80.6.7 --- libstdtypes.tex 2 May 2002 17:54:01 -0000 1.80.6.8 *************** *** 389,395 **** Buffer objects are not directly supported by Python syntax, but can be created by calling the builtin function ! \function{buffer()}.\bifuncindex{buffer}. They support ! concatenation and repetition, but the result is a new string object ! rather than a new buffer object. \obindex{buffer} --- 389,395 ---- Buffer objects are not directly supported by Python syntax, but can be created by calling the builtin function ! \function{buffer()}.\bifuncindex{buffer} They support concatenation ! and repetition, but the result is a new string object rather than a ! new buffer object. \obindex{buffer} From fdrake@sourceforge.net Thu May 2 18:54:20 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 10:54:20 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex,1.90,1.91 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv4973/lib Modified Files: libstdtypes.tex Log Message: Remove extra period produced by previous change. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.90 retrieving revision 1.91 diff -C2 -d -r1.90 -r1.91 *** libstdtypes.tex 2 May 2002 05:56:04 -0000 1.90 --- libstdtypes.tex 2 May 2002 17:54:18 -0000 1.91 *************** *** 394,400 **** Buffer objects are not directly supported by Python syntax, but can be created by calling the builtin function ! \function{buffer()}.\bifuncindex{buffer}. They support ! concatenation and repetition, but the result is a new string object ! rather than a new buffer object. \obindex{buffer} --- 394,400 ---- Buffer objects are not directly supported by Python syntax, but can be created by calling the builtin function ! \function{buffer()}.\bifuncindex{buffer} They support concatenation ! and repetition, but the result is a new string object rather than a ! new buffer object. \obindex{buffer} From fdrake@sourceforge.net Thu May 2 18:55:28 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 10:55:28 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew22.tex,1.56,1.57 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv5308/whatsnew Modified Files: whatsnew22.tex Log Message: Many minor markup adjustments for consistency. Index: whatsnew22.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew22.tex,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** whatsnew22.tex 10 Apr 2002 21:53:22 -0000 1.56 --- whatsnew22.tex 2 May 2002 17:55:26 -0000 1.57 *************** *** 522,528 **** own iterator, this method can just return \code{self}. In particular, iterators will usually be their own iterators. Extension types ! implemented in C can implement a \code{tp_iter} function in order to return an iterator, and extension types that want to behave as ! iterators can define a \code{tp_iternext} function. So, after all this, what do iterators actually do? They have one --- 522,528 ---- own iterator, this method can just return \code{self}. In particular, iterators will usually be their own iterators. Extension types ! implemented in C can implement a \member{tp_iter} function in order to return an iterator, and extension types that want to behave as ! iterators can define a \member{tp_iternext} function. So, after all this, what do iterators actually do? They have one *************** *** 553,557 **** For backward compatibility and convenience, an iterator is automatically constructed for sequences that don't implement ! \method{__iter__()} or a \code{tp_iter} slot, so \code{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 --- 553,557 ---- For backward compatibility and convenience, an iterator is automatically constructed for sequences that don't implement ! \method{__iter__()} or a \member{tp_iter} slot, so \code{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 *************** *** 660,668 **** \keyword{return} statement is that on reaching a \keyword{yield} the generator's state of execution is suspended and local variables are ! preserved. On the next call to the generator's \code{.next()} method, the function will resume executing immediately after the \keyword{yield} statement. (For complicated reasons, the \keyword{yield} statement isn't allowed inside the \keyword{try} block ! of a \code{try...finally} statement; read \pep{255} for a full explanation of the interaction between \keyword{yield} and exceptions.) --- 660,668 ---- \keyword{return} statement is that on reaching a \keyword{yield} the generator's state of execution is suspended and local variables are ! preserved. On the next call to the generator's \code{next()} method, the function will resume executing immediately after the \keyword{yield} statement. (For complicated reasons, the \keyword{yield} statement isn't allowed inside the \keyword{try} block ! of a \keyword{try}...\keyword{finally} statement; read \pep{255} for a full explanation of the interaction between \keyword{yield} and exceptions.) *************** *** 864,868 **** \item Classes can define methods called \method{__truediv__} and \method{__floordiv__} to overload the two division operators. At the ! C level, there are also slots in the \code{PyNumberMethods} structure so extension types can define the two operators. --- 864,868 ---- \item Classes can define methods called \method{__truediv__} and \method{__floordiv__} to overload the two division operators. At the ! C level, there are also slots in the \ctype{PyNumberMethods} structure so extension types can define the two operators. *************** *** 1132,1136 **** introduced in Python 2.1 to provide interactive help. \code{help(\var{object})} displays any available help text about ! \var{object}. \code{help()} with no argument puts you in an online help utility, where you can enter the names of functions, classes, or modules to read their help text. --- 1132,1136 ---- introduced in Python 2.1 to provide interactive help. \code{help(\var{object})} displays any available help text about ! \var{object}. \function{help()} with no argument puts you in an online help utility, where you can enter the names of functions, classes, or modules to read their help text. *************** *** 1244,1248 **** presumably faster. Instead of specifying a format string, the caller simply gives the minimum and maximum number of arguments ! expected, and a set of pointers to \code{PyObject*} variables that will be filled in with argument values. --- 1244,1248 ---- presumably faster. Instead of specifying a format string, the caller simply gives the minimum and maximum number of arguments ! expected, and a set of pointers to \ctype{PyObject*} variables that will be filled in with argument values. *************** *** 1359,1366 **** file APIs. As MBCS is explicitly used by the file APIs, Python's choice of ASCII as the default encoding turns out to be an ! annoyance. On Unix, the locale's character set is used if \function{locale.nl_langinfo(CODESET)} is available. (Windows support was contributed by Mark Hammond with assistance from ! Marc-Andr\'e Lemburg. Unix support was added by Martin von L\"owis.) \item Large file support is now enabled on Windows. (Contributed by --- 1359,1366 ---- file APIs. As MBCS is explicitly used by the file APIs, Python's choice of ASCII as the default encoding turns out to be an ! annoyance. On \UNIX, the locale's character set is used if \function{locale.nl_langinfo(CODESET)} is available. (Windows support was contributed by Mark Hammond with assistance from ! Marc-Andr\'e Lemburg. \UNIX{} support was added by Martin von L\"owis.) \item Large file support is now enabled on Windows. (Contributed by From fdrake@sourceforge.net Thu May 2 18:56:19 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 10:56:19 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew22.tex,1.54,1.54.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv5558/whatsnew Modified Files: Tag: release22-maint whatsnew22.tex Log Message: Many minor markup adjustments for consistency. Index: whatsnew22.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew22.tex,v retrieving revision 1.54 retrieving revision 1.54.2.1 diff -C2 -d -r1.54 -r1.54.2.1 *** whatsnew22.tex 21 Dec 2001 04:39:11 -0000 1.54 --- whatsnew22.tex 2 May 2002 17:56:17 -0000 1.54.2.1 *************** *** 521,527 **** own iterator, this method can just return \code{self}. In particular, iterators will usually be their own iterators. Extension types ! implemented in C can implement a \code{tp_iter} function in order to return an iterator, and extension types that want to behave as ! iterators can define a \code{tp_iternext} function. So, after all this, what do iterators actually do? They have one --- 521,527 ---- own iterator, this method can just return \code{self}. In particular, iterators will usually be their own iterators. Extension types ! implemented in C can implement a \member{tp_iter} function in order to return an iterator, and extension types that want to behave as ! iterators can define a \member{tp_iternext} function. So, after all this, what do iterators actually do? They have one *************** *** 552,556 **** For backward compatibility and convenience, an iterator is automatically constructed for sequences that don't implement ! \method{__iter__()} or a \code{tp_iter} slot, so \code{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 --- 552,556 ---- For backward compatibility and convenience, an iterator is automatically constructed for sequences that don't implement ! \method{__iter__()} or a \member{tp_iter} slot, so \code{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 *************** *** 659,667 **** \keyword{return} statement is that on reaching a \keyword{yield} the generator's state of execution is suspended and local variables are ! preserved. On the next call to the generator's \code{.next()} method, the function will resume executing immediately after the \keyword{yield} statement. (For complicated reasons, the \keyword{yield} statement isn't allowed inside the \keyword{try} block ! of a \code{try...finally} statement; read \pep{255} for a full explanation of the interaction between \keyword{yield} and exceptions.) --- 659,667 ---- \keyword{return} statement is that on reaching a \keyword{yield} the generator's state of execution is suspended and local variables are ! preserved. On the next call to the generator's \code{next()} method, the function will resume executing immediately after the \keyword{yield} statement. (For complicated reasons, the \keyword{yield} statement isn't allowed inside the \keyword{try} block ! of a \keyword{try}...\keyword{finally} statement; read \pep{255} for a full explanation of the interaction between \keyword{yield} and exceptions.) *************** *** 863,867 **** \item Classes can define methods called \method{__truediv__} and \method{__floordiv__} to overload the two division operators. At the ! C level, there are also slots in the \code{PyNumberMethods} structure so extension types can define the two operators. --- 863,867 ---- \item Classes can define methods called \method{__truediv__} and \method{__floordiv__} to overload the two division operators. At the ! C level, there are also slots in the \ctype{PyNumberMethods} structure so extension types can define the two operators. *************** *** 1131,1135 **** introduced in Python 2.1 to provide interactive help. \code{help(\var{object})} displays any available help text about ! \var{object}. \code{help()} with no argument puts you in an online help utility, where you can enter the names of functions, classes, or modules to read their help text. --- 1131,1135 ---- introduced in Python 2.1 to provide interactive help. \code{help(\var{object})} displays any available help text about ! \var{object}. \function{help()} with no argument puts you in an online help utility, where you can enter the names of functions, classes, or modules to read their help text. *************** *** 1243,1247 **** presumably faster. Instead of specifying a format string, the caller simply gives the minimum and maximum number of arguments ! expected, and a set of pointers to \code{PyObject*} variables that will be filled in with argument values. --- 1243,1247 ---- presumably faster. Instead of specifying a format string, the caller simply gives the minimum and maximum number of arguments ! expected, and a set of pointers to \ctype{PyObject*} variables that will be filled in with argument values. *************** *** 1356,1363 **** file APIs. As MBCS is explicitly used by the file APIs, Python's choice of ASCII as the default encoding turns out to be an ! annoyance. On Unix, the locale's character set is used if \function{locale.nl_langinfo(CODESET)} is available. (Windows support was contributed by Mark Hammond with assistance from ! Marc-Andr\'e Lemburg. Unix support was added by Martin von L\"owis.) \item Large file support is now enabled on Windows. (Contributed by --- 1356,1363 ---- file APIs. As MBCS is explicitly used by the file APIs, Python's choice of ASCII as the default encoding turns out to be an ! annoyance. On \UNIX, the locale's character set is used if \function{locale.nl_langinfo(CODESET)} is available. (Windows support was contributed by Mark Hammond with assistance from ! Marc-Andr\'e Lemburg. \UNIX{} support was added by Martin von L\"owis.) \item Large file support is now enabled on Windows. (Contributed by From fdrake@sourceforge.net Thu May 2 19:13:50 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 11:13:50 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_b2.py,1.29.6.2,1.29.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv11406 Modified Files: Tag: release22-maint test_b2.py Log Message: Add a regression test that was removed prematurely. This tests deprecated (but not removed!) features of the xrange object. This test should be maintained for all of 2.2.x to avoid regression failures. Index: test_b2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b2.py,v retrieving revision 1.29.6.2 retrieving revision 1.29.6.3 diff -C2 -d -r1.29.6.2 -r1.29.6.3 *** test_b2.py 2 May 2002 16:07:59 -0000 1.29.6.2 --- test_b2.py 2 May 2002 18:13:48 -0000 1.29.6.3 *************** *** 297,300 **** --- 297,314 ---- if r.stop != 3: raise TestFailed, 'xrange(10, 3, -1).stop' if r.step != -1: raise TestFailed, 'xrange(10, 3, -1).step' + # regression tests for SourceForge bug #221965 + def _range_test(r): + verify(r.start != r.stop, 'Test not valid for passed-in xrange object.') + if r.stop in r: + raise TestFailed, 'r.stop in ' + `r` + if r.stop-r.step not in r: + raise TestFailed, 'r.stop-r.step not in ' + `r` + if r.start not in r: + raise TestFailed, 'r.start not in ' + `r` + if r.stop+r.step in r: + raise TestFailed, 'r.stop+r.step in ' + `r` + _range_test(xrange(10)) + _range_test(xrange(9, -1, -1)) + _range_test(xrange(0, 10, 2)) print 'zip' From fdrake@sourceforge.net Thu May 2 19:40:33 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 11:40:33 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_b2.py,1.32,1.33 test_repr.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv19354/Lib/test Modified Files: test_b2.py test_repr.py Log Message: Remove all tests that rely on deprecated-in-2.2 features of xrange objects. "What's New in Python 2.2" documented that these would be removed in Python 2.3. Index: test_b2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b2.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** test_b2.py 2 May 2002 16:07:44 -0000 1.32 --- test_b2.py 2 May 2002 18:40:31 -0000 1.33 *************** *** 296,320 **** if tuple(xrange(0,10,2)) != tuple(range(0,10,2)): raise TestFailed, 'xrange(0,10,2)' - r = xrange(10) - if r.tolist() != range(10): raise TestFailed, 'xrange(10).tolist()' - if r.start != 0: raise TestFailed, 'xrange(10).start' - if r.stop != 10: raise TestFailed, 'xrange(10).stop' - if r.step != 1: raise TestFailed, 'xrange(10).step' - r = xrange(3, 10) - if r.tolist() != range(3, 10): raise TestFailed, 'xrange(3, 10).tolist()' - if r.start != 3: raise TestFailed, 'xrange(3, 10).start' - if r.stop != 10: raise TestFailed, 'xrange(3, 10).stop' - if r.step != 1: raise TestFailed, 'xrange(3, 10).step' - r = xrange(3, 10, 2) - if r.tolist() != range(3, 10, 2): raise TestFailed, 'xrange(3, 10, 2).tolist()' - if r.start != 3: raise TestFailed, 'xrange(3, 10, 2).start' - if r.stop != 11: raise TestFailed, 'xrange(3, 10, 2).stop' - if r.step != 2: raise TestFailed, 'xrange(3, 10, 2).step' - r = xrange(10, 3, -1) - if r.tolist() != range(10, 3, -1): - raise TestFailed, 'xrange(10, 3, -1).tolist()' - if r.start != 10: raise TestFailed, 'xrange(10, 3, -1).start' - if r.stop != 3: raise TestFailed, 'xrange(10, 3, -1).stop' - if r.step != -1: raise TestFailed, 'xrange(10, 3, -1).step' print 'zip' --- 296,299 ---- Index: test_repr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_repr.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_repr.py 16 Apr 2002 01:27:44 -0000 1.12 --- test_repr.py 2 May 2002 18:40:31 -0000 1.13 *************** *** 111,122 **** eq(repr(xrange(1, 2)), 'xrange(1, 2)') eq(repr(xrange(1, 2, 3)), 'xrange(1, 4, 3)') - # Turn off warnings for deprecated multiplication - warnings.filterwarnings('ignore', - r'xrange object multiplication is deprecated', - DeprecationWarning, module=ReprTests.__module__) - warnings.filterwarnings('ignore', - r"PyRange_New's 'repetitions' argument is deprecated", - DeprecationWarning, module=ReprTests.__module__) - eq(repr(xrange(1) * 3), '(xrange(1) * 3)') def test_nesting(self): --- 111,114 ---- From fdrake@sourceforge.net Thu May 2 20:56:58 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 12:56:58 -0700 Subject: [Python-checkins] python/dist/src/Objects rangeobject.c,2.34,2.35 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv12620/Objects Modified Files: rangeobject.c Log Message: Remove old deprecated features from the xrange object. Index: rangeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/rangeobject.c,v retrieving revision 2.34 retrieving revision 2.35 diff -C2 -d -r2.34 -r2.35 *** rangeobject.c 2 May 2002 16:05:27 -0000 2.34 --- rangeobject.c 2 May 2002 19:56:55 -0000 2.35 *************** *** 3,11 **** #include "Python.h" - #include "structmember.h" - #include - - #define WARN(msg) if (PyErr_Warn(PyExc_DeprecationWarning, msg) < 0) \ - return NULL; typedef struct { --- 3,6 ---- *************** *** 14,78 **** long step; long len; - int reps; - long totlen; } rangeobject; - static int - long_mul(long i, long j, long *kk) - { - PyObject *a; - PyObject *b; - PyObject *c; - - if ((a = PyInt_FromLong(i)) == NULL) - return 0; - - if ((b = PyInt_FromLong(j)) == NULL) - return 0; - - c = PyNumber_Multiply(a, b); - - Py_DECREF(a); - Py_DECREF(b); - - if (c == NULL) - return 0; - - if (!PyInt_Check(c)) { - Py_DECREF(c); - goto overflow; - } - - *kk = PyInt_AS_LONG(c); - Py_DECREF(c); - - if (*kk > INT_MAX) { - overflow: - PyErr_SetString(PyExc_OverflowError, - "integer multiplication"); - return 0; - } - else - return 1; - } - PyObject * PyRange_New(long start, long len, long step, int reps) { ! long totlen = -1; ! rangeobject *obj = PyObject_New(rangeobject, &PyRange_Type); if (obj == NULL) return NULL; - - if (reps != 1) - WARN("PyRange_New's 'repetitions' argument is deprecated"); ! if (len == 0 || reps <= 0) { start = 0; len = 0; step = 1; - reps = 1; - totlen = 0; } else { --- 9,33 ---- long step; long len; } rangeobject; PyObject * PyRange_New(long start, long len, long step, int reps) { ! rangeobject *obj; ! ! if (reps != 1) { ! PyErr_SetString(PyExc_ValueError, ! "PyRange_New's 'repetitions' argument must be 1"); ! return NULL; ! } + obj = PyObject_New(rangeobject, &PyRange_Type); if (obj == NULL) return NULL; ! if (len == 0) { start = 0; len = 0; step = 1; } else { *************** *** 85,121 **** return NULL; } - if (! long_mul(len, (long) reps, &totlen)) { - if(!PyErr_ExceptionMatches(PyExc_OverflowError)) - return NULL; - PyErr_Clear(); - totlen = -1; - } } - obj->start = start; obj->len = len; obj->step = step; - obj->reps = reps; - obj->totlen = totlen; return (PyObject *) obj; } - static void - range_dealloc(rangeobject *r) - { - PyObject_Del(r); - } - static PyObject * range_item(rangeobject *r, int i) { ! if (i < 0 || i >= r->totlen) ! if (r->totlen!=-1) { ! PyErr_SetString(PyExc_IndexError, "xrange object index out of range"); ! return NULL; ! } ! return PyInt_FromLong(r->start + (i % r->len) * r->step); } --- 40,59 ---- return NULL; } } obj->start = start; obj->len = len; obj->step = step; return (PyObject *) obj; } static PyObject * range_item(rangeobject *r, int i) { ! if (i < 0 || i >= r->len) { ! PyErr_SetString(PyExc_IndexError, "xrange object index out of range"); ! return NULL; ! } return PyInt_FromLong(r->start + (i % r->len) * r->step); } *************** *** 124,131 **** range_length(rangeobject *r) { ! if (r->totlen == -1) ! PyErr_SetString(PyExc_OverflowError, ! "xrange object has too many items"); ! return r->totlen; } --- 62,66 ---- range_length(rangeobject *r) { ! return r->len; } *************** *** 149,353 **** r->start + r->len * r->step, r->step); - if (r->reps != 1) { - PyObject *extra = PyString_FromFormat( - "(%s * %d)", - PyString_AS_STRING(rtn), r->reps); - Py_DECREF(rtn); - rtn = extra; - } return rtn; } - static PyObject * - range_repeat(rangeobject *r, int n) - { - long lreps = 0; - - WARN("xrange object multiplication is deprecated; " - "convert to list instead"); - - if (n <= 0) - return (PyObject *) PyRange_New(0, 0, 1, 1); - - else if (n == 1) { - Py_INCREF(r); - return (PyObject *) r; - } - - else if (! long_mul((long) r->reps, (long) n, &lreps)) - return NULL; - - else - return (PyObject *) PyRange_New( - r->start, - r->len, - r->step, - (int) lreps); - } - - static int - range_compare(rangeobject *r1, rangeobject *r2) - { - - if (PyErr_Warn(PyExc_DeprecationWarning, - "xrange object comparison is deprecated; " - "convert to list instead") < 0) - return -1; - - if (r1->start != r2->start) - return r1->start - r2->start; - - else if (r1->step != r2->step) - return r1->step - r2->step; - - else if (r1->len != r2->len) - return r1->len - r2->len; - - else - return r1->reps - r2->reps; - } - - static PyObject * - range_slice(rangeobject *r, int low, int high) - { - WARN("xrange object slicing is deprecated; " - "convert to list instead"); - - if (r->reps != 1) { - PyErr_SetString(PyExc_TypeError, - "cannot slice a replicated xrange"); - return NULL; - } - if (low < 0) - low = 0; - else if (low > r->len) - low = r->len; - if (high < 0) - high = 0; - if (high < low) - high = low; - else if (high > r->len) - high = r->len; - - if (low == 0 && high == r->len) { - Py_INCREF(r); - return (PyObject *) r; - } - - return (PyObject *) PyRange_New( - low * r->step + r->start, - high - low, - r->step, - 1); - } - - static PyObject * - range_tolist(rangeobject *self, PyObject *args) - { - PyObject *thelist; - int j; - - WARN("xrange.tolist() is deprecated; use list(xrange) instead"); - - if (self->totlen == -1) - return PyErr_NoMemory(); - - if ((thelist = PyList_New(self->totlen)) == NULL) - return NULL; - - for (j = 0; j < self->totlen; ++j) - if ((PyList_SetItem(thelist, j, (PyObject *) PyInt_FromLong( - self->start + (j % self->len) * self->step))) < 0) - return NULL; - - return thelist; - } - - static PyObject * - range_get_stop(rangeobject *self, void *closure) - { - return PyInt_FromLong(self->start + (self->len * self->step)); - } - - static PyMethodDef range_methods[] = { - {"tolist", (PyCFunction)range_tolist, METH_NOARGS, - "tolist() -> list\n" - "Return a list object with the same values.\n" - "(This method is deprecated; use list() instead.)"}, - {NULL, NULL} - }; - - static PyMemberDef range_members[] = { - {"step", T_LONG, offsetof(rangeobject, step), RO, - "Interval between indexes of the slice; also known as the 'stride'."}, - {"start", T_LONG, offsetof(rangeobject, start), RO, - "First index of the slice."}, - {NULL, 0, 0, 0} - }; - - static PyGetSetDef range_getsets[] = { - {"stop", (getter)range_get_stop, NULL, - ""}, - {NULL}, - }; - - static PyObject * - range_getattro(rangeobject *self, PyObject *name) - { - PyObject *result; - result = PyObject_GenericGetAttr((PyObject *)self, name); - if (result && PyInt_CheckExact(result)) { - WARN("xrange object's 'start', 'stop' and 'step' " - "attributes are deprecated"); - } - return result; - } - static PySequenceMethods range_as_sequence = { ! (inquiry)range_length, /*sq_length*/ ! 0, /*sq_concat*/ ! (intargfunc)range_repeat, /*sq_repeat*/ ! (intargfunc)range_item, /*sq_item*/ ! (intintargfunc)range_slice, /*sq_slice*/ ! 0, /*sq_ass_item*/ ! 0, /*sq_ass_slice*/ ! 0, /*sq_contains*/ }; PyTypeObject PyRange_Type = { PyObject_HEAD_INIT(&PyType_Type) ! 0, /* Number of items for varobject */ ! "xrange", /* Name of this type */ ! sizeof(rangeobject), /* Basic object size */ ! 0, /* Item size for varobject */ ! (destructor)range_dealloc, /*tp_dealloc*/ ! 0, /*tp_print*/ ! 0, /*tp_getattr*/ ! 0, /*tp_setattr*/ ! (cmpfunc)range_compare, /*tp_compare*/ ! (reprfunc)range_repr, /*tp_repr*/ ! 0, /*tp_as_number*/ ! &range_as_sequence, /*tp_as_sequence*/ ! 0, /*tp_as_mapping*/ ! 0, /*tp_hash*/ ! 0, /*tp_call*/ ! 0, /*tp_str*/ ! (getattrofunc)range_getattro, /*tp_getattro*/ ! 0, /*tp_setattro*/ ! 0, /*tp_as_buffer*/ ! Py_TPFLAGS_DEFAULT, /*tp_flags*/ ! 0, /* tp_doc */ ! 0, /* tp_traverse */ ! 0, /* tp_clear */ ! 0, /* tp_richcompare */ ! 0, /* tp_weaklistoffset */ ! 0, /* tp_iter */ ! 0, /* tp_iternext */ ! range_methods, /* tp_methods */ ! range_members, /* tp_members */ ! range_getsets, /* tp_getset */ ! 0, /* tp_base */ ! 0, /* tp_dict */ }; - - #undef WARN --- 84,120 ---- r->start + r->len * r->step, r->step); return rtn; } static PySequenceMethods range_as_sequence = { ! (inquiry)range_length, /* sq_length */ ! 0, /* sq_concat */ ! 0, /* sq_repeat */ ! (intargfunc)range_item, /* sq_item */ ! 0, /* sq_slice */ }; PyTypeObject PyRange_Type = { PyObject_HEAD_INIT(&PyType_Type) ! 0, /* Number of items for varobject */ ! "xrange", /* Name of this type */ ! sizeof(rangeobject), /* Basic object size */ ! 0, /* Item size for varobject */ ! (destructor)PyObject_Del, /* tp_dealloc */ ! 0, /* tp_print */ ! 0, /* tp_getattr */ ! 0, /* tp_setattr */ ! 0, /* tp_compare */ ! (reprfunc)range_repr, /* tp_repr */ ! 0, /* tp_as_number */ ! &range_as_sequence, /* tp_as_sequence */ ! 0, /* tp_as_mapping */ ! 0, /* tp_hash */ ! 0, /* tp_call */ ! 0, /* tp_str */ ! 0, /* tp_getattro */ ! 0, /* tp_setattro */ ! 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT, /* tp_flags */ ! 0, /* tp_doc */ }; From loewis@sourceforge.net Thu May 2 21:10:01 2002 From: loewis@sourceforge.net (loewis@sourceforge.net) Date: Thu, 02 May 2002 13:10:01 -0700 Subject: [Python-checkins] python/dist/src/Modules arraymodule.c,2.70,2.71 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv16518 Modified Files: arraymodule.c Log Message: Patch #551009: Initialize array type dynamically. Index: arraymodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v retrieving revision 2.70 retrieving revision 2.71 diff -C2 -d -r2.70 -r2.71 *** arraymodule.c 12 Apr 2002 02:39:57 -0000 2.70 --- arraymodule.c 2 May 2002 20:09:59 -0000 2.71 *************** *** 1698,1702 **** 0, /* tp_call */ 0, /* tp_str */ ! PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ &array_as_buffer, /* tp_as_buffer*/ --- 1698,1702 ---- 0, /* tp_call */ 0, /* tp_str */ ! 0, /* tp_getattro */ 0, /* tp_setattro */ &array_as_buffer, /* tp_as_buffer*/ *************** *** 1718,1724 **** 0, /* tp_dictoffset */ 0, /* tp_init */ ! PyType_GenericAlloc, /* tp_alloc */ array_new, /* tp_new */ ! PyObject_Del, /* tp_free */ }; --- 1718,1724 ---- 0, /* tp_dictoffset */ 0, /* tp_init */ ! 0, /* tp_alloc */ array_new, /* tp_new */ ! 0, /* tp_free */ }; *************** *** 1735,1738 **** --- 1735,1741 ---- Arraytype.ob_type = &PyType_Type; + Arraytype.tp_getattro = PyObject_GenericGetAttr; + Arraytype.tp_alloc = PyType_GenericAlloc; + Arraytype.tp_free = PyObject_Del; m = Py_InitModule3("array", a_methods, module_doc); From tim_one@sourceforge.net Thu May 2 21:19:37 2002 From: tim_one@sourceforge.net (tim_one@sourceforge.net) Date: Thu, 02 May 2002 13:19:37 -0700 Subject: [Python-checkins] python/dist/src/Objects obmalloc.c,2.44,2.45 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv19140/python/Objects Modified Files: obmalloc.c Log Message: PyObject_Realloc(): If a small block is shrinking, bite the expense of copying it if at least 25% of the input block can be reclaimed. Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.44 retrieving revision 2.45 diff -C2 -d -r2.44 -r2.45 *** obmalloc.c 28 Apr 2002 06:14:45 -0000 2.44 --- obmalloc.c 2 May 2002 20:19:34 -0000 2.45 *************** *** 794,802 **** /* We're in charge of this block */ size = INDEX2SIZE(pool->szidx); ! if (size >= nbytes) ! /* Don't bother if a smaller size was requested. */ ! return p; ! /* We need more memory. */ ! assert(nbytes != 0); bp = PyObject_Malloc(nbytes); if (bp != NULL) { --- 794,813 ---- /* We're in charge of this block */ size = INDEX2SIZE(pool->szidx); ! if (nbytes <= size) { ! /* The block is staying the same or shrinking. If ! * it's shrinking, there's a tradeoff: it costs ! * cycles to copy the block to a smaller size class, ! * but it wastes memory not to copy it. The ! * compromise here is to copy on shrink only if at ! * least 25% of size can be shaved off. ! */ ! if (4 * nbytes > 3 * size) { ! /* It's the same, ! * or shrinking and new/old > 3/4. ! */ ! return p; ! } ! size = nbytes; ! } bp = PyObject_Malloc(nbytes); if (bp != NULL) { From loewis@sourceforge.net Thu May 2 21:23:35 2002 From: loewis@sourceforge.net (loewis@sourceforge.net) Date: Thu, 02 May 2002 13:23:35 -0700 Subject: [Python-checkins] python/dist/src/Include boolobject.h,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv20318 Modified Files: boolobject.h Log Message: Patch #551008: DL_IMPORT PyBool_FromLong. Index: boolobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/boolobject.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** boolobject.h 6 Apr 2002 03:58:41 -0000 1.2 --- boolobject.h 2 May 2002 20:23:27 -0000 1.3 *************** *** 25,29 **** /* Function to return a bool from a C long */ ! PyObject *PyBool_FromLong(long); #ifdef __cplusplus --- 25,29 ---- /* Function to return a bool from a C long */ ! extern DL_IMPORT(PyObject *) PyBool_FromLong(long); #ifdef __cplusplus From loewis@sourceforge.net Thu May 2 21:34:16 2002 From: loewis@sourceforge.net (loewis@sourceforge.net) Date: Thu, 02 May 2002 13:34:16 -0700 Subject: [Python-checkins] python/dist/src/Modules arraymodule.c,2.71,2.72 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv23722 Modified Files: arraymodule.c Log Message: Indicate delayed initialization of slots. Suggested by tim.one. Index: arraymodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v retrieving revision 2.71 retrieving revision 2.72 diff -C2 -d -r2.71 -r2.72 *** arraymodule.c 2 May 2002 20:09:59 -0000 2.71 --- arraymodule.c 2 May 2002 20:34:12 -0000 2.72 *************** *** 14,17 **** --- 14,19 ---- #endif /* !STDC_HEADERS */ + #define DELAYED(X) 0 + struct arrayobject; /* Forward */ *************** *** 1698,1702 **** 0, /* tp_call */ 0, /* tp_str */ ! 0, /* tp_getattro */ 0, /* tp_setattro */ &array_as_buffer, /* tp_as_buffer*/ --- 1700,1704 ---- 0, /* tp_call */ 0, /* tp_str */ ! DELAYED(PyObject_GenericGetAttr), /* tp_getattro */ 0, /* tp_setattro */ &array_as_buffer, /* tp_as_buffer*/ *************** *** 1718,1724 **** 0, /* tp_dictoffset */ 0, /* tp_init */ ! 0, /* tp_alloc */ array_new, /* tp_new */ ! 0, /* tp_free */ }; --- 1720,1726 ---- 0, /* tp_dictoffset */ 0, /* tp_init */ ! DELAYED(PyType_GenericAlloc), /* tp_alloc */ array_new, /* tp_new */ ! DELAYED(PyObject_Del), /* tp_free */ }; From fdrake@sourceforge.net Thu May 2 21:42:33 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 13:42:33 -0700 Subject: [Python-checkins] python/dist/src/Doc/tools node2label.pl,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory usw-pr-cvs1:/tmp/cvs-serv26821/tools Modified Files: node2label.pl Log Message: Work around limitation of Cygwin Perl: To avoid a permission denial, we need to do the inplace-edit with a backup file. A quick test leads me to believe this is sufficient to allow building the documentation on Cygwin; a full test is in progress. Index: node2label.pl =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/node2label.pl,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** node2label.pl 23 Jun 2001 04:35:09 -0000 1.12 --- node2label.pl 2 May 2002 20:42:30 -0000 1.13 *************** *** 1,6 **** #! /usr/bin/env perl use English; ! $INPLACE_EDIT = ''; # read the labels, then reverse the mappings --- 1,11 ---- #! /usr/bin/env perl + # On Cygwin, we actually have to generate a temporary file when doing + # the inplace edit, or we'll get permission errors. Not sure who's + # bug this is, except that it isn't ours. To deal with this, we + # generate backups during the edit phase and remove them at the end. + # use English; ! $INPLACE_EDIT = '.bak'; # read the labels, then reverse the mappings *************** *** 60,62 **** --- 65,71 ---- foreach $oldname (keys %newnames) { rename($oldname, $newnames{$oldname}); + } + + foreach $filename (glob('*.bak')) { + unlink($filename); } From fdrake@sourceforge.net Thu May 2 22:10:51 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 14:10:51 -0700 Subject: [Python-checkins] python/dist/src/Doc/doc doc.tex,1.64,1.65 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/doc In directory usw-pr-cvs1:/tmp/cvs-serv3252/doc Modified Files: doc.tex Log Message: Remove the warning about the Cygwin directions not working -- the latest change to Doc/tools/node2label.pl (revision 1.13) makes this work. Index: doc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/doc/doc.tex,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** doc.tex 1 May 2002 22:05:30 -0000 1.64 --- doc.tex 2 May 2002 21:10:48 -0000 1.65 *************** *** 1758,1767 **** \subsection{Working on Cygwin \label{cygwin}} - \begin{notice}[warning] - This section is a work in progress. It really doesn't work - yet. If anyone knows Cygwin and wants to help, send email to - \email{python-docs@python.org}. - \end{notice} - Installing the required tools under Cygwin under Cygwin can be a little tedious, if only because many packages are more difficult --- 1758,1761 ---- *************** *** 1794,1797 **** --- 1788,1794 ---- % configure && make install \end{verbatim} + + You should now be able to build at least the HTML, PDF, and + PostScript versions of the formatted documentation. From fdrake@sourceforge.net Thu May 2 22:15:19 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 14:15:19 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv4822/whatsnew Modified Files: whatsnew23.tex Log Message: Added note about using the documentation build tools under Cygwin. Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** whatsnew23.tex 29 Apr 2002 15:42:16 -0000 1.9 --- whatsnew23.tex 2 May 2002 21:15:16 -0000 1.10 *************** *** 261,264 **** --- 261,266 ---- \section{Other Changes and Fixes} + The tools used to build the documentation now work under Cygwin as + well as \UNIX. % ====================================================================== From fdrake@sourceforge.net Thu May 2 22:17:03 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 14:17:03 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.399,1.400 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv5596/Misc Modified Files: NEWS Log Message: Added note about using the documentation build tools under Cygwin. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.399 retrieving revision 1.400 diff -C2 -d -r1.399 -r1.400 *** NEWS 1 May 2002 20:33:53 -0000 1.399 --- NEWS 2 May 2002 21:17:00 -0000 1.400 *************** *** 178,181 **** --- 178,184 ---- controlled stopped being experimental long ago. + - The tools used to build the documentation now work under Cygwin as + well as Unix. + C API From fdrake@sourceforge.net Thu May 2 22:28:30 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 14:28:30 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.400,1.401 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv10349/Misc Modified Files: NEWS Log Message: Added notes related to the removal of deprecated features of the xrange type. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.400 retrieving revision 1.401 diff -C2 -d -r1.400 -r1.401 *** NEWS 2 May 2002 21:17:00 -0000 1.400 --- NEWS 2 May 2002 21:28:26 -0000 1.401 *************** *** 7,10 **** --- 7,15 ---- Core and builtins + - Deprecated features of xrange objects have been removed as + promised. The start, stop, and step attributes and the tolist() + method no longer exist. xrange repetition and slicing have been + removed. + - New builtin function enumerate(x), from PEP 279. Example: enumerate("abc") is an iterator returning (0,"a"), (1,"b"), (2,"c"). *************** *** 182,185 **** --- 187,194 ---- C API + + - PyRange_New() now raises ValueError if the fourth argument is not 1. + This is part of the removal of deprecated features of the xrange + object. - PyNumber_Coerce() and PyNumber_CoerceEx() now also invoke the type's From fdrake@sourceforge.net Thu May 2 22:37:25 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 14:37:25 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex,1.91,1.92 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv13372/lib Modified Files: libstdtypes.tex Log Message: Update the xrange object description to reflect the removal of deprecated features. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.91 retrieving revision 1.92 diff -C2 -d -r1.91 -r1.92 *** libstdtypes.tex 2 May 2002 17:54:18 -0000 1.91 --- libstdtypes.tex 2 May 2002 21:37:23 -0000 1.92 *************** *** 402,408 **** syntax to create them, but they are created using the \function{xrange()} function.\bifuncindex{xrange} They don't support ! slicing or concatenation, but do support repetition, and using ! \code{in}, \code{not in}, \function{min()} or \function{max()} on them ! is inefficient. \obindex{xrange} --- 402,408 ---- syntax to create them, but they are created using the \function{xrange()} function.\bifuncindex{xrange} They don't support ! slicing, concatenation, or repetition, and using \keyword{in}, ! \keyword{not} \keyword{in}, \function{min()} or \function{max()} on ! them is inefficient. \obindex{xrange} From tim_one@sourceforge.net Thu May 2 22:59:10 2002 From: tim_one@sourceforge.net (tim_one@sourceforge.net) Date: Thu, 02 May 2002 14:59:10 -0700 Subject: [Python-checkins] python/dist/src/Doc/tools prechm.py,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory usw-pr-cvs1:/tmp/cvs-serv21334/tools Modified Files: prechm.py Log Message: Boost the list of stop words, by merging in the little list Jeremy just checked into Zope's ZCTextIndex branch. This reduces the size of the .chm file by about 100KB. Index: prechm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/prechm.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** prechm.py 21 Apr 2002 04:44:11 -0000 1.14 --- prechm.py 2 May 2002 21:59:08 -0000 1.15 *************** *** 118,128 **** # language, so no point indexing them even if we wanted to. stop_list = ''' ! a an and ! is ! near ! not ! of ! or ! the ''' --- 118,130 ---- # language, so no point indexing them even if we wanted to. stop_list = ''' ! a and are as at ! be but by ! for ! if in into is it ! near no not ! of on or ! such ! that the their then there these they this to ! was will with ''' From bwarsaw@sourceforge.net Fri May 3 05:23:04 2002 From: bwarsaw@sourceforge.net (bwarsaw@sourceforge.net) Date: Thu, 02 May 2002 21:23:04 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_rfc822.py,1.9,1.9.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv12422/Lib/test Modified Files: Tag: release21-maint test_rfc822.py Log Message: Backport patch for revision 1.58 to the Py2.1.x maintenance branch. This fixes parseaddr() for the following RFC 2822 valid field: To: User J. Person Index: test_rfc822.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_rfc822.py,v retrieving revision 1.9 retrieving revision 1.9.4.1 diff -C2 -d -r1.9 -r1.9.4.1 *** test_rfc822.py 17 Jan 2001 21:51:36 -0000 1.9 --- test_rfc822.py 3 May 2002 04:23:02 -0000 1.9.4.1 *************** *** 125,126 **** --- 125,132 ---- foo''', [('', 'guido@[132.151.1.21]')]) + + test('''To: User J. Person + + foo''', [('User J. Person', 'person@dom.ain')]) + + From bwarsaw@sourceforge.net Fri May 3 05:23:04 2002 From: bwarsaw@sourceforge.net (bwarsaw@sourceforge.net) Date: Thu, 02 May 2002 21:23:04 -0700 Subject: [Python-checkins] python/dist/src/Lib rfc822.py,1.54.4.1,1.54.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv12422/Lib Modified Files: Tag: release21-maint rfc822.py Log Message: Backport patch for revision 1.58 to the Py2.1.x maintenance branch. This fixes parseaddr() for the following RFC 2822 valid field: To: User J. Person Index: rfc822.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/rfc822.py,v retrieving revision 1.54.4.1 retrieving revision 1.54.4.2 diff -C2 -d -r1.54.4.1 -r1.54.4.2 *** rfc822.py 23 Dec 2001 07:02:01 -0000 1.54.4.1 --- rfc822.py 3 May 2002 04:23:02 -0000 1.54.4.2 *************** *** 1,51 **** ! """RFC-822 message manipulation class. ! XXX This is only a very rough sketch of a full RFC-822 parser; ! in particular the tokenizing of addresses does not adhere to all the ! quoting rules. Directions for use: To create a Message object: first open a file, e.g.: fp = open(file, 'r') You can use any other legal way of getting an open file object, e.g. use ! sys.stdin or call os.popen(). ! Then pass the open file object to the Message() constructor: m = Message(fp) ! This class can work with any input object that supports a readline ! method. If the input object has seek and tell capability, the ! rewindbody method will work; also illegal lines will be pushed back ! onto the input stream. If the input object lacks seek but has an ! `unread' method that can push back a line of input, Message will use ! that to push back illegal lines. Thus this class can be used to parse ! messages coming from a buffered stream. ! The optional `seekable' argument is provided as a workaround for ! certain stdio libraries in which tell() discards buffered data before ! discovering that the lseek() system call doesn't work. For maximum ! portability, you should set the seekable argument to zero to prevent ! that initial \code{tell} when passing in an unseekable object such as ! a a file object created from a socket object. If it is 1 on entry -- ! which it is by default -- the tell() method of the open file object is ! called once; if this raises an exception, seekable is reset to 0. For ! other nonzero values of seekable, this test is not made. To get the text of a particular header there are several methods: str = m.getheader(name) str = m.getrawheader(name) ! where name is the name of the header, e.g. 'Subject'. ! The difference is that getheader() strips the leading and trailing ! whitespace, while getrawheader() doesn't. Both functions retain ! embedded whitespace (including newlines) exactly as they are ! specified in the header, and leave the case of the text unchanged. For addresses and address lists there are functions ! realname, mailaddress = m.getaddr(name) and list = m.getaddrlist(name) where the latter returns a list of (realname, mailaddr) tuples. There is also a method time = m.getdate(name) which parses a Date-like field and returns a time-compatible tuple, i.e. a tuple such as returned by time.localtime() or accepted by --- 1,65 ---- ! """RFC 2822 message manipulation. ! Note: This is only a very rough sketch of a full RFC-822 parser; in particular ! the tokenizing of addresses does not adhere to all the quoting rules. ! ! Note: RFC 2822 is a long awaited update to RFC 822. This module should ! conform to RFC 2822, and is thus mis-named (it's not worth renaming it). Some ! effort at RFC 2822 updates have been made, but a thorough audit has not been ! performed. Consider any RFC 2822 non-conformance to be a bug. ! ! RFC 2822: http://www.faqs.org/rfcs/rfc2822.html ! RFC 822: http://www.faqs.org/rfcs/rfc822.html (obsolete) Directions for use: To create a Message object: first open a file, e.g.: + fp = open(file, 'r') + You can use any other legal way of getting an open file object, e.g. use ! sys.stdin or call os.popen(). Then pass the open file object to the Message() ! constructor: ! m = Message(fp) ! This class can work with any input object that supports a readline method. If ! the input object has seek and tell capability, the rewindbody method will ! work; also illegal lines will be pushed back onto the input stream. If the ! input object lacks seek but has an `unread' method that can push back a line ! of input, Message will use that to push back illegal lines. Thus this class ! can be used to parse messages coming from a buffered stream. ! The optional `seekable' argument is provided as a workaround for certain stdio ! libraries in which tell() discards buffered data before discovering that the ! lseek() system call doesn't work. For maximum portability, you should set the ! seekable argument to zero to prevent that initial \code{tell} when passing in ! an unseekable object such as a a file object created from a socket object. If ! it is 1 on entry -- which it is by default -- the tell() method of the open ! file object is called once; if this raises an exception, seekable is reset to ! 0. For other nonzero values of seekable, this test is not made. To get the text of a particular header there are several methods: + str = m.getheader(name) str = m.getrawheader(name) ! ! where name is the name of the header, e.g. 'Subject'. The difference is that ! getheader() strips the leading and trailing whitespace, while getrawheader() ! doesn't. Both functions retain embedded whitespace (including newlines) ! exactly as they are specified in the header, and leave the case of the text ! unchanged. For addresses and address lists there are functions ! ! realname, mailaddress = m.getaddr(name) list = m.getaddrlist(name) + where the latter returns a list of (realname, mailaddr) tuples. There is also a method + time = m.getdate(name) + which parses a Date-like field and returns a time-compatible tuple, i.e. a tuple such as returned by time.localtime() or accepted by *************** *** 66,70 **** class Message: ! """Represents a single RFC-822-compliant message.""" def __init__(self, fp, seekable = 1): --- 80,84 ---- class Message: ! """Represents a single RFC 2822-compliant message.""" def __init__(self, fp, seekable = 1): *************** *** 107,122 **** """Read header lines. ! Read header lines up to the entirely blank line that ! terminates them. The (normally blank) line that ends the ! headers is skipped, but not included in the returned list. ! If a non-header line ends the headers, (which is an error), ! an attempt is made to backspace over it; it is never ! included in the returned list. ! The variable self.status is set to the empty string if all ! went well, otherwise it is an error message. ! The variable self.headers is a completely uninterpreted list ! of lines contained in the header (so printing them will ! reproduce the header exactly as it appears in the file). """ self.dict = {} --- 121,135 ---- """Read header lines. ! Read header lines up to the entirely blank line that terminates them. ! The (normally blank) line that ends the headers is skipped, but not ! included in the returned list. If a non-header line ends the headers, ! (which is an error), an attempt is made to backspace over it; it is ! never included in the returned list. ! The variable self.status is set to the empty string if all went well, ! otherwise it is an error message. The variable self.headers is a ! completely uninterpreted list of lines contained in the header (so ! printing them will reproduce the header exactly as it appears in the ! file). """ self.dict = {} *************** *** 184,189 **** This method should return the header name, suitably canonicalized. ! You may override this method in order to use Message parsing ! on tagged data in RFC822-like formats with special header formats. """ i = line.find(':') --- 197,202 ---- This method should return the header name, suitably canonicalized. ! You may override this method in order to use Message parsing on tagged ! data in RFC 2822-like formats with special header formats. """ i = line.find(':') *************** *** 194,204 **** def islast(self, line): ! """Determine whether a line is a legal end of RFC-822 headers. ! You may override this method if your application wants ! to bend the rules, e.g. to strip trailing whitespace, ! or to recognize MH template separators ('--------'). ! For convenience (e.g. for code reading from sockets) a ! line consisting of \r\n also matches. """ return line in _blanklines --- 207,216 ---- def islast(self, line): ! """Determine whether a line is a legal end of RFC 2822 headers. ! You may override this method if your application wants to bend the ! rules, e.g. to strip trailing whitespace, or to recognize MH template ! separators ('--------'). For convenience (e.g. for code reading from ! sockets) a line consisting of \r\n also matches. """ return line in _blanklines *************** *** 207,213 **** """Determine whether a line should be skipped entirely. ! You may override this method in order to use Message parsing ! on tagged data in RFC822-like formats that support embedded ! comments or free-text data. """ return None --- 219,225 ---- """Determine whether a line should be skipped entirely. ! You may override this method in order to use Message parsing on tagged ! data in RFC 2822-like formats that support embedded comments or ! free-text data. """ return None *************** *** 216,226 **** """Find all header lines matching a given header name. ! Look through the list of headers and find all lines ! matching a given header name (and their continuation ! lines). A list of the lines is returned, without ! interpretation. If the header does not occur, an ! empty list is returned. If the header occurs multiple ! times, all occurrences are returned. Case is not ! important in the header name. """ name = name.lower() + ':' --- 228,236 ---- """Find all header lines matching a given header name. ! Look through the list of headers and find all lines matching a given ! header name (and their continuation lines). A list of the lines is ! returned, without interpretation. If the header does not occur, an ! empty list is returned. If the header occurs multiple times, all ! occurrences are returned. Case is not important in the header name. """ name = name.lower() + ':' *************** *** 240,246 **** """Get the first header line matching name. ! This is similar to getallmatchingheaders, but it returns ! only the first matching header (and its continuation ! lines). """ name = name.lower() + ':' --- 250,255 ---- """Get the first header line matching name. ! This is similar to getallmatchingheaders, but it returns only the ! first matching header (and its continuation lines). """ name = name.lower() + ':' *************** *** 261,269 **** """A higher-level interface to getfirstmatchingheader(). ! Return a string containing the literal text of the ! header but with the keyword stripped. All leading, ! trailing and embedded whitespace is kept in the ! string, however. ! Return None if the header does not occur. """ --- 270,277 ---- """A higher-level interface to getfirstmatchingheader(). ! Return a string containing the literal text of the header but with the ! keyword stripped. All leading, trailing and embedded whitespace is ! kept in the string, however. Return None if the header does not ! occur. """ *************** *** 277,284 **** """Get the header value for a name. ! This is the normal interface: it returns a stripped ! version of the header value for a given header name, ! or None if it doesn't exist. This uses the dictionary ! version which finds the *last* such header. """ try: --- 285,291 ---- """Get the header value for a name. ! This is the normal interface: it returns a stripped version of the ! header value for a given header name, or None if it doesn't exist. ! This uses the dictionary version which finds the *last* such header. """ try: *************** *** 291,298 **** """Get all values for a header. ! This returns a list of values for headers given more than once; ! each value in the result list is stripped in the same way as the ! result of getheader(). If the header is not given, return an ! empty list. """ result = [] --- 298,304 ---- """Get all values for a header. ! This returns a list of values for headers given more than once; each ! value in the result list is stripped in the same way as the result of ! getheader(). If the header is not given, return an empty list. """ result = [] *************** *** 333,337 **** tuple as returned by getaddr(). Scans all named headers, so it works properly with multiple To: or Cc: headers for example. - """ raw = [] --- 339,342 ---- *************** *** 353,358 **** """Retrieve a date field from a header. ! Retrieves a date field from the named header, returning ! a tuple compatible with time.mktime(). """ try: --- 358,363 ---- """Retrieve a date field from a header. ! Retrieves a date field from the named header, returning a tuple ! compatible with time.mktime(). """ try: *************** *** 365,371 **** """Retrieve a date field from a header as a 10-tuple. ! The first 9 elements make up a tuple compatible with ! time.mktime(), and the 10th is the offset of the poster's ! time zone from GMT/UTC. """ try: --- 370,375 ---- """Retrieve a date field from a header as a 10-tuple. ! The first 9 elements make up a tuple compatible with time.mktime(), ! and the 10th is the offset of the poster's time zone from GMT/UTC. """ try: *************** *** 389,395 **** """Set the value of a header. ! Note: This is not a perfect inversion of __getitem__, because ! any changed headers get stuck at the end of the raw-headers list ! rather than where the altered header was. """ del self[name] # Won't fail if it doesn't exist --- 393,399 ---- """Set the value of a header. ! Note: This is not a perfect inversion of __getitem__, because any ! changed headers get stuck at the end of the raw-headers list rather ! than where the altered header was. """ del self[name] # Won't fail if it doesn't exist *************** *** 484,488 **** To understand what this class does, it helps to have a copy of ! RFC-822 in front of you. Note: this class interface is deprecated and may be removed in the future. --- 488,494 ---- To understand what this class does, it helps to have a copy of ! RFC 2822 in front of you. ! ! http://www.faqs.org/rfcs/rfc2822.html Note: this class interface is deprecated and may be removed in the future. *************** *** 493,498 **** """Initialize a new instance. ! `field' is an unparsed address header field, containing ! one or more addresses. """ self.specials = '()<>@,:;.\"[]' --- 499,504 ---- """Initialize a new instance. ! `field' is an unparsed address header field, containing one or more ! addresses. """ self.specials = '()<>@,:;.\"[]' *************** *** 501,504 **** --- 507,514 ---- self.CR = '\r\n' self.atomends = self.specials + self.LWS + self.CR + # Note that RFC 2822 now specifies `.' as obs-phrase, meaning that it + # is obsolete syntax. RFC 2822 requires that we recognize obsolete + # syntax, so allow dots in phrases. + self.phraseends = self.atomends.replace('.', '') self.field = field self.commentlist = [] *************** *** 615,619 **** def getaddrspec(self): ! """Parse an RFC-822 addr-spec.""" aslist = [] --- 625,629 ---- def getaddrspec(self): ! """Parse an RFC 2822 addr-spec.""" aslist = [] *************** *** 659,671 **** """Parse a header fragment delimited by special characters. ! `beginchar' is the start character for the fragment. ! If self is not looking at an instance of `beginchar' then ! getdelimited returns the empty string. `endchars' is a sequence of allowable end-delimiting characters. Parsing stops when one of these is encountered. ! If `allowcomments' is non-zero, embedded RFC-822 comments ! are allowed within the parsed fragment. """ if self.field[self.pos] != beginchar: --- 669,681 ---- """Parse a header fragment delimited by special characters. ! `beginchar' is the start character for the fragment. If self is not ! looking at an instance of `beginchar' then getdelimited returns the ! empty string. `endchars' is a sequence of allowable end-delimiting characters. Parsing stops when one of these is encountered. ! If `allowcomments' is non-zero, embedded RFC 2822 comments are allowed ! within the parsed fragment. """ if self.field[self.pos] != beginchar: *************** *** 701,713 **** def getdomainliteral(self): ! """Parse an RFC-822 domain-literal.""" return '[%s]' % self.getdelimited('[', ']\r', 0) ! def getatom(self): ! """Parse an RFC-822 atom.""" atomlist = [''] while self.pos < len(self.field): ! if self.field[self.pos] in self.atomends: break else: atomlist.append(self.field[self.pos]) --- 711,730 ---- def getdomainliteral(self): ! """Parse an RFC 2822 domain-literal.""" return '[%s]' % self.getdelimited('[', ']\r', 0) ! def getatom(self, atomends=None): ! """Parse an RFC 2822 atom. ! ! Optional atomends specifies a different set of end token delimiters ! (the default is to use self.atomends). This is used e.g. in ! getphraselist() since phrase endings must not include the `.' (which ! is legal in phrases).""" atomlist = [''] + if atomends is None: + atomends = self.atomends while self.pos < len(self.field): ! if self.field[self.pos] in atomends: break else: atomlist.append(self.field[self.pos]) *************** *** 717,725 **** def getphraselist(self): ! """Parse a sequence of RFC-822 phrases. ! A phrase is a sequence of words, which are in turn either ! RFC-822 atoms or quoted-strings. Phrases are canonicalized ! by squeezing all runs of continuous whitespace into one space. """ plist = [] --- 734,742 ---- def getphraselist(self): ! """Parse a sequence of RFC 2822 phrases. ! A phrase is a sequence of words, which are in turn either RFC 2822 ! atoms or quoted-strings. Phrases are canonicalized by squeezing all ! runs of continuous whitespace into one space. """ plist = [] *************** *** 732,743 **** elif self.field[self.pos] == '(': self.commentlist.append(self.getcomment()) ! elif self.field[self.pos] in self.atomends: break ! else: plist.append(self.getatom()) return plist class AddressList(AddrlistClass): ! """An AddressList encapsulates a list of parsed RFC822 addresses.""" def __init__(self, field): AddrlistClass.__init__(self, field) --- 749,761 ---- elif self.field[self.pos] == '(': self.commentlist.append(self.getcomment()) ! elif self.field[self.pos] in self.phraseends: break ! else: ! plist.append(self.getatom(self.phraseends)) return plist class AddressList(AddrlistClass): ! """An AddressList encapsulates a list of parsed RFC 2822 addresses.""" def __init__(self, field): AddrlistClass.__init__(self, field) From fdrake@sourceforge.net Fri May 3 05:50:53 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 21:50:53 -0700 Subject: [Python-checkins] python/dist/src/Doc Makefile,1.241,1.242 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory usw-pr-cvs1:/tmp/cvs-serv17494 Modified Files: Makefile Log Message: Integrated SF patch #539487 by Matthias Klose: This patch adds Milan Zamazal's conversion script and modifies the mkinfo script to build the info doc files from the LaTeX sources. Currently, the mac, doc and inst TeX files are not handled. Explicitly checks for GNU Emacs 21. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile,v retrieving revision 1.241 retrieving revision 1.242 diff -C2 -d -r1.241 -r1.242 *** Makefile 17 Apr 2002 03:31:08 -0000 1.241 --- Makefile 3 May 2002 04:50:51 -0000 1.242 *************** *** 89,92 **** --- 89,95 ---- HTMLBASE= file:`pwd` + # The emacs binary used to build the info docs. GNU Emacs 21 is required. + EMACS= emacs + # The end of this should reflect the major/minor version numbers of # the release: *************** *** 288,292 **** info: ! cd $(INFODIR) && $(MAKE) # Targets to convert the manuals to HTML using Nikos Drakos' LaTeX to --- 291,295 ---- info: ! cd $(INFODIR) && $(MAKE) EMACS=$(EMACS) # Targets to convert the manuals to HTML using Nikos Drakos' LaTeX to From fdrake@sourceforge.net Fri May 3 05:50:53 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 21:50:53 -0700 Subject: [Python-checkins] python/dist/src/Doc/info Makefile,1.7,1.8 python.dir,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/info In directory usw-pr-cvs1:/tmp/cvs-serv17494/info Modified Files: Makefile python.dir Log Message: Integrated SF patch #539487 by Matthias Klose: This patch adds Milan Zamazal's conversion script and modifies the mkinfo script to build the info doc files from the LaTeX sources. Currently, the mac, doc and inst TeX files are not handled. Explicitly checks for GNU Emacs 21. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/info/Makefile,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Makefile 17 Jul 2001 16:48:55 -0000 1.7 --- Makefile 3 May 2002 04:50:51 -0000 1.8 *************** *** 5,41 **** HTMLDIR=$(TOPDIR)/html MKINFO=$(TOOLSDIR)/mkinfo ! SCRIPTS=$(TOOLSDIR)/html2texi.pl $(TOOLSDIR)/checkargs.pm $(TOOLSDIR)/mkinfo \ ! $(TOOLSDIR)/fixinfo.el ! all: python-api.info python-ext.info python-lib.info \ ! python-ref.info python-tut.info \ ! python-dist.info python-inst.info ! python-api.info: $(HTMLDIR)/api/api.html $(SCRIPTS) ! $(MKINFO) $< ! python-ext.info: $(HTMLDIR)/ext/ext.html $(SCRIPTS) ! $(MKINFO) $< ! python-lib.info: $(HTMLDIR)/lib/lib.html $(SCRIPTS) ! $(MKINFO) $< # Not built by default; the conversion doesn't really handle it well. ! python-mac.info: $(HTMLDIR)/mac/mac.html $(SCRIPTS) ! $(MKINFO) $< ! python-ref.info: $(HTMLDIR)/ref/ref.html $(SCRIPTS) ! $(MKINFO) $< ! python-tut.info: $(HTMLDIR)/tut/tut.html $(SCRIPTS) ! $(MKINFO) $< ! python-dist.info: $(HTMLDIR)/dist/dist.html $(SCRIPTS) ! $(MKINFO) $< ! python-inst.info: $(HTMLDIR)/inst/inst.html $(SCRIPTS) ! $(MKINFO) $< clean: --- 5,66 ---- HTMLDIR=$(TOPDIR)/html + # The emacs binary used to build the info docs. GNU Emacs 21 is required. + EMACS=emacs + MKINFO=$(TOOLSDIR)/mkinfo ! SCRIPTS=$(TOOLSDIR)/checkargs.pm $(TOOLSDIR)/mkinfo $(TOOLSDIR)/py2texi.el ! # set VERSION to code the VERSION number into the info file name ! # allowing installation of more than one set of python info docs ! # into the same directory ! VERSION= + all: check-emacs-version \ + python$(VERSION)-api.info python$(VERSION)-ext.info \ + python$(VERSION)-lib.info python$(VERSION)-ref.info \ + python$(VERSION)-tut.info python$(VERSION)-dist.info ! # python$(VERSION)-doc.info python$(VERSION)-inst.info ! # python$(VERSION)-mac.info ! check-emacs-version: ! @v="`$(EMACS) --version 2>&1 | egrep '^(GNU |X)Emacs [12]*'`"; \ ! if `echo "$$v" | grep '^GNU Emacs 21' >/dev/null 2>&1`; then \ ! echo "Using $(EMACS) to build the info docs"; \ ! else \ ! echo "GNU Emacs 21 is required to build the info docs"; \ ! echo "Found $$v"; \ ! false; \ ! fi ! python$(VERSION)-api.info: ../api/api.tex $(SCRIPTS) ! EMACS=$(EMACS) $(MKINFO) $< $@ ! ! python$(VERSION)-ext.info: ../ext/ext.tex $(SCRIPTS) ! EMACS=$(EMACS) $(MKINFO) $< $@ ! ! python$(VERSION)-lib.info: ../lib/lib.tex $(SCRIPTS) ! EMACS=$(EMACS) $(MKINFO) $< $@ # Not built by default; the conversion doesn't really handle it well. ! python$(VERSION)-mac.info: ../mac/mac.tex $(SCRIPTS) ! EMACS=$(EMACS) $(MKINFO) $< $@ ! python$(VERSION)-ref.info: ../ref/ref.tex $(SCRIPTS) ! EMACS=$(EMACS) $(MKINFO) $< $@ ! python$(VERSION)-tut.info: ../tut/tut.tex $(SCRIPTS) ! EMACS=$(EMACS) $(MKINFO) $< $@ ! # Not built by default; the conversion doesn't handle it at all. ! python$(VERSION)-doc.info: ../doc/doc.tex $(SCRIPTS) ! EMACS=$(EMACS) $(MKINFO) $< $@ ! python$(VERSION)-dist.info: ../dist/dist.tex $(SCRIPTS) ! EMACS=$(EMACS) $(MKINFO) $< $@ ! ! # Not built by default; the conversion chokes on two @end multitable's ! python$(VERSION)-inst.info: ../inst/inst.tex $(SCRIPTS) ! EMACS=$(EMACS) $(MKINFO) $< $@ clean: *************** *** 43,73 **** clobber: clean ! rm -f *.texi python-*.info python-*.info-[0-9]* ! ! ! # This makes sure we can build info files from a "clean" tree, ! # in case we haven't already built the HTML: ! ! $(HTMLDIR)/api/api.html: ! cd $(HTMLDIR) && $(MAKE) api ! ! $(HTMLDIR)/ext/ext.html: ! cd $(HTMLDIR) && $(MAKE) ext ! ! $(HTMLDIR)/lib/lib.html: ! cd $(HTMLDIR) && $(MAKE) lib ! ! $(HTMLDIR)/mac/mac.html: ! cd $(HTMLDIR) && $(MAKE) mac ! ! $(HTMLDIR)/ref/ref.html: ! cd $(HTMLDIR) && $(MAKE) ref ! ! $(HTMLDIR)/tut/tut.html: ! cd $(HTMLDIR) && $(MAKE) tut ! ! $(HTMLDIR)/dist/dist.html: ! cd $(HTMLDIR) && $(MAKE) dist ! ! $(HTMLDIR)/inst/inst.html: ! cd $(HTMLDIR) && $(MAKE) inst --- 68,70 ---- clobber: clean ! rm -f *.texi python*-*.info python*-*.info-[0-9]* Index: python.dir =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/info/python.dir,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** python.dir 17 Jan 2002 21:27:00 -0000 1.3 --- python.dir 3 May 2002 04:50:51 -0000 1.4 *************** *** 3,10 **** * Python Library: (python-lib). Python Library Reference * Python Reference: (python-ref). Python Reference Manual - * Python Distutils: (python-dist). Distributing Python Modules * Python API: (python-api). Python/C API Reference Manual * Python Extending: (python-ext). Extending & Embedding Python - * Python Mac Modules: (python-mac). Python Macintosh Modules * Python Tutorial: (python-tut). Python Tutorial --- 3,12 ---- * Python Library: (python-lib). Python Library Reference + * Python Mac Modules: (python-mac). Python Macintosh Modules * Python Reference: (python-ref). Python Reference Manual * Python API: (python-api). Python/C API Reference Manual * Python Extending: (python-ext). Extending & Embedding Python * Python Tutorial: (python-tut). Python Tutorial + * Documenting Python: (python-doc). Documenting Python + * Installing Modules: (python-inst). Installing Python Modules + * Distributing Modules: (python-dist). Distributing Python Modules From fdrake@sourceforge.net Fri May 3 05:50:53 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 21:50:53 -0700 Subject: [Python-checkins] python/dist/src/Doc/tools py2texi.el,NONE,1.1 mkinfo,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory usw-pr-cvs1:/tmp/cvs-serv17494/tools Modified Files: mkinfo Added Files: py2texi.el Log Message: Integrated SF patch #539487 by Matthias Klose: This patch adds Milan Zamazal's conversion script and modifies the mkinfo script to build the info doc files from the LaTeX sources. Currently, the mac, doc and inst TeX files are not handled. Explicitly checks for GNU Emacs 21. --- NEW FILE: py2texi.el --- ;;; py2texi.el -- Conversion of Python LaTeX documentation to Texinfo ;; Copyright (C) 1998, 1999, 2001, 2002 Milan Zamazal ;; Author: Milan Zamazal ;; Version: $Id: py2texi.el,v 1.1 2002/05/03 04:50:51 fdrake Exp $ ;; Keywords: python ;; COPYRIGHT NOTICE ;; ;; This program 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. ;; ;; This program is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ;; for more details. ;; ;; You can find the GNU General Public License at ;; http://www.gnu.org/copyleft/gpl.html ;; or you can write to the Free Software Foundation, Inc., 59 Temple Place, ;; Suite 330, Boston, MA 02111-1307, USA. ;;; Commentary: ;; This is a Q&D hack for conversion of Python manuals to on-line help format. ;; I desperately needed usable online documenta for Python, so I wrote this. ;; The result code is ugly and need not contain complete information from ;; Python manuals. I apologize for my ignorance, especially ignorance to ;; python.sty. Improvements of this convertor are welcomed. ;; How to use it: ;; Load this file and apply `M-x py2texi'. You will be asked for name of a ;; file to be converted. ;; Where to find it: ;; New versions of this code might be found at ;; http://www.zamazal.org/software/python/py2texi/ . ;;; Code: (require 'texinfo) (eval-when-compile (require 'cl)) (defvar py2texi-python-version "2.2" "What to substitute for the \\version macro.") (defvar py2texi-python-short-version (progn (string-match "[0-9]+\\.[0-9]+" py2texi-python-version) (match-string 0 py2texi-python-version)) "Short version number, usually set by the LaTeX commands.") (defvar py2texi-stop-on-problems nil "*If non-nil, stop when you encouter soft problem.") (defconst py2texi-environments '(("abstract" 0 "@quotation" "@end quotation\n") ("center" 0 "" "") ("cfuncdesc" 3 (progn (setq findex t) "\n@table @code\n@item \\1 \\2(\\3)\n@findex \\2\n") "@end table") ("classdesc" 2 (progn (setq obindex t) "\n@table @code\n@item \\1(\\2)\n@obindex \\1\n") "@end table") ("classdesc*" 1 (progn (setq obindex t) "\n@table @code\n@item \\1\n@obindex \\1\n") "@end table") ("csimplemacrodesc" 1 (progn (setq cindex t) "\n@table @code\n@item \\1\n@cindex \\1\n") "@end table") ("ctypedesc" 1 (progn (setq cindex t) "\n@table @code\n@item \\1\n@cindex \\1\n") "@end table") ("cvardesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1 \\2\n@findex \\2\n") "@end table") ("datadesc" 1 (progn (setq findex t) "\n@table @code\n@item \\1\n@findex \\1\n") "@end table") ("datadescni" 1 "\n@table @code\n@item \\1\n" "@end table") ("definitions" 0 "@table @dfn" "@end table\n") ("description" 0 "@table @samp" "@end table\n") ("displaymath" 0 "" "") ("document" 0 (concat "@defcodeindex mo\n" "@defcodeindex ob\n" "@titlepage\n" (format "@title " title "\n") (format "@author " author "\n") "@page\n" author-address "@end titlepage\n" "@node Top, , , (dir)\n") (concat "@indices\n" "@contents\n" "@bye\n")) ("enumerate" 0 "@enumerate" "@end enumerate") ("excdesc" 1 (progn (setq obindex t) "\n@table @code\n@item \\1\n@obindex \\1\n") "@end table") ("excclassdesc" 2 (progn (setq obindex t) "\n@table @code\n@item \\1(\\2)\n@obindex \\1\n") "@end table") ("flushleft" 0 "" "") ("fulllineitems" 0 "\n@table @code\n" "@end table") ("funcdesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1(\\2)\n@findex \\1\n") "@end table") ("funcdescni" 2 "\n@table @code\n@item \\1(\\2)\n" "@end table") ("itemize" 0 "@itemize @bullet" "@end itemize\n") ("list" 2 "\n@table @code\n" "@end table") ("longtableii" 4 (concat "@multitable @columnfractions .5 .5\n" "@item \\3 @tab \\4\n" "@item ------- @tab ------ \n") "@end multitable\n") ("longtableiii" 5 (concat "@multitable @columnfractions .33 .33 .33\n" "@item \\3 @tab \\4 @tab \\5\n" "@item ------- @tab ------ @tab ------\n") "@end multitable\n") ("memberdesc" 1 (progn (setq findex t) "\n@table @code\n@item \\1\n@findex \\1\n") "@end table") ("memberdescni" 1 "\n@table @code\n@item \\1\n" "@end table") ("methoddesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1(\\2)\n@findex \\1\n") "@end table") ("methoddescni" 2 "\n@table @code\n@item \\1(\\2)\n" "@end table") ("notice" 0 "@emph{Notice:} " "") ("opcodedesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1 \\2\n@findex \\1\n") "@end table") ("productionlist" 0 "\n@table @code\n" "@end table") ("quotation" 0 "@quotation" "@end quotation") ("seealso" 0 "See also:\n@table @emph\n" "@end table") ("seealso*" 0 "@table @emph\n" "@end table") ("sloppypar" 0 "" "") ("small" 0 "" "") ("tableii" 4 (concat "@multitable @columnfractions .5 .5\n" "@item \\3 @tab \\4\n" "@item ------- @tab ------ \n") "@end multitable\n") ("tableiii" 5 (concat "@multitable @columnfractions .33 .33 .33\n" "@item \\3 @tab \\4 @tab \\5\n" "@item ------- @tab ------ @tab ------\n") "@end multitable\n") ("tableiv" 6 (concat "@multitable @columnfractions .25 .25 .25 .25\n" "@item \\3 @tab \\4 @tab \\5 @tab \\6\n" "@item ------- @tab ------- @tab ------- @tab -------\n") "@end multitable\n") ("tablev" 7 (concat "@multitable @columnfractions .20 .20 .20 .20 .20\n" "@item \\3 @tab \\4 @tab \\5 @tab \\6 @tab \\7\n" "@item ------- @tab ------- @tab ------- @tab ------- @tab -------\n") "@end multitable\n")) "Associative list defining substitutions for environments. Each list item is of the form (ENVIRONMENT ARGNUM BEGIN END) where: - ENVIRONMENT is LaTeX environment name - ARGNUM is number of (required) macro arguments - BEGIN is substitution for \begin{ENVIRONMENT} - END is substitution for \end{ENVIRONMENT} Both BEGIN and END are evaled. Moreover, you can reference arguments through \N regular expression notation in strings of BEGIN.") (defconst py2texi-commands '(("ABC" 0 "ABC") ("appendix" 0 (progn (setq appendix t) "")) ("ASCII" 0 "ASCII") ("author" 1 (progn (setq author (match-string 1 string)) "")) ("authoraddress" 1 (progn (setq author-address (match-string 1 string)) "")) ("b" 1 "@w{\\1}") ("bf" 0 "@destroy") ("bifuncindex" 1 (progn (setq findex t) "@findex{\\1}")) ("C" 0 "C") ("c" 0 "@,") ("catcode" 0 "") ("cdata" 1 "@code{\\1}") ("centerline" 1 "@center \\1") ("cfunction" 1 "@code{\\1}") ("chapter" 1 (format "@node \\1\n@%s \\1\n" (if appendix "appendix" "chapter"))) ("chapter*" 1 "@node \\1\n@unnumbered \\1\n") ("character" 1 "@samp{\\1}") ("citetitle" 1 "@ref{Top,,,\\1}") ("class" 1 "@code{\\1}") ("code" 1 "@code{\\1}") ("command" 1 "@command{\\1}") ("constant" 1 "@code{\\1}") ("copyright" 1 "@copyright{}") ("Cpp" 0 "C++") ("ctype" 1 "@code{\\1}") ("dataline" 1 (progn (setq findex t) "@item \\1\n@findex \\1\n")) ("date" 1 "\\1") ("declaremodule" 2 (progn (setq cindex t) "@label{\\2}@cindex{\\2}")) ("deprecated" 2 "@emph{This is deprecated in Python \\1. \\2}") ("dfn" 1 "@dfn{\\1}") ("documentclass" 1 py2texi-magic) ("e" 0 "@backslash{}") ("else" 0 (concat "@end ifinfo\n@" (setq last-if "iftex"))) ("EOF" 0 "@code{EOF}") ("email" 1 "@email{\\1}") ("emph" 1 "@emph{\\1}") ("envvar" 1 "@samp{\\1}") ("exception" 1 "@code{\\1}") ("exindex" 1 (progn (setq obindex t) "@obindex{\\1}")) ("fi" 0 (concat "@end " last-if)) ("file" 1 "@file{\\1}") ("filevar" 1 "@file{@var{\\1}}") ("footnote" 1 "@footnote{\\1}") ("frac" 0 "") ("funcline" 2 (progn (setq findex t) "@item \\1 \\2\n@findex \\1")) ("funclineni" 2 "@item \\1 \\2") ("function" 1 "@code{\\1}") ("grammartoken" 1 "@code{\\1}") ("hline" 0 "") ("ifhtml" 0 (concat "@" (setq last-if "ifinfo"))) ("iftexi" 0 (concat "@" (setq last-if "ifinfo"))) ("index" 1 (progn (setq cindex t) "@cindex{\\1}")) ("indexii" 2 (progn (setq cindex t) "@cindex{\\1 \\2}")) ("indexiii" 3 (progn (setq cindex t) "@cindex{\\1 \\2 \\3}")) ("indexiv" 3 (progn (setq cindex t) "@cindex{\\1 \\2 \\3 \\4}")) ("infinity" 0 "@emph{infinity}") ("it" 0 "@destroy") ("kbd" 1 "@key{\\1}") ("keyword" 1 "@code{\\1}") ("kwindex" 1 (progn (setq cindex t) "@cindex{\\1}")) ("label" 1 "@label{\\1}") ("Large" 0 "") ("LaTeX" 0 "La@TeX{}") ("large" 0 "") ("ldots" 0 "@dots{}") ("leftline" 1 "\\1") ("lineii" 2 "@item \\1 @tab \\2") ("lineiii" 3 "@item \\1 @tab \\2 @tab \\3") ("lineiv" 4 "@item \\1 @tab \\2 @tab \\3 @tab \\4") ("linev" 5 "@item \\1 @tab \\2 @tab \\3 @tab \\4 @tab \\5") ("localmoduletable" 0 "") ("longprogramopt" 1 "@option{--\\1}") ("mailheader" 1 "@code{\\1}") ("makeindex" 0 "") ("makemodindex" 0 "") ("maketitle" 0 (concat "@top " title "\n")) ("makevar" 1 "@code{\\1}") ("manpage" 2 "@samp{\\1(\\2)}") ("mbox" 1 "@w{\\1}") ("member" 1 "@code{\\1}") ("memberline" 1 "@item \\1\n@findex \\1\n") ("menuselection" 1 "@samp{\\1}") ("method" 1 "@code{\\1}") ("methodline" 2 (progn (setq moindex t) "@item \\1(\\2)\n@moindex \\1\n")) ("methodlineni" 2 "@item \\1(\\2)\n") ("mimetype" 1 "@samp{\\1}") ("module" 1 "@samp{\\1}") ("moduleauthor" 2 "This module was written by \\1 @email{\\2}.@*") ("modulesynopsis" 1 "\\1") ("moreargs" 0 "@dots{}") ("n" 0 "@backslash{}n") ("newcommand" 2 "") ("newsgroup" 1 "@samp{\\1}") ("nodename" 1 (save-excursion (save-match-data (re-search-backward "^@node ")) (delete-region (point) (save-excursion (end-of-line) (point))) (insert "@node " (match-string 1 string)) "")) ("noindent" 0 "@noindent ") ("note" 1 "@emph{Note:} \\1") ("NULL" 0 "@code{NULL}") ("obindex" 1 (progn (setq obindex t) "@obindex{\\1}")) ("opindex" 1 (progn (setq cindex t) "@cindex{\\1}")) ("option" 1 "@option{\\1}") ("optional" 1 "[\\1]") ("pep" 1 (progn (setq cindex t) "PEP@ \\1@cindex PEP \\1\n")) ("pi" 0 "pi") ("platform" 1 "") ("plusminus" 0 "+-") ("POSIX" 0 "POSIX") ("production" 2 "@item \\1 \\2") ("program" 1 "@command{\\1}") ("programopt" 1 "@option{\\1}") ("protect" 0 "") ("pytype" 1 "@code{\\1}") ("ref" 1 "@ref{\\1}") ("refbimodindex" 1 (progn (setq moindex t) "@moindex{\\1}")) ("refmodindex" 1 (progn (setq moindex t) "@moindex{\\1}")) ("refmodule" 1 "@samp{\\1}") ("refstmodindex" 1 (progn (setq moindex t) "@moindex{\\1}")) ("regexp" 1 "\"\\1\"") ("release" 1 (progn (setq py2texi-python-version (match-string 1 string)) "")) ("renewcommand" 2 "") ("rfc" 1 (progn (setq cindex t) "RFC@ \\1@cindex RFC \\1\n")) ("rm" 0 "@destroy") ("samp" 1 "@samp{\\1}") ("section" 1 (let ((str (match-string 1 string))) (save-match-data (if (string-match "\\(.*\\)[ \t\n]*---[ \t\n]*\\(.*\\)" str) (format "@node %s\n@section %s\n" (py2texi-backslash-quote (match-string 1 str)) (py2texi-backslash-quote (match-string 2 str))) "@node \\1\n@section \\1\n")))) ("sectionauthor" 2 "\nThis manual section was written by \\1 @email{\\2}.@*") ("seemodule" 2 "@ref{\\1} \\2") ("seepep" 3 "\n@table @strong\n@item PEP\\1 \\2\n\\3\n@end table\n") ("seerfc" 3 "\n@table @strong\n@item RFC\\1 \\2\n\\3\n@end table\n") ("seetext" 1 "\\1") ("seetitle" 1 "@cite{\\1}") ("seeurl" 2 "\n@table @url\n@item \\1\n\\2\n@end table\n") ("setindexsubitem" 1 (progn (setq cindex t) "@cindex \\1")) ("setreleaseinfo" 1 (progn (setq py2texi-releaseinfo ""))) ("setshortversion" 1 (progn (setq py2texi-python-short-version (match-string 1 string)) "")) ("shortversion" 0 py2texi-python-short-version) ("sqrt" 0 "") ("stindex" 1 (progn (setq cindex t) "@cindex{\\1}")) ("stmodindex" 1 (progn (setq moindex t) "@moindex{\\1}")) ("strong" 1 "@strong{\\1}") ("sub" 0 "/") ("subsection" 1 "@node \\1\n@subsection \\1\n") ("subsubsection" 1 "@node \\1\n@subsubsection \\1\n") ("sum" 0 "") ("tableofcontents" 0 "") ("term" 1 "@item \\1") ("textasciitilde" 0 "~") ("textasciicircum" 0 "^") ("textbackslash" 0 "@backslash{}") ("textrm" 1 "\\1") ("texttt" 1 "@code{\\1}") ("textunderscore" 0 "_") ("title" 1 (progn (setq title (match-string 1 string)) "@settitle \\1")) ("today" 0 "@today{}") ("token" 1 "@code{\\1}") ("tt" 0 "@destroy") ("ttindex" 1 (progn (setq cindex t) "@cindex{\\1}")) ("u" 0 "@backslash{}u") ("ulink" 2 "\\1") ("UNIX" 0 "UNIX") ("unspecified" 0 "@dots{}") ("url" 1 "@url{\\1}") ("usepackage" 1 "") ("var" 1 "@var{\\1}") ("verbatiminput" 1 "@code{\\1}") ("version" 0 py2texi-python-version) ("versionadded" 1 "@emph{Added in Python version \\1}") ("versionchanged" 1 "@emph{Changed in Python version \\1}") ("vskip" 1 "") ("vspace" 1 "") ("warning" 1 "@emph{\\1}") ("withsubitem" 2 "\\2") ("XXX" 1 "@strong{\\1}")) "Associative list of command substitutions. Each list item is of the form (COMMAND ARGNUM SUBSTITUTION) where: - COMMAND is LaTeX command name - ARGNUM is number of (required) command arguments - SUBSTITUTION substitution for the command. It is evaled and you can reference command arguments through the \\N regexp notation in strings.") (defvar py2texi-magic "@documentclass\n" "\"Magic\" string for auxiliary insertion at the beginning of document.") (defvar py2texi-dirs '("./" "../texinputs/") "Where to search LaTeX input files.") (defvar py2texi-buffer "*py2texi*" "The name of a buffer where Texinfo is generated.") (defconst py2texi-xemacs (string-match "^XEmacs" (emacs-version)) "Running under XEmacs?") (defmacro py2texi-search (regexp &rest body) `(progn (goto-char (point-min)) (while (re-search-forward ,regexp nil t) ,@body))) (defmacro py2texi-search-safe (regexp &rest body) `(py2texi-search ,regexp (unless (py2texi-protected) ,@body))) (defun py2texi-message (message) "Report message and stop if `py2texi-stop-on-problems' is non-nil." (if py2texi-stop-on-problems (error message) (message message))) (defun py2texi-backslash-quote (string) "Double backslahes in STRING." (let ((i 0)) (save-match-data (while (setq i (string-match "\\\\" string i)) (setq string (replace-match "\\\\\\\\" t nil string)) (setq i (+ i 2)))) string)) (defun py2texi (file) "Convert Python LaTeX documentation FILE to Texinfo." (interactive "fFile to convert: ") (switch-to-buffer (get-buffer-create py2texi-buffer)) (erase-buffer) (insert-file file) (let ((case-fold-search nil) (title "") (author "") (author-address "") (appendix nil) (findex nil) (obindex nil) (cindex nil) (moindex nil) last-if) (py2texi-process-verbatims) (py2texi-process-comments) (py2texi-process-includes) (py2texi-process-funnyas) (py2texi-process-environments) (py2texi-process-commands) (py2texi-fix-indentation) (py2texi-fix-nodes) (py2texi-fix-references) (py2texi-fix-indices) (py2texi-process-simple-commands) (py2texi-fix-fonts) (py2texi-fix-braces) (py2texi-fix-backslashes) (py2texi-destroy-empties) (py2texi-fix-newlines) (py2texi-adjust-level)) (let* ((filename (concat "./" (file-name-nondirectory file) (if (string-match "\\.tex$" file) "i" ".texi"))) (infofilename (py2texi-info-file-name filename))) (goto-char (point-min)) (when (looking-at py2texi-magic) (delete-region (point) (progn (beginning-of-line 2) (point))) (insert "\\input texinfo @c -*-texinfo-*-\n") (insert "@setfilename " (file-name-nondirectory infofilename))) (when (re-search-forward "@chapter" nil t) (texinfo-all-menus-update t)) (goto-char (point-min)) (write-file filename) (message (format "You can apply `makeinfo %s' now." filename)))) (defun py2texi-info-file-name (filename) "Generate name of info file from original file name FILENAME." (setq filename (expand-file-name filename)) (let ((directory (file-name-directory filename)) (basename (file-name-nondirectory filename))) (concat directory "python-" (substring basename 0 (- (length basename) 4)) "info"))) (defun py2texi-process-verbatims () "Process and protect verbatim environments." (let (delimiter beg end) (py2texi-search-safe "\\\\begin{\\(verbatim\\|displaymath\\)}" (replace-match "@example") (setq beg (copy-marker (point) nil)) (re-search-forward "\\\\end{\\(verbatim\\|displaymath\\)}") (setq end (copy-marker (match-beginning 0) nil)) (replace-match "@end example") (py2texi-texinfo-escape beg end) (put-text-property (- beg (length "@example")) (+ end (length "@end example")) 'py2texi-protected t)) (py2texi-search-safe "\\\\verb\\([^a-z]\\)" (setq delimiter (match-string 1)) (replace-match "@code{") (setq beg (copy-marker (point) nil)) (re-search-forward (regexp-quote delimiter)) (setq end (copy-marker (match-beginning 0) nil)) (replace-match "}") (put-text-property (- beg (length "@code{")) (+ end (length "}")) 'py2texi-protected t) (py2texi-texinfo-escape beg end)))) (defun py2texi-process-comments () "Remove comments." (let (point) (py2texi-search-safe "%" (setq point (point)) (when (save-excursion (re-search-backward "\\(^\\|[^\\]\\(\\\\\\\\\\)*\\)%\\=" nil t)) (delete-region (1- point) (save-excursion (beginning-of-line 2) (point))))))) (defun py2texi-process-includes () "Include LaTeX input files. Do not include .ind files." (let ((path (file-name-directory file)) filename dirs includefile) (py2texi-search-safe "\\\\input{\\([^}]+\\)}" (setq filename (match-string 1)) (unless (save-match-data (string-match "\\.tex$" filename)) (setq filename (concat filename ".tex"))) (setq includefile (save-match-data (string-match "\\.ind\\.tex$" filename))) (setq dirs py2texi-dirs) (while (and (not includefile) dirs) (setq includefile (concat path (car dirs) filename)) (unless (file-exists-p includefile) (setq includefile nil) (setq dirs (cdr dirs)))) (if includefile (save-restriction (narrow-to-region (match-beginning 0) (match-end 0)) (delete-region (point-min) (point-max)) (when (stringp includefile) (insert-file-contents includefile) (goto-char (point-min)) (insert "\n") (py2texi-process-verbatims) (py2texi-process-comments) (py2texi-process-includes))) (replace-match (format "\\\\emph{Included file %s}" filename)) (py2texi-message (format "Input file %s not found" filename)))))) (defun py2texi-process-funnyas () "Convert @s." (py2texi-search-safe "@" (replace-match "@@"))) (defun py2texi-process-environments () "Process LaTeX environments." (let ((stack ()) kind environment parameter arguments n string description) (py2texi-search-safe (concat "\\\\\\(begin\\|end\\|item\\)" "\\({\\([^}]*\\)}\\|[[]\\([^]]*\\)[]]\\|\\)") (setq kind (match-string 1) environment (match-string 3) parameter (match-string 4)) (replace-match "") (cond ((string= kind "begin") (setq description (assoc environment py2texi-environments)) (if description (progn (setq n (cadr description)) (setq description (cddr description)) (setq string (py2texi-tex-arguments n)) (string-match (py2texi-regexp n) string) ; incorrect but sufficient (insert (replace-match (eval (car description)) t nil string)) (setq stack (cons (cadr description) stack))) (py2texi-message (format "Unknown environment: %s" environment)) (setq stack (cons "" stack)))) ((string= kind "end") (insert (eval (car stack))) (setq stack (cdr stack))) ((string= kind "item") (insert "\n@item " (or parameter "") "\n")))) (when stack (py2texi-message (format "Unclosed environment: %s" (car stack)))))) (defun py2texi-process-commands () "Process LaTeX commands." (let (done command command-info string n) (while (not done) (setq done t) (py2texi-search-safe "\\\\\\([a-zA-Z*]+\\)\\(\\[[^]]*\\]\\)?" (setq command (match-string 1)) (setq command-info (assoc command py2texi-commands)) (if command-info (progn (setq done nil) (replace-match "") (setq command-info (cdr command-info)) (setq n (car command-info)) (setq string (py2texi-tex-arguments n)) (string-match (py2texi-regexp n) string) ; incorrect but sufficient (insert (replace-match (eval (cadr command-info)) t nil string))) (py2texi-message (format "Unknown command: %s (not processed)" command))))))) (defun py2texi-argument-pattern (count) (let ((filler "\\(?:[^{}]\\|\\\\{\\|\\\\}\\)*")) (if (<= count 0) filler (concat filler "\\(?:{" (py2texi-argument-pattern (1- count)) "}" filler "\\)*" filler)))) (defconst py2texi-tex-argument (concat "{\\(" (py2texi-argument-pattern 10) ;really at least 10! "\\)}[ \t%@c\n]*") "Regexp describing LaTeX command argument including argument separators.") (defun py2texi-regexp (n) "Make regexp matching N LaTeX command arguments." (if (= n 0) "" (let ((regexp "^[^{]*")) (while (> n 0) (setq regexp (concat regexp py2texi-tex-argument)) (setq n (1- n))) regexp))) (defun py2texi-tex-arguments (n) "Remove N LaTeX command arguments and return them as a string." (let ((point (point)) (i 0) result match) (if (= n 0) (progn (when (re-search-forward "\\=\\({}\\| *\\)" nil t) (replace-match "")) "") (while (> n 0) (unless (re-search-forward "\\(\\=\\|[^\\\\]\\)\\(\\\\\\\\\\)*\\([{}]\\)" nil t) (debug)) (if (string= (match-string 3) "{") (setq i (1+ i)) (setq i (1- i)) (when (<= i 0) (setq n (1- n))))) (setq result (buffer-substring-no-properties point (point))) (while (string-match "\n[ \t]*" result) (setq result (replace-match " " t nil result))) (delete-region point (point)) result))) (defun py2texi-process-simple-commands () "Replace single character LaTeX commands." (let (char) (py2texi-search-safe "\\\\\\([^a-z]\\)" (setq char (match-string 1)) (replace-match (format "%s%s" (if (or (string= char "{") (string= char "}") (string= char " ")) "@" "") (if (string= char "\\") "\\\\" char)))))) (defun py2texi-fix-indentation () "Remove white space at the beginning of lines." (py2texi-search-safe "^[ \t]+" (replace-match ""))) (defun py2texi-fix-nodes () "Remove unwanted characters from nodes and make nodes unique." (let ((nodes (make-hash-table :test 'equal)) id counter string label) (py2texi-search "^@node +\\(.*\\)$" (setq string (match-string 1)) (if py2texi-xemacs (replace-match "@node " t) (replace-match "" t nil nil 1)) (when (string-match "@label{[^}]*}" string) (setq label (match-string 0 string)) (setq string (replace-match "" t nil string))) (while (string-match "@[a-zA-Z]+\\|[{}():]\\|``\\|''" string) (setq string (replace-match "" t nil string))) (while (string-match " -- " string) (setq string (replace-match " - " t nil string))) (when (string-match " +$" string) (setq string (replace-match "" t nil string))) (when (string-match "^\\(Built-in\\|Standard\\) Module \\|The " string) (setq string (replace-match "" t nil string))) (string-match "^[^,]+" string) (setq id (match-string 0 string)) (setq counter (gethash id nodes)) (if counter (progn (setq counter (1+ counter)) (setq string (replace-match (format "\\& %d" counter) t nil string))) (setq counter 1)) (setf (gethash id nodes) counter) (insert string) (when label (beginning-of-line 3) (insert label "\n"))))) (defun py2texi-fix-references () "Process labels and make references to point to appropriate nodes." (let ((labels ()) node) (py2texi-search-safe "@label{\\([^}]*\\)}" (setq node (save-excursion (save-match-data (and (re-search-backward "@node +\\([^,\n]+\\)" nil t) (match-string 1))))) (when node (setq labels (cons (cons (match-string 1) node) labels))) (replace-match "")) (py2texi-search-safe "@ref{\\([^}]*\\)}" (setq node (assoc (match-string 1) labels)) (replace-match "") (when node (insert (format "@ref{%s}" (cdr node))))))) (defun py2texi-fix-indices () "Remove unwanted characters from @*index commands and create final indices." (py2texi-search-safe "@..?index\\>[^\n]*\\(\\)\n" (replace-match "" t nil nil 1)) (py2texi-search-safe "@..?index\\>[^\n]*\\(\\)" (replace-match "\n" t nil nil 1)) (py2texi-search-safe "@..?index\\({\\)\\([^}]+\\)\\(}+\\)" (replace-match " " t nil nil 1) (replace-match "" t nil nil 3) (let ((string (match-string 2))) (save-match-data (while (string-match "@[a-z]+{" string) (setq string (replace-match "" nil nil string))) (while (string-match "{" string) (setq string (replace-match "" nil nil string)))) (replace-match string t t nil 2))) (py2texi-search-safe "@..?index\\>.*\\([{}]\\|@[a-z]*\\)" (replace-match "" t nil nil 1) (goto-char (match-beginning 0))) (py2texi-search-safe "[^\n]\\(\\)@..?index\\>" (replace-match "\n" t nil nil 1)) (goto-char (point-max)) (re-search-backward "@indices") (replace-match "") (insert (if moindex (concat "@node Module Index\n" "@unnumbered Module Index\n" "@printindex mo\n") "") (if obindex (concat "@node Class-Exception-Object Index\n" "@unnumbered Class, Exception, and Object Index\n" "@printindex ob\n") "") (if findex (concat "@node Function-Method-Variable Index\n" "@unnumbered Function, Method, and Variable Index\n" "@printindex fn\n") "") (if cindex (concat "@node Miscellaneous Index\n" "@unnumbered Miscellaneous Index\n" "@printindex cp\n") ""))) (defun py2texi-fix-backslashes () "Make backslashes from auxiliary commands." (py2texi-search-safe "@backslash{}" (replace-match "\\\\"))) (defun py2texi-fix-fonts () "Remove garbage after unstructured font commands." (let (string) (py2texi-search-safe "@destroy" (replace-match "") (when (eq (preceding-char) ?{) (forward-char -1) (setq string (py2texi-tex-arguments 1)) (insert (substring string 1 (1- (length string)))))))) (defun py2texi-fix-braces () "Escape braces for Texinfo." (let (string) (py2texi-search "{" (unless (or (py2texi-protected) (save-excursion (re-search-backward "@\\([a-zA-Z]*\\|multitable.*\\){\\=" nil t))) (forward-char -1) (setq string (py2texi-tex-arguments 1)) (insert "@" (substring string 0 (1- (length string))) "@}"))))) (defun py2texi-fix-newlines () "Remove extra newlines." (py2texi-search "\n\n\n+" (replace-match "\n\n")) (py2texi-search-safe "@item.*\n\n" (delete-backward-char 1)) (py2texi-search "@end example" (unless (looking-at "\n\n") (insert "\n")))) (defun py2texi-destroy-empties () "Remove all comments. This avoids some makeinfo errors." (py2texi-search "@c\\>" (unless (eq (py2texi-protected) t) (delete-region (- (point) 2) (save-excursion (end-of-line) (point))) (cond ((looking-at "\n\n") (delete-char 1)) ((save-excursion (re-search-backward "^[ \t]*\\=" nil t)) (delete-region (save-excursion (beginning-of-line) (point)) (1+ (point)))))))) (defun py2texi-adjust-level () "Increase heading level to @chapter, if needed. This is only needed for distutils, so it has a very simple form only." (goto-char (point-min)) (unless (re-search-forward "@chapter\\>" nil t) (py2texi-search-safe "@section\\>" (replace-match "@chapter" t)) (py2texi-search-safe "@\\(sub\\)\\(sub\\)?section\\>" (replace-match "" nil nil nil 1)))) (defun py2texi-texinfo-escape (beg end) "Escape Texinfo special characters in region." (save-excursion (goto-char beg) (while (re-search-forward "[@{}]" end t) (replace-match "@\\&")))) (defun py2texi-protected () "Return protection status of the point before current point." (get-text-property (1- (point)) 'py2texi-protected)) ;;; Announce (provide 'py2texi) ;;; py2texi.el ends here Index: mkinfo =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/mkinfo,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** mkinfo 8 Jan 1999 15:32:27 -0000 1.2 --- mkinfo 3 May 2002 04:50:51 -0000 1.3 *************** *** 18,22 **** DOCDIR=`dirname "$FILENAME"` DOCFILE=`basename "$FILENAME"` ! DOCNAME=`basename "$FILENAME" .html` # Now build the real directory names, and locate our support stuff: --- 18,27 ---- DOCDIR=`dirname "$FILENAME"` DOCFILE=`basename "$FILENAME"` ! DOCNAME=`basename "$FILENAME" .tex` ! if [ $# -gt 1 ]; then ! INFONAME="$2" ! else ! INFONAME="python-$DOCNAME.info" ! fi # Now build the real directory names, and locate our support stuff: *************** *** 32,36 **** # show what we're doing, like make does: echo "$*" ! $* || exit $? } --- 37,41 ---- # show what we're doing, like make does: echo "$*" ! "$@" || exit $? } *************** *** 38,44 **** # generate the Texinfo file: ! run $PERL -I$TOOLSDIR $TOOLSDIR/html2texi.pl $DOCDIR/$DOCFILE ! run $EMACS -batch -l $TOOLSDIR/fixinfo.el $DOCNAME.texi ! rm -f $DOCNAME.texi~ --- 43,51 ---- # generate the Texinfo file: ! run $EMACS -batch -q --no-site-file -l $TOOLSDIR/py2texi.el \ ! --eval "(setq py2texi-dirs '(\"./\" \"../texinputs/\" \"$DOCDIR\"))" \ ! --eval "(py2texi \"$DOCDIR/$DOCFILE\")" \ ! -f kill-emacs ! echo Done *************** *** 46,48 **** run $MAKEINFO --footnote-style end --fill-column 72 \ ! --paragraph-indent 0 $DOCNAME.texi --- 53,55 ---- run $MAKEINFO --footnote-style end --fill-column 72 \ ! --paragraph-indent 0 --output=$INFONAME $DOCNAME.texi From fdrake@sourceforge.net Fri May 3 05:54:22 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 21:54:22 -0700 Subject: [Python-checkins] python/dist/src/Doc Makefile,1.235.2.1.2.8,1.235.2.1.2.9 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory usw-pr-cvs1:/tmp/cvs-serv18139 Modified Files: Tag: release22-maint Makefile Log Message: Integrated SF patch #539487 by Matthias Klose: This patch adds Milan Zamazal's conversion script and modifies the mkinfo script to build the info doc files from the LaTeX sources. Currently, the mac, doc and inst TeX files are not handled. Explicitly checks for GNU Emacs 21. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile,v retrieving revision 1.235.2.1.2.8 retrieving revision 1.235.2.1.2.9 diff -C2 -d -r1.235.2.1.2.8 -r1.235.2.1.2.9 *** Makefile 2 May 2002 04:51:37 -0000 1.235.2.1.2.8 --- Makefile 3 May 2002 04:54:19 -0000 1.235.2.1.2.9 *************** *** 89,92 **** --- 89,95 ---- HTMLBASE= file:`pwd` + # The emacs binary used to build the info docs. GNU Emacs 21 is required. + EMACS= emacs + # The end of this should reflect the major/minor version numbers of # the release: *************** *** 288,292 **** info: ! cd $(INFODIR) && $(MAKE) # Targets to convert the manuals to HTML using Nikos Drakos' LaTeX to --- 291,295 ---- info: ! cd $(INFODIR) && $(MAKE) EMACS=$(EMACS) # Targets to convert the manuals to HTML using Nikos Drakos' LaTeX to From fdrake@sourceforge.net Fri May 3 05:54:22 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 21:54:22 -0700 Subject: [Python-checkins] python/dist/src/Doc/info Makefile,1.7,1.7.16.1 python.dir,1.2.30.1,1.2.30.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/info In directory usw-pr-cvs1:/tmp/cvs-serv18139/info Modified Files: Tag: release22-maint Makefile python.dir Log Message: Integrated SF patch #539487 by Matthias Klose: This patch adds Milan Zamazal's conversion script and modifies the mkinfo script to build the info doc files from the LaTeX sources. Currently, the mac, doc and inst TeX files are not handled. Explicitly checks for GNU Emacs 21. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/info/Makefile,v retrieving revision 1.7 retrieving revision 1.7.16.1 diff -C2 -d -r1.7 -r1.7.16.1 *** Makefile 17 Jul 2001 16:48:55 -0000 1.7 --- Makefile 3 May 2002 04:54:20 -0000 1.7.16.1 *************** *** 5,41 **** HTMLDIR=$(TOPDIR)/html MKINFO=$(TOOLSDIR)/mkinfo ! SCRIPTS=$(TOOLSDIR)/html2texi.pl $(TOOLSDIR)/checkargs.pm $(TOOLSDIR)/mkinfo \ ! $(TOOLSDIR)/fixinfo.el ! all: python-api.info python-ext.info python-lib.info \ ! python-ref.info python-tut.info \ ! python-dist.info python-inst.info ! python-api.info: $(HTMLDIR)/api/api.html $(SCRIPTS) ! $(MKINFO) $< ! python-ext.info: $(HTMLDIR)/ext/ext.html $(SCRIPTS) ! $(MKINFO) $< ! python-lib.info: $(HTMLDIR)/lib/lib.html $(SCRIPTS) ! $(MKINFO) $< # Not built by default; the conversion doesn't really handle it well. ! python-mac.info: $(HTMLDIR)/mac/mac.html $(SCRIPTS) ! $(MKINFO) $< ! python-ref.info: $(HTMLDIR)/ref/ref.html $(SCRIPTS) ! $(MKINFO) $< ! python-tut.info: $(HTMLDIR)/tut/tut.html $(SCRIPTS) ! $(MKINFO) $< ! python-dist.info: $(HTMLDIR)/dist/dist.html $(SCRIPTS) ! $(MKINFO) $< ! python-inst.info: $(HTMLDIR)/inst/inst.html $(SCRIPTS) ! $(MKINFO) $< clean: --- 5,66 ---- HTMLDIR=$(TOPDIR)/html + # The emacs binary used to build the info docs. GNU Emacs 21 is required. + EMACS=emacs + MKINFO=$(TOOLSDIR)/mkinfo ! SCRIPTS=$(TOOLSDIR)/checkargs.pm $(TOOLSDIR)/mkinfo $(TOOLSDIR)/py2texi.el ! # set VERSION to code the VERSION number into the info file name ! # allowing installation of more than one set of python info docs ! # into the same directory ! VERSION= + all: check-emacs-version \ + python$(VERSION)-api.info python$(VERSION)-ext.info \ + python$(VERSION)-lib.info python$(VERSION)-ref.info \ + python$(VERSION)-tut.info python$(VERSION)-dist.info ! # python$(VERSION)-doc.info python$(VERSION)-inst.info ! # python$(VERSION)-mac.info ! check-emacs-version: ! @v="`$(EMACS) --version 2>&1 | egrep '^(GNU |X)Emacs [12]*'`"; \ ! if `echo "$$v" | grep '^GNU Emacs 21' >/dev/null 2>&1`; then \ ! echo "Using $(EMACS) to build the info docs"; \ ! else \ ! echo "GNU Emacs 21 is required to build the info docs"; \ ! echo "Found $$v"; \ ! false; \ ! fi ! python$(VERSION)-api.info: ../api/api.tex $(SCRIPTS) ! EMACS=$(EMACS) $(MKINFO) $< $@ ! ! python$(VERSION)-ext.info: ../ext/ext.tex $(SCRIPTS) ! EMACS=$(EMACS) $(MKINFO) $< $@ ! ! python$(VERSION)-lib.info: ../lib/lib.tex $(SCRIPTS) ! EMACS=$(EMACS) $(MKINFO) $< $@ # Not built by default; the conversion doesn't really handle it well. ! python$(VERSION)-mac.info: ../mac/mac.tex $(SCRIPTS) ! EMACS=$(EMACS) $(MKINFO) $< $@ ! python$(VERSION)-ref.info: ../ref/ref.tex $(SCRIPTS) ! EMACS=$(EMACS) $(MKINFO) $< $@ ! python$(VERSION)-tut.info: ../tut/tut.tex $(SCRIPTS) ! EMACS=$(EMACS) $(MKINFO) $< $@ ! # Not built by default; the conversion doesn't handle it at all. ! python$(VERSION)-doc.info: ../doc/doc.tex $(SCRIPTS) ! EMACS=$(EMACS) $(MKINFO) $< $@ ! python$(VERSION)-dist.info: ../dist/dist.tex $(SCRIPTS) ! EMACS=$(EMACS) $(MKINFO) $< $@ ! ! # Not built by default; the conversion chokes on two @end multitable's ! python$(VERSION)-inst.info: ../inst/inst.tex $(SCRIPTS) ! EMACS=$(EMACS) $(MKINFO) $< $@ clean: *************** *** 43,73 **** clobber: clean ! rm -f *.texi python-*.info python-*.info-[0-9]* ! ! ! # This makes sure we can build info files from a "clean" tree, ! # in case we haven't already built the HTML: ! ! $(HTMLDIR)/api/api.html: ! cd $(HTMLDIR) && $(MAKE) api ! ! $(HTMLDIR)/ext/ext.html: ! cd $(HTMLDIR) && $(MAKE) ext ! ! $(HTMLDIR)/lib/lib.html: ! cd $(HTMLDIR) && $(MAKE) lib ! ! $(HTMLDIR)/mac/mac.html: ! cd $(HTMLDIR) && $(MAKE) mac ! ! $(HTMLDIR)/ref/ref.html: ! cd $(HTMLDIR) && $(MAKE) ref ! ! $(HTMLDIR)/tut/tut.html: ! cd $(HTMLDIR) && $(MAKE) tut ! ! $(HTMLDIR)/dist/dist.html: ! cd $(HTMLDIR) && $(MAKE) dist ! ! $(HTMLDIR)/inst/inst.html: ! cd $(HTMLDIR) && $(MAKE) inst --- 68,70 ---- clobber: clean ! rm -f *.texi python*-*.info python*-*.info-[0-9]* Index: python.dir =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/info/python.dir,v retrieving revision 1.2.30.1 retrieving revision 1.2.30.2 diff -C2 -d -r1.2.30.1 -r1.2.30.2 *** python.dir 17 Jan 2002 21:26:44 -0000 1.2.30.1 --- python.dir 3 May 2002 04:54:20 -0000 1.2.30.2 *************** *** 3,10 **** * Python Library: (python-lib). Python Library Reference * Python Reference: (python-ref). Python Reference Manual - * Python Distutils: (python-dist). Distributing Python Modules * Python API: (python-api). Python/C API Reference Manual * Python Extending: (python-ext). Extending & Embedding Python - * Python Mac Modules: (python-mac). Python Macintosh Modules * Python Tutorial: (python-tut). Python Tutorial --- 3,12 ---- * Python Library: (python-lib). Python Library Reference + * Python Mac Modules: (python-mac). Python Macintosh Modules * Python Reference: (python-ref). Python Reference Manual * Python API: (python-api). Python/C API Reference Manual * Python Extending: (python-ext). Extending & Embedding Python * Python Tutorial: (python-tut). Python Tutorial + * Documenting Python: (python-doc). Documenting Python + * Installing Modules: (python-inst). Installing Python Modules + * Distributing Modules: (python-dist). Distributing Python Modules From fdrake@sourceforge.net Fri May 3 05:54:22 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Thu, 02 May 2002 21:54:22 -0700 Subject: [Python-checkins] python/dist/src/Doc/tools py2texi.el,NONE,1.1.2.1 mkinfo,1.2,1.2.30.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory usw-pr-cvs1:/tmp/cvs-serv18139/tools Modified Files: Tag: release22-maint mkinfo Added Files: Tag: release22-maint py2texi.el Log Message: Integrated SF patch #539487 by Matthias Klose: This patch adds Milan Zamazal's conversion script and modifies the mkinfo script to build the info doc files from the LaTeX sources. Currently, the mac, doc and inst TeX files are not handled. Explicitly checks for GNU Emacs 21. --- NEW FILE: py2texi.el --- ;;; py2texi.el -- Conversion of Python LaTeX documentation to Texinfo ;; Copyright (C) 1998, 1999, 2001, 2002 Milan Zamazal ;; Author: Milan Zamazal ;; Version: $Id: py2texi.el,v 1.1.2.1 2002/05/03 04:54:20 fdrake Exp $ ;; Keywords: python ;; COPYRIGHT NOTICE ;; ;; This program 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. ;; ;; This program is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ;; for more details. ;; ;; You can find the GNU General Public License at ;; http://www.gnu.org/copyleft/gpl.html ;; or you can write to the Free Software Foundation, Inc., 59 Temple Place, ;; Suite 330, Boston, MA 02111-1307, USA. ;;; Commentary: ;; This is a Q&D hack for conversion of Python manuals to on-line help format. ;; I desperately needed usable online documenta for Python, so I wrote this. ;; The result code is ugly and need not contain complete information from ;; Python manuals. I apologize for my ignorance, especially ignorance to ;; python.sty. Improvements of this convertor are welcomed. ;; How to use it: ;; Load this file and apply `M-x py2texi'. You will be asked for name of a ;; file to be converted. ;; Where to find it: ;; New versions of this code might be found at ;; http://www.zamazal.org/software/python/py2texi/ . ;;; Code: (require 'texinfo) (eval-when-compile (require 'cl)) (defvar py2texi-python-version "2.2" "What to substitute for the \\version macro.") (defvar py2texi-python-short-version (progn (string-match "[0-9]+\\.[0-9]+" py2texi-python-version) (match-string 0 py2texi-python-version)) "Short version number, usually set by the LaTeX commands.") (defvar py2texi-stop-on-problems nil "*If non-nil, stop when you encouter soft problem.") (defconst py2texi-environments '(("abstract" 0 "@quotation" "@end quotation\n") ("center" 0 "" "") ("cfuncdesc" 3 (progn (setq findex t) "\n@table @code\n@item \\1 \\2(\\3)\n@findex \\2\n") "@end table") ("classdesc" 2 (progn (setq obindex t) "\n@table @code\n@item \\1(\\2)\n@obindex \\1\n") "@end table") ("classdesc*" 1 (progn (setq obindex t) "\n@table @code\n@item \\1\n@obindex \\1\n") "@end table") ("csimplemacrodesc" 1 (progn (setq cindex t) "\n@table @code\n@item \\1\n@cindex \\1\n") "@end table") ("ctypedesc" 1 (progn (setq cindex t) "\n@table @code\n@item \\1\n@cindex \\1\n") "@end table") ("cvardesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1 \\2\n@findex \\2\n") "@end table") ("datadesc" 1 (progn (setq findex t) "\n@table @code\n@item \\1\n@findex \\1\n") "@end table") ("datadescni" 1 "\n@table @code\n@item \\1\n" "@end table") ("definitions" 0 "@table @dfn" "@end table\n") ("description" 0 "@table @samp" "@end table\n") ("displaymath" 0 "" "") ("document" 0 (concat "@defcodeindex mo\n" "@defcodeindex ob\n" "@titlepage\n" (format "@title " title "\n") (format "@author " author "\n") "@page\n" author-address "@end titlepage\n" "@node Top, , , (dir)\n") (concat "@indices\n" "@contents\n" "@bye\n")) ("enumerate" 0 "@enumerate" "@end enumerate") ("excdesc" 1 (progn (setq obindex t) "\n@table @code\n@item \\1\n@obindex \\1\n") "@end table") ("excclassdesc" 2 (progn (setq obindex t) "\n@table @code\n@item \\1(\\2)\n@obindex \\1\n") "@end table") ("flushleft" 0 "" "") ("fulllineitems" 0 "\n@table @code\n" "@end table") ("funcdesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1(\\2)\n@findex \\1\n") "@end table") ("funcdescni" 2 "\n@table @code\n@item \\1(\\2)\n" "@end table") ("itemize" 0 "@itemize @bullet" "@end itemize\n") ("list" 2 "\n@table @code\n" "@end table") ("longtableii" 4 (concat "@multitable @columnfractions .5 .5\n" "@item \\3 @tab \\4\n" "@item ------- @tab ------ \n") "@end multitable\n") ("longtableiii" 5 (concat "@multitable @columnfractions .33 .33 .33\n" "@item \\3 @tab \\4 @tab \\5\n" "@item ------- @tab ------ @tab ------\n") "@end multitable\n") ("memberdesc" 1 (progn (setq findex t) "\n@table @code\n@item \\1\n@findex \\1\n") "@end table") ("memberdescni" 1 "\n@table @code\n@item \\1\n" "@end table") ("methoddesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1(\\2)\n@findex \\1\n") "@end table") ("methoddescni" 2 "\n@table @code\n@item \\1(\\2)\n" "@end table") ("notice" 0 "@emph{Notice:} " "") ("opcodedesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1 \\2\n@findex \\1\n") "@end table") ("productionlist" 0 "\n@table @code\n" "@end table") ("quotation" 0 "@quotation" "@end quotation") ("seealso" 0 "See also:\n@table @emph\n" "@end table") ("seealso*" 0 "@table @emph\n" "@end table") ("sloppypar" 0 "" "") ("small" 0 "" "") ("tableii" 4 (concat "@multitable @columnfractions .5 .5\n" "@item \\3 @tab \\4\n" "@item ------- @tab ------ \n") "@end multitable\n") ("tableiii" 5 (concat "@multitable @columnfractions .33 .33 .33\n" "@item \\3 @tab \\4 @tab \\5\n" "@item ------- @tab ------ @tab ------\n") "@end multitable\n") ("tableiv" 6 (concat "@multitable @columnfractions .25 .25 .25 .25\n" "@item \\3 @tab \\4 @tab \\5 @tab \\6\n" "@item ------- @tab ------- @tab ------- @tab -------\n") "@end multitable\n") ("tablev" 7 (concat "@multitable @columnfractions .20 .20 .20 .20 .20\n" "@item \\3 @tab \\4 @tab \\5 @tab \\6 @tab \\7\n" "@item ------- @tab ------- @tab ------- @tab ------- @tab -------\n") "@end multitable\n")) "Associative list defining substitutions for environments. Each list item is of the form (ENVIRONMENT ARGNUM BEGIN END) where: - ENVIRONMENT is LaTeX environment name - ARGNUM is number of (required) macro arguments - BEGIN is substitution for \begin{ENVIRONMENT} - END is substitution for \end{ENVIRONMENT} Both BEGIN and END are evaled. Moreover, you can reference arguments through \N regular expression notation in strings of BEGIN.") (defconst py2texi-commands '(("ABC" 0 "ABC") ("appendix" 0 (progn (setq appendix t) "")) ("ASCII" 0 "ASCII") ("author" 1 (progn (setq author (match-string 1 string)) "")) ("authoraddress" 1 (progn (setq author-address (match-string 1 string)) "")) ("b" 1 "@w{\\1}") ("bf" 0 "@destroy") ("bifuncindex" 1 (progn (setq findex t) "@findex{\\1}")) ("C" 0 "C") ("c" 0 "@,") ("catcode" 0 "") ("cdata" 1 "@code{\\1}") ("centerline" 1 "@center \\1") ("cfunction" 1 "@code{\\1}") ("chapter" 1 (format "@node \\1\n@%s \\1\n" (if appendix "appendix" "chapter"))) ("chapter*" 1 "@node \\1\n@unnumbered \\1\n") ("character" 1 "@samp{\\1}") ("citetitle" 1 "@ref{Top,,,\\1}") ("class" 1 "@code{\\1}") ("code" 1 "@code{\\1}") ("command" 1 "@command{\\1}") ("constant" 1 "@code{\\1}") ("copyright" 1 "@copyright{}") ("Cpp" 0 "C++") ("ctype" 1 "@code{\\1}") ("dataline" 1 (progn (setq findex t) "@item \\1\n@findex \\1\n")) ("date" 1 "\\1") ("declaremodule" 2 (progn (setq cindex t) "@label{\\2}@cindex{\\2}")) ("deprecated" 2 "@emph{This is deprecated in Python \\1. \\2}") ("dfn" 1 "@dfn{\\1}") ("documentclass" 1 py2texi-magic) ("e" 0 "@backslash{}") ("else" 0 (concat "@end ifinfo\n@" (setq last-if "iftex"))) ("EOF" 0 "@code{EOF}") ("email" 1 "@email{\\1}") ("emph" 1 "@emph{\\1}") ("envvar" 1 "@samp{\\1}") ("exception" 1 "@code{\\1}") ("exindex" 1 (progn (setq obindex t) "@obindex{\\1}")) ("fi" 0 (concat "@end " last-if)) ("file" 1 "@file{\\1}") ("filevar" 1 "@file{@var{\\1}}") ("footnote" 1 "@footnote{\\1}") ("frac" 0 "") ("funcline" 2 (progn (setq findex t) "@item \\1 \\2\n@findex \\1")) ("funclineni" 2 "@item \\1 \\2") ("function" 1 "@code{\\1}") ("grammartoken" 1 "@code{\\1}") ("hline" 0 "") ("ifhtml" 0 (concat "@" (setq last-if "ifinfo"))) ("iftexi" 0 (concat "@" (setq last-if "ifinfo"))) ("index" 1 (progn (setq cindex t) "@cindex{\\1}")) ("indexii" 2 (progn (setq cindex t) "@cindex{\\1 \\2}")) ("indexiii" 3 (progn (setq cindex t) "@cindex{\\1 \\2 \\3}")) ("indexiv" 3 (progn (setq cindex t) "@cindex{\\1 \\2 \\3 \\4}")) ("infinity" 0 "@emph{infinity}") ("it" 0 "@destroy") ("kbd" 1 "@key{\\1}") ("keyword" 1 "@code{\\1}") ("kwindex" 1 (progn (setq cindex t) "@cindex{\\1}")) ("label" 1 "@label{\\1}") ("Large" 0 "") ("LaTeX" 0 "La@TeX{}") ("large" 0 "") ("ldots" 0 "@dots{}") ("leftline" 1 "\\1") ("lineii" 2 "@item \\1 @tab \\2") ("lineiii" 3 "@item \\1 @tab \\2 @tab \\3") ("lineiv" 4 "@item \\1 @tab \\2 @tab \\3 @tab \\4") ("linev" 5 "@item \\1 @tab \\2 @tab \\3 @tab \\4 @tab \\5") ("localmoduletable" 0 "") ("longprogramopt" 1 "@option{--\\1}") ("mailheader" 1 "@code{\\1}") ("makeindex" 0 "") ("makemodindex" 0 "") ("maketitle" 0 (concat "@top " title "\n")) ("makevar" 1 "@code{\\1}") ("manpage" 2 "@samp{\\1(\\2)}") ("mbox" 1 "@w{\\1}") ("member" 1 "@code{\\1}") ("memberline" 1 "@item \\1\n@findex \\1\n") ("menuselection" 1 "@samp{\\1}") ("method" 1 "@code{\\1}") ("methodline" 2 (progn (setq moindex t) "@item \\1(\\2)\n@moindex \\1\n")) ("methodlineni" 2 "@item \\1(\\2)\n") ("mimetype" 1 "@samp{\\1}") ("module" 1 "@samp{\\1}") ("moduleauthor" 2 "This module was written by \\1 @email{\\2}.@*") ("modulesynopsis" 1 "\\1") ("moreargs" 0 "@dots{}") ("n" 0 "@backslash{}n") ("newcommand" 2 "") ("newsgroup" 1 "@samp{\\1}") ("nodename" 1 (save-excursion (save-match-data (re-search-backward "^@node ")) (delete-region (point) (save-excursion (end-of-line) (point))) (insert "@node " (match-string 1 string)) "")) ("noindent" 0 "@noindent ") ("note" 1 "@emph{Note:} \\1") ("NULL" 0 "@code{NULL}") ("obindex" 1 (progn (setq obindex t) "@obindex{\\1}")) ("opindex" 1 (progn (setq cindex t) "@cindex{\\1}")) ("option" 1 "@option{\\1}") ("optional" 1 "[\\1]") ("pep" 1 (progn (setq cindex t) "PEP@ \\1@cindex PEP \\1\n")) ("pi" 0 "pi") ("platform" 1 "") ("plusminus" 0 "+-") ("POSIX" 0 "POSIX") ("production" 2 "@item \\1 \\2") ("program" 1 "@command{\\1}") ("programopt" 1 "@option{\\1}") ("protect" 0 "") ("pytype" 1 "@code{\\1}") ("ref" 1 "@ref{\\1}") ("refbimodindex" 1 (progn (setq moindex t) "@moindex{\\1}")) ("refmodindex" 1 (progn (setq moindex t) "@moindex{\\1}")) ("refmodule" 1 "@samp{\\1}") ("refstmodindex" 1 (progn (setq moindex t) "@moindex{\\1}")) ("regexp" 1 "\"\\1\"") ("release" 1 (progn (setq py2texi-python-version (match-string 1 string)) "")) ("renewcommand" 2 "") ("rfc" 1 (progn (setq cindex t) "RFC@ \\1@cindex RFC \\1\n")) ("rm" 0 "@destroy") ("samp" 1 "@samp{\\1}") ("section" 1 (let ((str (match-string 1 string))) (save-match-data (if (string-match "\\(.*\\)[ \t\n]*---[ \t\n]*\\(.*\\)" str) (format "@node %s\n@section %s\n" (py2texi-backslash-quote (match-string 1 str)) (py2texi-backslash-quote (match-string 2 str))) "@node \\1\n@section \\1\n")))) ("sectionauthor" 2 "\nThis manual section was written by \\1 @email{\\2}.@*") ("seemodule" 2 "@ref{\\1} \\2") ("seepep" 3 "\n@table @strong\n@item PEP\\1 \\2\n\\3\n@end table\n") ("seerfc" 3 "\n@table @strong\n@item RFC\\1 \\2\n\\3\n@end table\n") ("seetext" 1 "\\1") ("seetitle" 1 "@cite{\\1}") ("seeurl" 2 "\n@table @url\n@item \\1\n\\2\n@end table\n") ("setindexsubitem" 1 (progn (setq cindex t) "@cindex \\1")) ("setreleaseinfo" 1 (progn (setq py2texi-releaseinfo ""))) ("setshortversion" 1 (progn (setq py2texi-python-short-version (match-string 1 string)) "")) ("shortversion" 0 py2texi-python-short-version) ("sqrt" 0 "") ("stindex" 1 (progn (setq cindex t) "@cindex{\\1}")) ("stmodindex" 1 (progn (setq moindex t) "@moindex{\\1}")) ("strong" 1 "@strong{\\1}") ("sub" 0 "/") ("subsection" 1 "@node \\1\n@subsection \\1\n") ("subsubsection" 1 "@node \\1\n@subsubsection \\1\n") ("sum" 0 "") ("tableofcontents" 0 "") ("term" 1 "@item \\1") ("textasciitilde" 0 "~") ("textasciicircum" 0 "^") ("textbackslash" 0 "@backslash{}") ("textrm" 1 "\\1") ("texttt" 1 "@code{\\1}") ("textunderscore" 0 "_") ("title" 1 (progn (setq title (match-string 1 string)) "@settitle \\1")) ("today" 0 "@today{}") ("token" 1 "@code{\\1}") ("tt" 0 "@destroy") ("ttindex" 1 (progn (setq cindex t) "@cindex{\\1}")) ("u" 0 "@backslash{}u") ("ulink" 2 "\\1") ("UNIX" 0 "UNIX") ("unspecified" 0 "@dots{}") ("url" 1 "@url{\\1}") ("usepackage" 1 "") ("var" 1 "@var{\\1}") ("verbatiminput" 1 "@code{\\1}") ("version" 0 py2texi-python-version) ("versionadded" 1 "@emph{Added in Python version \\1}") ("versionchanged" 1 "@emph{Changed in Python version \\1}") ("vskip" 1 "") ("vspace" 1 "") ("warning" 1 "@emph{\\1}") ("withsubitem" 2 "\\2") ("XXX" 1 "@strong{\\1}")) "Associative list of command substitutions. Each list item is of the form (COMMAND ARGNUM SUBSTITUTION) where: - COMMAND is LaTeX command name - ARGNUM is number of (required) command arguments - SUBSTITUTION substitution for the command. It is evaled and you can reference command arguments through the \\N regexp notation in strings.") (defvar py2texi-magic "@documentclass\n" "\"Magic\" string for auxiliary insertion at the beginning of document.") (defvar py2texi-dirs '("./" "../texinputs/") "Where to search LaTeX input files.") (defvar py2texi-buffer "*py2texi*" "The name of a buffer where Texinfo is generated.") (defconst py2texi-xemacs (string-match "^XEmacs" (emacs-version)) "Running under XEmacs?") (defmacro py2texi-search (regexp &rest body) `(progn (goto-char (point-min)) (while (re-search-forward ,regexp nil t) ,@body))) (defmacro py2texi-search-safe (regexp &rest body) `(py2texi-search ,regexp (unless (py2texi-protected) ,@body))) (defun py2texi-message (message) "Report message and stop if `py2texi-stop-on-problems' is non-nil." (if py2texi-stop-on-problems (error message) (message message))) (defun py2texi-backslash-quote (string) "Double backslahes in STRING." (let ((i 0)) (save-match-data (while (setq i (string-match "\\\\" string i)) (setq string (replace-match "\\\\\\\\" t nil string)) (setq i (+ i 2)))) string)) (defun py2texi (file) "Convert Python LaTeX documentation FILE to Texinfo." (interactive "fFile to convert: ") (switch-to-buffer (get-buffer-create py2texi-buffer)) (erase-buffer) (insert-file file) (let ((case-fold-search nil) (title "") (author "") (author-address "") (appendix nil) (findex nil) (obindex nil) (cindex nil) (moindex nil) last-if) (py2texi-process-verbatims) (py2texi-process-comments) (py2texi-process-includes) (py2texi-process-funnyas) (py2texi-process-environments) (py2texi-process-commands) (py2texi-fix-indentation) (py2texi-fix-nodes) (py2texi-fix-references) (py2texi-fix-indices) (py2texi-process-simple-commands) (py2texi-fix-fonts) (py2texi-fix-braces) (py2texi-fix-backslashes) (py2texi-destroy-empties) (py2texi-fix-newlines) (py2texi-adjust-level)) (let* ((filename (concat "./" (file-name-nondirectory file) (if (string-match "\\.tex$" file) "i" ".texi"))) (infofilename (py2texi-info-file-name filename))) (goto-char (point-min)) (when (looking-at py2texi-magic) (delete-region (point) (progn (beginning-of-line 2) (point))) (insert "\\input texinfo @c -*-texinfo-*-\n") (insert "@setfilename " (file-name-nondirectory infofilename))) (when (re-search-forward "@chapter" nil t) (texinfo-all-menus-update t)) (goto-char (point-min)) (write-file filename) (message (format "You can apply `makeinfo %s' now." filename)))) (defun py2texi-info-file-name (filename) "Generate name of info file from original file name FILENAME." (setq filename (expand-file-name filename)) (let ((directory (file-name-directory filename)) (basename (file-name-nondirectory filename))) (concat directory "python-" (substring basename 0 (- (length basename) 4)) "info"))) (defun py2texi-process-verbatims () "Process and protect verbatim environments." (let (delimiter beg end) (py2texi-search-safe "\\\\begin{\\(verbatim\\|displaymath\\)}" (replace-match "@example") (setq beg (copy-marker (point) nil)) (re-search-forward "\\\\end{\\(verbatim\\|displaymath\\)}") (setq end (copy-marker (match-beginning 0) nil)) (replace-match "@end example") (py2texi-texinfo-escape beg end) (put-text-property (- beg (length "@example")) (+ end (length "@end example")) 'py2texi-protected t)) (py2texi-search-safe "\\\\verb\\([^a-z]\\)" (setq delimiter (match-string 1)) (replace-match "@code{") (setq beg (copy-marker (point) nil)) (re-search-forward (regexp-quote delimiter)) (setq end (copy-marker (match-beginning 0) nil)) (replace-match "}") (put-text-property (- beg (length "@code{")) (+ end (length "}")) 'py2texi-protected t) (py2texi-texinfo-escape beg end)))) (defun py2texi-process-comments () "Remove comments." (let (point) (py2texi-search-safe "%" (setq point (point)) (when (save-excursion (re-search-backward "\\(^\\|[^\\]\\(\\\\\\\\\\)*\\)%\\=" nil t)) (delete-region (1- point) (save-excursion (beginning-of-line 2) (point))))))) (defun py2texi-process-includes () "Include LaTeX input files. Do not include .ind files." (let ((path (file-name-directory file)) filename dirs includefile) (py2texi-search-safe "\\\\input{\\([^}]+\\)}" (setq filename (match-string 1)) (unless (save-match-data (string-match "\\.tex$" filename)) (setq filename (concat filename ".tex"))) (setq includefile (save-match-data (string-match "\\.ind\\.tex$" filename))) (setq dirs py2texi-dirs) (while (and (not includefile) dirs) (setq includefile (concat path (car dirs) filename)) (unless (file-exists-p includefile) (setq includefile nil) (setq dirs (cdr dirs)))) (if includefile (save-restriction (narrow-to-region (match-beginning 0) (match-end 0)) (delete-region (point-min) (point-max)) (when (stringp includefile) (insert-file-contents includefile) (goto-char (point-min)) (insert "\n") (py2texi-process-verbatims) (py2texi-process-comments) (py2texi-process-includes))) (replace-match (format "\\\\emph{Included file %s}" filename)) (py2texi-message (format "Input file %s not found" filename)))))) (defun py2texi-process-funnyas () "Convert @s." (py2texi-search-safe "@" (replace-match "@@"))) (defun py2texi-process-environments () "Process LaTeX environments." (let ((stack ()) kind environment parameter arguments n string description) (py2texi-search-safe (concat "\\\\\\(begin\\|end\\|item\\)" "\\({\\([^}]*\\)}\\|[[]\\([^]]*\\)[]]\\|\\)") (setq kind (match-string 1) environment (match-string 3) parameter (match-string 4)) (replace-match "") (cond ((string= kind "begin") (setq description (assoc environment py2texi-environments)) (if description (progn (setq n (cadr description)) (setq description (cddr description)) (setq string (py2texi-tex-arguments n)) (string-match (py2texi-regexp n) string) ; incorrect but sufficient (insert (replace-match (eval (car description)) t nil string)) (setq stack (cons (cadr description) stack))) (py2texi-message (format "Unknown environment: %s" environment)) (setq stack (cons "" stack)))) ((string= kind "end") (insert (eval (car stack))) (setq stack (cdr stack))) ((string= kind "item") (insert "\n@item " (or parameter "") "\n")))) (when stack (py2texi-message (format "Unclosed environment: %s" (car stack)))))) (defun py2texi-process-commands () "Process LaTeX commands." (let (done command command-info string n) (while (not done) (setq done t) (py2texi-search-safe "\\\\\\([a-zA-Z*]+\\)\\(\\[[^]]*\\]\\)?" (setq command (match-string 1)) (setq command-info (assoc command py2texi-commands)) (if command-info (progn (setq done nil) (replace-match "") (setq command-info (cdr command-info)) (setq n (car command-info)) (setq string (py2texi-tex-arguments n)) (string-match (py2texi-regexp n) string) ; incorrect but sufficient (insert (replace-match (eval (cadr command-info)) t nil string))) (py2texi-message (format "Unknown command: %s (not processed)" command))))))) (defun py2texi-argument-pattern (count) (let ((filler "\\(?:[^{}]\\|\\\\{\\|\\\\}\\)*")) (if (<= count 0) filler (concat filler "\\(?:{" (py2texi-argument-pattern (1- count)) "}" filler "\\)*" filler)))) (defconst py2texi-tex-argument (concat "{\\(" (py2texi-argument-pattern 10) ;really at least 10! "\\)}[ \t%@c\n]*") "Regexp describing LaTeX command argument including argument separators.") (defun py2texi-regexp (n) "Make regexp matching N LaTeX command arguments." (if (= n 0) "" (let ((regexp "^[^{]*")) (while (> n 0) (setq regexp (concat regexp py2texi-tex-argument)) (setq n (1- n))) regexp))) (defun py2texi-tex-arguments (n) "Remove N LaTeX command arguments and return them as a string." (let ((point (point)) (i 0) result match) (if (= n 0) (progn (when (re-search-forward "\\=\\({}\\| *\\)" nil t) (replace-match "")) "") (while (> n 0) (unless (re-search-forward "\\(\\=\\|[^\\\\]\\)\\(\\\\\\\\\\)*\\([{}]\\)" nil t) (debug)) (if (string= (match-string 3) "{") (setq i (1+ i)) (setq i (1- i)) (when (<= i 0) (setq n (1- n))))) (setq result (buffer-substring-no-properties point (point))) (while (string-match "\n[ \t]*" result) (setq result (replace-match " " t nil result))) (delete-region point (point)) result))) (defun py2texi-process-simple-commands () "Replace single character LaTeX commands." (let (char) (py2texi-search-safe "\\\\\\([^a-z]\\)" (setq char (match-string 1)) (replace-match (format "%s%s" (if (or (string= char "{") (string= char "}") (string= char " ")) "@" "") (if (string= char "\\") "\\\\" char)))))) (defun py2texi-fix-indentation () "Remove white space at the beginning of lines." (py2texi-search-safe "^[ \t]+" (replace-match ""))) (defun py2texi-fix-nodes () "Remove unwanted characters from nodes and make nodes unique." (let ((nodes (make-hash-table :test 'equal)) id counter string label) (py2texi-search "^@node +\\(.*\\)$" (setq string (match-string 1)) (if py2texi-xemacs (replace-match "@node " t) (replace-match "" t nil nil 1)) (when (string-match "@label{[^}]*}" string) (setq label (match-string 0 string)) (setq string (replace-match "" t nil string))) (while (string-match "@[a-zA-Z]+\\|[{}():]\\|``\\|''" string) (setq string (replace-match "" t nil string))) (while (string-match " -- " string) (setq string (replace-match " - " t nil string))) (when (string-match " +$" string) (setq string (replace-match "" t nil string))) (when (string-match "^\\(Built-in\\|Standard\\) Module \\|The " string) (setq string (replace-match "" t nil string))) (string-match "^[^,]+" string) (setq id (match-string 0 string)) (setq counter (gethash id nodes)) (if counter (progn (setq counter (1+ counter)) (setq string (replace-match (format "\\& %d" counter) t nil string))) (setq counter 1)) (setf (gethash id nodes) counter) (insert string) (when label (beginning-of-line 3) (insert label "\n"))))) (defun py2texi-fix-references () "Process labels and make references to point to appropriate nodes." (let ((labels ()) node) (py2texi-search-safe "@label{\\([^}]*\\)}" (setq node (save-excursion (save-match-data (and (re-search-backward "@node +\\([^,\n]+\\)" nil t) (match-string 1))))) (when node (setq labels (cons (cons (match-string 1) node) labels))) (replace-match "")) (py2texi-search-safe "@ref{\\([^}]*\\)}" (setq node (assoc (match-string 1) labels)) (replace-match "") (when node (insert (format "@ref{%s}" (cdr node))))))) (defun py2texi-fix-indices () "Remove unwanted characters from @*index commands and create final indices." (py2texi-search-safe "@..?index\\>[^\n]*\\(\\)\n" (replace-match "" t nil nil 1)) (py2texi-search-safe "@..?index\\>[^\n]*\\(\\)" (replace-match "\n" t nil nil 1)) (py2texi-search-safe "@..?index\\({\\)\\([^}]+\\)\\(}+\\)" (replace-match " " t nil nil 1) (replace-match "" t nil nil 3) (let ((string (match-string 2))) (save-match-data (while (string-match "@[a-z]+{" string) (setq string (replace-match "" nil nil string))) (while (string-match "{" string) (setq string (replace-match "" nil nil string)))) (replace-match string t t nil 2))) (py2texi-search-safe "@..?index\\>.*\\([{}]\\|@[a-z]*\\)" (replace-match "" t nil nil 1) (goto-char (match-beginning 0))) (py2texi-search-safe "[^\n]\\(\\)@..?index\\>" (replace-match "\n" t nil nil 1)) (goto-char (point-max)) (re-search-backward "@indices") (replace-match "") (insert (if moindex (concat "@node Module Index\n" "@unnumbered Module Index\n" "@printindex mo\n") "") (if obindex (concat "@node Class-Exception-Object Index\n" "@unnumbered Class, Exception, and Object Index\n" "@printindex ob\n") "") (if findex (concat "@node Function-Method-Variable Index\n" "@unnumbered Function, Method, and Variable Index\n" "@printindex fn\n") "") (if cindex (concat "@node Miscellaneous Index\n" "@unnumbered Miscellaneous Index\n" "@printindex cp\n") ""))) (defun py2texi-fix-backslashes () "Make backslashes from auxiliary commands." (py2texi-search-safe "@backslash{}" (replace-match "\\\\"))) (defun py2texi-fix-fonts () "Remove garbage after unstructured font commands." (let (string) (py2texi-search-safe "@destroy" (replace-match "") (when (eq (preceding-char) ?{) (forward-char -1) (setq string (py2texi-tex-arguments 1)) (insert (substring string 1 (1- (length string)))))))) (defun py2texi-fix-braces () "Escape braces for Texinfo." (let (string) (py2texi-search "{" (unless (or (py2texi-protected) (save-excursion (re-search-backward "@\\([a-zA-Z]*\\|multitable.*\\){\\=" nil t))) (forward-char -1) (setq string (py2texi-tex-arguments 1)) (insert "@" (substring string 0 (1- (length string))) "@}"))))) (defun py2texi-fix-newlines () "Remove extra newlines." (py2texi-search "\n\n\n+" (replace-match "\n\n")) (py2texi-search-safe "@item.*\n\n" (delete-backward-char 1)) (py2texi-search "@end example" (unless (looking-at "\n\n") (insert "\n")))) (defun py2texi-destroy-empties () "Remove all comments. This avoids some makeinfo errors." (py2texi-search "@c\\>" (unless (eq (py2texi-protected) t) (delete-region (- (point) 2) (save-excursion (end-of-line) (point))) (cond ((looking-at "\n\n") (delete-char 1)) ((save-excursion (re-search-backward "^[ \t]*\\=" nil t)) (delete-region (save-excursion (beginning-of-line) (point)) (1+ (point)))))))) (defun py2texi-adjust-level () "Increase heading level to @chapter, if needed. This is only needed for distutils, so it has a very simple form only." (goto-char (point-min)) (unless (re-search-forward "@chapter\\>" nil t) (py2texi-search-safe "@section\\>" (replace-match "@chapter" t)) (py2texi-search-safe "@\\(sub\\)\\(sub\\)?section\\>" (replace-match "" nil nil nil 1)))) (defun py2texi-texinfo-escape (beg end) "Escape Texinfo special characters in region." (save-excursion (goto-char beg) (while (re-search-forward "[@{}]" end t) (replace-match "@\\&")))) (defun py2texi-protected () "Return protection status of the point before current point." (get-text-property (1- (point)) 'py2texi-protected)) ;;; Announce (provide 'py2texi) ;;; py2texi.el ends here Index: mkinfo =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/mkinfo,v retrieving revision 1.2 retrieving revision 1.2.30.1 diff -C2 -d -r1.2 -r1.2.30.1 *** mkinfo 8 Jan 1999 15:32:27 -0000 1.2 --- mkinfo 3 May 2002 04:54:20 -0000 1.2.30.1 *************** *** 18,22 **** DOCDIR=`dirname "$FILENAME"` DOCFILE=`basename "$FILENAME"` ! DOCNAME=`basename "$FILENAME" .html` # Now build the real directory names, and locate our support stuff: --- 18,27 ---- DOCDIR=`dirname "$FILENAME"` DOCFILE=`basename "$FILENAME"` ! DOCNAME=`basename "$FILENAME" .tex` ! if [ $# -gt 1 ]; then ! INFONAME="$2" ! else ! INFONAME="python-$DOCNAME.info" ! fi # Now build the real directory names, and locate our support stuff: *************** *** 32,36 **** # show what we're doing, like make does: echo "$*" ! $* || exit $? } --- 37,41 ---- # show what we're doing, like make does: echo "$*" ! "$@" || exit $? } *************** *** 38,44 **** # generate the Texinfo file: ! run $PERL -I$TOOLSDIR $TOOLSDIR/html2texi.pl $DOCDIR/$DOCFILE ! run $EMACS -batch -l $TOOLSDIR/fixinfo.el $DOCNAME.texi ! rm -f $DOCNAME.texi~ --- 43,51 ---- # generate the Texinfo file: ! run $EMACS -batch -q --no-site-file -l $TOOLSDIR/py2texi.el \ ! --eval "(setq py2texi-dirs '(\"./\" \"../texinputs/\" \"$DOCDIR\"))" \ ! --eval "(py2texi \"$DOCDIR/$DOCFILE\")" \ ! -f kill-emacs ! echo Done *************** *** 46,48 **** run $MAKEINFO --footnote-style end --fill-column 72 \ ! --paragraph-indent 0 $DOCNAME.texi --- 53,55 ---- run $MAKEINFO --footnote-style end --fill-column 72 \ ! --paragraph-indent 0 --output=$INFONAME $DOCNAME.texi From loewis@sourceforge.net Fri May 3 06:53:17 2002 From: loewis@sourceforge.net (loewis@sourceforge.net) Date: Thu, 02 May 2002 22:53:17 -0700 Subject: [Python-checkins] python/dist/src configure,1.303,1.304 configure.in,1.313,1.314 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv29775 Modified Files: configure configure.in Log Message: Patch #551093: Let cygwin default to --enable-shared. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.303 retrieving revision 1.304 diff -C2 -d -r1.303 -r1.304 *** configure 20 Apr 2002 13:46:42 -0000 1.303 --- configure 3 May 2002 05:53:15 -0000 1.304 *************** *** 1,4 **** #! /bin/sh ! # From configure.in Revision: 1.311 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. --- 1,4 ---- #! /bin/sh ! # From configure.in Revision: 1.313 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. *************** *** 3071,3075 **** if test -z "$enable_shared" then ! enable_shared="no" fi echo "$as_me:$LINENO: result: $enable_shared" >&5 --- 3071,3080 ---- if test -z "$enable_shared" then ! case $ac_sys_system in ! CYGWIN*) ! enable_shared="yes";; ! *) ! enable_shared="no";; ! esac fi echo "$as_me:$LINENO: result: $enable_shared" >&5 Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.313 retrieving revision 1.314 diff -C2 -d -r1.313 -r1.314 *** configure.in 20 Apr 2002 13:46:43 -0000 1.313 --- configure.in 3 May 2002 05:53:15 -0000 1.314 *************** *** 338,342 **** if test -z "$enable_shared" then ! enable_shared="no" fi AC_MSG_RESULT($enable_shared) --- 338,347 ---- if test -z "$enable_shared" then ! case $ac_sys_system in ! CYGWIN*) ! enable_shared="yes";; ! *) ! enable_shared="no";; ! esac fi AC_MSG_RESULT($enable_shared) From nascheme@sourceforge.net Sat May 4 06:35:22 2002 From: nascheme@sourceforge.net (nascheme@sourceforge.net) Date: Fri, 03 May 2002 22:35:22 -0700 Subject: [Python-checkins] python/dist/src/Modules gcmodule.c,2.40,2.41 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv5412/Modules Modified Files: gcmodule.c Log Message: Move all data for a single generation into a structure. The set of generations is now an array. This cleans up some code and makes it easy to change the number of generations. Also, implemented a gc_list_is_empty() function. This makes the logic a little clearer in places. The performance impact of these changes should be negligible. One functional change is that allocation/collection counters are always zeroed at the start of a collection. This should fix SF bug #551915. This change is too big for back-porting but the minimal patch on SF looks good for a bugfix release. Index: gcmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v retrieving revision 2.40 retrieving revision 2.41 diff -C2 -d -r2.40 -r2.41 *** gcmodule.c 28 Apr 2002 01:57:25 -0000 2.40 --- gcmodule.c 4 May 2002 05:35:20 -0000 2.41 *************** *** 32,49 **** /*** Global GC state ***/ /* linked lists of container objects */ ! PyGC_Head _PyGC_generation0 = {{&_PyGC_generation0, &_PyGC_generation0, 0}}; ! static PyGC_Head generation1 = {{&generation1, &generation1, 0}}; ! static PyGC_Head generation2 = {{&generation2, &generation2, 0}}; ! static int generation = 0; /* current generation being collected */ ! /* collection frequencies, XXX tune these */ ! static int enabled = 1; /* automatic collection enabled? */ ! static int threshold0 = 700; /* net new containers before collection */ ! static int threshold1 = 10; /* generation0 collections before collecting 1 */ ! static int threshold2 = 10; /* generation1 collections before collecting 2 */ ! /* net new objects allocated since last collection */ ! static int allocated; /* true if we are currently running the collector */ --- 32,56 ---- /*** Global GC state ***/ + struct gc_generation { + PyGC_Head head; + int threshold; /* collection threshold */ + int count; /* count of allocations or collections of younger + generations */ + }; + + #define NUM_GENERATIONS 3 + #define GEN_HEAD(n) (&generations[n].head) + /* linked lists of container objects */ ! static struct gc_generation generations[NUM_GENERATIONS] = { ! /* PyGC_Head, threshold, count */ ! {{{GEN_HEAD(0), GEN_HEAD(0), 0}}, 700, 0}, ! {{{GEN_HEAD(1), GEN_HEAD(1), 0}}, 10, 0}, ! {{{GEN_HEAD(2), GEN_HEAD(2), 0}}, 10, 0}, ! }; ! PyGC_Head *_PyGC_generation0 = GEN_HEAD(0); ! static int enabled = 1; /* automatic collection enabled? */ /* true if we are currently running the collector */ *************** *** 82,85 **** --- 89,98 ---- } + static int + gc_list_is_empty(PyGC_Head *list) + { + return (list->gc.gc_next == list); + } + static void gc_list_append(PyGC_Head *node, PyGC_Head *list) *************** *** 102,107 **** gc_list_move(PyGC_Head *from, PyGC_Head *to) { ! if (from->gc.gc_next == from) { ! /* empty from list */ gc_list_init(to); } --- 115,119 ---- gc_list_move(PyGC_Head *from, PyGC_Head *to) { ! if (gc_list_is_empty(from)) { gc_list_init(to); } *************** *** 120,124 **** { PyGC_Head *tail; ! if (from->gc.gc_next != from) { tail = to->gc.gc_prev; tail->gc.gc_next = from->gc.gc_next; --- 132,136 ---- { PyGC_Head *tail; ! if (!gc_list_is_empty(from)) { tail = to->gc.gc_prev; tail->gc.gc_next = from->gc.gc_next; *************** *** 331,335 **** inquiry clear; ! while (unreachable->gc.gc_next != unreachable) { PyGC_Head *gc = unreachable->gc.gc_next; PyObject *op = FROM_GC(gc); --- 343,347 ---- inquiry clear; ! while (!gc_list_is_empty(unreachable)) { PyGC_Head *gc = unreachable->gc.gc_next; PyObject *op = FROM_GC(gc); *************** *** 355,362 **** * collection process works. */ static long ! collect(PyGC_Head *young, PyGC_Head *old) { long n = 0; long m = 0; PyGC_Head reachable; PyGC_Head unreachable; --- 367,377 ---- * collection process works. */ static long ! collect(int generation) { + int i; long n = 0; long m = 0; + PyGC_Head *young; /* the generation we are examining */ + PyGC_Head *old; /* next older generation */ PyGC_Head reachable; PyGC_Head unreachable; *************** *** 365,375 **** if (debug & DEBUG_STATS) { ! PySys_WriteStderr( ! "gc: collecting generation %d...\n" ! "gc: objects in each generation: %ld %ld %ld\n", ! generation, ! gc_list_size(&_PyGC_generation0), ! gc_list_size(&generation1), ! gc_list_size(&generation2)); } --- 380,409 ---- if (debug & DEBUG_STATS) { ! PySys_WriteStderr("gc: collecting generation %d...\n", ! generation); ! PySys_WriteStderr("gc: objects in each generation:"); ! for (i = 0; i < NUM_GENERATIONS; i++) { ! PySys_WriteStderr(" %ld", gc_list_size(GEN_HEAD(i))); ! } ! PySys_WriteStderr("\n"); ! } ! ! /* update collection and allocation counters */ ! if (generation+1 < NUM_GENERATIONS) ! generations[generation+1].count += 1; ! for (i = 0; i <= generation; i++) ! generations[generation].count = 0; ! ! /* merge younger generations with one we are currently collecting */ ! for (i = 0; i < generation; i++) { ! gc_list_merge(GEN_HEAD(i), GEN_HEAD(generation)); ! } ! ! /* handy references */ ! young = GEN_HEAD(generation); ! if (generation < NUM_GENERATIONS-1) { ! old = GEN_HEAD(generation+1); ! } else { ! old = GEN_HEAD(NUM_GENERATIONS-1); } *************** *** 450,454 **** Py_FatalError("unexpected exception during garbage collection"); } - allocated = 0; return n+m; } --- 484,487 ---- *************** *** 457,488 **** collect_generations(void) { ! static long collections0 = 0; ! static long collections1 = 0; long n = 0; ! ! if (collections1 > threshold2) { ! generation = 2; ! gc_list_merge(&_PyGC_generation0, &generation2); ! gc_list_merge(&generation1, &generation2); ! if (generation2.gc.gc_next != &generation2) { ! n = collect(&generation2, &generation2); ! } ! collections1 = 0; ! } ! else if (collections0 > threshold1) { ! generation = 1; ! collections1++; ! gc_list_merge(&_PyGC_generation0, &generation1); ! if (generation1.gc.gc_next != &generation1) { ! n = collect(&generation1, &generation2); ! } ! collections0 = 0; ! } ! else { ! generation = 0; ! collections0++; ! if (_PyGC_generation0.gc.gc_next != &_PyGC_generation0) { ! n = collect(&_PyGC_generation0, &generation1); } } --- 490,503 ---- collect_generations(void) { ! int i; long n = 0; ! /* Find the oldest generation (higest numbered) where the count ! * exceeds the threshold. Objects in the that generation and ! * generations younger than it will be collected. */ ! for (i = NUM_GENERATIONS-1; i >= 0; i--) { ! if (generations[i].count > generations[i].threshold) { ! n = collect(i); ! break; } } *************** *** 563,570 **** else { collecting = 1; ! generation = 2; ! gc_list_merge(&_PyGC_generation0, &generation2); ! gc_list_merge(&generation1, &generation2); ! n = collect(&generation2, &generation2); collecting = 0; } --- 578,582 ---- else { collecting = 1; ! n = collect(NUM_GENERATIONS - 1); collecting = 0; } *************** *** 625,631 **** gc_set_thresh(PyObject *self, PyObject *args) { ! if (!PyArg_ParseTuple(args, "i|ii:set_threshold", &threshold0, ! &threshold1, &threshold2)) return NULL; Py_INCREF(Py_None); --- 637,650 ---- gc_set_thresh(PyObject *self, PyObject *args) { ! int i; ! if (!PyArg_ParseTuple(args, "i|ii:set_threshold", ! &generations[0].threshold, ! &generations[1].threshold, ! &generations[2].threshold)) return NULL; + for (i = 2; i < NUM_GENERATIONS; i++) { + /* generations higher than 2 get the same threshold */ + generations[i].threshold = generations[2].threshold; + } Py_INCREF(Py_None); *************** *** 645,649 **** return NULL; ! return Py_BuildValue("(iii)", threshold0, threshold1, threshold2); } --- 664,671 ---- return NULL; ! return Py_BuildValue("(iii)", ! generations[0].threshold, ! generations[1].threshold, ! generations[2].threshold); } *************** *** 684,693 **** gc_get_referrers(PyObject *self, PyObject *args) { PyObject *result = PyList_New(0); ! if (!(gc_referrers_for(args, &_PyGC_generation0, result) && ! gc_referrers_for(args, &generation1, result) && ! gc_referrers_for(args, &generation2, result))) { ! Py_DECREF(result); ! return NULL; } return result; --- 706,716 ---- gc_get_referrers(PyObject *self, PyObject *args) { + int i; PyObject *result = PyList_New(0); ! for (i = 0; i < NUM_GENERATIONS; i++) { ! if (!(gc_referrers_for(args, GEN_HEAD(i), result))) { ! Py_DECREF(result); ! return NULL; ! } } return result; *************** *** 720,723 **** --- 743,747 ---- gc_get_objects(PyObject *self, PyObject *args) { + int i; PyObject* result; *************** *** 728,736 **** return NULL; } ! if (append_objects(result, &_PyGC_generation0) || ! append_objects(result, &generation1) || ! append_objects(result, &generation2)) { ! Py_DECREF(result); ! return NULL; } return result; --- 752,760 ---- return NULL; } ! for (i = 0; i < NUM_GENERATIONS; i++) { ! if (append_objects(result, GEN_HEAD(i))) { ! Py_DECREF(result); ! return NULL; ! } } return result; *************** *** 855,866 **** return (PyObject *)PyErr_NoMemory(); g->gc.gc_next = NULL; ! allocated++; ! if (allocated > threshold0 && enabled && ! threshold0 && !collecting && !PyErr_Occurred()) { collecting = 1; ! collect_generations(); collecting = 0; } --- 879,890 ---- return (PyObject *)PyErr_NoMemory(); g->gc.gc_next = NULL; ! generations[0].count++; /* number of allocated GC objects */ ! if (generations[0].count > generations[0].threshold && enabled && ! generations[0].threshold && !collecting && !PyErr_Occurred()) { collecting = 1; ! collect_generations(); collecting = 0; } *************** *** 920,925 **** if (g->gc.gc_next != NULL) gc_list_remove(g); ! if (allocated > 0) { ! allocated--; } PyObject_FREE(g); --- 944,949 ---- if (g->gc.gc_next != NULL) gc_list_remove(g); ! if (generations[0].count > 0) { ! generations[0].count--; } PyObject_FREE(g); From nascheme@sourceforge.net Sat May 4 06:36:08 2002 From: nascheme@sourceforge.net (nascheme@sourceforge.net) Date: Fri, 03 May 2002 22:36:08 -0700 Subject: [Python-checkins] python/dist/src/Include objimpl.h,2.52,2.53 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv5549/Include Modified Files: objimpl.h Log Message: _PyGC_generation0 is now a pointer Index: objimpl.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/objimpl.h,v retrieving revision 2.52 retrieving revision 2.53 diff -C2 -d -r2.52 -r2.53 *** objimpl.h 28 Apr 2002 04:11:46 -0000 2.52 --- objimpl.h 4 May 2002 05:36:06 -0000 2.53 *************** *** 259,263 **** } PyGC_Head; ! extern PyGC_Head _PyGC_generation0; #define _Py_AS_GC(o) ((PyGC_Head *)(o)-1) --- 259,263 ---- } PyGC_Head; ! extern PyGC_Head *_PyGC_generation0; #define _Py_AS_GC(o) ((PyGC_Head *)(o)-1) *************** *** 269,276 **** if (g->gc.gc_next != NULL) \ Py_FatalError("GC object already in linked list"); \ ! g->gc.gc_next = &_PyGC_generation0; \ ! g->gc.gc_prev = _PyGC_generation0.gc.gc_prev; \ g->gc.gc_prev->gc.gc_next = g; \ ! _PyGC_generation0.gc.gc_prev = g; \ } while (0); --- 269,276 ---- if (g->gc.gc_next != NULL) \ Py_FatalError("GC object already in linked list"); \ ! g->gc.gc_next = _PyGC_generation0; \ ! g->gc.gc_prev = _PyGC_generation0->gc.gc_prev; \ g->gc.gc_prev->gc.gc_next = g; \ ! _PyGC_generation0->gc.gc_prev = g; \ } while (0); From loewis@sourceforge.net Sat May 4 14:13:44 2002 From: loewis@sourceforge.net (loewis@sourceforge.net) Date: Sat, 04 May 2002 06:13:44 -0700 Subject: [Python-checkins] python/dist/src/Modules posixmodule.c,2.232,2.233 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv26421 Modified Files: posixmodule.c Log Message: Rename posix_WCONTINUED to posix_WIFCONTINUED, call WIFCONTINUED inside, add it to the posix_methods. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.232 retrieving revision 2.233 diff -C2 -d -r2.232 -r2.233 *** posixmodule.c 23 Apr 2002 15:58:01 -0000 2.232 --- posixmodule.c 4 May 2002 13:13:41 -0000 2.233 *************** *** 4858,4862 **** static PyObject * ! posix_WCONTINUED(PyObject *self, PyObject *args) { #ifdef UNION_WAIT --- 4858,4862 ---- static PyObject * ! posix_WIFCONTINUED(PyObject *self, PyObject *args) { #ifdef UNION_WAIT *************** *** 4874,4878 **** } ! return PyBool_FromLong(WCONTINUED(status)); #undef status_i } --- 4874,4878 ---- } ! return PyBool_FromLong(WIFCONTINUED(status)); #undef status_i } *************** *** 6466,6469 **** --- 6466,6472 ---- {"WCOREDUMP", posix_WCOREDUMP, METH_VARARGS, posix_WCOREDUMP__doc__}, #endif /* WCOREDUMP */ + #ifdef WIFCONTINUED + {"WIFCONTINUED",posix_WIFCONTINUED, METH_VARARGS, posix_WIFCONTINUED__doc__}, + #endif /* WIFCONTINUED */ #ifdef WIFSTOPPED {"WIFSTOPPED", posix_WIFSTOPPED, METH_VARARGS, posix_WIFSTOPPED__doc__}, From tim_one@sourceforge.net Sun May 5 21:40:02 2002 From: tim_one@sourceforge.net (tim_one@sourceforge.net) Date: Sun, 05 May 2002 13:40:02 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_random.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv14885/python/Lib/test Added Files: test_random.py Log Message: random.gauss() uses a piece of hidden state used by nothing else, and the .seed() and .whseed() methods failed to reset it. In other words, setting the seed didn't completely determine the sequence of results produced by random.gauss(). It does now. Programs repeatedly mixing calls to a seed method with calls to gauss() may see different results now. Bugfix candidate (random.gauss() has always been broken in this way), despite that it may change results. --- NEW FILE: test_random.py --- import test_support import random # Ensure that the seed() method initializes all the hidden state. In # particular, through 2.2.1 it failed to reset a piece of state used by # (and only by) the .gauss() method. for seed in 1, 12, 123, 1234, 12345, 123456, 654321: for seeder in random.seed, random.whseed: seeder(seed) x1 = random.random() y1 = random.gauss(0, 1) seeder(seed) x2 = random.random() y2 = random.gauss(0, 1) test_support.vereq(x1, x2) test_support.vereq(y1, y2) From tim_one@sourceforge.net Sun May 5 21:40:02 2002 From: tim_one@sourceforge.net (tim_one@sourceforge.net) Date: Sun, 05 May 2002 13:40:02 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.401,1.402 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv14885/python/Misc Modified Files: NEWS Log Message: random.gauss() uses a piece of hidden state used by nothing else, and the .seed() and .whseed() methods failed to reset it. In other words, setting the seed didn't completely determine the sequence of results produced by random.gauss(). It does now. Programs repeatedly mixing calls to a seed method with calls to gauss() may see different results now. Bugfix candidate (random.gauss() has always been broken in this way), despite that it may change results. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.401 retrieving revision 1.402 diff -C2 -d -r1.401 -r1.402 *** NEWS 2 May 2002 21:28:26 -0000 1.401 --- NEWS 5 May 2002 20:40:00 -0000 1.402 *************** *** 105,108 **** --- 105,115 ---- Library + - random.gauss() uses a piece of hidden state used by nothing else, + and the .seed() and .whseed() methods failed to reset it. In other + words, setting the seed didn't completely determine the sequence of + results produced by random.gauss(). It does now. Programs repeatedly + mixing calls to a seed method with calls to gauss() may see different + results now. + - The pickle.Pickler class grew a clear_memo() method to mimic that provided by cPickle.Pickler. From tim_one@sourceforge.net Sun May 5 21:40:01 2002 From: tim_one@sourceforge.net (tim_one@sourceforge.net) Date: Sun, 05 May 2002 13:40:01 -0700 Subject: [Python-checkins] python/dist/src/Lib random.py,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv14885/python/Lib Modified Files: random.py Log Message: random.gauss() uses a piece of hidden state used by nothing else, and the .seed() and .whseed() methods failed to reset it. In other words, setting the seed didn't completely determine the sequence of results produced by random.gauss(). It does now. Programs repeatedly mixing calls to a seed method with calls to gauss() may see different results now. Bugfix candidate (random.gauss() has always been broken in this way), despite that it may change results. Index: random.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/random.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** random.py 13 Apr 2002 14:41:19 -0000 1.27 --- random.py 5 May 2002 20:39:59 -0000 1.28 *************** *** 117,121 **** self.seed(x) - self.gauss_next = None ## -------------------- core generator ------------------- --- 117,120 ---- *************** *** 151,154 **** --- 150,155 ---- self._seed = int(x)+1, int(y)+1, int(z)+1 + self.gauss_next = None + def random(self): """Get the next random number in the range [0.0, 1.0).""" *************** *** 238,241 **** --- 239,244 ---- # Zero is a poor seed, so substitute 1 self._seed = (x or 1, y or 1, z or 1) + + self.gauss_next = None def whseed(self, a=None): From jackjansen@sourceforge.net Sun May 5 22:48:14 2002 From: jackjansen@sourceforge.net (jackjansen@sourceforge.net) Date: Sun, 05 May 2002 14:48:14 -0700 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf pycfbridge.c,NONE,1.1 pycfbridge.h,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory usw-pr-cvs1:/tmp/cvs-serv12539 Added Files: pycfbridge.c pycfbridge.h Log Message: First steps towards a generalized converter of Python object hierarchies to CoreFoundation object hierarchies and vice versa. --- NEW FILE: pycfbridge.c --- /* ** Convert objects from Python to CoreFoundation and vice-versa. */ #ifdef WITHOUT_FRAMEWORKS #include #include #include #include #include #include #else #include #endif #include "Python.h" #include "macglue.h" #include "pycfbridge.h" /* ---------------------------------------- */ /* CoreFoundation objects to Python objects */ /* ---------------------------------------- */ PyObject * PyCF_CF2Python(CFTypeRef src) { CFTypeID typeid; typeid = CFGetTypeID(src); if (typeid == CFArrayGetTypeID()) return PyCF_CF2Python_sequence((CFArrayRef)src); if (typeid == CFDictionaryGetTypeID()) return PyCF_CF2Python_mapping((CFDictionaryRef)src); return PyCF_CF2Python_simple(src); } PyObject * PyCF_CF2Python_sequence(CFArrayRef src) { PyErr_SetString(PyExc_SystemError, "Not yet implemented"); return NULL; } PyObject * PyCF_CF2Python_mapping(CFTypeRef src) { PyErr_SetString(PyExc_SystemError, "Not yet implemented"); return NULL; } PyObject * PyCF_CF2Python_simple(CFTypeRef src) { CFTypeID typeid; typeid = CFGetTypeID(src); if (typeid == CFStringGetTypeID()) return PyCF_CF2Python_string((CFStringRef)src); PyMac_Error(resNotFound); return NULL; } /* Unsure - Return unicode or 8 bit strings? */ PyObject * PyCF_CF2Python_string(CFStringRef src) { int size = CFStringGetLength(src)+1; Py_UNICODE *data = malloc(size*sizeof(Py_UNICODE)); CFRange range; PyObject *rv; range.location = 0; range.length = size; if( data == NULL ) return PyErr_NoMemory(); CFStringGetCharacters(src, range, data); rv = (PyObject *)PyUnicode_FromUnicode(data, size); free(data); return rv; } /* ---------------------------------------- */ /* Python objects to CoreFoundation objects */ /* ---------------------------------------- */ int PyCF_Python2CF(PyObject *src, CFTypeRef *dst) { if (PySequence_Check(src)) return PyCF_Python2CF_sequence(src, (CFArrayRef *)dst); if (PyMapping_Check(src)) return PyCF_Python2CF_mapping(src, (CFDictionaryRef *)dst); return PyCF_Python2CF_simple(src, dst); } int PyCF_Python2CF_sequence(PyObject *src, CFArrayRef *dst) { CFArrayRef rv = NULL; CFTypeRef item_cf = NULL; PyObject *item_py = NULL; int size, i; size = PySequence_Size(src); rv = CFArrayCreateMutable((CFAllocatorRef)NULL, size, &kCFTypeArrayCallBacks); if (rv == NULL) { PyMac_Error(resNotFound); goto err; } for( i=0; iob_type->tp_name); return 0; } int PyCF_Python2CF_string(PyObject *src, CFStringRef *dst) { char *chars; CFIndex size; UniChar *unichars; if (PyString_Check(src)) { if ((chars = PyString_AsString(src)) == NULL ) goto err; *dst = CFStringCreateWithCString((CFAllocatorRef)NULL, chars, 0); return 1; } if (PyUnicode_Check(src)) { /* We use the CF types here, if Python was configured differently that will give an error */ size = PyUnicode_GetSize(src); if ((unichars = PyUnicode_AsUnicode(src)) == NULL ) goto err; *dst = CFStringCreateWithCharacters((CFAllocatorRef)NULL, unichars, size); return 1; } err: PyErr_Format(PyExc_TypeError, "Cannot convert %.500s objects to CF", src->ob_type->tp_name); return 0; } --- NEW FILE: pycfbridge.h --- extern PyObject *PyCF_CF2Python(CFTypeRef src); extern PyObject *PyCF_CF2Python_sequence(CFArrayRef src); extern PyObject *PyCF_CF2Python_mapping(CFTypeRef src); extern PyObject *PyCF_CF2Python_simple(CFTypeRef src); extern PyObject *PyCF_CF2Python_string(CFStringRef src); extern int PyCF_Python2CF(PyObject *src, CFTypeRef *dst); extern int PyCF_Python2CF_sequence(PyObject *src, CFArrayRef *dst); extern int PyCF_Python2CF_mapping(PyObject *src, CFDictionaryRef *dst); extern int PyCF_Python2CF_simple(PyObject *src, CFTypeRef *dst); extern int PyCF_Python2CF_string(PyObject *src, CFStringRef *dst); From akuchling@sourceforge.net Mon May 6 14:57:21 2002 From: akuchling@sourceforge.net (akuchling@sourceforge.net) Date: Mon, 06 May 2002 06:57:21 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils util.py,1.66,1.67 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv21764 Modified Files: util.py Log Message: Prevent convert_path from crashing if the path is an empty string. Bugfix candidate. Index: util.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/util.py,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** util.py 31 Jan 2002 18:55:48 -0000 1.66 --- util.py 6 May 2002 13:57:19 -0000 1.67 *************** *** 85,91 **** if os.sep == '/': return pathname ! if pathname[0] == '/': raise ValueError, "path '%s' cannot be absolute" % pathname ! if pathname[-1] == '/': raise ValueError, "path '%s' cannot end with '/'" % pathname --- 85,91 ---- if os.sep == '/': return pathname ! if pathname and pathname[0] == '/': raise ValueError, "path '%s' cannot be absolute" % pathname ! if pathname and pathname[-1] == '/': raise ValueError, "path '%s' cannot end with '/'" % pathname From fdrake@sourceforge.net Mon May 6 17:02:45 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Mon, 06 May 2002 09:02:45 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libxreadlines.tex,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv32655/lib Modified Files: libxreadlines.tex Log Message: Add a note explaining the interaction between unbuffered input and xreadlines.xreadlines(). This closes SF patch #552804. Index: libxreadlines.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libxreadlines.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** libxreadlines.tex 12 Jan 2001 22:57:32 -0000 1.2 --- libxreadlines.tex 6 May 2002 16:02:42 -0000 1.3 *************** *** 39,43 **** Return a new xreadlines object which will iterate over the contents of \var{fileobj}. \var{fileobj} must have a \method{readlines()} ! method that supports the \var{sizehint} parameter. \end{funcdesc} --- 39,45 ---- Return a new xreadlines object which will iterate over the contents of \var{fileobj}. \var{fileobj} must have a \method{readlines()} ! method that supports the \var{sizehint} parameter. \note{Because ! the \method{readlines()} method buffers data, this effectively ! ignores the effects of setting the file object as unbuffered.} \end{funcdesc} From fdrake@sourceforge.net Mon May 6 17:03:03 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Mon, 06 May 2002 09:03:03 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libxreadlines.tex,1.2,1.2.22.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv32732/lib Modified Files: Tag: release22-maint libxreadlines.tex Log Message: Add a note explaining the interaction between unbuffered input and xreadlines.xreadlines(). This closes SF patch #552804. Index: libxreadlines.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libxreadlines.tex,v retrieving revision 1.2 retrieving revision 1.2.22.1 diff -C2 -d -r1.2 -r1.2.22.1 *** libxreadlines.tex 12 Jan 2001 22:57:32 -0000 1.2 --- libxreadlines.tex 6 May 2002 16:03:00 -0000 1.2.22.1 *************** *** 39,43 **** Return a new xreadlines object which will iterate over the contents of \var{fileobj}. \var{fileobj} must have a \method{readlines()} ! method that supports the \var{sizehint} parameter. \end{funcdesc} --- 39,45 ---- Return a new xreadlines object which will iterate over the contents of \var{fileobj}. \var{fileobj} must have a \method{readlines()} ! method that supports the \var{sizehint} parameter. \note{Because ! the \method{readlines()} method buffers data, this effectively ! ignores the effects of setting the file object as unbuffered.} \end{funcdesc} From fdrake@sourceforge.net Mon May 6 17:05:03 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Mon, 06 May 2002 09:05:03 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libxreadlines.tex,1.2,1.2.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv877/lib Modified Files: Tag: release21-maint libxreadlines.tex Log Message: Add a note explaining the interaction between unbuffered input and xreadlines.xreadlines(). This closes SF patch #552804. Index: libxreadlines.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libxreadlines.tex,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** libxreadlines.tex 12 Jan 2001 22:57:32 -0000 1.2 --- libxreadlines.tex 6 May 2002 16:05:01 -0000 1.2.4.1 *************** *** 39,43 **** Return a new xreadlines object which will iterate over the contents of \var{fileobj}. \var{fileobj} must have a \method{readlines()} ! method that supports the \var{sizehint} parameter. \end{funcdesc} --- 39,46 ---- Return a new xreadlines object which will iterate over the contents of \var{fileobj}. \var{fileobj} must have a \method{readlines()} ! method that supports the \var{sizehint} parameter. \strong{Note:} ! Because the \method{readlines()} method buffers data, this ! effectively ignores the effects of setting the file object as ! unbuffered. \end{funcdesc} From akuchling@sourceforge.net Mon May 6 18:46:42 2002 From: akuchling@sourceforge.net (akuchling@sourceforge.net) Date: Mon, 06 May 2002 10:46:42 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv32142 Modified Files: whatsnew23.tex Log Message: Write two sections, and write some partial text for some other sections Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** whatsnew23.tex 2 May 2002 21:15:16 -0000 1.10 --- whatsnew23.tex 6 May 2002 17:46:39 -0000 1.11 *************** *** 1,4 **** \documentclass{howto} - % $Id$ --- 1,3 ---- *************** *** 15,19 **** {\large This article is a draft, and is currently up to date for some ! random version of the CVS tree around March 26 2002. Please send any additions, comments or errata to the author.} --- 14,18 ---- {\large This article is a draft, and is currently up to date for some ! random version of the CVS tree around May 26 2002. Please send any additions, comments or errata to the author.} *************** *** 35,38 **** --- 34,38 ---- %====================================================================== \section{PEP 255: Simple Generators} + \label{section-generators} In Python 2.2, generators were added as an optional feature, to be *************** *** 185,194 **** \section{PEP 278: Universal Newline Support} ! XXX write this section ! %Highlights: import and friends will understand any of \r, \n and \r\n ! %as end of line. Python file input will do the same if you use mode 'U'. ! %Everything can be disabled by configuring with --without-universal-newlines. \begin{seealso} --- 185,212 ---- \section{PEP 278: Universal Newline Support} ! The three major operating systems used today are Microsoft Windows, ! Apple's Macintosh OS, and the various Unix derivatives. A minor ! irritation is that these three platforms all use different characters ! to mark the ends of lines in text files. Unix uses character 10, the ! ASCII linefeed, MacOS uses character 13, the ASCII carriage return, ! and Windows uses a two-character sequence of carriage return plus a ! newline. ! Python's file objects can now support end of line conventions other ! than the one followed by the platform on which Python is running. ! Opening a file with the mode \samp{U} or \samp{rU} will open a file ! for reading in universal newline mode. All three line ending ! conventions will be translated to a \samp{\e n} in the strings ! returned by the various file methods such as \method{read()} and ! \method{readline()}. ! ! Universal newline support is also used when importing modules and when ! executing a file with the \function{execfile()} function. This means ! that Python modules can be shared between all three operating systems ! without needing to convert the line-endings. + This feature can be disabled at compile-time by specifying the + \longprogramopt{without-universal-newlines} when running Python's + configure script. \begin{seealso} *************** *** 201,206 **** %====================================================================== \section{PEP 285: The \class{bool} Type} ! XXX write this section \begin{seealso} --- 219,288 ---- %====================================================================== \section{PEP 285: The \class{bool} Type} + \label{section-bool} ! A Boolean type was added to Python 2.3. Two new constants were added ! to the \module{__builtin__} module, \constant{True} and ! \constant{False}. The type object for this new type is named ! \class{bool}; the constructor for it takes any Python value and ! converts it to \constant{True} or \constant{False}. ! ! \begin{verbatim} ! >>> bool(1) ! True ! >>> bool(0) ! False ! >>> bool([]) ! False ! >>> bool( (1,) ) ! True ! \end{verbatim} ! ! Most of the standard library modules and built-in functions have been ! changed to return Booleans. ! ! \begin{verbatim} ! >>> o = [] ! >>> hasattr(o, 'append') ! True ! >>> isinstance(o, list) ! True ! >>> isinstance(o, tuple) ! False ! \end{verbatim} ! ! Python's Booleans were added with the primary goal of making code ! clearer. For example, if you're reading a function and encounter the ! statement \code{return 1}, you might wonder whether the \samp{1} ! represents a truth value, or whether it's an index, or whether it's a ! coefficient that multiplies some other quantity. If the statement is ! \code{return True}, however, the meaning of the return value is quite ! clearly a truth value. ! ! Python's Booleans were not added for the sake of strict type-checking. ! A very strict language such as Pascal ! % XXX is Pascal the right example here? ! would also prevent you performing arithmetic with Booleans, and would ! require that the expression in an \keyword{if} statement always ! evaluate to a Boolean. Python is not this strict, and it never will ! be. (\pep{285} explicitly says this.) So you can still use any ! expression in an \keyword{if}, even ones that evaluate to a list or ! tuple or some random object, and the Boolean type is a subclass of the ! \class{int} class, so arithmetic using a Boolean still works. ! ! \begin{verbatim} ! >>> True + 1 ! 2 ! >>> False + 1 ! 1 ! >>> False * 75 ! 0 ! >>> True * 75 ! 75 ! \end{verbatim} ! ! To sum up \constant{True} and \constant{False} in a sentence: they're ! alternative ways to spell the integer values 1 and 0, with the single ! difference that \function{str()} and \function{repr()} return the ! strings \samp{True} and \samp{False} instead of \samp{1} and \samp{0}. \begin{seealso} *************** *** 214,238 **** \section{New and Improved Modules} ! arraymodule.c: - add Py_UNICODE arrays ! - support +=, *= distutils: command/bdist_packager, support for Solaris pkgtool and HP-UX swinstall - Return enhanced tuples in grpmodule ! posixmodule: killpg, mknod, fchdir, ! Expat is now included with the Python source ! Readline: Add get_history_item, get_current_history_length, and ! redisplay functions. ! Add optional arg to string methods strip(), lstrip(), rstrip(). ! The optional arg specifies characters to delete. ! New method: string.zfill() - Add dict method pop(). New enumerate() built-in. --- 296,406 ---- \section{New and Improved Modules} ! As usual, Python's standard modules had a number of enhancements and ! bug fixes. Here's a partial list; consult the \file{Misc/NEWS} file ! in the source tree, or the CVS logs, for a more complete list. ! ! \begin{itemize} ! ! \item One minor but far-reaching change is that the names of extension ! types defined by the modules included with Python now contain the ! module and a \samp{.} in front of the type name. For example, in ! Python 2.2, if you created a socket and printed its ! \member{__class__}, you'd get this output: ! ! \begin{verbatim} ! >>> s = socket.socket() ! >>> s.__class__ ! ! \end{verbatim} ! ! In 2.3, you get this: ! \begin{verbatim} ! >>> s.__class__ ! ! \end{verbatim} ! ! \item The \method{strip()}, \method{lstrip()}, and \method{rstrip()} ! string methods now have an optional argument for specifying the ! characters to strip. The default is still to remove all whitespace ! characters: ! ! \begin{verbatim} ! >>> ' abc '.strip() ! 'abc' ! >>> '><><><>'.strip('<>') ! 'abc' ! >>> '><><><>\n'.strip('<>') ! 'abc<><><>\n' ! >>> u'\u4000\u4001abc\u4000'.strip(u'\u4000') ! u'\u4001abc' ! >>> ! \end{verbatim} ! ! \item Another new string method is \method{zfill()}, originally a ! function in the \module{string} module. \method{zfill()} pads a ! numeric string with zeros on the left until it's the specified width. ! Note that the \code{\%} operator is still more flexible and powerful ! than \method{zfill()}. ! ! \begin{verbatim} ! >>> '45'.zfill(4) ! '0045' ! >>> '12345'.zfill(4) ! '12345' ! >>> 'goofy'.zfill(4) ! '0goofy' ! \end{verbatim} ! ! \item Dictionaries have a new method, method{pop(\var{key})}, that ! returns the value corresponding to \var{key} and removes that ! key/value pair from the dictionary. \method{pop()} will raise a ! \exception{KeyError} if the requsted key isn't present in the ! dictionary: ! ! \begin{verbatim} ! >>> d = {1:2} ! >>> d ! {1: 2} ! >>> d.pop(4) ! Traceback (most recent call last): ! File ``'', line 1, in ? ! KeyError: 4 ! >>> d.pop(1) ! 2 ! >>> d.pop(1) ! Traceback (most recent call last): ! File ``'', line 1, in ? ! KeyError: pop(): dictionary is empty ! >>> d ! {} ! >>> ! \end{verbatim} distutils: command/bdist_packager, support for Solaris pkgtool and HP-UX swinstall ! \item Two new functions, \function{killpg()} and \function{mknod()}, ! were added to the \module{posix} module that underlies the \module{os} ! module. ! \item (XXX write this) arraymodule.c: - add Py_UNICODE arrays ! - support +=, *= ! \item The \module{grp} module now returns enhanced tuples: ! \begin{verbatim} ! >>> import grp ! >>> g = grp.getgrnam('amk') ! >>> g.gr_name, g.gr_gid ! ('amk', 500) ! \end{verbatim} ! \item The \module{readline} module also gained a number of new ! functions: \function{get_history_item()}, ! \function{get_current_history_length()}, and \function{redisplay()}. ! ! \end{itemize} New enumerate() built-in. *************** *** 241,271 **** \section{Interpreter Changes and Fixes} ! file object can now be subtyped (did this not work before?) ! yield is now always available ! This adds the module name and a dot in front of the type name in every ! type object initializer, except for built-in types (and those that ! already had this). Note that it touches lots of Mac modules -- I have ! no way to test these but the changes look right. Apologies if they're ! not. This also touches the weakref docs, which contains a sample type ! object initializer. It also touches the mmap test output, because the ! mmap type's repr is included in that output. It touches object.h to ! put the correct description in a comment. - File objects: Grow the string buffer at a mildly exponential rate for - the getc version of get_line. This makes test_bufio finish in 1.7 - seconds instead of 57 seconds on my machine (with Py_DEBUG defined). %====================================================================== \section{Other Changes and Fixes} The tools used to build the documentation now work under Cygwin as well as \UNIX. % ====================================================================== ! \section{C Interface Changes} ! Patch \#527027: Allow building python as shared library with --enable-shared --- 409,451 ---- \section{Interpreter Changes and Fixes} ! Here are the changes that Python 2.3 makes to the core language. ! \begin{itemize} ! \item The \keyword{yield} statement is now always a keyword, as ! described in section~\ref{section-generators}. ! \item Two new constants, \constant{True} and \constant{False} were ! added along with the built-in \class{bool} type, as described in ! section~\ref{section-bool}. ! ! \item The \class{file} type can now be subtyped. (XXX did this not work ! before? Thought I used it in an example in the 2.2 What's New document...) ! ! \item File objects also manage their internal string buffer ! differently by increasing it exponentially when needed. ! This results in the benchmark tests in \file{Lib/test/test_bufio.py} ! speeding up from 57 seconds to 1.7 seconds, according to one ! measurement. ! ! \end{itemize} %====================================================================== \section{Other Changes and Fixes} + XXX write this + The tools used to build the documentation now work under Cygwin as well as \UNIX. + % ====================================================================== ! \section{Build and C API Changes} ! XXX write this ! ! \begin{itemize} ! ! \item Patch \#527027: Allow building python as shared library with --enable-shared *************** *** 278,281 **** --- 458,465 ---- PyArg_NoArgs macro is now deprecated + \item The source code for the Expat XML parser is now included with + the Python source, so the \module{pyexpat} module is no longer + dependent on having a system library containing Expat. + === Introduce two new flag bits that can be set in a PyMethodDef method *************** *** 298,302 **** === ! Ports: OS/2 EMX port --- 482,490 ---- === ! \end{itemize} ! ! \subsection{Port-Specific Changes} ! ! XXX write this OS/2 EMX port *************** *** 320,324 **** \end{document} - - - --- 508,509 ---- From jackjansen@sourceforge.net Tue May 7 21:16:22 2002 From: jackjansen@sourceforge.net (jackjansen@sourceforge.net) Date: Tue, 07 May 2002 13:16:22 -0700 Subject: [Python-checkins] python/dist/src/Mac/Lib/lib-scriptpackages/Finder Standard_Suite.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib/lib-scriptpackages/Finder In directory usw-pr-cvs1:/tmp/cvs-serv7923/Python/Mac/Lib/lib-scriptpackages/Finder Modified Files: Standard_Suite.py Log Message: Fixed a mistake on my part when regenerating: removed a bogus import of Applscript_Suite. Bugfix candidate (I'll move it over myself). Index: Standard_Suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Lib/lib-scriptpackages/Finder/Standard_Suite.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Standard_Suite.py 23 Apr 2002 21:07:23 -0000 1.3 --- Standard_Suite.py 7 May 2002 20:16:20 -0000 1.4 *************** *** 317,322 **** return _arguments['----'] - import AppleScript_Suite - import AppleScript_Suite _Enum_list = None # XXXX enum list not found!! _Enum_bool = None # XXXX enum bool not found!! --- 317,320 ---- From jackjansen@sourceforge.net Tue May 7 21:21:52 2002 From: jackjansen@sourceforge.net (jackjansen@sourceforge.net) Date: Tue, 07 May 2002 13:21:52 -0700 Subject: [Python-checkins] python/dist/src/Mac/Lib/lib-scriptpackages/Finder Standard_Suite.py,1.2.20.1,1.2.20.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib/lib-scriptpackages/Finder In directory usw-pr-cvs1:/tmp/cvs-serv9580 Modified Files: Tag: release22-maint Standard_Suite.py Log Message: Backport of 1.4: Fixed a mistake on my part when regenerating: removed a bogus import of ApplscriBugfix candidate (I'll move it over myself). Index: Standard_Suite.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Lib/lib-scriptpackages/Finder/Standard_Suite.py,v retrieving revision 1.2.20.1 retrieving revision 1.2.20.2 diff -C2 -d -r1.2.20.1 -r1.2.20.2 *** Standard_Suite.py 24 Apr 2002 09:21:47 -0000 1.2.20.1 --- Standard_Suite.py 7 May 2002 20:21:50 -0000 1.2.20.2 *************** *** 317,322 **** return _arguments['----'] - import AppleScript_Suite - import AppleScript_Suite _Enum_list = None # XXXX enum list not found!! _Enum_bool = None # XXXX enum bool not found!! --- 317,320 ---- From akuchling@sourceforge.net Tue May 7 21:58:05 2002 From: akuchling@sourceforge.net (akuchling@sourceforge.net) Date: Tue, 07 May 2002 13:58:05 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.402,1.403 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv22444 Modified Files: NEWS Log Message: Fix typos Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.402 retrieving revision 1.403 diff -C2 -d -r1.402 -r1.403 *** NEWS 5 May 2002 20:40:00 -0000 1.402 --- NEWS 7 May 2002 20:58:03 -0000 1.403 *************** *** 44,48 **** names for its two values, True and False. Comparisons and sundry other operations that return a truth value have been changed to ! return a bool instead. Read PEP 285 for an explanantion of why this is backward compatible. --- 44,48 ---- names for its two values, True and False. Comparisons and sundry other operations that return a truth value have been changed to ! return a bool instead. Read PEP 285 for an explanation of why this is backward compatible. *************** *** 71,77 **** a ValueError when the xreadlines.next() method was called. ! - posix.killpg has been added where available. ! ! - sys.exit() inadvertantly allowed more than one argument. An exception will now be raised if more than one argument is used. --- 71,75 ---- a ValueError when the xreadlines.next() method was called. ! - sys.exit() inadvertently allowed more than one argument. An exception will now be raised if more than one argument is used. *************** *** 82,86 **** written to disk. ! - posix.mknod was added. - The locale module now exposes the C library's gettext interface. --- 80,84 ---- written to disk. ! - posix.killpg and posix.mknod have been added where available. - The locale module now exposes the C library's gettext interface. *************** *** 143,147 **** - compileall now supports quiet operation. ! - The BaseHTTPServer implements now optionally HTTP/1.1 persistent connections. --- 141,145 ---- - compileall now supports quiet operation. ! - The BaseHTTPServer now implements optional HTTP/1.1 persistent connections. *************** *** 222,226 **** PyCore_* family of APIs have been removed. ! - The "u#" parser marker will now pass through Unicode object as-is without going through the buffer API. --- 220,224 ---- PyCore_* family of APIs have been removed. ! - The "u#" parser marker will now pass through Unicode objects as-is without going through the buffer API. *************** *** 269,273 **** - New tempfile.TemporaryFile implementation for Windows: this doesn't ! need a TemproraryFileWrapper wrapper anymore, and should be immune to a nasty problem: before 2.3, if you got a temp file on Windows, it got wrapped in an object whose close() method first closed the --- 267,271 ---- - New tempfile.TemporaryFile implementation for Windows: this doesn't ! need a TemporaryFileWrapper wrapper anymore, and should be immune to a nasty problem: before 2.3, if you got a temp file on Windows, it got wrapped in an object whose close() method first closed the *************** *** 330,334 **** - test suite: the pickle and cPickle tests were not executing any code ! when run from the standard regresssion test. Tools/Demos --- 328,332 ---- - test suite: the pickle and cPickle tests were not executing any code ! when run from the standard regression test. Tools/Demos *************** *** 513,517 **** The MRO (method resolution order) for each base class is respected according to its kind, but the MRO for the derived class is computed ! using new-style MRO rules if any base clase is a new-style class. This needs to be documented. --- 511,515 ---- The MRO (method resolution order) for each base class is respected according to its kind, but the MRO for the derived class is computed ! using new-style MRO rules if any base class is a new-style class. This needs to be documented. *************** *** 551,555 **** copy-on-write memory mappings. This was previously possible only on Unix. A new keyword argument was required to support this in a ! uniform way because the mmap() signuatures had diverged across platforms. Thanks to Jay T Miller for repairing this! --- 549,553 ---- copy-on-write memory mappings. This was previously possible only on Unix. A new keyword argument was required to support this in a ! uniform way because the mmap() signatures had diverged across platforms. Thanks to Jay T Miller for repairing this! *************** *** 917,921 **** - property() now takes 4 keyword arguments: fget, fset, fdel and doc. ! These map to readonly attributes 'fget', 'fset', 'fdel', and '__doc__' in the constructed property object. fget, fset and fdel weren't discoverable from Python in 2.2a3. __doc__ is new, and allows to --- 915,919 ---- - property() now takes 4 keyword arguments: fget, fset, fdel and doc. ! These map to read-only attributes 'fget', 'fset', 'fdel', and '__doc__' in the constructed property object. fget, fset and fdel weren't discoverable from Python in 2.2a3. __doc__ is new, and allows to *************** *** 967,971 **** operation was handled by the builtin type), could return that instance instead a value of the base type. For example, if s was of ! a str sublass type, s[:] returned s as-is. Now it returns a str with the same value as s. --- 965,969 ---- operation was handled by the builtin type), could return that instance instead a value of the base type. For example, if s was of ! a str subclass type, s[:] returned s as-is. Now it returns a str with the same value as s. From akuchling@sourceforge.net Tue May 7 22:01:19 2002 From: akuchling@sourceforge.net (akuchling@sourceforge.net) Date: Tue, 07 May 2002 14:01:19 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv23617 Modified Files: whatsnew23.tex Log Message: More filling out Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** whatsnew23.tex 6 May 2002 17:46:39 -0000 1.11 --- whatsnew23.tex 7 May 2002 21:01:16 -0000 1.12 *************** *** 2,5 **** --- 2,8 ---- % $Id$ + % TODO: + % Go through and get the contributor's name for all the various changes + \title{What's New in Python 2.3} \release{0.01} *************** *** 33,38 **** %====================================================================== ! \section{PEP 255: Simple Generators} ! \label{section-generators} In Python 2.2, generators were added as an optional feature, to be --- 36,40 ---- %====================================================================== ! \section{PEP 255: Simple Generators\label{section-generators}} In Python 2.2, generators were added as an optional feature, to be *************** *** 44,56 **** it when 2.2 came out, you can skip the rest of this section. ! Generators are a new feature that interacts with the iterators ! introduced in Python 2.2. ! ! You're doubtless familiar with how function calls work in Python or ! C. When you call a function, it gets a private namespace where its local variables are created. When the function reaches a \keyword{return} statement, the local variables are destroyed and the resulting value is returned to the caller. A later call to the same function will get ! a fresh new set of local variables. But, what if the local variables weren't thrown away on exiting a function? What if you could later resume the function where it left off? This is what generators --- 46,55 ---- it when 2.2 came out, you can skip the rest of this section. ! You're doubtless familiar with how function calls work in Python or C. ! When you call a function, it gets a private namespace where its local variables are created. When the function reaches a \keyword{return} statement, the local variables are destroyed and the resulting value is returned to the caller. A later call to the same function will get ! a fresh new set of local variables. But, what if the local variables weren't thrown away on exiting a function? What if you could later resume the function where it left off? This is what generators *************** *** 186,195 **** The three major operating systems used today are Microsoft Windows, ! Apple's Macintosh OS, and the various Unix derivatives. A minor irritation is that these three platforms all use different characters ! to mark the ends of lines in text files. Unix uses character 10, the ! ASCII linefeed, MacOS uses character 13, the ASCII carriage return, ! and Windows uses a two-character sequence of carriage return plus a ! newline. Python's file objects can now support end of line conventions other --- 185,194 ---- The three major operating systems used today are Microsoft Windows, ! Apple's Macintosh OS, and the various \UNIX\ derivatives. A minor irritation is that these three platforms all use different characters ! to mark the ends of lines in text files. \UNIX\ uses character 10, ! the ASCII linefeed, while MacOS uses character 13, the ASCII carriage ! return, and Windows uses a two-character sequence of a carriage return ! plus a newline. Python's file objects can now support end of line conventions other *************** *** 206,212 **** without needing to convert the line-endings. ! This feature can be disabled at compile-time by specifying the \longprogramopt{without-universal-newlines} when running Python's ! configure script. \begin{seealso} --- 205,211 ---- without needing to convert the line-endings. ! This feature can be disabled at compile-time by specifying \longprogramopt{without-universal-newlines} when running Python's ! \file{configure} script. \begin{seealso} *************** *** 218,223 **** %====================================================================== ! \section{PEP 285: The \class{bool} Type} ! \label{section-bool} A Boolean type was added to Python 2.3. Two new constants were added --- 217,222 ---- %====================================================================== ! \section{PEP 285: The \class{bool} Type\label{section-bool}} ! A Boolean type was added to Python 2.3. Two new constants were added *************** *** 242,251 **** \begin{verbatim} ! >>> o = [] ! >>> hasattr(o, 'append') True ! >>> isinstance(o, list) True ! >>> isinstance(o, tuple) False \end{verbatim} --- 241,250 ---- \begin{verbatim} ! >>> obj = [] ! >>> hasattr(obj, 'append') True ! >>> isinstance(obj, list) True ! >>> isinstance(obj, tuple) False \end{verbatim} *************** *** 294,297 **** --- 293,399 ---- %====================================================================== + \section{Other Language Changes} + + Here are the changes that Python 2.3 makes to the core language. + + \begin{itemize} + \item The \keyword{yield} statement is now always a keyword, as + described in section~\ref{section-generators}. + + \item Two new constants, \constant{True} and \constant{False} were + added along with the built-in \class{bool} type, as described in + section~\ref{section-bool}. + + \item A new built-in function, \function{enumerate()}, will make + certain loops a bit clearer. \code{enumerate(thing)}, where + \var{thing} is either an iterator or a sequence, returns a iterator + that will return \code{(0, \var{thing[0]})}, \code{(1, + \var{thing[1]})}, \code{(2, \var{thing[2]})}, and so forth. Fairly + often you'll see code to change every element of a list that looks like this: + + \begin{verbatim} + for i in range(len(L)): + item = L[i] + # ... compute some result based on item ... + L[i] = result + \end{verbatim} + + This can be rewritten using \function{enumerate()} as: + + \begin{verbatim} + for i, item in enumerate(L): + # ... compute some result based on item ... + L[i] = result + \end{verbatim} + + \end{itemize} + + + %====================================================================== + \section{Specialized Object Allocator (pymalloc)\label{section-pymalloc}} + + An experimental feature added to Python 2.1 was a specialized object + allocator called pymalloc, written by Vladimir Marangozov. Pymalloc + was intended to be faster than the system \function{malloc()} and have + less memory overhead. The allocator uses C's \function{malloc()} + function to get large pools of memory, and then fulfills smaller + memory requests from these pools. + + In 2.1 and 2.2, pymalloc was an experimental feature and wasn't + enabled by default; you had to explicitly turn it on by providing the + \longprogramopt{with-pymalloc} option to the \program{configure} + script. In 2.3, pymalloc has had further enhancements and is now + enabled by default; you'll have to supply + \longprogramopt{without-pymalloc} to disable it. + + This change is transparent to code written in Python; however, + pymalloc may expose bugs in C extensions. Authors of C extension + modules should test their code with the object allocator enabled, + because some incorrect code may cause core dumps at runtime. There + are a bunch of memory allocation functions in Python's C API that have + previously been just aliases for the C library's \function{malloc()} + and \function{free()}, meaning that if you accidentally called + mismatched functions, the error wouldn't be noticeable. When the + object allocator is enabled, these functions aren't aliases of + \function{malloc()} and \function{free()} any more, and calling the + wrong function to free memory will get you a core dump. For example, + if memory was allocated using \function{PyMem_New()}, it has to be + freed using \function{PyMem_Del()}, not \function{free()}. A few + modules included with Python fell afoul of this and had to be fixed; + doubtless there are more third-party modules that will have the same + problem. + + As part of this change, the confusing multiple interfaces for + allocating memory have been consolidated down into two APIs. + Memory allocated with one API must not be freed with the other API. + + \begin{itemize} + \item To allocate and free an undistinguished chunk of memory, use + \cfunction{PyMem_Malloc()}, \cfunction{PyMem_Realloc()}, + \cfunction{PyMem_Free()}, and the other \cfunction{PyMem_*} + functions. + + \item To allocate and free Python objects, + use \cfunction{PyObject_New()}, \cfunction{PyObject_NewVar()}, and + \cfunction{PyObject_Del()}. + \end{itemize} + + Thanks to lots of work by Tim Peters, pymalloc in 2.3 also provides + debugging features to catch memory overwrites and doubled frees in + both extension modules and in the interpreter itself. To enable this + support, turn on the Python interpreter's debugging code by running + \program{configure} with \longprogramopt{with-pydebug}. + + \begin{seealso} + + \seeurl{XXX} + {For the full details of the pymalloc implementation, see + the comments at the top of the file \file{Objects/obmalloc.c} in the + Python source code. The above link points to the file within the + SourceForge CVS browser.} + + \end{seealso} + + %====================================================================== \section{New and Improved Modules} *************** *** 348,352 **** >>> '12345'.zfill(4) '12345' ! >>> 'goofy'.zfill(4) '0goofy' \end{verbatim} --- 450,454 ---- >>> '12345'.zfill(4) '12345' ! >>> 'goofy'.zfill(6) '0goofy' \end{verbatim} *************** *** 377,390 **** \end{verbatim} - distutils: command/bdist_packager, support for Solaris pkgtool - and HP-UX swinstall - - \item Two new functions, \function{killpg()} and \function{mknod()}, were added to the \module{posix} module that underlies the \module{os} module. ! \item (XXX write this) arraymodule.c: - add Py_UNICODE arrays ! - support +=, *= \item The \module{grp} module now returns enhanced tuples: --- 479,496 ---- \end{verbatim} \item Two new functions, \function{killpg()} and \function{mknod()}, were added to the \module{posix} module that underlies the \module{os} module. ! \item Two new binary packagers were added to the Distutils. ! \code{bdist_pkgtool} builds \file{.pkg} files to use with Solaris ! \program{pkgtool}, and \code{bdist_sdux} builds \program{swinstall} ! packages for use on HP-UX. (Contributed by Mark Alexander.) ! ! \item The \module{array} module now supports arrays of Unicode ! characters using the \samp{u} format character. Arrays also ! now support using the \code{+=} assignment operator to add another array's ! contents, and the \code{*=} assignment operator to repeat an array. ! (Contributed by XXX.) \item The \module{grp} module now returns enhanced tuples: *************** *** 404,460 **** - New enumerate() built-in. - - %====================================================================== - \section{Interpreter Changes and Fixes} - - Here are the changes that Python 2.3 makes to the core language. - - \begin{itemize} - \item The \keyword{yield} statement is now always a keyword, as - described in section~\ref{section-generators}. - - \item Two new constants, \constant{True} and \constant{False} were - added along with the built-in \class{bool} type, as described in - section~\ref{section-bool}. - - \item The \class{file} type can now be subtyped. (XXX did this not work - before? Thought I used it in an example in the 2.2 What's New document...) - - \item File objects also manage their internal string buffer - differently by increasing it exponentially when needed. - This results in the benchmark tests in \file{Lib/test/test_bufio.py} - speeding up from 57 seconds to 1.7 seconds, according to one - measurement. - - \end{itemize} - - - %====================================================================== - \section{Other Changes and Fixes} - - XXX write this - - The tools used to build the documentation now work under Cygwin as - well as \UNIX. - - % ====================================================================== \section{Build and C API Changes} ! XXX write this \begin{itemize} ! \item Patch \#527027: Allow building python as shared library with ! --enable-shared ! ! pymalloc is now enabled by default (also mention debug-mode pymalloc) ! ! Memory API reworking -- which functions are deprecated? ! PyObject_DelItemString() added ! PyArg_NoArgs macro is now deprecated \item The source code for the Expat XML parser is now included with --- 510,534 ---- % ====================================================================== \section{Build and C API Changes} ! Changes to Python's build process, and to the C API, include: \begin{itemize} ! \item Python can now optionally be built as a shared library ! (\file{libpython2.3.so}) by supplying \longprogramopt{enable-shared} ! when running Python's \file{configure} script. (Contributed by XXX ! Patch \#527027) ! \item The \cfunction{PyArg_NoArgs()} macro is now deprecated, and code ! that ! uses it should be changed to use \code{PyArg_ParseTuple(args, "")} ! instead. ! \item A new function, \cfunction{PyObject_DelItemString(\var{mapping}, ! char *\var{key})} was added ! as shorthand for ! \code{PyObject_DelItem(\var{mapping}, PyString_New(\var{key})}. \item The source code for the Expat XML parser is now included with *************** *** 462,467 **** dependent on having a system library containing Expat. ! === ! Introduce two new flag bits that can be set in a PyMethodDef method descriptor, as used for the tp_methods slot of a type. These new flag bits are both optional, and mutually exclusive. Most methods will not --- 536,546 ---- dependent on having a system library containing Expat. ! \item File objects now manage their internal string buffer ! differently by increasing it exponentially when needed. ! This results in the benchmark tests in \file{Lib/test/test_bufio.py} ! speeding up from 57 seconds to 1.7 seconds, according to one ! measurement. ! ! \item XXX Introduce two new flag bits that can be set in a PyMethodDef method descriptor, as used for the tp_methods slot of a type. These new flag bits are both optional, and mutually exclusive. Most methods will not *************** *** 480,484 **** these special method types are not meaningful in that case; a ValueError will be raised if these flags are found in that context. - === \end{itemize} --- 559,562 ---- *************** *** 488,494 **** XXX write this ! OS/2 EMX port ! MacOS: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing --- 566,572 ---- XXX write this ! XXX OS/2 EMX port ! XXX MacOS: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing *************** *** 497,509 **** were not Python-compatible. ! Checked in Sean Reifschneider's RPM spec file and patches. %====================================================================== \section{Acknowledgements \label{acks}} The author would like to thank the following people for offering suggestions, corrections and assistance with various drafts of this ! article: Fred~L. Drake, Jr. \end{document} --- 575,599 ---- were not Python-compatible. ! XXX Checked in Sean Reifschneider's RPM spec file and patches. %====================================================================== + \section{Other Changes and Fixes} + + Finally, there are various miscellaneous fixes: + + \begin{itemize} + + \item The tools used to build the documentation now work under Cygwin + as well as \UNIX. + + \end{itemize} + + %====================================================================== \section{Acknowledgements \label{acks}} The author would like to thank the following people for offering suggestions, corrections and assistance with various drafts of this ! article: Fred~L. Drake, Jr., Detlef Lannert. \end{document} From akuchling@sourceforge.net Tue May 7 22:03:48 2002 From: akuchling@sourceforge.net (akuchling@sourceforge.net) Date: Tue, 07 May 2002 14:03:48 -0700 Subject: [Python-checkins] python/dist/src/Doc/inst inst.tex,1.38,1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/inst In directory usw-pr-cvs1:/tmp/cvs-serv24360 Modified Files: inst.tex Log Message: Move 'Tips and Tricks' to be the last section Index: inst.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/inst/inst.tex,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** inst.tex 7 May 2002 21:02:35 -0000 1.38 --- inst.tex 7 May 2002 21:03:45 -0000 1.39 *************** *** 3,7 **** % TODO: - % Move 'Tips and Tricks' to be the last section % Fill in XXX comments --- 3,6 ---- *************** *** 374,603 **** - \section{Building Extensions: Tips and Tricks} - \label{building-ext} - - Whenever possible, the Distutils try to use the configuration - information made available by the Python interpreter used to run the - \file{setup.py} script. For example, the same compiler and linker - flags used to compile Python will also be used for compiling - extensions. Usually this will work well, but in complicated - situations this might be inappropriate. This section discusses how to - override the usual Distutils behaviour. - - \subsection{Tweaking compiler/linker flags} - \label{tweak-flags} - - Compiling a Python extension written in C or \Cpp will sometimes - require specifying custom flags for the compiler and linker in order - to use a particular library or produce a special kind of object code. - This is especially true if the extension hasn't been tested on your - platform, or if you're trying to cross-compile Python. - - In the most general case, the extension author might have foreseen - that compiling the extensions would be complicated, and provided a - \file{Setup} file for you to edit. This will likely only be done if - the module distribution contains many separate extension modules, or - if they often require elaborate sets of compiler flags in order to work. - - A \file{Setup} file, if present, is parsed in order to get a list of - extensions to build. Each line in a \file{Setup} describes a single - module. Lines have the following structure: - - \begin{verbatim} - ... [ ...] [ ...] [ ...] - \end{verbatim} - - Let's examine each of the fields in turn. - - \begin{itemize} - - \item \var{module} is the name of the extension module to be built, - and should be a valid Python identifier. You can't just change this - in order to rename a module (edits to the source code would also be - needed), so this should be left alone. - - \item \var{sourcefile} is anything that's likely to be a source code - file, at least judging by the filename. Filenames ending in .c are - assumed to be written in C, filenames ending in .C, .cc, .c++ are - assumed to be \Cpp, and filenames ending in .m or .mm are assumed to - be in Objective C. - - \item \var{cpparg} is an argument for the C preprocessor, - and is anything starting with -I, -D, -U or -C . - - \item is anything ending in .a or beginning with -l or -L. - \end{itemize} - - If a particular platform requires a special library on your platform, - you can add it by editing the \file{Setup} file and running - \code{python setup.py build}. For example, if the module defined by the line - - \begin{verbatim} - foo foomodule.c - \end{verbatim} - - must be linked with the math library \file{libm.a} on your platform, - simply add \samp{-lm} to the line: - - \begin{verbatim} - foo foomodule.c -lm - \end{verbatim} - - Arbitrary switches intended for the compiler or the linker can be - supplied with the \code{-Xcompiler \var{arg}} and \code{-Xlinker - \var{arg}} options: - - \begin{verbatim} - foo foomodule.c -Xcompiler -o32 -Xlinker -shared -lm - \end{verbatim} - - The next option after \code{-Xcompiler} and \code{-Xlinker} will be - appended to the proper command line, so in the above example the - compiler will be passed the \samp{-o32} option, and the linker will be - passed \samp{-shared}. If a compiler option requires an argument, - you'll have to supply multiple \code{-Xcompiler} options; for example, - to pass \code{-x c++} the \file{Setup} file would have to contain - \code{-Xcompiler -x -Xcompiler c++}. - - Compiler flags can also be supplied through setting the - \envvar{CFLAGS} environment variable. If set, the contents of - \envvar{CFLAGS} will be added to the compiler flags specified in the - \file{Setup} file. - - - \subsection{Using non-Microsoft compilers on Windows \label{non-ms-compilers}} - \sectionauthor{Rene Liebscher}{R.Liebscher@gmx.de} - - \subsubsection{Borland C++} - - This subsection describes the necessary steps to use Distutils with the - Borland \Cpp{} compiler version 5.5. - %Should we mention that users have to create cfg-files for the compiler? - %see also http://community.borland.com/article/0,1410,21205,00.html - - First you have to know that Borland's object file format (OMF) is - different from the format used by the Python version you can download - from the Python or ActiveState Web site. (Python is built with - Microsoft Visual \Cpp, which uses COFF as the object file format.) - For this reason you have to convert Python's library - \file{python20.lib} into the Borland format. You can do this as - follows: - - \begin{verbatim} - coff2omf python20.lib python20_bcpp.lib - \end{verbatim} - - The \file{coff2omf} program comes with the Borland compiler. The file - \file{python20.lib} is in the \file{Libs} directory of your Python - installation. If your extension uses other libraries (zlib,...) you - have to convert them too. - - The converted files have to reside in the same directories as the - normal libraries. - - How does Distutils manage to use these libraries with their changed - names? If the extension needs a library (eg. \file{foo}) Distutils - checks first if it finds a library with suffix \file{_bcpp} - (eg. \file{foo_bcpp.lib}) and then uses this library. In the case it - doesn't find such a special library it uses the default name - (\file{foo.lib}.)\footnote{This also means you could replace all - existing COFF-libraries with OMF-libraries of the same name.} - - To let Distutils compile your extension with Borland \Cpp{} you now have - to type: - - \begin{verbatim} - python setup.py build --compiler=bcpp - \end{verbatim} - - If you want to use the Borland \Cpp{} compiler as the default, you - could specify this in your personal or system-wide configuration file - for Distutils (see section~\ref{config-files}.) - - \begin{seealso} - \seetitle[http://www.borland.com/bcppbuilder/freecompiler/] - {\Cpp{}Builder Compiler} - {Information about the free \Cpp{} compiler from Borland, - including links to the download pages.} - - \seetitle[http://www.cyberus.ca/~g_will/pyExtenDL.shtml] - {Creating Python Extensions Using Borland's Free Compiler} - {Document describing how to use Borland's free command-line C++ - compiler to build Python.} - \end{seealso} - - - \subsubsection{GNU C / Cygwin / MinGW32} - - This section describes the necessary steps to use Distutils with the - GNU C/\Cpp{} compilers in their Cygwin and MinGW32 - distributions.\footnote{Check - \url{http://sources.redhat.com/cygwin/} and - \url{http://www.mingw.org/} for more information} - - \XXX{For a Python which was built with Cygwin, all should work without - any of these following steps.} - - These compilers also require some special libraries. - This task is more complex than for Borland's \Cpp, because there is no - program to convert the library. - % I don't understand what the next line means. --amk - % (inclusive the references on data structures.) - - First you have to create a list of symbols which the Python DLL exports. - (You can find a good program for this task at - \url{http://starship.python.net/crew/kernr/mingw32/Notes.html}, see at - PExports 0.42h there.) - - \begin{verbatim} - pexports python20.dll >python20.def - \end{verbatim} - - Then you can create from these information an import library for gcc. - - \begin{verbatim} - dlltool --dllname python20.dll --def python20.def --output-lib libpython20.a - \end{verbatim} - - The resulting library has to be placed in the same directory as - \file{python20.lib}. (Should be the \file{libs} directory under your - Python installation directory.) - - If your extension uses other libraries (zlib,...) you might - have to convert them too. - The converted files have to reside in the same directories as the normal - libraries do. - - To let Distutils compile your extension with Cygwin you now have to type - - \begin{verbatim} - python setup.py build --compiler=cygwin - \end{verbatim} - - and for Cygwin in no-cygwin mode\footnote{Then you have no - \POSIX{} emulation available, but you also don't need - \file{cygwin1.dll}.} or for MinGW32 type: - - \begin{verbatim} - python setup.py build --compiler=mingw32 - \end{verbatim} - - If you want to use any of these options/compilers as default, you should - consider to write it in your personal or system-wide configuration file - for Distutils (see section~\ref{config-files}.) - - \begin{seealso} - \seetitle[http://www.zope.org/Members/als/tips/win32_mingw_modules] - {Building Python modules on MS Windows platform with MinGW32} - {Information about building the required libraries for the MinGW32 - environment.} - - \seeurl{http://pyopengl.sourceforge.net/ftp/win32-stuff/} - {Converted import libraries in Cygwin/MinGW32 and Borland format, - and a script to create the registry entries needed for Distutils - to locate the built Python.} - \end{seealso} - - \section{Alternate Installation} \label{alt-install} --- 373,376 ---- *************** *** 1059,1062 **** --- 832,1062 ---- See also the ``Reference'' section of the ``Distributing Python Modules'' manual. + + \section{Building Extensions: Tips and Tricks} + \label{building-ext} + + Whenever possible, the Distutils try to use the configuration + information made available by the Python interpreter used to run the + \file{setup.py} script. For example, the same compiler and linker + flags used to compile Python will also be used for compiling + extensions. Usually this will work well, but in complicated + situations this might be inappropriate. This section discusses how to + override the usual Distutils behaviour. + + \subsection{Tweaking compiler/linker flags} + \label{tweak-flags} + + Compiling a Python extension written in C or \Cpp will sometimes + require specifying custom flags for the compiler and linker in order + to use a particular library or produce a special kind of object code. + This is especially true if the extension hasn't been tested on your + platform, or if you're trying to cross-compile Python. + + In the most general case, the extension author might have foreseen + that compiling the extensions would be complicated, and provided a + \file{Setup} file for you to edit. This will likely only be done if + the module distribution contains many separate extension modules, or + if they often require elaborate sets of compiler flags in order to work. + + A \file{Setup} file, if present, is parsed in order to get a list of + extensions to build. Each line in a \file{Setup} describes a single + module. Lines have the following structure: + + \begin{verbatim} + ... [ ...] [ ...] [ ...] + \end{verbatim} + + Let's examine each of the fields in turn. + + \begin{itemize} + + \item \var{module} is the name of the extension module to be built, + and should be a valid Python identifier. You can't just change this + in order to rename a module (edits to the source code would also be + needed), so this should be left alone. + + \item \var{sourcefile} is anything that's likely to be a source code + file, at least judging by the filename. Filenames ending in .c are + assumed to be written in C, filenames ending in .C, .cc, .c++ are + assumed to be \Cpp, and filenames ending in .m or .mm are assumed to + be in Objective C. + + \item \var{cpparg} is an argument for the C preprocessor, + and is anything starting with -I, -D, -U or -C . + + \item is anything ending in .a or beginning with -l or -L. + \end{itemize} + + If a particular platform requires a special library on your platform, + you can add it by editing the \file{Setup} file and running + \code{python setup.py build}. For example, if the module defined by the line + + \begin{verbatim} + foo foomodule.c + \end{verbatim} + + must be linked with the math library \file{libm.a} on your platform, + simply add \samp{-lm} to the line: + + \begin{verbatim} + foo foomodule.c -lm + \end{verbatim} + + Arbitrary switches intended for the compiler or the linker can be + supplied with the \code{-Xcompiler \var{arg}} and \code{-Xlinker + \var{arg}} options: + + \begin{verbatim} + foo foomodule.c -Xcompiler -o32 -Xlinker -shared -lm + \end{verbatim} + + The next option after \code{-Xcompiler} and \code{-Xlinker} will be + appended to the proper command line, so in the above example the + compiler will be passed the \samp{-o32} option, and the linker will be + passed \samp{-shared}. If a compiler option requires an argument, + you'll have to supply multiple \code{-Xcompiler} options; for example, + to pass \code{-x c++} the \file{Setup} file would have to contain + \code{-Xcompiler -x -Xcompiler c++}. + + Compiler flags can also be supplied through setting the + \envvar{CFLAGS} environment variable. If set, the contents of + \envvar{CFLAGS} will be added to the compiler flags specified in the + \file{Setup} file. + + + \subsection{Using non-Microsoft compilers on Windows \label{non-ms-compilers}} + \sectionauthor{Rene Liebscher}{R.Liebscher@gmx.de} + + \subsubsection{Borland C++} + + This subsection describes the necessary steps to use Distutils with the + Borland \Cpp{} compiler version 5.5. + %Should we mention that users have to create cfg-files for the compiler? + %see also http://community.borland.com/article/0,1410,21205,00.html + + First you have to know that Borland's object file format (OMF) is + different from the format used by the Python version you can download + from the Python or ActiveState Web site. (Python is built with + Microsoft Visual \Cpp, which uses COFF as the object file format.) + For this reason you have to convert Python's library + \file{python20.lib} into the Borland format. You can do this as + follows: + + \begin{verbatim} + coff2omf python20.lib python20_bcpp.lib + \end{verbatim} + + The \file{coff2omf} program comes with the Borland compiler. The file + \file{python20.lib} is in the \file{Libs} directory of your Python + installation. If your extension uses other libraries (zlib,...) you + have to convert them too. + + The converted files have to reside in the same directories as the + normal libraries. + + How does Distutils manage to use these libraries with their changed + names? If the extension needs a library (eg. \file{foo}) Distutils + checks first if it finds a library with suffix \file{_bcpp} + (eg. \file{foo_bcpp.lib}) and then uses this library. In the case it + doesn't find such a special library it uses the default name + (\file{foo.lib}.)\footnote{This also means you could replace all + existing COFF-libraries with OMF-libraries of the same name.} + + To let Distutils compile your extension with Borland \Cpp{} you now have + to type: + + \begin{verbatim} + python setup.py build --compiler=bcpp + \end{verbatim} + + If you want to use the Borland \Cpp{} compiler as the default, you + could specify this in your personal or system-wide configuration file + for Distutils (see section~\ref{config-files}.) + + \begin{seealso} + \seetitle[http://www.borland.com/bcppbuilder/freecompiler/] + {\Cpp{}Builder Compiler} + {Information about the free \Cpp{} compiler from Borland, + including links to the download pages.} + + \seetitle[http://www.cyberus.ca/~g_will/pyExtenDL.shtml] + {Creating Python Extensions Using Borland's Free Compiler} + {Document describing how to use Borland's free command-line C++ + compiler to build Python.} + \end{seealso} + + + \subsubsection{GNU C / Cygwin / MinGW32} + + This section describes the necessary steps to use Distutils with the + GNU C/\Cpp{} compilers in their Cygwin and MinGW32 + distributions.\footnote{Check + \url{http://sources.redhat.com/cygwin/} and + \url{http://www.mingw.org/} for more information} + + \XXX{For a Python which was built with Cygwin, all should work without + any of these following steps.} + + These compilers also require some special libraries. + This task is more complex than for Borland's \Cpp, because there is no + program to convert the library. + % I don't understand what the next line means. --amk + % (inclusive the references on data structures.) + + First you have to create a list of symbols which the Python DLL exports. + (You can find a good program for this task at + \url{http://starship.python.net/crew/kernr/mingw32/Notes.html}, see at + PExports 0.42h there.) + + \begin{verbatim} + pexports python20.dll >python20.def + \end{verbatim} + + Then you can create from these information an import library for gcc. + + \begin{verbatim} + dlltool --dllname python20.dll --def python20.def --output-lib libpython20.a + \end{verbatim} + + The resulting library has to be placed in the same directory as + \file{python20.lib}. (Should be the \file{libs} directory under your + Python installation directory.) + + If your extension uses other libraries (zlib,...) you might + have to convert them too. + The converted files have to reside in the same directories as the normal + libraries do. + + To let Distutils compile your extension with Cygwin you now have to type + + \begin{verbatim} + python setup.py build --compiler=cygwin + \end{verbatim} + + and for Cygwin in no-cygwin mode\footnote{Then you have no + \POSIX{} emulation available, but you also don't need + \file{cygwin1.dll}.} or for MinGW32 type: + + \begin{verbatim} + python setup.py build --compiler=mingw32 + \end{verbatim} + + If you want to use any of these options/compilers as default, you should + consider to write it in your personal or system-wide configuration file + for Distutils (see section~\ref{config-files}.) + + \begin{seealso} + \seetitle[http://www.zope.org/Members/als/tips/win32_mingw_modules] + {Building Python modules on MS Windows platform with MinGW32} + {Information about building the required libraries for the MinGW32 + environment.} + + \seeurl{http://pyopengl.sourceforge.net/ftp/win32-stuff/} + {Converted import libraries in Cygwin/MinGW32 and Borland format, + and a script to create the registry entries needed for Distutils + to locate the built Python.} + \end{seealso} + + \end{document} From akuchling@sourceforge.net Tue May 7 22:02:37 2002 From: akuchling@sourceforge.net (akuchling@sourceforge.net) Date: Tue, 07 May 2002 14:02:37 -0700 Subject: [Python-checkins] python/dist/src/Doc/inst inst.tex,1.37,1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/inst In directory usw-pr-cvs1:/tmp/cvs-serv23871 Modified Files: inst.tex Log Message: Add section on Setup file Updates for 2.2 Remove references to Makefile.pre.in build method Index: inst.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/inst/inst.tex,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** inst.tex 6 Dec 2001 16:34:53 -0000 1.37 --- inst.tex 7 May 2002 21:02:35 -0000 1.38 *************** *** 2,5 **** --- 2,9 ---- \usepackage{distutils} + % TODO: + % Move 'Tips and Tricks' to be the last section + % Fill in XXX comments + \title{Installing Python Modules} *************** *** 11,20 **** % other docs on "import site", PYTHONSTARTUP, PYTHONHOME, etc. % - % Also, I need to take into account that most modules out there don't - % (yet) use Distutils: briefly explain the old Makefile.pre.in - % convention (maybe move material from the E&E manual to here?), and - % explain where to copy .py and .so files manually if the distribution - % doesn't provide a mechanism for doing so. - % % Finally, it might be useful to include all the material from my "Care % and Feeding of a Python Installation" talk in here somewhere. Yow! --- 15,18 ---- *************** *** 64,71 **** modules to an existing Python installation. With the introduction of the Python Distribution Utilities (Distutils for short) in Python 2.0, ! this is starting to change. Not everything will change overnight, ! though, so while this document concentrates on installing module ! distributions that use the Distutils, we will also spend some time ! dealing with the old ways. This document is aimed primarily at the people who need to install --- 62,66 ---- modules to an existing Python installation. With the introduction of the Python Distribution Utilities (Distutils for short) in Python 2.0, ! this changed. This document is aimed primarily at the people who need to install *************** *** 89,94 **** installer available for Windows users, an RPM package for users of RPM-based Linux systems (Red Hat, SuSE, Mandrake, and many others), a ! Debian package for users of Debian-based Linux systems (Debian proper, ! Caldera, Corel, etc.), and so forth. In that case, you would download the installer appropriate to your --- 84,88 ---- installer available for Windows users, an RPM package for users of RPM-based Linux systems (Red Hat, SuSE, Mandrake, and many others), a ! Debian package for users of Debian-based Linux systems, and so forth. In that case, you would download the installer appropriate to your *************** *** 118,123 **** will unpack into a similarly-named directory: \file{foo-1.0} or \file{widget-0.9.7}. Additionally, the distribution will contain a ! setup script \file{setup.py}, and a \file{README.txt} (or possibly ! \file{README}), which should explain that building and installing the module distribution is a simple matter of running --- 112,117 ---- will unpack into a similarly-named directory: \file{foo-1.0} or \file{widget-0.9.7}. Additionally, the distribution will contain a ! setup script \file{setup.py}, and a file named \file{README.txt} or possibly ! just \file{README}, which should explain that building and installing the module distribution is a simple matter of running *************** *** 133,169 **** - \subsection{The old way: no standards} - \label{old-way} - - Before the Distutils, there was no infrastructure to support installing - third-party modules in a consistent, standardized way. Thus, it's not - really possible to write a general manual for installing Python modules - that don't use the Distutils; the only truly general statement that can - be made is, ``Read the module's own installation instructions.'' - - However, if such instructions exist at all, they are often woefully - inadequate and targeted at experienced Python developers. Such users - are already familiar with how the Python library is laid out on their - platform, and know where to copy various files in order for Python to - find them. This document makes no such assumptions, and explains how - the Python library is laid out on three major platforms (\UNIX, Windows, - and Mac OS), so that you can understand what happens when the Distutils - do their job \emph{and} know how to install modules manually when the - module author fails to provide a setup script. - - Additionally, while there has not previously been a standard - installation mechanism, Python has had some standard machinery for - building extensions on \UNIX{} since Python 1.4. This - machinery (the \file{Makefile.pre.in} file) is superseded by the - Distutils, but it will no doubt live on in older module distributions - for a while. This \file{Makefile.pre.in} mechanism is documented in - the \citetitle[../ext/ext.html]{Extending \& Embedding Python} manual, - but that manual is aimed at module developers---hence, we include - documentation for builders/installers here. - - All of the pre-Distutils material is tucked away in - section~\ref{pre-distutils}. - - \section{Standard Build and Install} \label{standard-install} --- 127,130 ---- *************** *** 249,256 **** \end{verbatim} ! (If you do this, you will notice that running the \command{install} command first runs the \command{build} command, which---in this case---quickly notices that it has nothing to do, since everything in ! the \file{build} directory is up-to-date.) You may not need this ability to break things down often if all you do --- 210,217 ---- \end{verbatim} ! If you do this, you will notice that running the \command{install} command first runs the \command{build} command, which---in this case---quickly notices that it has nothing to do, since everything in ! the \file{build} directory is up-to-date. You may not need this ability to break things down often if all you do *************** *** 416,431 **** \label{building-ext} ! (This is the section to read for people doing any sort of interesting ! build. Things to talk about: \begin{itemize} ! \item the \file{Setup} file (any platform now, but \UNIX-biased) ! \item CFLAGS and LDFLAGS (must implement them first!) ! \item using non-MS compilers on Windows (how to convert ! Python's library, ...) \end{itemize} ! %\subsection{Tweaking compiler/linker flags} ! %\label{tweak-flags} --- 377,467 ---- \label{building-ext} ! Whenever possible, the Distutils try to use the configuration ! information made available by the Python interpreter used to run the ! \file{setup.py} script. For example, the same compiler and linker ! flags used to compile Python will also be used for compiling ! extensions. Usually this will work well, but in complicated ! situations this might be inappropriate. This section discusses how to ! override the usual Distutils behaviour. ! ! \subsection{Tweaking compiler/linker flags} ! \label{tweak-flags} ! ! Compiling a Python extension written in C or \Cpp will sometimes ! require specifying custom flags for the compiler and linker in order ! to use a particular library or produce a special kind of object code. ! This is especially true if the extension hasn't been tested on your ! platform, or if you're trying to cross-compile Python. ! ! In the most general case, the extension author might have foreseen ! that compiling the extensions would be complicated, and provided a ! \file{Setup} file for you to edit. This will likely only be done if ! the module distribution contains many separate extension modules, or ! if they often require elaborate sets of compiler flags in order to work. ! ! A \file{Setup} file, if present, is parsed in order to get a list of ! extensions to build. Each line in a \file{Setup} describes a single ! module. Lines have the following structure: ! ! \begin{verbatim} ! ... [ ...] [ ...] [ ...] ! \end{verbatim} ! ! Let's examine each of the fields in turn. ! \begin{itemize} ! ! \item \var{module} is the name of the extension module to be built, ! and should be a valid Python identifier. You can't just change this ! in order to rename a module (edits to the source code would also be ! needed), so this should be left alone. ! ! \item \var{sourcefile} is anything that's likely to be a source code ! file, at least judging by the filename. Filenames ending in .c are ! assumed to be written in C, filenames ending in .C, .cc, .c++ are ! assumed to be \Cpp, and filenames ending in .m or .mm are assumed to ! be in Objective C. ! ! \item \var{cpparg} is an argument for the C preprocessor, ! and is anything starting with -I, -D, -U or -C . ! ! \item is anything ending in .a or beginning with -l or -L. \end{itemize} + If a particular platform requires a special library on your platform, + you can add it by editing the \file{Setup} file and running + \code{python setup.py build}. For example, if the module defined by the line ! \begin{verbatim} ! foo foomodule.c ! \end{verbatim} ! ! must be linked with the math library \file{libm.a} on your platform, ! simply add \samp{-lm} to the line: ! ! \begin{verbatim} ! foo foomodule.c -lm ! \end{verbatim} ! ! Arbitrary switches intended for the compiler or the linker can be ! supplied with the \code{-Xcompiler \var{arg}} and \code{-Xlinker ! \var{arg}} options: ! ! \begin{verbatim} ! foo foomodule.c -Xcompiler -o32 -Xlinker -shared -lm ! \end{verbatim} ! ! The next option after \code{-Xcompiler} and \code{-Xlinker} will be ! appended to the proper command line, so in the above example the ! compiler will be passed the \samp{-o32} option, and the linker will be ! passed \samp{-shared}. If a compiler option requires an argument, ! you'll have to supply multiple \code{-Xcompiler} options; for example, ! to pass \code{-x c++} the \file{Setup} file would have to contain ! \code{-Xcompiler -x -Xcompiler c++}. ! ! Compiler flags can also be supplied through setting the ! \envvar{CFLAGS} environment variable. If set, the contents of ! \envvar{CFLAGS} will be added to the compiler flags specified in the ! \file{Setup} file. *************** *** 437,449 **** This subsection describes the necessary steps to use Distutils with the Borland \Cpp{} compiler version 5.5. ! %Should we mention that users have to create cfg-files for the compiler %see also http://community.borland.com/article/0,1410,21205,00.html ! First you have to know that the Borland's object file format(OMF) is ! different from what is used by the Python version you can download ! from the Python Web site. (Python is built with Microsoft Visual \Cpp, ! which uses COFF as object file format.) For this reason you have to ! convert Python's library \file{python20.lib} into the Borland format. ! You can do this as follows: \begin{verbatim} --- 473,486 ---- This subsection describes the necessary steps to use Distutils with the Borland \Cpp{} compiler version 5.5. ! %Should we mention that users have to create cfg-files for the compiler? %see also http://community.borland.com/article/0,1410,21205,00.html ! First you have to know that Borland's object file format (OMF) is ! different from the format used by the Python version you can download ! from the Python or ActiveState Web site. (Python is built with ! Microsoft Visual \Cpp, which uses COFF as the object file format.) ! For this reason you have to convert Python's library ! \file{python20.lib} into the Borland format. You can do this as ! follows: \begin{verbatim} *************** *** 474,480 **** \end{verbatim} ! If you want to use the Borland \Cpp{} compiler as default, you should ! consider to write it in your personal or system-wide configuration ! file for Distutils (see section~\ref{config-files}.) \begin{seealso} --- 511,517 ---- \end{verbatim} ! If you want to use the Borland \Cpp{} compiler as the default, you ! could specify this in your personal or system-wide configuration file ! for Distutils (see section~\ref{config-files}.) \begin{seealso} *************** *** 502,509 **** any of these following steps.} ! For these compilers we have to create some special libraries too. ! This task is more complex as for Borland's \Cpp, because there is no ! program to convert the library (inclusive the references on data ! structures.) First you have to create a list of symbols which the Python DLL exports. --- 539,547 ---- any of these following steps.} ! These compilers also require some special libraries. ! This task is more complex than for Borland's \Cpp, because there is no ! program to convert the library. ! % I don't understand what the next line means. --amk ! % (inclusive the references on data structures.) First you have to create a list of symbols which the Python DLL exports. *************** *** 570,574 **** standard third-party module directory. Or you might wish to try out a module before making it a standard part of your local Python ! installation; this is especially true when upgrading a distribution already present: you want to make sure your existing base of scripts still works with the new version before actually upgrading. --- 608,612 ---- standard third-party module directory. Or you might wish to try out a module before making it a standard part of your local Python ! installation. This is especially true when upgrading a distribution already present: you want to make sure your existing base of scripts still works with the new version before actually upgrading. *************** *** 632,637 **** rather than a local add-on. However, if you are installing Python modules from source, you probably want them to go in ! \file{/usr/local/lib/python1.\filevar{X}} rather than ! \file{/usr/lib/python1.\filevar{X}}. This can be done with \begin{verbatim} --- 670,675 ---- rather than a local add-on. However, if you are installing Python modules from source, you probably want them to go in ! \file{/usr/local/lib/python2.\filevar{X}} rather than ! \file{/usr/lib/python2.\filevar{X}}. This can be done with \begin{verbatim} *************** *** 642,648 **** 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 modules in \file{/usr/local/lib/python1.\filevar{X}}, but those modules would have to be installed to, say, ! \file{/mnt/\filevar{@server}/export/lib/python1.\filevar{X}}. This could be done with --- 680,686 ---- 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 modules in \file{/usr/local/lib/python2.\filevar{X}}, but those modules would have to be installed to, say, ! \file{/mnt/\filevar{@server}/export/lib/python2.\filevar{X}}. This could be done with *************** *** 659,664 **** \longprogramopt{prefix}. Files are installed as follows: ! \installscheme{prefix}{/lib/python1.\filevar{X}/site-packages} ! {exec-prefix}{/lib/python1.\filevar{X}/site-packages} {prefix}{/bin} {prefix}{/share} --- 697,702 ---- \longprogramopt{prefix}. Files are installed as follows: ! \installscheme{prefix}{/lib/python2.\filevar{X}/site-packages} ! {exec-prefix}{/lib/python2.\filevar{X}/site-packages} {prefix}{/bin} {prefix}{/share} *************** *** 672,676 **** that a standard \UNIX{} installation uses the prefix scheme, but with \longprogramopt{prefix} and \longprogramopt{exec-prefix} supplied by ! Python itself (as \code{sys.prefix} and \code{sys.exec\_prefix}). Thus, you might think you'll never use the prefix scheme, but every time you run \code{python setup.py install} without any other options, you're --- 710,714 ---- that a standard \UNIX{} installation uses the prefix scheme, but with \longprogramopt{prefix} and \longprogramopt{exec-prefix} supplied by ! Python itself as \code{sys.prefix} and \code{sys.exec\_prefix}. Thus, you might think you'll never use the prefix scheme, but every time you run \code{python setup.py install} without any other options, you're *************** *** 682,686 **** interpreter used to run the setup script will be used in compiling extensions. It is your responsibility to ensure that the interpreter ! used to run extensions installed in this way is compatibile with the interpreter used to build them. The best way to do this is to ensure that the two interpreters are the same version of Python (possibly --- 720,724 ---- interpreter used to run the setup script will be used in compiling extensions. It is your responsibility to ensure that the interpreter ! used to run extensions installed in this way is compatible with the interpreter used to build them. The best way to do this is to ensure that the two interpreters are the same version of Python (possibly *************** *** 703,708 **** \end{verbatim} ! to install modules to the \file{\textbackslash{}Temp} directory on the current ! drive. The installation base is defined by the \longprogramopt{prefix} option; --- 741,747 ---- \end{verbatim} ! to install modules to the ! \file{\textbackslash{}Temp\textbackslash{}Python} directory on the ! current drive. The installation base is defined by the \longprogramopt{prefix} option; *************** *** 715,721 **** ! \subsection{Alternate installation: Mac OS} \label{alt-install-macos} Like Windows, Mac OS has no notion of home directories (or even of users), and a fairly simple standard Python installation. Thus, only a --- 754,762 ---- ! \subsection{Alternate installation: Mac OS 9} \label{alt-install-macos} + % XXX Mac OS X? + Like Windows, Mac OS has no notion of home directories (or even of users), and a fairly simple standard Python installation. Thus, only a *************** *** 740,744 **** the same base directory, or you might want to completely redefine the installation scheme. In either case, you're creating a \emph{custom ! installation scheme}. You probably noticed the column of ``override options'' in the tables --- 781,785 ---- the same base directory, or you might want to completely redefine the installation scheme. In either case, you're creating a \emph{custom ! installation scheme}. You probably noticed the column of ``override options'' in the tables *************** *** 823,828 **** \code{\$PLAT} is not (necessarily) an environment variable---it will be ! expanded by the Distutils as it parses your command line options (just ! as it does when parsing your configuration file(s)). Obviously, specifying the entire installation scheme every time you --- 864,869 ---- \code{\$PLAT} is not (necessarily) an environment variable---it will be ! expanded by the Distutils as it parses your command line options, just ! as it does when parsing your configuration file(s). Obviously, specifying the entire installation scheme every time you *************** *** 865,876 **** You probably noticed the use of \code{\$HOME} and \code{\$PLAT} in the sample configuration file input. These are Distutils configuration ! variables, which bear a strong resemblance to environment variables. In ! fact, you can use environment variables in config files---on platforms ! that have such a notion---but the Distutils additionally define a few ! extra variables that may not be in your environment, such as ! \code{\$PLAT}. (And of course, you can only use the configuration ! variables supplied by the Distutils on systems that don't have ! environment variables, such as Mac OS (\XXX{true?}).) See ! section~\ref{config-files} for details. \XXX{need some Windows and Mac OS examples---when would custom --- 906,917 ---- You probably noticed the use of \code{\$HOME} and \code{\$PLAT} in the sample configuration file input. These are Distutils configuration ! variables, which bear a strong resemblance to environment variables. ! In fact, you can use environment variables in config files on ! platforms that have such a notion but the Distutils additionally ! define a few extra variables that may not be in your environment, such ! as \code{\$PLAT}. (And of course, on systems that don't have ! environment variables, such as Mac OS (\XXX{true?}), the configuration ! variables supplied by the Distutils are the only ones you can use.) ! See section~\ref{config-files} for details. \XXX{need some Windows and Mac OS examples---when would custom *************** *** 959,966 **** The Distutils configuration files all have the same syntax. The config ! files are grouped into sections; there is one section for each Distutils command, plus a \code{global} section for global options that affect every command. Each section consists of one option per line, specified ! like \code{option=value}. For example, the following is a complete config file that just forces --- 1000,1007 ---- The Distutils configuration files all have the same syntax. The config ! files are grouped into sections. There is one section for each Distutils command, plus a \code{global} section for global options that affect every command. Each section consists of one option per line, specified ! as \code{option=value}. For example, the following is a complete config file that just forces *************** *** 1018,1034 **** See also the ``Reference'' section of the ``Distributing Python Modules'' manual. - - - %\section{Pre-Distutils Conventions} - %\label{pre-distutils} - - - %\subsection{The Makefile.pre.in file} - %\label{makefile-pre-in} - - - %\subsection{Installing modules manually} - %\label{manual-install} - \end{document} --- 1059,1062 ---- From jackjansen@sourceforge.net Tue May 7 22:41:52 2002 From: jackjansen@sourceforge.net (jackjansen@sourceforge.net) Date: Tue, 07 May 2002 14:41:52 -0700 Subject: [Python-checkins] python/dist/src/Mac/Build PythonStandSmall.mcp,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Build In directory usw-pr-cvs1:/tmp/cvs-serv4759/Python/Mac/Build Modified Files: PythonStandSmall.mcp Log Message: Added enumobject.c Index: PythonStandSmall.mcp =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Build/PythonStandSmall.mcp,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 Binary files /tmp/cvsfdpJee and /tmp/cvsOxTtRk differ From jackjansen@sourceforge.net Tue May 7 22:42:11 2002 From: jackjansen@sourceforge.net (jackjansen@sourceforge.net) Date: Tue, 07 May 2002 14:42:11 -0700 Subject: [Python-checkins] python/dist/src/Mac/Build PythonCore.mcp,1.34,1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Build In directory usw-pr-cvs1:/tmp/cvs-serv5011/Python/Mac/Build Modified Files: PythonCore.mcp Log Message: Added enumobject.c Index: PythonCore.mcp =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Build/PythonCore.mcp,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 Binary files /tmp/cvsOEzusj and /tmp/cvsQ1mWTr differ From jackjansen@sourceforge.net Tue May 7 23:59:08 2002 From: jackjansen@sourceforge.net (jackjansen@sourceforge.net) Date: Tue, 07 May 2002 15:59:08 -0700 Subject: [Python-checkins] python/dist/src/Mac/Build PythonStandSmall.mcp,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Build In directory usw-pr-cvs1:/tmp/cvs-serv27122/Python/Mac/Build Modified Files: PythonStandSmall.mcp Log Message: Added pycfbridge.c Index: PythonStandSmall.mcp =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Build/PythonStandSmall.mcp,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 Binary files /tmp/cvsSCw3u6 and /tmp/cvsIN5Iw3 differ From jackjansen@sourceforge.net Tue May 7 23:59:55 2002 From: jackjansen@sourceforge.net (jackjansen@sourceforge.net) Date: Tue, 07 May 2002 15:59:55 -0700 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf _CFmodule.c,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory usw-pr-cvs1:/tmp/cvs-serv27449/Python/Mac/Modules/cf Modified Files: _CFmodule.c Log Message: More support for bridging between Python and CoreFoundation objects. Still untested. Index: _CFmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/_CFmodule.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** _CFmodule.c 23 Apr 2002 22:45:47 -0000 1.12 --- _CFmodule.c 7 May 2002 22:59:53 -0000 1.13 *************** *** 32,35 **** --- 32,37 ---- #endif + #include "pycfbridge.h" + #ifdef USE_TOOLBOX_OBJECT_GLUE extern PyObject *_CFTypeRefObj_New(CFTypeRef); *************** *** 288,291 **** --- 290,301 ---- } + static PyObject *CFTypeRefObj_toPython(CFTypeRefObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + + return PyCF_CF2Python(_self->ob_itself); + + } + static PyMethodDef CFTypeRefObj_methods[] = { {"CFGetTypeID", (PyCFunction)CFTypeRefObj_CFGetTypeID, 1, *************** *** 305,308 **** --- 315,320 ---- {"CFShow", (PyCFunction)CFTypeRefObj_CFShow, 1, "() -> None"}, + {"toPython", (PyCFunction)CFTypeRefObj_toPython, 1, + "() -> (python_object)"}, {NULL, NULL, 0} }; *************** *** 3696,3699 **** --- 3708,3735 ---- } + static PyObject *CF_toCF(PyObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + + CFTypeRef rv; + CFTypeID typeid; + + if (!PyArg_ParseTuple(_args, "O&", PyCF_Python2CF, &rv)) + return NULL; + typeid = CFGetTypeID(rv); + + if (typeid == CFStringGetTypeID()) + return Py_BuildValue("O&", CFStringRefObj_New, rv); + if (typeid == CFArrayGetTypeID()) + return Py_BuildValue("O&", CFArrayRefObj_New, rv); + if (typeid == CFDictionaryGetTypeID()) + return Py_BuildValue("O&", CFDictionaryRefObj_New, rv); + if (typeid == CFURLGetTypeID()) + return Py_BuildValue("O&", CFURLRefObj_New, rv); + + return Py_BuildValue("O&", CFTypeRefObj_New, rv); + + } + static PyMethodDef CF_methods[] = { {"__CFRangeMake", (PyCFunction)CF___CFRangeMake, 1, *************** *** 3779,3782 **** --- 3815,3820 ---- {"CFURLCreateFromFSRef", (PyCFunction)CF_CFURLCreateFromFSRef, 1, "(FSRef fsRef) -> (CFURLRef _rv)"}, + {"toCF", (PyCFunction)CF_toCF, 1, + "(python_object) -> (CF_object)"}, {NULL, NULL, 0} }; From jackjansen@sourceforge.net Wed May 8 00:00:05 2002 From: jackjansen@sourceforge.net (jackjansen@sourceforge.net) Date: Tue, 07 May 2002 16:00:05 -0700 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf pycfbridge.c,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory usw-pr-cvs1:/tmp/cvs-serv27668/Python/Mac/Modules/cf Modified Files: pycfbridge.c Log Message: More support for bridging between Python and CoreFoundation objects. Still untested. Index: pycfbridge.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/pycfbridge.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pycfbridge.c 5 May 2002 21:48:12 -0000 1.1 --- pycfbridge.c 7 May 2002 23:00:03 -0000 1.2 *************** *** 27,30 **** --- 27,34 ---- CFTypeID typeid; + if( src == NULL ) { + Py_INCREF(Py_None); + return Py_None; + } typeid = CFGetTypeID(src); if (typeid == CFArrayGetTypeID()) *************** *** 37,41 **** PyObject * PyCF_CF2Python_sequence(CFArrayRef src) { ! PyErr_SetString(PyExc_SystemError, "Not yet implemented"); return NULL; } --- 41,64 ---- PyObject * PyCF_CF2Python_sequence(CFArrayRef src) { ! int size = CFArrayGetCount(src); ! PyObject *rv; ! CFTypeRef item_cf; ! PyObject *item_py = NULL; ! int i; ! ! if ( (rv=PyList_New(size)) == NULL ) ! return NULL; ! for(i=0; i Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory usw-pr-cvs1:/tmp/cvs-serv27523/Python/Mac/Modules/cf Modified Files: cfsupport.py Log Message: More support for bridging between Python and CoreFoundation objects. Still untested. Index: cfsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/cfsupport.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** cfsupport.py 1 Jan 2002 22:43:13 -0000 1.14 --- cfsupport.py 7 May 2002 22:59:58 -0000 1.15 *************** *** 54,57 **** --- 54,59 ---- #endif + #include "pycfbridge.h" + #ifdef USE_TOOLBOX_OBJECT_GLUE extern PyObject *_CFTypeRefObj_New(CFTypeRef); *************** *** 485,488 **** --- 487,521 ---- f.docstring = lambda: "() -> (unicode _rv)" CFStringRef_object.add(f) + + toPython_body = """ + return PyCF_CF2Python(_self->ob_itself); + """ + + f = ManualGenerator("toPython", toPython_body); + f.docstring = lambda: "() -> (python_object)" + CFTypeRef_object.add(f) + + toCF_body = """ + CFTypeRef rv; + CFTypeID typeid; + + if (!PyArg_ParseTuple(_args, "O&", PyCF_Python2CF, &rv)) + return NULL; + typeid = CFGetTypeID(rv); + + if (typeid == CFStringGetTypeID()) + return Py_BuildValue("O&", CFStringRefObj_New, rv); + if (typeid == CFArrayGetTypeID()) + return Py_BuildValue("O&", CFArrayRefObj_New, rv); + if (typeid == CFDictionaryGetTypeID()) + return Py_BuildValue("O&", CFDictionaryRefObj_New, rv); + if (typeid == CFURLGetTypeID()) + return Py_BuildValue("O&", CFURLRefObj_New, rv); + + return Py_BuildValue("O&", CFTypeRefObj_New, rv); + """ + f = ManualGenerator("toCF", toCF_body); + f.docstring = lambda: "(python_object) -> (CF_object)" + module.add(f) # ADD add forloop here From loewis@sourceforge.net Wed May 8 08:16:39 2002 From: loewis@sourceforge.net (loewis@sourceforge.net) Date: Wed, 08 May 2002 00:16:39 -0700 Subject: [Python-checkins] python/dist/src/Modules/expat expat.h,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Modules/expat In directory usw-pr-cvs1:/tmp/cvs-serv683 Modified Files: expat.h Log Message: Patch #551011: Fix compilation problems with Cygwin. Index: expat.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/expat/expat.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** expat.h 13 Feb 2002 07:47:16 -0000 1.2 --- expat.h 8 May 2002 07:16:37 -0000 1.3 *************** *** 10,14 **** #ifndef XMLPARSEAPI ! # if defined(__declspec) && !defined(__BEOS__) # define XMLPARSEAPI(type) __declspec(dllimport) type __cdecl # else --- 10,14 ---- #ifndef XMLPARSEAPI ! # if defined(__declspec) && !defined(__BEOS__) && !defined(__CYGWIN__) # define XMLPARSEAPI(type) __declspec(dllimport) type __cdecl # else From loewis@sourceforge.net Wed May 8 09:44:23 2002 From: loewis@sourceforge.net (loewis@sourceforge.net) Date: Wed, 08 May 2002 01:44:23 -0700 Subject: [Python-checkins] python/dist/src/Doc/api abstract.tex,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv2607/Doc/api Modified Files: abstract.tex Log Message: Patch #552433: Special-case tuples. Avoid sub-type checking for lists. Avoid checks for negative indices and duplicate checks for support of the sequence protocol. Index: abstract.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/abstract.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** abstract.tex 23 Apr 2002 18:15:44 -0000 1.13 --- abstract.tex 8 May 2002 08:44:20 -0000 1.14 *************** *** 766,769 **** --- 766,776 ---- \end{cfuncdesc} + \begin{cfuncdesc}{PyObject*}{PySequence_ITEM}{PyObject *o, int i} + Return the \var{i}th element of \var{o} or \NULL on failure. + Macro form of \cfunction{PySequence_GetItem()} but without checking + that \cfunction{PySequence_Check(\var{o})} is true and without + adjustment for negative indices. + \end{cfuncdesc} + \begin{cfuncdesc}{int}{PySequence_Fast_GET_SIZE}{PyObject *o} Returns the length of \var{o}, assuming that \var{o} was From loewis@sourceforge.net Wed May 8 09:44:23 2002 From: loewis@sourceforge.net (loewis@sourceforge.net) Date: Wed, 08 May 2002 01:44:23 -0700 Subject: [Python-checkins] python/dist/src/Include abstract.h,2.43,2.44 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv2607/Include Modified Files: abstract.h Log Message: Patch #552433: Special-case tuples. Avoid sub-type checking for lists. Avoid checks for negative indices and duplicate checks for support of the sequence protocol. Index: abstract.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/abstract.h,v retrieving revision 2.43 retrieving revision 2.44 diff -C2 -d -r2.43 -r2.44 *** abstract.h 5 Jan 2002 10:50:30 -0000 2.43 --- abstract.h 8 May 2002 08:44:21 -0000 2.44 *************** *** 1016,1019 **** --- 1016,1025 ---- */ + #define PySequence_ITEM(o, i)\ + ( o->ob_type->tp_as_sequence->sq_item(o, i) ) + /* Assume tp_as_sequence and sq_item exist and that i does not + need to be corrected for a negative index + */ + DL_IMPORT(int) PySequence_Count(PyObject *o, PyObject *value); From loewis@sourceforge.net Wed May 8 09:44:23 2002 From: loewis@sourceforge.net (loewis@sourceforge.net) Date: Wed, 08 May 2002 01:44:23 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.403,1.404 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv2607/Misc Modified Files: NEWS Log Message: Patch #552433: Special-case tuples. Avoid sub-type checking for lists. Avoid checks for negative indices and duplicate checks for support of the sequence protocol. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.403 retrieving revision 1.404 diff -C2 -d -r1.403 -r1.404 *** NEWS 7 May 2002 20:58:03 -0000 1.403 --- NEWS 8 May 2002 08:44:21 -0000 1.404 *************** *** 193,196 **** --- 193,200 ---- C API + - Added new macro PySequence_ITEM(o, i) that directly calls + sq_item without rechecking that o is a sequence and without + adjusting for negative indices. + - PyRange_New() now raises ValueError if the fourth argument is not 1. This is part of the removal of deprecated features of the xrange From loewis@sourceforge.net Wed May 8 09:44:23 2002 From: loewis@sourceforge.net (loewis@sourceforge.net) Date: Wed, 08 May 2002 01:44:23 -0700 Subject: [Python-checkins] python/dist/src/Objects iterobject.c,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv2607/Objects Modified Files: iterobject.c Log Message: Patch #552433: Special-case tuples. Avoid sub-type checking for lists. Avoid checks for negative indices and duplicate checks for support of the sequence protocol. Index: iterobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/iterobject.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** iterobject.c 18 Mar 2002 20:43:51 -0000 1.8 --- iterobject.c 8 May 2002 08:44:21 -0000 1.9 *************** *** 13,16 **** --- 13,21 ---- { seqiterobject *it; + + if (!PySequence_Check(seq)) { + PyErr_BadInternalCall(); + return NULL; + } it = PyObject_GC_New(seqiterobject, &PySeqIter_Type); if (it == NULL) *************** *** 64,68 **** seq = it->it_seq; ! if (PyList_Check(seq)) { PyObject *item; if (it->it_index >= PyList_GET_SIZE(seq)) { --- 69,73 ---- seq = it->it_seq; ! if (PyList_CheckExact(seq)) { PyObject *item; if (it->it_index >= PyList_GET_SIZE(seq)) { *************** *** 74,79 **** return item; } else { ! PyObject *result = PySequence_GetItem(seq, it->it_index++); if (result != NULL) { return result; --- 79,95 ---- return item; } + if (PyTuple_CheckExact(seq)) { + PyObject *item; + if (it->it_index >= PyTuple_GET_SIZE(seq)) { + return NULL; + } + item = PyTuple_GET_ITEM(seq, it->it_index); + it->it_index++; + Py_INCREF(item); + return item; + } else { ! PyObject *result = PySequence_ITEM(seq, it->it_index); ! it->it_index++; if (result != NULL) { return result; From loewis@sourceforge.net Wed May 8 09:49:29 2002 From: loewis@sourceforge.net (loewis@sourceforge.net) Date: Wed, 08 May 2002 01:49:29 -0700 Subject: [Python-checkins] python/dist/src/Objects rangeobject.c,2.35,2.36 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv4722 Modified Files: rangeobject.c Log Message: Patch #551410: Implement tp_getiter. Index: rangeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/rangeobject.c,v retrieving revision 2.35 retrieving revision 2.36 diff -C2 -d -r2.35 -r2.36 *** rangeobject.c 2 May 2002 19:56:55 -0000 2.35 --- rangeobject.c 8 May 2002 08:49:27 -0000 2.36 *************** *** 9,12 **** --- 9,14 ---- long step; long len; + long index; + int used; /* Set to 1 if called by range_getiter */ } rangeobject; *************** *** 44,47 **** --- 46,51 ---- obj->len = len; obj->step = step; + obj->index = 0; + obj->used = 0; return (PyObject *) obj; *************** *** 87,90 **** --- 91,133 ---- } + static PyObject * + range_getiter(rangeobject *r) + { + rangeobject *obj; + if (r->used == 0 || r->index >= r->len) { + Py_INCREF(r); + r->used = 1; + r->index = 0; + return (PyObject *)r; + } + + obj = PyObject_NEW(rangeobject, &PyRange_Type); + if (obj == NULL) + return NULL; + + obj->start = r->start; + obj->len = r->len; + obj->step = r->step; + obj->index = 0; + obj->used = 1; + return (PyObject *) obj; + } + + static PyObject * + range_next(rangeobject *r) + { + if (r->index >= r->len) { + PyErr_SetObject(PyExc_StopIteration, Py_None); + return NULL; + } + return PyInt_FromLong(r->start + (r->index++) * r->step); + } + + static PyMethodDef range_methods[] = { + {"next", (PyCFunction)range_next, METH_NOARGS, + "it.next() -- get the next value, or raise StopIteration"}, + {NULL, NULL} /* sentinel */ + }; + static PySequenceMethods range_as_sequence = { (inquiry)range_length, /* sq_length */ *************** *** 113,120 **** 0, /* tp_call */ 0, /* tp_str */ ! 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ 0, /* tp_doc */ }; --- 156,170 ---- 0, /* tp_call */ 0, /* tp_str */ ! PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + (getiterfunc)range_getiter, /* tp_iter */ + (iternextfunc)range_next, /* tp_iternext */ + range_methods, /* tp_methods */ }; From loewis@sourceforge.net Wed May 8 09:51:31 2002 From: loewis@sourceforge.net (loewis@sourceforge.net) Date: Wed, 08 May 2002 01:51:31 -0700 Subject: [Python-checkins] python/dist/src configure,1.304,1.305 configure.in,1.314,1.315 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv5758 Modified Files: configure configure.in Log Message: Patch #553403: Fix typo. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.304 retrieving revision 1.305 diff -C2 -d -r1.304 -r1.305 *** configure 3 May 2002 05:53:15 -0000 1.304 --- configure 8 May 2002 08:51:28 -0000 1.305 *************** *** 1,4 **** #! /bin/sh ! # From configure.in Revision: 1.313 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. --- 1,4 ---- #! /bin/sh ! # From configure.in Revision: 1.314 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. *************** *** 3019,3023 **** LDLIBRARY="$LIBRARY" BLDLIBRARY='$(LDLIBRARY)' ! INSTSONMAE='$(LDLIBRARY)' DLLLIBRARY='' LDLIBRARYDIR='' --- 3019,3023 ---- LDLIBRARY="$LIBRARY" BLDLIBRARY='$(LDLIBRARY)' ! INSTSONAME='$(LDLIBRARY)' DLLLIBRARY='' LDLIBRARYDIR='' Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.314 retrieving revision 1.315 diff -C2 -d -r1.314 -r1.315 *** configure.in 3 May 2002 05:53:15 -0000 1.314 --- configure.in 8 May 2002 08:51:29 -0000 1.315 *************** *** 292,296 **** LDLIBRARY="$LIBRARY" BLDLIBRARY='$(LDLIBRARY)' ! INSTSONMAE='$(LDLIBRARY)' DLLLIBRARY='' LDLIBRARYDIR='' --- 292,296 ---- LDLIBRARY="$LIBRARY" BLDLIBRARY='$(LDLIBRARY)' ! INSTSONAME='$(LDLIBRARY)' DLLLIBRARY='' LDLIBRARYDIR='' From loewis@sourceforge.net Wed May 8 09:56:35 2002 From: loewis@sourceforge.net (loewis@sourceforge.net) Date: Wed, 08 May 2002 01:56:35 -0700 Subject: [Python-checkins] python/dist/src/Misc ACKS,1.171,1.172 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv8144/Misc Modified Files: ACKS Log Message: Patch #553277: Accept callbacks that are callable, not callbacks that are true. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.171 retrieving revision 1.172 diff -C2 -d -r1.171 -r1.172 *** ACKS 23 Apr 2002 13:29:43 -0000 1.171 --- ACKS 8 May 2002 08:56:33 -0000 1.172 *************** *** 227,230 **** --- 227,231 ---- Paul Jackson David Jacobs + Geert Jansen Jack Jansen Bill Janssen From loewis@sourceforge.net Wed May 8 09:56:35 2002 From: loewis@sourceforge.net (loewis@sourceforge.net) Date: Wed, 08 May 2002 01:56:35 -0700 Subject: [Python-checkins] python/dist/src/Lib ftplib.py,1.66,1.67 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv8144/Lib Modified Files: ftplib.py Log Message: Patch #553277: Accept callbacks that are callable, not callbacks that are true. Index: ftplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ftplib.py,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** ftplib.py 10 Mar 2002 15:59:58 -0000 1.66 --- ftplib.py 8 May 2002 08:56:33 -0000 1.67 *************** *** 393,397 **** with trailing CRLF stripped. This creates a new port for you. print_line() is the default callback.''' ! if not callback: callback = print_line resp = self.sendcmd('TYPE A') conn = self.transfercmd(cmd) --- 393,397 ---- with trailing CRLF stripped. This creates a new port for you. print_line() is the default callback.''' ! if not callable(callback): callback = print_line resp = self.sendcmd('TYPE A') conn = self.transfercmd(cmd) From loewis@sourceforge.net Wed May 8 10:00:04 2002 From: loewis@sourceforge.net (loewis@sourceforge.net) Date: Wed, 08 May 2002 02:00:04 -0700 Subject: [Python-checkins] python/dist/src Makefile.pre.in,1.82,1.83 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv9701 Modified Files: Makefile.pre.in Log Message: Patch #553230: Create LIBDIR if necessary. Bugfix candidate. Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** Makefile.pre.in 26 Apr 2002 19:40:53 -0000 1.82 --- Makefile.pre.in 8 May 2002 08:59:59 -0000 1.83 *************** *** 550,554 **** # This goes into $(exec_prefix) altbininstall: $(BUILDPYTHON) ! @for i in $(BINDIR); \ do \ if test ! -d $$i; then \ --- 550,554 ---- # This goes into $(exec_prefix) altbininstall: $(BUILDPYTHON) ! @for i in $(BINDIR) $(LIBDIR); \ do \ if test ! -d $$i; then \ From nascheme@sourceforge.net Wed May 8 15:14:43 2002 From: nascheme@sourceforge.net (nascheme@sourceforge.net) Date: Wed, 08 May 2002 07:14:43 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.404,1.405 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv26571/Misc Modified Files: NEWS Log Message: Remove news about PyMalloc_*. Do we need to say anything about pymalloc? Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.404 retrieving revision 1.405 diff -C2 -d -r1.404 -r1.405 *** NEWS 8 May 2002 08:44:21 -0000 1.404 --- NEWS 8 May 2002 14:14:41 -0000 1.405 *************** *** 217,226 **** - PyType_Ready() accidentally did not inherit tp_is_gc; now it does. ! - Objects allocated using the new PyMalloc_New and PyMalloc_NewVar ! functions will be allocated using pymalloc if it is enabled. These ! objects should be deallocated using PyMalloc_Del. The PyObject_{New, ! NewVar,NEW_VAR,Del,DEL} APIs have been changed to always use ! PyMem_MALLOC and PyMem_FREE, even if pymalloc is enabled. The ! PyCore_* family of APIs have been removed. - The "u#" parser marker will now pass through Unicode objects as-is --- 217,221 ---- - PyType_Ready() accidentally did not inherit tp_is_gc; now it does. ! - The PyCore_* family of APIs have been removed. - The "u#" parser marker will now pass through Unicode objects as-is From akuchling@sourceforge.net Wed May 8 14:39:05 2002 From: akuchling@sourceforge.net (akuchling@sourceforge.net) Date: Wed, 08 May 2002 06:39:05 -0700 Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex,1.37,1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory usw-pr-cvs1:/tmp/cvs-serv11593 Modified Files: dist.tex Log Message: Updates and rewriting Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** dist.tex 8 Mar 2002 22:02:06 -0000 1.37 --- dist.tex 8 May 2002 13:39:03 -0000 1.38 *************** *** 4,7 **** --- 4,12 ---- % $Id$ + % TODO + % Document extension.read_setup_file + % Document build_clib command + % + \title{Distributing Python Modules} *************** *** 34,53 **** \label{intro} ! In the past, Python module developers have not had much infrastructure ! support for distributing modules, nor have Python users had much support ! for installing and maintaining third-party modules. With the ! introduction of the Python Distribution Utilities (Distutils for short) ! in Python 1.6, this situation should start to improve. ! ! This document only covers using the Distutils to distribute your Python ! modules. Using the Distutils does not tie you to Python 1.6, though: ! the Distutils work just fine with Python 1.5.2, and it is reasonable ! (and expected to become commonplace) to expect users of Python 1.5.2 to ! download and install the Distutils separately before they can install ! your modules. Python 1.6 (or later) users, of course, won't have to add ! anything to their Python installation in order to use the Distutils to ! install third-party modules. ! ! This document concentrates on the role of developer/distributor: if you're looking for information on installing Python modules, you should refer to the \citetitle[../inst/inst.html]{Installing Python --- 39,44 ---- \label{intro} ! This document covers using the Distutils to distribute your Python ! modules, concentrating on the role of developer/distributor: if you're looking for information on installing Python modules, you should refer to the \citetitle[../inst/inst.html]{Installing Python *************** *** 86,98 **** The setup script is usually quite simple, although since it's written in Python, there are no arbitrary limits to what you can do with ! it.\footnote{But be careful about putting arbitrarily expensive ! operations in your setup script; unlike, say, Autoconf-style configure scripts, the setup script may be run multiple times in the course of building and installing your module distribution. If you need to insert potentially expensive processing steps into the Distutils ! chain, see section~\ref{extending} on extending the Distutils.} If ! all you want to do is distribute a module called \module{foo}, contained ! in a file \file{foo.py}, then your setup script can be as little as ! this: \begin{verbatim} --- 77,90 ---- The setup script is usually quite simple, although since it's written in Python, there are no arbitrary limits to what you can do with ! it, though you should be careful about putting arbitrarily expensive ! operations in your setup script. Unlike, say, Autoconf-style configure scripts, the setup script may be run multiple times in the course of building and installing your module distribution. If you need to insert potentially expensive processing steps into the Distutils ! chain, see section~\ref{extending} on extending the Distutils. ! ! If all you want to do is distribute a module called \module{foo}, ! contained in a file \file{foo.py}, then your setup script can be as ! little as this: \begin{verbatim} *************** *** 126,135 **** which will create an archive file (e.g., tarball on \UNIX, ZIP file on Windows) containing your setup script, \file{setup.py}, and your module, ! \file{foo.py}. The archive file will be named \file{Foo-1.0.tar.gz} (or ! \file{.zip}), and will unpack into a directory \file{Foo-1.0}. If an end-user wishes to install your \module{foo} module, all she has ! to do is download \file{Foo-1.0.tar.gz} (or \file{.zip}), unpack it, ! and---from the \file{Foo-1.0} directory---run \begin{verbatim} --- 118,127 ---- which will create an archive file (e.g., tarball on \UNIX, ZIP file on Windows) containing your setup script, \file{setup.py}, and your module, ! \file{foo.py}. The archive file will be named \file{foo-1.0.tar.gz} (or ! \file{.zip}), and will unpack into a directory \file{foo-1.0}. If an end-user wishes to install your \module{foo} module, all she has ! to do is download \file{foo-1.0.tar.gz} (or \file{.zip}), unpack it, ! and---from the \file{foo-1.0} directory---run \begin{verbatim} *************** *** 159,169 **** \end{verbatim} ! will create an executable installer, \file{Foo-1.0.win32.exe}, in the current directory. ! Currently (Distutils 0.9.2), the only other useful built ! distribution format is RPM, implemented by the \command{bdist\_rpm} ! command. For example, the following command will create an RPM file ! called \file{Foo-1.0.noarch.rpm}: \begin{verbatim} --- 151,162 ---- \end{verbatim} ! will create an executable installer, \file{foo-1.0.win32.exe}, in the current directory. ! Other useful built distribution formats are RPM, implemented by the ! \command{bdist\_rpm} command, Solaris \program{pkgtool} ! (\command{bdist\_pkgtool}, and HP-UX \program{swinstall} (\command{bdist_sdux}). ! For example, the following command will create an RPM file called ! \file{foo-1.0.noarch.rpm}: \begin{verbatim} *************** *** 193,209 **** code imported by some other code. Three types of modules concern us here: pure Python modules, extension modules, and packages. \item[pure Python module] a module written in Python and contained in a single \file{.py} file (and possibly associated \file{.pyc} and/or \file{.pyo} files). Sometimes referred to as a ``pure module.'' \item[extension module] a module written in the low-level language of ! the Python implementation: C/C++ for Python, Java for JPython. Typically contained in a single dynamically loadable pre-compiled file, e.g. a shared object (\file{.so}) file for Python extensions on \UNIX, a DLL (given the \file{.pyd} extension) for Python extensions ! on Windows, or a Java class file for JPython extensions. (Note that currently, the Distutils only handles C/C++ extensions for Python.) \item[package] a module that contains other modules; typically contained in a directory in the filesystem and distinguished from other directories by the presence of a file \file{\_\_init\_\_.py}. \item[root package] the root of the hierarchy of packages. (This isn't really a package, since it doesn't have an \file{\_\_init\_\_.py} --- 186,206 ---- code imported by some other code. Three types of modules concern us here: pure Python modules, extension modules, and packages. + \item[pure Python module] a module written in Python and contained in a single \file{.py} file (and possibly associated \file{.pyc} and/or \file{.pyo} files). Sometimes referred to as a ``pure module.'' + \item[extension module] a module written in the low-level language of ! the Python implementation: C/C++ for Python, Java for Jython. Typically contained in a single dynamically loadable pre-compiled file, e.g. a shared object (\file{.so}) file for Python extensions on \UNIX, a DLL (given the \file{.pyd} extension) for Python extensions ! on Windows, or a Java class file for Jython extensions. (Note that currently, the Distutils only handles C/C++ extensions for Python.) + \item[package] a module that contains other modules; typically contained in a directory in the filesystem and distinguished from other directories by the presence of a file \file{\_\_init\_\_.py}. + \item[root package] the root of the hierarchy of packages. (This isn't really a package, since it doesn't have an \file{\_\_init\_\_.py} *************** *** 227,242 **** \emph{en masse}. Examples of some well-known module distributions are Numeric Python, PyXML, PIL (the Python Imaging Library), or ! mxDateTime. (This would be called a \emph{package}, except that term is already taken in the Python context: a single module distribution may contain zero, one, or many Python packages.) \item[pure module distribution] a module distribution that contains only pure Python modules and packages. Sometimes referred to as a ``pure distribution.'' \item[non-pure module distribution] a module distribution that contains at least one extension module. Sometimes referred to as a ``non-pure distribution.'' \item[distribution root] the top-level directory of your source tree (or ! source distribution); the directory where \file{setup.py} exists and ! is run from \end{description} --- 224,242 ---- \emph{en masse}. Examples of some well-known module distributions are Numeric Python, PyXML, PIL (the Python Imaging Library), or ! mxBase. (This would be called a \emph{package}, except that term is already taken in the Python context: a single module distribution may contain zero, one, or many Python packages.) + \item[pure module distribution] a module distribution that contains only pure Python modules and packages. Sometimes referred to as a ``pure distribution.'' + \item[non-pure module distribution] a module distribution that contains at least one extension module. Sometimes referred to as a ``non-pure distribution.'' + \item[distribution root] the top-level directory of your source tree (or ! source distribution); the directory where \file{setup.py} exists. Generally ! \file{setup.py} will be run from this directory. \end{description} *************** *** 291,301 **** setup script portable across operating systems, which of course is one of the major goals of the Distutils. In this spirit, all pathnames in ! this document are slash-separated (MacOS programmers should keep in mind that the \emph{absence} of a leading slash indicates a relative ! path, the opposite of the MacOS convention with colons). This, of course, only applies to pathnames given to Distutils functions. ! If you, for example, use standard python functions such as glob.glob ! or os.listdir to specify files, you should be careful to write portable code instead of hardcoding path separators: --- 291,301 ---- setup script portable across operating systems, which of course is one of the major goals of the Distutils. In this spirit, all pathnames in ! this document are slash-separated. (MacOS programmers should keep in mind that the \emph{absence} of a leading slash indicates a relative ! path, the opposite of the MacOS convention with colons.) This, of course, only applies to pathnames given to Distutils functions. ! If you, for example, use standard python functions such as \function{glob.glob} ! or \function{os.listdir} to specify files, you should be careful to write portable code instead of hardcoding path separators: *************** *** 334,340 **** \end{verbatim} ! in your setup script. (The keys to this dictionary are package names, and an empty package name stands for the root package. The values are ! directory names relative to your distribution root.) In this case, when you say \code{packages = ['foo']}, you are promising that the file \file{lib/foo/\_\_init\_\_.py} exists. --- 334,340 ---- \end{verbatim} ! in your setup script. The keys to this dictionary are package names, and an empty package name stands for the root package. The values are ! directory names relative to your distribution root. In this case, when you say \code{packages = ['foo']}, you are promising that the file \file{lib/foo/\_\_init\_\_.py} exists. *************** *** 401,409 **** \begin{verbatim} ! Extension("foo", ["foo.c"]) \end{verbatim} The \class{Extension} class can be imported from ! \module{distutils.core}, along with \function{setup()}. Thus, the setup script for a module distribution that contains only this one extension and nothing else might be: --- 401,409 ---- \begin{verbatim} ! uExtension("foo", ["foo.c"]) \end{verbatim} The \class{Extension} class can be imported from ! \module{distutils.core} along with \function{setup()}. Thus, the setup script for a module distribution that contains only this one extension and nothing else might be: *************** *** 460,467 **** The second argument to the \class{Extension} constructor is a list of ! source files. Since the Distutils currently only support C/C++ ! extensions, these are normally C/C++ source files. (Be sure to use ! appropriate extensions to distinguish C++ source files: \file{.cc} and ! \file{.cpp} seem to be recognized by both \UNIX{} and Windows compilers.) However, you can also include SWIG interface (\file{.i}) files in the --- 460,468 ---- The second argument to the \class{Extension} constructor is a list of ! source files. Since the Distutils currently only support C, \Cpp, and ! Objective-C extensions, these are normally C/\Cpp/Objective-C source ! files. (Be sure to use appropriate extensions to distinguish \Cpp\ ! source files: \file{.cc} and \file{.cpp} seem to be recognized by both ! \UNIX{} and Windows compilers.) However, you can also include SWIG interface (\file{.i}) files in the *************** *** 509,520 **** If you need to include header files from some other Python extension, ! you can take advantage of the fact that the Distutils install extension ! header files in a consistent way. For example, the Numerical Python ! header files are installed (on a standard \UNIX{} installation) to ! \file{/usr/local/include/python1.5/Numerical}. (The exact location will ! differ according to your platform and Python installation.) Since the ! Python include directory---\file{/usr/local/include/python1.5} in this ! case---is always included in the search path when building Python ! extensions, the best approach is to include (e.g.) \code{}. If you insist on putting the \file{Numerical} include directory right into your header search path, --- 510,522 ---- If you need to include header files from some other Python extension, ! you can take advantage of the fact that the Distutils installs ! extension header files in a consistent way. For example, on a ! standard \UNIX{} installation the Numerical Python header files are ! installed to \file{/usr/local/include/python1.5/Numerical}. (The ! exact location will differ according to your platform and Python ! installation.) Since the Python include ! directory---\file{/usr/local/include/python1.5} in this case---is ! always included in the search path when building Python extensions, ! the best approach is to include (e.g.) \code{}. If you insist on putting the \file{Numerical} include directory right into your header search path, *************** *** 603,614 **** \option{extra\_compile\_args} and \option{extra\_link\_args} can be used ! to specify additional command line options for the compiler resp. ! the linker command line. ! \option{export\_symbols} is only useful on windows, it can contain a list of symbols (functions or variables) to be exported. This option ! is not needed when building compiled extensions: the \code{initmodule} ! function will automatically be added to the exported symbols list ! by Distutils. \subsection{Listing scripts} --- 605,616 ---- \option{extra\_compile\_args} and \option{extra\_link\_args} can be used ! to specify additional command line options for the respective compiler and ! linker command lines. ! \option{export\_symbols} is only useful on Windows. It can contain a list of symbols (functions or variables) to be exported. This option ! is not needed when building compiled extensions: Distutils ! will automatically add \code{initmodule} ! to the list of exported symbols. \subsection{Listing scripts} *************** *** 616,625 **** which are usually not run by themselves but imported by scripts. ! Scripts are files containing Python source code, indended to be started ! from the command line. ! Distutils doesn't provide much functionality for the scripts: the only ! support Distutils gives is to adjust the first line of the script ! if it starts with \code{\#!} and contains the word ``python'' to refer ! to the current interpreter location. The \option{scripts} option simply is a list of files to be handled --- 618,627 ---- which are usually not run by themselves but imported by scripts. ! Scripts are files containing Python source code, indended to be ! started from the command line. Scripts don't require Distutils to do ! anything very complicated. The only clever feature is that if the ! first line of the script starts with \code{\#!} and contains the word ! ``python'', the Distutils will adjust the first line to refer to the ! current interpreter location. The \option{scripts} option simply is a list of files to be handled *************** *** 676,684 **** override either on the command-line or by editing the config file. ! (If you have more advanced needs, such as determining which extensions ! to build based on what capabilities are present on the target system, ! then you need the Distutils ``auto-configuration'' facility. This ! started to appear in Distutils 0.9 but, as of this writing, isn't mature ! or stable enough yet for real-world use.) The setup configuration file is a useful middle-ground between the setup --- 678,686 ---- override either on the command-line or by editing the config file. ! % (If you have more advanced needs, such as determining which extensions ! % to build based on what capabilities are present on the target system, ! % then you need the Distutils ``auto-configuration'' facility. This ! % started to appear in Distutils 0.9 but, as of this writing, isn't mature ! % or stable enough yet for real-world use.) The setup configuration file is a useful middle-ground between the setup *************** *** 709,718 **** where \var{command} is one of the Distutils commands (e.g. ! \command{build\_py}, \command{install}), and \var{option} is one of the ! options that command supports. Any number of options can be supplied ! for each command, and any number of command sections can be included in ! the file. Blank lines are ignored, as are comments (from a ! \character{\#} character to end-of-line). Long option values can be ! split across multiple lines simply by indenting the continuation lines. You can find out the list of options supported by a particular command --- 711,721 ---- where \var{command} is one of the Distutils commands (e.g. ! \command{build\_py}, \command{install}), and \var{option} is one of ! the options that command supports. Any number of options can be ! supplied for each command, and any number of command sections can be ! included in the file. Blank lines are ignored, as are comments, which ! run from a \character{\#} character until the end of the line. Long ! option values can be split across multiple lines simply by indenting ! the continuation lines. You can find out the list of options supported by a particular command *************** *** 771,775 **** Another example: certain commands take a lot of options that don't ! change from run-to-run; for example, \command{bdist\_rpm} needs to know everything required to generate a ``spec'' file for creating an RPM distribution. Some of this information comes from the setup script, and --- 774,778 ---- Another example: certain commands take a lot of options that don't ! change from run to run; for example, \command{bdist\_rpm} needs to know everything required to generate a ``spec'' file for creating an RPM distribution. Some of this information comes from the setup script, and *************** *** 815,819 **** (assuming you haven't specified any \command{sdist} options in the setup script or config file), \command{sdist} creates the archive of the ! default format for the current platform. The default format is gzip'ed tar file (\file{.tar.gz}) on \UNIX, and ZIP file on Windows. \XXX{no MacOS support here} --- 818,822 ---- (assuming you haven't specified any \command{sdist} options in the setup script or config file), \command{sdist} creates the archive of the ! default format for the current platform. The default format is a gzip'ed tar file (\file{.tar.gz}) on \UNIX, and ZIP file on Windows. \XXX{no MacOS support here} *************** *** 831,835 **** \lineiii{zip}{zip file (\file{.zip})}{(1),(3)} \lineiii{gztar}{gzip'ed tar file (\file{.tar.gz})}{(2),(4)} ! \lineiii{bztar}{bzip2'ed tar file (\file{.tar.gz})}{(4)} \lineiii{ztar}{compressed tar file (\file{.tar.Z})}{(4)} \lineiii{tar}{tar file (\file{.tar})}{(4)} --- 834,838 ---- \lineiii{zip}{zip file (\file{.zip})}{(1),(3)} \lineiii{gztar}{gzip'ed tar file (\file{.tar.gz})}{(2),(4)} ! \lineiii{bztar}{bzip2'ed tar file (\file{.tar.bz2})}{(4)} \lineiii{ztar}{compressed tar file (\file{.tar.Z})}{(4)} \lineiii{tar}{tar file (\file{.tar})}{(4)} *************** *** 867,870 **** --- 870,874 ---- you called your setup script), and \file{setup.cfg} \end{itemize} + Sometimes this is enough, but usually you will want to specify additional files to distribute. The typical way to do this is to write *************** *** 960,967 **** \file{MANIFEST.in} and create the manifest \item if neither \file{MANIFEST} nor \file{MANIFEST.in} exist, create a ! manifest with just the default file set\footnote{In versions of the ! Distutils up to and including 0.9.2 (Python 2.0b1), this feature was ! broken; use the \programopt{-f} (\longprogramopt{force-manifest}) ! option to work around the bug.} \item if either \file{MANIFEST.in} or the setup script (\file{setup.py}) are more recent than \file{MANIFEST}, recreate \file{MANIFEST} by --- 964,968 ---- \file{MANIFEST.in} and create the manifest \item if neither \file{MANIFEST} nor \file{MANIFEST.in} exist, create a ! manifest with just the default file set \item if either \file{MANIFEST.in} or the setup script (\file{setup.py}) are more recent than \file{MANIFEST}, recreate \file{MANIFEST} by *************** *** 972,980 **** There are a couple of options that modify this behaviour. First, use the \longprogramopt{no-defaults} and \longprogramopt{no-prune} to ! disable the standard ``include'' and ``exclude'' sets.\footnote{Note ! that if you have no manifest template, no manifest, and use the ! \longprogramopt{no-defaults}, you will get an empty manifest. Another ! bug in Distutils 0.9.2 and earlier causes an uncaught exception in ! this case. The workaround is: Don't Do That.} Second, you might want to force the manifest to be regenerated---for --- 973,977 ---- There are a couple of options that modify this behaviour. First, use the \longprogramopt{no-defaults} and \longprogramopt{no-prune} to ! disable the standard ``include'' and ``exclude'' sets. Second, you might want to force the manifest to be regenerated---for *************** *** 1018,1022 **** designed to enable module developers to concentrate on their specialty---writing code and creating source distributions---while an ! intermediary species of \emph{packager} springs up to turn source distributions into built distributions for as many platforms as there are packagers. --- 1015,1019 ---- designed to enable module developers to concentrate on their specialty---writing code and creating source distributions---while an ! intermediary species called \emph{packagers} springs up to turn source distributions into built distributions for as many platforms as there are packagers. *************** *** 1027,1031 **** software periodically grabbing new source distributions and turning them into built distributions for as many platforms as the software has ! access to. Regardless of the nature of the beast, a packager uses the setup script and the \command{bdist} command family to generate built distributions. --- 1024,1028 ---- software periodically grabbing new source distributions and turning them into built distributions for as many platforms as the software has ! access to. Regardless of who they are, a packager uses the setup script and the \command{bdist} command family to generate built distributions. *************** *** 1042,1051 **** directory), and creates the default type of built distribution for my platform. The default format for built distributions is a ``dumb'' tar ! file on \UNIX, and an simple executable installer on Windows. (That tar file is considered ``dumb'' because it has to be unpacked in a specific location to work.) Thus, the above command on a \UNIX{} system creates ! \file{Distutils-0.9.1.\filevar{plat}.tar.gz}; unpacking this tarball from the right place installs the Distutils just as though you had downloaded the source distribution and run \code{python setup.py --- 1039,1048 ---- directory), and creates the default type of built distribution for my platform. The default format for built distributions is a ``dumb'' tar ! file on \UNIX, and a simple executable installer on Windows. (That tar file is considered ``dumb'' because it has to be unpacked in a specific location to work.) Thus, the above command on a \UNIX{} system creates ! \file{Distutils-1.0.\filevar{plat}.tar.gz}; unpacking this tarball from the right place installs the Distutils just as though you had downloaded the source distribution and run \code{python setup.py *************** *** 1055,1064 **** distributions relative to \filevar{prefix}.) ! Obviously, for pure Python distributions, this isn't a huge win---but ! for non-pure distributions, which include extensions that would need to ! be compiled, it can mean the difference between someone being able to ! use your extensions or not. And creating ``smart'' built distributions, ! such as an RPM package or an executable installer for Windows, is a big ! win for users even if your distribution doesn't include any extensions. The \command{bdist} command has a \longprogramopt{formats} option, --- 1052,1063 ---- distributions relative to \filevar{prefix}.) ! Obviously, for pure Python distributions, this isn't any simpler than ! just running \code{python setup.py install}---but for non-pure ! distributions, which include extensions that would need to be ! compiled, it can mean the difference between someone being able to use ! your extensions or not. And creating ``smart'' built distributions, ! such as an RPM package or an executable installer for Windows, is far ! more convenient for users even if your distribution doesn't include ! any extensions. The \command{bdist} command has a \longprogramopt{formats} option, *************** *** 1071,1075 **** would, when run on a \UNIX{} system, create ! \file{Distutils-0.8.\filevar{plat}.zip}---again, this archive would be unpacked from the root directory to install the Distutils. --- 1070,1074 ---- would, when run on a \UNIX{} system, create ! \file{Distutils-1.0.\filevar{plat}.zip}---again, this archive would be unpacked from the root directory to install the Distutils. *************** *** 1082,1086 **** \lineiii{zip}{zip file (\file{.zip})}{(4)} \lineiii{rpm}{RPM}{(5)} ! \lineiii{srpm}{source RPM}{(5) \XXX{to do!}} \lineiii{wininst}{self-extracting ZIP file for Windows}{(2),(4)} \end{tableiii} --- 1081,1088 ---- \lineiii{zip}{zip file (\file{.zip})}{(4)} \lineiii{rpm}{RPM}{(5)} ! \lineiii{pkgtool}{Solaris \program{pkgtool}}{} ! \lineiii{sdux}{HP-UX \program{swinstall}}{} ! \lineiii{rpm}{RPM}{(5)} ! % \lineiii{srpm}{source RPM}{(5) \XXX{to do!}} \lineiii{wininst}{self-extracting ZIP file for Windows}{(2),(4)} \end{tableiii} *************** *** 1128,1132 **** \label{creating-rpms} ! The RPM format is used by many of popular Linux distributions, including Red Hat, SuSE, and Mandrake. If one of these (or any of the other RPM-based Linux distributions) is your usual environment, creating RPM --- 1130,1134 ---- \label{creating-rpms} ! The RPM format is used by many popular Linux distributions, including Red Hat, SuSE, and Mandrake. If one of these (or any of the other RPM-based Linux distributions) is your usual environment, creating RPM *************** *** 1245,1254 **** ! \subsection{Creating Windows installers} \label{creating-wininst} ! Executable Windows installers are the natural format for binary distributions on Windows. They display a nice graphical user interface, ! display some information of the module distribution to be installed, taken from the meta-data in the setup script, let the user select a few (currently maybe too few) options, and start or cancel the installation. --- 1247,1256 ---- ! \subsection{Creating Windows Installers} \label{creating-wininst} ! Executable installers are the natural format for binary distributions on Windows. They display a nice graphical user interface, ! display some information about the module distribution to be installed taken from the meta-data in the setup script, let the user select a few (currently maybe too few) options, and start or cancel the installation. *************** *** 1269,1279 **** If you have a pure module distribution (only containing pure Python modules and packages), the resulting installer will be ! version independent and have a name like \file{Foo-1.0.win32.exe}. These installers can even be created on \UNIX{} or MacOS platforms. If you have a non-pure distribution, the extensions can only be ! created on a Windows platform, and will be Python version dependend. The installer filename will reflect this and now has the form ! \file{Foo-1.0.win32-py2.0.exe}. You have to create a separate installer for every Python version you want to support. --- 1271,1281 ---- If you have a pure module distribution (only containing pure Python modules and packages), the resulting installer will be ! version independent and have a name like \file{foo-1.0.win32.exe}. These installers can even be created on \UNIX{} or MacOS platforms. If you have a non-pure distribution, the extensions can only be ! created on a Windows platform, and will be Python version dependent. The installer filename will reflect this and now has the form ! \file{foo-1.0.win32-py2.0.exe}. You have to create a separate installer for every Python version you want to support. From jackjansen@sourceforge.net Wed May 8 16:29:35 2002 From: jackjansen@sourceforge.net (jackjansen@sourceforge.net) Date: Wed, 08 May 2002 08:29:35 -0700 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf pycfbridge.c,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory usw-pr-cvs1:/tmp/cvs-serv597 Modified Files: pycfbridge.c Log Message: Partial fix for string handling. Null byte TBD. Index: pycfbridge.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/pycfbridge.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pycfbridge.c 7 May 2002 23:00:03 -0000 1.2 --- pycfbridge.c 8 May 2002 15:29:33 -0000 1.3 *************** *** 54,58 **** item_py = PyCF_CF2Python(item_cf); if (item_py == NULL ) goto err; ! if (!PyList_SetItem(rv, i, item_py)) goto err; item_py = NULL; } --- 54,58 ---- item_py = PyCF_CF2Python(item_cf); if (item_py == NULL ) goto err; ! if (PyList_SetItem(rv, i, item_py) < 0) goto err; item_py = NULL; } *************** *** 87,91 **** value_py = PyCF_CF2Python(value_py); if (value_py == NULL ) goto err; ! if (!PyDict_SetItem(rv, key_py, value_py)) goto err; key_py = NULL; value_py = NULL; --- 87,91 ---- value_py = PyCF_CF2Python(value_py); if (value_py == NULL ) goto err; ! if (PyDict_SetItem(rv, key_py, value_py) < 0) goto err; key_py = NULL; value_py = NULL; *************** *** 136,139 **** --- 136,141 ---- PyCF_Python2CF(PyObject *src, CFTypeRef *dst) { + if (PyString_Check(src) || PyUnicode_Check(src)) + return PyCF_Python2CF_simple(src, dst); if (PySequence_Check(src)) return PyCF_Python2CF_sequence(src, (CFArrayRef *)dst); From Jack.Jansen@cwi.nl Wed May 8 16:39:50 2002 From: Jack.Jansen@cwi.nl (Jack Jansen) Date: Wed, 8 May 2002 17:39:50 +0200 Subject: [Python-checkins] python/dist/src/Lib ftplib.py,1.66,1.67 In-Reply-To: Message-ID: On Wednesday, May 8, 2002, at 10:56 , loewis@sourceforge.net wrote: > Update of /cvsroot/python/python/dist/src/Lib > In directory usw-pr-cvs1:/tmp/cvs-serv8144/Lib > > Modified Files: > ftplib.py > Log Message: > Patch #553277: Accept callbacks that are callable, not callbacks that > are true. Is this patch a good idea? Now you can pass all sorts of garbage as callback (callback="hello") and it'll be silently ignored. I would think something like "if not callback is None:" or so would be better... And in general I think it's unwise in Python to have an object that tests false (because it's __len__ returns 0, in the case of this bug report) but is still expected to do something. "if object: do_something_with(object)" is fairly standard Python idiom. -- - Jack Jansen http://www.cwi.nl/~jack - - If I can't dance I don't want to be part of your revolution -- Emma Goldman - From guido@python.org Wed May 8 17:02:31 2002 From: guido@python.org (Guido van Rossum) Date: Wed, 08 May 2002 12:02:31 -0400 Subject: [Python-checkins] python/dist/src/Lib ftplib.py,1.66,1.67 In-Reply-To: Your message of "Wed, 08 May 2002 17:39:50 +0200." References: Message-ID: <200205081602.g48G2Vu01490@odiug.zope.com> > Is this patch a good idea? Now you can pass all sorts of garbage as > callback (callback="hello") and it'll be silently ignored. I would think > something like "if not callback is None:" or so would be better... I think Martin will change it to that, yes. > And in general I think it's unwise in Python to have an object that > tests false (because it's __len__ returns 0, in the case of this bug > report) but is still expected to do something. "if object: > do_something_with(object)" is fairly standard Python idiom. But it's a time bomb waiting to go off! The correct code should read "if object is not None: do_something_with(object)". There are lots of objects that (for better or for worse!) define __len__. So beware. --Guido van Rossum (home page: http://www.python.org/~guido/) From Jack.Jansen@oratrix.com Wed May 8 22:28:38 2002 From: Jack.Jansen@oratrix.com (Jack Jansen) Date: Wed, 8 May 2002 23:28:38 +0200 Subject: [Python-checkins] python/dist/src/Lib ftplib.py,1.66,1.67 In-Reply-To: <200205081602.g48G2Vu01490@odiug.zope.com> Message-ID: <8F455A31-62CA-11D6-8C16-003065517236@oratrix.com> On woensdag, mei 8, 2002, at 06:02 , Guido van Rossum wrote: >> And in general I think it's unwise in Python to have an object that >> tests false (because it's __len__ returns 0, in the case of this bug >> report) but is still expected to do something. "if object: >> do_something_with(object)" is fairly standard Python idiom. > > But it's a time bomb waiting to go off! The correct code should read > "if object is not None: do_something_with(object)". There are lots of > objects that (for better or for worse!) define __len__. So beware. Hmm. I hadn't noticed this (yet), but I wonder whether it's then a good idea to let pychecker or so test for this, especially the case where an optional argument is used in a simple "if arg:" test. I know that I wrote a lot of code like this over the years... -- - Jack Jansen http://www.cwi.nl/~jack - - If I can't dance I don't want to be part of your revolution -- Emma Goldman - From jackjansen@sourceforge.net Wed May 8 23:13:53 2002 From: jackjansen@sourceforge.net (jackjansen@sourceforge.net) Date: Wed, 08 May 2002 15:13:53 -0700 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf pycfbridge.c,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory usw-pr-cvs1:/tmp/cvs-serv3863/Python/Mac/Modules/cf Modified Files: pycfbridge.c Log Message: Fixed string and dict conversion, and implemented booleans and numbers (int and float). I think we now have enough CFType support to start on plists and CFpreferences! Transparent handling of unknown CFType objects still TBD. Index: pycfbridge.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/pycfbridge.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pycfbridge.c 8 May 2002 15:29:33 -0000 1.3 --- pycfbridge.c 8 May 2002 22:13:51 -0000 1.4 *************** *** 5,8 **** --- 5,9 ---- #ifdef WITHOUT_FRAMEWORKS #include + #include #include #include *************** *** 67,72 **** PyCF_CF2Python_mapping(CFTypeRef src) { int size = CFDictionaryGetCount(src); ! PyObject *rv; ! CFTypeRef *allkeys, *allvalues; CFTypeRef key_cf, value_cf; PyObject *key_py = NULL, *value_py = NULL; --- 68,73 ---- PyCF_CF2Python_mapping(CFTypeRef src) { int size = CFDictionaryGetCount(src); ! PyObject *rv = NULL; ! CFTypeRef *allkeys = NULL, *allvalues = NULL; CFTypeRef key_cf, value_cf; PyObject *key_py = NULL, *value_py = NULL; *************** *** 74,82 **** allkeys = malloc(size*sizeof(CFTypeRef *)); ! if (allkeys == NULL) return PyErr_NoMemory(); allvalues = malloc(size*sizeof(CFTypeRef *)); ! if (allvalues == NULL) return PyErr_NoMemory(); ! if ( (rv=PyDict_New()) == NULL ) ! return NULL; CFDictionaryGetKeysAndValues(src, allkeys, allvalues); for(i=0; i References: Message-ID: <15577.47522.513901.822071@12-248-41-177.client.attbi.com> MvL> Index: abstract.h ... MvL> + #define PySequence_ITEM(o, i)\ ... Assuming this passes muster, shouldn't it be named PySequence_GET_ITEM to match the concrete GET_ITEM macros for lists and tuples? Skip From akuchling@sourceforge.net Thu May 9 15:33:20 2002 From: akuchling@sourceforge.net (akuchling@sourceforge.net) Date: Thu, 09 May 2002 07:33:20 -0700 Subject: [Python-checkins] python/dist/src/Misc python.man,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv3832 Modified Files: python.man Log Message: Fix typo Index: python.man =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/python.man,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** python.man 12 Oct 2001 22:17:56 -0000 1.23 --- python.man 9 May 2002 14:33:18 -0000 1.24 *************** *** 339,343 **** require dates specified as strings to include 4-digit years, otherwise 2-digit years are converted based on rules described in the \fItime\fP ! module documnetation. .IP PYTHONOPTIMIZE If this is set to a non-empty string it is equivalent to specifying --- 339,343 ---- require dates specified as strings to include 4-digit years, otherwise 2-digit years are converted based on rules described in the \fItime\fP ! module documentation. .IP PYTHONOPTIMIZE If this is set to a non-empty string it is equivalent to specifying From akuchling@sourceforge.net Thu May 9 15:34:49 2002 From: akuchling@sourceforge.net (akuchling@sourceforge.net) Date: Thu, 09 May 2002 07:34:49 -0700 Subject: [Python-checkins] python/dist/src/Misc python.man,1.23,1.23.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv4536 Modified Files: Tag: release22-maint python.man Log Message: Fix typo Index: python.man =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/python.man,v retrieving revision 1.23 retrieving revision 1.23.10.1 diff -C2 -d -r1.23 -r1.23.10.1 *** python.man 12 Oct 2001 22:17:56 -0000 1.23 --- python.man 9 May 2002 14:34:47 -0000 1.23.10.1 *************** *** 339,343 **** require dates specified as strings to include 4-digit years, otherwise 2-digit years are converted based on rules described in the \fItime\fP ! module documnetation. .IP PYTHONOPTIMIZE If this is set to a non-empty string it is equivalent to specifying --- 339,343 ---- require dates specified as strings to include 4-digit years, otherwise 2-digit years are converted based on rules described in the \fItime\fP ! module documentation. .IP PYTHONOPTIMIZE If this is set to a non-empty string it is equivalent to specifying From neal@metaslash.com Thu May 9 15:36:40 2002 From: neal@metaslash.com (Neal Norwitz) Date: Thu, 09 May 2002 10:36:40 -0400 Subject: [Python-checkins] python/dist/src/Lib ftplib.py,1.66,1.67 References: <8F455A31-62CA-11D6-8C16-003065517236@oratrix.com> Message-ID: <3CDA8978.20C2101B@metaslash.com> Jack Jansen wrote: > > On woensdag, mei 8, 2002, at 06:02 , Guido van Rossum wrote: > >> And in general I think it's unwise in Python to have an object that > >> tests false (because it's __len__ returns 0, in the case of this bug > >> report) but is still expected to do something. "if object: > >> do_something_with(object)" is fairly standard Python idiom. > > > > But it's a time bomb waiting to go off! The correct code should read > > "if object is not None: do_something_with(object)". There are lots of > > objects that (for better or for worse!) define __len__. So beware. > > Hmm. I hadn't noticed this (yet), but I wonder whether it's then > a good idea to let pychecker or so test for this, especially the > case where an optional argument is used in a simple "if arg:" > test. I know that I wrote a lot of code like this over the > years... There is a feature request for pychecker to do this: https://sourceforge.net/tracker/index.php?func=detail&aid=530528&group_id=24686&atid=382220 I haven't done anything because I think there would be too many false positives. Is there a set of rules which would indicate when this is dangerous? Of course, the rules would also eliminate cases which should be ok. Neal From barry@barrys-emacs.org Fri May 10 10:47:47 2002 From: barry@barrys-emacs.org (Barry Scott) Date: Fri, 10 May 2002 10:47:47 +0100 Subject: [PyChecker-list] Re: [Python-checkins] python/dist/src/Lib ftplib.py,1.66,1.67 In-Reply-To: <3CDA8978.20C2101B@metaslash.com> Message-ID: <001f01c1f807$bd7474f0$060210ac@private> Maybe if you see this pattern: if obj: ... obj.something ... you may need to ignore if "something" is a string or file method to reduce false positives further. Barry > -----Original Message----- > From: pychecker-list-admin@lists.sourceforge.net > [mailto:pychecker-list-admin@lists.sourceforge.net]On Behalf Of Neal > Norwitz > Sent: 09 May 2002 15:37 > To: Jack Jansen > Cc: Guido van Rossum; loewis@sourceforge.net; > python-checkins@python.org; PyChecker > Subject: [PyChecker-list] Re: [Python-checkins] python/dist/src/Lib > ftplib.py,1.66,1.67 > > > Jack Jansen wrote: > > > > On woensdag, mei 8, 2002, at 06:02 , Guido van Rossum wrote: > > >> And in general I think it's unwise in Python to have an object that > > >> tests false (because it's __len__ returns 0, in the case of this bug > > >> report) but is still expected to do something. "if object: > > >> do_something_with(object)" is fairly standard Python idiom. > > > > > > But it's a time bomb waiting to go off! The correct code should read > > > "if object is not None: do_something_with(object)". There are lots of > > > objects that (for better or for worse!) define __len__. So beware. > > > > Hmm. I hadn't noticed this (yet), but I wonder whether it's then > > a good idea to let pychecker or so test for this, especially the > > case where an optional argument is used in a simple "if arg:" > > test. I know that I wrote a lot of code like this over the > > years... > > There is a feature request for pychecker to do this: > https://sourceforge.net/tracker/index.php?func=detail&aid=530528&group_id=24686&atid=382220 > > I haven't done anything because I think there would > be too many false positives. Is there a set of rules > which would indicate when this is dangerous? Of course, > the rules would also eliminate cases which should be ok. > > Neal > > _______________________________________________________________ > > Have big pipes? SourceForge.net is looking for download mirrors. We supply > the hardware. You get the recognition. Email Us: bandwidth@sourceforge.net > _______________________________________________ > PyChecker-list mailing list > PyChecker-list@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pychecker-list > From fdrake@sourceforge.net Fri May 10 13:37:58 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Fri, 10 May 2002 05:37:58 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.84,1.85 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv15758 Modified Files: libos.tex Log Message: Fix markup error that suppressed space. Closes SF bug #554257. Not relevant to older releases. Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** libos.tex 1 May 2002 03:31:42 -0000 1.84 --- libos.tex 10 May 2002 12:37:56 -0000 1.85 *************** *** 1194,1198 **** \begin{funcdesc}{waitpid}{pid, options} ! The details of this function differ on \UNIX and Windows. On \UNIX: --- 1194,1198 ---- \begin{funcdesc}{waitpid}{pid, options} ! The details of this function differ on \UNIX{} and Windows. On \UNIX: From gward@sourceforge.net Fri May 10 15:40:24 2002 From: gward@sourceforge.net (gward@sourceforge.net) Date: Fri, 10 May 2002 07:40:24 -0700 Subject: [Python-checkins] distutils/doc/dist dist.tex,1.38,1.39 Message-ID: Update of /cvsroot/python/distutils/doc/dist In directory usw-pr-cvs1:/tmp/cvs-serv25237 Modified Files: dist.tex Log Message: [from Oct 2000] Clarify explanations of header file search directories. Index: dist.tex =================================================================== RCS file: /cvsroot/python/distutils/doc/dist/dist.tex,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** dist.tex 8 May 2002 13:39:03 -0000 1.38 --- dist.tex 10 May 2002 14:40:22 -0000 1.39 *************** *** 506,526 **** You should avoid this sort of non-portable usage if you plan to ! distribute your code: it's probably better to write your code to include ! (e.g.) \code{}. If you need to include header files from some other Python extension, ! you can take advantage of the fact that the Distutils installs ! extension header files in a consistent way. For example, on a ! standard \UNIX{} installation the Numerical Python header files are ! installed to \file{/usr/local/include/python1.5/Numerical}. (The ! exact location will differ according to your platform and Python installation.) Since the Python include ! directory---\file{/usr/local/include/python1.5} in this case---is ! always included in the search path when building Python extensions, ! the best approach is to include (e.g.) ! \code{}. If you insist on putting the ! \file{Numerical} include directory right into your header search path, ! though, you can find that directory using the Distutils ! \module{sysconfig} module: \begin{verbatim} --- 506,530 ---- You should avoid this sort of non-portable usage if you plan to ! distribute your code: it's probably better to write C code like ! \begin{verbatim} ! #include ! \end{verbatim} If you need to include header files from some other Python extension, ! you can take advantage of the fact that header files are installed in a ! consistent way by the Distutils \command{install\_header} command. For ! example, the Numerical Python header files are installed (on a standard ! Unix installation) to \file{/usr/local/include/python1.5/Numerical}. ! (The exact location will differ according to your platform and Python installation.) Since the Python include ! directory---\file{/usr/local/include/python1.5} in this case---is always ! included in the search path when building Python extensions, the best ! approach is to write C code like ! \begin{verbatim} ! #include ! \end{verbatim} ! If you must put the \file{Numerical} include directory right into your ! header search path, though, you can find that directory using the ! Distutils \module{sysconfig} module: \begin{verbatim} From gward@sourceforge.net Fri May 10 15:42:12 2002 From: gward@sourceforge.net (gward@sourceforge.net) Date: Fri, 10 May 2002 07:42:12 -0700 Subject: [Python-checkins] distutils/doc/dist dist.tex,1.39,1.40 Message-ID: Update of /cvsroot/python/distutils/doc/dist In directory usw-pr-cvs1:/tmp/cvs-serv26086 Modified Files: dist.tex Log Message: [from Oct 2000] The zipfile module has been in the standard library for some time now. Index: dist.tex =================================================================== RCS file: /cvsroot/python/distutils/doc/dist/dist.tex,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** dist.tex 10 May 2002 14:40:22 -0000 1.39 --- dist.tex 10 May 2002 14:42:10 -0000 1.40 *************** *** 848,852 **** \item[(2)] default on \UNIX \item[(3)] requires either external \program{zip} utility or ! \module{zipfile} module (not part of the standard Python library) \item[(4)] requires external utilities: \program{tar} and possibly one of \program{gzip}, \program{bzip2}, or \program{compress} --- 848,853 ---- \item[(2)] default on \UNIX \item[(3)] requires either external \program{zip} utility or ! \module{zipfile} module (part of the standard Python library since ! Python~1.6) \item[(4)] requires external utilities: \program{tar} and possibly one of \program{gzip}, \program{bzip2}, or \program{compress} *************** *** 1099,1103 **** of \program{gzip}, \program{bzip2}, or \program{compress} \item[(4)] requires either external \program{zip} utility or ! \module{zipfile} module (not part of the standard Python library) \item[(5)] requires external \program{rpm} utility, version 3.0.4 or better (use \code{rpm --version} to find out which version you have) --- 1100,1105 ---- of \program{gzip}, \program{bzip2}, or \program{compress} \item[(4)] requires either external \program{zip} utility or ! \module{zipfile} module (part of the standard Python library since ! Python~1.6) \item[(5)] requires external \program{rpm} utility, version 3.0.4 or better (use \code{rpm --version} to find out which version you have) From gward@sourceforge.net Fri May 10 15:46:01 2002 From: gward@sourceforge.net (gward@sourceforge.net) Date: Fri, 10 May 2002 07:46:01 -0700 Subject: [Python-checkins] distutils/doc/dist dist.tex,1.40,1.41 Message-ID: Update of /cvsroot/python/distutils/doc/dist In directory usw-pr-cvs1:/tmp/cvs-serv27347 Modified Files: dist.tex Log Message: [from Oct 2000] Start fleshing out the "Examples" section. Index: dist.tex =================================================================== RCS file: /cvsroot/python/distutils/doc/dist/dist.tex,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** dist.tex 10 May 2002 14:42:10 -0000 1.40 --- dist.tex 10 May 2002 14:45:59 -0000 1.41 *************** *** 1292,1309 **** the \longprogramopt{no-target-optimize} option. ! %\section{Examples} ! %\label{examples} ! %\subsection{Pure Python distribution (by module)} ! %\label{pure-mod} ! %\subsection{Pure Python distribution (by package)} ! %\label{pure-pkg} ! %\subsection{Single extension module} ! %\label{single-ext} --- 1292,1503 ---- the \longprogramopt{no-target-optimize} option. ! \section{Examples} ! \label{examples} ! \subsection{Pure Python distribution (by module)} ! \label{pure-mod} + If you're just distributing a couple of modules, especially if they + don't live in a particular package, you can specify them individually + using the \option{py\_modules} option in the setup script. ! In the simplest case, you'll have two files to worry about: a setup ! script and the single module you're distributing, \file{foo.py} in this ! example: ! \begin{verbatim} ! / ! setup.py ! foo.py ! \end{verbatim} ! (In all diagrams in this section, \verb|| will refer to the ! distribution root directory.) A minimal setup script to describe this ! situation would be: ! \begin{verbatim} ! from distutils.core import setup ! setup(name = "foo", version = "1.0", ! py_modules = ["foo"]) ! \end{verbatim} ! Note that the name of the distribution is specified independently with ! the \option{name} option, and there's no rule that says it has to be the ! same as the name of the sole module in the distribution (although that's ! probably a good convention to follow). However, the distribution name ! is used to generate filenames, so you should stick to letters, digits, ! underscores, and hyphens. + Since \option{py\_modules} is a list, you can of course specify multiple + modules, eg. if you're distributing modules \module{foo} and + \module{bar}, your setup might look like this: + \begin{verbatim} + / + setup.py + foo.py + bar.py + \end{verbatim} + and the setup script might be + \begin{verbatim} + from distutils.core import setup + setup(name = "foobar", version = "1.0", + py_modules = ["foo", "bar"]) + \end{verbatim} ! You can put module source files into another directory, but if you have ! enough modules to do that, it's probably easier to specify modules by ! package rather than listing them individually. ! ! ! \subsection{Pure Python distribution (by package)} ! \label{pure-pkg} ! ! If you have more than a couple of modules to distribute, especially if ! they are in multiple packages, it's probably easier to specify whole ! packages rather than individual modules. This works even if your ! modules are not in a package; you can just tell the Distutils to process ! modules from the root package, and that works the same as any other ! package (except that you don't have to have an \file{\_\_init\_\_.py} ! file). ! ! The setup script from the last example could also be written as ! \begin{verbatim} ! from distutils.core import setup ! setup(name = "foobar", version = "1.0", ! packages = [""]) ! \end{verbatim} ! (The empty string stands for the root package.) ! ! If those two files are moved into a subdirectory, but remain in the root ! package, e.g.: ! \begin{verbatim} ! / ! setup.py ! src/ foo.py ! bar.py ! \end{verbatim} ! then you would still specify the root package, but you have to tell the ! Distutils where source files in the root package live: ! \begin{verbatim} ! from distutils.core import setup ! setup(name = "foobar", version = "1.0", ! package_dir = {"": "src"}, ! packages = [""]) ! \end{verbatim} ! ! More typically, though, you will want to distribute multiple modules in ! the same package (or in sub-packages). For example, if the \module{foo} ! and \module{bar} modules belong in package \module{foobar}, one way to ! layout your source tree is ! \begin{verbatim} ! / ! setup.py ! foobar/ ! __init__.py ! foo.py ! bar.py ! \end{verbatim} ! This is in fact the default layout expected by the Distutils, and the ! one that requires the least work to describe in your setup script: ! \begin{verbatim} ! from distutils.core import setup ! setup(name = "foobar", version = "1.0", ! packages = ["foobar"]) ! \end{verbatim} ! ! If you want to put modules in directories not named for their package, ! then you need to use the \option{package\_dir} option again. For ! example, if the \file{src} directory holds modules in the ! \module{foobar} package: ! \begin{verbatim} ! / ! setup.py ! src/ ! __init__.py ! foo.py ! bar.py ! \end{verbatim} ! an appropriate setup script would be ! \begin{verbatim} ! from distutils.core import setup ! setup(name = "foobar", version = "1.0", ! package_dir = {"foobar" : "src"}, ! packages = ["foobar"]) ! \end{verbatim} ! ! Or, you might put modules from your main package right in the ! distribution root: ! \begin{verbatim} ! / ! setup.py ! __init__.py ! foo.py ! bar.py ! \end{verbatim} ! in which case your setup script would be ! \begin{verbatim} ! from distutils.core import setup ! setup(name = "foobar", version = "1.0", ! package_dir = {"foobar" : ""}, ! packages = ["foobar"]) ! \end{verbatim} ! (The empty string also stands for the current directory.) ! ! If you have sub-packages, they must be explicitly listed in ! \option{packages}, but any entries in \option{package\_dir} ! automatically extend to sub-packages. (In other words, the Distutils ! does \emph{not} scan your source tree, trying to figure out which ! directories correspond to Python packages by looking for ! \file{\_\_init\_\_.py} files.) Thus, if the default layout grows a ! sub-package: ! \begin{verbatim} ! / ! setup.py ! foobar/ ! __init__.py ! foo.py ! bar.py ! subfoo/ ! __init__.py ! blah.py ! \end{verbatim} ! then the corresponding setup script would be ! \begin{verbatim} ! from distutils.core import setup ! setup(name = "foobar", version = "1.0", ! packages = ["foobar", "foobar.subfoo"]) ! \end{verbatim} ! (Again, the empty string in \option{package\_dir} stands for the current ! directory.) ! ! ! \subsection{Single extension module} ! \label{single-ext} ! ! Extension modules are specified using the \option{ext\_modules} option. ! \option{package\_dir} has no effect on where extension source files are ! found; it only affects the source for pure Python modules. The simplest ! case, a single extension module in a single C source file, is: ! \begin{verbatim} ! / ! setup.py ! foo.c ! \end{verbatim} ! If the \module{foo} extension belongs in the root package, the setup ! script for this could be ! \begin{verbatim} ! from distutils.core import setup ! setup(name = "foobar", version = "1.0", ! ext_modules = [Extension("foo", ["foo.c"])]) ! \end{verbatim} ! ! If the extension actually belongs in a package, say \module{foopkg}, ! then ! ! With exactly the same source tree layout, this extension can be put in ! the \module{foopkg} package simply by changing the name of the ! extension: ! \begin{verbatim} ! from distutils.core import setup ! setup(name = "foobar", version = "1.0", ! ext_modules = [Extension("foopkg.foo", ["foo.c"])]) ! \end{verbatim} *************** *** 1313,1317 **** %\subsection{Putting it all together} - --- 1507,1510 ---- From akuchling@sourceforge.net Fri May 10 22:00:08 2002 From: akuchling@sourceforge.net (akuchling@sourceforge.net) Date: Fri, 10 May 2002 14:00:08 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv18195 Modified Files: whatsnew23.tex Log Message: Give the enumerate() PEP a section of its own Add some credits Fill in a link Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** whatsnew23.tex 7 May 2002 21:01:16 -0000 1.12 --- whatsnew23.tex 10 May 2002 21:00:05 -0000 1.13 *************** *** 216,222 **** \end{seealso} %====================================================================== ! \section{PEP 285: The \class{bool} Type\label{section-bool}} A Boolean type was added to Python 2.3. Two new constants were added --- 216,257 ---- \end{seealso} + %====================================================================== ! \section{PEP 279: The \function{enumerate()} Built-in Function} ! ! A new built-in function, \function{enumerate()}, will make ! certain loops a bit clearer. \code{enumerate(thing)}, where ! \var{thing} is either an iterator or a sequence, returns a iterator ! that will return \code{(0, \var{thing[0]})}, \code{(1, ! \var{thing[1]})}, \code{(2, \var{thing[2]})}, and so forth. Fairly ! often you'll see code to change every element of a list that looks ! like this: + \begin{verbatim} + for i in range(len(L)): + item = L[i] + # ... compute some result based on item ... + L[i] = result + \end{verbatim} + + This can be rewritten using \function{enumerate()} as: + + \begin{verbatim} + for i, item in enumerate(L): + # ... compute some result based on item ... + L[i] = result + \end{verbatim} + + + \begin{seealso} + + \seepep{279}{The enumerate() built-in function}{Written + by Raymond D. Hettinger.} + + \end{seealso} + + + %====================================================================== + \section{PEP 285: The \class{bool} Type\label{section-bool}} A Boolean type was added to Python 2.3. Two new constants were added *************** *** 293,331 **** %====================================================================== ! \section{Other Language Changes} ! ! Here are the changes that Python 2.3 makes to the core language. ! ! \begin{itemize} ! \item The \keyword{yield} statement is now always a keyword, as ! described in section~\ref{section-generators}. ! ! \item Two new constants, \constant{True} and \constant{False} were ! added along with the built-in \class{bool} type, as described in ! section~\ref{section-bool}. ! ! \item A new built-in function, \function{enumerate()}, will make ! certain loops a bit clearer. \code{enumerate(thing)}, where ! \var{thing} is either an iterator or a sequence, returns a iterator ! that will return \code{(0, \var{thing[0]})}, \code{(1, ! \var{thing[1]})}, \code{(2, \var{thing[2]})}, and so forth. Fairly ! often you'll see code to change every element of a list that looks like this: ! \begin{verbatim} ! for i in range(len(L)): ! item = L[i] ! # ... compute some result based on item ... ! L[i] = result ! \end{verbatim} ! This can be rewritten using \function{enumerate()} as: ! \begin{verbatim} ! for i, item in enumerate(L): ! # ... compute some result based on item ... ! L[i] = result ! \end{verbatim} ! \end{itemize} --- 328,345 ---- %====================================================================== ! %\section{Other Language Changes} ! %Here are the changes that Python 2.3 makes to the core language. ! %\begin{itemize} ! %\item The \keyword{yield} statement is now always a keyword, as ! %described in section~\ref{section-generators}. ! %\item Two new constants, \constant{True} and \constant{False} were ! %added along with the built-in \class{bool} type, as described in ! %section~\ref{section-bool}. ! %\item ! %\end{itemize} *************** *** 387,391 **** \begin{seealso} ! \seeurl{XXX} {For the full details of the pymalloc implementation, see the comments at the top of the file \file{Objects/obmalloc.c} in the --- 401,405 ---- \begin{seealso} ! \seeurl{http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Objects/obmalloc.c} {For the full details of the pymalloc implementation, see the comments at the top of the file \file{Objects/obmalloc.c} in the *************** *** 492,496 **** now support using the \code{+=} assignment operator to add another array's contents, and the \code{*=} assignment operator to repeat an array. ! (Contributed by XXX.) \item The \module{grp} module now returns enhanced tuples: --- 506,510 ---- now support using the \code{+=} assignment operator to add another array's contents, and the \code{*=} assignment operator to repeat an array. ! (Contributed by Jason Orendorff.) \item The \module{grp} module now returns enhanced tuples: *************** *** 519,524 **** \item Python can now optionally be built as a shared library (\file{libpython2.3.so}) by supplying \longprogramopt{enable-shared} ! when running Python's \file{configure} script. (Contributed by XXX ! Patch \#527027) \item The \cfunction{PyArg_NoArgs()} macro is now deprecated, and code --- 533,538 ---- \item Python can now optionally be built as a shared library (\file{libpython2.3.so}) by supplying \longprogramopt{enable-shared} ! when running Python's \file{configure} script. (Contributed by Ondrej ! Palkovsky.) \item The \cfunction{PyArg_NoArgs()} macro is now deprecated, and code From jhylton@sourceforge.net Fri May 10 22:00:38 2002 From: jhylton@sourceforge.net (jhylton@sourceforge.net) Date: Fri, 10 May 2002 14:00:38 -0700 Subject: [Python-checkins] python/dist/src/Lib StringIO.py,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv18604 Modified Files: StringIO.py Log Message: Use isinstance() in preference to comparison of type by is. Index: StringIO.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/StringIO.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** StringIO.py 7 Apr 2002 06:36:22 -0000 1.22 --- StringIO.py 10 May 2002 21:00:35 -0000 1.23 *************** *** 40,44 **** def __init__(self, buf = ''): # Force self.buf to be a string or unicode ! if type(buf) is not types.UnicodeType: buf = str(buf) self.buf = buf --- 40,44 ---- def __init__(self, buf = ''): # Force self.buf to be a string or unicode ! if not isinstance(buf, types.UnicodeType): buf = str(buf) self.buf = buf *************** *** 139,143 **** if not s: return # Force s to be a string or unicode ! if type(s) is not types.UnicodeType: s = str(s) if self.pos > self.len: --- 139,143 ---- if not s: return # Force s to be a string or unicode ! if not isinstance(s, types.UnicodeType): s = str(s) if self.pos > self.len: From jackjansen@sourceforge.net Fri May 10 23:51:54 2002 From: jackjansen@sourceforge.net (jackjansen@sourceforge.net) Date: Fri, 10 May 2002 15:51:54 -0700 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf cfscan.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory usw-pr-cvs1:/tmp/cvs-serv16856/Python/Mac/Modules/cf Modified Files: cfscan.py Log Message: - Get data from CFData objects as Python strings and vv. - Started on supporting CFPropertyLists. Index: cfscan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/cfscan.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** cfscan.py 24 Mar 2002 23:01:44 -0000 1.7 --- cfscan.py 10 May 2002 22:51:52 -0000 1.8 *************** *** 16,19 **** --- 16,20 ---- "CFStringRef", "CFMutableStringRef", "CFURLRef", + ## "CFPropertyListRef", ) # ADD object typenames here *************** *** 32,36 **** ## "CFPlugIn.h", ## "CFPreferences.h", ! ## "CFPropertyList.h", ## "CFSet.h", "CFString.h", --- 33,37 ---- ## "CFPlugIn.h", ## "CFPreferences.h", ! "CFPropertyList.h", ## "CFSet.h", "CFString.h", *************** *** 131,134 **** --- 132,138 ---- [("OptionalCFURLRef", "*", "*")]), + # We handle CFPropertyListRef objects as plain CFTypeRef + ([("CFPropertyListRef", "*", "*")], + [("CFTypeRef", "*", "*")]), ] From jackjansen@sourceforge.net Fri May 10 23:52:00 2002 From: jackjansen@sourceforge.net (jackjansen@sourceforge.net) Date: Fri, 10 May 2002 15:52:00 -0700 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf cfsupport.py,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory usw-pr-cvs1:/tmp/cvs-serv16891/Python/Mac/Modules/cf Modified Files: cfsupport.py Log Message: - Get data from CFData objects as Python strings and vv. - Started on supporting CFPropertyLists. Index: cfsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/cfsupport.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** cfsupport.py 7 May 2002 22:59:58 -0000 1.15 --- cfsupport.py 10 May 2002 22:51:58 -0000 1.16 *************** *** 50,53 **** --- 50,54 ---- #include #include + #include #else #include *************** *** 196,199 **** --- 197,201 ---- CFURLRef = OpaqueByValueType("CFURLRef", "CFURLRefObj") OptionalCFURLRef = OpaqueByValueType("CFURLRef", "OptionalCFURLRefObj") + ##CFPropertyListRef = OpaqueByValueType("CFPropertyListRef", "CFTypeRefObj") # ADD object type here *************** *** 302,305 **** --- 304,319 ---- basechain = "&CFTypeRefObj_chain" + def outputCheckConvertArg(self): + Out(""" + if (v == Py_None) { *p_itself = NULL; return 1; } + if (PyString_Check(v)) { + char *cStr; + int cLen; + if( PyString_AsStringAndSize(v, &cStr, &cLen) < 0 ) return 0; + *p_itself = CFDataCreate((CFAllocatorRef)NULL, (unsigned char *)cStr, cLen); + return 1; + } + """) + def outputRepr(self): Output() *************** *** 491,494 **** --- 505,523 ---- return PyCF_CF2Python(_self->ob_itself); """ + + # Get data from CFDataRef + getasdata_body = """ + int size = CFDataGetLength(_self->ob_itself); + char *data = (char *)CFDataGetBytePtr(_self->ob_itself); + + _res = (PyObject *)PyString_FromStringAndSize(data, size); + return _res; + """ + + f = ManualGenerator("CFDataGetData", getasdata_body); + f.docstring = lambda: "() -> (string _rv)" + CFDataRef_object.add(f) + + f = ManualGenerator("toPython", toPython_body); From fdrake@sourceforge.net Sat May 11 04:36:28 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Fri, 10 May 2002 20:36:28 -0700 Subject: [Python-checkins] python/dist/src README,1.145,1.146 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv4498 Modified Files: README Log Message: Fix typo: ptread --> pthread Closes SF bug #554644. Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/README,v retrieving revision 1.145 retrieving revision 1.146 diff -C2 -d -r1.145 -r1.146 *** README 23 Apr 2002 13:06:07 -0000 1.145 --- README 11 May 2002 03:36:26 -0000 1.146 *************** *** 289,293 **** (The optimizer bug reported at this place in previous releases has been worked around by a minimal code change.) If you get ! errors about ptread_* functions, during compile or during testing, try setting CC to a thread-safe (reentrant) compiler, like "cc_r". For full C++ module support, set CC="xlC_r" (or --- 289,293 ---- (The optimizer bug reported at this place in previous releases has been worked around by a minimal code change.) If you get ! errors about pthread_* functions, during compile or during testing, try setting CC to a thread-safe (reentrant) compiler, like "cc_r". For full C++ module support, set CC="xlC_r" (or From fdrake@sourceforge.net Sat May 11 04:37:17 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Fri, 10 May 2002 20:37:17 -0700 Subject: [Python-checkins] python/dist/src README,1.136.4.4,1.136.4.5 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv4641 Modified Files: Tag: release22-maint README Log Message: Fix typo: ptread --> pthread Closes SF bug #554644. Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/README,v retrieving revision 1.136.4.4 retrieving revision 1.136.4.5 diff -C2 -d -r1.136.4.4 -r1.136.4.5 *** README 25 Mar 2002 13:15:52 -0000 1.136.4.4 --- README 11 May 2002 03:37:15 -0000 1.136.4.5 *************** *** 289,293 **** (The optimizer bug reported at this place in previous releases has been worked around by a minimal code change.) If you get ! errors about ptread_* functions, during compile or during testing, try setting CC to a thread-safe (reentrant) compiler, like "cc_r". For full C++ module support, set CC="xlC_r" (or --- 289,293 ---- (The optimizer bug reported at this place in previous releases has been worked around by a minimal code change.) If you get ! errors about pthread_* functions, during compile or during testing, try setting CC to a thread-safe (reentrant) compiler, like "cc_r". For full C++ module support, set CC="xlC_r" (or From fdrake@sourceforge.net Sat May 11 04:38:01 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Fri, 10 May 2002 20:38:01 -0700 Subject: [Python-checkins] python/dist/src README,1.122.2.7,1.122.2.8 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv4746 Modified Files: Tag: release21-maint README Log Message: Fix typo: ptread --> pthread Closes SF bug #554644. Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/README,v retrieving revision 1.122.2.7 retrieving revision 1.122.2.8 diff -C2 -d -r1.122.2.7 -r1.122.2.8 *** README 8 Apr 2002 06:05:47 -0000 1.122.2.7 --- README 11 May 2002 03:37:59 -0000 1.122.2.8 *************** *** 271,275 **** (The optimizer bug reported at this place in previous releases has been worked around by a minimal code change.) If you get ! errors about ptread_* functions, during compile or during testing, try setting CC to a thread-safe (reentrant) compiler, like "cc_r". For full C++ module support, set CC="xlC_r" (or --- 271,275 ---- (The optimizer bug reported at this place in previous releases has been worked around by a minimal code change.) If you get ! errors about pthread_* functions, during compile or during testing, try setting CC to a thread-safe (reentrant) compiler, like "cc_r". For full C++ module support, set CC="xlC_r" (or From rhettinger@sourceforge.net Sun May 12 04:09:28 2002 From: rhettinger@sourceforge.net (rhettinger@sourceforge.net) Date: Sat, 11 May 2002 20:09:28 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref3.tex,1.87,1.88 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv9015 Modified Files: ref3.tex Log Message: Closes SF patch: 552468. Type class unification invalidated the statement: x.__getitem__[i] is not equivalent to x[i]. Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -d -r1.87 -r1.88 *** ref3.tex 16 Apr 2002 02:03:05 -0000 1.87 --- ref3.tex 12 May 2002 03:09:25 -0000 1.88 *************** *** 898,905 **** a method named \method{__getitem__()}, and \code{x} is an instance of this class, then \code{x[i]} is equivalent to ! \code{x.__getitem__(i)}. (The reverse is not true --- if \code{x} is ! a list object, \code{x.__getitem__(i)} is not equivalent to ! \code{x[i]}.) Except where mentioned, attempts to execute an ! operation raise an exception when no appropriate method is defined. \withsubitem{(mapping object method)}{\ttindex{__getitem__()}} --- 898,903 ---- a method named \method{__getitem__()}, and \code{x} is an instance of this class, then \code{x[i]} is equivalent to ! \code{x.__getitem__(i)}. Except where mentioned, attempts to execute ! an operation raise an exception when no appropriate method is defined. \withsubitem{(mapping object method)}{\ttindex{__getitem__()}} From rhettinger@sourceforge.net Sun May 12 06:53:54 2002 From: rhettinger@sourceforge.net (rhettinger@sourceforge.net) Date: Sat, 11 May 2002 22:53:54 -0700 Subject: [Python-checkins] python/dist/src/Lib ftplib.py,1.67,1.68 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv7734 Modified Files: ftplib.py Log Message: Closes SF patch 553277. Per GvR, reverting to original patch -- the way to test if 'callable' has not been supplied is to test for None instead of False. The previous correction to 'if callable()' was wrong because an unusable callback would be ignored rather than raising an exception. Index: ftplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ftplib.py,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** ftplib.py 8 May 2002 08:56:33 -0000 1.67 --- ftplib.py 12 May 2002 05:53:51 -0000 1.68 *************** *** 393,397 **** with trailing CRLF stripped. This creates a new port for you. print_line() is the default callback.''' ! if not callable(callback): callback = print_line resp = self.sendcmd('TYPE A') conn = self.transfercmd(cmd) --- 393,397 ---- with trailing CRLF stripped. This creates a new port for you. print_line() is the default callback.''' ! if callback is None: callback = print_line resp = self.sendcmd('TYPE A') conn = self.transfercmd(cmd) From rhettinger@sourceforge.net Sun May 12 07:07:24 2002 From: rhettinger@sourceforge.net (rhettinger@sourceforge.net) Date: Sat, 11 May 2002 23:07:24 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.405,1.406 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv10707 Modified Files: NEWS Log Message: Noted change in ftplib 1.68 closing SF patch 553277. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.405 retrieving revision 1.406 diff -C2 -d -r1.405 -r1.406 *** NEWS 8 May 2002 14:14:41 -0000 1.405 --- NEWS 12 May 2002 06:07:21 -0000 1.406 *************** *** 103,106 **** --- 103,113 ---- Library + - ftplib.retrlines() now tests for callback is None rather than testing + for False. Was causing an error when given a callback object which + was callable but also returned len() as zero. The change may + create new breakage if the caller relied on the undocumented behavior + and called with callback set to [] or some other False value not + identical to None. + - random.gauss() uses a piece of hidden state used by nothing else, and the .seed() and .whseed() methods failed to reset it. In other From tim_one@sourceforge.net Sun May 12 08:19:40 2002 From: tim_one@sourceforge.net (tim_one@sourceforge.net) Date: Sun, 12 May 2002 00:19:40 -0700 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c,2.254,2.255 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv21915/python/Python Modified Files: bltinmodule.c Log Message: SF bug 555042: zip() may trigger MemoryError. NOT a bugfix candidate: this is a fix to an optimization introduced in 2.3. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.254 retrieving revision 2.255 diff -C2 -d -r2.254 -r2.255 *** bltinmodule.c 29 Apr 2002 21:27:32 -0000 2.254 --- bltinmodule.c 12 May 2002 07:19:38 -0000 2.255 *************** *** 1718,1728 **** assert(PyTuple_Check(args)); ! /* Guess at result length: the shortest of the input lengths. */ len = -1; /* unknown */ for (i = 0; i < itemsize; ++i) { PyObject *item = PyTuple_GET_ITEM(args, i); int thislen = PySequence_Length(item); ! if (thislen < 0) PyErr_Clear(); else if (len < 0 || thislen < len) len = thislen; --- 1718,1733 ---- assert(PyTuple_Check(args)); ! /* Guess at result length: the shortest of the input lengths. ! If some argument refuses to say, we refuse to guess too, lest ! an argument like xrange(sys.maxint) lead us astray.*/ len = -1; /* unknown */ for (i = 0; i < itemsize; ++i) { PyObject *item = PyTuple_GET_ITEM(args, i); int thislen = PySequence_Length(item); ! if (thislen < 0) { PyErr_Clear(); + len = -1; + break; + } else if (len < 0 || thislen < len) len = thislen; From tim_one@sourceforge.net Sun May 12 08:19:40 2002 From: tim_one@sourceforge.net (tim_one@sourceforge.net) Date: Sun, 12 May 2002 00:19:40 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_b2.py,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv21915/python/Lib/test Modified Files: test_b2.py Log Message: SF bug 555042: zip() may trigger MemoryError. NOT a bugfix candidate: this is a fix to an optimization introduced in 2.3. Index: test_b2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b2.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** test_b2.py 2 May 2002 18:40:31 -0000 1.33 --- test_b2.py 12 May 2002 07:19:37 -0000 1.34 *************** *** 345,350 **** raise TestFailed, 'zip(a, b) - missing expected TypeError' # Epilogue -- unlink the temp file - unlink(TESTFN) --- 345,360 ---- raise TestFailed, 'zip(a, b) - missing expected TypeError' + # Make sure zip doesn't try to allocate a billion elements for the + # result list when one of its arguments doesn't say how long it is. + # A MemoryError is the most likely failure mode. + class SequenceWithoutALength: + def __getitem__(self, i): + if i == 5: + raise IndexError + else: + return i + vereq(zip(SequenceWithoutALength(), xrange(2**30)), + list(enumerate(range(5)))) # Epilogue -- unlink the temp file unlink(TESTFN) From rhettinger@sourceforge.net Sun May 12 18:20:41 2002 From: rhettinger@sourceforge.net (rhettinger@sourceforge.net) Date: Sun, 12 May 2002 10:20:41 -0700 Subject: [Python-checkins] python/dist/src/Objects floatobject.c,2.110.6.1,2.110.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv30199 Modified Files: Tag: release22-maint floatobject.c Log Message: Close SF bug 551673. Backport Skip Montanaro's checkin of 2.112. Clarifies message when raising TypeError to indicate that float() accepts strings or numbers. Index: floatobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v retrieving revision 2.110.6.1 retrieving revision 2.110.6.2 diff -C2 -d -r2.110.6.1 -r2.110.6.2 *** floatobject.c 11 Mar 2002 10:17:17 -0000 2.110.6.1 --- floatobject.c 12 May 2002 17:20:38 -0000 2.110.6.2 *************** *** 124,128 **** else if (PyObject_AsCharBuffer(v, &s, &len)) { PyErr_SetString(PyExc_TypeError, ! "float() needs a string argument"); return NULL; } --- 124,128 ---- else if (PyObject_AsCharBuffer(v, &s, &len)) { PyErr_SetString(PyExc_TypeError, ! "float() argument must be a string or a number"); return NULL; } From bwarsaw@sourceforge.net Sun May 12 18:37:50 2002 From: bwarsaw@sourceforge.net (bwarsaw@sourceforge.net) Date: Sun, 12 May 2002 10:37:50 -0700 Subject: [Python-checkins] python/dist/src/Misc python-mode.el,4.20,4.21 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv3313 Modified Files: python-mode.el Log Message: (py-execute-region): Do the blank line skipping inside the save-excursion so that when the function is complete, point is preserved. Index: python-mode.el =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/python-mode.el,v retrieving revision 4.20 retrieving revision 4.21 diff -C2 -d -r4.20 -r4.21 *** python-mode.el 30 Apr 2002 18:58:52 -0000 4.20 --- python-mode.el 12 May 2002 17:37:46 -0000 4.21 *************** *** 1496,1507 **** (interactive "r\nP") ;; Skip ahead to the first non-blank line - (goto-char start) - (beginning-of-line) - (while (and (looking-at "\\s *$") - (< (point) end)) - (forward-line 1)) - (setq start (point)) - (or (< start end) - (error "Region is empty")) (let* ((proc (get-process py-which-bufname)) (temp (if (memq 'broken-temp-names py-emacs-features) --- 1496,1499 ---- *************** *** 1521,1524 **** --- 1513,1523 ---- (save-excursion (goto-char start) + (beginning-of-line) + (while (and (looking-at "\\s *$") + (< (point) end)) + (forward-line 1)) + (setq start (point)) + (or (< start end) + (error "Region is empty")) (let ((needs-if (/= (py-point 'bol) (py-point 'boi)))) (set-buffer buf) From jackjansen@sourceforge.net Sun May 12 23:03:58 2002 From: jackjansen@sourceforge.net (jackjansen@sourceforge.net) Date: Sun, 12 May 2002 15:03:58 -0700 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf _CFmodule.c,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory usw-pr-cvs1:/tmp/cvs-serv2922/Python/Mac/Modules/cf Modified Files: _CFmodule.c Log Message: - Better exception when a NULL CF object is encountered. - Manually generate a routine with funny error semantics. Index: _CFmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/_CFmodule.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** _CFmodule.c 7 May 2002 22:59:53 -0000 1.13 --- _CFmodule.c 12 May 2002 22:03:56 -0000 1.14 *************** *** 28,31 **** --- 28,32 ---- #include #include + #include #else #include *************** *** 138,142 **** { CFTypeRefObject *it; ! if (itself == NULL) return PyMac_Error(resNotFound); it = PyObject_NEW(CFTypeRefObject, &CFTypeRef_Type); if (it == NULL) return NULL; --- 139,147 ---- { CFTypeRefObject *it; ! if (itself == NULL) ! { ! PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); ! return NULL; ! } it = PyObject_NEW(CFTypeRefObject, &CFTypeRef_Type); if (it == NULL) return NULL; *************** *** 276,279 **** --- 281,313 ---- } + static PyObject *CFTypeRefObj_CFPropertyListCreateXMLData(CFTypeRefObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + CFDataRef _rv; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = CFPropertyListCreateXMLData((CFAllocatorRef)NULL, + _self->ob_itself); + _res = Py_BuildValue("O&", + CFDataRefObj_New, _rv); + return _res; + } + + static PyObject *CFTypeRefObj_CFPropertyListCreateDeepCopy(CFTypeRefObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + CFTypeRef _rv; + CFOptionFlags mutabilityOption; + if (!PyArg_ParseTuple(_args, "l", + &mutabilityOption)) + return NULL; + _rv = CFPropertyListCreateDeepCopy((CFAllocatorRef)NULL, + _self->ob_itself, + mutabilityOption); + _res = Py_BuildValue("O&", + CFTypeRefObj_New, _rv); + return _res; + } + static PyObject *CFTypeRefObj_CFShow(CFTypeRefObject *_self, PyObject *_args) { *************** *** 290,293 **** --- 324,353 ---- } + static PyObject *CFTypeRefObj_CFPropertyListCreateFromXMLData(CFTypeRefObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + + CFTypeRef _rv; + CFOptionFlags mutabilityOption; + CFStringRef errorString; + if (!PyArg_ParseTuple(_args, "l", + &mutabilityOption)) + return NULL; + _rv = CFPropertyListCreateFromXMLData((CFAllocatorRef)NULL, + _self->ob_itself, + mutabilityOption, + &errorString); + if (errorString) + CFRelease(errorString); + if (_rv == NULL) { + PyErr_SetString(PyExc_RuntimeError, "Parse error in XML data"); + return NULL; + } + _res = Py_BuildValue("O&", + CFTypeRefObj_New, _rv); + return _res; + + } + static PyObject *CFTypeRefObj_toPython(CFTypeRefObject *_self, PyObject *_args) { *************** *** 313,318 **** --- 373,384 ---- {"CFCopyDescription", (PyCFunction)CFTypeRefObj_CFCopyDescription, 1, "() -> (CFStringRef _rv)"}, + {"CFPropertyListCreateXMLData", (PyCFunction)CFTypeRefObj_CFPropertyListCreateXMLData, 1, + "() -> (CFDataRef _rv)"}, + {"CFPropertyListCreateDeepCopy", (PyCFunction)CFTypeRefObj_CFPropertyListCreateDeepCopy, 1, + "(CFOptionFlags mutabilityOption) -> (CFTypeRef _rv)"}, {"CFShow", (PyCFunction)CFTypeRefObj_CFShow, 1, "() -> None"}, + {"CFPropertyListCreateFromXMLData", (PyCFunction)CFTypeRefObj_CFPropertyListCreateFromXMLData, 1, + "(CFOptionFlags mutabilityOption) -> (CFTypeRefObj)"}, {"toPython", (PyCFunction)CFTypeRefObj_toPython, 1, "() -> (python_object)"}, *************** *** 387,391 **** { CFArrayRefObject *it; ! if (itself == NULL) return PyMac_Error(resNotFound); it = PyObject_NEW(CFArrayRefObject, &CFArrayRef_Type); if (it == NULL) return NULL; --- 453,461 ---- { CFArrayRefObject *it; ! if (itself == NULL) ! { ! PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); ! return NULL; ! } it = PyObject_NEW(CFArrayRefObject, &CFArrayRef_Type); if (it == NULL) return NULL; *************** *** 539,543 **** { CFMutableArrayRefObject *it; ! if (itself == NULL) return PyMac_Error(resNotFound); it = PyObject_NEW(CFMutableArrayRefObject, &CFMutableArrayRef_Type); if (it == NULL) return NULL; --- 609,617 ---- { CFMutableArrayRefObject *it; ! if (itself == NULL) ! { ! PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); ! return NULL; ! } it = PyObject_NEW(CFMutableArrayRefObject, &CFMutableArrayRef_Type); if (it == NULL) return NULL; *************** *** 720,724 **** { CFDictionaryRefObject *it; ! if (itself == NULL) return PyMac_Error(resNotFound); it = PyObject_NEW(CFDictionaryRefObject, &CFDictionaryRef_Type); if (it == NULL) return NULL; --- 794,802 ---- { CFDictionaryRefObject *it; ! if (itself == NULL) ! { ! PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); ! return NULL; ! } it = PyObject_NEW(CFDictionaryRefObject, &CFDictionaryRef_Type); if (it == NULL) return NULL; *************** *** 854,858 **** { CFMutableDictionaryRefObject *it; ! if (itself == NULL) return PyMac_Error(resNotFound); it = PyObject_NEW(CFMutableDictionaryRefObject, &CFMutableDictionaryRef_Type); if (it == NULL) return NULL; --- 932,940 ---- { CFMutableDictionaryRefObject *it; ! if (itself == NULL) ! { ! PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); ! return NULL; ! } it = PyObject_NEW(CFMutableDictionaryRefObject, &CFMutableDictionaryRef_Type); if (it == NULL) return NULL; *************** *** 972,976 **** { CFDataRefObject *it; ! if (itself == NULL) return PyMac_Error(resNotFound); it = PyObject_NEW(CFDataRefObject, &CFDataRef_Type); if (it == NULL) return NULL; --- 1054,1062 ---- { CFDataRefObject *it; ! if (itself == NULL) ! { ! PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); ! return NULL; ! } it = PyObject_NEW(CFDataRefObject, &CFDataRef_Type); if (it == NULL) return NULL; *************** *** 983,987 **** if (v == Py_None) { *p_itself = NULL; return 1; } ! /* Check for other CF objects here */ if (!CFDataRefObj_Check(v)) --- 1069,1079 ---- if (v == Py_None) { *p_itself = NULL; return 1; } ! if (PyString_Check(v)) { ! char *cStr; ! int cLen; ! if( PyString_AsStringAndSize(v, &cStr, &cLen) < 0 ) return 0; ! *p_itself = CFDataCreate((CFAllocatorRef)NULL, (unsigned char *)cStr, cLen); ! return 1; ! } if (!CFDataRefObj_Check(v)) *************** *** 1047,1050 **** --- 1139,1154 ---- } + static PyObject *CFDataRefObj_CFDataGetData(CFDataRefObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + + int size = CFDataGetLength(_self->ob_itself); + char *data = (char *)CFDataGetBytePtr(_self->ob_itself); + + _res = (PyObject *)PyString_FromStringAndSize(data, size); + return _res; + + } + static PyMethodDef CFDataRefObj_methods[] = { {"CFDataCreateCopy", (PyCFunction)CFDataRefObj_CFDataCreateCopy, 1, *************** *** 1054,1057 **** --- 1158,1163 ---- {"CFStringCreateFromExternalRepresentation", (PyCFunction)CFDataRefObj_CFStringCreateFromExternalRepresentation, 1, "(CFStringEncoding encoding) -> (CFStringRef _rv)"}, + {"CFDataGetData", (PyCFunction)CFDataRefObj_CFDataGetData, 1, + "() -> (string _rv)"}, {NULL, NULL, 0} }; *************** *** 1124,1128 **** { CFMutableDataRefObject *it; ! if (itself == NULL) return PyMac_Error(resNotFound); it = PyObject_NEW(CFMutableDataRefObject, &CFMutableDataRef_Type); if (it == NULL) return NULL; --- 1230,1238 ---- { CFMutableDataRefObject *it; ! if (itself == NULL) ! { ! PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); ! return NULL; ! } it = PyObject_NEW(CFMutableDataRefObject, &CFMutableDataRef_Type); if (it == NULL) return NULL; *************** *** 1330,1334 **** { CFStringRefObject *it; ! if (itself == NULL) return PyMac_Error(resNotFound); it = PyObject_NEW(CFStringRefObject, &CFStringRef_Type); if (it == NULL) return NULL; --- 1440,1448 ---- { CFStringRefObject *it; ! if (itself == NULL) ! { ! PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); ! return NULL; ! } it = PyObject_NEW(CFStringRefObject, &CFStringRef_Type); if (it == NULL) return NULL; *************** *** 2011,2015 **** { CFMutableStringRefObject *it; ! if (itself == NULL) return PyMac_Error(resNotFound); it = PyObject_NEW(CFMutableStringRefObject, &CFMutableStringRef_Type); if (it == NULL) return NULL; --- 2125,2133 ---- { CFMutableStringRefObject *it; ! if (itself == NULL) ! { ! PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); ! return NULL; ! } it = PyObject_NEW(CFMutableStringRefObject, &CFMutableStringRef_Type); if (it == NULL) return NULL; *************** *** 2340,2344 **** { CFURLRefObject *it; ! if (itself == NULL) return PyMac_Error(resNotFound); it = PyObject_NEW(CFURLRefObject, &CFURLRef_Type); if (it == NULL) return NULL; --- 2458,2466 ---- { CFURLRefObject *it; ! if (itself == NULL) ! { ! PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); ! return NULL; ! } it = PyObject_NEW(CFURLRefObject, &CFURLRef_Type); if (it == NULL) return NULL; From jackjansen@sourceforge.net Sun May 12 23:04:03 2002 From: jackjansen@sourceforge.net (jackjansen@sourceforge.net) Date: Sun, 12 May 2002 15:04:03 -0700 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf cfscan.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory usw-pr-cvs1:/tmp/cvs-serv2964/Python/Mac/Modules/cf Modified Files: cfscan.py Log Message: - Better exception when a NULL CF object is encountered. - Manually generate a routine with funny error semantics. Index: cfscan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/cfscan.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** cfscan.py 10 May 2002 22:51:52 -0000 1.8 --- cfscan.py 12 May 2002 22:04:01 -0000 1.9 *************** *** 98,101 **** --- 98,102 ---- "CFStringGetCharacterAtIndex", # No format for single unichars yet. "kCFStringEncodingInvalidId", # incompatible constant declaration + "CFPropertyListCreateFromXMLData", # Manually generated ] From jackjansen@sourceforge.net Sun May 12 23:04:16 2002 From: jackjansen@sourceforge.net (jackjansen@sourceforge.net) Date: Sun, 12 May 2002 15:04:16 -0700 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf cfsupport.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory usw-pr-cvs1:/tmp/cvs-serv3036/Python/Mac/Modules/cf Modified Files: cfsupport.py Log Message: - Better exception when a NULL CF object is encountered. - Manually generate a routine with funny error semantics. Index: cfsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/cfsupport.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** cfsupport.py 10 May 2002 22:51:58 -0000 1.16 --- cfsupport.py 12 May 2002 22:04:14 -0000 1.17 *************** *** 204,208 **** class MyGlobalObjectDefinition(GlobalObjectDefinition): def outputCheckNewArg(self): ! Output("if (itself == NULL) return PyMac_Error(resNotFound);") def outputStructMembers(self): GlobalObjectDefinition.outputStructMembers(self) --- 204,212 ---- class MyGlobalObjectDefinition(GlobalObjectDefinition): def outputCheckNewArg(self): ! Output('if (itself == NULL)') ! OutLbrace() ! Output('PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");') ! Output('return NULL;') ! OutRbrace() def outputStructMembers(self): GlobalObjectDefinition.outputStructMembers(self) *************** *** 502,509 **** CFStringRef_object.add(f) - toPython_body = """ - return PyCF_CF2Python(_self->ob_itself); - """ - # Get data from CFDataRef getasdata_body = """ --- 506,509 ---- *************** *** 519,523 **** --- 519,552 ---- CFDataRef_object.add(f) + # Manual generator for CFPropertyListCreateFromXMLData because of funny error return + fromxml_body = """ + CFTypeRef _rv; + CFOptionFlags mutabilityOption; + CFStringRef errorString; + if (!PyArg_ParseTuple(_args, "l", + &mutabilityOption)) + return NULL; + _rv = CFPropertyListCreateFromXMLData((CFAllocatorRef)NULL, + _self->ob_itself, + mutabilityOption, + &errorString); + if (errorString) + CFRelease(errorString); + if (_rv == NULL) { + PyErr_SetString(PyExc_RuntimeError, "Parse error in XML data"); + return NULL; + } + _res = Py_BuildValue("O&", + CFTypeRefObj_New, _rv); + return _res; + """ + f = ManualGenerator("CFPropertyListCreateFromXMLData", fromxml_body) + f.docstring = lambda: "(CFOptionFlags mutabilityOption) -> (CFTypeRefObj)" + CFTypeRef_object.add(f) + # Convert CF objects to Python objects + toPython_body = """ + return PyCF_CF2Python(_self->ob_itself); + """ f = ManualGenerator("toPython", toPython_body); From rhettinger@sourceforge.net Mon May 13 04:52:49 2002 From: rhettinger@sourceforge.net (rhettinger@sourceforge.net) Date: Sun, 12 May 2002 20:52:49 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libmath.tex,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv4765 Modified Files: libmath.tex Log Message: Added degrees() and radians() to mathmodule. Closing patch 552452 and feature request 426539. Index: libmath.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmath.tex,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** libmath.tex 18 Dec 2000 13:50:24 -0000 1.25 --- libmath.tex 13 May 2002 03:52:47 -0000 1.26 *************** *** 48,51 **** --- 48,55 ---- \end{funcdesc} + \begin{funcdesc}{degrees}{x} + Converts angle \var{x} from radians to degrees. + \end{funcdesc} + \begin{funcdesc}{exp}{x} Return \code{e**\var{x}}. *************** *** 98,101 **** --- 102,109 ---- \begin{funcdesc}{pow}{x, y} Return \code{\var{x}**\var{y}}. + \end{funcdesc} + + \begin{funcdesc}{radians}{x} + Converts angle \var{x} from degrees to radians. \end{funcdesc} From rhettinger@sourceforge.net Mon May 13 04:55:03 2002 From: rhettinger@sourceforge.net (rhettinger@sourceforge.net) Date: Sun, 12 May 2002 20:55:03 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_math.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv5200 Modified Files: test_math.py Log Message: Adds tests for degrees() and radians() functions added to mathmodule. Closes patch 552452 and feature request 426539. Index: test_math.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_math.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** test_math.py 5 Sep 2001 22:36:56 -0000 1.13 --- test_math.py 13 May 2002 03:55:01 -0000 1.14 *************** *** 58,61 **** --- 58,66 ---- testit('cosh(2)-2*cosh(1)**2', math.cosh(2)-2*math.cosh(1)**2, -1) # Thanks to Lambert + print 'degrees' + testit('degrees(pi)', math.degrees(math.pi), 180.0) + testit('degrees(pi/2)', math.degrees(math.pi/2), 90.0) + testit('degrees(-pi/4)', math.degrees(-math.pi/4), -45.0) + print 'exp' testit('exp(-1)', math.exp(-1), 1/math.e) *************** *** 129,132 **** --- 134,142 ---- testit('pow(2,1)', math.pow(2,1), 2) testit('pow(2,-1)', math.pow(2,-1), 0.5) + + print 'radians' + testit('radians(180)', math.radians(180), math.pi) + testit('radians(90)', math.radians(90), math.pi/2) + testit('radians(-45)', math.radians(-45), -math.pi/4) print 'sin' From rhettinger@sourceforge.net Mon May 13 04:56:13 2002 From: rhettinger@sourceforge.net (rhettinger@sourceforge.net) Date: Sun, 12 May 2002 20:56:13 -0700 Subject: [Python-checkins] python/dist/src/Modules mathmodule.c,2.66,2.67 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv5484 Modified Files: mathmodule.c Log Message: Added degrees() and radians() to mathmodule. Closes patch 552452 and feature request 426539. Index: mathmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mathmodule.c,v retrieving revision 2.66 retrieving revision 2.67 diff -C2 -d -r2.66 -r2.67 *** mathmodule.c 6 Sep 2001 08:16:17 -0000 2.66 --- mathmodule.c 13 May 2002 03:56:10 -0000 2.67 *************** *** 275,278 **** --- 275,303 ---- "log10(x) -> the base 10 logarithm of x."; + static const double degToRad = 3.141592653589793238462643383 / 180.0; + + static PyObject * + math_degrees(PyObject *self, PyObject *args) + { + double x; + if (! PyArg_ParseTuple(args, "d:degrees", &x)) + return NULL; + return PyFloat_FromDouble(x / degToRad); + } + + static char math_degrees_doc[] = + "degrees(x) -> converts angle x from radians to degrees"; + + static PyObject * + math_radians(PyObject *self, PyObject *args) + { + double x; + if (! PyArg_ParseTuple(args, "d:radians", &x)) + return NULL; + return PyFloat_FromDouble(x * degToRad); + } + + static char math_radians_doc[] = + "radians(x) -> converts angle x from degrees to radians"; static PyMethodDef math_methods[] = { *************** *** 284,287 **** --- 309,313 ---- {"cos", math_cos, METH_VARARGS, math_cos_doc}, {"cosh", math_cosh, METH_VARARGS, math_cosh_doc}, + {"degrees", math_degrees, METH_VARARGS, math_degrees_doc}, {"exp", math_exp, METH_VARARGS, math_exp_doc}, {"fabs", math_fabs, METH_VARARGS, math_fabs_doc}, *************** *** 295,298 **** --- 321,325 ---- {"modf", math_modf, METH_VARARGS, math_modf_doc}, {"pow", math_pow, METH_VARARGS, math_pow_doc}, + {"radians", math_radians, METH_VARARGS, math_radians_doc}, {"sin", math_sin, METH_VARARGS, math_sin_doc}, {"sinh", math_sinh, METH_VARARGS, math_sinh_doc}, From rhettinger@sourceforge.net Mon May 13 05:17:34 2002 From: rhettinger@sourceforge.net (rhettinger@sourceforge.net) Date: Sun, 12 May 2002 21:17:34 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.406,1.407 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv8720 Modified Files: NEWS Log Message: Noted SF patch 552452 adding degree/radian conversions to mathmodule.c. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.406 retrieving revision 1.407 diff -C2 -d -r1.406 -r1.407 *** NEWS 12 May 2002 06:07:21 -0000 1.406 --- NEWS 13 May 2002 04:17:32 -0000 1.407 *************** *** 103,106 **** --- 103,108 ---- Library + - added degree/radian conversion functions to the math module. + - ftplib.retrlines() now tests for callback is None rather than testing for False. Was causing an error when given a callback object which From rhettinger@sourceforge.net Mon May 13 08:55:31 2002 From: rhettinger@sourceforge.net (rhettinger@sourceforge.net) Date: Mon, 13 May 2002 00:55:31 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref3.tex,1.82.4.1,1.82.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv29042 Modified Files: Tag: release22-maint ref3.tex Log Message: Backport ver 1.88 correction noting that lists now support .__getitem__(). Closes SF bug 548874 and patch 552468. Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.82.4.1 retrieving revision 1.82.4.2 diff -C2 -d -r1.82.4.1 -r1.82.4.2 *** ref3.tex 16 Apr 2002 02:03:31 -0000 1.82.4.1 --- ref3.tex 13 May 2002 07:55:24 -0000 1.82.4.2 *************** *** 883,890 **** a method named \method{__getitem__()}, and \code{x} is an instance of this class, then \code{x[i]} is equivalent to ! \code{x.__getitem__(i)}. (The reverse is not true --- if \code{x} is ! a list object, \code{x.__getitem__(i)} is not equivalent to ! \code{x[i]}.) Except where mentioned, attempts to execute an ! operation raise an exception when no appropriate method is defined. \withsubitem{(mapping object method)}{\ttindex{__getitem__()}} --- 883,888 ---- a method named \method{__getitem__()}, and \code{x} is an instance of this class, then \code{x[i]} is equivalent to ! \code{x.__getitem__(i)}. Except where mentioned, attempts to execute ! an operation raise an exception when no appropriate method is defined. \withsubitem{(mapping object method)}{\ttindex{__getitem__()}} From doerwalter@sourceforge.net Mon May 13 10:00:46 2002 From: doerwalter@sourceforge.net (doerwalter@sourceforge.net) Date: Mon, 13 May 2002 02:00:46 -0700 Subject: [Python-checkins] python/dist/src/Objects stringobject.c,2.161,2.162 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv14122/Objects Modified Files: stringobject.c Log Message: Add #ifdef PY_USING_UNICODE sections, so that stringobject.c compiles again with --disable-unicode. Fixes SF bug http://www.python.org/sf/554912 Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.161 retrieving revision 2.162 diff -C2 -d -r2.161 -r2.162 *** stringobject.c 27 Apr 2002 18:44:32 -0000 2.161 --- stringobject.c 13 May 2002 09:00:41 -0000 2.162 *************** *** 1458,1461 **** --- 1458,1462 ---- if (PyString_Check(sep)) return do_xstrip(self, striptype, sep); + #ifdef Py_USING_UNICODE else if (PyUnicode_Check(sep)) { PyObject *uniself = PyUnicode_FromObject((PyObject *)self); *************** *** 1468,1474 **** --- 1469,1480 ---- return res; } + #endif else { PyErr_Format(PyExc_TypeError, + #ifdef Py_USING_UNICODE "%s arg must be None, str or unicode", + #else + "%s arg must be None or str", + #endif STRIPNAME(striptype)); return NULL; From doerwalter@sourceforge.net Mon May 13 10:11:47 2002 From: doerwalter@sourceforge.net (doerwalter@sourceforge.net) Date: Mon, 13 May 2002 02:11:47 -0700 Subject: [Python-checkins] python/dist/src/Objects stringobject.c,2.147.6.4,2.147.6.5 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv18221/Objects Modified Files: Tag: release22-maint stringobject.c Log Message: Backport checkin: Add #ifdef PY_USING_UNICODE sections, so that stringobject.c compiles again with --disable-unicode. Fixes SF bug http://www.python.org/sf/554912 Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.147.6.4 retrieving revision 2.147.6.5 diff -C2 -d -r2.147.6.4 -r2.147.6.5 *** stringobject.c 30 Apr 2002 03:41:53 -0000 2.147.6.4 --- stringobject.c 13 May 2002 09:11:44 -0000 2.147.6.5 *************** *** 1490,1493 **** --- 1490,1494 ---- if (PyString_Check(sep)) return do_xstrip(self, striptype, sep); + #ifdef Py_USING_UNICODE else if (PyUnicode_Check(sep)) { PyObject *uniself = PyUnicode_FromObject((PyObject *)self); *************** *** 1500,1506 **** --- 1501,1512 ---- return res; } + #endif else { PyErr_Format(PyExc_TypeError, + #ifdef Py_USING_UNICODE "%s arg must be None, str or unicode", + #else + "%s arg must be None or str", + #endif STRIPNAME(striptype)); return NULL; From mwh@sourceforge.net Mon May 13 10:42:18 2002 From: mwh@sourceforge.net (mwh@sourceforge.net) Date: Mon, 13 May 2002 02:42:18 -0700 Subject: [Python-checkins] python/dist/src/Lib StringIO.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv32637/Lib Modified Files: StringIO.py Log Message: Make StringIO work in --disable-unicode builds... Index: StringIO.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/StringIO.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** StringIO.py 10 May 2002 21:00:35 -0000 1.23 --- StringIO.py 13 May 2002 09:42:15 -0000 1.24 *************** *** 40,44 **** def __init__(self, buf = ''): # Force self.buf to be a string or unicode ! if not isinstance(buf, types.UnicodeType): buf = str(buf) self.buf = buf --- 40,44 ---- def __init__(self, buf = ''): # Force self.buf to be a string or unicode ! if not isinstance(buf, types.StringTypes): buf = str(buf) self.buf = buf *************** *** 139,143 **** if not s: return # Force s to be a string or unicode ! if not isinstance(s, types.UnicodeType): s = str(s) if self.pos > self.len: --- 139,143 ---- if not s: return # Force s to be a string or unicode ! if not isinstance(s, types.StringTypes): s = str(s) if self.pos > self.len: From mwh@sourceforge.net Mon May 13 10:42:18 2002 From: mwh@sourceforge.net (mwh@sourceforge.net) Date: Mon, 13 May 2002 02:42:18 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_StringIO.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv32637/Lib/test Modified Files: test_StringIO.py Log Message: Make StringIO work in --disable-unicode builds... Index: test_StringIO.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_StringIO.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_StringIO.py 16 Feb 2002 07:34:19 -0000 1.12 --- test_StringIO.py 13 May 2002 09:42:16 -0000 1.13 *************** *** 74,77 **** --- 74,79 ---- def test_unicode(self): + if not test_support.have_unicode: return + # The StringIO module also supports concatenating Unicode # snippets to larger Unicode strings. This is tested by this From mwh@sourceforge.net Mon May 13 11:15:02 2002 From: mwh@sourceforge.net (mwh@sourceforge.net) Date: Mon, 13 May 2002 03:15:02 -0700 Subject: [Python-checkins] python/dist/src/Modules arraymodule.c,2.72,2.73 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv12976 Modified Files: arraymodule.c Log Message: array_tounicode isn't defined in --disable-unicode builds... I have a patch to make the test work too, but it's not pretty so I'll submit it to sf. Index: arraymodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v retrieving revision 2.72 retrieving revision 2.73 diff -C2 -d -r2.72 -r2.73 *** arraymodule.c 2 May 2002 20:34:12 -0000 2.72 --- arraymodule.c 13 May 2002 10:14:59 -0000 2.73 *************** *** 1448,1455 **** --- 1448,1459 ---- PyOS_snprintf(buf, sizeof(buf), "array('%c', ", typecode); s = PyString_FromString(buf); + #ifdef Py_USING_UNICODE if (typecode == 'c') + #endif v = array_tostring(a, t_empty); + #ifdef Py_USING_UNICODE else v = array_tounicode(a, t_empty); + #endif Py_DECREF(t_empty); t = PyObject_Repr(v); From gvanrossum@sourceforge.net Mon May 13 15:55:38 2002 From: gvanrossum@sourceforge.net (gvanrossum@sourceforge.net) Date: Mon, 13 May 2002 07:55:38 -0700 Subject: [Python-checkins] python/dist/src/Lib telnetlib.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv2370 Modified Files: telnetlib.py Log Message: SF 554073. Fix typo in error reporting of unrecognized character following IAC. Bugfix candidate if anyone cares. Index: telnetlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/telnetlib.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** telnetlib.py 16 Feb 2002 23:06:19 -0000 1.17 --- telnetlib.py 13 May 2002 14:55:33 -0000 1.18 *************** *** 422,426 **** self.sock.sendall(IAC + DONT + opt) else: ! self.msg('IAC %d not recognized' % ord(opt)) except EOFError: # raised by self.rawq_getchar() pass --- 422,426 ---- self.sock.sendall(IAC + DONT + opt) else: ! self.msg('IAC %d not recognized' % ord(c)) except EOFError: # raised by self.rawq_getchar() pass From gvanrossum@sourceforge.net Mon May 13 15:58:04 2002 From: gvanrossum@sourceforge.net (gvanrossum@sourceforge.net) Date: Mon, 13 May 2002 07:58:04 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_fcntl.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv3232 Modified Files: test_fcntl.py Log Message: SF 554663. Add OpenBSD3. Bugfix candidate if anyone cares. Index: test_fcntl.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_fcntl.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** test_fcntl.py 24 Feb 2002 05:32:32 -0000 1.21 --- test_fcntl.py 13 May 2002 14:58:02 -0000 1.22 *************** *** 21,25 **** 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', 'bsdos2', 'bsdos3', 'bsdos4', ! 'openbsd', 'openbsd2'): lockdata = struct.pack('lxxxxlxxxxlhh', 0, 0, 0, fcntl.F_WRLCK, 0) elif sys.platform in ['aix3', 'aix4', 'hp-uxB', 'unixware7']: --- 21,25 ---- 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', 'bsdos2', 'bsdos3', 'bsdos4', ! 'openbsd', 'openbsd2', 'openbsd3'): lockdata = struct.pack('lxxxxlxxxxlhh', 0, 0, 0, fcntl.F_WRLCK, 0) elif sys.platform in ['aix3', 'aix4', 'hp-uxB', 'unixware7']: From gvanrossum@sourceforge.net Mon May 13 19:29:48 2002 From: gvanrossum@sourceforge.net (gvanrossum@sourceforge.net) Date: Mon, 13 May 2002 11:29:48 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py,1.133,1.134 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv8995/Lib/test Modified Files: test_descr.py Log Message: Jim Fulton reported a segfault in dir(). A heavily proxied object returned a proxy for __class__ whose __bases__ was also a proxy. The merge_class_dict() helper for dir() assumed incorrectly that __bases__ would always be a tuple and used the in-line tuple API on the proxy. I will backport this to 2.2 as well. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.133 retrieving revision 1.134 diff -C2 -d -r1.133 -r1.134 *** test_descr.py 18 Apr 2002 18:06:20 -0000 1.133 --- test_descr.py 13 May 2002 18:29:46 -0000 1.134 *************** *** 366,369 **** --- 366,389 ---- vereq(dir(None), dir(Ellipsis)) + # Nasty test case for proxied objects + class Wrapper(object): + def __init__(self, obj): + self.__obj = obj + def __repr__(self): + return "Wrapper(%s)" % repr(self.__obj) + def __getitem__(self, key): + return Wrapper(self.__obj[key]) + def __len__(self): + return len(self.__obj) + def __getattr__(self, name): + return Wrapper(getattr(self.__obj, name)) + + class C(object): + def __getclass(self): + return Wrapper(type(self)) + __class__ = property(__getclass) + + dir(C()) # This used to segfault + binops = { 'add': '+', From gvanrossum@sourceforge.net Mon May 13 19:29:48 2002 From: gvanrossum@sourceforge.net (gvanrossum@sourceforge.net) Date: Mon, 13 May 2002 11:29:48 -0700 Subject: [Python-checkins] python/dist/src/Objects object.c,2.173,2.174 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv8995/Objects Modified Files: object.c Log Message: Jim Fulton reported a segfault in dir(). A heavily proxied object returned a proxy for __class__ whose __bases__ was also a proxy. The merge_class_dict() helper for dir() assumed incorrectly that __bases__ would always be a tuple and used the in-line tuple API on the proxy. I will backport this to 2.2 as well. Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.173 retrieving revision 2.174 diff -C2 -d -r2.173 -r2.174 *** object.c 26 Apr 2002 02:46:00 -0000 2.173 --- object.c 13 May 2002 18:29:46 -0000 2.174 *************** *** 1521,1532 **** PyErr_Clear(); else { int i, n; ! assert(PyTuple_Check(bases)); ! n = PyTuple_GET_SIZE(bases); ! for (i = 0; i < n; i++) { ! PyObject *base = PyTuple_GET_ITEM(bases, i); ! if (merge_class_dict(dict, base) < 0) { ! Py_DECREF(bases); ! return -1; } } --- 1521,1540 ---- PyErr_Clear(); else { + /* We have no guarantee that bases is a real tuple */ int i, n; ! n = PySequence_Size(bases); /* This better be right */ ! if (n < 0) ! PyErr_Clear(); ! else { ! for (i = 0; i < n; i++) { ! PyObject *base = PySequence_GetItem(bases, i); ! if (base == NULL) { ! Py_DECREF(bases); ! return -1; ! } ! if (merge_class_dict(dict, base) < 0) { ! Py_DECREF(bases); ! return -1; ! } } } From gvanrossum@sourceforge.net Mon May 13 19:30:42 2002 From: gvanrossum@sourceforge.net (gvanrossum@sourceforge.net) Date: Mon, 13 May 2002 11:30:42 -0700 Subject: [Python-checkins] python/dist/src/Objects object.c,2.162.6.2,2.162.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv10109/Objects Modified Files: Tag: release22-maint object.c Log Message: Backport from 2.3: Jim Fulton reported a segfault in dir(). A heavily proxied object returned a proxy for __class__ whose __bases__ was also a proxy. The merge_class_dict() helper for dir() assumed incorrectly that __bases__ would always be a tuple and used the in-line tuple API on the proxy. Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.162.6.2 retrieving revision 2.162.6.3 diff -C2 -d -r2.162.6.2 -r2.162.6.3 *** object.c 5 Mar 2002 15:41:40 -0000 2.162.6.2 --- object.c 13 May 2002 18:30:40 -0000 2.162.6.3 *************** *** 1508,1519 **** PyErr_Clear(); else { int i, n; ! assert(PyTuple_Check(bases)); ! n = PyTuple_GET_SIZE(bases); ! for (i = 0; i < n; i++) { ! PyObject *base = PyTuple_GET_ITEM(bases, i); ! if (merge_class_dict(dict, base) < 0) { ! Py_DECREF(bases); ! return -1; } } --- 1508,1527 ---- PyErr_Clear(); else { + /* We have no guarantee that bases is a real tuple */ int i, n; ! n = PySequence_Size(bases); /* This better be right */ ! if (n < 0) ! PyErr_Clear(); ! else { ! for (i = 0; i < n; i++) { ! PyObject *base = PySequence_GetItem(bases, i); ! if (base == NULL) { ! Py_DECREF(bases); ! return -1; ! } ! if (merge_class_dict(dict, base) < 0) { ! Py_DECREF(bases); ! return -1; ! } } } From gvanrossum@sourceforge.net Mon May 13 19:30:42 2002 From: gvanrossum@sourceforge.net (gvanrossum@sourceforge.net) Date: Mon, 13 May 2002 11:30:42 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py,1.113.4.14,1.113.4.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv10109/Lib/test Modified Files: Tag: release22-maint test_descr.py Log Message: Backport from 2.3: Jim Fulton reported a segfault in dir(). A heavily proxied object returned a proxy for __class__ whose __bases__ was also a proxy. The merge_class_dict() helper for dir() assumed incorrectly that __bases__ would always be a tuple and used the in-line tuple API on the proxy. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.113.4.14 retrieving revision 1.113.4.15 diff -C2 -d -r1.113.4.14 -r1.113.4.15 *** test_descr.py 23 Apr 2002 04:02:54 -0000 1.113.4.14 --- test_descr.py 13 May 2002 18:30:40 -0000 1.113.4.15 *************** *** 366,369 **** --- 366,389 ---- vereq(dir(None), dir(Ellipsis)) + # Nasty test case for proxied objects + class Wrapper(object): + def __init__(self, obj): + self.__obj = obj + def __repr__(self): + return "Wrapper(%s)" % repr(self.__obj) + def __getitem__(self, key): + return Wrapper(self.__obj[key]) + def __len__(self): + return len(self.__obj) + def __getattr__(self, name): + return Wrapper(getattr(self.__obj, name)) + + class C(object): + def __getclass(self): + return Wrapper(type(self)) + __class__ = property(__getclass) + + dir(C()) # This used to segfault + binops = { 'add': '+', From jackjansen@sourceforge.net Mon May 13 22:21:41 2002 From: jackjansen@sourceforge.net (jackjansen@sourceforge.net) Date: Mon, 13 May 2002 14:21:41 -0700 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf _CFmodule.c,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory usw-pr-cvs1:/tmp/cvs-serv20664/Python/Mac/Modules/cf Modified Files: _CFmodule.c Log Message: Added CFPreferences support. Added these as functions, not methods, which seemed counter-intuitive. Index: _CFmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/_CFmodule.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** _CFmodule.c 12 May 2002 22:03:56 -0000 1.14 --- _CFmodule.c 13 May 2002 21:21:38 -0000 1.15 *************** *** 29,32 **** --- 29,33 ---- #include #include + #include #else #include *************** *** 3321,3324 **** --- 3322,3642 ---- } + static PyObject *CF_CFPreferencesCopyAppValue(PyObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + CFTypeRef _rv; + CFStringRef key; + CFStringRef applicationID; + #ifndef CFPreferencesCopyAppValue + PyMac_PRECHECK(CFPreferencesCopyAppValue); + #endif + if (!PyArg_ParseTuple(_args, "O&O&", + CFStringRefObj_Convert, &key, + CFStringRefObj_Convert, &applicationID)) + return NULL; + _rv = CFPreferencesCopyAppValue(key, + applicationID); + _res = Py_BuildValue("O&", + CFTypeRefObj_New, _rv); + return _res; + } + + static PyObject *CF_CFPreferencesGetAppBooleanValue(PyObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + Boolean _rv; + CFStringRef key; + CFStringRef applicationID; + Boolean keyExistsAndHasValidFormat; + #ifndef CFPreferencesGetAppBooleanValue + PyMac_PRECHECK(CFPreferencesGetAppBooleanValue); + #endif + if (!PyArg_ParseTuple(_args, "O&O&", + CFStringRefObj_Convert, &key, + CFStringRefObj_Convert, &applicationID)) + return NULL; + _rv = CFPreferencesGetAppBooleanValue(key, + applicationID, + &keyExistsAndHasValidFormat); + _res = Py_BuildValue("ll", + _rv, + keyExistsAndHasValidFormat); + return _res; + } + + static PyObject *CF_CFPreferencesGetAppIntegerValue(PyObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + CFIndex _rv; + CFStringRef key; + CFStringRef applicationID; + Boolean keyExistsAndHasValidFormat; + #ifndef CFPreferencesGetAppIntegerValue + PyMac_PRECHECK(CFPreferencesGetAppIntegerValue); + #endif + if (!PyArg_ParseTuple(_args, "O&O&", + CFStringRefObj_Convert, &key, + CFStringRefObj_Convert, &applicationID)) + return NULL; + _rv = CFPreferencesGetAppIntegerValue(key, + applicationID, + &keyExistsAndHasValidFormat); + _res = Py_BuildValue("ll", + _rv, + keyExistsAndHasValidFormat); + return _res; + } + + static PyObject *CF_CFPreferencesSetAppValue(PyObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + CFStringRef key; + CFTypeRef value; + CFStringRef applicationID; + #ifndef CFPreferencesSetAppValue + PyMac_PRECHECK(CFPreferencesSetAppValue); + #endif + if (!PyArg_ParseTuple(_args, "O&O&O&", + CFStringRefObj_Convert, &key, + CFTypeRefObj_Convert, &value, + CFStringRefObj_Convert, &applicationID)) + return NULL; + CFPreferencesSetAppValue(key, + value, + applicationID); + Py_INCREF(Py_None); + _res = Py_None; + return _res; + } + + static PyObject *CF_CFPreferencesAddSuitePreferencesToApp(PyObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + CFStringRef applicationID; + CFStringRef suiteID; + #ifndef CFPreferencesAddSuitePreferencesToApp + PyMac_PRECHECK(CFPreferencesAddSuitePreferencesToApp); + #endif + if (!PyArg_ParseTuple(_args, "O&O&", + CFStringRefObj_Convert, &applicationID, + CFStringRefObj_Convert, &suiteID)) + return NULL; + CFPreferencesAddSuitePreferencesToApp(applicationID, + suiteID); + Py_INCREF(Py_None); + _res = Py_None; + return _res; + } + + static PyObject *CF_CFPreferencesRemoveSuitePreferencesFromApp(PyObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + CFStringRef applicationID; + CFStringRef suiteID; + #ifndef CFPreferencesRemoveSuitePreferencesFromApp + PyMac_PRECHECK(CFPreferencesRemoveSuitePreferencesFromApp); + #endif + if (!PyArg_ParseTuple(_args, "O&O&", + CFStringRefObj_Convert, &applicationID, + CFStringRefObj_Convert, &suiteID)) + return NULL; + CFPreferencesRemoveSuitePreferencesFromApp(applicationID, + suiteID); + Py_INCREF(Py_None); + _res = Py_None; + return _res; + } + + static PyObject *CF_CFPreferencesAppSynchronize(PyObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + Boolean _rv; + CFStringRef applicationID; + #ifndef CFPreferencesAppSynchronize + PyMac_PRECHECK(CFPreferencesAppSynchronize); + #endif + if (!PyArg_ParseTuple(_args, "O&", + CFStringRefObj_Convert, &applicationID)) + return NULL; + _rv = CFPreferencesAppSynchronize(applicationID); + _res = Py_BuildValue("l", + _rv); + return _res; + } + + static PyObject *CF_CFPreferencesCopyValue(PyObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + CFTypeRef _rv; + CFStringRef key; + CFStringRef applicationID; + CFStringRef userName; + CFStringRef hostName; + #ifndef CFPreferencesCopyValue + PyMac_PRECHECK(CFPreferencesCopyValue); + #endif + if (!PyArg_ParseTuple(_args, "O&O&O&O&", + CFStringRefObj_Convert, &key, + CFStringRefObj_Convert, &applicationID, + CFStringRefObj_Convert, &userName, + CFStringRefObj_Convert, &hostName)) + return NULL; + _rv = CFPreferencesCopyValue(key, + applicationID, + userName, + hostName); + _res = Py_BuildValue("O&", + CFTypeRefObj_New, _rv); + return _res; + } + + static PyObject *CF_CFPreferencesCopyMultiple(PyObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + CFDictionaryRef _rv; + CFArrayRef keysToFetch; + CFStringRef applicationID; + CFStringRef userName; + CFStringRef hostName; + #ifndef CFPreferencesCopyMultiple + PyMac_PRECHECK(CFPreferencesCopyMultiple); + #endif + if (!PyArg_ParseTuple(_args, "O&O&O&O&", + CFArrayRefObj_Convert, &keysToFetch, + CFStringRefObj_Convert, &applicationID, + CFStringRefObj_Convert, &userName, + CFStringRefObj_Convert, &hostName)) + return NULL; + _rv = CFPreferencesCopyMultiple(keysToFetch, + applicationID, + userName, + hostName); + _res = Py_BuildValue("O&", + CFDictionaryRefObj_New, _rv); + return _res; + } + + static PyObject *CF_CFPreferencesSetValue(PyObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + CFStringRef key; + CFTypeRef value; + CFStringRef applicationID; + CFStringRef userName; + CFStringRef hostName; + #ifndef CFPreferencesSetValue + PyMac_PRECHECK(CFPreferencesSetValue); + #endif + if (!PyArg_ParseTuple(_args, "O&O&O&O&O&", + CFStringRefObj_Convert, &key, + CFTypeRefObj_Convert, &value, + CFStringRefObj_Convert, &applicationID, + CFStringRefObj_Convert, &userName, + CFStringRefObj_Convert, &hostName)) + return NULL; + CFPreferencesSetValue(key, + value, + applicationID, + userName, + hostName); + Py_INCREF(Py_None); + _res = Py_None; + return _res; + } + + static PyObject *CF_CFPreferencesSetMultiple(PyObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + CFDictionaryRef keysToSet; + CFArrayRef keysToRemove; + CFStringRef applicationID; + CFStringRef userName; + CFStringRef hostName; + #ifndef CFPreferencesSetMultiple + PyMac_PRECHECK(CFPreferencesSetMultiple); + #endif + if (!PyArg_ParseTuple(_args, "O&O&O&O&O&", + CFDictionaryRefObj_Convert, &keysToSet, + CFArrayRefObj_Convert, &keysToRemove, + CFStringRefObj_Convert, &applicationID, + CFStringRefObj_Convert, &userName, + CFStringRefObj_Convert, &hostName)) + return NULL; + CFPreferencesSetMultiple(keysToSet, + keysToRemove, + applicationID, + userName, + hostName); + Py_INCREF(Py_None); + _res = Py_None; + return _res; + } + + static PyObject *CF_CFPreferencesSynchronize(PyObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + Boolean _rv; + CFStringRef applicationID; + CFStringRef userName; + CFStringRef hostName; + #ifndef CFPreferencesSynchronize + PyMac_PRECHECK(CFPreferencesSynchronize); + #endif + if (!PyArg_ParseTuple(_args, "O&O&O&", + CFStringRefObj_Convert, &applicationID, + CFStringRefObj_Convert, &userName, + CFStringRefObj_Convert, &hostName)) + return NULL; + _rv = CFPreferencesSynchronize(applicationID, + userName, + hostName); + _res = Py_BuildValue("l", + _rv); + return _res; + } + + static PyObject *CF_CFPreferencesCopyApplicationList(PyObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + CFArrayRef _rv; + CFStringRef userName; + CFStringRef hostName; + #ifndef CFPreferencesCopyApplicationList + PyMac_PRECHECK(CFPreferencesCopyApplicationList); + #endif + if (!PyArg_ParseTuple(_args, "O&O&", + CFStringRefObj_Convert, &userName, + CFStringRefObj_Convert, &hostName)) + return NULL; + _rv = CFPreferencesCopyApplicationList(userName, + hostName); + _res = Py_BuildValue("O&", + CFArrayRefObj_New, _rv); + return _res; + } + + static PyObject *CF_CFPreferencesCopyKeyList(PyObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + CFArrayRef _rv; + CFStringRef applicationID; + CFStringRef userName; + CFStringRef hostName; + #ifndef CFPreferencesCopyKeyList + PyMac_PRECHECK(CFPreferencesCopyKeyList); + #endif + if (!PyArg_ParseTuple(_args, "O&O&O&", + CFStringRefObj_Convert, &applicationID, + CFStringRefObj_Convert, &userName, + CFStringRefObj_Convert, &hostName)) + return NULL; + _rv = CFPreferencesCopyKeyList(applicationID, + userName, + hostName); + _res = Py_BuildValue("O&", + CFArrayRefObj_New, _rv); + return _res; + } + static PyObject *CF_CFStringGetTypeID(PyObject *_self, PyObject *_args) { *************** *** 3885,3888 **** --- 4203,4234 ---- {"CFDictionaryCreateMutableCopy", (PyCFunction)CF_CFDictionaryCreateMutableCopy, 1, "(CFIndex capacity, CFDictionaryRef theDict) -> (CFMutableDictionaryRef _rv)"}, + {"CFPreferencesCopyAppValue", (PyCFunction)CF_CFPreferencesCopyAppValue, 1, + "(CFStringRef key, CFStringRef applicationID) -> (CFTypeRef _rv)"}, + {"CFPreferencesGetAppBooleanValue", (PyCFunction)CF_CFPreferencesGetAppBooleanValue, 1, + "(CFStringRef key, CFStringRef applicationID) -> (Boolean _rv, Boolean keyExistsAndHasValidFormat)"}, + {"CFPreferencesGetAppIntegerValue", (PyCFunction)CF_CFPreferencesGetAppIntegerValue, 1, + "(CFStringRef key, CFStringRef applicationID) -> (CFIndex _rv, Boolean keyExistsAndHasValidFormat)"}, + {"CFPreferencesSetAppValue", (PyCFunction)CF_CFPreferencesSetAppValue, 1, + "(CFStringRef key, CFTypeRef value, CFStringRef applicationID) -> None"}, + {"CFPreferencesAddSuitePreferencesToApp", (PyCFunction)CF_CFPreferencesAddSuitePreferencesToApp, 1, + "(CFStringRef applicationID, CFStringRef suiteID) -> None"}, + {"CFPreferencesRemoveSuitePreferencesFromApp", (PyCFunction)CF_CFPreferencesRemoveSuitePreferencesFromApp, 1, + "(CFStringRef applicationID, CFStringRef suiteID) -> None"}, + {"CFPreferencesAppSynchronize", (PyCFunction)CF_CFPreferencesAppSynchronize, 1, + "(CFStringRef applicationID) -> (Boolean _rv)"}, + {"CFPreferencesCopyValue", (PyCFunction)CF_CFPreferencesCopyValue, 1, + "(CFStringRef key, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFTypeRef _rv)"}, + {"CFPreferencesCopyMultiple", (PyCFunction)CF_CFPreferencesCopyMultiple, 1, + "(CFArrayRef keysToFetch, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFDictionaryRef _rv)"}, + {"CFPreferencesSetValue", (PyCFunction)CF_CFPreferencesSetValue, 1, + "(CFStringRef key, CFTypeRef value, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> None"}, + {"CFPreferencesSetMultiple", (PyCFunction)CF_CFPreferencesSetMultiple, 1, + "(CFDictionaryRef keysToSet, CFArrayRef keysToRemove, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> None"}, + {"CFPreferencesSynchronize", (PyCFunction)CF_CFPreferencesSynchronize, 1, + "(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (Boolean _rv)"}, + {"CFPreferencesCopyApplicationList", (PyCFunction)CF_CFPreferencesCopyApplicationList, 1, + "(CFStringRef userName, CFStringRef hostName) -> (CFArrayRef _rv)"}, + {"CFPreferencesCopyKeyList", (PyCFunction)CF_CFPreferencesCopyKeyList, 1, + "(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFArrayRef _rv)"}, {"CFStringGetTypeID", (PyCFunction)CF_CFStringGetTypeID, 1, "() -> (CFTypeID _rv)"}, *************** *** 4018,4021 **** --- 4364,4378 ---- if (PyDict_SetItemString(d, "CFURLRefType", (PyObject *)&CFURLRef_Type) != 0) Py_FatalError("can't initialize CFURLRefType"); + + #define _STRINGCONST(name) PyModule_AddObject(m, #name, CFStringRefObj_New(name)) + _STRINGCONST(kCFPreferencesAnyApplication); + _STRINGCONST(kCFPreferencesCurrentApplication); + _STRINGCONST(kCFPreferencesAnyHost); + _STRINGCONST(kCFPreferencesCurrentHost); + _STRINGCONST(kCFPreferencesAnyUser); + _STRINGCONST(kCFPreferencesCurrentUser); + + + } From jackjansen@sourceforge.net Mon May 13 22:21:51 2002 From: jackjansen@sourceforge.net (jackjansen@sourceforge.net) Date: Mon, 13 May 2002 14:21:51 -0700 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf cfsupport.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory usw-pr-cvs1:/tmp/cvs-serv20917/Python/Mac/Modules/cf Modified Files: cfsupport.py Log Message: Added CFPreferences support. Added these as functions, not methods, which seemed counter-intuitive. Index: cfsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/cfsupport.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** cfsupport.py 12 May 2002 22:04:14 -0000 1.17 --- cfsupport.py 13 May 2002 21:21:49 -0000 1.18 *************** *** 51,54 **** --- 51,55 ---- #include #include + #include #else #include *************** *** 166,169 **** --- 167,181 ---- """ + variablestuff=""" + #define _STRINGCONST(name) PyModule_AddObject(m, #name, CFStringRefObj_New(name)) + _STRINGCONST(kCFPreferencesAnyApplication); + _STRINGCONST(kCFPreferencesCurrentApplication); + _STRINGCONST(kCFPreferencesAnyHost); + _STRINGCONST(kCFPreferencesCurrentHost); + _STRINGCONST(kCFPreferencesAnyUser); + _STRINGCONST(kCFPreferencesCurrentUser); + + """ + Boolean = Type("Boolean", "l") CFTypeID = Type("CFTypeID", "l") # XXXX a guess, seems better than OSTypeType. *************** *** 406,410 **** # Create the generator groups and link them ! module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) CFTypeRef_object = CFTypeRefObjectDefinition('CFTypeRef', 'CFTypeRefObj', 'CFTypeRef') CFArrayRef_object = CFArrayRefObjectDefinition('CFArrayRef', 'CFArrayRefObj', 'CFArrayRef') --- 418,422 ---- # Create the generator groups and link them ! module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff, variablestuff) CFTypeRef_object = CFTypeRefObjectDefinition('CFTypeRef', 'CFTypeRefObj', 'CFTypeRef') CFArrayRef_object = CFArrayRefObjectDefinition('CFArrayRef', 'CFArrayRefObj', 'CFArrayRef') From jackjansen@sourceforge.net Mon May 13 22:21:46 2002 From: jackjansen@sourceforge.net (jackjansen@sourceforge.net) Date: Mon, 13 May 2002 14:21:46 -0700 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf cfscan.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory usw-pr-cvs1:/tmp/cvs-serv20859/Python/Mac/Modules/cf Modified Files: cfscan.py Log Message: Added CFPreferences support. Added these as functions, not methods, which seemed counter-intuitive. Index: cfscan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/cfscan.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** cfscan.py 12 May 2002 22:04:01 -0000 1.9 --- cfscan.py 13 May 2002 21:21:44 -0000 1.10 *************** *** 32,36 **** ## "CFNumber.h", ## "CFPlugIn.h", ! ## "CFPreferences.h", "CFPropertyList.h", ## "CFSet.h", --- 32,36 ---- ## "CFNumber.h", ## "CFPlugIn.h", ! "CFPreferences.h", "CFPropertyList.h", ## "CFSet.h", *************** *** 55,59 **** classname = "Function" listname = "functions" ! if arglist: t, n, m = arglist[0] if t in OBJECTS and m == "InMode": --- 55,59 ---- classname = "Function" listname = "functions" ! if arglist and name[:13] != 'CFPreferences': t, n, m = arglist[0] if t in OBJECTS and m == "InMode": From jackjansen@sourceforge.net Mon May 13 22:23:12 2002 From: jackjansen@sourceforge.net (jackjansen@sourceforge.net) Date: Mon, 13 May 2002 14:23:12 -0700 Subject: [Python-checkins] python/dist/src/Mac/Modules/cf pycfbridge.c,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory usw-pr-cvs1:/tmp/cvs-serv21827/Python/Mac/Modules/cf Modified Files: pycfbridge.c Log Message: Added typechecking to the individual python->CF converters, so we can use them in the CF object initializers safely. Index: pycfbridge.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/pycfbridge.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pycfbridge.c 8 May 2002 22:13:51 -0000 1.4 --- pycfbridge.c 13 May 2002 21:23:10 -0000 1.5 *************** *** 173,176 **** --- 173,182 ---- int size, i; + if( !PySequence_Check(src) ) { + PyErr_Format(PyExc_TypeError, + "Cannot convert %.500s objects to CFArray", + src->ob_type->tp_name); + return 0; + } size = PySequence_Size(src); rv = CFArrayCreateMutable((CFAllocatorRef)NULL, size, &kCFTypeArrayCallBacks); *************** *** 206,209 **** --- 212,221 ---- int size, i; + if( !PyMapping_Check(src) ) { + PyErr_Format(PyExc_TypeError, + "Cannot convert %.500s objects to CFDictionary", + src->ob_type->tp_name); + return 0; + } size = PyMapping_Size(src); rv = CFDictionaryCreateMutable((CFAllocatorRef)NULL, size, *************** *** 242,249 **** --- 254,263 ---- PyCF_Python2CF_simple(PyObject *src, CFTypeRef *dst) { + #if 0 if (PyObject_HasAttrString(src, "CFType")) { *dst = PyObject_CallMethod(src, "CFType", ""); return (*dst != NULL); } + #endif if (PyString_Check(src) || PyUnicode_Check(src)) return PyCF_Python2CF_string(src, (CFStringRef *)dst); *************** *** 267,271 **** PyErr_Format(PyExc_TypeError, ! "Cannot convert %.500s objects to CF", src->ob_type->tp_name); return 0; --- 281,285 ---- PyErr_Format(PyExc_TypeError, ! "Cannot convert %.500s objects to CFType", src->ob_type->tp_name); return 0; *************** *** 292,296 **** err: PyErr_Format(PyExc_TypeError, ! "Cannot convert %.500s objects to CF", src->ob_type->tp_name); return 0; --- 306,310 ---- err: PyErr_Format(PyExc_TypeError, ! "Cannot convert %.500s objects to CFString", src->ob_type->tp_name); return 0; From rhettinger@sourceforge.net Mon May 13 23:39:31 2002 From: rhettinger@sourceforge.net (rhettinger@sourceforge.net) Date: Mon, 13 May 2002 15:39:31 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib librandom.tex,1.25.18.1,1.25.18.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv26121 Modified Files: Tag: release22-maint librandom.tex Log Message: Correct gammavariate's method name and domain. Partial solution to SF bug 527139. Index: librandom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/librandom.tex,v retrieving revision 1.25.18.1 retrieving revision 1.25.18.2 diff -C2 -d -r1.25.18.1 -r1.25.18.2 *** librandom.tex 18 Apr 2002 04:59:44 -0000 1.25.18.1 --- librandom.tex 13 May 2002 22:39:28 -0000 1.25.18.2 *************** *** 217,223 **** \end{funcdesc} ! \begin{funcdesc}{gamma}{alpha, beta} Gamma distribution. (\emph{Not} the gamma function!) Conditions on ! the parameters are \code{\var{alpha} > -1} and \code{\var{beta} > 0}. \end{funcdesc} --- 217,223 ---- \end{funcdesc} ! \begin{funcdesc}{gammavariate}{alpha, beta} Gamma distribution. (\emph{Not} the gamma function!) Conditions on ! the parameters are \code{\var{alpha} >= 0.5} and \code{\var{beta} > 0}. \end{funcdesc} From rhettinger@sourceforge.net Mon May 13 23:40:40 2002 From: rhettinger@sourceforge.net (rhettinger@sourceforge.net) Date: Mon, 13 May 2002 15:40:40 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib librandom.tex,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv27316 Modified Files: librandom.tex Log Message: Correct gammavariate's method name and domain. Partial solution to SF bug 527139. Index: librandom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/librandom.tex,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** librandom.tex 12 Apr 2002 20:01:47 -0000 1.26 --- librandom.tex 13 May 2002 22:40:38 -0000 1.27 *************** *** 217,223 **** \end{funcdesc} ! \begin{funcdesc}{gamma}{alpha, beta} Gamma distribution. (\emph{Not} the gamma function!) Conditions on ! the parameters are \code{\var{alpha} > -1} and \code{\var{beta} > 0}. \end{funcdesc} --- 217,223 ---- \end{funcdesc} ! \begin{funcdesc}{gammavariate}{alpha, beta} Gamma distribution. (\emph{Not} the gamma function!) Conditions on ! the parameters are \code{\var{alpha} >= 0.5} and \code{\var{beta} > 0}. \end{funcdesc} From rhettinger@sourceforge.net Tue May 14 00:40:17 2002 From: rhettinger@sourceforge.net (rhettinger@sourceforge.net) Date: Mon, 13 May 2002 16:40:17 -0700 Subject: [Python-checkins] python/dist/src/Lib random.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv19459 Modified Files: random.py Log Message: Closes SF bug 527139. Moved temp variables inside guard. Index: random.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/random.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** random.py 5 May 2002 20:39:59 -0000 1.28 --- random.py 13 May 2002 23:40:14 -0000 1.29 *************** *** 447,458 **** def gammavariate(self, alpha, beta): # beta times standard gamma ! ainv = _sqrt(2.0 * alpha - 1.0) ! return beta * self.stdgamma(alpha, ainv, alpha - LOG4, alpha + ainv) ! ! def stdgamma(self, alpha, ainv, bbb, ccc): ! # ainv = sqrt(2 * alpha - 1) ! # bbb = alpha - log(4) ! # ccc = alpha + ainv random = self.random if alpha <= 0.0: --- 447,453 ---- def gammavariate(self, alpha, beta): # beta times standard gamma ! return beta * self.stdgamma(alpha) + def stdgamma(self, alpha, *args): # *args for Py2.2 compatiblity random = self.random if alpha <= 0.0: *************** *** 465,468 **** --- 460,467 ---- # Applied Statistics, (1977), 26, No. 1, p71-74 + ainv = _sqrt(2.0 * alpha - 1.0) + bbb = alpha - LOG4 + ccc = alpha + ainv + while 1: u1 = random() From rhettinger@sourceforge.net Tue May 14 00:43:08 2002 From: rhettinger@sourceforge.net (rhettinger@sourceforge.net) Date: Mon, 13 May 2002 16:43:08 -0700 Subject: [Python-checkins] python/dist/src/Lib random.py,1.26.6.1,1.26.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv20930 Modified Files: Tag: release22-maint random.py Log Message: Closes SF bug 527139. Moved temp variables inside guard. Index: random.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/random.py,v retrieving revision 1.26.6.1 retrieving revision 1.26.6.2 diff -C2 -d -r1.26.6.1 -r1.26.6.2 *** random.py 18 Apr 2002 05:00:45 -0000 1.26.6.1 --- random.py 13 May 2002 23:43:06 -0000 1.26.6.2 *************** *** 444,455 **** def gammavariate(self, alpha, beta): # beta times standard gamma ! ainv = _sqrt(2.0 * alpha - 1.0) ! return beta * self.stdgamma(alpha, ainv, alpha - LOG4, alpha + ainv) ! ! def stdgamma(self, alpha, ainv, bbb, ccc): ! # ainv = sqrt(2 * alpha - 1) ! # bbb = alpha - log(4) ! # ccc = alpha + ainv random = self.random if alpha <= 0.0: --- 444,450 ---- def gammavariate(self, alpha, beta): # beta times standard gamma ! return beta * self.stdgamma(alpha) + def stdgamma(self, alpha, *args): # *args for Py2.2 compatiblity random = self.random if alpha <= 0.0: *************** *** 462,465 **** --- 457,464 ---- # Applied Statistics, (1977), 26, No. 1, p71-74 + ainv = _sqrt(2.0 * alpha - 1.0) + bbb = alpha - LOG4 + ccc = alpha + ainv + while 1: u1 = random() From rhettinger@sourceforge.net Tue May 14 00:47:04 2002 From: rhettinger@sourceforge.net (rhettinger@sourceforge.net) Date: Mon, 13 May 2002 16:47:04 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib librandom.tex,1.25.18.2,1.25.18.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv22216 Modified Files: Tag: release22-maint librandom.tex Log Message: Closes SF bug 527139. Brings docs inline with random.py 1.26.6.1 which fixed the unnecessarily restricted method domain. Index: librandom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/librandom.tex,v retrieving revision 1.25.18.2 retrieving revision 1.25.18.3 diff -C2 -d -r1.25.18.2 -r1.25.18.3 *** librandom.tex 13 May 2002 22:39:28 -0000 1.25.18.2 --- librandom.tex 13 May 2002 23:47:02 -0000 1.25.18.3 *************** *** 219,223 **** \begin{funcdesc}{gammavariate}{alpha, beta} Gamma distribution. (\emph{Not} the gamma function!) Conditions on ! the parameters are \code{\var{alpha} >= 0.5} and \code{\var{beta} > 0}. \end{funcdesc} --- 219,223 ---- \begin{funcdesc}{gammavariate}{alpha, beta} Gamma distribution. (\emph{Not} the gamma function!) Conditions on ! the parameters are \code{\var{alpha} > 0} and \code{\var{beta} > 0}. \end{funcdesc} From rhettinger@sourceforge.net Tue May 14 00:49:15 2002 From: rhettinger@sourceforge.net (rhettinger@sourceforge.net) Date: Mon, 13 May 2002 16:49:15 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib librandom.tex,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv23528 Modified Files: librandom.tex Log Message: Closes SF bug 527139. Brings docs inline with random.py 1.29 which fixes the unnecessarily restricted method domain. Index: librandom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/librandom.tex,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** librandom.tex 13 May 2002 22:40:38 -0000 1.27 --- librandom.tex 13 May 2002 23:49:13 -0000 1.28 *************** *** 219,223 **** \begin{funcdesc}{gammavariate}{alpha, beta} Gamma distribution. (\emph{Not} the gamma function!) Conditions on ! the parameters are \code{\var{alpha} >= 0.5} and \code{\var{beta} > 0}. \end{funcdesc} --- 219,223 ---- \begin{funcdesc}{gammavariate}{alpha, beta} Gamma distribution. (\emph{Not} the gamma function!) Conditions on ! the parameters are \code{\var{alpha} > 0} and \code{\var{beta} > 0}. \end{funcdesc} From bwarsaw@sourceforge.net Tue May 14 03:13:32 2002 From: bwarsaw@sourceforge.net (bwarsaw@sourceforge.net) Date: Mon, 13 May 2002 19:13:32 -0700 Subject: [Python-checkins] python/dist/src/Lib smtpd.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv2103 Modified Files: smtpd.py Log Message: smtp_RCPT(): Removed a somewhat embarrassing debugging line, found by Scot Stevenson. Could be a bug fix candidate, but probably doesn't matter much unless a certain blue-nosed cat suddenly becomes corporeal and starts emailing some stmp.py (sic) fronted mailer. Index: smtpd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtpd.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** smtpd.py 11 Feb 2002 18:05:05 -0000 1.12 --- smtpd.py 14 May 2002 02:13:30 -0000 1.13 *************** *** 242,248 **** self.push('501 Syntax: RCPT TO:
') return - if address.lower().startswith('stimpy'): - self.push('503 You suck %s' % address) - return self.__rcpttos.append(address) print >> DEBUGSTREAM, 'recips:', self.__rcpttos --- 242,245 ---- From rhettinger@sourceforge.net Tue May 14 07:40:36 2002 From: rhettinger@sourceforge.net (rhettinger@sourceforge.net) Date: Mon, 13 May 2002 23:40:36 -0700 Subject: [Python-checkins] python/dist/src/Lib random.py,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv29789 Modified Files: random.py Log Message: Closes patch 529408 deprecating random.stdgamma(). Index: random.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/random.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** random.py 13 May 2002 23:40:14 -0000 1.29 --- random.py 14 May 2002 06:40:34 -0000 1.30 *************** *** 446,457 **** def gammavariate(self, alpha, beta): ! # beta times standard gamma ! return beta * self.stdgamma(alpha) ! ! def stdgamma(self, alpha, *args): # *args for Py2.2 compatiblity random = self.random - if alpha <= 0.0: - raise ValueError, 'stdgamma: alpha must be > 0.0' - if alpha > 1.0: --- 446,458 ---- def gammavariate(self, alpha, beta): ! ! # alpha > 0, beta > 0, mean is alpha*beta, variance is alpha*beta**2 ! ! # Warning: a few older sources define the gamma distribution in terms ! # of alpha > -1.0 ! if alpha <= 0.0 or beta <= 0.0: ! raise ValueError, 'gammavariate: alpha and beta must be > 0.0' ! random = self.random if alpha > 1.0: *************** *** 472,476 **** r = bbb+ccc*v-x if r + SG_MAGICCONST - 4.5*z >= 0.0 or r >= _log(z): ! return x elif alpha == 1.0: --- 473,477 ---- r = bbb+ccc*v-x if r + SG_MAGICCONST - 4.5*z >= 0.0 or r >= _log(z): ! return x * beta elif alpha == 1.0: *************** *** 479,483 **** while u <= 1e-7: u = random() ! return -_log(u) else: # alpha is between 0 and 1 (exclusive) --- 480,484 ---- while u <= 1e-7: u = random() ! return -_log(u) * beta else: # alpha is between 0 and 1 (exclusive) *************** *** 498,502 **** ((p > 1) and (u1 > pow(x, alpha - 1.0)))): break ! return x --- 499,523 ---- ((p > 1) and (u1 > pow(x, alpha - 1.0)))): break ! return x * beta ! ! ! def stdgamma(self, alpha, ainv, bbb, ccc): ! # This method was (and shall remain) undocumented. ! # This method is deprecated ! # for the following reasons: ! # 1. Returns same as .gammavariate(alpha, 1.0) ! # 2. Requires caller to provide 3 extra arguments ! # that are functions of alpha anyway ! # 3. Can't be used for alpha < 0.5 ! ! # ainv = sqrt(2 * alpha - 1) ! # bbb = alpha - log(4) ! # ccc = alpha + ainv ! import warnings ! warnings.warn("The stdgamma function is deprecated; " ! "use gammavariate() instead", ! DeprecationWarning) ! return self.gammavariate(alpha, 1.0) ! *************** *** 597,601 **** (avg, stddev, smallest, largest) ! def _test(N=200): print 'TWOPI =', TWOPI print 'LOG4 =', LOG4 --- 618,622 ---- (avg, stddev, smallest, largest) ! def _test(N=20000): print 'TWOPI =', TWOPI print 'LOG4 =', LOG4 *************** *** 608,611 **** --- 629,635 ---- _test_generator(N, 'expovariate(1.0)') _test_generator(N, 'vonmisesvariate(0.0, 1.0)') + _test_generator(N, 'gammavariate(0.01, 1.0)') + _test_generator(N, 'gammavariate(0.1, 1.0)') + _test_generator(N, 'gammavariate(0.1, 2.0)') _test_generator(N, 'gammavariate(0.5, 1.0)') _test_generator(N, 'gammavariate(0.9, 1.0)') From rhettinger@sourceforge.net Tue May 14 07:56:30 2002 From: rhettinger@sourceforge.net (rhettinger@sourceforge.net) Date: Mon, 13 May 2002 23:56:30 -0700 Subject: [Python-checkins] python/dist/src/Lib random.py,1.26.6.2,1.26.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv5803 Modified Files: Tag: release22-maint random.py Log Message: Closes patch 529408 deprecating random.stdgamma(). Index: random.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/random.py,v retrieving revision 1.26.6.2 retrieving revision 1.26.6.3 diff -C2 -d -r1.26.6.2 -r1.26.6.3 *** random.py 13 May 2002 23:43:06 -0000 1.26.6.2 --- random.py 14 May 2002 06:56:27 -0000 1.26.6.3 *************** *** 443,454 **** def gammavariate(self, alpha, beta): - # beta times standard gamma - return beta * self.stdgamma(alpha) ! def stdgamma(self, alpha, *args): # *args for Py2.2 compatiblity ! random = self.random ! if alpha <= 0.0: ! raise ValueError, 'stdgamma: alpha must be > 0.0' if alpha > 1.0: --- 443,455 ---- def gammavariate(self, alpha, beta): ! # alpha > 0, beta > 0, mean is alpha*beta, variance is alpha*beta**2 ! ! # Warning: a few older sources define the gamma distribution in terms ! # of alpha > -1.0 ! if alpha <= 0.0 or beta <= 0.0: ! raise ValueError, 'gammavariate: alpha and beta must be > 0.0' + random = self.random if alpha > 1.0: *************** *** 469,473 **** r = bbb+ccc*v-x if r + SG_MAGICCONST - 4.5*z >= 0.0 or r >= _log(z): ! return x elif alpha == 1.0: --- 470,474 ---- r = bbb+ccc*v-x if r + SG_MAGICCONST - 4.5*z >= 0.0 or r >= _log(z): ! return x * beta elif alpha == 1.0: *************** *** 476,480 **** while u <= 1e-7: u = random() ! return -_log(u) else: # alpha is between 0 and 1 (exclusive) --- 477,481 ---- while u <= 1e-7: u = random() ! return -_log(u) * beta else: # alpha is between 0 and 1 (exclusive) *************** *** 495,499 **** ((p > 1) and (u1 > pow(x, alpha - 1.0)))): break ! return x --- 496,520 ---- ((p > 1) and (u1 > pow(x, alpha - 1.0)))): break ! return x * beta ! ! ! def stdgamma(self, alpha, ainv, bbb, ccc): ! # This method was (and shall remain) undocumented. ! # This method is deprecated ! # for the following reasons: ! # 1. Returns same as .gammavariate(alpha, 1.0) ! # 2. Requires caller to provide 3 extra arguments ! # that are functions of alpha anyway ! # 3. Can't be used for alpha < 0.5 ! ! # ainv = sqrt(2 * alpha - 1) ! # bbb = alpha - log(4) ! # ccc = alpha + ainv ! import warnings ! warnings.warn("The stdgamma function is deprecated; " ! "use gammavariate() instead", ! DeprecationWarning) ! return self.gammavariate(alpha, 1.0) ! *************** *** 594,598 **** (avg, stddev, smallest, largest) ! def _test(N=200): print 'TWOPI =', TWOPI print 'LOG4 =', LOG4 --- 615,619 ---- (avg, stddev, smallest, largest) ! def _test(N=20000): print 'TWOPI =', TWOPI print 'LOG4 =', LOG4 *************** *** 605,608 **** --- 626,632 ---- _test_generator(N, 'expovariate(1.0)') _test_generator(N, 'vonmisesvariate(0.0, 1.0)') + _test_generator(N, 'gammavariate(0.01, 1.0)') + _test_generator(N, 'gammavariate(0.1, 1.0)') + _test_generator(N, 'gammavariate(0.1, 2.0)') _test_generator(N, 'gammavariate(0.5, 1.0)') _test_generator(N, 'gammavariate(0.9, 1.0)') From rhettinger@sourceforge.net Tue May 14 09:51:36 2002 From: rhettinger@sourceforge.net (rhettinger@sourceforge.net) Date: Tue, 14 May 2002 01:51:36 -0700 Subject: [Python-checkins] python/dist/src/Lib/test/output test_math,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv27060 Modified Files: test_math Log Message: Added tests for new degree/radian conversions. Index: test_math =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_math,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_math 16 Oct 2000 17:35:13 -0000 1.5 --- test_math 14 May 2002 08:51:33 -0000 1.6 *************** *** 9,12 **** --- 9,13 ---- cos cosh + degrees exp fabs *************** *** 20,23 **** --- 21,25 ---- modf pow + radians sin sinh From gvanrossum@sourceforge.net Tue May 14 15:08:14 2002 From: gvanrossum@sourceforge.net (gvanrossum@sourceforge.net) Date: Tue, 14 May 2002 07:08:14 -0700 Subject: [Python-checkins] python/dist/src/Lib random.py,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv21630 Modified Files: random.py Log Message: Use spaces, not tabs for indents. Raymond Hettinger, beware! This caused the Unix install to fail! Index: random.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/random.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** random.py 14 May 2002 06:40:34 -0000 1.30 --- random.py 14 May 2002 14:08:12 -0000 1.31 *************** *** 449,456 **** # alpha > 0, beta > 0, mean is alpha*beta, variance is alpha*beta**2 ! # Warning: a few older sources define the gamma distribution in terms ! # of alpha > -1.0 ! if alpha <= 0.0 or beta <= 0.0: ! raise ValueError, 'gammavariate: alpha and beta must be > 0.0' random = self.random --- 449,456 ---- # alpha > 0, beta > 0, mean is alpha*beta, variance is alpha*beta**2 ! # Warning: a few older sources define the gamma distribution in terms ! # of alpha > -1.0 ! if alpha <= 0.0 or beta <= 0.0: ! raise ValueError, 'gammavariate: alpha and beta must be > 0.0' random = self.random From gvanrossum@sourceforge.net Tue May 14 15:07:15 2002 From: gvanrossum@sourceforge.net (gvanrossum@sourceforge.net) Date: Tue, 14 May 2002 07:07:15 -0700 Subject: [Python-checkins] python/dist/src/Lib random.py,1.26.6.3,1.26.6.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv21135 Modified Files: Tag: release22-maint random.py Log Message: Use spaces, not tabs for indents. Raymond Hettinger, beware! This caused the Unix install to fail! Index: random.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/random.py,v retrieving revision 1.26.6.3 retrieving revision 1.26.6.4 diff -C2 -d -r1.26.6.3 -r1.26.6.4 *** random.py 14 May 2002 06:56:27 -0000 1.26.6.3 --- random.py 14 May 2002 14:07:12 -0000 1.26.6.4 *************** *** 446,453 **** # alpha > 0, beta > 0, mean is alpha*beta, variance is alpha*beta**2 ! # Warning: a few older sources define the gamma distribution in terms ! # of alpha > -1.0 ! if alpha <= 0.0 or beta <= 0.0: ! raise ValueError, 'gammavariate: alpha and beta must be > 0.0' random = self.random --- 446,453 ---- # alpha > 0, beta > 0, mean is alpha*beta, variance is alpha*beta**2 ! # Warning: a few older sources define the gamma distribution in terms ! # of alpha > -1.0 ! if alpha <= 0.0 or beta <= 0.0: ! raise ValueError, 'gammavariate: alpha and beta must be > 0.0' random = self.random From fdrake@sourceforge.net Tue May 14 16:50:13 2002 From: fdrake@sourceforge.net (fdrake@sourceforge.net) Date: Tue, 14 May 2002 08:50:13 -0700 Subject: [Python-checkins] python/dist/src/Lib HTMLParser.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv25394/Lib Modified Files: HTMLParser.py Log Message: Simplify code to remove an unnecessary test. Index: HTMLParser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/HTMLParser.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** HTMLParser.py 3 Dec 2001 17:09:50 -0000 1.10 --- HTMLParser.py 14 May 2002 15:50:11 -0000 1.11 *************** *** 149,154 **** elif startswith("= 0: - self.clear_cdata_mode() elif startswith(" 'URL'.""" # Most URL schemes require ASCII. If that changes, the conversion # can be relaxed ! if type(url) is types.UnicodeType: try: url = url.encode("ASCII") --- 907,922 ---- # quote('abc def') -> 'abc%20def') + if hasattr(types, "UnicodeType"): + def _is_unicode(x): + return isinstance(x, unicode) + else: + def _is_unicode(x): + return 0 + def toBytes(url): """toBytes(u"URL") --> 'URL'.""" # Most URL schemes require ASCII. If that changes, the conversion # can be relaxed ! if _is_unicode(url): try: url = url.encode("ASCII") *************** *** 1190,1194 **** v = quote_plus(v) l.append(k + '=' + v) ! elif type(v) == types.UnicodeType: # is there a reasonable way to convert to ASCII? # encode generates a string, but "replace" or "ignore" --- 1197,1201 ---- v = quote_plus(v) l.append(k + '=' + v) ! elif _is_unicode(v): # is there a reasonable way to convert to ASCII? # encode generates a string, but "replace" or "ignore" From fdrake@acm.org Fri May 24 19:14:19 2002 From: fdrake@acm.org (Fred L. Drake, Jr.) Date: Fri, 24 May 2002 14:14:19 -0400 Subject: [Python-checkins] python/dist/src/Lib urllib.py,1.143,1.144 In-Reply-To: References: Message-ID: <15598.33531.189123.465626@grendel.zope.com> gvanrossum@users.sourceforge.net writes: > + if hasattr(types, "UnicodeType"): > + def _is_unicode(x): > + return isinstance(x, unicode) > + else: > + def _is_unicode(x): > + return 0 > + Is this preferable to: try: unicode except NameError: def _is_unicode(x): return 0 else: def _is_unicode(x): return isinstance(x, unicode) I've generally been using the later for feature tests; should I be doing it differently? -Fred -- Fred L. Drake, Jr. PythonLabs at Zope Corporation From gvanrossum@users.sourceforge.net Fri May 24 19:47:50 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 24 May 2002 11:47:50 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.144,2.145 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv20828 Modified Files: typeobject.c Log Message: Add a safeguard against setting the class to something with a different free or alloc slot. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.144 retrieving revision 2.145 diff -C2 -d -r2.144 -r2.145 *** typeobject.c 18 Apr 2002 04:12:28 -0000 2.144 --- typeobject.c 24 May 2002 18:47:47 -0000 2.145 *************** *** 1623,1626 **** --- 1623,1636 ---- } new = (PyTypeObject *)value; + if (new->tp_dealloc != old->tp_dealloc || + new->tp_free != old->tp_free) + { + PyErr_Format(PyExc_TypeError, + "__class__ assignment: " + "'%s' deallocator differs from '%s'", + new->tp_name, + old->tp_name); + return -1; + } newbase = new; oldbase = old; From gvanrossum@users.sourceforge.net Fri May 24 20:02:02 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 24 May 2002 12:02:02 -0700 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c,2.255,2.256 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv24325/Python Modified Files: bltinmodule.c Log Message: - A new type object, 'string', is added. This is a common base type for 'str' and 'unicode', and can be used instead of types.StringTypes, e.g. to test whether something is "a string": isinstance(x, string) is True for Unicode and 8-bit strings. This is an abstract base class and cannot be instantiated directly. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.255 retrieving revision 2.256 diff -C2 -d -r2.255 -r2.256 *** bltinmodule.c 12 May 2002 07:19:38 -0000 2.255 --- bltinmodule.c 24 May 2002 19:01:59 -0000 2.256 *************** *** 1906,1909 **** --- 1906,1910 ---- SETBUILTIN("staticmethod", &PyStaticMethod_Type); SETBUILTIN("str", &PyString_Type); + SETBUILTIN("string", &PyBaseString_Type); SETBUILTIN("super", &PySuper_Type); SETBUILTIN("tuple", &PyTuple_Type); From gvanrossum@users.sourceforge.net Fri May 24 20:02:00 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 24 May 2002 12:02:00 -0700 Subject: [Python-checkins] python/dist/src/Include stringobject.h,2.33,2.34 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv24325/Include Modified Files: stringobject.h Log Message: - A new type object, 'string', is added. This is a common base type for 'str' and 'unicode', and can be used instead of types.StringTypes, e.g. to test whether something is "a string": isinstance(x, string) is True for Unicode and 8-bit strings. This is an abstract base class and cannot be instantiated directly. Index: stringobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/stringobject.h,v retrieving revision 2.33 retrieving revision 2.34 diff -C2 -d -r2.33 -r2.34 *** stringobject.h 29 Mar 2002 03:29:07 -0000 2.33 --- stringobject.h 24 May 2002 19:01:57 -0000 2.34 *************** *** 40,43 **** --- 40,44 ---- } PyStringObject; + extern DL_IMPORT(PyTypeObject) PyBaseString_Type; extern DL_IMPORT(PyTypeObject) PyString_Type; From gvanrossum@users.sourceforge.net Fri May 24 20:02:00 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 24 May 2002 12:02:00 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.408,1.409 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv24325/Misc Modified Files: NEWS Log Message: - A new type object, 'string', is added. This is a common base type for 'str' and 'unicode', and can be used instead of types.StringTypes, e.g. to test whether something is "a string": isinstance(x, string) is True for Unicode and 8-bit strings. This is an abstract base class and cannot be instantiated directly. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.408 retrieving revision 1.409 diff -C2 -d -r1.408 -r1.409 *** NEWS 20 May 2002 00:14:24 -0000 1.408 --- NEWS 24 May 2002 19:01:58 -0000 1.409 *************** *** 7,10 **** --- 7,16 ---- Core and builtins + - A new type object, 'string', is added. This is a common base type + for 'str' and 'unicode', and can be used instead of + types.StringTypes, e.g. to test whether something is "a string": + isinstance(x, string) is True for Unicode and 8-bit strings. This + is an abstract base class and cannot be instantiated directly. + - Deprecated features of xrange objects have been removed as promised. The start, stop, and step attributes and the tolist() From gvanrossum@users.sourceforge.net Fri May 24 20:02:02 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 24 May 2002 12:02:02 -0700 Subject: [Python-checkins] python/dist/src/Objects object.c,2.174,2.175 stringobject.c,2.163,2.164 unicodeobject.c,2.148,2.149 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv24325/Objects Modified Files: object.c stringobject.c unicodeobject.c Log Message: - A new type object, 'string', is added. This is a common base type for 'str' and 'unicode', and can be used instead of types.StringTypes, e.g. to test whether something is "a string": isinstance(x, string) is True for Unicode and 8-bit strings. This is an abstract base class and cannot be instantiated directly. Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.174 retrieving revision 2.175 diff -C2 -d -r2.174 -r2.175 *** object.c 13 May 2002 18:29:46 -0000 2.174 --- object.c 24 May 2002 19:01:58 -0000 2.175 *************** *** 1780,1783 **** --- 1780,1786 ---- Py_FatalError("Can't initialize 'bool'"); + if (PyType_Ready(&PyString_Type) < 0) + Py_FatalError("Can't initialize 'str'"); + if (PyType_Ready(&PyList_Type) < 0) Py_FatalError("Can't initialize 'list'"); Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.163 retrieving revision 2.164 diff -C2 -d -r2.163 -r2.164 *** stringobject.c 21 May 2002 15:14:57 -0000 2.163 --- stringobject.c 24 May 2002 19:01:58 -0000 2.164 *************** *** 2856,2859 **** --- 2856,2913 ---- } + static PyObject * + basestring_new(PyTypeObject *type, PyObject *args, PyObject *kwds) + { + PyErr_SetString(PyExc_TypeError, + "The string type cannot be instantiated"); + return NULL; + } + + static char basestring_doc[] = + "Type string cannot be instantiated; it is the base for str and unicode."; + + PyTypeObject PyBaseString_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "string", + 0, + 0, + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + basestring_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &PyBaseObject_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + basestring_new, /* tp_new */ + 0, /* tp_free */ + }; + static char string_doc[] = "str(object) -> string\n\ *************** *** 2894,2898 **** 0, /* tp_members */ 0, /* tp_getset */ ! 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ --- 2948,2952 ---- 0, /* tp_members */ 0, /* tp_getset */ ! &PyBaseString_Type, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.148 retrieving revision 2.149 diff -C2 -d -r2.148 -r2.149 *** unicodeobject.c 21 May 2002 15:14:57 -0000 2.148 --- unicodeobject.c 24 May 2002 19:01:59 -0000 2.149 *************** *** 5836,5840 **** 0, /* tp_members */ 0, /* tp_getset */ ! 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ --- 5836,5840 ---- 0, /* tp_members */ 0, /* tp_getset */ ! &PyBaseString_Type, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ *************** *** 5860,5863 **** --- 5860,5865 ---- for (i = 0; i < 256; i++) unicode_latin1[i] = NULL; + if (PyType_Ready(&PyUnicode_Type) < 0) + Py_FatalError("Can't initialize 'unicode'"); } From bwarsaw@users.sourceforge.net Fri May 24 20:39:50 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri, 24 May 2002 12:39:50 -0700 Subject: [Python-checkins] python/nondist/peps pep-0008.txt,1.9,1.10 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv3401 Modified Files: pep-0008.txt Log Message: More additions based on comments from Tim Peters, Neal Norwitz, Gerhard Haring, and Guido van Rossum. Index: pep-0008.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0008.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pep-0008.txt 24 May 2002 17:07:17 -0000 1.9 --- pep-0008.txt 24 May 2002 19:39:47 -0000 1.10 *************** *** 501,507 **** ! Optimization and Other Programming Recommendations ! - class-based exceptions are always preferred over string-based exceptions. Modules or packages should define their own domain-specific base exception class, which should be subclassed --- 501,513 ---- ! Programming Recommendations ! - Comparisons to singletons like None should always be done with ! 'is' or 'is not'. Also, beware of writing "if x" when you ! really mean "if x is not None" -- e.g. when testing whether a ! variable or argument that defaults to None was set to some other ! value. ! ! - Class-based exceptions are always preferred over string-based exceptions. Modules or packages should define their own domain-specific base exception class, which should be subclassed *************** *** 542,545 **** --- 548,559 ---- sequences are false, so "if not seq" or "if seq" is preferable to "if len(seq)" or "if not len(seq)". + + - Don't write string literals that rely on significant trailing + whitespace. Such trailing whitespace is visually + indistinguishable and some editors (or more recently, + reindent.py) will trim them. + + - Don't compare boolean values to True or False using == (bool + types are new in Python 2.3). From akuchling@users.sourceforge.net Fri May 24 20:42:32 2002 From: akuchling@users.sourceforge.net (akuchling@users.sourceforge.net) Date: Fri, 24 May 2002 12:42:32 -0700 Subject: [Python-checkins] python/nondist/peps pep-0008.txt,1.10,1.11 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv4109 Modified Files: pep-0008.txt Log Message: Typo fix Index: pep-0008.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0008.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pep-0008.txt 24 May 2002 19:39:47 -0000 1.10 --- pep-0008.txt 24 May 2002 19:42:30 -0000 1.11 *************** *** 293,297 **** does. This comment should appear after the "def" line. ! - PEP 257 describes good docstrings conventions. Note that most importantly, the """ that ends a multiline docstring should be on a line by itself, e.g.: --- 293,297 ---- does. This comment should appear after the "def" line. ! - PEP 257 describes good docstring conventions. Note that most importantly, the """ that ends a multiline docstring should be on a line by itself, e.g.: From gvanrossum@users.sourceforge.net Fri May 24 20:46:22 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 24 May 2002 12:46:22 -0700 Subject: [Python-checkins] python/nondist/peps pep-0008.txt,1.11,1.12 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv5154 Modified Files: pep-0008.txt Log Message: Two tiny clarifications. Index: pep-0008.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0008.txt,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** pep-0008.txt 24 May 2002 19:42:30 -0000 1.11 --- pep-0008.txt 24 May 2002 19:46:20 -0000 1.12 *************** *** 507,511 **** really mean "if x is not None" -- e.g. when testing whether a variable or argument that defaults to None was set to some other ! value. - Class-based exceptions are always preferred over string-based --- 507,512 ---- really mean "if x is not None" -- e.g. when testing whether a variable or argument that defaults to None was set to some other ! value. The other value might be a value that's false in a ! Boolean context! - Class-based exceptions are always preferred over string-based *************** *** 555,559 **** - Don't compare boolean values to True or False using == (bool ! types are new in Python 2.3). --- 556,563 ---- - Don't compare boolean values to True or False using == (bool ! types are new in Python 2.3): ! ! No: if greeting == True: print "Hello world" ! Yes: if greeting: print "Hello world" From akuchling@users.sourceforge.net Fri May 24 22:09:00 2002 From: akuchling@users.sourceforge.net (akuchling@users.sourceforge.net) Date: Fri, 24 May 2002 14:09:00 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv27948 Modified Files: whatsnew23.tex Log Message: Mention math.degrees() and math.radians() Other minor rewrites Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** whatsnew23.tex 10 May 2002 21:00:05 -0000 1.13 --- whatsnew23.tex 24 May 2002 21:08:58 -0000 1.14 *************** *** 294,305 **** Python's Booleans were not added for the sake of strict type-checking. ! A very strict language such as Pascal ! % XXX is Pascal the right example here? ! would also prevent you performing arithmetic with Booleans, and would ! require that the expression in an \keyword{if} statement always ! evaluate to a Boolean. Python is not this strict, and it never will ! be. (\pep{285} explicitly says this.) So you can still use any ! expression in an \keyword{if}, even ones that evaluate to a list or ! tuple or some random object, and the Boolean type is a subclass of the \class{int} class, so arithmetic using a Boolean still works. --- 294,304 ---- Python's Booleans were not added for the sake of strict type-checking. ! A very strict language such as Pascal would also prevent you ! performing arithmetic with Booleans, and would require that the ! expression in an \keyword{if} statement always evaluate to a Boolean. ! Python is not this strict, and it never will be. (\pep{285} ! explicitly says so.) So you can still use any expression in an ! \keyword{if}, even ones that evaluate to a list or tuple or some ! random object, and the Boolean type is a subclass of the \class{int} class, so arithmetic using a Boolean still works. *************** *** 383,394 **** \begin{itemize} ! \item To allocate and free an undistinguished chunk of memory, use ! \cfunction{PyMem_Malloc()}, \cfunction{PyMem_Realloc()}, ! \cfunction{PyMem_Free()}, and the other \cfunction{PyMem_*} ! functions. \item To allocate and free Python objects, use \cfunction{PyObject_New()}, \cfunction{PyObject_NewVar()}, and \cfunction{PyObject_Del()}. \end{itemize} --- 382,399 ---- \begin{itemize} ! \item To allocate and free an undistinguished chunk of memory using ! Python's allocator, use ! \cfunction{PyMem_Malloc()}, \cfunction{PyMem_Realloc()}, and ! \cfunction{PyMem_Free()}. ! ! \item In rare cases you may want to avoid using Python's allocator ! in order to allocate a chunk of memory; ! use \cfunction{PyObject_Malloc}, \cfunction{PyObject_Realloc}, ! and \cfunction{PyObject_Free}. \item To allocate and free Python objects, use \cfunction{PyObject_New()}, \cfunction{PyObject_NewVar()}, and \cfunction{PyObject_Del()}. + \end{itemize} *************** *** 492,495 **** --- 497,507 ---- >>> \end{verbatim} + + \item Two new functions in the \module{math} module, + \function{degrees(\var{rads})} and \function{radians(\var{degs})}, + convert between radians and degrees. Other functions in the + \module{math} module such as + \function{math.sin()} and \function{math.cos()} have always required + input values measured in radians. (Contributed by Raymond Hettinger.) \item Two new functions, \function{killpg()} and \function{mknod()}, From gvanrossum@users.sourceforge.net Fri May 24 22:38:50 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 24 May 2002 14:38:50 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.145,2.146 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv3811a Modified Files: typeobject.c Log Message: Fix for SF bug 551412. When _PyType_Lookup() is called on a type whose tp_mro hasn't been initialized, it would dump core. Fix this by checking for NULL and calling PyType_Ready(). Will fix this in 2.2.1 too. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.145 retrieving revision 2.146 diff -C2 -d -r2.145 -r2.146 *** typeobject.c 24 May 2002 18:47:47 -0000 2.145 --- typeobject.c 24 May 2002 21:38:46 -0000 2.146 *************** *** 1222,1225 **** --- 1222,1231 ---- /* Look in tp_dict of types in MRO */ mro = type->tp_mro; + if (mro == NULL) { + if (PyType_Ready(type) < 0) + return NULL; + mro = type->tp_mro; + assert(mro != NULL); + } assert(PyTuple_Check(mro)); n = PyTuple_GET_SIZE(mro); From gvanrossum@users.sourceforge.net Fri May 24 22:40:12 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 24 May 2002 14:40:12 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py,1.134,1.135 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv4146 Modified Files: test_descr.py Log Message: Fix for SF bug 551412. When _PyType_Lookup() is called on a type whose tp_mro hasn't been initialized, it would dump core. Fix this by checking for NULL and calling PyType_Ready(). Will fix this in 2.2.1 too. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.134 retrieving revision 1.135 diff -C2 -d -r1.134 -r1.135 *** test_descr.py 13 May 2002 18:29:46 -0000 1.134 --- test_descr.py 24 May 2002 21:40:08 -0000 1.135 *************** *** 3020,3024 **** --- 3020,3040 ---- raise TestFailed, "string subclass allowed as exception" + def do_this_first(): + if verbose: + print "Testing SF bug 551412 ..." + # This dumps core when SF bug 551412 isn't fixed -- + # but only when test_descr.py is run separately. + # (That can't be helped -- as soon as PyType_Ready() + # is called for PyLong_Type, the bug is gone.) + class UserLong(object): + def __pow__(self, *args): + pass + try: + pow(0L, UserLong(), 0L) + except: + pass + def test_main(): + do_this_first() class_docstrings() lists() From gvanrossum@users.sourceforge.net Fri May 24 22:41:28 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 24 May 2002 14:41:28 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.126.4.10,2.126.4.11 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv4469 Modified Files: Tag: release22-maint typeobject.c Log Message: Fix for SF bug 551412. When _PyType_Lookup() is called on a type whose tp_mro hasn't been initialized, it would dump core. Fix this by checking for NULL and calling PyType_Ready(). Backport from 2.3. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.126.4.10 retrieving revision 2.126.4.11 diff -C2 -d -r2.126.4.10 -r2.126.4.11 *** typeobject.c 18 Apr 2002 05:11:50 -0000 2.126.4.10 --- typeobject.c 24 May 2002 21:41:26 -0000 2.126.4.11 *************** *** 1219,1222 **** --- 1219,1228 ---- /* Look in tp_dict of types in MRO */ mro = type->tp_mro; + if (mro == NULL) { + if (PyType_Ready(type) < 0) + return NULL; + mro = type->tp_mro; + assert(mro != NULL); + } assert(PyTuple_Check(mro)); n = PyTuple_GET_SIZE(mro); From gvanrossum@users.sourceforge.net Sat May 25 01:19:13 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 24 May 2002 17:19:13 -0700 Subject: [Python-checkins] python/nondist/peps pep-0283.txt,1.3,1.4 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv7313 Modified Files: pep-0283.txt Log Message: Add a note about the expected schedule changes. Index: pep-0283.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0283.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pep-0283.txt 6 Mar 2002 20:56:46 -0000 1.3 --- pep-0283.txt 25 May 2002 00:19:11 -0000 1.4 *************** *** 21,24 **** --- 21,27 ---- positive or negative, this may affect decisions. + This schedule will change! See the discussion started here: + http://mail.python.org/pipermail/python-dev/2002-May/024395.html + Release Schedule From fdrake@users.sourceforge.net Sat May 25 21:28:48 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Sat, 25 May 2002 13:28:48 -0700 Subject: [Python-checkins] python/dist/src/Doc Makefile,1.243,1.244 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory usw-pr-cvs1:/tmp/cvs-serv31654 Modified Files: Makefile Log Message: Define the "all" target more reasonably, but retain "html" as the default target. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile,v retrieving revision 1.243 retrieving revision 1.244 diff -C2 -d -r1.243 -r1.244 *** Makefile 23 May 2002 19:41:25 -0000 1.243 --- Makefile 25 May 2002 20:28:46 -0000 1.244 *************** *** 167,171 **** # Main target ! all: html dvi: $(DVIFILES) --- 167,172 ---- # Main target ! default: html ! all: html dvi ps pdf isilo dvi: $(DVIFILES) From mwh@users.sourceforge.net Mon May 27 15:05:34 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Mon, 27 May 2002 07:05:34 -0700 Subject: [Python-checkins] python/dist/src/Include Python.h,2.48,2.49 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv31400/Include Modified Files: Python.h Log Message: Silly typo. Index: Python.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/Python.h,v retrieving revision 2.48 retrieving revision 2.49 diff -C2 -d -r2.48 -r2.49 *** Python.h 15 May 2002 18:24:06 -0000 2.48 --- Python.h 27 May 2002 14:05:31 -0000 2.49 *************** *** 11,15 **** /* Forcing SUSv2 compatibility still produces problems on some ! platforms, True64 and SGI IRIX begin two of them, so for now the define is switched off. */ #if 0 --- 11,15 ---- /* Forcing SUSv2 compatibility still produces problems on some ! platforms, True64 and SGI IRIX being two of them, so for now the define is switched off. */ #if 0 From mwh@users.sourceforge.net Mon May 27 16:08:26 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Mon, 27 May 2002 08:08:26 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv24806/Doc/whatsnew Modified Files: whatsnew23.tex Log Message: This is patch [ 559250 ] more POSIX signal stuff Adds support (and docs and tests and autoconfery) for posix signal mask handling -- sigpending, sigprocmask and sigsuspend. Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** whatsnew23.tex 24 May 2002 21:08:58 -0000 1.14 --- whatsnew23.tex 27 May 2002 15:08:23 -0000 1.15 *************** *** 533,536 **** --- 533,542 ---- \function{get_current_history_length()}, and \function{redisplay()}. + \item Support for more advanced POSIX signal handling -- specifically + the functions \function{sigpending}, \function{sigprocmask} and + \function{sigsupend}, and depending on platform support -- was added + to the \module{signal} module. These functions make some previously + unavoidable race conditions avoidable. + \end{itemize} From mwh@users.sourceforge.net Mon May 27 16:08:26 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Mon, 27 May 2002 08:08:26 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.409,1.410 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv24806/Misc Modified Files: NEWS Log Message: This is patch [ 559250 ] more POSIX signal stuff Adds support (and docs and tests and autoconfery) for posix signal mask handling -- sigpending, sigprocmask and sigsuspend. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.409 retrieving revision 1.410 diff -C2 -d -r1.409 -r1.410 *** NEWS 24 May 2002 19:01:58 -0000 1.409 --- NEWS 27 May 2002 15:08:24 -0000 1.410 *************** *** 107,110 **** --- 107,113 ---- is called. + - signal.sigpending, signal.sigprocmask and signal.sigsuspend have + been added where available. + Library From mwh@users.sourceforge.net Mon May 27 16:08:26 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Mon, 27 May 2002 08:08:26 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libsignal.tex,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv24806/Doc/lib Modified Files: libsignal.tex Log Message: This is patch [ 559250 ] more POSIX signal stuff Adds support (and docs and tests and autoconfery) for posix signal mask handling -- sigpending, sigprocmask and sigsuspend. Index: libsignal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsignal.tex,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** libsignal.tex 15 Feb 2002 20:59:43 -0000 1.23 --- libsignal.tex 27 May 2002 15:08:24 -0000 1.24 *************** *** 19,26 **** \item - There is no way to ``block'' signals temporarily from critical - sections (since this is not supported by all \UNIX{} flavors). - - \item Although Python signal handlers are called asynchronously as far as the Python user is concerned, they can only occur between the --- 19,22 ---- *************** *** 93,96 **** --- 89,102 ---- \end{datadesc} + \begin{datadesc}{SIG_BLOCK} + \end{datadesc} + \begin{datadesc}{SIG_UNBLOCK} + \end{datadesc} + \begin{datadesc}{SIG_SETMASK} + These constants are for use as the first parameter of the + \function{sigprocmask} function described below. + \end{datadesc} + + The \module{signal} module defines the following functions: *************** *** 143,146 **** --- 149,192 ---- reference manual for a description of frame objects). \obindex{frame} + \end{funcdesc} + + The following functions are supported if your platform does. Most + modern \UNIX-alikes now do. + + \begin{funcdesc}{sigpending}{} + Return the set of pending signals, i.e. a list containing the + numbers of those signals that have been raised while blocked. + \versionadded{2.3} + \end{funcdesc} + + \begin{funcdesc}{sigprocmask}{how, sigset} + Change the list of currently blocked signals. The parameter + \var{how} should be one of \constant{SIG_BLOCK}, + \constant{SIG_UNBLOCK} or \constant{SIG_SETMASK} and \var{sigset} + should be a sequence of signal numbers. The behaviour of the call + depends on the value of \var{how}: + + \begin{tableii}{l|l}{textrm}{Value of \var{how}}{Behaviour of call} + \lineii{\constant{SIG_BLOCK}} + {The set of blocked signals is the union of the current set + and \var{sigset}.} + \lineii{\constant{SIG_UNBLOCK}} + {The signals in \var{sigset} are removed from the current + set of blocked signals. It is legal to attempt to unblock + a signal which is not blocked.} + \lineii{\constant{SIG_SETMASK}} + {The set of blocked signals is set to the \var{sigset}.} + \end{tableii} + + A list contating the numbers of the previously blocked signals is + returned. + \versionadded{2.3} + \end{funcdesc} + + \begin{funcdesc}{sigsuspend}{sigset} + Temporarily replace the signal mask with \var{sigset} (which should + be a sequnce of signal numbers) and suspend the process until a + signal is received. + \versionadded{2.3} \end{funcdesc} From mwh@users.sourceforge.net Mon May 27 16:08:26 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Mon, 27 May 2002 08:08:26 -0700 Subject: [Python-checkins] python/dist/src configure.in,1.317,1.318 configure,1.307,1.308 pyconfig.h.in,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv24806 Modified Files: configure.in configure pyconfig.h.in Log Message: This is patch [ 559250 ] more POSIX signal stuff Adds support (and docs and tests and autoconfery) for posix signal mask handling -- sigpending, sigprocmask and sigsuspend. Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.317 retrieving revision 1.318 diff -C2 -d -r1.317 -r1.318 *** configure.in 15 May 2002 18:24:06 -0000 1.317 --- configure.in 27 May 2002 15:08:21 -0000 1.318 *************** *** 1594,1599 **** select setegid seteuid setgid setgroups \ setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \ ! sigaction siginterrupt sigrelse strftime strptime symlink sysconf \ ! tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ truncate uname unsetenv waitpid _getpty getpriority) --- 1594,1599 ---- select setegid seteuid setgid setgroups \ setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \ ! sigaction siginterrupt sigprocmask sigrelse strftime strptime symlink \ ! sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ truncate uname unsetenv waitpid _getpty getpriority) Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.307 retrieving revision 1.308 diff -C2 -d -r1.307 -r1.308 *** configure 15 May 2002 18:24:05 -0000 1.307 --- configure 27 May 2002 15:08:21 -0000 1.308 *************** *** 1,4 **** #! /bin/sh ! # From configure.in Revision: 1.316 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. --- 1,4 ---- #! /bin/sh ! # From configure.in Revision: 1.317 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. *************** *** 11279,11282 **** --- 11279,11283 ---- + for ac_func in alarm chown chroot clock confstr ctermid ctermid_r execv \ fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \ *************** *** 11287,11292 **** select setegid seteuid setgid setgroups \ setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \ ! sigaction siginterrupt sigrelse strftime strptime symlink sysconf \ ! tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ truncate uname unsetenv waitpid _getpty getpriority do --- 11288,11293 ---- select setegid seteuid setgid setgroups \ setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \ ! sigaction siginterrupt sigprocmask sigrelse strftime strptime symlink \ ! sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ truncate uname unsetenv waitpid _getpty getpriority do Index: pyconfig.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/pyconfig.h.in,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** pyconfig.h.in 15 May 2002 18:24:06 -0000 1.35 --- pyconfig.h.in 27 May 2002 15:08:23 -0000 1.36 *************** *** 384,387 **** --- 384,390 ---- #undef HAVE_SIGNAL_H + /* Define to 1 if you have the `sigprocmask' function. */ + #undef HAVE_SIGPROCMASK + /* Define to 1 if you have the `sigrelse' function. */ #undef HAVE_SIGRELSE From mwh@users.sourceforge.net Mon May 27 16:08:26 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Mon, 27 May 2002 08:08:26 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_signal.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv24806/Lib/test Modified Files: test_signal.py Log Message: This is patch [ 559250 ] more POSIX signal stuff Adds support (and docs and tests and autoconfery) for posix signal mask handling -- sigpending, sigprocmask and sigsuspend. Index: test_signal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_signal.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** test_signal.py 24 Oct 2001 20:32:02 -0000 1.9 --- test_signal.py 27 May 2002 15:08:23 -0000 1.10 *************** *** 1,7 **** # Test the signal module ! from test_support import verbose, TestSkipped import signal ! import os ! import sys if sys.platform[:3] in ('win', 'os2') or sys.platform=='riscos': --- 1,6 ---- # Test the signal module ! from test_support import verbose, TestSkipped, TestFailed import signal ! import os, sys, time if sys.platform[:3] in ('win', 'os2') or sys.platform=='riscos': *************** *** 65,66 **** --- 64,128 ---- if verbose: print "KeyboardInterrupt (assume the alarm() went off)" + + + if hasattr(signal, "sigprocmask"): + class HupDelivered(Exception): + pass + def hup(signum, frame): + raise HupDelivered + def hup2(signum, frame): + signal.signal(signal.SIGHUP, hup) + return + signal.signal(signal.SIGHUP, hup) + + if verbose: + print "blocking SIGHUP" + + defaultmask = signal.sigprocmask(signal.SIG_BLOCK, [signal.SIGHUP]) + + if verbose: + print "sending SIGHUP" + + try: + os.kill(pid, signal.SIGHUP) + except HupDelivered: + raise TestFailed, "HUP not blocked" + + if signal.SIGHUP not in signal.sigpending(): + raise TestFailed, "HUP not pending" + + if verbose: + print "unblocking SIGHUP" + + try: + signal.sigprocmask(signal.SIG_UNBLOCK, [signal.SIGHUP]) + except HupDelivered: + pass + else: + raise TestFailed, "HUP not delivered" + + if verbose: + print "testing sigsuspend" + + signal.sigprocmask(signal.SIG_BLOCK, [signal.SIGHUP]) + signal.signal(signal.SIGHUP, hup2) + + if not os.fork(): + time.sleep(2) + os.kill(pid, signal.SIGHUP) + time.sleep(2) + os.kill(pid, signal.SIGHUP) + os._exit(0) + else: + try: + signal.sigsuspend(defaultmask) + except: + raise TestFailed, "sigsuspend erroneously raised" + + try: + signal.sigsuspend(defaultmask) + except HupDelivered: + pass + else: + raise TestFailed, "sigsupsend didn't raise" + From mwh@users.sourceforge.net Mon May 27 16:08:25 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Mon, 27 May 2002 08:08:25 -0700 Subject: [Python-checkins] python/dist/src/Modules signalmodule.c,2.66,2.67 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv24806/Modules Modified Files: signalmodule.c Log Message: This is patch [ 559250 ] more POSIX signal stuff Adds support (and docs and tests and autoconfery) for posix signal mask handling -- sigpending, sigprocmask and sigsuspend. Index: signalmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/signalmodule.c,v retrieving revision 2.66 retrieving revision 2.67 diff -C2 -d -r2.66 -r2.67 *** signalmodule.c 31 Mar 2002 15:27:00 -0000 2.66 --- signalmodule.c 27 May 2002 15:08:23 -0000 2.67 *************** *** 271,274 **** --- 271,421 ---- "; + #ifdef HAVE_SIGPROCMASK /* we assume that having SIGPROCMASK is enough + to guarantee full POSIX signal handling */ + /* returns 0 for success, <0 for failure (with exception set) */ + static int + _signal_list_to_sigset(PyObject* seq, sigset_t* set, char* mesg) + { + int i, len, val; + + seq = PySequence_Fast(seq, mesg); + if (!seq) + return -1; + + len = PySequence_Fast_GET_SIZE(seq); + + sigemptyset(set); + + for (i = 0; i < len; i++) { + val = PyInt_AsLong(PySequence_Fast_GET_ITEM(seq, i)); + if (val == -1 && PyErr_Occurred()) { + Py_DECREF(seq); + return -1; + } + if (sigaddset(set, val) < 0) { + Py_DECREF(seq); + PyErr_SetFromErrno(PyExc_ValueError); + return -1; + } + } + + Py_DECREF(seq); + return 0; + } + + static PyObject* + _signal_sigset_to_list(sigset_t* set) + { + PyObject* ret; + PyObject* ob; + int i; + + ret = PyList_New(0); + if (!ret) + return NULL; + + for (i = 1; i < NSIG; i++) { + if (sigismember(set, i)) { + ob = PyInt_FromLong(i); + if (!ob) { + Py_DECREF(ret); + return NULL; + } + PyList_Append(ret, ob); + Py_DECREF(ob); + } + } + + return ret; + } + + static PyObject* + signal_sigprocmask(PyObject* self, PyObject* args) + { + int how; + sigset_t newset, oldset; + PyObject* seq; + + if (!PyArg_ParseTuple(args, "iO", &how, &seq)) + return NULL; + + if (_signal_list_to_sigset(seq, &newset, + "sigprocmask requires a sequence") < 0) + return NULL; + + if (sigprocmask(how, &newset, &oldset) < 0) { + return PyErr_SetFromErrno(PyExc_ValueError); + } + + if (PyErr_CheckSignals()) + return NULL; + + return _signal_sigset_to_list(&oldset); + } + + static char sigprocmask_doc[] = + "sigprocmask(how, sigset) -> sigset\n\ + \n\ + Change the list of currently blocked signals. The parameter how should be\n\ + one of SIG_BLOCK, SIG_UNBLOCK or SIG_SETMASK and sigset should be a\n\ + sequence of signal numbers. The behaviour of the call depends on the value\n\ + of how:\n\ + \n\ + SIG_BLOCK\n\ + The set of blocked signals is the union of the current set and the\n\ + sigset argument.\n\ + SIG_UNBLOCK\n\ + The signals in sigset are removed from the current set of blocked\n\ + signals. It is legal to attempt to unblock a signal which is not\n\ + blocked.\n\ + SIG_SETMASK\n\ + The set of blocked signals is set to the argument set.\n\ + \n\ + A list contating the numbers of the previously blocked signals is returned."; + + static PyObject* + signal_sigpending(PyObject* self) + { + sigset_t set; + + if (sigpending(&set) < 0) { + return PyErr_SetFromErrno(PyExc_ValueError); + } + + return _signal_sigset_to_list(&set); + } + + static char sigpending_doc[] = + "sigpending() -> sigset\n\ + \n\ + Return the set of pending signals, i.e. a list containing the numbers of\n\ + those signals that have been raised while blocked."; + + static PyObject* + signal_sigsuspend(PyObject* self, PyObject* arg) + { + sigset_t set; + + if (_signal_list_to_sigset(arg, &set, + "sigsuspend requires a sequence") < 0) + return NULL; + + Py_BEGIN_ALLOW_THREADS + sigsuspend(&set); + Py_END_ALLOW_THREADS + + if (PyErr_CheckSignals()) + return NULL; + + Py_INCREF(Py_None); + return Py_None; + } + + static char sigsuspend_doc[] = + "sigsuspend(sigset) -> None\n\ + \n\ + Temporarily replace the signal mask with sigset (which should be a sequence\n\ + of signal numbers) and suspend the process until a signal is received."; + #endif /* List of functions defined in the module */ *************** *** 285,288 **** --- 432,443 ---- {"default_int_handler", signal_default_int_handler, METH_VARARGS, default_int_handler_doc}, + #ifdef HAVE_SIGPROCMASK + {"sigprocmask", (PyCFunction)signal_sigprocmask, + METH_VARARGS, sigprocmask_doc}, + {"sigpending", (PyCFunction)signal_sigpending, + METH_NOARGS, sigpending_doc}, + {"sigsuspend", (PyCFunction)signal_sigsuspend, + METH_O, sigsuspend_doc}, + #endif {NULL, NULL} /* sentinel */ }; *************** *** 300,303 **** --- 455,462 ---- default_int_handler() -- default SIGINT handler\n\ \n\ + sigpending() |\n\ + sigprocmask() |-- posix signal mask handling [Unix only]\n\ + sigsuspend() |\n\ + \n\ Constants:\n\ \n\ *************** *** 548,551 **** --- 707,722 ---- Py_XDECREF(x); #endif + #ifdef HAVE_SIGPROCMASK + x = PyInt_FromLong(SIG_BLOCK); + PyDict_SetItemString(d, "SIG_BLOCK", x); + Py_XDECREF(x); + x = PyInt_FromLong(SIG_UNBLOCK); + PyDict_SetItemString(d, "SIG_UNBLOCK", x); + Py_XDECREF(x); + x = PyInt_FromLong(SIG_SETMASK); + PyDict_SetItemString(d, "SIG_SETMASK", x); + Py_XDECREF(x); + #endif + if (!PyErr_Occurred()) return; From akuchling@users.sourceforge.net Mon May 27 18:20:11 2002 From: akuchling@users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon, 27 May 2002 10:20:11 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv15113 Modified Files: whatsnew23.tex Log Message: Rearrange paragraph Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** whatsnew23.tex 27 May 2002 15:08:23 -0000 1.15 --- whatsnew23.tex 27 May 2002 17:19:46 -0000 1.16 *************** *** 533,541 **** \function{get_current_history_length()}, and \function{redisplay()}. ! \item Support for more advanced POSIX signal handling -- specifically ! the functions \function{sigpending}, \function{sigprocmask} and ! \function{sigsupend}, and depending on platform support -- was added ! to the \module{signal} module. These functions make some previously ! unavoidable race conditions avoidable. \end{itemize} --- 533,541 ---- \function{get_current_history_length()}, and \function{redisplay()}. ! \item Support for more advanced POSIX signal handling was added ! to the \module{signal} module by adding the \function{sigpending}, ! \function{sigprocmask} and \function{sigsuspend} functions, where supported ! by the platform. These functions make it possible to avoid some previously ! unavoidable race conditions. \end{itemize} From jackjansen@users.sourceforge.net Tue May 28 11:58:22 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Tue, 28 May 2002 03:58:22 -0700 Subject: [Python-checkins] python/dist/src/Python import.c,2.201,2.202 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv10296/Python Modified Files: import.c Log Message: File modes in filedescr entries are also passed to Python, so we now put "U" in there, and convert it to "rb" (or "r" for non-universal-newline builds) before passing it to fopen(). Fixes #561326. Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.201 retrieving revision 2.202 diff -C2 -d -r2.201 -r2.202 *** import.c 14 Apr 2002 20:12:41 -0000 2.201 --- import.c 28 May 2002 10:58:19 -0000 2.202 *************** *** 82,86 **** #ifdef RISCOS static const struct filedescr _PyImport_StandardFiletab[] = { ! {"/py", "r" PY_STDIOTEXTMODE, PY_SOURCE}, {"/pyc", "rb", PY_COMPILED}, {0, 0} --- 82,86 ---- #ifdef RISCOS static const struct filedescr _PyImport_StandardFiletab[] = { ! {"/py", "U", PY_SOURCE}, {"/pyc", "rb", PY_COMPILED}, {0, 0} *************** *** 88,94 **** #else static const struct filedescr _PyImport_StandardFiletab[] = { ! {".py", "r" PY_STDIOTEXTMODE, PY_SOURCE}, #ifdef MS_WIN32 ! {".pyw", "r" PY_STDIOTEXTMODE, PY_SOURCE}, #endif {".pyc", "rb", PY_COMPILED}, --- 88,94 ---- #else static const struct filedescr _PyImport_StandardFiletab[] = { ! {".py", "U", PY_SOURCE}, #ifdef MS_WIN32 ! {".pyw", "U", PY_SOURCE}, #endif {".pyc", "rb", PY_COMPILED}, *************** *** 893,896 **** --- 893,897 ---- size_t len, namelen; struct filedescr *fdp = NULL; + char *filemode; FILE *fp = NULL; #ifndef RISCOS *************** *** 1066,1070 **** PySys_WriteStderr("# trying %s\n", buf); #endif /* !macintosh */ ! fp = fopen(buf, fdp->mode); if (fp != NULL) { if (case_ok(buf, len, namelen, name)) --- 1067,1073 ---- PySys_WriteStderr("# trying %s\n", buf); #endif /* !macintosh */ ! filemode = fdp->mode; ! if (filemode[0] == 'U') filemode = "r" PY_STDIOTEXTMODE; ! fp = fopen(buf, filemode); if (fp != NULL) { if (case_ok(buf, len, namelen, name)) From fdrake@users.sourceforge.net Tue May 28 16:46:26 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 28 May 2002 08:46:26 -0700 Subject: [Python-checkins] python/nondist/peps pep2html.py,1.36,1.37 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv32476 Modified Files: pep2html.py Log Message: Change the handling of email addresses to be somewhat more difficult for spam harvesters to collect, and limit those that are actually turned into hyperlinks. Index: pep2html.py =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep2html.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** pep2html.py 4 Apr 2002 16:13:32 -0000 1.36 --- pep2html.py 28 May 2002 15:46:24 -0000 1.37 *************** *** 102,105 **** --- 102,128 ---- + NON_MASKED_EMAILS = [ + 'peps@python.org', + 'python-list@python.org', + 'python-dev@python.org', + ] + + def fixemail(address, pepno): + if address.lower() in NON_MASKED_EMAILS: + # return hyperlinked version of email address + return linkemail(address, pepno) + else: + # return masked version of email address + parts = address.split('@', 1) + return '%s at %s' % (parts[0], parts[1]) + + + def linkemail(address, pepno): + parts = address.split('@', 1) + return ('' + '%s at %s' + % (parts[0], parts[1], pepno, parts[0], parts[1])) + + def fixfile(infile, outfile): basename = os.path.basename(infile) *************** *** 167,173 **** for addr in v.split(): if '@' in addr: ! mailtos.append( ! '%s' % ! (addr, pep, addr)) elif addr.startswith('http:'): mailtos.append( --- 190,198 ---- for addr in v.split(): if '@' in addr: ! if k.lower() == 'discussions-to': ! m = linkemail(addr, pep) ! else: ! m = fixemail(addr, pep) ! mailtos.append(m) elif addr.startswith('http:'): mailtos.append( *************** *** 230,235 **** continue elif parts and '@' in parts[-1]: ! # This is a pep email address line, so hyperlink it ! url = '%s' % (parts[-1], parts[-1]) if need_pre: print >> fo, '
'
--- 255,260 ----
                      continue
                  elif parts and '@' in parts[-1]:
!                     # This is a pep email address line, so filter it.
!                     url = fixemail(parts[-1], pep)
                      if need_pre:
                          print >> fo, '
'





From gvanrossum@users.sourceforge.net  Tue May 28 16:55:18 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Tue, 28 May 2002 08:55:18 -0700
Subject: [Python-checkins] python/nondist/peps pep-0000.txt,1.181,1.182
Message-ID: 

Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv9562

Modified Files:
	pep-0000.txt 
Log Message:
Take authorship of 283 froM Hylton.


Index: pep-0000.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v
retrieving revision 1.181
retrieving revision 1.182
diff -C2 -d -r1.181 -r1.182
*** pep-0000.txt	29 Apr 2002 16:03:42 -0000	1.181
--- pep-0000.txt	28 May 2002 15:55:16 -0000	1.182
***************
*** 90,94 ****
   S   281  Loop Counter Iteration with range and xrange Hetland
   S   282  A Logging System                             Mick
!  I   283  Python 2.3 Release Schedule                  Hylton
   S   284  Integer for-loops                            Eppstein, Ewing
   S   286  Enhanced Argument Tuples                     von Loewis
--- 90,94 ----
   S   281  Loop Counter Iteration with range and xrange Hetland
   S   282  A Logging System                             Mick
!  I   283  Python 2.3 Release Schedule                  van Rossum
   S   284  Integer for-loops                            Eppstein, Ewing
   S   286  Enhanced Argument Tuples                     von Loewis
***************
*** 261,265 ****
   S   281  Loop Counter Iteration with range and xrange Hetland
   S   282  A Logging System                             Mick
!  I   283  Python 2.3 Release Schedule                  Hylton
   S   284  Integer for-loops                            Eppstein, Ewing
   SF  285  Adding a bool type                           van Rossum
--- 261,265 ----
   S   281  Loop Counter Iteration with range and xrange Hetland
   S   282  A Logging System                             Mick
!  I   283  Python 2.3 Release Schedule                  van Rossum
   S   284  Integer for-loops                            Eppstein, Ewing
   SF  285  Adding a bool type                           van Rossum





From bwarsaw@users.sourceforge.net  Tue May 28 16:20:20 2002
From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net)
Date: Tue, 28 May 2002 08:20:20 -0700
Subject: [Python-checkins] python/nondist/peps pep-0001.txt,1.33,1.34
Message-ID: 

Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv4265

Modified Files:
	pep-0001.txt 
Log Message:
Remove Barry's & Jeremy's email address from the Authors: header (note
to other PEP authors -- it is okay now to omit your email address from
this header, although we will be obscuring it soon).

Also, use peps@python.org as the PEP editor contact address instead of
Barry's personal address.

Remove Guido's email address.

Other updates explaining where address obscuring takes place and where
it doesn't.

Updated the Emacs file local variable section.


Index: pep-0001.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0001.txt,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** pep-0001.txt	18 Apr 2002 19:19:35 -0000	1.33
--- pep-0001.txt	28 May 2002 15:20:17 -0000	1.34
***************
*** 3,8 ****
  Version: $Revision$
  Last-Modified: $Date$
! Author: barry@zope.com (Barry A. Warsaw),
!     jeremy@zope.com (Jeremy Hylton)
  Status: Active
  Type: Informational
--- 3,7 ----
  Version: $Revision$
  Last-Modified: $Date$
! Author: Barry A. Warsaw, Jeremy Hylton
  Status: Active
  Type: Informational
***************
*** 43,47 ****
  PEP Work Flow
  
!     The PEP editor, Barry Warsaw , assigns numbers
      for each PEP and changes its status.
  
--- 42,46 ----
  PEP Work Flow
  
!     The PEP editor, Barry Warsaw , assigns numbers
      for each PEP and changes its status.
  
***************
*** 62,68 ****
      the SourceForge patch manager[2] or feature request tracker[3].
  
!     The PEP champion then emails the PEP editor with a proposed title
!     and a rough, but fleshed out, draft of the PEP.  This draft must
!     be written in PEP style as described below.
  
      If the PEP editor approves, he will assign the PEP a number, label
--- 61,67 ----
      the SourceForge patch manager[2] or feature request tracker[3].
  
!     The PEP champion then emails the PEP editor  with
!     a proposed title and a rough, but fleshed out, draft of the PEP.
!     This draft must be written in PEP style as described below.
  
      If the PEP editor approves, he will assign the PEP a number, label
***************
*** 72,78 ****
      status include duplication of effort, being technically unsound,
      or not in keeping with the Python philosophy.  The BDFL
!     (Benevolent Dictator for Life, Guido van Rossum
!     ) can be consulted during the approval phase,
!     and is the final arbitrator of the draft's PEP-ability.
  
      The author of the PEP is then responsible for posting the PEP to
--- 71,77 ----
      status include duplication of effort, being technically unsound,
      or not in keeping with the Python philosophy.  The BDFL
!     (Benevolent Dictator for Life, Guido van Rossum) can be consulted
!     during the approval phase, and is the final arbitrator of the
!     draft's PEP-ability.
  
      The author of the PEP is then responsible for posting the PEP to
***************
*** 94,103 ****
      discussed on python-list@python.org and/or python-dev@python.org
      will not be accepted.  However, wherever possible, long open-ended
!     discussions on public mailing lists should be avoided.  A better
!     strategy is to encourage public feedback be sent directly to the
!     PEP author during the early draft phases, who collects and
!     integrates the comments back into the PEP.  Before code is
!     committed to CVS in a non-experimental way though, discussion must
!     be moved back to the python-dev and/or python-list mailing lists.
  
      Once the authors have completed a PEP, they must inform the PEP
--- 93,101 ----
      discussed on python-list@python.org and/or python-dev@python.org
      will not be accepted.  However, wherever possible, long open-ended
!     discussions on public mailing lists should be avoided.  Strategies
!     to keep the discussions efficient include, setting up a separate
!     SIG mailing list for the topic, having the PEP author accept
!     private comments in the early design phases, etc.  PEP authors
!     should use their discretion here.
  
      Once the authors have completed a PEP, they must inform the PEP
***************
*** 141,146 ****
      1. Preamble -- RFC822 style headers containing meta-data about the
         PEP, including the PEP number, a short descriptive title
!        (limited to a maximum of 44 characters), the names contact info
!        for each author, etc.
  
      2. Abstract -- a short (~200 word) description of the technical
--- 139,144 ----
      1. Preamble -- RFC822 style headers containing meta-data about the
         PEP, including the PEP number, a short descriptive title
!        (limited to a maximum of 44 characters), the names, and
!        optionally the contact info for each author, etc.
  
      2. Abstract -- a short (~200 word) description of the technical
***************
*** 148,153 ****
  
      3. Copyright/public domain -- Each PEP must either be explicitly
!        labelled in the public domain or the Open Publication
!        License[4].
  
      4. Specification -- The technical specification should describe
--- 146,151 ----
  
      3. Copyright/public domain -- Each PEP must either be explicitly
!        labelled as placed in the public domain (see this PEP as an
!        example) or licensed under the Open Publication License[4].
  
      4. Specification -- The technical specification should describe
***************
*** 195,199 ****
          Version: 
          Last-Modified: 
!         Author: 
        * Discussions-To: 
          Status: 
--- 193,197 ----
          Version: 
          Last-Modified: 
!         Author: 
        * Discussions-To: 
          Status: 
***************
*** 206,217 ****
        * Replaced-By: 
  
!     The Author: header lists the email addresses and names of all the
!     authors/owners of the PEP.  The format of the author entry should
!     be
  
          address@dom.ain (Random J. User)
  
!     and if there are multiple authors, each should be on a separate
!     line following RFC 822 continuation line conventions.
  
      Standards track PEPs must have a Python-Version: header which
--- 204,221 ----
        * Replaced-By: 
  
!     The Author: header lists the names and optionally, the email
!     addresses of all the authors/owners of the PEP.  The format of the
!     author entry should be
  
          address@dom.ain (Random J. User)
  
!     if the email address is included, and just
! 
!         Random J. User
! 
!     if the address is not given.  If there are multiple authors, each
!     should be on a separate line following RFC 822 continuation line
!     conventions.  Note that personal email addresses in PEPs will be
!     obscured as a defense against spam harvesters.
  
      Standards track PEPs must have a Python-Version: header which
***************
*** 224,228 ****
      header is necessary if the PEP is being discussed privately with
      the author, or on the python-list or python-dev email mailing
!     lists.
  
      Created: records the date that the PEP was assigned a number,
--- 228,233 ----
      header is necessary if the PEP is being discussed privately with
      the author, or on the python-list or python-dev email mailing
!     lists.  Note that email addresses in the Discussions-To: header
!     will not be obscured.
  
      Created: records the date that the PEP was assigned a number,
***************
*** 366,368 ****
--- 371,375 ----
  mode: indented-text
  indent-tabs-mode: nil
+ sentence-end-double-space: t
+ fill-column: 70
  End:





From gvanrossum@users.sourceforge.net  Tue May 28 16:54:47 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Tue, 28 May 2002 08:54:47 -0700
Subject: [Python-checkins] python/nondist/peps pep-0283.txt,1.4,1.5
Message-ID: 

Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv8965

Modified Files:
	pep-0283.txt 
Log Message:
Total rewrite.  Claimed authorship.  (Will update PEP 0 too.)


Index: pep-0283.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0283.txt,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** pep-0283.txt	25 May 2002 00:19:11 -0000	1.4
--- pep-0283.txt	28 May 2002 15:54:45 -0000	1.5
***************
*** 2,6 ****
  Title: Python 2.3 Release Schedule
  Version: $Revision$
! Author: jeremy@zope.com (Jeremy Hylton)
  Status: Incomplete
  Type: Informational
--- 2,6 ----
  Title: Python 2.3 Release Schedule
  Version: $Revision$
! Author: Guido van Rossum
  Status: Incomplete
  Type: Informational
***************
*** 11,55 ****
  Abstract
  
!     This document describes the post-Python 2.2 development and
!     release schedule.  The schedule primarily concerns itself with
!     PEP-sized items.  Small bug fixes and changes will occur up until
!     the first beta release.
! 
!     NOTE: the schedule below and the list of features under
!     consideration are all subject to change!  If the energy in the
!     community changes or the feedback on a PEP is particularly
!     positive or negative, this may affect decisions.
! 
!     This schedule will change!  See the discussion started here:
!     http://mail.python.org/pipermail/python-dev/2002-May/024395.html
  
! Release Schedule
  
!     Tentative future release dates.
  
-     30-Aug-2002: 2.3   (final release)
-     26-Aug-2002: 2.3c1 (release candidate)
-     14-Aug-2002: 2.3b2
-     17-Jul-2002: 2.3b1
-     19-Jun-2002: 2.3a2
-     22-May-2002: 2.3a1
  
  Release Manager
  
!     TBD
  
  Planned features for 2.3
  
!     TBD
  
!     Here are a few PEPs that I know to be under consideration.  If a
!     PEP isn't on this list, it's because I'm not a confident channeler.
  
-     PEP 266  Optimizing Global Variable/Attribute Access  Montanaro
-     PEP 267  Optimized Access to Module Namespaces        Hylton
-     PEP 269  Pgen Module for Python                       Riehl
-     PEP 273  Import Modules from Zip Archives             Ahlstrom
-     PEP 280  Optimizing access to globals                 van Rossum
-     PEP 282  A Logging System                             Mick
  
  Copyright
--- 11,179 ----
  Abstract
  
!     This document describes the development and release schedule for
!     Python 2.3.  The schedule primarily concerns itself with PEP-sized
!     items.  Small features may be added until the first beta release.
!     Bugs may be fixed until the final release.
  
!     There is currently no defined schedule.  We hope to release at
!     least the first alpha before OSCON 2002, and the final release
!     before the end of 2002, but if important projects below are
!     delayed, the release may be delayed.
  
!     There will be at least two alpha releases, two beta releases, and
!     one release candidate.  Alpha and beta releases will be spaced at
!     least 4 weeks apart (except if an emergency release must be made
!     to correct a blunder in the previous release; then the blunder
!     release does not count).  Release candidates will be spaced at
!     least one week apart (excepting again blunder corrections).
  
  
  Release Manager
  
!     Barry Warsaw.  (Didn't have his finger on his nose in time. :)
! 
  
  Planned features for 2.3
  
!     Here are a few PEPs and other ideas under consideration, with
!     comments in "parade of the PEPs" style.  Not all of these will be
!     part of the final 2.3 release; we'll update the list as decisions
!     crystallize.  (There's also a bunch of things already implemented,
!     like bool, PyMalloc, and universal newlines.)
  
!     This is pretty much an unordered laundry list.  Please send
!     feedback to python-dev@python.org; I hope to maintain this for the
!     life of the 2.3 development process.
! 
!     - PEP 266  Optimizing Global Variable/Attribute Access  Montanaro
!       PEP 267  Optimized Access to Module Namespaces        Hylton
!       PEP 280  Optimizing access to globals                 van Rossum
! 
!       These are basically three friendly competing proposals.  Jeremy
!       has made a little progress with a new compiler, but it's going
!       slow and the compiler is only the first step.  Maybe we'll be
!       able to refactor the compiler in this release.  I'm tempted to
!       say we won't hold our breath.  In the mean time, Oren Tirosh has
!       a much simpler idea that may give a serious boost to the
!       performance of accessing globals and built-ins, by optimizing
!       and inlining the dict access:
!       http://tothink.com/python/fastnames/
! 
!     - PEP 269  Pgen Module for Python                       Riehl
! 
!       I haven't heard from Jon Riehl, so I consider dropping this idea.
! 
!     - PEP 273  Import Modules from Zip Archives             Ahlstrom
! 
!       I think this is close -- maybe it's already checked in and I
!       don't know about it!
! 
!     - PEP 282  A Logging System                             Mick
! 
!       Vinay Sajip has been making steady progress on an
!       implementation, and despite a recent near-flamewar (which I
!       haven't followed) I expect that his code will be incorporated in
!       the near future.
! 
!     - Provide alternatives for common uses of the types module;
!       Skip Montanaro has posted a proto-PEP for this idea:
!       http://mail.python.org/pipermail/python-dev/2002-May/024346.html
! 
!     - Extended slice notation for all built-in sequences.  Raymond
!       Hettinger is working on this.
! 
!     - An iterator tools module featuring goodies from SML and Haskell?
!       http://mail.python.org/pipermail/python-dev/2002-May/024418.html
! 
!     - Speed up list iterations by filling tp_iter and other tweaks?
!       http://www.python.org/sf/560736
! 
!     - Fix the buffer object???
!       http://mail.python.org/pipermail/python-dev/2002-May/023896.html
! 
!     - Lazily tracking tuples?
!       http://mail.python.org/pipermail/python-dev/2002-May/023926.html
!       http://www.python.org/sf/558745
! 
!     - Timeoutsocket.  Work in progress.
!       http://mail.python.org/pipermail/python-dev/2002-May/024077.html
!       http://www.python.org/sf/555085
! 
!     - Making None a keyword.  Can't be done right away, but a warning
!       would be a first step.
!       http://mail.python.org/pipermail/python-dev/2002-April/023600.html
! 
!     - Stage 2 of the int/long integration (PEP 237).  This mostly
!       means warning about situations where hex, oct or shift of an int
!       returns a different value than for the same value as a long.  I
!       propose *not* to change the semantics this time; that will
!       happen in the next release, still with a warning.  (I think the
!       PEP misses this step, but it's necessary -- we can't just change
!       the semantics silently without warning first.)  Does this need a
!       __future__ statement???
! 
!     - Nuke SET_LINENO from all code objects (providing a different way
!       to set debugger breakpoints).  This can boost pystone by >5%.
!       (Tim Peters.)
! 
!     - Write a pymemcompat.h that people can bundle with their
!       extensions and then use the 2.3 memory interface with all
!       Pythons in the range 1.5.2 to 2.3.  (Michael Hudson.)
! 
!     - PEP 262  Database of Installed Python Packages        Kuchling
! 
!       Andrew is still hopeful that he'll implement this.
! 
!     - Add support for the long-awaited Python catalog.  Kapil
!       Thangavelu is working on an implementation (he's planning a demo
!       for OSCON 2002).  What else is needed?
! 
!     - PEP 286  Enhanced Argument Tuples                     von Loewis
! 
!       I haven't had the time to review this thoroughly.  It seems a
!       deep optimization hack (also makes better correctness guarantees
!       though).
! 
!     - Warn when an extension type's tp_compare returns anything except
!       -1, 0 or 1.  http://www.python.org/sf/472523
! 
!     - A standard datetime type.  An implementation effort is under way:
!       http://www.zope.org/Members/fdrake/DateTimeWiki/FrontPage
!       Effbot and MAL have a proposal for a basic interface that all
!       datetime types should implement, but there are some problems with
!       UTC.  A decision needs to be made.
! 
!     - PEP 272  API for Block Encryption Algorithms          Kuchling
! 
!       Andrew wants to finish this.  I've heard one person (who shall
!       remain nameless) comment that there's no need for such an API.
! 
!     - Decide on a clearer deprecation policy (especially for modules)
!       and act on it.  For a start, see this message from Neil Norwitz:
!       http://mail.python.org/pipermail/python-dev/2002-April/023165.html
! 
!     - Documentation: complete the distribution and installation
!       manuals.
! 
!     - Documentation: complete the documentation for new-style
!       classes.
! 
!     - Look over the Demos/ directory and update where required.
! 
!     - New tests.
! 
!     - Fix doc bugs on SF.
! 
!     - Remove use of deprecated features in the core.
! 
!     - Doc deprecated features appropriately
! 
!     - Move deprecated features under Py_DEPRECATED (or whatever is decided)
! 
!     - Deprecate modules which are unmaintained, or perhaps make a new
!       category for modules 'Unmaintained'
! 
!     - In general, lots of cleanup so it is easier to move forward.
  
  
  Copyright





From gvanrossum@users.sourceforge.net  Tue May 28 19:47:31 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Tue, 28 May 2002 11:47:31 -0700
Subject: [Python-checkins] python/dist/src/Python compile.c,2.243,2.244
Message-ID: 

Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv16868

Modified Files:
	compile.c 
Log Message:
Accept u"..." literals even when Unicode is disabled.  But these
literals must not contain \u, \U or \N escapes.  (XXX Should they also
not contain non-ASCII characters?)


Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.243
retrieving revision 2.244
diff -C2 -d -r2.243 -r2.244
*** compile.c	24 May 2002 15:47:06 -0000	2.243
--- compile.c	28 May 2002 18:47:29 -0000	2.244
***************
*** 1131,1147 ****
  	int quote = first;
  	int rawmode = 0;
- #ifdef Py_USING_UNICODE
  	int unicode = 0;
! #endif
  	if (isalpha(quote) || quote == '_') {
  		if (quote == 'u' || quote == 'U') {
- #ifdef Py_USING_UNICODE
  			quote = *++s;
  			unicode = 1;
- #else
- 			com_error(com, PyExc_SyntaxError,
- 				  "Unicode literals not supported in this Python");
- 			return NULL;
- #endif
  		}
  		if (quote == 'r' || quote == 'R') {
--- 1131,1140 ----
  	int quote = first;
  	int rawmode = 0;
  	int unicode = 0;
! 
  	if (isalpha(quote) || quote == '_') {
  		if (quote == 'u' || quote == 'U') {
  			quote = *++s;
  			unicode = 1;
  		}
  		if (quote == 'r' || quote == 'R') {
***************
*** 1251,1254 ****
--- 1244,1259 ----
  				  "invalid \\x escape");
  			return NULL;
+ #ifndef Py_USING_UNICODE
+ 		case 'u':
+ 		case 'U':
+ 		case 'N':
+ 			if (unicode) {
+ 				Py_DECREF(v);
+ 				com_error(com, PyExc_ValueError,
+ 					  "Unicode escapes not legal "
+ 					  "when Unicode disabled");
+ 				return NULL;
+ 			}
+ #endif
  		default:
  			*p++ = '\\';





From gvanrossum@users.sourceforge.net  Tue May 28 19:49:06 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Tue, 28 May 2002 11:49:06 -0700
Subject: [Python-checkins] python/dist/src/Lib/email Charset.py,1.2,1.3
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib/email
In directory usw-pr-cvs1:/tmp/cvs-serv18378

Modified Files:
	Charset.py 
Log Message:
Importing Charset should not fail when Unicode is disabled.  (XXX
Using Unicode-aware methods may still die with a NameError on unicode.
Maybe there's a more elegant solution but I doubt anybody cares.)


Index: Charset.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/Charset.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Charset.py	23 May 2002 15:15:29 -0000	1.2
--- Charset.py	28 May 2002 18:49:03 -0000	1.3
***************
*** 2,6 ****
  # Author: che@debian.org (Ben Gertzfield)
  
! from types import UnicodeType
  from email.Encoders import encode_7or8bit
  import email.base64MIME
--- 2,14 ----
  # Author: che@debian.org (Ben Gertzfield)
  
! try:
!     unicode
! except NameError:
!     def _is_unicode(x):
!         return 1==0
! else:
!     def _is_unicode(x):
!         return isinstance(x, unicode)
!     
  from email.Encoders import encode_7or8bit
  import email.base64MIME
***************
*** 227,231 ****
          with the Unicode replacement character U+FFFD.
          """
!         if isinstance(s, UnicodeType) or self.input_codec is None:
              return s
          try:
--- 235,239 ----
          with the Unicode replacement character U+FFFD.
          """
!         if _is_unicode(s) or self.input_codec is None:
              return s
          try:
***************
*** 255,259 ****
          else:
              codec = self.input_codec
!         if not isinstance(ustr, UnicodeType) or codec is None:
              return ustr
          try:
--- 263,267 ----
          else:
              codec = self.input_codec
!         if not _is_unicode(ustr) or codec is None:
              return ustr
          try:





From tismer@tismer.com  Tue May 28 21:08:30 2002
From: tismer@tismer.com (Christian Tismer)
Date: Tue, 28 May 2002 13:08:30 -0700
Subject: [Python-checkins] python/dist/src/Lib/bdb.py
Message-ID: <3CF3E3BE.7020503@tismer.com>

(this message is hand-generated, due to a crash in the notification system)
Update of /cvsroot/python/python/dist/src/Lib

Modified files:
         bdb.py
Log message:
This is a Python 2.1 and 2.2 bugfix candidate:
(or how do I "mark" something to be a candidate?)

fixed an old buglet that caused bdb to be unable to
continue in the botframe, after a breakpoint was set.
the key idea is not to set botframe to the bottom level frame,
but its f_back, which actually might be None.
Additional changes: migrated old exception trick to use
sys._getframe(), which exists both in 2.1 and 2.2 .

Note: I believe Mark Hammond needs to look over his code now.
F5 correctly starts up in the debugger, but later on doesn't stop at a given
breakpoint any longer.

kind regards - chris

Index: bdb.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/bdb.py,v
retrieving revision 1.38
retrieving revision 1.39
diff -r1.38 -r1.39
68c68
<             self.botframe = frame
---
 >             self.botframe = frame.f_back # (CT) Note that this may 
also be None!
94,95c94,95
<         if self.stopframe is None:
<             return True
---
 > 		# (CT) stopframe may now also be None, see dispatch_call.
 > 		# (CT) the former test for None is therefore removed from here.
172,175c172
<         try:
<             raise Exception
<         except:
<             frame = sys.exc_info()[2].tb_frame.f_back
---
 >         frame = sys._getframe().f_back
192,195c189
<             try:
<                 raise Exception
<             except:
<                 frame = sys.exc_info()[2].tb_frame.f_back
---
 >             frame = sys._getframe().f_back




From nnorwitz@users.sourceforge.net  Wed May 29 01:54:40 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Tue, 28 May 2002 17:54:40 -0700
Subject: [Python-checkins] python/dist/src/Lib bdb.py,1.39,1.40
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv10215

Modified Files:
	bdb.py 
Log Message:
Whitespace normalization

Index: bdb.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/bdb.py,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -d -r1.39 -r1.40
*** bdb.py	28 May 2002 08:04:00 -0000	1.39
--- bdb.py	29 May 2002 00:54:38 -0000	1.40
***************
*** 92,97 ****
  
      def stop_here(self, frame):
! 		# (CT) stopframe may now also be None, see dispatch_call.
! 		# (CT) the former test for None is therefore removed from here.
          if frame is self.stopframe:
              return True
--- 92,97 ----
  
      def stop_here(self, frame):
!         # (CT) stopframe may now also be None, see dispatch_call.
!         # (CT) the former test for None is therefore removed from here.
          if frame is self.stopframe:
              return True





From nnorwitz@users.sourceforge.net  Wed May 29 02:17:49 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Tue, 28 May 2002 18:17:49 -0700
Subject: [Python-checkins] python/dist/src/Lib bdb.py,1.33.6.1,1.33.6.2
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv20577

Modified Files:
      Tag: release22-maint
	bdb.py 
Log Message:
Backport fix by tismer for #210682

fixed an old buglet that caused bdb to be unable to
continue in the botframe, after a breakpoint was set.
the key idea is not to set botframe to the bottom level frame,
but its f_back, which actually might be None.
Additional changes: migrated old exception trick to use
sys._getframe(), which exists both in 2.1 and 2.2 .

Note: I believe Mark Hammond needs to look over his code now.
F5 correctly starts up in the debugger, but later on doesn't stop at a given
breakpoint any longer.

kind regards - chris



Index: bdb.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/bdb.py,v
retrieving revision 1.33.6.1
retrieving revision 1.33.6.2
diff -C2 -d -r1.33.6.1 -r1.33.6.2
*** bdb.py	28 Feb 2002 10:00:34 -0000	1.33.6.1
--- bdb.py	29 May 2002 01:17:47 -0000	1.33.6.2
***************
*** 65,69 ****
          if self.botframe is None:
              # First call of dispatch since reset()
!             self.botframe = frame
              return self.trace_dispatch
          if not (self.stop_here(frame) or self.break_anywhere(frame)):
--- 65,69 ----
          if self.botframe is None:
              # First call of dispatch since reset()
!             self.botframe = frame.f_back # (CT) Note that this may also be None!
              return self.trace_dispatch
          if not (self.stop_here(frame) or self.break_anywhere(frame)):
***************
*** 91,96 ****
  
      def stop_here(self, frame):
!         if self.stopframe is None:
!             return 1
          if frame is self.stopframe:
              return 1
--- 91,96 ----
  
      def stop_here(self, frame):
!         # (CT) stopframe may now also be None, see dispatch_call.
!         # (CT) the former test for None is therefore removed from here.
          if frame is self.stopframe:
              return 1
***************
*** 169,176 ****
      def set_trace(self):
          """Start debugging from here."""
!         try:
!             1 + ''
!         except:
!             frame = sys.exc_info()[2].tb_frame.f_back
          self.reset()
          while frame:
--- 169,173 ----
      def set_trace(self):
          """Start debugging from here."""
!         frame = sys._getframe().f_back
          self.reset()
          while frame:
***************
*** 189,196 ****
              # no breakpoints; run without debugger overhead
              sys.settrace(None)
!             try:
!                 1 + ''  # raise an exception
!             except:
!                 frame = sys.exc_info()[2].tb_frame.f_back
              while frame and frame is not self.botframe:
                  del frame.f_trace
--- 186,190 ----
              # no breakpoints; run without debugger overhead
              sys.settrace(None)
!             frame = sys._getframe().f_back
              while frame and frame is not self.botframe:
                  del frame.f_trace





From nnorwitz@users.sourceforge.net  Wed May 29 02:29:40 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Tue, 28 May 2002 18:29:40 -0700
Subject: [Python-checkins] python/dist/src/Lib bdb.py,1.31,1.31.2.1
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv25208

Modified Files:
      Tag: release21-maint
	bdb.py 
Log Message:
Backport fix by tismer for #210682

fixed an old buglet that caused bdb to be unable to
continue in the botframe, after a breakpoint was set.
the key idea is not to set botframe to the bottom level frame,
but its f_back, which actually might be None.
Additional changes: migrated old exception trick to use
sys._getframe(), which exists both in 2.1 and 2.2 .

Note: I believe Mark Hammond needs to look over his code now.
F5 correctly starts up in the debugger, but later on doesn't stop at a given
breakpoint any longer.

kind regards - chris


Index: bdb.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/bdb.py,v
retrieving revision 1.31
retrieving revision 1.31.2.1
diff -C2 -d -r1.31 -r1.31.2.1
*** bdb.py	8 Apr 2001 15:05:16 -0000	1.31
--- bdb.py	29 May 2002 01:29:38 -0000	1.31.2.1
***************
*** 62,66 ****
          if self.botframe is None:
              # First call of dispatch since reset()
!             self.botframe = frame
              return self.trace_dispatch
          if not (self.stop_here(frame) or self.break_anywhere(frame)):
--- 62,66 ----
          if self.botframe is None:
              # First call of dispatch since reset()
!             self.botframe = frame.f_back # (CT) Note that this may also be None!
              return self.trace_dispatch
          if not (self.stop_here(frame) or self.break_anywhere(frame)):
***************
*** 87,92 ****
  
      def stop_here(self, frame):
!         if self.stopframe is None:
!             return 1
          if frame is self.stopframe:
              return 1
--- 87,92 ----
  
      def stop_here(self, frame):
!         # (CT) stopframe may now also be None, see dispatch_call.
!         # (CT) the former test for None is therefore removed from here.
          if frame is self.stopframe:
              return 1
***************
*** 165,172 ****
      def set_trace(self):
          """Start debugging from here."""
!         try:
!             1 + ''
!         except:
!             frame = sys.exc_info()[2].tb_frame.f_back
          self.reset()
          while frame:
--- 165,169 ----
      def set_trace(self):
          """Start debugging from here."""
!         frame = sys._getframe().f_back
          self.reset()
          while frame:
***************
*** 185,192 ****
              # no breakpoints; run without debugger overhead
              sys.settrace(None)
!             try:
!                 1 + ''  # raise an exception
!             except:
!                 frame = sys.exc_info()[2].tb_frame.f_back
              while frame and frame is not self.botframe:
                  del frame.f_trace
--- 182,186 ----
              # no breakpoints; run without debugger overhead
              sys.settrace(None)
!             frame = sys._getframe().f_back
              while frame and frame is not self.botframe:
                  del frame.f_trace





From guido@python.org  Wed May 29 03:30:41 2002
From: guido@python.org (Guido van Rossum)
Date: Tue, 28 May 2002 22:30:41 -0400
Subject: [Python-checkins] python/dist/src/Lib bdb.py,1.31,1.31.2.1
In-Reply-To: Your message of "Tue, 28 May 2002 18:29:40 PDT."
 
References: 
Message-ID: <200205290230.g4T2Ufk04600@pcp742651pcs.reston01.va.comcast.net>

> Backport fix by tismer for #210682

Thanks, Neal!

--Guido van Rossum (home page: http://www.python.org/~guido/)



From mwh@users.sourceforge.net  Wed May 29 11:32:26 2002
From: mwh@users.sourceforge.net (mwh@users.sourceforge.net)
Date: Wed, 29 May 2002 03:32:26 -0700
Subject: [Python-checkins] python/dist/src/Modules md5.h,2.7,2.8
Message-ID: 

Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv16787

Modified Files:
	md5.h 
Log Message:
This is patch

[ 558914 ] Build md5.c fails on Cray T3E

I've also deleted a comment that I didn't understand.  Feel free to 
put it back if it makes/made sense to you.


Index: md5.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/md5.h,v
retrieving revision 2.7
retrieving revision 2.8
diff -C2 -d -r2.7 -r2.8
*** md5.h	26 Sep 2000 05:46:01 -0000	2.7
--- md5.h	29 May 2002 10:32:24 -0000	2.8
***************
*** 31,45 ****
  typedef unsigned char *POINTER;
  
- /* UINT2 defines a two byte word */
- typedef unsigned short int UINT2;
- 
  /* UINT4 defines a four byte word */
  #if SIZEOF_LONG == 4
  typedef unsigned long int UINT4;
! #else
! #if INT_MAX == 2147483647
  typedef unsigned int UINT4;
- #endif
- /* Too bad if neither is; pyport.h would need to be fixed. */
  #endif
  
--- 31,41 ----
  typedef unsigned char *POINTER;
  
  /* UINT4 defines a four byte word */
  #if SIZEOF_LONG == 4
  typedef unsigned long int UINT4;
! #elif SIZEOF_SHORT == 4
! typedef unsigned short int UINT4;
! #elif INT_MAX == 2147483647
  typedef unsigned int UINT4;
  #endif
  





From lemburg@users.sourceforge.net  Wed May 29 12:33:15 2002
From: lemburg@users.sourceforge.net (lemburg@users.sourceforge.net)
Date: Wed, 29 May 2002 04:33:15 -0700
Subject: [Python-checkins] python/dist/src/Objects unicodeobject.c,2.149,2.150
Message-ID: 

Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv2190/Objects

Modified Files:
	unicodeobject.c 
Log Message:
Fix for bug [ 561796 ] string.find causes lazy error



Index: unicodeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.149
retrieving revision 2.150
diff -C2 -d -r2.149 -r2.150
*** unicodeobject.c	24 May 2002 19:01:59 -0000	2.149
--- unicodeobject.c	29 May 2002 11:33:13 -0000	2.150
***************
*** 2888,2896 ****
      str = PyUnicode_FromObject(str);
      if (str == NULL)
! 	return -1;
      substr = PyUnicode_FromObject(substr);
      if (substr == NULL) {
  	Py_DECREF(substr);
! 	return -1;
      }
      
--- 2888,2896 ----
      str = PyUnicode_FromObject(str);
      if (str == NULL)
! 	return -2;
      substr = PyUnicode_FromObject(substr);
      if (substr == NULL) {
  	Py_DECREF(substr);
! 	return -2;
      }
      





From lemburg@users.sourceforge.net  Wed May 29 12:33:15 2002
From: lemburg@users.sourceforge.net (lemburg@users.sourceforge.net)
Date: Wed, 29 May 2002 04:33:15 -0700
Subject: [Python-checkins] python/dist/src/Include unicodeobject.h,2.37,2.38
Message-ID: 

Update of /cvsroot/python/python/dist/src/Include
In directory usw-pr-cvs1:/tmp/cvs-serv2190/Include

Modified Files:
	unicodeobject.h 
Log Message:
Fix for bug [ 561796 ] string.find causes lazy error



Index: unicodeobject.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/unicodeobject.h,v
retrieving revision 2.37
retrieving revision 2.38
diff -C2 -d -r2.37 -r2.38
*** unicodeobject.h	22 Apr 2002 17:42:37 -0000	2.37
--- unicodeobject.h	29 May 2002 11:33:13 -0000	2.38
***************
*** 984,988 ****
  
  /* Return the first position of substr in str[start:end] using the
!    given search direction or -1 if not found. */
  
  extern DL_IMPORT(int) PyUnicode_Find(
--- 984,989 ----
  
  /* Return the first position of substr in str[start:end] using the
!    given search direction or -1 if not found. -2 is returned in case
!    an error occurred and an exception is set. */
  
  extern DL_IMPORT(int) PyUnicode_Find(





From neal@metaslash.com  Wed May 29 14:24:45 2002
From: neal@metaslash.com (Neal Norwitz)
Date: Wed, 29 May 2002 09:24:45 -0400
Subject: [Python-checkins] python/dist/src/Objects
 unicodeobject.c,2.149,2.150
References: 
Message-ID: <3CF4D69D.A7952150@metaslash.com>

lemburg@users.sourceforge.net wrote:

> Index: unicodeobject.c
> ===================================================================
>       substr = PyUnicode_FromObject(substr);
>       if (substr == NULL) {
>         Py_DECREF(substr);
> !       return -2;
>       }

Can this code be correct?  If substr is NULL, then it will be DECREF'd?
It would seem the original substr should perhaps be DECREF'd.
It seems like there needs to be another local variable.
Also looking at the handling of str wrt DECREF'ing, this is different
than substr, is that correct?

Neal



From lemburg@users.sourceforge.net  Wed May 29 14:46:31 2002
From: lemburg@users.sourceforge.net (lemburg@users.sourceforge.net)
Date: Wed, 29 May 2002 06:46:31 -0700
Subject: [Python-checkins] python/dist/src/Objects unicodeobject.c,2.150,2.151
Message-ID: 

Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv23817/Objects

Modified Files:
	unicodeobject.c 
Log Message:
Fix a possible segfault. Found be Neal Norvitz.



Index: unicodeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.150
retrieving revision 2.151
diff -C2 -d -r2.150 -r2.151
*** unicodeobject.c	29 May 2002 11:33:13 -0000	2.150
--- unicodeobject.c	29 May 2002 13:46:29 -0000	2.151
***************
*** 2891,2895 ****
      substr = PyUnicode_FromObject(substr);
      if (substr == NULL) {
! 	Py_DECREF(substr);
  	return -2;
      }
--- 2891,2895 ----
      substr = PyUnicode_FromObject(substr);
      if (substr == NULL) {
! 	Py_DECREF(str);
  	return -2;
      }





From mal@lemburg.com  Wed May 29 14:47:47 2002
From: mal@lemburg.com (M.-A. Lemburg)
Date: Wed, 29 May 2002 15:47:47 +0200
Subject: [Python-checkins] python/dist/src/Objects  unicodeobject.c,2.149,2.150
References:  <3CF4D69D.A7952150@metaslash.com>
Message-ID: <3CF4DC03.7070002@lemburg.com>

Neal Norwitz wrote:
> lemburg@users.sourceforge.net wrote:
> 
> 
>>Index: unicodeobject.c
>>===================================================================
>>      substr = PyUnicode_FromObject(substr);
>>      if (substr == NULL) {
>>        Py_DECREF(substr);
>>!       return -2;
>>      }
> 
> 
> Can this code be correct?  If substr is NULL, then it will be DECREF'd?
> It would seem the original substr should perhaps be DECREF'd.
> It seems like there needs to be another local variable.
> Also looking at the handling of str wrt DECREF'ing, this is different
> than substr, is that correct?

Good catch. That should be Py_DECREF(str);

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Company & Consulting:                           http://www.egenix.com/
Python Software:                   http://www.egenix.com/files/python/
Meet us at EuroPython 2002:                 http://www.europython.org/




From gvanrossum@users.sourceforge.net  Wed May 29 15:00:24 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Wed, 29 May 2002 07:00:24 -0700
Subject: [Python-checkins] python/dist/src/Modules md5.h,2.8,2.9
Message-ID: 

Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv32025

Modified Files:
	md5.h 
Log Message:
Issue an explicit error when we can't find an appropriate type for
UINT4.


Index: md5.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/md5.h,v
retrieving revision 2.8
retrieving revision 2.9
diff -C2 -d -r2.8 -r2.9
*** md5.h	29 May 2002 10:32:24 -0000	2.8
--- md5.h	29 May 2002 14:00:22 -0000	2.9
***************
*** 38,41 ****
--- 38,43 ----
  #elif INT_MAX == 2147483647
  typedef unsigned int UINT4;
+ #else
+ #error "Can't find a 4-byte integral type"
  #endif
  





From gvanrossum@users.sourceforge.net  Wed May 29 16:43:07 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Wed, 29 May 2002 08:43:07 -0700
Subject: [Python-checkins] python/nondist/peps pep-0283.txt,1.5,1.6
Message-ID: 

Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv1262

Modified Files:
	pep-0283.txt 
Log Message:
Add silent deprecation.


Index: pep-0283.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0283.txt,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** pep-0283.txt	28 May 2002 15:54:45 -0000	1.5
--- pep-0283.txt	29 May 2002 15:43:05 -0000	1.6
***************
*** 153,156 ****
--- 153,164 ----
        http://mail.python.org/pipermail/python-dev/2002-April/023165.html
  
+     - Add a new concept, "silent deprecation", with associated warning
+       SilentDeprecationWarning.  This warning is normally suppressed,
+       but can be enabled by a suitable -W option.
+ 
+     - Use silent deprecation for the types and string modules.  This
+       requires providing alternatives for the parts that aren't
+       covered yet (e.g. string.whitespace and types.TracebackType).
+ 
      - Documentation: complete the distribution and installation
        manuals.





From nnorwitz@users.sourceforge.net  Wed May 29 16:54:56 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Wed, 29 May 2002 08:54:56 -0700
Subject: [Python-checkins] python/dist/src/Lib warnings.py,1.13,1.14
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv13399/Lib

Modified Files:
	warnings.py 
Log Message:
As discussed on python-dev, add a mechanism to indicate features
that are in the process of deprecation (PendingDeprecationWarning).
Docs could be improved.


Index: warnings.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/warnings.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** warnings.py	16 Apr 2002 01:51:25 -0000	1.13
--- warnings.py	29 May 2002 15:54:53 -0000	1.14
***************
*** 263,264 ****
--- 263,265 ----
      _processoptions(sys.warnoptions)
      filterwarnings("ignore", category=OverflowWarning, append=1)
+     filterwarnings("ignore", category=PendingDeprecationWarning, append=1)





From nnorwitz@users.sourceforge.net  Wed May 29 16:54:56 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Wed, 29 May 2002 08:54:56 -0700
Subject: [Python-checkins] python/dist/src/Python exceptions.c,1.30,1.31
Message-ID: 

Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv13399/Python

Modified Files:
	exceptions.c 
Log Message:
As discussed on python-dev, add a mechanism to indicate features
that are in the process of deprecation (PendingDeprecationWarning).
Docs could be improved.


Index: exceptions.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/exceptions.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** exceptions.c	28 Mar 2002 20:57:51 -0000	1.30
--- exceptions.c	29 May 2002 15:54:54 -0000	1.31
***************
*** 111,114 ****
--- 111,115 ----
        +-- UserWarning\n\
        +-- DeprecationWarning\n\
+       +-- PendingDeprecationWarning\n\
        +-- SyntaxWarning\n\
        +-- OverflowWarning\n\
***************
*** 921,924 ****
--- 922,930 ----
  
  static char
+ PendingDeprecationWarning__doc__[] =
+ "Base class for warnings about features which will be deprecated "
+ "in the future.";
+ 
+ static char
  SyntaxWarning__doc__[] = "Base class for warnings about dubious syntax.";
  
***************
*** 988,991 ****
--- 994,998 ----
  PyObject *PyExc_UserWarning;
  PyObject *PyExc_DeprecationWarning;
+ PyObject *PyExc_PendingDeprecationWarning;
  PyObject *PyExc_SyntaxWarning;
  PyObject *PyExc_OverflowWarning;
***************
*** 1064,1067 ****
--- 1071,1076 ----
   {"DeprecationWarning", &PyExc_DeprecationWarning, &PyExc_Warning,
    DeprecationWarning__doc__},
+  {"PendingDeprecationWarning", &PyExc_PendingDeprecationWarning, &PyExc_Warning,
+   PendingDeprecationWarning__doc__},
   {"SyntaxWarning", &PyExc_SyntaxWarning, &PyExc_Warning, SyntaxWarning__doc__},
   {"OverflowWarning", &PyExc_OverflowWarning, &PyExc_Warning,





From nnorwitz@users.sourceforge.net  Wed May 29 16:54:57 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Wed, 29 May 2002 08:54:57 -0700
Subject: [Python-checkins] python/dist/src/Include pyerrors.h,2.53,2.54
Message-ID: 

Update of /cvsroot/python/python/dist/src/Include
In directory usw-pr-cvs1:/tmp/cvs-serv13399/Include

Modified Files:
	pyerrors.h 
Log Message:
As discussed on python-dev, add a mechanism to indicate features
that are in the process of deprecation (PendingDeprecationWarning).
Docs could be improved.


Index: pyerrors.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/pyerrors.h,v
retrieving revision 2.53
retrieving revision 2.54
diff -C2 -d -r2.53 -r2.54
*** pyerrors.h	3 Dec 2001 00:43:33 -0000	2.53
--- pyerrors.h	29 May 2002 15:54:54 -0000	2.54
***************
*** 67,70 ****
--- 67,71 ----
  extern DL_IMPORT(PyObject *) PyExc_UserWarning;
  extern DL_IMPORT(PyObject *) PyExc_DeprecationWarning;
+ extern DL_IMPORT(PyObject *) PyExc_PendingDeprecationWarning;
  extern DL_IMPORT(PyObject *) PyExc_SyntaxWarning;
  extern DL_IMPORT(PyObject *) PyExc_OverflowWarning;





From nnorwitz@users.sourceforge.net  Wed May 29 16:54:57 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Wed, 29 May 2002 08:54:57 -0700
Subject: [Python-checkins] python/dist/src/Misc NEWS,1.410,1.411
Message-ID: 

Update of /cvsroot/python/python/dist/src/Misc
In directory usw-pr-cvs1:/tmp/cvs-serv13399/Misc

Modified Files:
	NEWS 
Log Message:
As discussed on python-dev, add a mechanism to indicate features
that are in the process of deprecation (PendingDeprecationWarning).
Docs could be improved.


Index: NEWS
===================================================================
RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v
retrieving revision 1.410
retrieving revision 1.411
diff -C2 -d -r1.410 -r1.411
*** NEWS	27 May 2002 15:08:24 -0000	1.410
--- NEWS	29 May 2002 15:54:54 -0000	1.411
***************
*** 7,10 ****
--- 7,16 ----
  Core and builtins
  
+ - A new warning PendingDeprecationWarning was added to provide
+   direction on features which are in the process of being deprecated.
+   The warning will not be printed by default.  To see the pending
+   deprecations, use -Walways::PendingDeprecationWarning::
+   as a command line option or warnings.filterwarnings() in code.
+ 
  - A new type object, 'string', is added.  This is a common base type
    for 'str' and 'unicode', and can be used instead of





From nnorwitz@users.sourceforge.net  Wed May 29 16:54:57 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Wed, 29 May 2002 08:54:57 -0700
Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.16,1.17
Message-ID: 

Update of /cvsroot/python/python/dist/src/Doc/whatsnew
In directory usw-pr-cvs1:/tmp/cvs-serv13399/Doc/whatsnew

Modified Files:
	whatsnew23.tex 
Log Message:
As discussed on python-dev, add a mechanism to indicate features
that are in the process of deprecation (PendingDeprecationWarning).
Docs could be improved.


Index: whatsnew23.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** whatsnew23.tex	27 May 2002 17:19:46 -0000	1.16
--- whatsnew23.tex	29 May 2002 15:54:55 -0000	1.17
***************
*** 343,346 ****
--- 343,355 ----
  
  
+ %\begin{PendingDeprecationWarning}
+ A new warning PendingDeprecationWarning was added to provide
+ direction on features which are in the process of being deprecated.
+ The warning will not be printed by default.  To see the pending
+ deprecations, use -Walways::PendingDeprecationWarning:: on the command line
+ or warnings.filterwarnings().
+ %\end{PendingDeprecationWarning}
+ 
+ 
  %======================================================================
  \section{Specialized Object Allocator (pymalloc)\label{section-pymalloc}}





From nnorwitz@users.sourceforge.net  Wed May 29 16:54:57 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Wed, 29 May 2002 08:54:57 -0700
Subject: [Python-checkins] python/dist/src/Doc/lib libexcs.tex,1.45,1.46
Message-ID: 

Update of /cvsroot/python/python/dist/src/Doc/lib
In directory usw-pr-cvs1:/tmp/cvs-serv13399/Doc/lib

Modified Files:
	libexcs.tex 
Log Message:
As discussed on python-dev, add a mechanism to indicate features
that are in the process of deprecation (PendingDeprecationWarning).
Docs could be improved.


Index: libexcs.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libexcs.tex,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** libexcs.tex	28 Mar 2002 21:06:17 -0000	1.45
--- libexcs.tex	29 May 2002 15:54:55 -0000	1.46
***************
*** 377,380 ****
--- 377,384 ----
  \end{excdesc}
  
+ \begin{excdesc}{PendingDeprecationWarning}
+ Base class for warnings about features which will be deprecated in the future.
+ \end{excdesc}
+ 
  \begin{excdesc}{SyntaxWarning}
  Base class for warnings about dubious syntax
***************
*** 424,427 ****
--- 428,432 ----
  	  +-- UserWarning
  	  +-- DeprecationWarning
+ 	  +-- PendingDeprecationWarning
  	  +-- SyntaxWarning
  	  +-- OverflowWarning





From nnorwitz@users.sourceforge.net  Wed May 29 16:54:58 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Wed, 29 May 2002 08:54:58 -0700
Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.161,1.162
Message-ID: 

Update of /cvsroot/python/python/dist/src/Doc/tut
In directory usw-pr-cvs1:/tmp/cvs-serv13399/Doc/tut

Modified Files:
	tut.tex 
Log Message:
As discussed on python-dev, add a mechanism to indicate features
that are in the process of deprecation (PendingDeprecationWarning).
Docs could be improved.


Index: tut.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v
retrieving revision 1.161
retrieving revision 1.162
diff -C2 -d -r1.161 -r1.162
*** tut.tex	2 May 2002 14:31:55 -0000	1.161
--- tut.tex	29 May 2002 15:54:55 -0000	1.162
***************
*** 2454,2476 ****
  ['ArithmeticError', 'AssertionError', 'AttributeError',
   'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError',
!  'Exception', 'FloatingPointError', 'IOError', 'ImportError',
   'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt',
   'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented',
   'NotImplementedError', 'OSError', 'OverflowError', 'OverflowWarning',
!  'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError',
!  'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError',
!  'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError',
!  'UnicodeError', 'UserWarning', 'ValueError', 'Warning',
!  'ZeroDivisionError', '_', '__debug__', '__doc__', '__import__',
!  '__name__', 'abs', 'apply', 'buffer', 'callable', 'chr', 'classmethod',
!  'cmp', 'coerce', 'compile', 'complex', 'copyright', 'credits', 'delattr',
!  'dict', 'dir', 'divmod', 'eval', 'execfile', 'exit', 'file', 'filter',
!  'float', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id',
!  'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter', 'len',
!  'license', 'list', 'locals', 'long', 'map', 'max', 'min', 'object',
!  'oct', 'open', 'ord', 'pow', 'property', 'quit', 'range', 'raw_input',
!  'reduce', 'reload', 'repr', 'round', 'setattr', 'slice', 'staticmethod',
!  'str', 'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange',
!  'zip']
  \end{verbatim}
  
--- 2454,2477 ----
  ['ArithmeticError', 'AssertionError', 'AttributeError',
   'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError',
!  'Exception', 'False', 'FloatingPointError', 'IOError', 'ImportError',
   'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt',
   'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented',
   'NotImplementedError', 'OSError', 'OverflowError', 'OverflowWarning',
!  'PendingDeprecationWarning', 'ReferenceError',
!  'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration',
!  'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError',
!  'True', 'TypeError', 'UnboundLocalError', 'UnicodeError', 'UserWarning',
!  'ValueError', 'Warning', 'ZeroDivisionError', '__debug__', '__doc__',
!  '__import__', '__name__', 'abs', 'apply', 'bool', 'buffer',
!  'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'compile', 'complex',
!  'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod',
!  'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float',
!  'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id',
!  'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter',
!  'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min',
!  'object', 'oct', 'open', 'ord', 'pow', 'property', 'quit',
!  'range', 'raw_input', 'reduce', 'reload', 'repr', 'round',
!  'setattr', 'slice', 'staticmethod', 'str', 'string', 'super',
!  'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip']
  \end{verbatim}
  





From rhettinger@users.sourceforge.net  Wed May 29 17:18:44 2002
From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net)
Date: Wed, 29 May 2002 09:18:44 -0700
Subject: [Python-checkins] python/dist/src/Lib MimeWriter.py,1.7,1.8 cmd.py,1.28,1.29 dumbdbm.py,1.17,1.18 formatter.py,1.19,1.20 gzip.py,1.33,1.34 htmllib.py,1.18,1.19 pickle.py,1.63,1.64 rexec.py,1.34,1.35 robotparser.py,1.14,1.15
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv28724

Modified Files:
	MimeWriter.py cmd.py dumbdbm.py formatter.py gzip.py 
	htmllib.py pickle.py rexec.py robotparser.py 
Log Message:
Patch 560023 adding docstrings.  2.2 Candidate (after verifying modules were not updated after 2.2).

Index: MimeWriter.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/MimeWriter.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** MimeWriter.py	9 Feb 2001 09:34:36 -0000	1.7
--- MimeWriter.py	29 May 2002 16:18:41 -0000	1.8
***************
*** 1,7 ****
  """Generic MIME writer.
  
! Classes:
! 
! MimeWriter - the only thing here.
  
  """
--- 1,10 ----
  """Generic MIME writer.
  
! This module defines the class MimeWriter.  The MimeWriter class implements
! a basic formatter for creating MIME multi-part files.  It doesn't seek around
! the output file nor does it use large amounts of buffer space. You must write
! the parts out in the order that they should occur in the final file.
! MimeWriter does buffer the headers you add, allowing you to rearrange their
! order.
  
  """
***************
*** 87,90 ****
--- 90,101 ----
  
      def addheader(self, key, value, prefix=0):
+         """Add a header line to the MIME message.
+ 
+         The key is the name of the header, where the value obviously provides
+         the value of the header. The optional argument prefix determines
+         where the header is inserted; 0 means append at the end, 1 means
+         insert at the start. The default is to append.
+ 
+         """
          lines = value.split("\n")
          while lines and not lines[-1]: del lines[-1]
***************
*** 100,107 ****
--- 111,134 ----
  
      def flushheaders(self):
+         """Writes out and forgets all headers accumulated so far.
+ 
+         This is useful if you don't need a body part at all; for example,
+         for a subpart of type message/rfc822 that's (mis)used to store some
+         header-like information.
+ 
+         """
          self._fp.writelines(self._headers)
          self._headers = []
  
      def startbody(self, ctype, plist=[], prefix=1):
+         """Returns a file-like object for writing the body of the message.
+ 
+         The content-type is set to the provided ctype, and the optional
+         parameter, plist, provides additional parameters for the
+         content-type declaration.  The optional argument prefix determines
+         where the header is inserted; 0 means append at the end, 1 means
+         insert at the start. The default is to insert at the start.
+ 
+         """
          for name, value in plist:
              ctype = ctype + ';\n %s=\"%s\"' % (name, value)
***************
*** 112,115 ****
--- 139,154 ----
  
      def startmultipartbody(self, subtype, boundary=None, plist=[], prefix=1):
+         """Returns a file-like object for writing the body of the message.
+ 
+         Additionally, this method initializes the multi-part code, where the
+         subtype parameter provides the multipart subtype, the boundary
+         parameter may provide a user-defined boundary specification, and the
+         plist parameter provides optional parameters for the subtype.  The
+         optional argument, prefix, determines where the header is inserted;
+         0 means append at the end, 1 means insert at the start. The default
+         is to insert at the start.  Subparts should be created using the
+         nextpart() method.
+ 
+         """
          self._boundary = boundary or mimetools.choose_boundary()
          return self.startbody("multipart/" + subtype,
***************
*** 118,125 ****
--- 157,178 ----
  
      def nextpart(self):
+         """Returns a new instance of MimeWriter which represents an
+         individual part in a multipart message.
+ 
+         This may be used to write the part as well as used for creating
+         recursively complex multipart messages. The message must first be
+         initialized with the startmultipartbody() method before using the
+         nextpart() method.
+ 
+         """
          self._fp.write("\n--" + self._boundary + "\n")
          return self.__class__(self._fp)
  
      def lastpart(self):
+         """This is used to designate the last part of a multipart message.
+ 
+         It should always be used when writing multipart messages.
+ 
+         """
          self._fp.write("\n--" + self._boundary + "--\n")
  

Index: cmd.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/cmd.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** cmd.py	24 Mar 2002 16:34:21 -0000	1.28
--- cmd.py	29 May 2002 16:18:41 -0000	1.29
***************
*** 54,57 ****
--- 54,68 ----
  
  class Cmd:
+     """A simple framework for writing line-oriented command interpreters.
+ 
+     These are often useful for test harnesses, administrative tools, and
+     prototypes that will later be wrapped in a more sophisticated interface.
+ 
+     A Cmd instance or subclass instance is a line-oriented interpreter
+     framework.  There is no good reason to instantiate Cmd itself; rather,
+     it's useful as a superclass of an interpreter class you define yourself
+     in order to inherit Cmd's methods and encapsulate action methods.
+ 
+     """
      prompt = PROMPT
      identchars = IDENTCHARS
***************
*** 68,71 ****
--- 79,90 ----
  
      def __init__(self, completekey='tab'):
+         """Instantiate a line-oriented interpreter framework.
+ 
+         The optional argument is the readline name of a completion key;
+         it defaults to the Tab key. If completekey is not None and the
+         readline module is available, command completion is done
+         automatically.
+ 
+         """
          if completekey:
              try:
***************
*** 77,80 ****
--- 96,105 ----
  
      def cmdloop(self, intro=None):
+         """Repeatedly issue a prompt, accept input, parse an initial prefix
+         off the received input, and dispatch to action methods, passing them
+         the remainder of the line as argument.
+ 
+         """
+ 
          self.preloop()
          if intro is not None:
***************
*** 107,119 ****
--- 132,154 ----
  
      def precmd(self, line):
+         """Hook method executed just before the command line is
+         interpreted, but after the input prompt is generated and issued.
+ 
+         """
          return line
  
      def postcmd(self, stop, line):
+         """Hook method executed just after a command dispatch is finished."""
          return stop
  
      def preloop(self):
+         """Hook method executed once when the cmdloop() method is called."""
          pass
  
      def postloop(self):
+         """Hook method executed once when the cmdloop() method is about to
+         return.
+ 
+         """
          pass
  
***************
*** 135,138 ****
--- 170,182 ----
  
      def onecmd(self, line):
+         """Interpret the argument as though it had been typed in response
+         to the prompt.
+ 
+         This may be overridden, but should not normally need to be;
+         see the precmd() and postcmd() methods for useful execution hooks.
+         The return value is a flag indicating whether interpretation of
+         commands by the interpreter should stop.
+ 
+         """
          cmd, arg, line = self.parseline(line)
          if not line:
***************
*** 151,161 ****
--- 195,223 ----
  
      def emptyline(self):
+         """Called when an empty line is entered in response to the prompt.
+ 
+         If this method is not overridden, it repeats the last nonempty
+         command entered.
+ 
+         """
          if self.lastcmd:
              return self.onecmd(self.lastcmd)
  
      def default(self, line):
+         """Called on an input line when the command prefix is not recognized.
+ 
+         If this method is not overridden, it prints an error message and
+         returns.
+ 
+         """
          print '*** Unknown syntax:', line
  
      def completedefault(self, *ignored):
+         """Method called to complete an input line when no command-specific
+         complete_*() method is available.
+ 
+         By default, it returns an empty list.
+ 
+         """
          return []
  

Index: dumbdbm.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/dumbdbm.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** dumbdbm.py	16 Feb 2002 07:34:19 -0000	1.17
--- dumbdbm.py	29 May 2002 16:18:41 -0000	1.18
***************
*** 155,158 ****
--- 155,170 ----
  
  def open(file, flag=None, mode=0666):
+     """Open the database file, filename, and return corresponding object.
+ 
+     The flag argument, used to control how the database is opened in the
+     other DBM implementations, is ignored in the dumbdbm module; the
+     database is always opened for update, and will be created if it does
+     not exist.
+ 
+     The optional mode argument is the UNIX mode of the file, used only when
+     the database has to be created.  It defaults to octal code 0666 (and
+     will be modified by the prevailing umask).
+ 
+     """
      # flag, mode arguments are currently ignored
      return _Database(file, mode)

Index: formatter.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/formatter.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** formatter.py	13 Aug 2001 14:55:17 -0000	1.19
--- formatter.py	29 May 2002 16:18:42 -0000	1.20
***************
*** 28,31 ****
--- 28,40 ----
  
  class NullFormatter:
+     """A formatter which does nothing.
+ 
+     If the writer parameter is omitted, a NullWriter instance is created.
+     No methods of the writer are called by NullFormatter instances.
+ 
+     Implementations should inherit from this class if implementing a writer
+     interface but don't need to inherit any implementation.
+ 
+     """
  
      def __init__(self, writer=None):
***************
*** 53,56 ****
--- 62,72 ----
  
  class AbstractFormatter:
+     """The standard formatter.
+ 
+     This implementation has demonstrated wide applicability to many writers,
+     and may be used directly in most circumstances.  It has been used to
+     implement a full-featured World Wide Web browser.
+ 
+     """
  
      #  Space handling policy:  blank spaces at the boundary between elements
***************
*** 284,288 ****
  
  class NullWriter:
!     """Minimal writer interface to use in testing & inheritance."""
      def __init__(self): pass
      def flush(self): pass
--- 300,310 ----
  
  class NullWriter:
!     """Minimal writer interface to use in testing & inheritance.
! 
!     A writer which only provides the interface definition; no actions are
!     taken on any methods.  This should be the base class for all writers
!     which do not need to inherit any implementation methods.
! 
!     """
      def __init__(self): pass
      def flush(self): pass
***************
*** 301,304 ****
--- 323,332 ----
  
  class AbstractWriter(NullWriter):
+     """A writer which can be used in debugging formatters, but not much else.
+ 
+     Each method simply announces itself by printing its name and
+     arguments on standard output.
+ 
+     """
  
      def new_alignment(self, align):
***************
*** 337,340 ****
--- 365,375 ----
  
  class DumbWriter(NullWriter):
+     """Simple writer class which writes output on the file object passed in
+     as the file parameter or, if file is omitted, on standard output.  The
+     output is simply word-wrapped to the number of columns specified by
+     the maxcol parameter.  This class is suitable for reflowing a sequence
+     of paragraphs.
+ 
+     """
  
      def __init__(self, file=None, maxcol=72):

Index: gzip.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/gzip.py,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** gzip.py	23 May 2002 01:43:04 -0000	1.33
--- gzip.py	29 May 2002 16:18:42 -0000	1.34
***************
*** 28,34 ****
--- 28,44 ----
  
  def open(filename, mode="rb", compresslevel=9):
+     """Shorthand for GzipFile(filename, mode, compresslevel).
+ 
+     The filename argument is required; mode defaults to 'rb'
+     and compresslevel defaults to 9.
+ 
+     """
      return GzipFile(filename, mode, compresslevel)
  
  class GzipFile:
+     """The GzipFile class simulates most of the methods of a file object with
+     the exception of the readinto(), truncate(), and xreadlines() methods.
+ 
+     """
  
      myfileobj = None
***************
*** 36,39 ****
--- 46,77 ----
      def __init__(self, filename=None, mode=None,
                   compresslevel=9, fileobj=None):
+         """Constructor for the GzipFile class.
+ 
+         At least one of fileobj and filename must be given a
+         non-trivial value.
+ 
+         The new class instance is based on fileobj, which can be a regular
+         file, a 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.
+ 
+         When fileobj is not None, the filename argument is only used to be
+         included in the gzip file header, which may includes the original
+         filename of the uncompressed file.  It defaults to the filename of
+         fileobj, if discernible; otherwise, it defaults to the empty string,
+         and in this case the original filename is not included in the header.
+ 
+         The mode argument can be any of 'r', 'rb', 'a', 'ab', 'w', or 'wb',
+         depending on whether the file will be read or written.  The default
+         is the mode of fileobj if discernible; otherwise, the default is 'rb'.
+         Be aware that only the 'rb', 'ab', and 'wb' values should be used
+         for cross-platform portability.
+ 
+         The compresslevel argument is an integer from 1 to 9 controlling the
+         level of compression; 1 is fastest and produces the least compression,
+         and 9 is slowest and produces the most compression.  The default is 9.
+ 
+         """
+ 
          # guarantee the file is opened in binary mode on platforms
          # that care about that sort of thing

Index: htmllib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/htmllib.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** htmllib.py	11 May 2001 18:45:52 -0000	1.18
--- htmllib.py	29 May 2002 16:18:42 -0000	1.19
***************
*** 12,19 ****
--- 12,32 ----
  
  class HTMLParser(SGMLParser):
+     """This is the basic HTML parser class.
+ 
+     It supports all entity names required by the HTML 2.0 specification
+     RFC 1866.  It also defines handlers for all HTML 2.0 and many HTML 3.0
+     and 3.2 elements.
+ 
+     """
  
      from htmlentitydefs import entitydefs
  
      def __init__(self, formatter, verbose=0):
+         """Creates an instance of the HTMLParser class.
+ 
+         The formatter parameter is the formatter instance associated with
+         the parser.
+ 
+         """
          SGMLParser.__init__(self, verbose)
          self.formatter = formatter
***************
*** 44,50 ****
--- 57,78 ----
  
      def save_bgn(self):
+         """Begins saving character data in a buffer instead of sending it
+         to the formatter object.
+ 
+         Retrieve the stored data via the save_end() method.  Use of the
+         save_bgn() / save_end() pair may not be nested.
+ 
+         """
          self.savedata = ''
  
      def save_end(self):
+         """Ends buffering character data and returns all data saved since
+         the preceding call to the save_bgn() method.
+ 
+         If the nofill flag is false, whitespace is collapsed to single
+         spaces.  A call to this method without a preceding call to the
+         save_bgn() method will raise a TypeError exception.
+ 
+         """
          data = self.savedata
          self.savedata = None
***************
*** 56,59 ****
--- 84,96 ----
  
      def anchor_bgn(self, href, name, type):
+         """This method is called at the start of an anchor region.
+ 
+         The arguments correspond to the attributes of the  tag with
+         the same names.  The default implementation maintains a list of
+         hyperlinks (defined by the HREF attribute for  tags) within
+         the document.  The list of hyperlinks is available as the data
+         attribute anchorlist.
+ 
+         """
          self.anchor = href
          if self.anchor:
***************
*** 61,64 ****
--- 98,107 ----
  
      def anchor_end(self):
+         """This method is called at the end of an anchor region.
+ 
+         The default implementation adds a textual footnote marker using an
+         index into the list of hyperlinks created by the anchor_bgn()method.
+ 
+         """
          if self.anchor:
              self.handle_data("[%d]" % len(self.anchorlist))
***************
*** 68,71 ****
--- 111,120 ----
  
      def handle_image(self, src, alt, *args):
+         """This method is called to handle images.
+ 
+         The default implementation simply passes the alt value to the
+         handle_data() method.
+ 
+         """
          self.handle_data(alt)
  

Index: pickle.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v
retrieving revision 1.63
retrieving revision 1.64
diff -C2 -d -r1.63 -r1.64
*** pickle.py	23 May 2002 15:15:29 -0000	1.63
--- pickle.py	29 May 2002 16:18:42 -0000	1.64
***************
*** 42,48 ****
  mloads = marshal.loads
  
! class PickleError(Exception): pass
! class PicklingError(PickleError): pass
! class UnpicklingError(PickleError): pass
  
  class _Stop(Exception):
--- 42,70 ----
  mloads = marshal.loads
  
! class PickleError(Exception):
!     """A common base class for the other pickling exceptions.
! 
!     Inherits from \exception{Exception}.
! 
!     """
!     pass
! 
! class PicklingError(PickleError):
!     """This exception is raised when an unpicklable object is passed to the
!     dump() method.
! 
!     """
!     pass
! 
! class UnpicklingError(PickleError):
!     """This exception is raised when there is a problem unpickling an object,
!     such as a security violation.
! 
!     Note that other exceptions may also be raised during unpickling, including
!     (but not necessarily limited to) AttributeError, EOFError, ImportError,
!     and IndexError.
! 
!     """
!     pass
  
  class _Stop(Exception):
***************
*** 112,115 ****
--- 134,148 ----
  
      def __init__(self, file, bin = 0):
+         """This takes a file-like object for writing a pickle data stream.
+ 
+         The optional bin parameter if true, tells the pickler to use the more
+         efficient binary pickle format, otherwise the ASCII format is used
+         (this is the default).
+ 
+         The file parameter must have a write() method that accepts a single
+         string argument.  It can thus be an open file object, a StringIO
+         object, or any other custom object that meets this interface.
+ 
+         """
          self.write = file.write
          self.memo = {}
***************
*** 117,123 ****
--- 150,170 ----
  
      def clear_memo(self):
+         """Clears the pickler's "memo".
+ 
+         The memo is the data structure that remembers which objects the
+         pickler has already seen, so that shared or recursive objects pickled
+         by reference and not by value.  This method is useful when re-using
+         picklers.
+ 
+         """
          self.memo.clear()
  
      def dump(self, object):
+         """Write a pickled representation of object to the open file object.
+ 
+         Either the binary or ASCII format will be used, depending on the
+         value of the bin flag passed to the constructor.
+ 
+         """
          self.save(object)
          self.write(STOP)
***************
*** 595,598 ****
--- 642,658 ----
  
      def __init__(self, file):
+         """This takes a file-like object for reading a pickle data stream.
+ 
+         This class automatically determines whether the data stream was
+         written in binary mode or not, so it does not need a flag as in
+         the Pickler class factory.
+ 
+         The file-like object must have two methods, a read() method that
+         takes an integer argument, and a readline() method that requires no
+         arguments.  Both methods should return a string.  Thus file-like
+         object can be a file object opened for reading, a StringIO object,
+         or any other custom object that meets this interface.
+ 
+         """
          self.readline = file.readline
          self.read = file.read
***************
*** 600,603 ****
--- 660,669 ----
  
      def load(self):
+         """Read a pickled object representation from the open file object.
+ 
+         Return the reconstituted object hierarchy specified in the file
+         object.
+ 
+         """
          self.mark = object() # any new unique object
          self.stack = []

Index: rexec.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/rexec.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** rexec.py	13 Oct 2001 18:34:42 -0000	1.34
--- rexec.py	29 May 2002 16:18:42 -0000	1.35
***************
*** 115,120 ****
  
  class RExec(ihooks._Verbose):
  
!     """Restricted Execution environment."""
  
      ok_path = tuple(sys.path)           # That's a policy decision
--- 115,130 ----
  
  class RExec(ihooks._Verbose):
+     """Basic restricted execution framework.
  
!     Code executed in this restricted environment will only have access to
!     modules and functions that are deemed safe; you can subclass RExec to
!     add or remove capabilities as desired.
! 
!     The RExec class can prevent code from performing unsafe operations like
!     reading or writing disk files, or using TCP/IP sockets.  However, it does
!     not protect against code using extremely large amounts of memory or
!     processor time.
! 
!     """
  
      ok_path = tuple(sys.path)           # That's a policy decision
***************
*** 136,139 ****
--- 146,176 ----
  
      def __init__(self, hooks = None, verbose = 0):
+         """Returns an instance of the RExec class.
+ 
+         The hooks parameter is an instance of the RHooks class or a subclass
+         of it.  If it is omitted or None, the default RHooks class is
+         instantiated.
+ 
+         Whenever the RExec module searches for a module (even a built-in one)
+         or reads a module's code, it doesn't actually go out to the file
+         system itself.  Rather, it calls methods of an RHooks instance that
+         was passed to or created by its constructor.  (Actually, the RExec
+         object doesn't make these calls --- they are made by a module loader
+         object that's part of the RExec object.  This allows another level of
+         flexibility, which can be useful when changing the mechanics of
+         import within the restricted environment.)
+ 
+         By providing an alternate RHooks object, we can control the file
+         system accesses made to import a module, without changing the
+         actual algorithm that controls the order in which those accesses are
+         made.  For instance, we could substitute an RHooks object that
+         passes all filesystem requests to a file server elsewhere, via some
+         RPC mechanism such as ILU.  Grail's applet loader uses this to support
+         importing applets from a URL for a directory.
+ 
+         If the verbose parameter is true, additional debugging output may be
+         sent to standard output.
+ 
+         """
          ihooks._Verbose.__init__(self, verbose)
          # XXX There's a circular reference here:
***************
*** 251,272 ****
--- 288,352 ----
  
      def r_exec(self, code):
+         """Execute code within a restricted environment.
+ 
+         The code parameter must either be a string containing one or more
+         lines of Python code, or a compiled code object, which will be
+         executed in the restricted environment's __main__ module.
+ 
+         """
          m = self.add_module('__main__')
          exec code in m.__dict__
  
      def r_eval(self, code):
+         """Evaluate code within a restricted environment.
+ 
+         The code parameter must either be a string containing a Python
+         expression, or a compiled code object, which will be evaluated in
+         the restricted environment's __main__ module.  The value of the
+         expression or code object will be returned.
+ 
+         """
          m = self.add_module('__main__')
          return eval(code, m.__dict__)
  
      def r_execfile(self, file):
+         """Execute the Python code in the file in the restricted
+         environment's __main__ module.
+ 
+         """
          m = self.add_module('__main__')
          execfile(file, m.__dict__)
  
      def r_import(self, mname, globals={}, locals={}, fromlist=[]):
+         """Import a module, raising an ImportError exception if the module
+         is considered unsafe.
+ 
+         This method is implicitly called by code executing in the
+         restricted environment.  Overriding this method in a subclass is
+         used to change the policies enforced by a restricted environment.
+ 
+         """
          return self.importer.import_module(mname, globals, locals, fromlist)
  
      def r_reload(self, m):
+         """Reload the module object, re-parsing and re-initializing it.
+ 
+         This method is implicitly called by code executing in the
+         restricted environment.  Overriding this method in a subclass is
+         used to change the policies enforced by a restricted environment.
+ 
+         """
          return self.importer.reload(m)
  
      def r_unload(self, m):
+         """Unload the module.
+ 
+         Removes it from the restricted environment's sys.modules dictionary.
+ 
+         This method is implicitly called by code executing in the
+         restricted environment.  Overriding this method in a subclass is
+         used to change the policies enforced by a restricted environment.
+ 
+         """
          return self.importer.unload(m)
  
***************
*** 326,344 ****
--- 406,491 ----
  
      def s_exec(self, *args):
+         """Execute code within a restricted environment.
+ 
+         Similar to the r_exec() method, but the code will be granted access
+         to restricted versions of the standard I/O streams sys.stdin,
+         sys.stderr, and sys.stdout.
+ 
+         The code parameter must either be a string containing one or more
+         lines of Python code, or a compiled code object, which will be
+         executed in the restricted environment's __main__ module.
+ 
+         """
          return self.s_apply(self.r_exec, args)
  
      def s_eval(self, *args):
+         """Evaluate code within a restricted environment.
+ 
+         Similar to the r_eval() method, but the code will be granted access
+         to restricted versions of the standard I/O streams sys.stdin,
+         sys.stderr, and sys.stdout.
+ 
+         The code parameter must either be a string containing a Python
+         expression, or a compiled code object, which will be evaluated in
+         the restricted environment's __main__ module.  The value of the
+         expression or code object will be returned.
          return self.s_apply(self.r_eval, args)
  
+         """
+ 
      def s_execfile(self, *args):
+         """Execute the Python code in the file in the restricted
+         environment's __main__ module.
+ 
+         Similar to the r_execfile() method, but the code will be granted
+         access to restricted versions of the standard I/O streams sys.stdin,
+         sys.stderr, and sys.stdout.
+ 
+         """
          return self.s_apply(self.r_execfile, args)
  
      def s_import(self, *args):
+         """Import a module, raising an ImportError exception if the module
+         is considered unsafe.
+ 
+         This method is implicitly called by code executing in the
+         restricted environment.  Overriding this method in a subclass is
+         used to change the policies enforced by a restricted environment.
+ 
+         Similar to the r_import() method, but has access to restricted
+         versions of the standard I/O streams sys.stdin, sys.stderr, and
+         sys.stdout.
+ 
+         """
          return self.s_apply(self.r_import, args)
  
      def s_reload(self, *args):
+         """Reload the module object, re-parsing and re-initializing it.
+ 
+         This method is implicitly called by code executing in the
+         restricted environment.  Overriding this method in a subclass is
+         used to change the policies enforced by a restricted environment.
+ 
+         Similar to the r_reload() method, but has access to restricted
+         versions of the standard I/O streams sys.stdin, sys.stderr, and
+         sys.stdout.
+ 
+         """
          return self.s_apply(self.r_reload, args)
  
      def s_unload(self, *args):
+         """Unload the module.
+ 
+         Removes it from the restricted environment's sys.modules dictionary.
+ 
+         This method is implicitly called by code executing in the
+         restricted environment.  Overriding this method in a subclass is
+         used to change the policies enforced by a restricted environment.
+ 
+         Similar to the r_unload() method, but has access to restricted
+         versions of the standard I/O streams sys.stdin, sys.stderr, and
+         sys.stdout.
+ 
+         """
          return self.s_apply(self.r_unload, args)
  
***************
*** 346,349 ****
--- 493,508 ----
  
      def r_open(self, file, mode='r', buf=-1):
+         """Method called when open() is called in the restricted environment.
+ 
+         The arguments are identical to those of the open() function, and a
+         file object (or a class instance compatible with file objects)
+         should be returned.  RExec's default behaviour is allow opening
+         any file for reading, but forbidding any attempt to write a file.
+ 
+         This method is implicitly called by code executing in the
+         restricted environment.  Overriding this method in a subclass is
+         used to change the policies enforced by a restricted environment.
+ 
+         """
          if mode not in ('r', 'rb'):
              raise IOError, "can't open files for writing in restricted mode"

Index: robotparser.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/robotparser.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** robotparser.py	4 Apr 2002 22:55:58 -0000	1.14
--- robotparser.py	29 May 2002 16:18:42 -0000	1.15
***************
*** 21,24 ****
--- 21,29 ----
  
  class RobotFileParser:
+     """ This class provides a set of methods to read, parse and answer
+     questions about a single robots.txt file.
+ 
+     """
+ 
      def __init__(self, url=''):
          self.entries = []
***************
*** 30,44 ****
--- 35,61 ----
  
      def mtime(self):
+         """Returns the time the robots.txt file was last fetched.
+ 
+         This is useful for long-running web spiders that need to
+         check for new robots.txt files periodically.
+ 
+         """
          return self.last_checked
  
      def modified(self):
+         """Sets the time the robots.txt file was last fetched to the
+         current time.
+ 
+         """
          import time
          self.last_checked = time.time()
  
      def set_url(self, url):
+         """Sets the URL referring to a robots.txt file."""
          self.url = url
          self.host, self.path = urlparse.urlparse(url)[1:3]
  
      def read(self):
+         """Reads the robots.txt URL and feeds it to the parser."""
          opener = URLopener()
          f = opener.open(self.url)





From bwarsaw@users.sourceforge.net  Wed May 29 17:07:29 2002
From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net)
Date: Wed, 29 May 2002 09:07:29 -0700
Subject: [Python-checkins] python/nondist/peps pep-0008.txt,1.12,1.13
Message-ID: 

Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv23076

Modified Files:
	pep-0008.txt 
Log Message:
Slight change to the string methods recommendation; we mitigate the
recommendation if compatibility with pre-Python 2.0 is necessary.


Index: pep-0008.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0008.txt,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** pep-0008.txt	24 May 2002 19:46:20 -0000	1.12
--- pep-0008.txt	29 May 2002 16:07:27 -0000	1.13
***************
*** 519,525 ****
              """Base class for errors in the email package."""
  
!     - Avoid the use of the string module; instead use string methods.
!       These are always much faster and share the same API with unicode
!       strings.
  
      - Avoid slicing strings when checking for prefixes or suffixes.
--- 519,526 ----
              """Base class for errors in the email package."""
  
!     - Use string methods instead of the string module unless
!       backward-compatibility with versions earlier than Python 2.0 is
!       important.  String methods are always much faster and share the
!       same API with unicode strings.
  
      - Avoid slicing strings when checking for prefixes or suffixes.





From akuchling@users.sourceforge.net  Wed May 29 18:30:37 2002
From: akuchling@users.sourceforge.net (akuchling@users.sourceforge.net)
Date: Wed, 29 May 2002 10:30:37 -0700
Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.17,1.18
Message-ID: 

Update of /cvsroot/python/python/dist/src/Doc/whatsnew
In directory usw-pr-cvs1:/tmp/cvs-serv4117

Modified Files:
	whatsnew23.tex 
Log Message:
More additions

Index: whatsnew23.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** whatsnew23.tex	29 May 2002 15:54:55 -0000	1.17
--- whatsnew23.tex	29 May 2002 17:30:34 -0000	1.18
***************
*** 6,10 ****
  
  \title{What's New in Python 2.3}
! \release{0.01}
  \author{A.M. Kuchling}
  \authoraddress{\email{akuchlin@mems-exchange.org}}
--- 6,10 ----
  
  \title{What's New in Python 2.3}
! \release{0.02}
  \author{A.M. Kuchling}
  \authoraddress{\email{akuchlin@mems-exchange.org}}
***************
*** 507,510 ****
--- 507,512 ----
  \end{verbatim}
  
+ (Contributed by Raymond Hettinger.)
+ 
  \item Two new functions in the \module{math} module, 
  \function{degrees(\var{rads})} and \function{radians(\var{degs})},
***************
*** 583,603 ****
  measurement.
  
! \item XXX Introduce two new flag bits that can be set in a PyMethodDef method
! descriptor, as used for the tp_methods slot of a type.  These new flag
! bits are both optional, and mutually exclusive.  Most methods will not
! use either.  These flags are used to create special method types which
! exist in the same namespace as normal methods without having to use
! tedious construction code to insert the new special method objects in
! the type's tp_dict after PyType_Ready() has been called.
! 
! If METH_CLASS is specified, the method will represent a class method
! like that returned by the classmethod() built-in.
! 
! If METH_STATIC is specified, the method will represent a static method
! like that returned by the staticmethod() built-in.
! 
! These flags may not be used in the PyMethodDef table for modules since
! these special method types are not meaningful in that case; a
! ValueError will be raised if these flags are found in that context.
  
  \end{itemize}
--- 585,592 ----
  measurement.
  
! \item It's now possible to define class and static methods for a C
! extension type by setting either the \constant{METH_CLASS} or
! \constant{METH_STATIC} flags in a method's \ctype{PyMethodDef}
! structure.
  
  \end{itemize}
***************
*** 605,620 ****
  \subsection{Port-Specific Changes}
  
  XXX write this
  
  XXX OS/2 EMX port
  
! XXX MacOS: Weaklink most toolbox modules, improving backward
! compatibility. Modules will no longer fail to load if a single routine
! is missing on the curent OS version, in stead calling the missing
! routine will raise an exception.  Should finally fix 531398. 2.2.1
! candidate.  Also blacklisted some constants with definitions that
! were not Python-compatible.
  
! XXX Checked in Sean Reifschneider's RPM spec file and patches.
  
  
--- 594,610 ----
  \subsection{Port-Specific Changes}
  
+ 
  XXX write this
  
  XXX OS/2 EMX port
  
! On MacOS, most toolbox modules have been weaklinked to improve
! backward compatibility.  This means that modules will no longer fail
! to load if a single routine is missing on the curent OS version.
! Instead calling the missing routine will raise an exception.  
  
! Sean Reifschneider contributed an updated RPM spec file that can be
! found in the \file{Misc/RPM/} directory in the Python source
! distribution.
  
  





From akuchling@users.sourceforge.net  Wed May 29 18:33:50 2002
From: akuchling@users.sourceforge.net (akuchling@users.sourceforge.net)
Date: Wed, 29 May 2002 10:33:50 -0700
Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex,1.41,1.42
Message-ID: 

Update of /cvsroot/python/python/dist/src/Doc/dist
In directory usw-pr-cvs1:/tmp/cvs-serv5768

Modified Files:
	dist.tex 
Log Message:
Various minor rewrites

Index: dist.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -d -r1.41 -r1.42
*** dist.tex	10 May 2002 14:45:59 -0000	1.41
--- dist.tex	29 May 2002 17:33:48 -0000	1.42
***************
*** 22,26 ****
    \noindent
    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
--- 22,26 ----
    \noindent
    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
***************
*** 72,90 ****
  
  
! \subsection{A simple example}
  \label{simple-example}
  
! The setup script is usually quite simple, although since it's written in
! Python, there are no arbitrary limits to what you can do with
! it, though you should be careful about putting arbitrarily expensive
!   operations in your setup script. Unlike, say, Autoconf-style configure
!   scripts, the setup script may be run multiple times in the course of
!   building and installing your module distribution.  If you need to
!   insert potentially expensive processing steps into the Distutils
!   chain, see section~\ref{extending} on extending the Distutils.
  
  If all you want to do is distribute a module called \module{foo},
  contained in a file \file{foo.py}, then your setup script can be as
! little as this:
  
  \begin{verbatim}
--- 72,90 ----
  
  
! \subsection{A Simple Example}
  \label{simple-example}
  
! The setup script is usually quite simple, although since it's written
! in Python, there are no arbitrary limits to what you can do with it,
! though you should be careful about putting arbitrarily expensive
! operations in your setup script. Unlike, say, Autoconf-style configure
! scripts, the setup script may be run multiple times in the course of
! building and installing your module distribution.  If you need to
! insert potentially expensive processing steps into the Distutils
! chain, see section~\ref{extending} on extending the Distutils.
  
  If all you want to do is distribute a module called \module{foo},
  contained in a file \file{foo.py}, then your setup script can be as
! simple as this:
  
  \begin{verbatim}
***************
*** 100,108 ****
    keyword arguments to the \function{setup()} function
  \item those keyword arguments fall into two categories: package
!   meta-data (name, version number) and information about what's in the
    package (a list of pure Python modules, in this case)
  \item modules are specified by module name, not filename (the same will
    hold true for packages and extensions)
! \item it's recommended that you supply a little more meta-data, in
    particular your name, email address and a URL for the project
    (see section~\ref{setup-script} for an example)
--- 100,108 ----
    keyword arguments to the \function{setup()} function
  \item those keyword arguments fall into two categories: package
!   metadata (name, version number) and information about what's in the
    package (a list of pure Python modules, in this case)
  \item modules are specified by module name, not filename (the same will
    hold true for packages and extensions)
! \item it's recommended that you supply a little more metadata, in
    particular your name, email address and a URL for the project
    (see section~\ref{setup-script} for an example)
***************
*** 117,121 ****
  
  which will create an archive file (e.g., tarball on \UNIX, ZIP file on
! Windows) containing your setup script, \file{setup.py}, and your module,
  \file{foo.py}.  The archive file will be named \file{foo-1.0.tar.gz} (or
  \file{.zip}), and will unpack into a directory \file{foo-1.0}.
--- 117,121 ----
  
  which will create an archive file (e.g., tarball on \UNIX, ZIP file on
! Windows) containing your setup script \file{setup.py}, and your module
  \file{foo.py}.  The archive file will be named \file{foo-1.0.tar.gz} (or
  \file{.zip}), and will unpack into a directory \file{foo-1.0}.
***************
*** 133,137 ****
  
  This simple example demonstrates some fundamental concepts of the
! Distutils: first, both developers and installers have the same basic
  user interface, i.e. the setup script.  The difference is which
  Distutils \emph{commands} they use: the \command{sdist} command is
--- 133,137 ----
  
  This simple example demonstrates some fundamental concepts of the
! Distutils. First, both developers and installers have the same basic
  user interface, i.e. the setup script.  The difference is which
  Distutils \emph{commands} they use: the \command{sdist} command is
***************
*** 156,162 ****
  Other useful built distribution formats are RPM, implemented by the
  \command{bdist\_rpm} command, Solaris \program{pkgtool}
! (\command{bdist\_pkgtool}, and HP-UX \program{swinstall} (\command{bdist_sdux}).
! For example, the following command will create an RPM file called
! \file{foo-1.0.noarch.rpm}:
  
  \begin{verbatim}
--- 156,162 ----
  Other useful built distribution formats are RPM, implemented by the
  \command{bdist\_rpm} command, Solaris \program{pkgtool}
! (\command{bdist\_pkgtool}), and HP-UX \program{swinstall}
! (\command{bdist_sdux}).  For example, the following command will
! create an RPM file called \file{foo-1.0.noarch.rpm}:
  
  \begin{verbatim}
***************
*** 164,169 ****
  \end{verbatim}
  
! (This uses the \command{rpm} command, so has to be run on an RPM-based
! system such as Red Hat Linux, SuSE Linux, or Mandrake Linux.)
  
  You can find out what distribution formats are available at any time by
--- 164,170 ----
  \end{verbatim}
  
! (The \command{bdist\_rpm} command uses the \command{rpm} executable,
! therefore this has to be run on an RPM-based system such as Red Hat
! Linux, SuSE Linux, or Mandrake Linux.)
  
  You can find out what distribution formats are available at any time by
***************
*** 210,214 ****
    Unlike regular packages, modules in the root package can be found in
    many directories: in fact, every directory listed in \code{sys.path}
!   can contribute modules to the root package.
  \end{description}
  
--- 211,215 ----
    Unlike regular packages, modules in the root package can be found in
    many directories: in fact, every directory listed in \code{sys.path}
!   contributes modules to the root package.
  \end{description}
  
***************
*** 278,282 ****
  There are only two differences between this and the trivial one-file
  distribution presented in section~\ref{simple-example}: more
! meta-data, and the specification of pure Python modules by package,
  rather than by module.  This is important since the Distutils consist of
  a couple of dozen modules split into (so far) two packages; an explicit
--- 279,283 ----
  There are only two differences between this and the trivial one-file
  distribution presented in section~\ref{simple-example}: more
! metadata, and the specification of pure Python modules by package,
  rather than by module.  This is important since the Distutils consist of
  a couple of dozen modules split into (so far) two packages; an explicit
***************
*** 295,302 ****
  path, the opposite of the MacOS convention with colons.)
  
! This, of course, only applies to pathnames given to Distutils functions.
! If you, for example, use standard python functions such as \function{glob.glob}
! or \function{os.listdir} to specify files, you should be careful to write portable
! code instead of hardcoding path separators:
  
  \begin{verbatim}
--- 296,304 ----
  path, the opposite of the MacOS convention with colons.)
  
! This, of course, only applies to pathnames given to Distutils
! functions.  If you, for example, use standard python functions such as
! \function{glob.glob} or \function{os.listdir} to specify files, you
! should be careful to write portable code instead of hardcoding path
! separators:
  
  \begin{verbatim}
***************
*** 305,308 ****
--- 307,311 ----
  \end{verbatim}
  
+ 
  \subsection{Listing whole packages}
  \label{listing-packages}
***************
*** 318,324 ****
  the Distutils will find a file \file{foo/\_\_init\_\_.py} (which might
  be spelled differently on your system, but you get the idea) relative to
! the directory where your setup script lives.  (If you break this
! promise, the Distutils will issue a warning but process the broken
! package anyways.)
  
  If you use a different convention to lay out your source directory,
--- 321,327 ----
  the Distutils will find a file \file{foo/\_\_init\_\_.py} (which might
  be spelled differently on your system, but you get the idea) relative to
! the directory where your setup script lives.  If you break this
! promise, the Distutils will issue a warning but still process the broken
! package anyways.
  
  If you use a different convention to lay out your source directory,
***************
*** 326,330 ****
  option to tell the Distutils about your convention.  For example, say
  you keep all Python source under \file{lib}, so that modules in the
! ``root package'' (i.e., not in any package at all) are right in
  \file{lib}, modules in the \module{foo} package are in \file{lib/foo},
  and so forth.  Then you would put
--- 329,333 ----
  option to tell the Distutils about your convention.  For example, say
  you keep all Python source under \file{lib}, so that modules in the
! ``root package'' (i.e., not in any package at all) are in
  \file{lib}, modules in the \module{foo} package are in \file{lib/foo},
  and so forth.  Then you would put
***************
*** 384,387 ****
--- 387,391 ----
  \label{describing-extensions}
  
+ % XXX read over this section
  Just as writing Python extension modules is a bit more complicated than
  writing pure Python modules, describing them to the Distutils is a bit
***************
*** 618,626 ****
  to the list of exported symbols.
  
! \subsection{Listing scripts}
  So far we have been dealing with pure and non-pure Python modules,
  which are usually not run by themselves but imported by scripts.
  
! Scripts are files containing Python source code, indended to be
  started from the command line.  Scripts don't require Distutils to do
  anything very complicated.  The only clever feature is that if the
--- 622,630 ----
  to the list of exported symbols.
  
! \subsection{Installing Scripts}
  So far we have been dealing with pure and non-pure Python modules,
  which are usually not run by themselves but imported by scripts.
  
! Scripts are files containing Python source code, intended to be
  started from the command line.  Scripts don't require Distutils to do
  anything very complicated.  The only clever feature is that if the
***************
*** 630,641 ****
  
  The \option{scripts} option simply is a list of files to be handled
! in this way.
  
  
! \subsection{Listing additional files}
  
  The \option{data\_files} option can be used to specify additional
! files needed by the module distribution: configuration files,
! data files, anything which does not fit in the previous categories.
  
  \option{data\_files} specifies a sequence of (\var{directory},
--- 634,652 ----
  
  The \option{scripts} option simply is a list of files to be handled
! in this way.  From the PyXML setup script:
  
+ \begin{verbatim}
+ setup (... 
+        scripts = ['scripts/xmlproc_parse', 'scripts/xmlproc_val']
+       )
+ \end{verbatim}
  
! 
! \subsection{Installing Additional Files}
  
  The \option{data\_files} option can be used to specify additional
! files needed by the module distribution: configuration files, message
! catalogs, data files, anything which doesn't fit in the previous
! categories.
  
  \option{data\_files} specifies a sequence of (\var{directory},
***************
*** 645,649 ****
  setup(...
        data_files=[('bitmaps', ['bm/b1.gif', 'bm/b2.gif']),
!                   ('config', ['cfg/data.cfg'])])
  \end{verbatim}
  
--- 656,662 ----
  setup(...
        data_files=[('bitmaps', ['bm/b1.gif', 'bm/b2.gif']),
!                   ('config', ['cfg/data.cfg']),
!                   ('/etc/init.d', ['init-script'])]
!      )
  \end{verbatim}
  
***************
*** 740,746 ****
  \end{verbatim}
  
- Or consult section \ref{reference} of this document (the command
- reference).
- 
  Note that an option spelled \longprogramopt{foo-bar} on the command-line 
  is spelled \option{foo\_bar} in configuration files.
--- 753,756 ----
***************
*** 1259,1266 ****
  distributions on Windows.  They display a nice graphical user interface,
  display some information about the module distribution to be installed taken
! from the meta-data in the setup script, let the user select a few
  (currently maybe too few) options, and start or cancel the installation.
  
! Since the meta-data is taken from the setup script, creating
  Windows installers is usually as easy as running:
  
--- 1269,1276 ----
  distributions on Windows.  They display a nice graphical user interface,
  display some information about the module distribution to be installed taken
! from the metadata in the setup script, let the user select a few
  (currently maybe too few) options, and start or cancel the installation.
  
! Since the metadata is taken from the setup script, creating
  Windows installers is usually as easy as running:
  





From nascheme@users.sourceforge.net  Wed May 29 19:19:21 2002
From: nascheme@users.sourceforge.net (nascheme@users.sourceforge.net)
Date: Wed, 29 May 2002 11:19:21 -0700
Subject: [Python-checkins] python/dist/src/Modules _hotshot.c,1.16,1.17
Message-ID: 

Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv28796/Modules

Modified Files:
	_hotshot.c 
Log Message:
The logreader object did not always refill the input buffer correctly
and got confused by certain log files.  Remove logreader_refill and the
associated logic and replace with fgetc.


Index: _hotshot.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_hotshot.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** _hotshot.c	20 Mar 2002 21:32:07 -0000	1.16
--- _hotshot.c	29 May 2002 18:19:14 -0000	1.17
***************
*** 84,92 ****
      PyObject *info;
      FILE *logfp;
-     int filled;
-     int index;
      int linetimings;
      int frametimings;
-     unsigned char buffer[BUFFERSIZE];
  } LogReaderObject;
  
--- 84,89 ----
***************
*** 273,295 ****
  unpack_packed_int(LogReaderObject *self, int *pvalue, int discard)
  {
      int accum = 0;
      int bits = 0;
-     int index = self->index;
      int cont;
  
      do {
-         if (index >= self->filled)
-             return ERR_EOF;
          /* read byte */
!         accum |= ((self->buffer[index] & 0x7F) >> discard) << bits;
          bits += (7 - discard);
!         cont = self->buffer[index] & 0x80;
!         /* move to next */
          discard = 0;
-         index++;
      } while (cont);
  
-     /* save state */
-     self->index = index;
      *pvalue = accum;
  
--- 270,288 ----
  unpack_packed_int(LogReaderObject *self, int *pvalue, int discard)
  {
+     int c;
      int accum = 0;
      int bits = 0;
      int cont;
  
      do {
          /* read byte */
! 	if ((c = fgetc(self->logfp)) == EOF)
!             return ERR_EOF;
!         accum |= ((c & 0x7F) >> discard) << bits;
          bits += (7 - discard);
!         cont = c & 0x80;
          discard = 0;
      } while (cont);
  
      *pvalue = accum;
  
***************
*** 303,333 ****
  unpack_string(LogReaderObject *self, PyObject **pvalue)
  {
      int len;
!     int oldindex = self->index;
!     int err = unpack_packed_int(self, &len, 0);
  
!     if (!err) {
!         /* need at least len bytes in buffer */
!         if (len > (self->filled - self->index)) {
!             self->index = oldindex;
!             err = ERR_EOF;
!         }
!         else {
!             *pvalue = PyString_FromStringAndSize((char *)self->buffer + self->index,
!                                                  len);
!             if (*pvalue == NULL) {
!                 self->index = oldindex;
!                 err = ERR_EXCEPTION;
!             }
!             else
!                 self->index += len;
          }
      }
!     return err;
  }
  
  
  static int
! unpack_add_info(LogReaderObject *self, int skip_opcode)
  {
      PyObject *key;
--- 296,325 ----
  unpack_string(LogReaderObject *self, PyObject **pvalue)
  {
+     int i;
      int len;
!     int err;
!     char *buf;
!     
!     if ((err = unpack_packed_int(self, &len, 0)))
!         return err;
  
!     buf = malloc(len);
!     for (i=0; i < len; i++) {
!         if ((buf[i] = fgetc(self->logfp)) == EOF) {
!             free(buf);
!             return ERR_EOF;
          }
      }
!     *pvalue = PyString_FromStringAndSize(buf, len);
!     free(buf);
!     if (*pvalue == NULL) {
!         return ERR_EXCEPTION;
!     }
!     return 0;
  }
  
  
  static int
! unpack_add_info(LogReaderObject *self)
  {
      PyObject *key;
***************
*** 335,343 ****
      int err;
  
-     if (skip_opcode) {
-         if (self->buffer[self->index] != WHAT_ADD_INFO)
-             return ERR_BAD_RECTYPE;
-         self->index++;
-     }
      err = unpack_string(self, &key);
      if (!err) {
--- 327,330 ----
***************
*** 370,392 ****
  
  static void
- logreader_refill(LogReaderObject *self)
- {
-     int needed;
-     size_t res;
- 
-     if (self->index) {
-         memmove(self->buffer, &self->buffer[self->index],
-                 self->filled - self->index);
-         self->filled = self->filled - self->index;
-         self->index = 0;
-     }
-     needed = BUFFERSIZE - self->filled;
-     if (needed > 0) {
-         res = fread(&self->buffer[self->filled], 1, needed, self->logfp);
-         self->filled += res;
-     }
- }
- 
- static void
  eof_error(void)
  {
--- 357,360 ----
***************
*** 398,402 ****
  logreader_tp_iternext(LogReaderObject *self)
  {
!     int what, oldindex;
      int err = ERR_NONE;
      int lineno = -1;
--- 366,371 ----
  logreader_tp_iternext(LogReaderObject *self)
  {
!     int c;
!     int what;
      int err = ERR_NONE;
      int lineno = -1;
***************
*** 414,433 ****
          return NULL;
      }
-  restart:
-     if ((self->filled - self->index) < MAXEVENTSIZE)
-         logreader_refill(self);
  
!     /* end of input */
!     if (self->filled == 0)
          return NULL;
  
!     oldindex = self->index;
  
-     /* decode the record type */
-     what = self->buffer[self->index] & WHAT_OTHER;
-     if (what == WHAT_OTHER) {
-         what = self->buffer[self->index];
-         self->index++;
-     }
      switch (what) {
      case WHAT_ENTER:
--- 383,398 ----
          return NULL;
      }
  
! restart:
!     /* decode the record type */
!     if ((c = fgetc(self->logfp)) == EOF)
          return NULL;
  
!     what = c & WHAT_OTHER;
!     if (what == WHAT_OTHER)
!         what = c; /* need all the bits for type */
!     else
!         ungetc(c, self->logfp); /* type byte includes packed int */
  
      switch (what) {
      case WHAT_ENTER:
***************
*** 448,452 ****
          break;
      case WHAT_ADD_INFO:
!         err = unpack_add_info(self, 0);
          break;
      case WHAT_DEFINE_FILE:
--- 413,417 ----
          break;
      case WHAT_ADD_INFO:
!         err = unpack_add_info(self);
          break;
      case WHAT_DEFINE_FILE:
***************
*** 469,500 ****
          break;
      case WHAT_LINE_TIMES:
!         if (self->index >= self->filled)
              err = ERR_EOF;
          else {
!             self->linetimings = self->buffer[self->index] ? 1 : 0;
!             self->index++;
!             goto restart;
!         }
          break;
      case WHAT_FRAME_TIMES:
!         if (self->index >= self->filled)
              err = ERR_EOF;
          else {
!             self->frametimings = self->buffer[self->index] ? 1 : 0;
!             self->index++;
!             goto restart;
!         }
          break;
      default:
          err = ERR_BAD_RECTYPE;
      }
-     if (err == ERR_EOF && oldindex != 0) {
-         /* It looks like we ran out of data before we had it all; this
-          * could easily happen with large packed integers or string
-          * data.  Try forcing the buffer to be re-filled before failing.
-          */
-         err = ERR_NONE;
-         logreader_refill(self);
-     }
      if (err == ERR_BAD_RECTYPE) {
          PyErr_SetString(PyExc_ValueError,
--- 434,455 ----
          break;
      case WHAT_LINE_TIMES:
!         if ((c = fgetc(self->logfp)) == EOF)
              err = ERR_EOF;
          else {
!             self->linetimings = c ? 1 : 0;
! 	    goto restart;
! 	}
          break;
      case WHAT_FRAME_TIMES:
!         if ((c = fgetc(self->logfp)) == EOF)
              err = ERR_EOF;
          else {
!             self->frametimings = c ? 1 : 0;
! 	    goto restart;
! 	}
          break;
      default:
          err = ERR_BAD_RECTYPE;
      }
      if (err == ERR_BAD_RECTYPE) {
          PyErr_SetString(PyExc_ValueError,
***************
*** 502,506 ****
      }
      else if (err == ERR_EOF) {
-         /* Could not avoid end-of-buffer error. */
          eof_error();
      }
--- 457,460 ----
***************
*** 1390,1399 ****
      LogReaderObject *self = NULL;
      char *filename;
  
      if (PyArg_ParseTuple(args, "s:logreader", &filename)) {
          self = PyObject_New(LogReaderObject, &LogReaderType);
          if (self != NULL) {
-             self->filled = 0;
-             self->index = 0;
              self->frametimings = 1;
              self->linetimings = 0;
--- 1344,1353 ----
      LogReaderObject *self = NULL;
      char *filename;
+     int c;
+     int err = 0;
  
      if (PyArg_ParseTuple(args, "s:logreader", &filename)) {
          self = PyObject_New(LogReaderObject, &LogReaderType);
          if (self != NULL) {
              self->frametimings = 1;
              self->linetimings = 0;
***************
*** 1411,1422 ****
                  goto finally;
              }
!             /* Aggressively attempt to load all preliminary ADD_INFO
!              * records from the log so the info records are available
!              * from a fresh logreader object.
!              */
!             logreader_refill(self);
!             while (self->filled > self->index
!                    && self->buffer[self->index] == WHAT_ADD_INFO) {
!                 int err = unpack_add_info(self, 1);
                  if (err) {
                      if (err == ERR_EOF)
--- 1365,1379 ----
                  goto finally;
              }
!             /* read initial info */
!             for (;;) {
!                 if ((c = fgetc(self->logfp)) == EOF) {
!                     eof_error();
!                     break;
!                 }
!                 if (c != WHAT_ADD_INFO) {
!                     ungetc(c, self->logfp);
!                     break;
!                 }
!                 err = unpack_add_info(self);
                  if (err) {
                      if (err == ERR_EOF)
***************
*** 1427,1436 ****
                      break;
                  }
-                 /* Refill agressively so we can avoid EOF during
-                  * initialization unless there's a real EOF condition
-                  * (the tp_iternext handler loops attempts to refill
-                  * and try again).
-                  */
-                 logreader_refill(self);
              }
          }
--- 1384,1387 ----





From nascheme@users.sourceforge.net  Wed May 29 19:44:33 2002
From: nascheme@users.sourceforge.net (nascheme@users.sourceforge.net)
Date: Wed, 29 May 2002 11:44:33 -0700
Subject: [Python-checkins] python/dist/src/Modules _hotshot.c,1.11.6.2,1.11.6.3
Message-ID: 

Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv6222a/Modules

Modified Files:
      Tag: release22-maint
	_hotshot.c 
Log Message:
The logreader object did not always refill the input buffer correctly
and got confused by certain log files.  Remove logreader_refill and the
associated logic and replace with fgetc.


Index: _hotshot.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_hotshot.c,v
retrieving revision 1.11.6.2
retrieving revision 1.11.6.3
diff -C2 -d -r1.11.6.2 -r1.11.6.3
*** _hotshot.c	8 Feb 2002 21:31:23 -0000	1.11.6.2
--- _hotshot.c	29 May 2002 18:44:30 -0000	1.11.6.3
***************
*** 81,89 ****
      PyObject *info;
      FILE *logfp;
-     int filled;
-     int index;
      int linetimings;
      int frametimings;
-     unsigned char buffer[BUFFERSIZE];
  } LogReaderObject;
  
--- 81,86 ----
***************
*** 270,292 ****
  unpack_packed_int(LogReaderObject *self, int *pvalue, int discard)
  {
      int accum = 0;
      int bits = 0;
-     int index = self->index;
      int cont;
  
      do {
-         if (index >= self->filled)
-             return ERR_EOF;
          /* read byte */
!         accum |= ((self->buffer[index] & 0x7F) >> discard) << bits;
          bits += (7 - discard);
!         cont = self->buffer[index] & 0x80;
!         /* move to next */
          discard = 0;
-         index++;
      } while (cont);
  
-     /* save state */
-     self->index = index;
      *pvalue = accum;
  
--- 267,285 ----
  unpack_packed_int(LogReaderObject *self, int *pvalue, int discard)
  {
+     int c;
      int accum = 0;
      int bits = 0;
      int cont;
  
      do {
          /* read byte */
! 	if ((c = fgetc(self->logfp)) == EOF)
!             return ERR_EOF;
!         accum |= ((c & 0x7F) >> discard) << bits;
          bits += (7 - discard);
!         cont = c & 0x80;
          discard = 0;
      } while (cont);
  
      *pvalue = accum;
  
***************
*** 300,330 ****
  unpack_string(LogReaderObject *self, PyObject **pvalue)
  {
      int len;
!     int oldindex = self->index;
!     int err = unpack_packed_int(self, &len, 0);
  
!     if (!err) {
!         /* need at least len bytes in buffer */
!         if (len > (self->filled - self->index)) {
!             self->index = oldindex;
!             err = ERR_EOF;
!         }
!         else {
!             *pvalue = PyString_FromStringAndSize((char *)self->buffer + self->index,
!                                                  len);
!             if (*pvalue == NULL) {
!                 self->index = oldindex;
!                 err = ERR_EXCEPTION;
!             }
!             else
!                 self->index += len;
          }
      }
!     return err;
  }
  
  
  static int
! unpack_add_info(LogReaderObject *self, int skip_opcode)
  {
      PyObject *key;
--- 293,322 ----
  unpack_string(LogReaderObject *self, PyObject **pvalue)
  {
+     int i;
      int len;
!     int err;
!     char *buf;
!     
!     if ((err = unpack_packed_int(self, &len, 0)))
!         return err;
  
!     buf = malloc(len);
!     for (i=0; i < len; i++) {
!         if ((buf[i] = fgetc(self->logfp)) == EOF) {
!             free(buf);
!             return ERR_EOF;
          }
      }
!     *pvalue = PyString_FromStringAndSize(buf, len);
!     free(buf);
!     if (*pvalue == NULL) {
!         return ERR_EXCEPTION;
!     }
!     return 0;
  }
  
  
  static int
! unpack_add_info(LogReaderObject *self)
  {
      PyObject *key;
***************
*** 332,340 ****
      int err;
  
-     if (skip_opcode) {
-         if (self->buffer[self->index] != WHAT_ADD_INFO)
-             return ERR_BAD_RECTYPE;
-         self->index++;
-     }
      err = unpack_string(self, &key);
      if (!err) {
--- 324,327 ----
***************
*** 367,389 ****
  
  static void
- logreader_refill(LogReaderObject *self)
- {
-     int needed;
-     size_t res;
- 
-     if (self->index) {
-         memmove(self->buffer, &self->buffer[self->index],
-                 self->filled - self->index);
-         self->filled = self->filled - self->index;
-         self->index = 0;
-     }
-     needed = BUFFERSIZE - self->filled;
-     if (needed > 0) {
-         res = fread(&self->buffer[self->filled], 1, needed, self->logfp);
-         self->filled += res;
-     }
- }
- 
- static void
  eof_error(void)
  {
--- 354,357 ----
***************
*** 395,399 ****
  logreader_tp_iternext(LogReaderObject *self)
  {
!     int what, oldindex;
      int err = ERR_NONE;
      int lineno = -1;
--- 363,368 ----
  logreader_tp_iternext(LogReaderObject *self)
  {
!     int c;
!     int what;
      int err = ERR_NONE;
      int lineno = -1;
***************
*** 411,430 ****
          return NULL;
      }
-  restart:
-     if ((self->filled - self->index) < MAXEVENTSIZE)
-         logreader_refill(self);
  
!     /* end of input */
!     if (self->filled == 0)
          return NULL;
  
!     oldindex = self->index;
  
-     /* decode the record type */
-     what = self->buffer[self->index] & WHAT_OTHER;
-     if (what == WHAT_OTHER) {
-         what = self->buffer[self->index];
-         self->index++;
-     }
      switch (what) {
      case WHAT_ENTER:
--- 380,395 ----
          return NULL;
      }
  
! restart:
!     /* decode the record type */
!     if ((c = fgetc(self->logfp)) == EOF)
          return NULL;
  
!     what = c & WHAT_OTHER;
!     if (what == WHAT_OTHER)
!         what = c; /* need all the bits for type */
!     else
!         ungetc(c, self->logfp); /* type byte includes packed int */
  
      switch (what) {
      case WHAT_ENTER:
***************
*** 445,449 ****
          break;
      case WHAT_ADD_INFO:
!         err = unpack_add_info(self, 0);
          break;
      case WHAT_DEFINE_FILE:
--- 410,414 ----
          break;
      case WHAT_ADD_INFO:
!         err = unpack_add_info(self);
          break;
      case WHAT_DEFINE_FILE:
***************
*** 466,497 ****
          break;
      case WHAT_LINE_TIMES:
!         if (self->index >= self->filled)
              err = ERR_EOF;
          else {
!             self->linetimings = self->buffer[self->index] ? 1 : 0;
!             self->index++;
!             goto restart;
!         }
          break;
      case WHAT_FRAME_TIMES:
!         if (self->index >= self->filled)
              err = ERR_EOF;
          else {
!             self->frametimings = self->buffer[self->index] ? 1 : 0;
!             self->index++;
!             goto restart;
!         }
          break;
      default:
          err = ERR_BAD_RECTYPE;
      }
-     if (err == ERR_EOF && oldindex != 0) {
-         /* It looks like we ran out of data before we had it all; this
-          * could easily happen with large packed integers or string
-          * data.  Try forcing the buffer to be re-filled before failing.
-          */
-         err = ERR_NONE;
-         logreader_refill(self);
-     }
      if (err == ERR_BAD_RECTYPE) {
          PyErr_SetString(PyExc_ValueError,
--- 431,452 ----
          break;
      case WHAT_LINE_TIMES:
!         if ((c = fgetc(self->logfp)) == EOF)
              err = ERR_EOF;
          else {
!             self->linetimings = c ? 1 : 0;
! 	    goto restart;
! 	}
          break;
      case WHAT_FRAME_TIMES:
!         if ((c = fgetc(self->logfp)) == EOF)
              err = ERR_EOF;
          else {
!             self->frametimings = c ? 1 : 0;
! 	    goto restart;
! 	}
          break;
      default:
          err = ERR_BAD_RECTYPE;
      }
      if (err == ERR_BAD_RECTYPE) {
          PyErr_SetString(PyExc_ValueError,
***************
*** 499,503 ****
      }
      else if (err == ERR_EOF) {
-         /* Could not avoid end-of-buffer error. */
          eof_error();
      }
--- 454,457 ----
***************
*** 1387,1396 ****
      LogReaderObject *self = NULL;
      char *filename;
  
      if (PyArg_ParseTuple(args, "s:logreader", &filename)) {
          self = PyObject_New(LogReaderObject, &LogReaderType);
          if (self != NULL) {
-             self->filled = 0;
-             self->index = 0;
              self->frametimings = 1;
              self->linetimings = 0;
--- 1341,1350 ----
      LogReaderObject *self = NULL;
      char *filename;
+     int c;
+     int err = 0;
  
      if (PyArg_ParseTuple(args, "s:logreader", &filename)) {
          self = PyObject_New(LogReaderObject, &LogReaderType);
          if (self != NULL) {
              self->frametimings = 1;
              self->linetimings = 0;
***************
*** 1408,1419 ****
                  goto finally;
              }
!             /* Aggressively attempt to load all preliminary ADD_INFO
!              * records from the log so the info records are available
!              * from a fresh logreader object.
!              */
!             logreader_refill(self);
!             while (self->filled > self->index
!                    && self->buffer[self->index] == WHAT_ADD_INFO) {
!                 int err = unpack_add_info(self, 1);
                  if (err) {
                      if (err == ERR_EOF)
--- 1362,1376 ----
                  goto finally;
              }
!             /* read initial info */
!             for (;;) {
!                 if ((c = fgetc(self->logfp)) == EOF) {
!                     eof_error();
!                     break;
!                 }
!                 if (c != WHAT_ADD_INFO) {
!                     ungetc(c, self->logfp);
!                     break;
!                 }
!                 err = unpack_add_info(self);
                  if (err) {
                      if (err == ERR_EOF)
***************
*** 1424,1433 ****
                      break;
                  }
-                 /* Refill agressively so we can avoid EOF during
-                  * initialization unless there's a real EOF condition
-                  * (the tp_iternext handler loops attempts to refill
-                  * and try again).
-                  */
-                 logreader_refill(self);
              }
          }
--- 1381,1384 ----





From andymac@bullseye.apana.org.au  Wed May 29 12:10:27 2002
From: andymac@bullseye.apana.org.au (Andrew MacIntyre)
Date: Wed, 29 May 2002 22:10:27 +1100 (edt)
Subject: [Python-checkins] python/dist/src/Lib/test test_signal.py,1.9,1.10
In-Reply-To: 
Message-ID: 

On Mon, 27 May 2002 mwh@users.sourceforge.net wrote:

> Update of /cvsroot/python/python/dist/src/Lib/test
> In directory usw-pr-cvs1:/tmp/cvs-serv24806/Lib/test
>
> Modified Files:
> 	test_signal.py
> Log Message:
> This is patch
>
> [ 559250 ] more POSIX signal stuff
>
> Adds support (and docs and tests and autoconfery) for posix signal
> mask handling -- sigpending, sigprocmask and sigsuspend.

Since this batch of checkins, my FreeBSD autobuilder is failing
test_socket:
  test test_signal failed -- HUP not pending

Running the test with -v yields:
test_signal
+ sleep 2
starting pause() loop...
call pause()...
+ kill -5 33123
+ sleep 2
handlerA (5, )
pause() returned
call pause()...
+ kill -2 33123
+ sleep 2
handlerB (2, )
HandlerBCalled exception caught
call pause()...
+ kill -3 33123
KeyboardInterrupt (assume the alarm() went off)
blocking SIGHUP
sending SIGHUP
test test_signal failed -- HUP not pending
1 test failed:
    test_signal


I found the following (apparently) signal related items in the autoconf
generated pyconfig.h:
/* Define to 1 if you have the  header file. */
#define HAVE_SIGNAL_H 1

/* Define to 1 if you have the `sigprocmask' function. */
#define HAVE_SIGPROCMASK 1

/* Define to 1 if you have the `sigrelse' function. */
/* #undef HAVE_SIGRELSE */

{...}

/* Define as the return type of signal handlers (`int' or `void'). */
#define RETSIGTYPE void


Any hints about where to start looking?
(I'm not au fait with signal() magic :-()

--
Andrew I MacIntyre                     "These thoughts are mine alone..."
E-mail: andymac@bullseye.apana.org.au  | Snail: PO Box 370
        andymac@pcug.org.au            |        Belconnen  ACT  2616
Web:    http://www.andymac.org/        |        Australia




From akuchling@users.sourceforge.net  Wed May 29 20:21:00 2002
From: akuchling@users.sourceforge.net (akuchling@users.sourceforge.net)
Date: Wed, 29 May 2002 12:21:00 -0700
Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.18,1.19
Message-ID: 

Update of /cvsroot/python/python/dist/src/Doc/whatsnew
In directory usw-pr-cvs1:/tmp/cvs-serv18262

Modified Files:
	whatsnew23.tex 
Log Message:
Add OS/2 text

Index: whatsnew23.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** whatsnew23.tex	29 May 2002 17:30:34 -0000	1.18
--- whatsnew23.tex	29 May 2002 19:20:57 -0000	1.19
***************
*** 594,610 ****
  \subsection{Port-Specific Changes}
  
! 
! XXX write this
! 
! XXX OS/2 EMX port
  
  On MacOS, most toolbox modules have been weaklinked to improve
  backward compatibility.  This means that modules will no longer fail
  to load if a single routine is missing on the curent OS version.
! Instead calling the missing routine will raise an exception.  
  
! Sean Reifschneider contributed an updated RPM spec file that can be
! found in the \file{Misc/RPM/} directory in the Python source
! distribution.
  
  
--- 594,616 ----
  \subsection{Port-Specific Changes}
  
! Support for a port to IBM's OS/2 using the EMX runtime environment was
! merged into the main Python source tree.  EMX is a POSIX emulation
! layer over the OS/2 system APIs.  The Python port for EMX tries to
! support all the POSIX-like capability exposed by the EMX runtime, and
! mostly succeeds; \function{fork()} and \function{fcntl()} are
! restricted by the limitations of the underlying emulation layer.  The
! standard OS/2 port, which uses IBM's Visual Age compiler, also gained
! support for case-sensitive import semantics as part of the integration
! of the EMX port into CVS.  (Contributed by Andrew MacIntyre.)
  
  On MacOS, most toolbox modules have been weaklinked to improve
  backward compatibility.  This means that modules will no longer fail
  to load if a single routine is missing on the curent OS version.
! Instead calling the missing routine will raise an exception.
! (Contributed by Jack Jansen.)
  
! The RPM spec files, found in the \file{Misc/RPM/} directory in the
! Python source distribution, were updated for 2.3.  (Contributed by
! Sean Reifschneider.)
  
  
***************
*** 621,624 ****
--- 627,631 ----
  \end{itemize}
  
+ 
  %======================================================================
  \section{Acknowledgements \label{acks}}
***************
*** 626,630 ****
  The author would like to thank the following people for offering
  suggestions, corrections and assistance with various drafts of this
! article: Fred~L. Drake, Jr., Detlef Lannert.
  
  \end{document}
--- 633,637 ----
  The author would like to thank the following people for offering
  suggestions, corrections and assistance with various drafts of this
! article: Fred~L. Drake, Jr., Detlef Lannert, Andrew MacIntyre.
  
  \end{document}





From fdrake@users.sourceforge.net  Wed May 29 20:40:39 2002
From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net)
Date: Wed, 29 May 2002 12:40:39 -0700
Subject: [Python-checkins] python/dist/src/Lib/hotshot log.py,1.5,1.6
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib/hotshot
In directory usw-pr-cvs1:/tmp/cvs-serv24933/Lib/hotshot

Modified Files:
	log.py 
Log Message:
Minor cleanup:
- Add comment explaining the structure of the stack.
- Minor optimization: make stack tuple directly usable as part of return
  value for enter/exit events.


Index: log.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/hotshot/log.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** log.py	12 Mar 2002 14:26:37 -0000	1.5
--- log.py	29 May 2002 19:40:36 -0000	1.6
***************
*** 42,45 ****
--- 42,51 ----
          else:
              self.cwd = None
+ 
+         # This mirrors the call stack of the profiled code as the log
+         # is read back in.  It contains tuples of the form:
+         #
+         #   (file name, line number of function def, function name)
+         #
          self._stack = []
          self._append = self._stack.append
***************
*** 100,112 ****
              if what == WHAT_ENTER:
                  filename, funcname = self._decode_location(fileno, lineno)
!                 self._append((filename, funcname, lineno))
!                 return what, (filename, lineno, funcname), tdelta
  
              if what == WHAT_EXIT:
!                 filename, funcname, lineno = self._pop()
!                 return what, (filename, lineno, funcname), tdelta
  
              if what == WHAT_LINENO:
!                 filename, funcname, firstlineno = self._stack[-1]
                  return what, (filename, lineno, funcname), tdelta
  
--- 106,118 ----
              if what == WHAT_ENTER:
                  filename, funcname = self._decode_location(fileno, lineno)
!                 t = (filename, lineno, funcname)
!                 self._append(t)
!                 return what, t, tdelta
  
              if what == WHAT_EXIT:
!                 return what, self._pop(), tdelta
  
              if what == WHAT_LINENO:
!                 filename, firstlineno, funcname = self._stack[-1]
                  return what, (filename, lineno, funcname), tdelta
  





From gvanrossum@users.sourceforge.net  Wed May 29 21:38:23 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Wed, 29 May 2002 13:38:23 -0700
Subject: [Python-checkins] python/dist/src/Lib/email base64MIME.py,1.2,1.3
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib/email
In directory usw-pr-cvs1:/tmp/cvs-serv12311

Modified Files:
	base64MIME.py 
Log Message:
Use floor division where appropriate.


Index: base64MIME.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/base64MIME.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** base64MIME.py	23 May 2002 15:15:30 -0000	1.2
--- base64MIME.py	29 May 2002 20:38:21 -0000	1.3
***************
*** 88,92 ****
      base64ed = []
      max_encoded = maxlinelen - len(charset) - MISC_LEN
!     max_unencoded = max_encoded * 3 / 4
  
      # BAW: Ben's original code used a step of max_unencoded, but I think it
--- 88,92 ----
      base64ed = []
      max_encoded = maxlinelen - len(charset) - MISC_LEN
!     max_unencoded = max_encoded * 3 // 4
  
      # BAW: Ben's original code used a step of max_unencoded, but I think it
***************
*** 132,136 ****
  
      encvec = []
!     max_unencoded = maxlinelen * 3 / 4
      for i in range(0, len(s), max_unencoded):
          # BAW: should encode() inherit b2a_base64()'s dubious behavior in
--- 132,136 ----
  
      encvec = []
!     max_unencoded = maxlinelen * 3 // 4
      for i in range(0, len(s), max_unencoded):
          # BAW: should encode() inherit b2a_base64()'s dubious behavior in





From akuchling@users.sourceforge.net  Wed May 29 22:09:06 2002
From: akuchling@users.sourceforge.net (akuchling@users.sourceforge.net)
Date: Wed, 29 May 2002 14:09:06 -0700
Subject: [Python-checkins] python/nondist/peps pep-0272.txt,1.8,1.9 pep-0000.txt,1.182,1.183
Message-ID: 

Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv23679

Modified Files:
	pep-0272.txt pep-0000.txt 
Log Message:
Add version number to title of PEP 272, and mark it final


Index: pep-0272.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0272.txt,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** pep-0272.txt	17 Apr 2002 23:11:18 -0000	1.8
--- pep-0272.txt	29 May 2002 21:09:03 -0000	1.9
***************
*** 1,10 ****
  PEP: 272
! Title: API for Block Encryption Algorithms
  Version: $Revision$
  Author: A.M. Kuchling 
! Status: Draft
  Type: Informational
  Created: 18-Sep-2001
! Post-History: 17-Apr-2002
  
  Abstract
--- 1,10 ----
  PEP: 272
! Title: API for Block Encryption Algorithms v1.0
  Version: $Revision$
  Author: A.M. Kuchling 
! Status: Final
  Type: Informational
  Created: 18-Sep-2001
! Post-History: 17-Apr-2002, 29-May-2002
  
  Abstract

Index: pep-0000.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v
retrieving revision 1.182
retrieving revision 1.183
diff -C2 -d -r1.182 -r1.183
*** pep-0000.txt	28 May 2002 15:55:16 -0000	1.182
--- pep-0000.txt	29 May 2002 21:09:03 -0000	1.183
***************
*** 48,52 ****
   I   248  Python Database API Specification v1.0       Lemburg
   I   249  Python Database API Specification v2.0       Lemburg
!  I   272  API for Block Encryption Algorithms          Kuchling
  
   Accepted PEPs (accepted; may not be implemented yet)
--- 48,52 ----
   I   248  Python Database API Specification v1.0       Lemburg
   I   249  Python Database API Specification v2.0       Lemburg
!  IF  272  API for Block Encryption Algorithms v1.0     Kuchling
  
   Accepted PEPs (accepted; may not be implemented yet)
***************
*** 250,254 ****
   S   270  uniq method for list objects                 Petrone
   SR  271  Prefixing sys.path by command line option    Giacometti
!  I   272  API for Block Encryption Algorithms          Kuchling
   S   273  Import Modules from Zip Archives             Ahlstrom
   S   274  Dict Comprehensions                          Warsaw
--- 250,254 ----
   S   270  uniq method for list objects                 Petrone
   SR  271  Prefixing sys.path by command line option    Giacometti
!  IF  272  API for Block Encryption Algorithms v1.0     Kuchling
   S   273  Import Modules from Zip Archives             Ahlstrom
   S   274  Dict Comprehensions                          Warsaw





From akuchling@users.sourceforge.net  Wed May 29 22:17:45 2002
From: akuchling@users.sourceforge.net (akuchling@users.sourceforge.net)
Date: Wed, 29 May 2002 14:17:45 -0700
Subject: [Python-checkins] python/nondist/peps pep-0000.txt,1.183,1.184 pep-0248.txt,1.3,1.4 pep-0249.txt,1.6,1.7
Message-ID: 

Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv26461

Modified Files:
	pep-0000.txt pep-0248.txt pep-0249.txt 
Log Message:
Mark the two database API PEPs as "Status: Final", with MAL's approval.
Neither has been revised significantly since 1996 or 1999.


Index: pep-0000.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v
retrieving revision 1.183
retrieving revision 1.184
diff -C2 -d -r1.183 -r1.184
*** pep-0000.txt	29 May 2002 21:09:03 -0000	1.183
--- pep-0000.txt	29 May 2002 21:17:42 -0000	1.184
***************
*** 46,51 ****
   I   102  Doing Python Micro Releases                Baxter, Warsaw, van Rossum
   IF  247  API for Cryptographic Hash Functions         Kuchling
!  I   248  Python Database API Specification v1.0       Lemburg
!  I   249  Python Database API Specification v2.0       Lemburg
   IF  272  API for Block Encryption Algorithms v1.0     Kuchling
  
--- 46,51 ----
   I   102  Doing Python Micro Releases                Baxter, Warsaw, van Rossum
   IF  247  API for Cryptographic Hash Functions         Kuchling
!  IF  248  Python Database API Specification v1.0       Lemburg
!  IF  249  Python Database API Specification v2.0       Lemburg
   IF  272  API for Block Encryption Algorithms v1.0     Kuchling
  
***************
*** 226,231 ****
   S   246  Object Adaptation                            Evans
   IF  247  API for Cryptographic Hash Functions         Kuchling
!  I   248  Python Database API Specification v1.0       Lemburg
!  I   249  Python Database API Specification v2.0       Lemburg
   SF  250  Using site-packages on Windows               Moore
   IF  251  Python 2.2 Release Schedule                  Warsaw, van Rossum
--- 226,231 ----
   S   246  Object Adaptation                            Evans
   IF  247  API for Cryptographic Hash Functions         Kuchling
!  IF  248  Python Database API Specification v1.0       Lemburg
!  IF  249  Python Database API Specification v2.0       Lemburg
   SF  250  Using site-packages on Windows               Moore
   IF  251  Python 2.2 Release Schedule                  Warsaw, van Rossum

Index: pep-0248.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0248.txt,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** pep-0248.txt	14 Jul 2001 16:21:44 -0000	1.3
--- pep-0248.txt	29 May 2002 21:17:42 -0000	1.4
***************
*** 4,8 ****
  Author: db-sig@python.org (Python Database SIG)
  Editor: mal@lemburg.com (Marc-Andre Lemburg)
! Status: Draft
  Replaced-By: 249
  Type: Informational
--- 4,8 ----
  Author: db-sig@python.org (Python Database SIG)
  Editor: mal@lemburg.com (Marc-Andre Lemburg)
! Status: Final
  Replaced-By: 249
  Type: Informational

Index: pep-0249.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0249.txt,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** pep-0249.txt	4 Feb 2002 22:47:07 -0000	1.6
--- pep-0249.txt	29 May 2002 21:17:42 -0000	1.7
***************
*** 4,8 ****
  Author: db-sig@python.org (Python Database SIG)
  Editor: mal@lemburg.com (Marc-Andre Lemburg)
! Status: Draft
  Type: Informational
  Replaces: 248
--- 4,8 ----
  Author: db-sig@python.org (Python Database SIG)
  Editor: mal@lemburg.com (Marc-Andre Lemburg)
! Status: Final
  Type: Informational
  Replaces: 248





From akuchling@users.sourceforge.net  Wed May 29 22:24:25 2002
From: akuchling@users.sourceforge.net (akuchling@users.sourceforge.net)
Date: Wed, 29 May 2002 14:24:25 -0700
Subject: [Python-checkins] python/nondist/peps pep-0262.txt,1.6,1.7
Message-ID: 

Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv28731

Modified Files:
	pep-0262.txt 
Log Message:
Point to (still-unfinished) implementation patch on SF

Index: pep-0262.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0262.txt,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** pep-0262.txt	28 Mar 2002 21:39:16 -0000	1.6
--- pep-0262.txt	29 May 2002 21:24:23 -0000	1.7
***************
*** 171,176 ****
      Patches to the Distutils that 1) implement an InstallationDatabase
      class, 2) Update the database when a new package is installed.  3)
!     a simple package management tool, features to be added to this
!     PEP.  (Or a separate PEP?)  
  
  
--- 171,177 ----
      Patches to the Distutils that 1) implement an InstallationDatabase
      class, 2) Update the database when a new package is installed.  3)
!     add a simple package management tool, features to be added to this
!     PEP.  (Or should that be a separate PEP?)  See [2] for the current 
!     patch.
  
  
***************
*** 201,204 ****
--- 202,209 ----
      [1] Michael Muller's patch (posted to the Distutils-SIG around 28
          Dec 1999) generates a list of installed files.
+ 
+     [2] A patch to implement this PEP will be tracked as 
+         patch #562100 on SourceForge.  
+         http://www.python.org/sf/562100
  
  





From rhettinger@users.sourceforge.net  Thu May 30 00:05:49 2002
From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net)
Date: Wed, 29 May 2002 16:05:49 -0700
Subject: [Python-checkins] python/dist/src/Lib MimeWriter.py,1.7,1.7.24.1
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv30766

Modified Files:
      Tag: release22-maint
	MimeWriter.py 
Log Message:
Backport change to 1.8 adding docstrings

Index: MimeWriter.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/MimeWriter.py,v
retrieving revision 1.7
retrieving revision 1.7.24.1
diff -C2 -d -r1.7 -r1.7.24.1
*** MimeWriter.py	9 Feb 2001 09:34:36 -0000	1.7
--- MimeWriter.py	29 May 2002 23:05:46 -0000	1.7.24.1
***************
*** 1,7 ****
  """Generic MIME writer.
  
! Classes:
! 
! MimeWriter - the only thing here.
  
  """
--- 1,10 ----
  """Generic MIME writer.
  
! This module defines the class MimeWriter.  The MimeWriter class implements
! a basic formatter for creating MIME multi-part files.  It doesn't seek around
! the output file nor does it use large amounts of buffer space. You must write
! the parts out in the order that they should occur in the final file.
! MimeWriter does buffer the headers you add, allowing you to rearrange their
! order.
  
  """
***************
*** 87,90 ****
--- 90,101 ----
  
      def addheader(self, key, value, prefix=0):
+         """Add a header line to the MIME message.
+ 
+         The key is the name of the header, where the value obviously provides
+         the value of the header. The optional argument prefix determines
+         where the header is inserted; 0 means append at the end, 1 means
+         insert at the start. The default is to append.
+ 
+         """
          lines = value.split("\n")
          while lines and not lines[-1]: del lines[-1]
***************
*** 100,107 ****
--- 111,134 ----
  
      def flushheaders(self):
+         """Writes out and forgets all headers accumulated so far.
+ 
+         This is useful if you don't need a body part at all; for example,
+         for a subpart of type message/rfc822 that's (mis)used to store some
+         header-like information.
+ 
+         """
          self._fp.writelines(self._headers)
          self._headers = []
  
      def startbody(self, ctype, plist=[], prefix=1):
+         """Returns a file-like object for writing the body of the message.
+ 
+         The content-type is set to the provided ctype, and the optional
+         parameter, plist, provides additional parameters for the
+         content-type declaration.  The optional argument prefix determines
+         where the header is inserted; 0 means append at the end, 1 means
+         insert at the start. The default is to insert at the start.
+ 
+         """
          for name, value in plist:
              ctype = ctype + ';\n %s=\"%s\"' % (name, value)
***************
*** 112,115 ****
--- 139,154 ----
  
      def startmultipartbody(self, subtype, boundary=None, plist=[], prefix=1):
+         """Returns a file-like object for writing the body of the message.
+ 
+         Additionally, this method initializes the multi-part code, where the
+         subtype parameter provides the multipart subtype, the boundary
+         parameter may provide a user-defined boundary specification, and the
+         plist parameter provides optional parameters for the subtype.  The
+         optional argument, prefix, determines where the header is inserted;
+         0 means append at the end, 1 means insert at the start. The default
+         is to insert at the start.  Subparts should be created using the
+         nextpart() method.
+ 
+         """
          self._boundary = boundary or mimetools.choose_boundary()
          return self.startbody("multipart/" + subtype,
***************
*** 118,125 ****
--- 157,178 ----
  
      def nextpart(self):
+         """Returns a new instance of MimeWriter which represents an
+         individual part in a multipart message.
+ 
+         This may be used to write the part as well as used for creating
+         recursively complex multipart messages. The message must first be
+         initialized with the startmultipartbody() method before using the
+         nextpart() method.
+ 
+         """
          self._fp.write("\n--" + self._boundary + "\n")
          return self.__class__(self._fp)
  
      def lastpart(self):
+         """This is used to designate the last part of a multipart message.
+ 
+         It should always be used when writing multipart messages.
+ 
+         """
          self._fp.write("\n--" + self._boundary + "--\n")
  





From rhettinger@users.sourceforge.net  Thu May 30 00:15:48 2002
From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net)
Date: Wed, 29 May 2002 16:15:48 -0700
Subject: [Python-checkins] python/dist/src/Lib cmd.py,1.26.16.1,1.26.16.2
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv765

Modified Files:
      Tag: release22-maint
	cmd.py 
Log Message:
Backport change to 1.29 adding docstrings

Index: cmd.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/cmd.py,v
retrieving revision 1.26.16.1
retrieving revision 1.26.16.2
diff -C2 -d -r1.26.16.1 -r1.26.16.2
*** cmd.py	25 Mar 2002 12:34:15 -0000	1.26.16.1
--- cmd.py	29 May 2002 23:15:46 -0000	1.26.16.2
***************
*** 54,57 ****
--- 54,68 ----
  
  class Cmd:
+     """A simple framework for writing line-oriented command interpreters.
+ 
+     These are often useful for test harnesses, administrative tools, and
+     prototypes that will later be wrapped in a more sophisticated interface.
+ 
+     A Cmd instance or subclass instance is a line-oriented interpreter
+     framework.  There is no good reason to instantiate Cmd itself; rather,
+     it's useful as a superclass of an interpreter class you define yourself
+     in order to inherit Cmd's methods and encapsulate action methods.
+ 
+     """
      prompt = PROMPT
      identchars = IDENTCHARS
***************
*** 68,71 ****
--- 79,90 ----
  
      def __init__(self, completekey='tab'):
+         """Instantiate a line-oriented interpreter framework.
+ 
+         The optional argument is the readline name of a completion key;
+         it defaults to the Tab key. If completekey is not None and the
+         readline module is available, command completion is done
+         automatically.
+ 
+         """
          if completekey:
              try:
***************
*** 77,80 ****
--- 96,105 ----
  
      def cmdloop(self, intro=None):
+         """Repeatedly issue a prompt, accept input, parse an initial prefix
+         off the received input, and dispatch to action methods, passing them
+         the remainder of the line as argument.
+ 
+         """
+ 
          self.preloop()
          if intro is not None:
***************
*** 107,119 ****
--- 132,154 ----
  
      def precmd(self, line):
+         """Hook method executed just before the command line is
+         interpreted, but after the input prompt is generated and issued.
+ 
+         """
          return line
  
      def postcmd(self, stop, line):
+         """Hook method executed just after a command dispatch is finished."""
          return stop
  
      def preloop(self):
+         """Hook method executed once when the cmdloop() method is called."""
          pass
  
      def postloop(self):
+         """Hook method executed once when the cmdloop() method is about to
+         return.
+ 
+         """
          pass
  
***************
*** 135,138 ****
--- 170,182 ----
  
      def onecmd(self, line):
+         """Interpret the argument as though it had been typed in response
+         to the prompt.
+ 
+         This may be overridden, but should not normally need to be;
+         see the precmd() and postcmd() methods for useful execution hooks.
+         The return value is a flag indicating whether interpretation of
+         commands by the interpreter should stop.
+ 
+         """
          cmd, arg, line = self.parseline(line)
          if not line:
***************
*** 151,161 ****
--- 195,223 ----
  
      def emptyline(self):
+         """Called when an empty line is entered in response to the prompt.
+ 
+         If this method is not overridden, it repeats the last nonempty
+         command entered.
+ 
+         """
          if self.lastcmd:
              return self.onecmd(self.lastcmd)
  
      def default(self, line):
+         """Called on an input line when the command prefix is not recognized.
+ 
+         If this method is not overridden, it prints an error message and
+         returns.
+ 
+         """
          print '*** Unknown syntax:', line
  
      def completedefault(self, *ignored):
+         """Method called to complete an input line when no command-specific
+         complete_*() method is available.
+ 
+         By default, it returns an empty list.
+ 
+         """
          return []
  





From rhettinger@users.sourceforge.net  Thu May 30 00:19:45 2002
From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net)
Date: Wed, 29 May 2002 16:19:45 -0700
Subject: [Python-checkins] python/dist/src/Lib dumbdbm.py,1.15.4.1,1.15.4.1.2.1
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv1582

Modified Files:
      Tag: release22-maint
	dumbdbm.py 
Log Message:
Backport change to 1.18 adding docstrings

Index: dumbdbm.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/dumbdbm.py,v
retrieving revision 1.15.4.1
retrieving revision 1.15.4.1.2.1
diff -C2 -d -r1.15.4.1 -r1.15.4.1.2.1
*** dumbdbm.py	21 Dec 2001 05:29:45 -0000	1.15.4.1
--- dumbdbm.py	29 May 2002 23:19:43 -0000	1.15.4.1.2.1
***************
*** 151,158 ****
          if self._index is not None:
              self._commit()
!   
  
  
  def open(file, flag=None, mode=0666):
      # flag, mode arguments are currently ignored
      return _Database(file, mode)
--- 151,170 ----
          if self._index is not None:
              self._commit()
! 
  
  
  def open(file, flag=None, mode=0666):
+     """Open the database file, filename, and return corresponding object.
+ 
+     The flag argument, used to control how the database is opened in the
+     other DBM implementations, is ignored in the dumbdbm module; the
+     database is always opened for update, and will be created if it does
+     not exist.
+ 
+     The optional mode argument is the UNIX mode of the file, used only when
+     the database has to be created.  It defaults to octal code 0666 (and
+     will be modified by the prevailing umask).
+ 
+     """
      # flag, mode arguments are currently ignored
      return _Database(file, mode)





From rhettinger@users.sourceforge.net  Thu May 30 00:24:14 2002
From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net)
Date: Wed, 29 May 2002 16:24:14 -0700
Subject: [Python-checkins] python/dist/src/Lib formatter.py,1.19,1.19.16.1
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv2424

Modified Files:
      Tag: release22-maint
	formatter.py 
Log Message:
Backport change to 1.18 adding docstrings

Index: formatter.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/formatter.py,v
retrieving revision 1.19
retrieving revision 1.19.16.1
diff -C2 -d -r1.19 -r1.19.16.1
*** formatter.py	13 Aug 2001 14:55:17 -0000	1.19
--- formatter.py	29 May 2002 23:24:12 -0000	1.19.16.1
***************
*** 28,31 ****
--- 28,40 ----
  
  class NullFormatter:
+     """A formatter which does nothing.
+ 
+     If the writer parameter is omitted, a NullWriter instance is created.
+     No methods of the writer are called by NullFormatter instances.
+ 
+     Implementations should inherit from this class if implementing a writer
+     interface but don't need to inherit any implementation.
+ 
+     """
  
      def __init__(self, writer=None):
***************
*** 53,56 ****
--- 62,72 ----
  
  class AbstractFormatter:
+     """The standard formatter.
+ 
+     This implementation has demonstrated wide applicability to many writers,
+     and may be used directly in most circumstances.  It has been used to
+     implement a full-featured World Wide Web browser.
+ 
+     """
  
      #  Space handling policy:  blank spaces at the boundary between elements
***************
*** 284,288 ****
  
  class NullWriter:
!     """Minimal writer interface to use in testing & inheritance."""
      def __init__(self): pass
      def flush(self): pass
--- 300,310 ----
  
  class NullWriter:
!     """Minimal writer interface to use in testing & inheritance.
! 
!     A writer which only provides the interface definition; no actions are
!     taken on any methods.  This should be the base class for all writers
!     which do not need to inherit any implementation methods.
! 
!     """
      def __init__(self): pass
      def flush(self): pass
***************
*** 301,304 ****
--- 323,332 ----
  
  class AbstractWriter(NullWriter):
+     """A writer which can be used in debugging formatters, but not much else.
+ 
+     Each method simply announces itself by printing its name and
+     arguments on standard output.
+ 
+     """
  
      def new_alignment(self, align):
***************
*** 337,340 ****
--- 365,375 ----
  
  class DumbWriter(NullWriter):
+     """Simple writer class which writes output on the file object passed in
+     as the file parameter or, if file is omitted, on standard output.  The
+     output is simply word-wrapped to the number of columns specified by
+     the maxcol parameter.  This class is suitable for reflowing a sequence
+     of paragraphs.
+ 
+     """
  
      def __init__(self, file=None, maxcol=72):





From rhettinger@users.sourceforge.net  Thu May 30 00:35:10 2002
From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net)
Date: Wed, 29 May 2002 16:35:10 -0700
Subject: [Python-checkins] python/dist/src/Lib htmllib.py,1.18,1.18.18.1
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv4631

Modified Files:
      Tag: release22-maint
	htmllib.py 
Log Message:
Backport change to 1.19 adding docstrings.

Index: htmllib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/htmllib.py,v
retrieving revision 1.18
retrieving revision 1.18.18.1
diff -C2 -d -r1.18 -r1.18.18.1
*** htmllib.py	11 May 2001 18:45:52 -0000	1.18
--- htmllib.py	29 May 2002 23:35:08 -0000	1.18.18.1
***************
*** 12,19 ****
--- 12,32 ----
  
  class HTMLParser(SGMLParser):
+     """This is the basic HTML parser class.
+ 
+     It supports all entity names required by the HTML 2.0 specification
+     RFC 1866.  It also defines handlers for all HTML 2.0 and many HTML 3.0
+     and 3.2 elements.
+ 
+     """
  
      from htmlentitydefs import entitydefs
  
      def __init__(self, formatter, verbose=0):
+         """Creates an instance of the HTMLParser class.
+ 
+         The formatter parameter is the formatter instance associated with
+         the parser.
+ 
+         """
          SGMLParser.__init__(self, verbose)
          self.formatter = formatter
***************
*** 44,50 ****
--- 57,78 ----
  
      def save_bgn(self):
+         """Begins saving character data in a buffer instead of sending it
+         to the formatter object.
+ 
+         Retrieve the stored data via the save_end() method.  Use of the
+         save_bgn() / save_end() pair may not be nested.
+ 
+         """
          self.savedata = ''
  
      def save_end(self):
+         """Ends buffering character data and returns all data saved since
+         the preceding call to the save_bgn() method.
+ 
+         If the nofill flag is false, whitespace is collapsed to single
+         spaces.  A call to this method without a preceding call to the
+         save_bgn() method will raise a TypeError exception.
+ 
+         """
          data = self.savedata
          self.savedata = None
***************
*** 56,59 ****
--- 84,96 ----
  
      def anchor_bgn(self, href, name, type):
+         """This method is called at the start of an anchor region.
+ 
+         The arguments correspond to the attributes of the  tag with
+         the same names.  The default implementation maintains a list of
+         hyperlinks (defined by the HREF attribute for  tags) within
+         the document.  The list of hyperlinks is available as the data
+         attribute anchorlist.
+ 
+         """
          self.anchor = href
          if self.anchor:
***************
*** 61,64 ****
--- 98,107 ----
  
      def anchor_end(self):
+         """This method is called at the end of an anchor region.
+ 
+         The default implementation adds a textual footnote marker using an
+         index into the list of hyperlinks created by the anchor_bgn()method.
+ 
+         """
          if self.anchor:
              self.handle_data("[%d]" % len(self.anchorlist))
***************
*** 68,71 ****
--- 111,120 ----
  
      def handle_image(self, src, alt, *args):
+         """This method is called to handle images.
+ 
+         The default implementation simply passes the alt value to the
+         handle_data() method.
+ 
+         """
          self.handle_data(alt)
  





From rhettinger@users.sourceforge.net  Thu May 30 00:44:52 2002
From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net)
Date: Wed, 29 May 2002 16:44:52 -0700
Subject: [Python-checkins] python/dist/src/Lib rexec.py,1.34,1.34.10.1
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv6575

Modified Files:
      Tag: release22-maint
	rexec.py 
Log Message:
Backport change to 1.35 adding doc strings

Index: rexec.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/rexec.py,v
retrieving revision 1.34
retrieving revision 1.34.10.1
diff -C2 -d -r1.34 -r1.34.10.1
*** rexec.py	13 Oct 2001 18:34:42 -0000	1.34
--- rexec.py	29 May 2002 23:44:50 -0000	1.34.10.1
***************
*** 115,120 ****
  
  class RExec(ihooks._Verbose):
  
!     """Restricted Execution environment."""
  
      ok_path = tuple(sys.path)           # That's a policy decision
--- 115,130 ----
  
  class RExec(ihooks._Verbose):
+     """Basic restricted execution framework.
  
!     Code executed in this restricted environment will only have access to
!     modules and functions that are deemed safe; you can subclass RExec to
!     add or remove capabilities as desired.
! 
!     The RExec class can prevent code from performing unsafe operations like
!     reading or writing disk files, or using TCP/IP sockets.  However, it does
!     not protect against code using extremely large amounts of memory or
!     processor time.
! 
!     """
  
      ok_path = tuple(sys.path)           # That's a policy decision
***************
*** 136,139 ****
--- 146,176 ----
  
      def __init__(self, hooks = None, verbose = 0):
+         """Returns an instance of the RExec class.
+ 
+         The hooks parameter is an instance of the RHooks class or a subclass
+         of it.  If it is omitted or None, the default RHooks class is
+         instantiated.
+ 
+         Whenever the RExec module searches for a module (even a built-in one)
+         or reads a module's code, it doesn't actually go out to the file
+         system itself.  Rather, it calls methods of an RHooks instance that
+         was passed to or created by its constructor.  (Actually, the RExec
+         object doesn't make these calls --- they are made by a module loader
+         object that's part of the RExec object.  This allows another level of
+         flexibility, which can be useful when changing the mechanics of
+         import within the restricted environment.)
+ 
+         By providing an alternate RHooks object, we can control the file
+         system accesses made to import a module, without changing the
+         actual algorithm that controls the order in which those accesses are
+         made.  For instance, we could substitute an RHooks object that
+         passes all filesystem requests to a file server elsewhere, via some
+         RPC mechanism such as ILU.  Grail's applet loader uses this to support
+         importing applets from a URL for a directory.
+ 
+         If the verbose parameter is true, additional debugging output may be
+         sent to standard output.
+ 
+         """
          ihooks._Verbose.__init__(self, verbose)
          # XXX There's a circular reference here:
***************
*** 251,272 ****
--- 288,352 ----
  
      def r_exec(self, code):
+         """Execute code within a restricted environment.
+ 
+         The code parameter must either be a string containing one or more
+         lines of Python code, or a compiled code object, which will be
+         executed in the restricted environment's __main__ module.
+ 
+         """
          m = self.add_module('__main__')
          exec code in m.__dict__
  
      def r_eval(self, code):
+         """Evaluate code within a restricted environment.
+ 
+         The code parameter must either be a string containing a Python
+         expression, or a compiled code object, which will be evaluated in
+         the restricted environment's __main__ module.  The value of the
+         expression or code object will be returned.
+ 
+         """
          m = self.add_module('__main__')
          return eval(code, m.__dict__)
  
      def r_execfile(self, file):
+         """Execute the Python code in the file in the restricted
+         environment's __main__ module.
+ 
+         """
          m = self.add_module('__main__')
          execfile(file, m.__dict__)
  
      def r_import(self, mname, globals={}, locals={}, fromlist=[]):
+         """Import a module, raising an ImportError exception if the module
+         is considered unsafe.
+ 
+         This method is implicitly called by code executing in the
+         restricted environment.  Overriding this method in a subclass is
+         used to change the policies enforced by a restricted environment.
+ 
+         """
          return self.importer.import_module(mname, globals, locals, fromlist)
  
      def r_reload(self, m):
+         """Reload the module object, re-parsing and re-initializing it.
+ 
+         This method is implicitly called by code executing in the
+         restricted environment.  Overriding this method in a subclass is
+         used to change the policies enforced by a restricted environment.
+ 
+         """
          return self.importer.reload(m)
  
      def r_unload(self, m):
+         """Unload the module.
+ 
+         Removes it from the restricted environment's sys.modules dictionary.
+ 
+         This method is implicitly called by code executing in the
+         restricted environment.  Overriding this method in a subclass is
+         used to change the policies enforced by a restricted environment.
+ 
+         """
          return self.importer.unload(m)
  
***************
*** 326,344 ****
--- 406,491 ----
  
      def s_exec(self, *args):
+         """Execute code within a restricted environment.
+ 
+         Similar to the r_exec() method, but the code will be granted access
+         to restricted versions of the standard I/O streams sys.stdin,
+         sys.stderr, and sys.stdout.
+ 
+         The code parameter must either be a string containing one or more
+         lines of Python code, or a compiled code object, which will be
+         executed in the restricted environment's __main__ module.
+ 
+         """
          return self.s_apply(self.r_exec, args)
  
      def s_eval(self, *args):
+         """Evaluate code within a restricted environment.
+ 
+         Similar to the r_eval() method, but the code will be granted access
+         to restricted versions of the standard I/O streams sys.stdin,
+         sys.stderr, and sys.stdout.
+ 
+         The code parameter must either be a string containing a Python
+         expression, or a compiled code object, which will be evaluated in
+         the restricted environment's __main__ module.  The value of the
+         expression or code object will be returned.
+ 
+         """
          return self.s_apply(self.r_eval, args)
  
      def s_execfile(self, *args):
+         """Execute the Python code in the file in the restricted
+         environment's __main__ module.
+ 
+         Similar to the r_execfile() method, but the code will be granted
+         access to restricted versions of the standard I/O streams sys.stdin,
+         sys.stderr, and sys.stdout.
+ 
+         """
          return self.s_apply(self.r_execfile, args)
  
      def s_import(self, *args):
+         """Import a module, raising an ImportError exception if the module
+         is considered unsafe.
+ 
+         This method is implicitly called by code executing in the
+         restricted environment.  Overriding this method in a subclass is
+         used to change the policies enforced by a restricted environment.
+ 
+         Similar to the r_import() method, but has access to restricted
+         versions of the standard I/O streams sys.stdin, sys.stderr, and
+         sys.stdout.
+ 
+         """
          return self.s_apply(self.r_import, args)
  
      def s_reload(self, *args):
+         """Reload the module object, re-parsing and re-initializing it.
+ 
+         This method is implicitly called by code executing in the
+         restricted environment.  Overriding this method in a subclass is
+         used to change the policies enforced by a restricted environment.
+ 
+         Similar to the r_reload() method, but has access to restricted
+         versions of the standard I/O streams sys.stdin, sys.stderr, and
+         sys.stdout.
+ 
+         """
          return self.s_apply(self.r_reload, args)
  
      def s_unload(self, *args):
+         """Unload the module.
+ 
+         Removes it from the restricted environment's sys.modules dictionary.
+ 
+         This method is implicitly called by code executing in the
+         restricted environment.  Overriding this method in a subclass is
+         used to change the policies enforced by a restricted environment.
+ 
+         Similar to the r_unload() method, but has access to restricted
+         versions of the standard I/O streams sys.stdin, sys.stderr, and
+         sys.stdout.
+ 
+         """
          return self.s_apply(self.r_unload, args)
  
***************
*** 346,349 ****
--- 493,508 ----
  
      def r_open(self, file, mode='r', buf=-1):
+         """Method called when open() is called in the restricted environment.
+ 
+         The arguments are identical to those of the open() function, and a
+         file object (or a class instance compatible with file objects)
+         should be returned.  RExec's default behaviour is allow opening
+         any file for reading, but forbidding any attempt to write a file.
+ 
+         This method is implicitly called by code executing in the
+         restricted environment.  Overriding this method in a subclass is
+         used to change the policies enforced by a restricted environment.
+ 
+         """
          if mode not in ('r', 'rb'):
              raise IOError, "can't open files for writing in restricted mode"





From rhettinger@users.sourceforge.net  Thu May 30 01:06:03 2002
From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net)
Date: Wed, 29 May 2002 17:06:03 -0700
Subject: [Python-checkins] python/dist/src/Lib rexec.py,1.35,1.36
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv10610

Modified Files:
	rexec.py 
Log Message:
Move statement out of comment block

Index: rexec.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/rexec.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** rexec.py	29 May 2002 16:18:42 -0000	1.35
--- rexec.py	30 May 2002 00:06:01 -0000	1.36
***************
*** 430,436 ****
          the restricted environment's __main__ module.  The value of the
          expression or code object will be returned.
-         return self.s_apply(self.r_eval, args)
  
          """
  
      def s_execfile(self, *args):
--- 430,436 ----
          the restricted environment's __main__ module.  The value of the
          expression or code object will be returned.
  
          """
+         return self.s_apply(self.r_eval, args)
  
      def s_execfile(self, *args):





From gvanrossum@users.sourceforge.net  Thu May 30 01:50:34 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Wed, 29 May 2002 17:50:34 -0700
Subject: [Python-checkins] python/nondist/peps pep-0283.txt,1.6,1.7
Message-ID: 

Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv20763

Modified Files:
	pep-0283.txt 
Log Message:
Remove mention of PEP 272 -- Andrew doesn't plan to submit any code
based on it to 2.3.


Index: pep-0283.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0283.txt,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** pep-0283.txt	29 May 2002 15:43:05 -0000	1.6
--- pep-0283.txt	30 May 2002 00:50:32 -0000	1.7
***************
*** 144,152 ****
        UTC.  A decision needs to be made.
  
-     - PEP 272  API for Block Encryption Algorithms          Kuchling
- 
-       Andrew wants to finish this.  I've heard one person (who shall
-       remain nameless) comment that there's no need for such an API.
- 
      - Decide on a clearer deprecation policy (especially for modules)
        and act on it.  For a start, see this message from Neil Norwitz:
--- 144,147 ----





From gvanrossum@users.sourceforge.net  Thu May 30 04:18:44 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Wed, 29 May 2002 20:18:44 -0700
Subject: [Python-checkins] python/nondist/peps pep-0283.txt,1.7,1.8
Message-ID: 

Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv1035

Modified Files:
	pep-0283.txt 
Log Message:
Add Optik.


Index: pep-0283.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0283.txt,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** pep-0283.txt	30 May 2002 00:50:32 -0000	1.7
--- pep-0283.txt	30 May 2002 03:18:42 -0000	1.8
***************
*** 76,79 ****
--- 76,84 ----
        the near future.
  
+     - A new command line option parser.  Greg Ward's Optik
+       (http://optik.sf.net) would fit the bill fine; there's only some
+       question about whether it should be given a less "cutesy" name.
+       See also http://www.python.org/sigs/getopt-sig/
+ 
      - Provide alternatives for common uses of the types module;
        Skip Montanaro has posted a proto-PEP for this idea:





From nnorwitz@users.sourceforge.net  Thu May 30 13:12:06 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Thu, 30 May 2002 05:12:06 -0700
Subject: [Python-checkins] python/dist/src/Lib pickle.py,1.64,1.65
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv14529/Lib

Modified Files:
	pickle.py 
Log Message:
Remove comment about inheritance, look one line up

Index: pickle.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v
retrieving revision 1.64
retrieving revision 1.65
diff -C2 -d -r1.64 -r1.65
*** pickle.py	29 May 2002 16:18:42 -0000	1.64
--- pickle.py	30 May 2002 12:12:04 -0000	1.65
***************
*** 43,51 ****
  
  class PickleError(Exception):
!     """A common base class for the other pickling exceptions.
! 
!     Inherits from \exception{Exception}.
! 
!     """
      pass
  
--- 43,47 ----
  
  class PickleError(Exception):
!     """A common base class for the other pickling exceptions."""
      pass
  





From gvanrossum@users.sourceforge.net  Thu May 30 16:41:58 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Thu, 30 May 2002 08:41:58 -0700
Subject: [Python-checkins] python/dist/src/Modules readline.c,2.48,2.49
Message-ID: 

Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv20079

Modified Files:
	readline.c 
Log Message:
SF #558432: Prevent Annoying ' ' from readline (Holker Krekel).

    readline in all python versions is configured
    to append a 'space' character for a successful
    completion. But for almost all python expressions
    'space' is not wanted (see coding conventions PEP 8).
    For example if you have a function 'longfunction'
    and you type 'longf' you get 'longfunction '
    as a completion. note the unwanted space at the 
    end. 

    The patch fixes this behaviour by setting readline's
    append_character to '\0' which means don't append
    anything. This doesn't work with readline < 2.1
    (AFAIK nowadays readline2.2 is in good use).

    An alternative approach would be to make the
    append_character
    accessable from python so that modules like
    the rlcompleter.py can set it to '\0'. 

[Ed.: I think expecting readline >= 2.2 is fine.  If a completer wants
another character they can append that to the keyword in the list.]


Index: readline.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v
retrieving revision 2.48
retrieving revision 2.49
diff -C2 -d -r2.48 -r2.49
*** readline.c	21 Apr 2002 15:03:18 -0000	2.48
--- readline.c	30 May 2002 15:41:56 -0000	2.49
***************
*** 574,577 ****
--- 574,578 ----
  		strdup(" \t\n`~!@#$%^&*()-=+[{]}\\|;:'\",<>/?");
  		/* All nonalphanums except '.' */
+ 	rl_completion_append_character ='\0';
  
  	begidx = PyInt_FromLong(0L);





From gvanrossum@users.sourceforge.net  Thu May 30 16:43:00 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Thu, 30 May 2002 08:43:00 -0700
Subject: [Python-checkins] python/dist/src/Misc ACKS,1.175,1.176
Message-ID: 

Update of /cvsroot/python/python/dist/src/Misc
In directory usw-pr-cvs1:/tmp/cvs-serv21128

Modified Files:
	ACKS 
Log Message:
Holger Krekel.


Index: ACKS
===================================================================
RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v
retrieving revision 1.175
retrieving revision 1.176
diff -C2 -d -r1.175 -r1.176
*** ACKS	23 May 2002 20:05:40 -0000	1.175
--- ACKS	30 May 2002 15:42:58 -0000	1.176
***************
*** 260,263 ****
--- 260,264 ----
  Joseph Koshy
  Bob Kras
+ Holger Krekel
  Hannu Krosing
  Andrew Kuchling





From mwh@users.sourceforge.net  Thu May 30 17:22:32 2002
From: mwh@users.sourceforge.net (mwh@users.sourceforge.net)
Date: Thu, 30 May 2002 09:22:32 -0700
Subject: [Python-checkins] python/dist/src/Misc pymemcompat.h,NONE,1.1
Message-ID: 

Update of /cvsroot/python/python/dist/src/Misc
In directory usw-pr-cvs1:/tmp/cvs-serv30354

Added Files:
	pymemcompat.h 
Log Message:
Add the pymemcompat.h header as discussed on python-dev.

Now we just need to make sure people know about it...



--- NEW FILE: pymemcompat.h ---
/* this idea of this file is that you bundle it with your extension,
   #include it, program to Python 2.3's memory API and have your
   extension build with any version of Python from 1.5.2 through to
   2.3 (and hopefully beyond) */

#ifndef Py_PYMEMCOMPAT_H
#define Py_PYMEMCOMPAT_H

#include "Python.h"

/* There are three "families" of memory API: the "raw memory", "object
   memory" and "object" families.  (This is ignoring the matter of the
   cycle collector, about which more is said below).

   Raw Memory:

       PyMem_Malloc, PyMem_Realloc, PyMem_Free

   Object Memory:

       PyObject_Malloc, PyObject_Realloc, PyObject_Free

   Object:

       PyObject_New, PyObject_NewVar, PyObject_Del

   The raw memory and object memory allocators both mimic the
   malloc/realloc/free interface from ANSI C, but the object memory
   allocator can (and, since 2.3, does by default) use a different
   allocation strategy biased towards lots of lots of "small"
   allocations.

   The object family is used for allocating Python objects, and the
   initializers take care of some basic initialization (setting the
   refcount to 1 and filling out the ob_type field) as well as having
   a somewhat different interface.

   Do not mix the families!  E.g. do not allocate memory with
   PyMem_Malloc and free it with PyObject_Free.  You may get away with
   it quite a lot of the time, but there *are* scenarios where this
   will break.  You Have Been Warned. 

   Also, in many versions of Python there are an insane amount of
   memory interfaces to choose from.  Use the ones described above. */

#if PY_VERSION_HEX < 0x01060000
/* raw memory interface already present */

/* there is no object memory interface in 1.5.2 */
#define PyObject_Malloc		PyMem_Malloc
#define PyObject_Realloc	PyMem_Realloc
#define PyObject_Free		PyMem_Free

/* the object interface is there, but the names have changed */
#define PyObject_New		PyObject_NEW
#define PyObject_NewVar		PyObject_NEW_VAR
#define PyObject_Del		PyMem_Free
#endif

/* If your object is a container you probably want to support the
   cycle collector, which was new in Python 2.0.

   Unfortunately, the interface to the collector that was present in
   Python 2.0 and 2.1 proved to be tricky to use, and so changed in
   2.2 -- in a way that can't easily be papered over with macros.

   This file contains macros that let you program to the 2.2 GC API.
   Your module will compile against any Python since version 1.5.2,
   but the type will only participate in the GC in versions 2.2 and
   up.  Some work is still necessary on your part to only fill out the
   tp_traverse and tp_clear fields when they exist and set tp_flags
   appropriately.

   It is possible to support both the 2.0 and 2.2 GC APIs, but it's
   not pretty and this comment block is too narrow to contain a
   desciption of what's required... */

#if PY_VERSION_HEX < 0x020200B1
#define PyObject_GC_New         PyObject_New
#define PyObject_GC_NewVar      PyObject_NewVar
#define PyObject_GC_Del         PyObject_Del
#define PyObject_GC_Track(op)
#define PyObject_GC_UnTrack(op)
#endif

#endif /* !Py_PYMEMCOMPAT_H */





From fdrake@users.sourceforge.net  Thu May 30 17:41:17 2002
From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net)
Date: Thu, 30 May 2002 09:41:17 -0700
Subject: [Python-checkins] python/dist/src/Misc pymemcompat.h,1.1,1.2
Message-ID: 

Update of /cvsroot/python/python/dist/src/Misc
In directory usw-pr-cvs1:/tmp/cvs-serv15525

Modified Files:
	pymemcompat.h 
Log Message:
Typo fixes.

Index: pymemcompat.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Misc/pymemcompat.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pymemcompat.h	30 May 2002 16:22:29 -0000	1.1
--- pymemcompat.h	30 May 2002 16:41:14 -0000	1.2
***************
*** 1,6 ****
! /* this idea of this file is that you bundle it with your extension,
     #include it, program to Python 2.3's memory API and have your
     extension build with any version of Python from 1.5.2 through to
!    2.3 (and hopefully beyond) */
  
  #ifndef Py_PYMEMCOMPAT_H
--- 1,6 ----
! /* The idea of this file is that you bundle it with your extension,
     #include it, program to Python 2.3's memory API and have your
     extension build with any version of Python from 1.5.2 through to
!    2.3 (and hopefully beyond). */
  
  #ifndef Py_PYMEMCOMPAT_H





From bckfnn@users.sourceforge.net  Thu May 30 17:59:58 2002
From: bckfnn@users.sourceforge.net (bckfnn@users.sourceforge.net)
Date: Thu, 30 May 2002 09:59:58 -0700
Subject: [Python-checkins] python/nondist/sandbox/ast asdl_java.py,1.5,1.6
Message-ID: 

Update of /cvsroot/python/python/nondist/sandbox/ast
In directory usw-pr-cvs1:/tmp/cvs-serv1623

Modified Files:
	asdl_java.py 
Log Message:
Added pickle support
Renamed Visitor.



Index: asdl_java.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/ast/asdl_java.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** asdl_java.py	21 Apr 2002 11:24:33 -0000	1.5
--- asdl_java.py	30 May 2002 16:59:56 -0000	1.6
***************
*** 53,58 ****
          self.file = open("%s.java" % name, "wb")
          print >> self.file, "// Autogenerated AST node"
!         print >> self.file, 'package org.python.p2.ast;'
!         print >> self.file, 'import org.python.p2.SimpleNode;'
          print >> self.file
      
--- 53,60 ----
          self.file = open("%s.java" % name, "wb")
          print >> self.file, "// Autogenerated AST node"
!         print >> self.file, 'package org.python.parser.ast;'
!         print >> self.file, 'import org.python.parser.SimpleNode;'
!         print >> self.file, 'import java.io.DataOutputStream;'
!         print >> self.file, 'import java.io.IOException;'
          print >> self.file
      
***************
*** 74,77 ****
--- 76,84 ----
  
  class AnalyzeVisitor(EmitVisitor):
+     index = 0
+     def makeIndex(self):
+         self.index += 1
+         return self.index
+ 
      def visitModule(self, mod):
          self.types = {}
***************
*** 91,98 ****
--- 98,108 ----
                  break
          for t in sum.types:
+             if not sum.simple:
+                 t.index = self.makeIndex()
              self.visit(t, name, depth)
  
      def visitProduct(self, product, name, depth):
          product.simple = 0
+         product.index = self.makeIndex()
          for f in product.fields:
              self.visit(f, depth + 1)
***************
*** 156,160 ****
          self.emit("", depth)
  
!         self.javaMethods(name, "%sType" % name, product.fields, depth+1)
  
          self.emit("}", depth)
--- 166,171 ----
          self.emit("", depth)
  
!         self.javaMethods(product, name, "%sType" % name, product.fields,
!                          depth+1)
  
          self.emit("}", depth)
***************
*** 177,189 ****
          self.emit("", depth)
  
!         self.javaMethods(cons.name, cons.name, cons.fields, depth+1)
  
          self.emit("}", depth)
          self.close()
  
!     def javaMethods(self, clsname, ctorname, fields, depth):
!         # The java ctor
!         self.emit("public %s(%s) {" % (ctorname,
!              ", ".join([self.fieldDef(f) for f in fields])), depth)
          for f in fields:
              self.emit("this.%s = %s;" % (f.name, f.name), depth+1)
--- 188,201 ----
          self.emit("", depth)
  
!         self.javaMethods(cons, cons.name, cons.name, cons.fields, depth+1)
  
          self.emit("}", depth)
          self.close()
  
!     def javaMethods(self, type, clsname, ctorname, fields, depth):
!         # The java ctors
!         fpargs = ", ".join([self.fieldDef(f) for f in fields])
! 
!         self.emit("public %s(%s) {" % (ctorname, fpargs), depth)
          for f in fields:
              self.emit("this.%s = %s;" % (f.name, f.name), depth+1)
***************
*** 191,194 ****
--- 203,216 ----
          self.emit("", 0)
  
+         if fpargs:
+             fpargs += ", "
+         self.emit("public %s(%sSimpleNode parent) {" % (ctorname, fpargs), depth)
+         self.emit("this(%s);" %
+                     ", ".join([str(f.name) for f in fields]), depth+1)
+         self.emit("this.beginLine = parent.beginLine;", depth+1);
+         self.emit("this.beginColumn = parent.beginColumn;", depth+1);
+         self.emit("}", depth)
+         self.emit("", 0)
+ 
          # The toString() method
          self.emit("public String toString() {", depth)
***************
*** 209,214 ****
          self.emit("", 0)
  
          # The accept() method
!         self.emit("public Object accept(Visitor visitor) throws Exception {", depth)
          if clsname == ctorname:
              self.emit('return visitor.visit%s(this);' % clsname, depth+1)
--- 231,244 ----
          self.emit("", 0)
  
+         # The pickle() method
+         self.emit("public void pickle(DataOutputStream ostream) throws IOException {", depth)
+         self.emit("pickleThis(%s, ostream);" % type.index, depth+1);
+         for f in fields:
+             self.emit("pickleThis(this.%s, ostream);" % f.name, depth+1)
+         self.emit("}", depth)
+         self.emit("", 0)
+ 
          # The accept() method
!         self.emit("public Object accept(VisitorIF visitor) throws Exception {", depth)
          if clsname == ctorname:
              self.emit('return visitor.visit%s(this);' % clsname, depth+1)
***************
*** 220,224 ****
  
          # The visitChildren() method
!         self.emit("public void traverse(Visitor visitor) throws Exception {", depth)
          for f in fields:
              if self.bltinnames.has_key(str(f.type)):
--- 250,254 ----
  
          # The visitChildren() method
!         self.emit("public void traverse(VisitorIF visitor) throws Exception {", depth)
          for f in fields:
              if self.bltinnames.has_key(str(f.type)):
***************
*** 270,275 ****
          for dfn in mod.dfns:
              self.visit(dfn)
!         self.open("Visitor")
!         self.emit('public interface Visitor {', 0)
          for ctor in self.ctors:
              self.emit("public Object visit%s(%s node) throws Exception;" % 
--- 300,305 ----
          for dfn in mod.dfns:
              self.visit(dfn)
!         self.open("VisitorIF")
!         self.emit('public interface VisitorIF {', 0)
          for ctor in self.ctors:
              self.emit("public Object visit%s(%s node) throws Exception;" % 
***************
*** 279,283 ****
  
          self.open("VisitorBase")
!         self.emit('public abstract class VisitorBase implements Visitor {', 0)
          for ctor in self.ctors:
              self.emit("public Object visit%s(%s node) throws Exception {" % 
--- 309,313 ----
  
          self.open("VisitorBase")
!         self.emit('public abstract class VisitorBase implements VisitorIF {', 0)
          for ctor in self.ctors:
              self.emit("public Object visit%s(%s node) throws Exception {" % 





From bckfnn@users.sourceforge.net  Thu May 30 18:00:52 2002
From: bckfnn@users.sourceforge.net (bckfnn@users.sourceforge.net)
Date: Thu, 30 May 2002 10:00:52 -0700
Subject: [Python-checkins] python/nondist/sandbox/ast python.asdl,1.23,1.24
Message-ID: 

Update of /cvsroot/python/python/nondist/sandbox/ast
In directory usw-pr-cvs1:/tmp/cvs-serv2329

Modified Files:
	python.asdl 
Log Message:
Renamed 'except' to 'excepthandler'. Except is a python reserved word.



Index: python.asdl
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/ast/python.asdl,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** python.asdl	22 May 2002 11:07:04 -0000	1.23
--- python.asdl	30 May 2002 17:00:50 -0000	1.24
***************
*** 29,33 ****
  	      -- 'type' is a bad name
  	      | Raise(expr? type, expr? inst, expr? tback)
! 	      | TryExcept(stmt* body, except* handlers, stmt* orelse)
  	      | TryFinally(stmt* body, stmt* finalbody)
  	      | Assert(expr test, expr? msg)
--- 29,33 ----
  	      -- 'type' is a bad name
  	      | Raise(expr? type, expr? inst, expr? tback)
! 	      | TryExcept(stmt* body, excepthandler* handlers, stmt* orelse)
  	      | TryFinally(stmt* body, stmt* finalbody)
  	      | Assert(expr test, expr? msg)
***************
*** 88,92 ****
  	-- not sure what to call the first argument for raise and except
  
! 	except = (expr? type, expr? name, stmt* body)
  
  	arguments = (expr* args, identifier? vararg, 
--- 88,92 ----
  	-- not sure what to call the first argument for raise and except
  
! 	excepthandler = (expr? type, expr? name, stmt* body)
  
  	arguments = (expr* args, identifier? vararg, 





From jhylton@users.sourceforge.net  Thu May 30 18:10:22 2002
From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net)
Date: Thu, 30 May 2002 10:10:22 -0700
Subject: [Python-checkins] python/dist/src/Lib/test test_import.py,1.10,1.11
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv12188/Lib/test

Modified Files:
	test_import.py 
Log Message:
Verify that the imp can find and load .py files.



Index: test_import.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_import.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** test_import.py	24 Oct 2001 20:32:02 -0000	1.10
--- test_import.py	30 May 2002 17:10:20 -0000	1.11
***************
*** 70,71 ****
--- 70,76 ----
  finally:
      del sys.path[0]
+ 
+ # Verify that the imp module can correctly load and find .py files
+ import imp
+ x = imp.find_module("os")
+ os = imp.load_module("os", *x)





From jhylton@users.sourceforge.net  Thu May 30 18:15:28 2002
From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net)
Date: Thu, 30 May 2002 10:15:28 -0700
Subject: [Python-checkins] python/dist/src/Python import.c,2.202,2.203
Message-ID: 

Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv17379/Python

Modified Files:
	import.c 
Log Message:
Cover a few corners in the 'U' mode integration to make imp work.

get_file() must convert 'U' to "r" PY_STDIOTEXTMODE before calling
fopen().

imp_load_module() must accept 'r' or 'U' or something with '+'.

Also reflow some long lines.




Index: import.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/import.c,v
retrieving revision 2.202
retrieving revision 2.203
diff -C2 -d -r2.202 -r2.203
*** import.c	28 May 2002 10:58:19 -0000	2.202
--- import.c	30 May 2002 17:15:25 -0000	2.203
***************
*** 1041,1045 ****
  		for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) {
  #if defined(PYOS_OS2)
! 			/* OS/2 limits DLLs to 8 character names (w/o extension)
  			 * so if the name is longer than that and its a
  			 * dynamically loaded module we're going to try,
--- 1041,1046 ----
  		for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) {
  #if defined(PYOS_OS2)
! 			/* OS/2 limits DLLs to 8 character names (w/o
! 			   extension)
  			 * so if the name is longer than that and its a
  			 * dynamically loaded module we're going to try,
***************
*** 1048,1054 ****
  			if (strlen(realname) > 8) {
  				/* is this an attempt to load a C extension? */
! 				const struct filedescr *scan = _PyImport_DynLoadFiletab;
  				while (scan->suffix != NULL) {
! 					if (strcmp(scan->suffix, fdp->suffix) == 0)
  						break;
  					else
--- 1049,1056 ----
  			if (strlen(realname) > 8) {
  				/* is this an attempt to load a C extension? */
! 				const struct filedescr *scan;
! 				scan = _PyImport_DynLoadFiletab;
  				while (scan->suffix != NULL) {
! 					if (!strcmp(scan->suffix, fdp->suffix))
  						break;
  					else
***************
*** 1068,1072 ****
  #endif /* !macintosh */
  			filemode = fdp->mode;
! 			if (filemode[0] == 'U') filemode = "r" PY_STDIOTEXTMODE;
  			fp = fopen(buf, filemode);
  			if (fp != NULL) {
--- 1070,1075 ----
  #endif /* !macintosh */
  			filemode = fdp->mode;
! 			if (filemode[0] == 'U') 
! 				filemode = "r" PY_STDIOTEXTMODE;
  			fp = fopen(buf, filemode);
  			if (fp != NULL) {
***************
*** 2297,2300 ****
--- 2300,2305 ----
  	FILE *fp;
  	if (fob == NULL) {
+ 		if (mode[0] == 'U') 
+ 			mode = "r" PY_STDIOTEXTMODE;
  		fp = fopen(pathname, mode);
  		if (fp == NULL)
***************
*** 2404,2411 ****
  			      &suffix, &mode, &type))
  		return NULL;
! 	if (*mode && (*mode != 'r' || strchr(mode, '+') != NULL)) {
! 		PyErr_Format(PyExc_ValueError,
! 			     "invalid file open mode %.200s", mode);
! 		return NULL;
  	}
  	if (fob == Py_None)
--- 2409,2417 ----
  			      &suffix, &mode, &type))
  		return NULL;
! 	if (*mode &&
! 	    !(*mode == 'r' || *mode == 'U' || strchr(mode, '+'))) {
! 			PyErr_Format(PyExc_ValueError,
! 				     "invalid file open mode %.200s", mode);
! 			return NULL;
  	}
  	if (fob == Py_None)





From gvanrossum@users.sourceforge.net  Thu May 30 18:33:10 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Thu, 30 May 2002 10:33:10 -0700
Subject: [Python-checkins] python/dist/src/Python import.c,2.203,2.204
Message-ID: 

Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv1513

Modified Files:
	import.c 
Log Message:
imp_load_module(): correct and comment the sense of the test for '+'
in the mode (it's forbidden).


Index: import.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/import.c,v
retrieving revision 2.203
retrieving revision 2.204
diff -C2 -d -r2.203 -r2.204
*** import.c	30 May 2002 17:15:25 -0000	2.203
--- import.c	30 May 2002 17:33:07 -0000	2.204
***************
*** 2409,2417 ****
  			      &suffix, &mode, &type))
  		return NULL;
! 	if (*mode &&
! 	    !(*mode == 'r' || *mode == 'U' || strchr(mode, '+'))) {
  			PyErr_Format(PyExc_ValueError,
  				     "invalid file open mode %.200s", mode);
  			return NULL;
  	}
  	if (fob == Py_None)
--- 2409,2422 ----
  			      &suffix, &mode, &type))
  		return NULL;
! 	if (*mode) {
! 		/* Mode must start with 'r' or 'U' and must not contain '+'.
! 		   Implicit in this test is the assumption that the mode
! 		   may contain other modifiers like 'b' or 't'. */
! 
! 		if (!(*mode == 'r' || *mode == 'U') || strchr(mode, '+')) {
  			PyErr_Format(PyExc_ValueError,
  				     "invalid file open mode %.200s", mode);
  			return NULL;
+ 		}
  	}
  	if (fob == Py_None)





From akuchling@users.sourceforge.net  Thu May 30 20:15:18 2002
From: akuchling@users.sourceforge.net (akuchling@users.sourceforge.net)
Date: Thu, 30 May 2002 12:15:18 -0700
Subject: [Python-checkins] python/dist/src/Lib/distutils/command install_lib.py,1.38,1.39
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib/distutils/command
In directory usw-pr-cvs1:/tmp/cvs-serv28051

Modified Files:
	install_lib.py 
Log Message:
Remove unneeded import


Index: install_lib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/install_lib.py,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** install_lib.py	6 Dec 2001 20:57:12 -0000	1.38
--- install_lib.py	30 May 2002 19:15:16 -0000	1.39
***************
*** 7,11 ****
  from distutils.core import Command
  from distutils.errors import DistutilsOptionError
- from distutils.dir_util import copy_tree
  
  class install_lib (Command):
--- 7,10 ----





From jhylton@users.sourceforge.net  Thu May 30 21:09:16 2002
From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net)
Date: Thu, 30 May 2002 13:09:16 -0700
Subject: [Python-checkins] python/nondist/sandbox/ast astmodule.c,1.7,1.8 test.py,1.4,1.5
Message-ID: 

Update of /cvsroot/python/python/nondist/sandbox/ast
In directory usw-pr-cvs1:/tmp/cvs-serv2919

Modified Files:
	astmodule.c test.py 
Log Message:
Add some preliminary support for subscripts and slices.

Track change of except -> excepthandler.


Index: astmodule.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/ast/astmodule.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** astmodule.c	22 Apr 2002 04:25:19 -0000	1.7
--- astmodule.c	30 May 2002 20:09:13 -0000	1.8
***************
*** 428,431 ****
--- 428,513 ----
  }
  
+ static slice_ty
+ ast_for_slice(node *n)
+ {
+     node *ch;
+     expr_ty lower = NULL, upper = NULL, step = NULL;
+ 
+     REQ(n, subscript);
+     /*
+        subscript: '.' '.' '.' | test | [test] ':' [test] [sliceop]
+        sliceop: ':' [test]
+     */
+     ch = CHILD(n, 0);
+     if (TYPE(ch) == DOT)
+ 	return Ellipsis();
+     if (NCH(n) == 1 && TYPE(ch) == test)
+ 	return Index(ast_for_expr(ch));
+     
+     if (TYPE(ch) == test)
+ 	lower = ast_for_expr(ch);
+ 
+     /* If there's an upper bound it's in the second or third position. */
+     if (TYPE(ch) == COLON) {
+ 	if (NCH(n) > 1) {
+ 	    node *n2 = CHILD(n, 1);
+ 	    if (TYPE(n2) == test)
+ 		upper = ast_for_expr(n2);
+ 	}
+     } else if (NCH(n) > 2) {
+ 	node *n2 = CHILD(n, 2);
+ 	if (TYPE(n2) == test)
+ 	    upper = ast_for_expr(n2);
+     }
+ 
+     ch = CHILD(n, NCH(n) - 1);
+     if (TYPE(ch) == sliceop) {
+ 	if (NCH(ch) == 1)
+ 	    ch = CHILD(ch, 0);
+ 	else
+ 	    ch = CHILD(ch, 1);
+ 	if (TYPE(ch) == test)
+ 	    step = ast_for_expr(ch);
+     }
+     
+     return Slice(lower, upper, step);
+ }
+ 
+ static expr_ty
+ ast_for_subscript(node *n)
+ {
+     node *t, *s;
+     int nch;
+ 
+     /* power: atom trailer* ('**' factor)* 
+        trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME 
+        subscriptlist: subscript (',' subscript)* [',']
+     */
+ 
+     REQ(n, power);
+     REQ(CHILD(n, 0), atom);
+     t = CHILD(n, 1);
+     REQ(t, trailer);
+ 
+     REQ(CHILD(t, 0), LSQB);
+     s = CHILD(t, 1);
+     REQ(CHILD(t, 2), RSQB);
+ 
+     nch = NCH(s);
+     if (nch <= 2) {
+ 	return Subscript(ast_for_atom(CHILD(n, 0)), 
+ 			 ast_for_slice(CHILD(s, 0)), Load);
+     } else {
+ 	int i;
+ 	asdl_seq *slices = asdl_seq_new(nch / 2);
+ 	for (i = 0; i < nch ; i += 2)
+ 	    asdl_seq_append(slices, ast_for_slice(CHILD(s, i)));
+ 	return Subscript(ast_for_atom(CHILD(n, 0)),
+ 			 ExtSlice(slices), Load);
+     }
+ 
+     return NULL;
+ }
+ 
  static expr_ty
  ast_for_expr(node *n)
***************
*** 541,545 ****
  		/* XXX a call */
  	    } else if (TYPE(CHILD(ch, 0)) == LSQB) {
! 		/* XXX a subscript */
  	    } else if (TYPE(CHILD(ch, 0)) == DOT) {
  		return Attribute(ast_for_atom(CHILD(n, 0)),
--- 623,627 ----
  		/* XXX a call */
  	    } else if (TYPE(CHILD(ch, 0)) == LSQB) {
! 		return ast_for_subscript(n);
  	    } else if (TYPE(CHILD(ch, 0)) == DOT) {
  		return Attribute(ast_for_atom(CHILD(n, 0)),
***************
*** 878,881 ****
--- 960,964 ----
      */
      char *s;
+ 
      REQ(n, if_stmt);
  
***************
*** 973,977 ****
  }
  
! static except_ty
  ast_for_except_clause(node *exc, node *body)
  {
--- 1056,1060 ----
  }
  
! static excepthandler_ty
  ast_for_except_clause(node *exc, node *body)
  {
***************
*** 981,991 ****
  
      if (NCH(exc) == 1)
! 	return except(NULL, NULL, ast_for_suite(body));
      else if (NCH(exc) == 2)
! 	return except(ast_for_expr(CHILD(exc, 1)), NULL, ast_for_suite(body));
      else {
  	expr_ty e = ast_for_expr(CHILD(exc, 3));
  	set_context(e, Store);
! 	return except(ast_for_expr(CHILD(exc, 1)), e,
  		      ast_for_suite(body));
      }
--- 1064,1075 ----
  
      if (NCH(exc) == 1)
! 	return excepthandler(NULL, NULL, ast_for_suite(body));
      else if (NCH(exc) == 2)
! 	return excepthandler(ast_for_expr(CHILD(exc, 1)), NULL, 
! 			     ast_for_suite(body));
      else {
  	expr_ty e = ast_for_expr(CHILD(exc, 3));
  	set_context(e, Store);
! 	return excepthandler(ast_for_expr(CHILD(exc, 1)), e,
  		      ast_for_suite(body));
      }

Index: test.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/ast/test.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** test.py	22 Apr 2002 04:25:19 -0000	1.4
--- test.py	30 May 2002 20:09:14 -0000	1.5
***************
*** 123,125 ****
--- 123,137 ----
  [x for x in x]
  obj.attr
+ x[0]
+ x[:]
+ x[1:]
+ x[:1]
+ x[::]
+ x[1:1]
+ x[1::]
+ x[:1:]
+ x[::1]
+ x[1:1:]
+ x[1:1:1]
+ x[1:2,2:3]
  """)





From nnorwitz@users.sourceforge.net  Fri May 31 14:11:43 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Fri, 31 May 2002 06:11:43 -0700
Subject: [Python-checkins] python/dist/src/Parser pgen.c,2.21,2.22
Message-ID: 

Update of /cvsroot/python/python/dist/src/Parser
In directory usw-pr-cvs1:/tmp/cvs-serv28633/Parser

Modified Files:
	pgen.c 
Log Message:
Py_IgnoreEnvironmentFlag should be extern, since it is declared in pythonrun.c

Index: pgen.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Parser/pgen.c,v
retrieving revision 2.21
retrieving revision 2.22
diff -C2 -d -r2.21 -r2.22
*** pgen.c	22 Apr 2002 03:29:32 -0000	2.21
--- pgen.c	31 May 2002 13:11:40 -0000	2.22
***************
*** 14,18 ****
  
  extern int Py_DebugFlag;
! int Py_IgnoreEnvironmentFlag; /* needed by Py_GETENV */
  
  
--- 14,18 ----
  
  extern int Py_DebugFlag;
! extern int Py_IgnoreEnvironmentFlag; /* needed by Py_GETENV */
  
  





From jhylton@users.sourceforge.net  Fri May 31 15:08:31 2002
From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net)
Date: Fri, 31 May 2002 07:08:31 -0700
Subject: [Python-checkins] python/dist/src/Lib/test test_syntax.py,NONE,1.1
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv3390/Lib/test

Added Files:
	test_syntax.py 
Log Message:
Fix SF bug [ 561825 ] Confusing error for "del f()"

In the error message, say del for del and assign for everything else.


--- NEW FILE: test_syntax.py ---
import re
import unittest

import test_support

class SyntaxTestCase(unittest.TestCase):

    def _check_error(self, code, errtext,
                     filename="", mode="exec"):
        """Check that compiling code raises SyntaxError with errtext.

        errtest is a regular expression that must be present in the
        test of the exception raised.
        """
        try:
            compile(code, filename, mode)
        except SyntaxError, err:
            mo = re.search(errtext, str(err))
            if mo is None:
                self.fail("SyntaxError did not contain '%s'" % `errtext`)
        else:
            self.fail("compile() did not raise SyntaxError")

    def test_assign_call(self):
        self._check_error("f() = 1", "assign")

    def test_assign_del(self):
        self._check_error("del f()", "delete")

def test_main():
    test_support.run_unittest(SyntaxTestCase)

if __name__ == "__main__":
    test_main()





From jhylton@users.sourceforge.net  Fri May 31 15:08:31 2002
From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net)
Date: Fri, 31 May 2002 07:08:31 -0700
Subject: [Python-checkins] python/dist/src/Python compile.c,2.244,2.245
Message-ID: 

Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv3390/Python

Modified Files:
	compile.c 
Log Message:
Fix SF bug [ 561825 ] Confusing error for "del f()"

In the error message, say del for del and assign for everything else.


Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.244
retrieving revision 2.245
diff -C2 -d -r2.244 -r2.245
*** compile.c	28 May 2002 18:47:29 -0000	2.244
--- compile.c	31 May 2002 14:08:29 -0000	2.245
***************
*** 2418,2423 ****
  	switch (TYPE(CHILD(n, 0))) {
  	case LPAR: /* '(' [exprlist] ')' */
! 		com_error(c, PyExc_SyntaxError,
! 			  "can't assign to function call");
  		break;
  	case DOT: /* '.' NAME */
--- 2418,2427 ----
  	switch (TYPE(CHILD(n, 0))) {
  	case LPAR: /* '(' [exprlist] ')' */
! 		if (assigning == OP_DELETE)
! 			com_error(c, PyExc_SyntaxError,
! 				  "can't delete function call");
! 		else
! 			com_error(c, PyExc_SyntaxError,
! 				  "can't assign to function call");
  		break;
  	case DOT: /* '.' NAME */





From nnorwitz@users.sourceforge.net  Fri May 31 15:13:06 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Fri, 31 May 2002 07:13:06 -0700
Subject: [Python-checkins] python/dist/src/Lib ftplib.py,1.68,1.69 markupbase.py,1.4,1.5 tabnanny.py,1.20,1.21
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv5685

Modified Files:
	ftplib.py markupbase.py tabnanny.py 
Log Message:
Use string methods where possible, and remove import string

Index: ftplib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/ftplib.py,v
retrieving revision 1.68
retrieving revision 1.69
diff -C2 -d -r1.68 -r1.69
*** ftplib.py	12 May 2002 05:53:51 -0000	1.68
--- ftplib.py	31 May 2002 14:13:03 -0000	1.69
***************
*** 37,41 ****
  import os
  import sys
- import string
  
  # Import SOCKS module if it exists, else standard socket module socket
--- 37,40 ----
***************
*** 267,271 ****
              raise error_proto, 'unsupported address family'
          fields = ['', `af`, host, `port`, '']
!         cmd = 'EPRT ' + string.joinfields(fields, '|')
          return self.voidcmd(cmd)
  
--- 266,270 ----
              raise error_proto, 'unsupported address family'
          fields = ['', `af`, host, `port`, '']
!         cmd = 'EPRT ' + '|'.join(fields)
          return self.voidcmd(cmd)
  
***************
*** 586,601 ****
      if resp[:3] <> '229':
          raise error_reply, resp
!     left = string.find(resp, '(')
      if left < 0: raise error_proto, resp
!     right = string.find(resp, ')', left + 1)
      if right < 0:
          raise error_proto, resp # should contain '(|||port|)'
      if resp[left + 1] <> resp[right - 1]:
          raise error_proto, resp
!     parts = string.split(resp[left + 1:right], resp[left+1])
      if len(parts) <> 5:
          raise error_proto, resp
      host = peer[0]
!     port = string.atoi(parts[3])
      return host, port
  
--- 585,600 ----
      if resp[:3] <> '229':
          raise error_reply, resp
!     left = resp.find('(')
      if left < 0: raise error_proto, resp
!     right = resp.find(')', left + 1)
      if right < 0:
          raise error_proto, resp # should contain '(|||port|)'
      if resp[left + 1] <> resp[right - 1]:
          raise error_proto, resp
!     parts = resp[left+1].split(resp[left + 1:right])
      if len(parts) <> 5:
          raise error_proto, resp
      host = peer[0]
!     port = int(parts[3])
      return host, port
  

Index: markupbase.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/markupbase.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** markupbase.py	26 Oct 2001 18:02:28 -0000	1.4
--- markupbase.py	31 May 2002 14:13:03 -0000	1.5
***************
*** 39,46 ****
              return j
          rawdata = self.rawdata
!         nlines = string.count(rawdata, "\n", i, j)
          if nlines:
              self.lineno = self.lineno + nlines
!             pos = string.rindex(rawdata, "\n", i, j) # Should not fail
              self.offset = j-(pos+1)
          else:
--- 39,46 ----
              return j
          rawdata = self.rawdata
!         nlines = rawdata.count("\n", i, j)
          if nlines:
              self.lineno = self.lineno + nlines
!             pos = rawdata.rindex("\n", i, j) # Should not fail
              self.offset = j-(pos+1)
          else:
***************
*** 177,181 ****
          rawdata = self.rawdata
          if '>' in rawdata[j:]:
!             return string.find(rawdata, ">", j) + 1
          return -1
  
--- 177,181 ----
          rawdata = self.rawdata
          if '>' in rawdata[j:]:
!             return rawdata.find(">", j) + 1
          return -1
  
***************
*** 201,205 ****
                  # an enumerated type; look for ')'
                  if ")" in rawdata[j:]:
!                     j = string.find(rawdata, ")", j) + 1
                  else:
                      return -1
--- 201,205 ----
                  # an enumerated type; look for ')'
                  if ")" in rawdata[j:]:
!                     j = rawdata.find(")", j) + 1
                  else:
                      return -1
***************
*** 308,312 ****
              if (i + len(s)) == n:
                  return None, -1  # end of buffer
!             return string.lower(name), m.end()
          else:
              self.updatepos(declstartpos, i)
--- 308,312 ----
              if (i + len(s)) == n:
                  return None, -1  # end of buffer
!             return name.lower(), m.end()
          else:
              self.updatepos(declstartpos, i)

Index: tabnanny.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/tabnanny.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** tabnanny.py	23 May 2002 15:15:29 -0000	1.20
--- tabnanny.py	31 May 2002 14:13:04 -0000	1.21
***************
*** 262,271 ****
  
  def format_witnesses(w):
-     import string
      firsts = map(lambda tup: str(tup[0]), w)
      prefix = "at tab size"
      if len(w) > 1:
          prefix = prefix + "s"
!     return prefix + " " + string.join(firsts, ', ')
  
  def process_tokens(tokens):
--- 262,270 ----
  
  def format_witnesses(w):
      firsts = map(lambda tup: str(tup[0]), w)
      prefix = "at tab size"
      if len(w) > 1:
          prefix = prefix + "s"
!     return prefix + " " + ', '.join(firsts)
  
  def process_tokens(tokens):





From nnorwitz@users.sourceforge.net  Fri May 31 15:15:13 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Fri, 31 May 2002 07:15:13 -0700
Subject: [Python-checkins] python/dist/src/Lib unittest.py,1.15,1.16
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv6497

Modified Files:
	unittest.py 
Log Message:
Fix printing plural (s or "").

Index: unittest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/unittest.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** unittest.py	21 May 2002 03:49:00 -0000	1.15
--- unittest.py	31 May 2002 14:15:11 -0000	1.16
***************
*** 617,621 ****
          run = result.testsRun
          self.stream.writeln("Ran %d test%s in %.3fs" %
!                             (run, run == 1 and "" or "s", timeTaken))
          self.stream.writeln()
          if not result.wasSuccessful():
--- 617,621 ----
          run = result.testsRun
          self.stream.writeln("Ran %d test%s in %.3fs" %
!                             (run, run != 1 and "s" or "", timeTaken))
          self.stream.writeln()
          if not result.wasSuccessful():





From gvanrossum@users.sourceforge.net  Fri May 31 15:32:09 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Fri, 31 May 2002 07:32:09 -0700
Subject: [Python-checkins] python/dist/src/Parser pgenmain.c,2.25,2.26
Message-ID: 

Update of /cvsroot/python/python/dist/src/Parser
In directory usw-pr-cvs1:/tmp/cvs-serv13674

Modified Files:
	pgenmain.c 
Log Message:
Add definition of Py_IgnoreEnvironmentFlag (needed at least in debug
mode).


Index: pgenmain.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Parser/pgenmain.c,v
retrieving revision 2.25
retrieving revision 2.26
diff -C2 -d -r2.25 -r2.26
*** pgenmain.c	14 Apr 2002 20:12:41 -0000	2.25
--- pgenmain.c	31 May 2002 14:32:07 -0000	2.26
***************
*** 23,26 ****
--- 23,27 ----
  int Py_DebugFlag;
  int Py_VerboseFlag;
+ int Py_IgnoreEnvironmentFlag;
  
  /* Forward */





From nnorwitz@users.sourceforge.net  Fri May 31 15:14:08 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Fri, 31 May 2002 07:14:08 -0700
Subject: [Python-checkins] python/dist/src/Lib robotparser.py,1.15,1.16
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv6156

Modified Files:
	robotparser.py 
Log Message:
Remove import of re, it is not used

Index: robotparser.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/robotparser.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** robotparser.py	29 May 2002 16:18:42 -0000	1.15
--- robotparser.py	31 May 2002 14:14:06 -0000	1.16
***************
*** 10,14 ****
      http://info.webcrawler.com/mak/projects/robots/norobots-rfc.html
  """
! import re,urlparse,urllib
  
  __all__ = ["RobotFileParser"]
--- 10,14 ----
      http://info.webcrawler.com/mak/projects/robots/norobots-rfc.html
  """
! import urlparse,urllib
  
  __all__ = ["RobotFileParser"]





From rhettinger@users.sourceforge.net  Fri May 31 18:49:13 2002
From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net)
Date: Fri, 31 May 2002 10:49:13 -0700
Subject: [Python-checkins] python/dist/src/Lib hmac.py,1.4,1.5 smtplib.py,1.53,1.54
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv25108

Modified Files:
	hmac.py smtplib.py 
Log Message:
Replace '==  None' with 'is None'

Index: hmac.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/hmac.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** hmac.py	13 Nov 2001 21:51:26 -0000	1.4
--- hmac.py	31 May 2002 17:49:10 -0000	1.5
***************
*** 28,32 ****
          digestmod: A module supporting PEP 247. Defaults to the md5 module.
          """
!         if digestmod == None:
              import md5
              digestmod = md5
--- 28,32 ----
          digestmod: A module supporting PEP 247. Defaults to the md5 module.
          """
!         if digestmod is None:
              import md5
              digestmod = md5

Index: smtplib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** smtplib.py	16 Apr 2002 01:38:39 -0000	1.53
--- smtplib.py	31 May 2002 17:49:10 -0000	1.54
***************
*** 550,554 ****
              (code, resp) = self.docmd("AUTH",
                  AUTH_PLAIN + " " + encode_plain(user, password))
!         elif authmethod == None:
              raise SMTPException("No suitable authentication method found.")
          if code not in [235, 503]:
--- 550,554 ----
              (code, resp) = self.docmd("AUTH",
                  AUTH_PLAIN + " " + encode_plain(user, password))
!         elif authmethod is None:
              raise SMTPException("No suitable authentication method found.")
          if code not in [235, 503]:





From fdrake@users.sourceforge.net  Fri May 31 19:21:58 2002
From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net)
Date: Fri, 31 May 2002 11:21:58 -0700
Subject: [Python-checkins] python/dist/src/Doc/lib tkinter.tex,1.11,1.12
Message-ID: 

Update of /cvsroot/python/python/dist/src/Doc/lib
In directory usw-pr-cvs1:/tmp/cvs-serv8656/lib

Modified Files:
	tkinter.tex 
Log Message:
Update links and information on PyQt/PyKDE.

Index: tkinter.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/tkinter.tex,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** tkinter.tex	5 Jan 2002 03:56:54 -0000	1.11
--- tkinter.tex	31 May 2002 18:21:56 -0000	1.12
***************
*** 1790,1799 ****
  specialized widgets, extensive documentation, and printing capabilities.
  }
! \seetitle[http://www.thekompany.com]{PyKDE}{
! PyKDE is a SIP wrapped interface to the Qt toolkit.
! The Qt \Cpp{} toolkit lies at the heart of the KDE desktop, and the
! Qt toolkit allows very tight integration with KDE, and also Windows
! portability. SIP is a tool for generating bindings for \Cpp{} libraries
! as Python classes, and is specifically designed for Python.
  }
  \seetitle[http://fxpy.sourceforge.net/]{FXPy}{
--- 1790,1806 ----
  specialized widgets, extensive documentation, and printing capabilities.
  }
! \seetitle[]{PyQt}{
! PyQt is a \program{sip}-wrapped binding to the Qt toolkit.  Qt is an
! extensive \Cpp{} GUI toolkit that is available for \UNIX, Windows and
! Mac OS X.  \program{sip} is a tool for generating bindings for \Cpp{}
! libraries as Python classes, and is specifically designed for Python.
! An online manual is available at
! \url{http://www.opendocspublishing.com/pyqt/} (errata are located at
! \url{http://www.valdyas.org/python/book.html}). 
! }
! \seetitle[http://www.riverbankcomputing.co.uk/pykde/index.php]{PyKDE}{
! PyKDE is a \program{sip}-wrapped interface to the KDE desktop
! libraries.  KDE is a desktop environment for \UNIX{} computers; the
! graphical components are based on Qt.
  }
  \seetitle[http://fxpy.sourceforge.net/]{FXPy}{





From fdrake@users.sourceforge.net  Fri May 31 19:22:16 2002
From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net)
Date: Fri, 31 May 2002 11:22:16 -0700
Subject: [Python-checkins] python/dist/src/Doc/lib tkinter.tex,1.10.6.1,1.10.6.2
Message-ID: 

Update of /cvsroot/python/python/dist/src/Doc/lib
In directory usw-pr-cvs1:/tmp/cvs-serv8820/lib

Modified Files:
      Tag: release22-maint
	tkinter.tex 
Log Message:
Update links and information on PyQt/PyKDE.

Index: tkinter.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/tkinter.tex,v
retrieving revision 1.10.6.1
retrieving revision 1.10.6.2
diff -C2 -d -r1.10.6.1 -r1.10.6.2
*** tkinter.tex	5 Jan 2002 03:57:19 -0000	1.10.6.1
--- tkinter.tex	31 May 2002 18:22:14 -0000	1.10.6.2
***************
*** 1790,1799 ****
  specialized widgets, extensive documentation, and printing capabilities.
  }
! \seetitle[http://www.thekompany.com]{PyKDE}{
! PyKDE is a SIP wrapped interface to the Qt toolkit.
! The Qt \Cpp{} toolkit lies at the heart of the KDE desktop, and the
! Qt toolkit allows very tight integration with KDE, and also Windows
! portability. SIP is a tool for generating bindings for \Cpp{} libraries
! as Python classes, and is specifically designed for Python.
  }
  \seetitle[http://fxpy.sourceforge.net/]{FXPy}{
--- 1790,1806 ----
  specialized widgets, extensive documentation, and printing capabilities.
  }
! \seetitle[]{PyQt}{
! PyQt is a \program{sip}-wrapped binding to the Qt toolkit.  Qt is an
! extensive \Cpp{} GUI toolkit that is available for \UNIX, Windows and
! Mac OS X.  \program{sip} is a tool for generating bindings for \Cpp{}
! libraries as Python classes, and is specifically designed for Python.
! An online manual is available at
! \url{http://www.opendocspublishing.com/pyqt/} (errata are located at
! \url{http://www.valdyas.org/python/book.html}). 
! }
! \seetitle[http://www.riverbankcomputing.co.uk/pykde/index.php]{PyKDE}{
! PyKDE is a \program{sip}-wrapped interface to the KDE desktop
! libraries.  KDE is a desktop environment for \UNIX{} computers; the
! graphical components are based on Qt.
  }
  \seetitle[http://fxpy.sourceforge.net/]{FXPy}{





From nnorwitz@users.sourceforge.net  Fri May 31 20:58:03 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Fri, 31 May 2002 12:58:03 -0700
Subject: [Python-checkins] python/dist/src/Misc NEWS,1.411,1.412
Message-ID: 

Update of /cvsroot/python/python/dist/src/Misc
In directory usw-pr-cvs1:/tmp/cvs-serv24025/Misc

Modified Files:
	NEWS 
Log Message:
Change name from string to basestring

Index: NEWS
===================================================================
RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v
retrieving revision 1.411
retrieving revision 1.412
diff -C2 -d -r1.411 -r1.412
*** NEWS	29 May 2002 15:54:54 -0000	1.411
--- NEWS	31 May 2002 19:58:00 -0000	1.412
***************
*** 13,20 ****
    as a command line option or warnings.filterwarnings() in code.
  
! - A new type object, 'string', is added.  This is a common base type
    for 'str' and 'unicode', and can be used instead of
    types.StringTypes, e.g. to test whether something is "a string":
!   isinstance(x, string) is True for Unicode and 8-bit strings.  This
    is an abstract base class and cannot be instantiated directly.
  
--- 13,20 ----
    as a command line option or warnings.filterwarnings() in code.
  
! - A new type object, 'basestring', is added.  This is a common base type
    for 'str' and 'unicode', and can be used instead of
    types.StringTypes, e.g. to test whether something is "a string":
!   isinstance(x, basestring) is True for Unicode and 8-bit strings.  This
    is an abstract base class and cannot be instantiated directly.
  





From nnorwitz@users.sourceforge.net  Fri May 31 20:58:04 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Fri, 31 May 2002 12:58:04 -0700
Subject: [Python-checkins] python/dist/src/Objects stringobject.c,2.164,2.165
Message-ID: 

Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv24025/Objects

Modified Files:
	stringobject.c 
Log Message:
Change name from string to basestring

Index: stringobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.164
retrieving revision 2.165
diff -C2 -d -r2.164 -r2.165
*** stringobject.c	24 May 2002 19:01:58 -0000	2.164
--- stringobject.c	31 May 2002 19:58:01 -0000	2.165
***************
*** 2860,2874 ****
  {
  	PyErr_SetString(PyExc_TypeError,
! 			"The string type cannot be instantiated");
  	return NULL;
  }
  
  static char basestring_doc[] =
! "Type string cannot be instantiated; it is the base for str and unicode.";
  
  PyTypeObject PyBaseString_Type = {
  	PyObject_HEAD_INIT(&PyType_Type)
  	0,
! 	"string",
  	0,
  	0,
--- 2860,2874 ----
  {
  	PyErr_SetString(PyExc_TypeError,
! 			"The basestring type cannot be instantiated");
  	return NULL;
  }
  
  static char basestring_doc[] =
! "Type basestring cannot be instantiated; it is the base for str and unicode.";
  
  PyTypeObject PyBaseString_Type = {
  	PyObject_HEAD_INIT(&PyType_Type)
  	0,
! 	"basestring",
  	0,
  	0,





From nnorwitz@users.sourceforge.net  Fri May 31 20:58:04 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Fri, 31 May 2002 12:58:04 -0700
Subject: [Python-checkins] python/dist/src/Python bltinmodule.c,2.256,2.257
Message-ID: 

Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv24025/Python

Modified Files:
	bltinmodule.c 
Log Message:
Change name from string to basestring

Index: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.256
retrieving revision 2.257
diff -C2 -d -r2.256 -r2.257
*** bltinmodule.c	24 May 2002 19:01:59 -0000	2.256
--- bltinmodule.c	31 May 2002 19:58:02 -0000	2.257
***************
*** 1891,1894 ****
--- 1891,1895 ----
  	SETBUILTIN("False",		Py_False);
  	SETBUILTIN("True",		Py_True);
+ 	SETBUILTIN("basestring",	&PyBaseString_Type);
  	SETBUILTIN("bool",		&PyBool_Type);
  	SETBUILTIN("classmethod",	&PyClassMethod_Type);
***************
*** 1906,1910 ****
  	SETBUILTIN("staticmethod",	&PyStaticMethod_Type);
  	SETBUILTIN("str",		&PyString_Type);
- 	SETBUILTIN("string",		&PyBaseString_Type);
  	SETBUILTIN("super",		&PySuper_Type);
  	SETBUILTIN("tuple",		&PyTuple_Type);
--- 1907,1910 ----





From gvanrossum@users.sourceforge.net  Fri May 31 21:03:56 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Fri, 31 May 2002 13:03:56 -0700
Subject: [Python-checkins] python/dist/src/Objects object.c,2.175,2.176
Message-ID: 

Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv27720

Modified Files:
	object.c 
Log Message:
Implement the intention of SF patch 472523 (but coded differently).

In the past, an object's tp_compare could return any value.  In 2.2
the docs were tightened to require it to return -1, 0 or 1; and -1 for
an error.

We now issue a warning if the value is not in this range.  When an
exception is raised, we allow -1 or -2 as return value, since -2 will
the recommended return value for errors in the future.  (Eventually
tp_compare will also be allowed to return +2, to indicate
NotImplemented; but that can only be implemented once we know all
extensions return a value in [-2...1].  Or perhaps it will require the
type to set a flag bit.)

I haven't decided yet whether to backport this to 2.2.x.  The patch
applies fine.  But is it fair to start warning in 2.2.2 about code
that worked flawlessly in 2.2.1?


Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.175
retrieving revision 2.176
diff -C2 -d -r2.175 -r2.176
*** object.c	24 May 2002 19:01:58 -0000	2.175
--- object.c	31 May 2002 20:03:54 -0000	2.176
***************
*** 354,357 ****
--- 354,397 ----
  
  
+ /* Helper to warn about deprecated tp_compare return values.  Return:
+    -2 for an exception;
+    -1 if v <  w;
+     0 if v == w;
+     1 if v  > w.
+    (This function cannot return 2.)
+ */
+ static int
+ adjust_tp_compare(int c)
+ {
+ 	if (PyErr_Occurred()) {
+ 		if (c != -1 && c != -2) {
+ 			PyObject *t, *v, *tb;
+ 			PyErr_Fetch(&t, &v, &tb);
+ 			if (PyErr_Warn(PyExc_RuntimeWarning,
+ 				       "tp_compare didn't return -1 or -2 "
+ 				       "for exception") < 0) {
+ 				Py_XDECREF(t);
+ 				Py_XDECREF(v);
+ 				Py_XDECREF(tb);
+ 			}
+ 			else
+ 				PyErr_Restore(t, v, tb);
+ 		}
+ 		return -2;
+ 	}
+ 	else if (c < -1 || c > 1) {
+ 		if (PyErr_Warn(PyExc_RuntimeWarning,
+ 			       "tp_compare didn't return -1, 0 or 1") < 0)
+ 			return -2;
+ 		else
+ 			return c < -1 ? -1 : 1;
+ 	}
+ 	else {
+ 		assert(c >= -1 && c <= 1);
+ 		return c;
+ 	}
+ }
+ 
+ 
  /* Macro to get the tp_richcompare field of a type if defined */
  #define RICHCOMPARE(t) (PyType_HasFeature((t), Py_TPFLAGS_HAVE_RICHCOMPARE) \
***************
*** 481,487 ****
  	if (f != NULL && f == w->ob_type->tp_compare) {
  		c = (*f)(v, w);
! 		if (c < 0 && PyErr_Occurred())
! 			return -1;
! 		return c < 0 ? -1 : c > 0 ? 1 : 0;
  	}
  
--- 521,525 ----
  	if (f != NULL && f == w->ob_type->tp_compare) {
  		c = (*f)(v, w);
! 		return adjust_tp_compare(c);
  	}
  
***************
*** 503,509 ****
  		Py_DECREF(v);
  		Py_DECREF(w);
! 		if (c < 0 && PyErr_Occurred())
! 			return -2;
! 		return c < 0 ? -1 : c > 0 ? 1 : 0;
  	}
  
--- 541,545 ----
  		Py_DECREF(v);
  		Py_DECREF(w);
! 		return adjust_tp_compare(c);
  	}
  
***************
*** 513,519 ****
  		Py_DECREF(v);
  		Py_DECREF(w);
! 		if (c < 0 && PyErr_Occurred())
! 			return -2;
! 		return c < 0 ? 1 : c > 0 ? -1 : 0; /* negated! */
  	}
  
--- 549,557 ----
  		Py_DECREF(v);
  		Py_DECREF(w);
! 		c = adjust_tp_compare(c);
! 		if (c >= -1)
! 			return -c; /* Swapped! */
! 		else
! 			return c;
  	}
  
***************
*** 592,600 ****
  
  /* Do a 3-way comparison, by hook or by crook.  Return:
!    -2 for an exception;
     -1 if v <  w;
      0 if v == w;
      1 if v >  w;
!    If the object implements a tp_compare function, it returns
     whatever this function returns (whether with an exception or not).
  */
--- 630,638 ----
  
  /* Do a 3-way comparison, by hook or by crook.  Return:
!    -2 for an exception (but see below);
     -1 if v <  w;
      0 if v == w;
      1 if v >  w;
!    BUT: if the object implements a tp_compare function, it returns
     whatever this function returns (whether with an exception or not).
  */
***************
*** 608,614 ****
  	    && (f = v->ob_type->tp_compare) != NULL) {
  		c = (*f)(v, w);
! 		if (c != 2 || !PyInstance_Check(v))
! 			return c;
  	}
  	c = try_rich_to_3way_compare(v, w);
  	if (c < 2)
--- 646,665 ----
  	    && (f = v->ob_type->tp_compare) != NULL) {
  		c = (*f)(v, w);
! 		if (PyInstance_Check(v)) {
! 			/* Instance tp_compare has a different signature.
! 			   But if it returns undefined we fall through. */
! 			if (c != 2)
! 				return c;
! 			/* Else fall throug to try_rich_to_3way_compare() */
! 		}
! 		else
! 			return adjust_tp_compare(c);
  	}
+ 	/* We only get here if one of the following is true:
+ 	   a) v and w have different types
+ 	   b) v and w have the same type, which doesn't have tp_compare
+ 	   c) v and w are instances, and either __cmp__ is not defined or
+ 	      __cmp__ returns NotImplemented
+ 	*/
  	c = try_rich_to_3way_compare(v, w);
  	if (c < 2)
***************
*** 903,907 ****
  		if (fcmp != NULL) {
  			int c = (*fcmp)(v, w);
! 			if (c < 0 && PyErr_Occurred()) {
  				res = NULL;
  				goto Done;
--- 954,959 ----
  		if (fcmp != NULL) {
  			int c = (*fcmp)(v, w);
! 			c = adjust_tp_compare(c);
! 			if (c == -2) {
  				res = NULL;
  				goto Done;





From nnorwitz@users.sourceforge.net  Fri May 31 21:23:36 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Fri, 31 May 2002 13:23:36 -0700
Subject: [Python-checkins] python/dist/src/Objects object.c,2.176,2.177
Message-ID: 

Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv5987

Modified Files:
	object.c 
Log Message:
Fix typo

Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.176
retrieving revision 2.177
diff -C2 -d -r2.176 -r2.177
*** object.c	31 May 2002 20:03:54 -0000	2.176
--- object.c	31 May 2002 20:23:33 -0000	2.177
***************
*** 651,655 ****
  			if (c != 2)
  				return c;
! 			/* Else fall throug to try_rich_to_3way_compare() */
  		}
  		else
--- 651,655 ----
  			if (c != 2)
  				return c;
! 			/* Else fall through to try_rich_to_3way_compare() */
  		}
  		else





From nnorwitz@users.sourceforge.net  Fri May 31 21:46:41 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Fri, 31 May 2002 13:46:41 -0700
Subject: [Python-checkins] python/dist/src/Lib/xml/dom minidom.py,1.45,1.46
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib/xml/dom
In directory usw-pr-cvs1:/tmp/cvs-serv17727/dom

Modified Files:
	minidom.py 
Log Message:
Use more string methods, remove import string

Index: minidom.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/minidom.py,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** minidom.py	15 Mar 2002 14:37:23 -0000	1.45
--- minidom.py	31 May 2002 20:46:38 -0000	1.46
***************
*** 15,22 ****
  """
  
- import string
- _string = string
- del string
- 
  from xml.dom import HierarchyRequestErr, EMPTY_NAMESPACE
  
--- 15,18 ----
***************
*** 285,293 ****
  def _write_data(writer, data):
      "Writes datachars to writer."
!     replace = _string.replace
!     data = replace(data, "&", "&")
!     data = replace(data, "<", "<")
!     data = replace(data, "\"", """)
!     data = replace(data, ">", ">")
      writer.write(data)
  
--- 281,288 ----
  def _write_data(writer, data):
      "Writes datachars to writer."
!     data = data.replace("&", "&")
!     data = data.replace("<", "<")
!     data = data.replace("\"", """)
!     data = data.replace(">", ">")
      writer.write(data)
  
***************
*** 759,763 ****
  
  def _nssplit(qualifiedName):
!     fields = _string.split(qualifiedName, ':', 1)
      if len(fields) == 2:
          return fields
--- 754,758 ----
  
  def _nssplit(qualifiedName):
!     fields = qualifiedName.split(':', 1)
      if len(fields) == 2:
          return fields
***************
*** 788,792 ****
          if version not in ("1.0", "2.0"):
              return 0
!         feature = _string.lower(feature)
          return feature == "core"
  
--- 783,787 ----
          if version not in ("1.0", "2.0"):
              return 0
!         feature = feature.lower()
          return feature == "core"
  





From nnorwitz@users.sourceforge.net  Fri May 31 21:46:41 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Fri, 31 May 2002 13:46:41 -0700
Subject: [Python-checkins] python/dist/src/Lib/xml/sax __init__.py,1.15,1.16 expatreader.py,1.27,1.28
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib/xml/sax
In directory usw-pr-cvs1:/tmp/cvs-serv17727/sax

Modified Files:
	__init__.py expatreader.py 
Log Message:
Use more string methods, remove import string

Index: __init__.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/xml/sax/__init__.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** __init__.py	31 Jul 2001 08:54:55 -0000	1.15
--- __init__.py	31 May 2002 20:46:39 -0000	1.16
***************
*** 59,70 ****
      import xml.sax.expatreader
  
! import os, string, sys
  if os.environ.has_key("PY_SAX_PARSER"):
!     default_parser_list = string.split(os.environ["PY_SAX_PARSER"], ",")
  del os
  
  _key = "python.xml.sax.parser"
  if sys.platform[:4] == "java" and sys.registry.containsKey(_key):
!     default_parser_list = string.split(sys.registry.getProperty(_key), ",")
  
  
--- 59,70 ----
      import xml.sax.expatreader
  
! import os, sys
  if os.environ.has_key("PY_SAX_PARSER"):
!     default_parser_list = os.environ["PY_SAX_PARSER"].split(",")
  del os
  
  _key = "python.xml.sax.parser"
  if sys.platform[:4] == "java" and sys.registry.containsKey(_key):
!     default_parser_list = sys.registry.getProperty(_key).split(",")
  
  

Index: expatreader.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/xml/sax/expatreader.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** expatreader.py	4 Apr 2002 19:12:31 -0000	1.27
--- expatreader.py	31 May 2002 20:46:39 -0000	1.28
***************
*** 26,30 ****
  AttributesNSImpl = xmlreader.AttributesNSImpl
  
- import string
  import weakref
  
--- 26,29 ----
***************
*** 221,225 ****
  
      def start_element_ns(self, name, attrs):
!         pair = string.split(name)
          if len(pair) == 1:
              pair = (None, name)
--- 220,224 ----
  
      def start_element_ns(self, name, attrs):
!         pair = name.split()
          if len(pair) == 1:
              pair = (None, name)
***************
*** 229,233 ****
          newattrs = {}
          for (aname, value) in attrs.items():
!             apair = string.split(aname)
              if len(apair) == 1:
                  apair = (None, aname)
--- 228,232 ----
          newattrs = {}
          for (aname, value) in attrs.items():
!             apair = aname.split()
              if len(apair) == 1:
                  apair = (None, aname)
***************
*** 241,245 ****
  
      def end_element_ns(self, name):
!         pair = string.split(name)
          if len(pair) == 1:
              pair = (None, name)
--- 240,244 ----
  
      def end_element_ns(self, name):
!         pair = name.split()
          if len(pair) == 1:
              pair = (None, name)





From nnorwitz@users.sourceforge.net  Fri May 31 21:51:33 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Fri, 31 May 2002 13:51:33 -0700
Subject: [Python-checkins] python/dist/src/Lib/lib-tk Tix.py,1.9,1.10
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib/lib-tk
In directory usw-pr-cvs1:/tmp/cvs-serv19881/lib-tk

Modified Files:
	Tix.py 
Log Message:
Use string methods, remove import string

Index: Tix.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tix.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Tix.py	28 Mar 2002 16:26:40 -0000	1.9
--- Tix.py	31 May 2002 20:51:31 -0000	1.10
***************
*** 27,31 ****
  #
  
- import string
  from Tkinter import *
  from Tkinter import _flatten, _cnfmerge, _default_root
--- 27,30 ----
***************
*** 36,40 ****
  
  import _tkinter # If this fails your Python may not be configured for Tk
! # TixVersion = string.atof(tkinter.TIX_VERSION) # If this fails your Python may not be configured for Tix
  # WARNING - TixVersion is a limited precision floating point number
  
--- 35,39 ----
  
  import _tkinter # If this fails your Python may not be configured for Tk
! # TixVersion = float(tkinter.TIX_VERSION) # If this fails your Python may not be configured for Tix
  # WARNING - TixVersion is a limited precision floating point number
  
***************
*** 392,396 ****
              try:
                  path = path[len(master._w)+1:]
!                 plist = string.splitfields(path, '.')
              except:
                  plist = []
--- 391,395 ----
              try:
                  path = path[len(master._w)+1:]
!                 plist = path.split('.')
              except:
                  plist = []
***************
*** 403,407 ****
              parent = master
              for i in range(len(plist) - 1):
!                 n = string.joinfields(plist[:i+1], '.')
                  try:
                      w = master._nametowidget(n)
--- 402,406 ----
              parent = master
              for i in range(len(plist) - 1):
!                 n = '.'.join(plist[:i+1])
                  try:
                      w = master._nametowidget(n)





From fdrake@acm.org  Fri May 31 21:56:36 2002
From: fdrake@acm.org (Fred L. Drake, Jr.)
Date: Fri, 31 May 2002 16:56:36 -0400
Subject: [Python-checkins] python/dist/src/Lib/xml/dom minidom.py,1.45,1.46
In-Reply-To: 
References: 
Message-ID: <15607.58244.442717.525000@grendel.zope.com>

nnorwitz@users.sourceforge.net writes:
 > Modified Files:
 > 	minidom.py 
 > Log Message:
 > Use more string methods, remove import string

Are you planning to check this into PyXML, or would you like me to
take care of that?


  -Fred

-- 
Fred L. Drake, Jr.  
PythonLabs at Zope Corporation



From gvanrossum@users.sourceforge.net  Fri May 31 22:00:20 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Fri, 31 May 2002 14:00:20 -0700
Subject: [Python-checkins] python/dist/src/Doc/api newtypes.tex,1.12,1.13
Message-ID: 

Update of /cvsroot/python/python/dist/src/Doc/api
In directory usw-pr-cvs1:/tmp/cvs-serv24520

Modified Files:
	newtypes.tex 
Log Message:
Explain that tp_basicsize must provide alignment for the items.


Index: newtypes.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/api/newtypes.tex,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** newtypes.tex	24 Apr 2002 06:35:11 -0000	1.12
--- newtypes.tex	31 May 2002 21:00:18 -0000	1.13
***************
*** 466,469 ****
--- 466,477 ----
    \member{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
+   \member{tp_basicsize}.  Example: suppose a type implements an array
+   of \code{double}. \member{tp_itemsize} is \code{sizeof(double)}.
+   It is the programmer's responsibility that \member{tp_basicsize} is
+   a multiple of \code{sizeof(double)} (assuming this is the alignment
+   requirement for \code{double}).
  \end{cmemberdesc}
  





From neal@metaslash.com  Fri May 31 22:00:47 2002
From: neal@metaslash.com (Neal Norwitz)
Date: Fri, 31 May 2002 17:00:47 -0400
Subject: [Python-checkins] python/dist/src/Lib/xml/dom minidom.py,1.45,1.46
References:  <15607.58244.442717.525000@grendel.zope.com>
Message-ID: <3CF7E47F.5D61B8A2@metaslash.com>

"Fred L. Drake, Jr." wrote:
> 
> nnorwitz@users.sourceforge.net writes:
>  > Modified Files:
>  >      minidom.py
>  > Log Message:
>  > Use more string methods, remove import string
> 
> Are you planning to check this into PyXML, or would you like me to
> take care of that?

Could you please do it?  I'm not a developer on PyXML.
Sorry, I wasn't sure if it was still maintained in a separate CVS.

Are PyXML and distutils the only modules maintained separately?
What about email and compiler?

Neal



From barry@zope.com  Fri May 31 22:08:23 2002
From: barry@zope.com (Barry A. Warsaw)
Date: Fri, 31 May 2002 17:08:23 -0400
Subject: [Python-checkins] python/dist/src/Lib/xml/dom minidom.py,1.45,1.46
References: 
 <15607.58244.442717.525000@grendel.zope.com>
 <3CF7E47F.5D61B8A2@metaslash.com>
Message-ID: <15607.58951.712222.969713@anthem.wooz.org>

>>>>> "NN" == Neal Norwitz  writes:

    NN> Are PyXML and distutils the only modules maintained
    NN> separately?  What about email and compiler?

I'm maintaining the email package and I'm trying to keep Python 2.1
compatibility.  It should be using string methods, but it still needs
to use the types module.

-Barry



From gvanrossum@users.sourceforge.net  Fri May 31 22:12:19 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Fri, 31 May 2002 14:12:19 -0700
Subject: [Python-checkins] python/dist/src/Lib rexec.py,1.36,1.37
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv30332

Modified Files:
	rexec.py 
Log Message:
SF bug 533625 (Armin Rigo). rexec: potential security hole

If a rexec instance allows writing in the current directory (a common
thing to do), there's a way to execute bogus bytecode.  Fix this by
not allowing imports from .pyc files (in a way that allows a site to
configure things so that .pyc files *are* allowed, if writing is not
allowed).

I'll apply this to 2.2 and 2.1 too.


Index: rexec.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/rexec.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** rexec.py	30 May 2002 00:06:01 -0000	1.36
--- rexec.py	31 May 2002 21:12:17 -0000	1.37
***************
*** 23,26 ****
--- 23,27 ----
  import os
  import ihooks
+ import imp
  
  __all__ = ["RExec"]
***************
*** 84,87 ****
--- 85,91 ----
          self.rexec = rexec
  
+     def get_suffixes(self):
+         return self.rexec.get_suffixes()
+ 
      def is_builtin(self, name):
          return self.rexec.is_builtin(name)
***************
*** 145,148 ****
--- 149,154 ----
      nok_builtin_names = ('open', 'file', 'reload', '__import__')
  
+     ok_file_types = (imp.C_EXTENSION, imp.PY_SOURCE)
+ 
      def __init__(self, hooks = None, verbose = 0):
          """Returns an instance of the RExec class.
***************
*** 204,208 ****
              src = sys.modules[name]
          else:
-             import imp
              src = imp.load_dynamic(name, filename, file)
          dst = self.copy_except(src, [])
--- 210,213 ----
***************
*** 214,217 ****
--- 219,227 ----
  
      # Helpers for RHooks
+ 
+     def get_suffixes(self):
+         return [item   # (suff, mode, type)
+                 for item in imp.get_suffixes()
+                 if item[2] in self.ok_file_types]
  
      def is_builtin(self, mname):





From gvanrossum@users.sourceforge.net  Fri May 31 22:12:55 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Fri, 31 May 2002 14:12:55 -0700
Subject: [Python-checkins] python/dist/src/Doc/lib librexec.tex,1.18,1.19
Message-ID: 

Update of /cvsroot/python/python/dist/src/Doc/lib
In directory usw-pr-cvs1:/tmp/cvs-serv30616

Modified Files:
	librexec.tex 
Log Message:
SF bug 533625 (Armin Rigo). rexec: potential security hole

If a rexec instance allows writing in the current directory (a common
thing to do), there's a way to execute bogus bytecode.  Fix this by
not allowing imports from .pyc files (in a way that allows a site to
configure things so that .pyc files *are* allowed, if writing is not
allowed).

I'll apply this to 2.2 and 2.1 too.


Index: librexec.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/librexec.tex,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** librexec.tex	20 Oct 2001 04:24:09 -0000	1.18
--- librexec.tex	31 May 2002 21:12:53 -0000	1.19
***************
*** 212,215 ****
--- 212,227 ----
  \end{memberdesc}
  
+ \begin{memberdesc}{ok_file_types}
+ Contains the file types from which modules are allowed to be loaded.
+ Each file type is an integer constant defined in the \refmodule{imp} module.
+ The meaningful values are \constant{PY_SOURCE}, \constant{PY_COMPILED}, and
+ \constant{C_EXTENSION}.  The value for \class{RExec} is \code{(C_EXTENSION,
+ PY_SOURCE)}.  Adding \constant{PY_COMPILED} in subclasses is not recommended;
+ an attacker could exit the restricted execution mode by putting a forged
+ byte-compiled file (\file{.pyc}) anywhere in your file system, for example
+ by writing it to \file{/tmp} or uploading it to the \file{/incoming}
+ directory of your public FTP server.
+ \end{memberdesc}
+ 
  
  \subsection{An example}





From gvanrossum@users.sourceforge.net  Fri May 31 22:17:55 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Fri, 31 May 2002 14:17:55 -0700
Subject: [Python-checkins] python/dist/src/Lib rexec.py,1.34.10.1,1.34.10.2
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv699/Lib

Modified Files:
      Tag: release22-maint
	rexec.py 
Log Message:
Backport to 2.2.x:

SF bug 533625 (Armin Rigo). rexec: potential security hole

If a rexec instance allows writing in the current directory (a common
thing to do), there's a way to execute bogus bytecode.  Fix this by
not allowing imports from .pyc files (in a way that allows a site to
configure things so that .pyc files *are* allowed, if writing is not
allowed).


Index: rexec.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/rexec.py,v
retrieving revision 1.34.10.1
retrieving revision 1.34.10.2
diff -C2 -d -r1.34.10.1 -r1.34.10.2
*** rexec.py	29 May 2002 23:44:50 -0000	1.34.10.1
--- rexec.py	31 May 2002 21:17:53 -0000	1.34.10.2
***************
*** 23,26 ****
--- 23,27 ----
  import os
  import ihooks
+ import imp
  
  __all__ = ["RExec"]
***************
*** 84,87 ****
--- 85,91 ----
          self.rexec = rexec
  
+     def get_suffixes(self):
+         return self.rexec.get_suffixes()
+ 
      def is_builtin(self, name):
          return self.rexec.is_builtin(name)
***************
*** 145,148 ****
--- 149,154 ----
      nok_builtin_names = ('open', 'file', 'reload', '__import__')
  
+     ok_file_types = (imp.C_EXTENSION, imp.PY_SOURCE)
+ 
      def __init__(self, hooks = None, verbose = 0):
          """Returns an instance of the RExec class.
***************
*** 204,208 ****
              src = sys.modules[name]
          else:
-             import imp
              src = imp.load_dynamic(name, filename, file)
          dst = self.copy_except(src, [])
--- 210,213 ----
***************
*** 214,217 ****
--- 219,227 ----
  
      # Helpers for RHooks
+ 
+     def get_suffixes(self):
+         return [item   # (suff, mode, type)
+                 for item in imp.get_suffixes()
+                 if item[2] in self.ok_file_types]
  
      def is_builtin(self, mname):





From gvanrossum@users.sourceforge.net  Fri May 31 22:17:55 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Fri, 31 May 2002 14:17:55 -0700
Subject: [Python-checkins] python/dist/src/Doc/lib librexec.tex,1.18,1.18.8.1
Message-ID: 

Update of /cvsroot/python/python/dist/src/Doc/lib
In directory usw-pr-cvs1:/tmp/cvs-serv699/Doc/lib

Modified Files:
      Tag: release22-maint
	librexec.tex 
Log Message:
Backport to 2.2.x:

SF bug 533625 (Armin Rigo). rexec: potential security hole

If a rexec instance allows writing in the current directory (a common
thing to do), there's a way to execute bogus bytecode.  Fix this by
not allowing imports from .pyc files (in a way that allows a site to
configure things so that .pyc files *are* allowed, if writing is not
allowed).


Index: librexec.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/librexec.tex,v
retrieving revision 1.18
retrieving revision 1.18.8.1
diff -C2 -d -r1.18 -r1.18.8.1
*** librexec.tex	20 Oct 2001 04:24:09 -0000	1.18
--- librexec.tex	31 May 2002 21:17:53 -0000	1.18.8.1
***************
*** 212,215 ****
--- 212,227 ----
  \end{memberdesc}
  
+ \begin{memberdesc}{ok_file_types}
+ Contains the file types from which modules are allowed to be loaded.
+ Each file type is an integer constant defined in the \refmodule{imp} module.
+ The meaningful values are \constant{PY_SOURCE}, \constant{PY_COMPILED}, and
+ \constant{C_EXTENSION}.  The value for \class{RExec} is \code{(C_EXTENSION,
+ PY_SOURCE)}.  Adding \constant{PY_COMPILED} in subclasses is not recommended;
+ an attacker could exit the restricted execution mode by putting a forged
+ byte-compiled file (\file{.pyc}) anywhere in your file system, for example
+ by writing it to \file{/tmp} or uploading it to the \file{/incoming}
+ directory of your public FTP server.
+ \end{memberdesc}
+ 
  
  \subsection{An example}





From gvanrossum@users.sourceforge.net  Fri May 31 22:19:55 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Fri, 31 May 2002 14:19:55 -0700
Subject: [Python-checkins] python/dist/src/Doc/lib librexec.tex,1.14.12.1,1.14.12.2
Message-ID: 

Update of /cvsroot/python/python/dist/src/Doc/lib
In directory usw-pr-cvs1:/tmp/cvs-serv1688/Doc/lib

Modified Files:
      Tag: release21-maint
	librexec.tex 
Log Message:
Backport to 2.1.x:

SF bug 533625 (Armin Rigo). rexec: potential security hole

If a rexec instance allows writing in the current directory (a common
thing to do), there's a way to execute bogus bytecode.  Fix this by
not allowing imports from .pyc files (in a way that allows a site to
configure things so that .pyc files *are* allowed, if writing is not
allowed).


Index: librexec.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/librexec.tex,v
retrieving revision 1.14.12.1
retrieving revision 1.14.12.2
diff -C2 -d -r1.14.12.1 -r1.14.12.2
*** librexec.tex	22 Jun 2001 18:22:10 -0000	1.14.12.1
--- librexec.tex	31 May 2002 21:19:53 -0000	1.14.12.2
***************
*** 211,214 ****
--- 211,226 ----
  \end{memberdesc}
  
+ \begin{memberdesc}{ok_file_types}
+ Contains the file types from which modules are allowed to be loaded.
+ Each file type is an integer constant defined in the \refmodule{imp} module.
+ The meaningful values are \constant{PY_SOURCE}, \constant{PY_COMPILED}, and
+ \constant{C_EXTENSION}.  The value for \class{RExec} is \code{(C_EXTENSION,
+ PY_SOURCE)}.  Adding \constant{PY_COMPILED} in subclasses is not recommended;
+ an attacker could exit the restricted execution mode by putting a forged
+ byte-compiled file (\file{.pyc}) anywhere in your file system, for example
+ by writing it to \file{/tmp} or uploading it to the \file{/incoming}
+ directory of your public FTP server.
+ \end{memberdesc}
+ 
  
  \subsection{An example}





From gvanrossum@users.sourceforge.net  Fri May 31 22:19:55 2002
From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net)
Date: Fri, 31 May 2002 14:19:55 -0700
Subject: [Python-checkins] python/dist/src/Lib rexec.py,1.28.4.1,1.28.4.2
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv1688/Lib

Modified Files:
      Tag: release21-maint
	rexec.py 
Log Message:
Backport to 2.1.x:

SF bug 533625 (Armin Rigo). rexec: potential security hole

If a rexec instance allows writing in the current directory (a common
thing to do), there's a way to execute bogus bytecode.  Fix this by
not allowing imports from .pyc files (in a way that allows a site to
configure things so that .pyc files *are* allowed, if writing is not
allowed).


Index: rexec.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/rexec.py,v
retrieving revision 1.28.4.1
retrieving revision 1.28.4.2
diff -C2 -d -r1.28.4.1 -r1.28.4.2
*** rexec.py	18 Jun 2001 12:34:31 -0000	1.28.4.1
--- rexec.py	31 May 2002 21:19:53 -0000	1.28.4.2
***************
*** 23,26 ****
--- 23,27 ----
  import os
  import ihooks
+ import imp
  
  __all__ = ["RExec"]
***************
*** 84,87 ****
--- 85,91 ----
          self.rexec = rexec
  
+     def get_suffixes(self):
+         return self.rexec.get_suffixes()
+ 
      def is_builtin(self, name):
          return self.rexec.is_builtin(name)
***************
*** 135,138 ****
--- 139,144 ----
      nok_builtin_names = ('open', 'reload', '__import__')
  
+     ok_file_types = (imp.C_EXTENSION, imp.PY_SOURCE)
+ 
      def __init__(self, hooks = None, verbose = 0):
          ihooks._Verbose.__init__(self, verbose)
***************
*** 170,174 ****
              src = sys.modules[name]
          else:
-             import imp
              src = imp.load_dynamic(name, filename, file)
          dst = self.copy_except(src, [])
--- 176,179 ----
***************
*** 180,183 ****
--- 185,193 ----
  
      # Helpers for RHooks
+ 
+     def get_suffixes(self):
+         return [item   # (suff, mode, type)
+                 for item in imp.get_suffixes()
+                 if item[2] in self.ok_file_types]
  
      def is_builtin(self, mname):





From rhettinger@users.sourceforge.net  Fri May 31 22:37:05 2002
From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net)
Date: Fri, 31 May 2002 14:37:05 -0700
Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.106,2.107 iterobject.c,1.9,1.10
Message-ID: 

Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv8943

Modified Files:
	listobject.c iterobject.c 
Log Message:
SF 560736.  Optimize list iteration by filling the tp_iter slot.


Index: listobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v
retrieving revision 2.106
retrieving revision 2.107
diff -C2 -d -r2.106 -r2.107
*** listobject.c	22 May 2002 23:19:16 -0000	2.106
--- listobject.c	31 May 2002 21:37:01 -0000	2.107
***************
*** 1683,1686 ****
--- 1683,1688 ----
  "list(sequence) -> new list initialized from sequence's items";
  
+ staticforward PyObject * list_iter(PyObject *seq);
+ 
  PyTypeObject PyList_Type = {
  	PyObject_HEAD_INIT(&PyType_Type)
***************
*** 1711,1715 ****
  	list_richcompare,			/* tp_richcompare */
  	0,					/* tp_weaklistoffset */
! 	0,					/* tp_iter */
  	0,					/* tp_iternext */
  	list_methods,				/* tp_methods */
--- 1713,1717 ----
  	list_richcompare,			/* tp_richcompare */
  	0,					/* tp_weaklistoffset */
! 	list_iter,				/* tp_iter */
  	0,					/* tp_iternext */
  	list_methods,				/* tp_methods */
***************
*** 1812,1813 ****
--- 1814,1930 ----
  	/* NOTE: This is *not* the standard list_type struct! */
  };
+ 
+ 
+ /*********************** List Iterator **************************/
+ 
+ typedef struct {
+         PyObject_HEAD
+         long      it_index;
+         PyObject *it_seq;
+ } listiterobject;
+ 
+ PyTypeObject PyListIter_Type;
+ 
+ PyObject *
+ list_iter(PyObject *seq)
+ {
+         listiterobject *it;
+ 
+         if (!PyList_Check(seq)) {
+                 PyErr_BadInternalCall();
+                 return NULL;
+         }
+         it = PyObject_GC_New(listiterobject, &PyListIter_Type);
+         if (it == NULL)
+                 return NULL;
+         it->it_index = 0;
+         Py_INCREF(seq);
+         it->it_seq = seq;
+         _PyObject_GC_TRACK(it);
+         return (PyObject *)it;
+ }
+ 
+ static void
+ listiter_dealloc(listiterobject *it)
+ {
+         _PyObject_GC_UNTRACK(it);
+         Py_DECREF(it->it_seq);
+         PyObject_GC_Del(it);
+ }
+ 
+ static int
+ listiter_traverse(listiterobject *it, visitproc visit, void *arg)
+ {
+         return visit(it->it_seq, arg);
+ }
+ 
+ 
+ static PyObject *
+ listiter_getiter(PyObject *it)
+ {
+         Py_INCREF(it);
+         return it;
+ }
+ 
+ static PyObject *
+ listiter_next(PyObject *it)
+ {
+         PyObject *seq;
+         PyObject *item;
+ 
+         assert(PyList_Check(it));
+         seq = ((listiterobject *)it)->it_seq;
+ 
+         if (((listiterobject *)it)->it_index < PyList_GET_SIZE(seq)) {
+ 		item = ((PyListObject *)(seq))->ob_item[((listiterobject *)it)->it_index++];
+                 Py_INCREF(item);
+                 return item;
+         }
+         return NULL;
+ }
+ 
+ static PyMethodDef listiter_methods[] = {
+         {"next",        (PyCFunction)listiter_next,     METH_NOARGS,
+          "it.next() -- get the next value, or raise StopIteration"},
+         {NULL,          NULL}           /* sentinel */
+ };
+ 
+ PyTypeObject PyListIter_Type = {
+         PyObject_HEAD_INIT(&PyType_Type)
+         0,                                      /* ob_size */
+         "listiterator",                         /* tp_name */
+         sizeof(listiterobject),                 /* tp_basicsize */
+         0,                                      /* tp_itemsize */
+         /* methods */
+         (destructor)listiter_dealloc,           /* tp_dealloc */
+         0,                                      /* tp_print */
+         0,                                      /* tp_getattr */
+         0,                                      /* tp_setattr */
+         0,                                      /* tp_compare */
+         0,                                      /* tp_repr */
+         0,                                      /* tp_as_number */
+         0,                                      /* tp_as_sequence */
+         0,                                      /* tp_as_mapping */
+         0,                                      /* tp_hash */
+         0,                                      /* tp_call */
+         0,                                      /* tp_str */
+         PyObject_GenericGetAttr,                /* tp_getattro */
+         0,                                      /* tp_setattro */
+         0,                                      /* tp_as_buffer */
+         Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
+         0,                                      /* tp_doc */
+         (traverseproc)listiter_traverse,        /* tp_traverse */
+         0,                                      /* tp_clear */
+         0,                                      /* tp_richcompare */
+         0,                                      /* tp_weaklistoffset */
+         (getiterfunc)listiter_getiter,          /* tp_iter */
+         (iternextfunc)listiter_next,            /* tp_iternext */
+         listiter_methods,			/* tp_methods */
+         0,                                      /* tp_members */
+         0,                                      /* tp_getset */
+         0,                                      /* tp_base */
+         0,                                      /* tp_dict */
+         0,                                      /* tp_descr_get */
+         0,                                      /* tp_descr_set */
+ };
+ 

Index: iterobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/iterobject.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** iterobject.c	8 May 2002 08:44:21 -0000	1.9
--- iterobject.c	31 May 2002 21:37:01 -0000	1.10
***************
*** 69,91 ****
  	seq = it->it_seq;
  
- 	if (PyList_CheckExact(seq)) {
- 		PyObject *item;
- 		if (it->it_index >= PyList_GET_SIZE(seq)) {
- 			return NULL;
- 		}
- 		item = PyList_GET_ITEM(seq, it->it_index);
- 		it->it_index++;
- 		Py_INCREF(item);
- 		return item;
- 	}
  	if (PyTuple_CheckExact(seq)) {
! 		PyObject *item;
! 		if (it->it_index >= PyTuple_GET_SIZE(seq)) {
! 			return NULL;
  		}
! 		item = PyTuple_GET_ITEM(seq, it->it_index);
! 		it->it_index++;
! 		Py_INCREF(item);
! 		return item;
  	}
  	else {
--- 69,81 ----
  	seq = it->it_seq;
  
  	if (PyTuple_CheckExact(seq)) {
! 		if (it->it_index < PyTuple_GET_SIZE(seq)) {
! 			PyObject *item;
! 			item = PyTuple_GET_ITEM(seq, it->it_index);
! 			it->it_index++;
! 			Py_INCREF(item);
! 			return item;
  		}
! 		return NULL;
  	}
  	else {





From rhettinger@users.sourceforge.net  Fri May 31 22:40:40 2002
From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net)
Date: Fri, 31 May 2002 14:40:40 -0700
Subject: [Python-checkins] python/dist/src/Lib/test test_descrtut.py,1.12,1.13
Message-ID: 

Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv11573

Modified Files:
	test_descrtut.py 
Log Message:
SF 560736.  Optimize list iteration by filling the tp_iter slot.

Index: test_descrtut.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descrtut.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** test_descrtut.py	3 Apr 2002 22:41:50 -0000	1.12
--- test_descrtut.py	31 May 2002 21:40:38 -0000	1.13
***************
*** 203,206 ****
--- 203,207 ----
       '__imul__',
       '__init__',
+      '__iter__',
       '__le__',
       '__len__',





From nnorwitz@users.sourceforge.net  Fri May 31 22:47:05 2002
From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net)
Date: Fri, 31 May 2002 14:47:05 -0700
Subject: [Python-checkins] python/dist/src/Modules selectmodule.c,2.62,2.63
Message-ID: 

Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv14127

Modified Files:
	selectmodule.c 
Log Message:
Remove unused static function

Index: selectmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/selectmodule.c,v
retrieving revision 2.62
retrieving revision 2.63
diff -C2 -d -r2.62 -r2.63
*** selectmodule.c	1 Apr 2002 14:53:37 -0000	2.62
--- selectmodule.c	31 May 2002 21:47:02 -0000	2.63
***************
*** 636,658 ****
  On Windows, only sockets are supported; on Unix, all file descriptors.";
  
- /*
-  * Convenience routine to export an integer value.
-  * For simplicity, errors (which are unlikely anyway) are ignored.
-  */
- 
- static void
- insint(PyObject *d, char *name, int value)
- {
- 	PyObject *v = PyInt_FromLong((long) value);
- 	if (v == NULL) {
- 		/* Don't bother reporting this error */
- 		PyErr_Clear();
- 	}
- 	else {
- 		PyDict_SetItemString(d, name, v);
- 		Py_DECREF(v);
- 	}
- }
- 
  DL_EXPORT(void)
  initselect(void)
--- 636,639 ----