From python-dev@python.org Fri Dec 1 07:59:38 2000 From: python-dev@python.org (Tim Peters) Date: Thu, 30 Nov 2000 23:59:38 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.82,1.83 Message-ID: <200012010759.XAA29918@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv29841/python/dist/src/misc Modified Files: NEWS Log Message: Made the description of %[udxXo] formats of negative longs in 2.1 more accurate. I suggested to Guido that %u be deprecated (it seems useless in Python to me). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -r1.82 -r1.83 *** NEWS 2000/11/30 05:22:43 1.82 --- NEWS 2000/12/01 07:59:35 1.83 *************** *** 4,8 **** Core language, builtins, and interpreter ! - %[duxXo] formats of negative Python longs now produce a sign character. In 1.6 and earlier, they never produced a sign, and raised an error if the value of the long was too large --- 4,8 ---- Core language, builtins, and interpreter ! - %[xXo] formats of negative Python longs now produce a sign character. In 1.6 and earlier, they never produced a sign, and raised an error if the value of the long was too large *************** *** 13,20 **** >>> "%x" % -0x42L ! '-42' # in 2.1 'ffffffbe' # in 2.0 and before, on 32-bit machines >>> hex(-0x42L) '-0x42L' # in all versions of Python --- 13,30 ---- >>> "%x" % -0x42L ! '-42' # in 2.1 'ffffffbe' # in 2.0 and before, on 32-bit machines >>> hex(-0x42L) '-0x42L' # in all versions of Python + + The behavior of %d formats for negative Python longs remains + the same as in 2.0 (although in 1.6 and before, they raised + an error if the long didn't fit in a Python int). + + %u formats don't make sense for Python longs, but are allowed + and treated the same as %d in 2.1. In 2.0, a negative long + formatted via %u produced a sign if and only if too large to + fit in an int. In 1.6 and earlier, a negative long formatted + via %u raised an error if it was too big to fit in an int. From python-dev@python.org Fri Dec 1 12:59:07 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 1 Dec 2000 04:59:07 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python getargs.c,2.49,2.50 Message-ID: <200012011259.EAA13346@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv13337 Modified Files: getargs.c Log Message: Clarified some of the error messages, esp. "read-only character buffer" replaced by "string or read-only character buffer". Index: getargs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v retrieving revision 2.49 retrieving revision 2.50 diff -C2 -r2.49 -r2.50 *** getargs.c 2000/09/26 05:46:01 2.49 --- getargs.c 2000/12/01 12:59:05 2.50 *************** *** 566,570 **** arg, NULL); if (arg == NULL) ! return "unicode conversion error"; *p = PyString_AS_STRING(arg); *q = PyString_GET_SIZE(arg); --- 566,570 ---- arg, NULL); if (arg == NULL) ! return "(unicode conversion error)"; *p = PyString_AS_STRING(arg); *q = PyString_GET_SIZE(arg); *************** *** 576,582 **** pb->bf_getreadbuffer == NULL || pb->bf_getsegcount == NULL ) ! return "read-only buffer"; if ( (*pb->bf_getsegcount)(arg, NULL) != 1 ) ! return "single-segment read-only buffer"; if ( (count = (*pb->bf_getreadbuffer)(arg, 0, p)) < 0 ) --- 576,582 ---- pb->bf_getreadbuffer == NULL || pb->bf_getsegcount == NULL ) ! return "string or read-only buffer"; if ( (*pb->bf_getsegcount)(arg, NULL) != 1 ) ! return "string or single-segment read-only buffer"; if ( (count = (*pb->bf_getreadbuffer)(arg, 0, p)) < 0 ) *************** *** 594,598 **** arg, NULL); if (arg == NULL) ! return "unicode conversion error"; *p = PyString_AS_STRING(arg); } --- 594,598 ---- arg, NULL); if (arg == NULL) ! return "(unicode conversion error)"; *p = PyString_AS_STRING(arg); } *************** *** 623,627 **** arg, NULL); if (arg == NULL) ! return "unicode conversion error"; *p = PyString_AS_STRING(arg); *q = PyString_GET_SIZE(arg); --- 623,627 ---- arg, NULL); if (arg == NULL) ! return "(unicode conversion error)"; *p = PyString_AS_STRING(arg); *q = PyString_GET_SIZE(arg); *************** *** 633,639 **** pb->bf_getreadbuffer == NULL || pb->bf_getsegcount == NULL ) ! return "read-only buffer"; if ( (*pb->bf_getsegcount)(arg, NULL) != 1 ) ! return "single-segment read-only buffer"; if ( (count = (*pb->bf_getreadbuffer)(arg, 0, p)) < 0 ) --- 633,639 ---- pb->bf_getreadbuffer == NULL || pb->bf_getsegcount == NULL ) ! return "string or read-only buffer"; if ( (*pb->bf_getsegcount)(arg, NULL) != 1 ) ! return "string or single-segment read-only buffer"; if ( (count = (*pb->bf_getreadbuffer)(arg, 0, p)) < 0 ) *************** *** 653,661 **** arg, NULL); if (arg == NULL) ! return "unicode conversion error"; *p = PyString_AS_STRING(arg); } else ! return "None or string"; if (*format == '#') { int *q = va_arg(*p_va, int *); --- 653,661 ---- arg, NULL); if (arg == NULL) ! return "(unicode conversion error)"; *p = PyString_AS_STRING(arg); } else ! return "string or None"; if (*format == '#') { int *q = va_arg(*p_va, int *); *************** *** 668,672 **** else if (*p != NULL && (int)strlen(*p) != PyString_Size(arg)) ! return "None or string without null bytes"; } break; --- 668,672 ---- else if (*p != NULL && (int)strlen(*p) != PyString_Size(arg)) ! return "string without null bytes or None"; } break; *************** *** 696,700 **** u = PyUnicode_FromObject(arg); if (u == NULL) ! return "string, unicode or text buffer"; /* Encode object; use default error handling */ --- 696,700 ---- u = PyUnicode_FromObject(arg); if (u == NULL) ! return "string or unicode or text buffer"; /* Encode object; use default error handling */ *************** *** 774,779 **** */ if ((int)strlen(PyString_AS_STRING(s)) != size) ! return "(encoded string without "\ ! "NULL bytes)"; *buffer = PyMem_NEW(char, size + 1); if (*buffer == NULL) { --- 774,778 ---- */ if ((int)strlen(PyString_AS_STRING(s)) != size) ! return "(encoded string without NULL bytes)"; *buffer = PyMem_NEW(char, size + 1); if (*buffer == NULL) { *************** *** 800,806 **** pb->bf_getreadbuffer == NULL || pb->bf_getsegcount == NULL ) ! return "read-only buffer"; if ( (*pb->bf_getsegcount)(arg, NULL) != 1 ) ! return "single-segment read-only buffer"; if ( (count = (*pb->bf_getreadbuffer)(arg, 0, p)) < 0 ) --- 799,805 ---- pb->bf_getreadbuffer == NULL || pb->bf_getsegcount == NULL ) ! return "unicode or read-only buffer"; if ( (*pb->bf_getsegcount)(arg, NULL) != 1 ) ! return "unicode or single-segment read-only buffer"; if ( (count = (*pb->bf_getreadbuffer)(arg, 0, p)) < 0 ) *************** *** 917,923 **** pb->bf_getcharbuffer == NULL || pb->bf_getsegcount == NULL ) ! return "read-only character buffer"; if ( (*pb->bf_getsegcount)(arg, NULL) != 1 ) ! return "single-segment read-only buffer"; if ( (count = pb->bf_getcharbuffer(arg, 0, p)) < 0 ) return "(unspecified)"; --- 916,922 ---- pb->bf_getcharbuffer == NULL || pb->bf_getsegcount == NULL ) ! return "string or read-only character buffer"; if ( (*pb->bf_getsegcount)(arg, NULL) != 1 ) ! return "string or single-segment read-only buffer"; if ( (count = pb->bf_getcharbuffer(arg, 0, p)) < 0 ) return "(unspecified)"; From python-dev@python.org Fri Dec 1 13:13:14 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 1 Dec 2000 05:13:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules socketmodule.c,1.128,1.129 Message-ID: <200012011313.FAA14368@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv14356 Modified Files: socketmodule.c Log Message: Patch by Michael Hudson to clarify the error message from getsockaddrarg when the address is not a tuple. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.128 retrieving revision 1.129 diff -C2 -r1.128 -r1.129 *** socketmodule.c 2000/10/06 15:37:06 1.128 --- socketmodule.c 2000/12/01 13:13:11 1.129 *************** *** 606,610 **** int port; addr=(struct sockaddr_in*)&(s->sock_addr).in; ! if (!PyArg_Parse(args, "(si)", &host, &port)) return 0; if (setipaddr(host, addr) < 0) --- 606,616 ---- int port; addr=(struct sockaddr_in*)&(s->sock_addr).in; ! if (!PyTuple_Check(args)) { ! PyErr_Format(PyExc_TypeError, ! "getsockaddrarg: AF_INET address must be tuple, not %.500s", ! args->ob_type->tp_name); ! return 0; ! } ! if (!PyArg_ParseTuple(args, "si:getsockaddrarg", &host, &port)) return 0; if (setipaddr(host, addr) < 0) From python-dev@python.org Fri Dec 1 15:25:26 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 1 Dec 2000 07:25:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcgihttp.tex,1.4,1.5 libcmpcache.tex,1.3,1.4 libcmp.tex,1.2,1.3 libcodeop.tex,1.2,1.3 libcurses.tex,1.22,1.23 libdircache.tex,1.3,1.4 libdl.tex,1.2,1.3 libfilecmp.tex,1.2,1.3 libfpformat.tex,1.2,1.3 liblinecache.tex,1.3,1.4 libmutex.tex,1.3,1.4 libnew.tex,1.6,1.7 libnis.tex,1.4,1.5 libpipes.tex,1.3,1.4 libpty.tex,1.3,1.4 librlcompleter.tex,1.4,1.5 libsched.tex,1.4,1.5 libsimplehttp.tex,1.2,1.3 libstatcache.tex,1.2,1.3 libstatvfs.tex,1.3,1.4 libsunau.tex,1.4,1.5 libtty.tex,1.1,1.2 libturtle.tex,1.2,1.3 libwave.tex,1.4,1.5 Message-ID: <200012011525.HAA25749@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv25715 Modified Files: libcgihttp.tex libcmpcache.tex libcmp.tex libcodeop.tex libcurses.tex libdircache.tex libdl.tex libfilecmp.tex libfpformat.tex liblinecache.tex libmutex.tex libnew.tex libnis.tex libpipes.tex libpty.tex librlcompleter.tex libsched.tex libsimplehttp.tex libstatcache.tex libstatvfs.tex libsunau.tex libtty.tex libturtle.tex libwave.tex Log Message: Update Moshe Zadka's email address to one works and might last a while. Index: libcgihttp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcgihttp.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** libcgihttp.tex 2000/10/10 16:56:41 1.4 --- libcgihttp.tex 2000/12/01 15:25:23 1.5 *************** *** 5,9 **** \declaremodule{standard}{CGIHTTPServer} \platform{Unix} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{This module provides a request handler for HTTP servers which can run CGI scripts.} --- 5,9 ---- \declaremodule{standard}{CGIHTTPServer} \platform{Unix} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{This module provides a request handler for HTTP servers which can run CGI scripts.} Index: libcmpcache.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcmpcache.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** libcmpcache.tex 1999/10/26 16:31:51 1.3 --- libcmpcache.tex 2000/12/01 15:25:23 1.4 *************** *** 3,7 **** \declaremodule{standard}{cmpcache} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Compare files very efficiently.} --- 3,7 ---- \declaremodule{standard}{cmpcache} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Compare files very efficiently.} Index: libcmp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcmp.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libcmp.tex 1999/10/26 16:31:51 1.2 --- libcmp.tex 2000/12/01 15:25:23 1.3 *************** *** 3,7 **** \declaremodule{standard}{cmp} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Compare files very efficiently.} --- 3,7 ---- \declaremodule{standard}{cmp} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Compare files very efficiently.} Index: libcodeop.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcodeop.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libcodeop.tex 2000/04/03 20:13:53 1.2 --- libcodeop.tex 2000/12/01 15:25:23 1.3 *************** *** 5,9 **** \declaremodule{standard}{codeop} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Compile (possibly incomplete) Python code.} --- 5,9 ---- \declaremodule{standard}{codeop} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Compile (possibly incomplete) Python code.} Index: libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** libcurses.tex 2000/11/18 17:57:33 1.22 --- libcurses.tex 2000/12/01 15:25:23 1.23 *************** *** 3,7 **** \declaremodule{standard}{curses} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \sectionauthor{Eric Raymond}{esr@thyrsus.com} \modulesynopsis{An interface to the curses library, providing portable --- 3,7 ---- \declaremodule{standard}{curses} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \sectionauthor{Eric Raymond}{esr@thyrsus.com} \modulesynopsis{An interface to the curses library, providing portable Index: libdircache.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdircache.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** libdircache.tex 2000/07/16 19:01:09 1.3 --- libdircache.tex 2000/12/01 15:25:23 1.4 *************** *** 3,7 **** \declaremodule{standard}{dircache} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Return directory listing, with cache mechanism.} --- 3,7 ---- \declaremodule{standard}{dircache} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Return directory listing, with cache mechanism.} Index: libdl.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdl.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libdl.tex 2000/07/16 19:01:09 1.2 --- libdl.tex 2000/12/01 15:25:23 1.3 *************** *** 3,7 **** \declaremodule{extension}{dl} \platform{Unix} %?????????? Anyone???????????? ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Call C functions in shared objects.} --- 3,7 ---- \declaremodule{extension}{dl} \platform{Unix} %?????????? Anyone???????????? ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Call C functions in shared objects.} Index: libfilecmp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfilecmp.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libfilecmp.tex 2000/07/03 08:24:49 1.2 --- libfilecmp.tex 2000/12/01 15:25:23 1.3 *************** *** 3,7 **** \declaremodule{standard}{filecmp} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Compare files efficiently.} --- 3,7 ---- \declaremodule{standard}{filecmp} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Compare files efficiently.} Index: libfpformat.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfpformat.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libfpformat.tex 1999/12/21 18:45:16 1.2 --- libfpformat.tex 2000/12/01 15:25:23 1.3 *************** *** 3,7 **** \declaremodule{standard}{fpformat} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{General floating point formatting functions.} --- 3,7 ---- \declaremodule{standard}{fpformat} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{General floating point formatting functions.} Index: liblinecache.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liblinecache.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** liblinecache.tex 2000/04/03 20:13:53 1.3 --- liblinecache.tex 2000/12/01 15:25:23 1.4 *************** *** 3,7 **** \declaremodule{standard}{linecache} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{This module provides random access to individual lines from text files.} --- 3,7 ---- \declaremodule{standard}{linecache} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{This module provides random access to individual lines from text files.} Index: libmutex.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmutex.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** libmutex.tex 2000/07/16 19:01:09 1.3 --- libmutex.tex 2000/12/01 15:25:23 1.4 *************** *** 4,8 **** \declaremodule{standard}{mutex} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Lock and queue for mutual exclusion.} --- 4,8 ---- \declaremodule{standard}{mutex} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Lock and queue for mutual exclusion.} Index: libnew.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libnew.tex,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** libnew.tex 2000/10/10 22:00:03 1.6 --- libnew.tex 2000/12/01 15:25:23 1.7 *************** *** 3,7 **** \declaremodule{builtin}{new} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Interface to the creation of runtime implementation objects.} --- 3,7 ---- \declaremodule{builtin}{new} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Interface to the creation of runtime implementation objects.} Index: libnis.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libnis.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** libnis.tex 2000/07/16 19:01:09 1.4 --- libnis.tex 2000/12/01 15:25:23 1.5 *************** *** 5,9 **** \platform{UNIX} \moduleauthor{Fred Gansevles}{Fred.Gansevles@cs.utwente.nl} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Interface to Sun's NIS (a.k.a. Yellow Pages) library.} --- 5,9 ---- \platform{UNIX} \moduleauthor{Fred Gansevles}{Fred.Gansevles@cs.utwente.nl} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Interface to Sun's NIS (a.k.a. Yellow Pages) library.} Index: libpipes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpipes.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** libpipes.tex 2000/07/16 19:01:10 1.3 --- libpipes.tex 2000/12/01 15:25:23 1.4 *************** *** 4,8 **** \declaremodule{standard}{pipes} \platform{Unix} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{A Python interface to \UNIX{} shell pipelines.} --- 4,8 ---- \declaremodule{standard}{pipes} \platform{Unix} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{A Python interface to \UNIX{} shell pipelines.} Index: libpty.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpty.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** libpty.tex 2000/06/28 17:27:48 1.3 --- libpty.tex 2000/12/01 15:25:23 1.4 *************** *** 5,9 **** \modulesynopsis{Pseudo-Terminal Handling for SGI and Linux.} \moduleauthor{Steen Lumholt}{} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} --- 5,9 ---- \modulesynopsis{Pseudo-Terminal Handling for SGI and Linux.} \moduleauthor{Steen Lumholt}{} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} Index: librlcompleter.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/librlcompleter.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** librlcompleter.tex 2000/10/10 17:03:45 1.4 --- librlcompleter.tex 2000/12/01 15:25:23 1.5 *************** *** 4,8 **** \declaremodule{standard}{rlcompleter} \platform{Unix} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Python identifier completion for the GNU readline library.} --- 4,8 ---- \declaremodule{standard}{rlcompleter} \platform{Unix} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Python identifier completion for the GNU readline library.} Index: libsched.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsched.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** libsched.tex 2000/07/16 19:01:10 1.4 --- libsched.tex 2000/12/01 15:25:23 1.5 *************** *** 5,9 **** \declaremodule{standard}{sched} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{General purpose event scheduler.} --- 5,9 ---- \declaremodule{standard}{sched} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{General purpose event scheduler.} Index: libsimplehttp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsimplehttp.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libsimplehttp.tex 2000/10/10 16:59:53 1.2 --- libsimplehttp.tex 2000/12/01 15:25:23 1.3 *************** *** 3,7 **** \declaremodule{standard}{SimpleHTTPServer} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{This module provides a basic request handler for HTTP servers.} --- 3,7 ---- \declaremodule{standard}{SimpleHTTPServer} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{This module provides a basic request handler for HTTP servers.} Index: libstatcache.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstatcache.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libstatcache.tex 1999/06/17 17:09:23 1.2 --- libstatcache.tex 2000/12/01 15:25:23 1.3 *************** *** 3,7 **** \declaremodule{standard}{statcache} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Stat files, and remember results.} --- 3,7 ---- \declaremodule{standard}{statcache} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Stat files, and remember results.} Index: libstatvfs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstatvfs.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** libstatvfs.tex 2000/07/16 19:01:10 1.3 --- libstatvfs.tex 2000/12/01 15:25:23 1.4 *************** *** 4,8 **** \declaremodule{standard}{statvfs} % LaTeX'ed from comments in module ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Constants for interpreting the result of \function{os.statvfs()}.} --- 4,8 ---- \declaremodule{standard}{statvfs} % LaTeX'ed from comments in module ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Constants for interpreting the result of \function{os.statvfs()}.} Index: libsunau.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsunau.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** libsunau.tex 2000/11/17 19:05:11 1.4 --- libsunau.tex 2000/12/01 15:25:23 1.5 *************** *** 3,7 **** \declaremodule{standard}{sunau} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Provide an interface to the Sun AU sound format.} --- 3,7 ---- \declaremodule{standard}{sunau} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Provide an interface to the Sun AU sound format.} Index: libtty.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtty.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** libtty.tex 1999/06/23 14:30:19 1.1 --- libtty.tex 2000/12/01 15:25:23 1.2 *************** *** 5,9 **** \platform{Unix} \moduleauthor{Steen Lumholt}{} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Utility functions that perform common terminal control operations.} --- 5,9 ---- \platform{Unix} \moduleauthor{Steen Lumholt}{} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Utility functions that perform common terminal control operations.} Index: libturtle.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libturtle.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libturtle.tex 1999/11/17 16:09:57 1.2 --- libturtle.tex 2000/12/01 15:25:23 1.3 *************** *** 7,11 **** \modulesynopsis{An environment for turtle graphics.} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} --- 7,11 ---- \modulesynopsis{An environment for turtle graphics.} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} Index: libwave.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwave.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** libwave.tex 2000/07/16 19:01:10 1.4 --- libwave.tex 2000/12/01 15:25:23 1.5 *************** *** 4,8 **** \declaremodule{standard}{wave} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Provide an interface to the WAV sound format.} --- 4,8 ---- \declaremodule{standard}{wave} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Provide an interface to the WAV sound format.} From python-dev@python.org Fri Dec 1 23:50:48 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 1 Dec 2000 15:50:48 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0229.txt,1.1,1.2 Message-ID: <200012012350.PAA31895@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv31855 Modified Files: pep-0229.txt Log Message: Refer to SF patch Add apparent resolution of one open issue Index: pep-0229.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0229.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** pep-0229.txt 2000/11/22 19:17:06 1.1 --- pep-0229.txt 2000/12/01 23:50:46 1.2 *************** *** 51,54 **** --- 51,69 ---- + Implementation + + Patch #102588 on SourceForge will contain the proposed patch. + As of Dec. 1, the patch does the following: + + * Removes the use of makesetup in building the interpreter. + * Hard-codes the presence of the strop, posix, and _sre modules. + * Adds an empty top-level setup.py file. + + Still to be done: + + * Write the top-level setup.py + * Handle a few tricky bits such as the signal module. + + Unresolved Issues *************** *** 60,63 **** --- 75,83 ---- we support compiling them statically into the resulting Python binary? + + [Answer: building a Python binary with the Distutils should be + feasible, though no one has implemented it yet. This will need to + be done, though the main setup.py will probably need to implement + its own BuildExt subclass anyway.] makesetup and the other contents of $(LIBPL)/config need to be From python-dev@python.org Sat Dec 2 03:38:01 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 1 Dec 2000 19:38:01 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0231.txt,NONE,1.1 Message-ID: <200012020338.TAA14006@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv13988 Added Files: pep-0231.txt Log Message: PEP 231, __findattr__(), Barry Warsaw --- NEW FILE --- PEP: 231 Title: __findattr__() Version: $Revision: 1.1 $ Author: barry@digicool.com (Barry A. Warsaw) Python-Version: 2.1 Status: Draft Created: 30-Nov-2000 Post-History: Introduction This PEP describes an extension to instance attribute lookup and modification machinery, which allows pure-Python implementations of many interesting programming models. This PEP tracks the status and ownership of this feature. It contains a description of the feature and outlines changes necessary to support the feature. This PEP summarizes discussions held in mailing list forums, and provides URLs for further information, where appropriate. The CVS revision history of this file contains the definitive historical record. Background The semantics for Python instances allow the programmer to customize some aspects of attribute lookup and attribute modification, through the special methods __getattr__() and __setattr__() [1]. However, because of certain restrictions imposed by these methods, there are useful programming techniques that can not be written in Python alone, e.g. strict Java Bean-like[2] interfaces and Zope style acquisitions[3]. In the latter case, Zope solves this by including a C extension called ExtensionClass[5] which modifies the standard class semantics, and uses a metaclass hook in Python's class model called alternatively the "Don Beaudry Hook" or "Don Beaudry Hack"[6]. While Zope's approach works, it has several disadvantages. First, it requires a C extension. Second it employs a very arcane, but truck-sized loophole in the Python machinery. Third, it can be difficult for other programmers to use and understand (the metaclass has well-known brain exploding properties). And fourth, because ExtensionClass instances aren't "real" Python instances, some aspects of the Python runtime system don't work with ExtensionClass instances. Proposals for fixing this problem have often been lumped under the rubric of fixing the "class/type dichotomy"; that is, eliminating the difference between built-in types and classes[7]. While a laudable goal itself, repairing this rift is not necessary in order to achieve the types of programming constructs described above. This proposal provides an 80% solution with a minimum of modification to Python's class and instance objects. It does nothing to address the type/class dichotomy. Proposal This proposal adds a new special method called __findattr__() with the following semantics: * If defined in a class, it will be called on all instance attribute resolutions instead of __getattr__() and __setattr__(). * __findattr__() is never called recursively. That is, when a specific instance's __findattr__() is on the call stack, further attribute accesses for that instance will use the standard __getattr__() and __setattr__() methods. * __findattr__() is called for both attribute access (`getting') and attribute modification (`setting'). It is not called for attribute deletion. * When called for getting, it is passed a single argument (not counting `self'): the name of the attribute being accessed. * When called for setting, it is called with third argument, which is the value to set the attribute to. * __findattr__() methods have the same caching semantics as __getattr__() and __setattr__(); i.e. if they are present in the class at class definition time, they are used, but if they are subsequently added to a class later they are not. Key Differences with the Existing Protocol __findattr__()'s semantics are different from the existing protocol in key ways: First, __getattr__() is never called if the attribute is found in the instance's __dict__. This is done for efficiency reasons, and because otherwise, __setattr__() would have no way to get to the instance's attributes. Second, __setattr__() cannot use "normal" syntax for setting instance attributes, e.g. "self.name = foo" because that would cause recursive calls to __setattr__(). __findattr__() is always called regardless of whether the attribute is in __dict__ or not, and a flag in the instance object prevents recursive calls to __findattr__(). This gives the class a chance to perform some action for every attribute access. And because it is called for both gets and sets, it is easy to write similar policy for all attribute access. Further, efficiency is not a problem because it is only paid when the extended mechanism is used. Examples One programming style that this proposal allows is a Java Bean-like interface to objects, where unadorned attribute access and modification is transparently mapped to a functional interface. E.g. class Bean: def __init__(self, x): self.__myfoo = x def __findattr__(self, name, *args): if name.startswith('_'): # Private names if args: setattr(self, name, args[0]) else: return getattr(self, name) else: # Public names if args: name = '_set_' + name else: name = '_get_' + name return getattr(self, name)(*args) def _set_foo(self, x): self.__myfoo = x def _get_foo(self): return self.__myfoo b = Bean(3) print b.foo b.foo = 9 print b.foo A second, more elaborate example is the implementation of both implicit and explicit acquisition in pure Python: import types class MethodWrapper: def __init__(self, container, method): self.__container = container self.__method = method def __call__(self, *args, **kws): return self.__method.im_func(self.__container, *args, **kws) class WrapperImplicit: def __init__(self, contained, container): self.__contained = contained self.__container = container def __repr__(self): return '' % (self.__container, self.__contained) def __findattr__(self, name, *args): # Some things are our own if name.startswith('_WrapperImplicit__'): if args: return setattr(self, name, *args) else: return getattr(self, name) # setattr stores the name on the contained object directly if args: return setattr(self.__contained, name, args[0]) # Other special names if name == 'aq_parent': return self.__container elif name == 'aq_self': return self.__contained elif name == 'aq_base': base = self.__contained try: while 1: base = base.aq_self except AttributeError: return base # no acquisition for _ names if name.startswith('_'): return getattr(self.__contained, name) # Everything else gets wrapped missing = () which = self.__contained obj = getattr(which, name, missing) if obj is missing: which = self.__container obj = getattr(which, name, missing) if obj is missing: raise AttributeError, name of = getattr(obj, '__of__', missing) if of is not missing: return of(self) elif type(obj) == types.MethodType: return MethodWrapper(self, obj) return obj class WrapperExplicit: def __init__(self, contained, container): self.__contained = contained self.__container = container def __repr__(self): return '' % (self.__container, self.__contained) def __findattr__(self, name, *args): # Some things are our own if name.startswith('_WrapperExplicit__'): if args: return setattr(self, name, *args) else: return getattr(self, name) # setattr stores the name on the contained object directly if args: return setattr(self.__contained, name, args[0]) # Other special names if name == 'aq_parent': return self.__container elif name == 'aq_self': return self.__contained elif name == 'aq_base': base = self.__contained try: while 1: base = base.aq_self except AttributeError: return base elif name == 'aq_acquire': return self.aq_acquire # explicit acquisition only obj = getattr(self.__contained, name) if type(obj) == types.MethodType: return MethodWrapper(self, obj) return obj def aq_acquire(self, name): # Everything else gets wrapped missing = () which = self.__contained obj = getattr(which, name, missing) if obj is missing: which = self.__container obj = getattr(which, name, missing) if obj is missing: raise AttributeError, name of = getattr(obj, '__of__', missing) if of is not missing: return of(self) elif type(obj) == types.MethodType: return MethodWrapper(self, obj) return obj class Implicit: def __of__(self, container): return WrapperImplicit(self, container) def __findattr__(self, name, *args): # ignore setattrs if args: return setattr(self, name, args[0]) obj = getattr(self, name) missing = () of = getattr(obj, '__of__', missing) if of is not missing: return of(self) return obj class Explicit(Implicit): def __of__(self, container): return WrapperExplicit(self, container) # tests class C(Implicit): color = 'red' class A(Implicit): def report(self): return self.color # simple implicit acquisition c = C() a = A() c.a = a assert c.a.report() == 'red' d = C() d.color = 'green' d.a = a assert d.a.report() == 'green' try: a.report() except AttributeError: pass else: assert 0, 'AttributeError expected' # special names assert c.a.aq_parent is c assert c.a.aq_self is a c.a.d = d assert c.a.d.aq_base is d assert c.a is not a # no acquisiton on _ names class E(Implicit): _color = 'purple' class F(Implicit): def report(self): return self._color e = E() f = F() e.f = f try: e.f.report() except AttributeError: pass else: assert 0, 'AttributeError expected' # explicit class G(Explicit): color = 'pink' class H(Explicit): def report(self): return self.aq_acquire('color') def barf(self): return self.color g = G() h = H() g.h = h assert g.h.report() == 'pink' i = G() i.color = 'cyan' i.h = h assert i.h.report() == 'cyan' try: g.i.barf() except AttributeError: pass else: assert 0, 'AttributeError expected' And finally, C++-like access control can also be accomplished, although less cleanly because of the difficulty of figuring out what method is being called from the runtime call stack: import sys import types PUBLIC = 0 PROTECTED = 1 PRIVATE = 2 try: getframe = sys._getframe except ImportError: def getframe(n): try: raise Exception except Exception: frame = sys.exc_info()[2].tb_frame while n > 0: frame = frame.f_back if frame is None: raise ValueError, 'call stack is not deep enough' return frame class AccessViolation(Exception): pass class Access: def __findattr__(self, name, *args): methcache = self.__dict__.setdefault('__cache__', {}) missing = () obj = getattr(self, name, missing) # if obj is missing we better be doing a setattr for # the first time if obj is not missing and type(obj) == types.MethodType: # Digusting hack because there's no way to # dynamically figure out what the method being # called is from the stack frame. methcache[obj.im_func.func_code] = obj.im_class # # What's the access permissions for this name? access, klass = getattr(self, '__access__', {}).get( name, (PUBLIC, 0)) if access is not PUBLIC: # Now try to see which method is calling us frame = getframe(0).f_back if frame is None: raise AccessViolation # Get the class of the method that's accessing # this attribute, by using the code object cache if frame.f_code.co_name == '__init__': # There aren't entries in the cache for ctors, # because the calling mechanism doesn't go # through __findattr__(). Are there other # methods that might have the same behavior? # Since we can't know who's __init__ we're in, # for now we'll assume that only protected and # public attrs can be accessed. if access is PRIVATE: raise AccessViolation else: methclass = self.__cache__.get(frame.f_code) if not methclass: raise AccessViolation if access is PRIVATE and methclass is not klass: raise AccessViolation if access is PROTECTED and not issubclass(methclass, klass): raise AccessViolation # If we got here, it must be okay to access the attribute if args: return setattr(self, name, *args) return obj # tests class A(Access): def __init__(self, foo=0, name='A'): self._foo = foo # can't set private names in __init__ self.__initprivate(name) def __initprivate(self, name): self._name = name def getfoo(self): return self._foo def setfoo(self, newfoo): self._foo = newfoo def getname(self): return self._name A.__access__ = {'_foo' : (PROTECTED, A), '_name' : (PRIVATE, A), '__dict__' : (PRIVATE, A), '__access__': (PRIVATE, A), } class B(A): def setfoo(self, newfoo): self._foo = newfoo + 3 def setname(self, name): self._name = name b = B(1) b.getfoo() a = A(1) assert a.getfoo() == 1 a.setfoo(2) assert a.getfoo() == 2 try: a._foo except AccessViolation: pass else: assert 0, 'AccessViolation expected' try: a._foo = 3 except AccessViolation: pass else: assert 0, 'AccessViolation expected' try: a.__dict__['_foo'] except AccessViolation: pass else: assert 0, 'AccessViolation expected' b = B() assert b.getfoo() == 0 b.setfoo(2) assert b.getfoo() == 5 try: b.setname('B') except AccessViolation: pass else: assert 0, 'AccessViolation expected' assert b.getname() == 'A' Reference Implementation The reference implementation, as a patch to the Python core, can be found at this URL: http://sourceforge.net/patch/?func=detailpatch&patch_id=102613&group_id=5470 References [1] http://www.python.org/doc/current/ref/attribute-access.html [2] http://www.javasoft.com/products/javabeans/ [3] http://www.digicool.com/releases/ExtensionClass/Acquisition.html [5] http://www.digicool.com/releases/ExtensionClass [6] http://www.python.org/doc/essays/metaclasses/ [7] http://www.foretec.com/python/workshops/1998-11/dd-ascher-sum.html [8] http://www.python.org/doc/howto/rexec/rexec.html Copyright This document has been placed in the Public Domain. Local Variables: mode: indented-text indent-tabs-mode: nil End: From python-dev@python.org Sat Dec 2 03:38:50 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 1 Dec 2000 19:38:50 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.52,1.53 Message-ID: <200012020338.TAA14175@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv14167 Modified Files: pep-0000.txt Log Message: PEP 231, __findattr__(), Barry Warsaw Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -r1.52 -r1.53 *** pep-0000.txt 2000/11/28 22:23:25 1.52 --- pep-0000.txt 2000/12/02 03:38:48 1.53 *************** *** 40,43 **** --- 40,44 ---- S 227 pep-0227.txt Statically Nested Scopes Hylton S 230 pep-0230.txt Warning Framework van Rossum + S 231 pep-0231.txt __findattr__() Warsaw Pie-in-the-sky PEPs (not ready; may become active yet) *************** *** 126,129 **** --- 127,131 ---- S 229 pep-0229.txt Using Distutils to Build Python Kuchling S 230 pep-0230.txt Warning Framework van Rossum + S 231 pep-0231.txt __findattr__() Warsaw Key From python-dev@python.org Sat Dec 2 04:11:35 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 1 Dec 2000 20:11:35 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0231.txt,1.1,1.2 Message-ID: <200012020411.UAA17734@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv17723 Modified Files: pep-0231.txt Log Message: Talk about PEP 213, which is related and can be (mostly) implemented using the __findattr__() hook. Index: pep-0231.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0231.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** pep-0231.txt 2000/12/02 03:37:58 1.1 --- pep-0231.txt 2000/12/02 04:11:32 1.2 *************** *** 111,114 **** --- 111,124 ---- + Related Work + + PEP 213 [9] describes a different approach to hooking into + attribute access and modification. The semantics proposed in PEP + 213 can be implemented using the __findattr__() hook described + here, with one caveat. The current reference implementation of + __findattr__() does not support hooking on attribute deletion. + This could be added if it's found desirable. See example below. + + Examples *************** *** 369,375 **** ! And finally, C++-like access control can also be accomplished, ! although less cleanly because of the difficulty of figuring out ! what method is being called from the runtime call stack: import sys --- 379,385 ---- ! C++-like access control can also be accomplished, although less ! cleanly because of the difficulty of figuring out what method is ! being called from the runtime call stack: import sys *************** *** 521,524 **** --- 531,586 ---- + Here's an implementation of the attribute hook described in PEP + 213 (except that hooking on attribute deletion isn't supported by + the current reference implementation). + + class Pep213: + def __findattr__(self, name, *args): + hookname = '__attr_%s__' % name + if args: + op = 'set' + else: + op = 'get' + # XXX: op = 'del' currently not supported + missing = () + meth = getattr(self, hookname, missing) + if meth is missing: + if op == 'set': + return setattr(self, name, *args) + else: + return getattr(self, name) + else: + return meth(op, *args) + + + def computation(i): + print 'doing computation:', i + return i + 3 + + + def rev_computation(i): + print 'doing rev_computation:', i + return i - 3 + + + class X(Pep213): + def __init__(self, foo=0): + self.__foo = foo + + def __attr_foo__(self, op, val=None): + if op == 'get': + return computation(self.__foo) + elif op == 'set': + self.__foo = rev_computation(val) + # XXX: 'del' not yet supported + + x = X() + fooval = x.foo + print fooval + x.foo = fooval + 5 + print x.foo + # del x.foo + + Reference Implementation *************** *** 538,541 **** --- 600,604 ---- [7] http://www.foretec.com/python/workshops/1998-11/dd-ascher-sum.html [8] http://www.python.org/doc/howto/rexec/rexec.html + [9] http://python.sourceforge.net/peps/pep-0213.html From python-dev@python.org Sat Dec 2 15:12:38 2000 From: python-dev@python.org (Barry Warsaw) Date: Sat, 2 Dec 2000 07:12:38 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0231.txt,1.2,1.3 Message-ID: <200012021512.HAA25553@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv25539 Modified Files: pep-0231.txt Log Message: Back out last second change in the examples. `missing' should be an empty mutable (i.e. list) since empty tuples are shared. Thanks Just! Index: pep-0231.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0231.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** pep-0231.txt 2000/12/02 04:11:32 1.2 --- pep-0231.txt 2000/12/02 15:12:35 1.3 *************** *** 203,207 **** return getattr(self.__contained, name) # Everything else gets wrapped ! missing = () which = self.__contained obj = getattr(which, name, missing) --- 203,207 ---- return getattr(self.__contained, name) # Everything else gets wrapped ! missing = [] which = self.__contained obj = getattr(which, name, missing) *************** *** 258,262 **** def aq_acquire(self, name): # Everything else gets wrapped ! missing = () which = self.__contained obj = getattr(which, name, missing) --- 258,262 ---- def aq_acquire(self, name): # Everything else gets wrapped ! missing = [] which = self.__contained obj = getattr(which, name, missing) *************** *** 283,287 **** return setattr(self, name, args[0]) obj = getattr(self, name) ! missing = () of = getattr(obj, '__of__', missing) if of is not missing: --- 283,287 ---- return setattr(self, name, args[0]) obj = getattr(self, name) ! missing = [] of = getattr(obj, '__of__', missing) if of is not missing: *************** *** 411,415 **** def __findattr__(self, name, *args): methcache = self.__dict__.setdefault('__cache__', {}) ! missing = () obj = getattr(self, name, missing) # if obj is missing we better be doing a setattr for --- 411,415 ---- def __findattr__(self, name, *args): methcache = self.__dict__.setdefault('__cache__', {}) ! missing = [] obj = getattr(self, name, missing) # if obj is missing we better be doing a setattr for *************** *** 543,547 **** op = 'get' # XXX: op = 'del' currently not supported ! missing = () meth = getattr(self, hookname, missing) if meth is missing: --- 543,547 ---- op = 'get' # XXX: op = 'del' currently not supported ! missing = [] meth = getattr(self, hookname, missing) if meth is missing: From python-dev@python.org Sun Dec 3 18:30:13 2000 From: python-dev@python.org (Martin v. Löwis) Date: Sun, 3 Dec 2000 10:30:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib urllib.py,1.107,1.108 Message-ID: <200012031830.KAA30620@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv30506 Modified Files: urllib.py Log Message: Convert Unicode strings to byte strings before passing them into specific protocols. Closes bug #119822. Index: urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.107 retrieving revision 1.108 diff -C2 -r1.107 -r1.108 *** urllib.py 2000/10/02 23:04:02 1.107 --- urllib.py 2000/12/03 18:30:10 1.108 *************** *** 27,34 **** import os import sys - __version__ = '1.13' # XXX This version is not always updated :-( - MAXFTPCACHE = 10 # Trim the ftp cache beyond this size --- 27,34 ---- import os import sys + import types + __version__ = '1.14' # XXX This version is not always updated :-( MAXFTPCACHE = 10 # Trim the ftp cache beyond this size *************** *** 137,157 **** def open(self, fullurl, data=None): """Use URLopener().open(file) instead of open(file, 'r').""" ! fullurl = unwrap(fullurl) if self.tempcache and self.tempcache.has_key(fullurl): filename, headers = self.tempcache[fullurl] fp = open(filename, 'rb') return addinfourl(fp, headers, fullurl) ! type, url = splittype(fullurl) ! if not type: ! type = 'file' ! if self.proxies.has_key(type): ! proxy = self.proxies[type] ! type, proxyhost = splittype(proxy) host, selector = splithost(proxyhost) url = (host, fullurl) # Signal special case to open_*() else: proxy = None ! name = 'open_' + type ! self.type = type if '-' in name: # replace - with _ --- 137,157 ---- def open(self, fullurl, data=None): """Use URLopener().open(file) instead of open(file, 'r').""" ! fullurl = unwrap(toBytes(fullurl)) if self.tempcache and self.tempcache.has_key(fullurl): filename, headers = self.tempcache[fullurl] fp = open(filename, 'rb') return addinfourl(fp, headers, fullurl) ! urltype, url = splittype(fullurl) ! if not urltype: ! urltype = 'file' ! if self.proxies.has_key(urltype): ! proxy = self.proxies[urltype] ! urltype, proxyhost = splittype(proxy) host, selector = splithost(proxyhost) url = (host, fullurl) # Signal special case to open_*() else: proxy = None ! name = 'open_' + urltype ! self.type = urltype if '-' in name: # replace - with _ *************** *** 184,188 **** """retrieve(url) returns (filename, None) for a local object or (tempfilename, headers) for a remote object.""" ! url = unwrap(url) if self.tempcache and self.tempcache.has_key(url): return self.tempcache[url] --- 184,188 ---- """retrieve(url) returns (filename, None) for a local object or (tempfilename, headers) for a remote object.""" ! url = unwrap(toBytes(url)) if self.tempcache and self.tempcache.has_key(url): return self.tempcache[url] *************** *** 239,243 **** import httplib user_passwd = None ! if type(url) is type(""): host, selector = splithost(url) if host: --- 239,243 ---- import httplib user_passwd = None ! if type(url) is types.StringType: host, selector = splithost(url) if host: *************** *** 314,318 **** import httplib user_passwd = None ! if type(url) is type(""): host, selector = splithost(url) if host: --- 314,318 ---- import httplib user_passwd = None ! if type(url) in types.StringTypes: host, selector = splithost(url) if host: *************** *** 852,855 **** --- 852,866 ---- # unquote('abc%20def') -> 'abc def' # quote('abc def') -> 'abc%20def') + + def toBytes(url): + """toBytes(u"URL") --> '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") + except UnicodeError: + raise UnicodeError("URL "+repr(url)+" contains non-ASCII characters") + return url def unwrap(url): From python-dev@python.org Sun Dec 3 19:21:11 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Sun, 03 Dec 2000 20:21:11 +0100 Subject: [Python-checkins] CVS: python/dist/src/Lib urllib.py,1.107,1.108 References: <200012031830.KAA30620@slayer.i.sourceforge.net> Message-ID: <3A2A9D27.AF43D665@lemburg.com> "Martin v. Löwis" wrote: > > Update of /cvsroot/python/python/dist/src/Lib > In directory slayer.i.sourceforge.net:/tmp/cvs-serv30506 > > Modified Files: > urllib.py > Log Message: > Convert Unicode strings to byte strings before passing them into specific > protocols. Closes bug #119822. > > ... > + > + def toBytes(url): > + """toBytes(u"URL") --> '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") You should make this: 'ascii' -- encoding names are lower case per convention (and the implementation has a short-cut to speed up conversion to 'ascii' -- not for 'ASCII'). > + except UnicodeError: > + raise UnicodeError("URL "+repr(url)+" contains non-ASCII characters") Would it be better to use a simple ValueError here ? (UnicodeError is a subclass of ValueError, but the error doesn't really have something to do with Unicode conversions...) > + return url > > def unwrap(url): -- Marc-Andre Lemburg ______________________________________________________________________ Company: http://www.egenix.com/ Consulting: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From python-dev@python.org Sun Dec 3 20:48:11 2000 From: python-dev@python.org (Moshe Zadka) Date: Sun, 3 Dec 2000 12:48:11 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib filecmp.py,1.6,1.7 Message-ID: <200012032048.MAA10353@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv9465 Modified Files: filecmp.py Log Message: Call of _cmp had wrong number of paramereters. Fixed definition of _cmp. Index: filecmp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/filecmp.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** filecmp.py 2000/07/03 08:18:47 1.6 --- filecmp.py 2000/12/03 20:48:07 1.7 *************** *** 296,302 **** # 2 for funny cases (can't stat, etc.) # ! def _cmp(a, b): try: ! return not abs(cmp(a, b)) except os.error: return 2 --- 296,302 ---- # 2 for funny cases (can't stat, etc.) # ! def _cmp(a, b, sh, st): try: ! return not abs(cmp(a, b, sh, st)) except os.error: return 2 From python-dev@python.org Mon Dec 4 15:42:14 2000 From: python-dev@python.org (Neil Schemenauer) Date: Mon, 4 Dec 2000 07:42:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.182,2.183 Message-ID: <200012041542.HAA17908@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv17504/Python Modified Files: bltinmodule.c Log Message: Make isinstance() more permissive in what types of arguments it accepts. Clarify exception messages for isinstance() and issubclass(). Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.182 retrieving revision 2.183 diff -C2 -r2.182 -r2.183 *** bltinmodule.c 2000/10/24 19:57:45 2.182 --- bltinmodule.c 2000/12/04 15:42:11 2.183 *************** *** 1996,2000 **** static int ! abstract_issubclass(PyObject *derived, PyObject *cls, char *err, int first) { static PyObject *__bases__ = NULL; --- 1996,2000 ---- static int ! abstract_issubclass(PyObject *derived, PyObject *cls, int first) { static PyObject *__bases__ = NULL; *************** *** 2013,2017 **** if (bases == NULL || !PyTuple_Check(bases)) { Py_XDECREF(bases); ! PyErr_SetString(PyExc_TypeError, err); return -1; } --- 2013,2018 ---- if (bases == NULL || !PyTuple_Check(bases)) { Py_XDECREF(bases); ! PyErr_SetString(PyExc_TypeError, ! "arg 2 must be a class or type"); return -1; } *************** *** 2025,2029 **** if (bases == NULL || !PyTuple_Check(bases)) { Py_XDECREF(bases); ! PyErr_SetString(PyExc_TypeError, err); return -1; } --- 2026,2031 ---- if (bases == NULL || !PyTuple_Check(bases)) { Py_XDECREF(bases); ! PyErr_SetString(PyExc_TypeError, ! "arg 2 must be a class or type"); return -1; } *************** *** 2031,2036 **** n = PyTuple_GET_SIZE(bases); for (i = 0; i < n; i++) { ! r = abstract_issubclass(PyTuple_GET_ITEM(bases, i), ! cls, err, 0); if (r != 0) break; --- 2033,2037 ---- n = PyTuple_GET_SIZE(bases); for (i = 0; i < n; i++) { ! r = abstract_issubclass(PyTuple_GET_ITEM(bases, i), cls, 0); if (r != 0) break; *************** *** 2072,2079 **** icls = PyObject_GetAttr(inst, __class__); if (icls != NULL) { ! retval = abstract_issubclass( ! icls, cls, ! "isinstance() arg 2 must be a class", ! 1); Py_DECREF(icls); if (retval < 0) --- 2073,2077 ---- icls = PyObject_GetAttr(inst, __class__); if (icls != NULL) { ! retval = abstract_issubclass( icls, cls, 1); Py_DECREF(icls); if (retval < 0) *************** *** 2082,2094 **** else { PyErr_SetString(PyExc_TypeError, ! "isinstance() arg 2 must be a class"); return NULL; } } - else { - PyErr_SetString(PyExc_TypeError, - "isinstance() arg 2 must be a class"); - return NULL; - } return PyInt_FromLong(retval); } --- 2080,2087 ---- else { PyErr_SetString(PyExc_TypeError, ! "arg 2 must be a class or type"); return NULL; } } return PyInt_FromLong(retval); } *************** *** 2112,2117 **** if (!PyClass_Check(derived) || !PyClass_Check(cls)) { ! retval = abstract_issubclass( ! derived, cls, "arguments must be classes", 1); if (retval < 0) return NULL; --- 2105,2109 ---- if (!PyClass_Check(derived) || !PyClass_Check(cls)) { ! retval = abstract_issubclass(derived, cls, 1); if (retval < 0) return NULL; From python-dev@python.org Mon Dec 4 16:29:16 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 4 Dec 2000 08:29:16 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib ConfigParser.py,1.23,1.24 Message-ID: <200012041629.IAA23683@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv23670 Modified Files: ConfigParser.py Log Message: remove_option(): Use the right variable name for the option name! This closes bug #124324. Index: ConfigParser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ConfigParser.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** ConfigParser.py 2000/09/27 22:43:54 1.23 --- ConfigParser.py 2000/12/04 16:29:13 1.24 *************** *** 362,368 **** except KeyError: raise NoSectionError(section) ! existed = sectdict.has_key(key) if existed: ! del sectdict[key] return existed --- 362,368 ---- except KeyError: raise NoSectionError(section) ! existed = sectdict.has_key(option) if existed: ! del sectdict[option] return existed From python-dev@python.org Mon Dec 4 16:30:43 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 4 Dec 2000 08:30:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_cfgparser.py,1.3,1.4 Message-ID: <200012041630.IAA23889@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv23878/test Modified Files: test_cfgparser.py Log Message: Add test cases for ConfigParser.remove_option() behavior. This includes coverage to ensure bug #124324 does not re-surface. Index: test_cfgparser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cfgparser.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_cfgparser.py 2000/10/23 17:22:07 1.3 --- test_cfgparser.py 2000/12/04 16:30:40 1.4 *************** *** 2,5 **** --- 2,8 ---- import StringIO + from test_support import TestFailed + + def basic(src): print *************** *** 25,28 **** --- 28,52 ---- else: print '__name__ "option" properly hidden by the API.' + + # Make sure the right things happen for remove_option(); + # added to include check for SourceForge bug #123324: + if not cf.remove_option('Foo Bar', 'foo'): + raise TestFailed( + "remove_option() failed to report existance of option") + if cf.has_option('Foo Bar', 'foo'): + raise TestFailed("remove_option() failed to remove option") + if cf.remove_option('Foo Bar', 'foo'): + raise TestFailed( + "remove_option() failed to report non-existance of option" + " that was removed") + try: + cf.remove_option('No Such Section', 'foo') + except ConfigParser.NoSectionError: + pass + else: + raise TestFailed( + "remove_option() failed to report non-existance of option" + " that never existed") + def interpolation(src): From python-dev@python.org Mon Dec 4 20:32:16 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 4 Dec 2000 12:32:16 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0207.txt,1.5,1.6 Message-ID: <200012042032.MAA12195@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv12181 Modified Files: pep-0207.txt Log Message: Checking in some text. Most of this is simply an Appendix repeating what David Ascher said in 1998 (before the starship bites the dust again). Index: pep-0207.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0207.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** pep-0207.txt 2000/11/28 22:23:25 1.5 --- pep-0207.txt 2000/12/04 20:32:13 1.6 *************** *** 2,9 **** Title: Rich Comparisions Version: $Revision$ ! Author: mal@lemburg.com (Marc-Andre Lemburg), guido@python.org (Guido van Rossum) Python-Version: 2.1 Status: Incomplete --- 2,330 ---- Title: Rich Comparisions Version: $Revision$ ! Author: guido@python.org (Guido van Rossum), mal@lemburg.com (Marc-Andre Lemburg) Python-Version: 2.1 Status: Incomplete + + Abstract + + This PEP proposes several new features for comparisons: + + - Allow separately overloading of <, >, <=, >=, ==, !=, both in + classes and in C extensions. + + - Allow any of those overloaded operators to return something else + besides a Boolean result. + + + Motivation + + The main motivation comes from NumPy, whose users agree that A", ">=", "==", "!=", "<>" (the last two have the same + meaning). When called with one of these strings as the third + argument, cmp() can return any Python object. Otherwise, it can + only return -1, 0 or 1 as before. + + Chained Comparisons + + Problem + + It would be nice to allow objects for which the comparison returns + something other than -1, 0, or 1 to be used in chained + comparisons, such as: + + x < y < z + + Currently, this is interpreted by Python as: + + temp1 = x < y + if temp1: + return y < z + else: + return temp1 + + Note that this requires testing the truth value of the result of + comparisons, with potential "shortcutting" of the right-side + comparison testings. In other words, the truth-value of the result + of the result of the comparison determines the result of a chained + operation. This is problematic in the case of arrays, since if x, + y and z are three arrays, then the user expects: + + x < y < z + + to be an array of 0's and 1's where 1's are in the locations + corresponding to the elements of y which are between the + corresponding elements in x and z. In other words, the right-hand + side must be evaluated regardless of the result of x < y, which is + incompatible with the mechanism currently in use by the parser. + + Solution + + Guido mentioned that one possible way out would be to change the + code generated by chained comparisons to allow arrays to be + chained-compared intelligently. What follows is a mixture of his + idea and my suggestions. The code generated for x < y < z would be + equivalent to: + + temp1 = x < y + if temp1: + temp2 = y < z + return boolean_combine(temp1, temp2) + else: + return temp1 + + where boolean_combine is a new function which does something like + the following: + + def boolean_combine(a, b): + if hasattr(a, '__boolean_and__') or \ + hasattr(b, '__boolean_and__'): + try: + return a.__boolean_and__(b) + except: + return b.__boolean_and__(a) + else: # standard behavior + if a: + return b + else: + return 0 + + where the __boolean_and__ special method is implemented for + C-level types by another value of the third argument to the + richcmp function. This method would perform a boolean comparison + of the arrays (currently implemented in the umath module as the + logical_and ufunc). + + Thus, objects returned by rich comparisons should always test + true, but should define another special method which creates + boolean combinations of them and their argument. + + This solution has the advantage of allowing chained comparisons to + work for arrays, but the disadvantage that it requires comparison + arrays to always return true (in an ideal world, I'd have them + always raise an exception on truth testing, since the meaning of + testing "if a>b:" is massively ambiguous. + + The inlining already present which deals with integer comparisons + would still apply, resulting in no performance cost for the most + common cases. From python-dev@python.org Mon Dec 4 22:04:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 4 Dec 2000 14:04:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib xmlsaxhandler.tex,1.1,1.2 Message-ID: <200012042204.OAA26596@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv26556/lib Modified Files: xmlsaxhandler.tex Log Message: Added a comment for ContentHandler.characters() explaining how to migrate SAX1 code to SAX2, based on bug #123695. Index: xmlsaxhandler.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmlsaxhandler.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** xmlsaxhandler.tex 2000/10/12 20:05:09 1.1 --- xmlsaxhandler.tex 2000/12/04 22:04:15 1.2 *************** *** 256,259 **** --- 256,267 ---- \var{content} may be a Unicode string or a byte string; the \code{expat} reader module produces always Unicode strings. + + \strong{Note:} The earlier SAX 1 interface provided by the Python + XML Special Interest Group used a more Java-like interface for this + method. Since most parsers used from Python did not take advatage + of the older interface, the simpler signature was chosen to replace + it. To convert old code to the new interface, use \var{content} + instead of slicing content with the old \var{offset} and + \var{lenght} parameters. \end{methoddesc} From python-dev@python.org Mon Dec 4 22:29:20 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 4 Dec 2000 14:29:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib xmlsaxhandler.tex,1.2,1.3 Message-ID: <200012042229.OAA29741@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv29719/Doc/lib Modified Files: xmlsaxhandler.tex Log Message: Two typos caught by /F; thanks! Index: xmlsaxhandler.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmlsaxhandler.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** xmlsaxhandler.tex 2000/12/04 22:04:15 1.2 --- xmlsaxhandler.tex 2000/12/04 22:29:17 1.3 *************** *** 259,267 **** \strong{Note:} The earlier SAX 1 interface provided by the Python XML Special Interest Group used a more Java-like interface for this ! method. Since most parsers used from Python did not take advatage of the older interface, the simpler signature was chosen to replace it. To convert old code to the new interface, use \var{content} instead of slicing content with the old \var{offset} and ! \var{lenght} parameters. \end{methoddesc} --- 259,267 ---- \strong{Note:} The earlier SAX 1 interface provided by the Python XML Special Interest Group used a more Java-like interface for this ! method. Since most parsers used from Python did not take advantage of the older interface, the simpler signature was chosen to replace it. To convert old code to the new interface, use \var{content} instead of slicing content with the old \var{offset} and ! \var{length} parameters. \end{methoddesc} From python-dev@python.org Tue Dec 5 03:16:36 2000 From: python-dev@python.org (Neil Schemenauer) Date: Mon, 4 Dec 2000 19:16:36 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.53,1.54 Message-ID: <200012050316.TAA28626@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv28587 Modified Files: pep-0000.txt Log Message: Make Neil Schemenauer the owner of 208. Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -r1.53 -r1.54 *** pep-0000.txt 2000/12/02 03:38:48 1.53 --- pep-0000.txt 2000/12/05 03:16:33 1.54 *************** *** 34,38 **** SD 205 pep-0205.txt Weak References Drake S 207 pep-0207.txt Rich Comparisons Lemburg, van Rossum ! S 208 pep-0208.txt Reworking the Coercion Model Ascher, Zadka S 217 pep-0217.txt Display Hook for Interactive Use Zadka S 222 pep-0222.txt Web Library Enhancements Kuchling --- 34,38 ---- SD 205 pep-0205.txt Weak References Drake S 207 pep-0207.txt Rich Comparisons Lemburg, van Rossum ! S 208 pep-0208.txt Reworking the Coercion Model Schemenauer S 217 pep-0217.txt Display Hook for Interactive Use Zadka S 222 pep-0222.txt Web Library Enhancements Kuchling *************** *** 155,158 **** --- 155,159 ---- Raymond, Eric esr@snark.thyrsus.com van Rossum, Guido guido@python.org + Schemenauer, Neil nas@arctrix.com Schneider-Kamp, Peter nownder@nowonder.de Warsaw, Barry barry@digicool.com From python-dev@python.org Tue Dec 5 03:17:11 2000 From: python-dev@python.org (Neil Schemenauer) Date: Mon, 4 Dec 2000 19:17:11 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0208.txt,1.3,1.4 Message-ID: <200012050317.TAA28678@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv28644 Modified Files: pep-0208.txt Log Message: Add some meat to the PEP (mostly from Marc-Andre's web page). Index: pep-0208.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0208.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** pep-0208.txt 2000/11/28 22:23:25 1.3 --- pep-0208.txt 2000/12/05 03:17:08 1.4 *************** *** 2,8 **** Title: Reworking the Coercion Model Version: $Revision$ ! Author: davida@activestate.com (David Ascher), pep@zadka.site.co.il (Moshe Zadka) Python-Version: 2.1 ! Status: Incomplete --- 2,211 ---- Title: Reworking the Coercion Model Version: $Revision$ ! Author: Neil Schemenauer ! Status: Draft ! Type: Standards Track ! Created: 04-Dec-2000 ! Post-History: Python-Version: 2.1 ! ! ! Abstract ! ! Many Python types implement numeric operations. When the arguments of ! a numeric operation are of different types, the interpreter tries to ! coerce the arguments into a common type. The numeric operation is ! then performed using this common type. This PEP proposes a new type ! flag to indicate that arguments to a type's numeric operations should ! not be coerced. Operations that do not support the supplied types ! indicate it by returning a new singleton object. Types which do not ! set the type flag are handled in a backwards compatible manner. ! Allowing operations handle different types is often simpler, more ! flexible, and faster then having the interpreter do coercion. ! ! ! Rational ! ! When implementing numeric or other related operations, it is often ! desirable to provide not only operations between operands of one type ! only, e.g. integer + integer, but to generalize the idea behind the ! operation to other type combinations as well, e.g. integer + float. ! ! A common approach to this mixed type situation is to provide a method ! of "lifting" the operands to a common type (coercion) and then use ! that type's operand method as execution mechanism. Yet, this strategy ! has a few drawbacks: ! ! * the "lifting" process creates at least one new (temporary) ! operand object, ! ! * since the coercion method is not being told about the operation ! that is to follow, it is not possible to implement operation ! specific coercion of types, ! ! * there is no elegant way to solve situations were a common type ! is not at hand, and ! ! * the coercion method will always have to be called prior to the ! operation's method itself. ! ! A fix for this situation is obviously needed, since these drawbacks ! make implementations of types needing these features very cumbersome, ! if not impossible. As an example, have a look at the DateTime and ! DateTimeDelta[1] types, the first being absolute, the second ! relative. You can always add a relative value to an absolute one, ! giving a new absolute value. Yet, there is no common type which the ! existing coercion mechanism could use to implement that operation. ! ! Currently, PyInstance types are treated specially by the interpreter ! in that their numeric methods are passed arguments of different types. ! Removing this special case simplifies the interpreter and allows other ! types to implement numeric methods that behave like instance types. ! This is especially useful for extension types like ExtensionClass. ! ! ! Specification ! ! Instead of using a central coercion method, the process of handling ! different operand types is simply left to the operation. If the ! operation finds that it cannot handle the given operand type ! combination, it may return a special singleton as indicator. ! ! Note that "numbers" (anything that implements the number protocol, or ! part of it) written in Python already use the first part of this ! strategy - it is the C level API that we focus on here. ! ! To maintain nearly 100% backward compatibility we have to be very ! careful to make numbers that don't know anything about the new ! strategy (old style numbers) work just as well as those that expect ! the new scheme (new style numbers). Furthermore, binary compatibility ! is a must, meaning that the interpreter may only access and use new ! style operations if the number indicates the availability of these. ! ! A new style number is considered by the interpreter as such if and ! only it it sets the type flag Py_TPFLAGS_NEWSTYLENUMBER. The main ! difference between an old style number and a new style one is that the ! numeric slot functions can no longer assume to be passed arguments of ! identical type. New style slots must check all arguments for proper ! type and implement the necessary conversions themselves. This may seem ! to cause more work on the behalf of the type implementor, but is in ! fact no more difficult than writing the same kind of routines for an ! old style coercion slot. ! ! If a new style slot finds that it cannot handle the passed argument ! type combination, it may return a new reference of the special ! singleton Py_NotImplemented to the caller. This will cause the caller ! to try the other operands operation slots until it finds a slot that ! does implement the operation for the specific type combination. If ! none of the possible slots succeed, it raises a TypeError. ! ! To make the implementation easy to understand (the whole topic is ! esoteric enough), a new layer in the handling of numeric operations is ! introduced. This layer takes care of all the different cases that need ! to be taken into account when dealing with all the possible ! combinations of old and new style numbers. It is implemented by the ! two functions _PyNumber_BinaryOperation() and ! _PyNumber_TernaryOperation(), which both are internal functions that ! only the functions in Objects/abstract.c have access to. The numeric ! API (PyNumber_*) is easy to adapt to this new layer. ! ! As a side-effect all numeric slots can be NULL-checked (this has to be ! done anyway, so the added feature comes at no extra cost). ! ! ! The scheme used by the layer to execute a binary operation is as ! follows: ! ! v | w | Action taken ! ---------+------------+---------------------------------- ! new | new | v.op(v,w), w.op(v,w) ! new | old | v.op(v,w), coerce(v,w), v.op(v,w) ! old | new | w.op(v,w), coerce(v,w), v.op(v,w) ! old | old | coerce(v,w), v.op(v,w) ! ! The indicated action sequence is executed from left to right until ! either the operation succeeds and a valid result (!= ! Py_NotImplemented) is returned or an exception is raised. Exceptions ! are returned to the calling function as-is. If a slot returns ! Py_NotImplemented, the next item in the sequence is executed. ! ! Note that coerce(v,w) will use the old style nb_coerce slot methods ! via a call to PyNumber_Coerce(). ! ! Ternary operations have a few more cases to handle: ! ! v | w | z | Action taken ! ----+-----+-----+------------------------------------ ! new | new | new | v.op(v,w,z), w.op(v,w,z), z.op(v,w,z) ! new | old | new | v.op(v,w,z), z.op(v,w,z), coerce(v,w,z), v.op(v,w,z) ! old | new | new | w.op(v,w,z), z.op(v,w,z), coerce(v,w,z), v.op(v,w,z) ! old | old | new | z.op(v,w,z), coerce(v,w,z), v.op(v,w,z) ! new | new | old | v.op(v,w,z), w.op(v,w,z), coerce(v,w,z), v.op(v,w,z) ! new | old | old | v.op(v,w,z), coerce(v,w,z), v.op(v,w,z) ! old | new | old | w.op(v,w,z), coerce(v,w,z), v.op(v,w,z) ! old | old | old | coerce(v,w,z), v.op(v,w,z) ! ! The same notes as above, except that coerce(v,w,z) actually does: ! ! if z != Py_None: ! coerce(v,w), coerce(v,z), coerce(w,z) ! else: ! # treat z as absent variable ! coerce(v,w) ! ! ! The current implementation uses this scheme already (there's only one ! ternary slot: nb_pow(a,b,c)). ! ! Note that the numeric protocol is also used for some other related ! tasks, e.g. sequence concatenation. These can also benefit from the ! new mechanism by implementing right-hand operations for type ! combinations that would otherwise fail to work. As an example, take ! string concatenation: currently you can only do string + string. With ! the new mechanism, a new string-like type could implement new_type + ! string and string + new_type, even though strings don't know anything ! about new_type. ! ! Since comparisons also rely on coercion (every time you compare an ! integer to a float, the integer is first converted to float and then ! compared...), a new slot to handle numeric comparisons is needed: ! ! PyObject *nb_cmp(PyObject *v, PyObject *w) ! ! This slot should compare the two objects and return an integer object ! stating the result. Currently, this result integer may only be -1, 0, ! 1. If the slot cannot handle the type combination, it may return a ! reference to Py_NotImplemented. Note that this slot is still in flux ! since it should take into account rich comparisons (ie. PEP 207). ! ! Numeric comparisons are handled by a new numeric protocol API: ! ! PyObject *PyNumber_Compare(PyObject *v, PyObject *w) ! ! This function compare the two objects as "numbers" and return an ! integer object stating the result. Currently, this result integer may ! only be -1, 0, 1. In case the operation cannot be handled by the given ! objects, a TypeError is raised. ! ! The PyObject_Compare() API needs to adjusted accordingly to make use ! of this new API. ! ! Other changes include adapting some of the built-in functions (e.g. ! cmp()) to use this API as well. Also, PyNumber_CoerceEx() will need to ! check for new style numbers before calling the nb_coerce slot. New ! style numbers don't provide a coercion slot and thus cannot be ! explicitly coerced. ! ! ! Reference Implementation ! ! A preliminary patch for the CVS version of Python is available through ! the Source Forge patch manager[2]. ! ! ! References ! ! [1] http://www.lemburg.com/files/python/mxDateTime.html ! [2] http://sourceforge.net/patch/download.php?id=102652 ! From python-dev@python.org Tue Dec 5 03:31:15 2000 From: python-dev@python.org (Neil Schemenauer) Date: Mon, 4 Dec 2000 19:31:15 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.54,1.55 Message-ID: <200012050331.TAA29515@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv29447 Modified Files: pep-0000.txt Log Message: Update some names in the numerical index to be consistent with the PEPs themselves. Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -r1.54 -r1.55 *** pep-0000.txt 2000/12/05 03:16:33 1.54 --- pep-0000.txt 2000/12/05 03:31:13 1.55 *************** *** 103,108 **** SD 205 pep-0205.txt Weak References Drake I 206 pep-0206.txt 2.0 Batteries Included Zadka ! S 207 pep-0207.txt Rich Comparisons Zadka, Lemburg ! S 208 pep-0208.txt Reworking the Coercion Model Ascher SD 209 pep-0209.txt Adding Multidimensional Arrays Ascher SD 210 pep-0210.txt Decoupling the Interpreter Loop Ascher --- 103,108 ---- SD 205 pep-0205.txt Weak References Drake I 206 pep-0206.txt 2.0 Batteries Included Zadka ! S 207 pep-0207.txt Rich Comparisons Lemburg, van Rossum ! S 208 pep-0208.txt Reworking the Coercion Model Schemenauer SD 209 pep-0209.txt Adding Multidimensional Arrays Ascher SD 210 pep-0210.txt Decoupling the Interpreter Loop Ascher From python-dev@python.org Tue Dec 5 15:05:17 2000 From: python-dev@python.org (Neil Schemenauer) Date: Tue, 5 Dec 2000 07:05:17 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0208.txt,1.4,1.5 Message-ID: <200012051505.HAA07133@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv7041 Modified Files: pep-0208.txt Log Message: - give credit where due - add copyright section Index: pep-0208.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0208.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** pep-0208.txt 2000/12/05 03:17:08 1.4 --- pep-0208.txt 2000/12/05 15:05:14 1.5 *************** *** 203,210 **** --- 203,222 ---- + Credits + + This PEP and the patch are heavily based on work done by Marc-André + Lemburg[3]. + + + Copyright + + This document has been placed in the public domain. + + References [1] http://www.lemburg.com/files/python/mxDateTime.html [2] http://sourceforge.net/patch/download.php?id=102652 + [3] http://www.lemburg.com/files/python/CoercionProposal.html From python-dev@python.org Wed Dec 6 10:38:00 2000 From: python-dev@python.org (Sjoerd Mullender) Date: Wed, 6 Dec 2000 02:38:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib xmllib.py,1.23,1.24 Message-ID: <200012061038.CAA19417@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv19399 Modified Files: xmllib.py Log Message: Two changes: - Use new Error class (subclass of RuntimeError so is backward compatible) which is raised when RuntimeError used to be raised. - Report original attribute name in error messages instead of name mangled with namespace URL. Index: xmllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmllib.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** xmllib.py 2000/08/31 10:26:52 1.23 --- xmllib.py 2000/12/06 10:37:57 1.24 *************** *** 9,12 **** --- 9,15 ---- version = '0.3' + class Error(RuntimeError): + pass + # Regular expressions used for parsing *************** *** 310,314 **** 'standalone') if version[1:-1] != '1.0': ! raise RuntimeError, 'only XML version 1.0 supported' if encoding: encoding = encoding[1:-1] if standalone: standalone = standalone[1:-1] --- 313,317 ---- 'standalone') if version[1:-1] != '1.0': ! raise Error('only XML version 1.0 supported') if encoding: encoding = encoding[1:-1] if standalone: standalone = standalone[1:-1] *************** *** 391,395 **** continue else: ! raise RuntimeError, 'neither < nor & ??' # We get here only if incomplete matches but # nothing else --- 394,398 ---- continue else: ! raise Error('neither < nor & ??') # We get here only if incomplete matches but # nothing else *************** *** 420,424 **** rawdata = self.rawdata if rawdata[i:i+4] <> ' The Index: libcfgparser.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcfgparser.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** libcfgparser.tex 2000/09/27 22:48:44 1.14 --- libcfgparser.tex 2000/12/07 00:03:24 1.15 *************** *** 46,50 **** Return a new instance of the \class{ConfigParser} class. When \var{defaults} is given, it is initialized into the dictionary of ! intrinsic defaults. They keys must be strings, and the values must be appropriate for the \samp{\%()s} string interpolation. Note that \var{__name__} is an intrinsic default; its value is the section name, --- 46,50 ---- Return a new instance of the \class{ConfigParser} class. When \var{defaults} is given, it is initialized into the dictionary of ! intrinsic defaults. The keys must be strings, and the values must be appropriate for the \samp{\%()s} string interpolation. Note that \var{__name__} is an intrinsic default; its value is the section name, From python-dev@python.org Thu Dec 7 00:06:49 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 6 Dec 2000 16:06:49 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc ACKS,1.10,1.11 Message-ID: <200012070006.QAA25739@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv25727 Modified Files: ACKS Log Message: Another name! Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ACKS,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** ACKS 2000/11/30 07:09:59 1.10 --- ACKS 2000/12/07 00:06:46 1.11 *************** *** 146,149 **** --- 146,150 ---- Mark Summerfield Reuben Sumner + Jim Tittsler Martijn Vries Charles G. Waldman From python-dev@python.org Thu Dec 7 04:47:54 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 6 Dec 2000 20:47:54 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib xmldom.tex,1.2,1.3 xmldomminidom.tex,1.1,1.2 Message-ID: <200012070447.UAA11641@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv11629/lib Modified Files: xmldom.tex xmldomminidom.tex Log Message: Lots of additional information. Not done, but much better. Index: xmldom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmldom.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** xmldom.tex 2000/11/29 06:10:22 1.2 --- xmldom.tex 2000/12/07 04:47:51 1.3 *************** *** 90,95 **** The definitive documentation for the DOM is the DOM specification from ! the W3C. This section lists the properties and methods supported by ! \refmodule{xml.dom.minidom}. Note that DOM attributes may also be manipulated as nodes instead of --- 90,94 ---- The definitive documentation for the DOM is the DOM specification from ! the W3C. Note that DOM attributes may also be manipulated as nodes instead of *************** *** 99,104 **** --- 98,109 ---- \begin{tableiii}{l|l|l}{class}{Interface}{Section}{Purpose} + \lineiii{DOMImplementation}{\ref{dom-implementation-objects}} + {Interface to the underlying implementation.} \lineiii{Node}{\ref{dom-node-objects}} {Base interface for most objects in a document.} + \lineiii{NodeList}{\ref{dom-nodelist-objects}} + {Interface for a sequence of nodes.} + \lineiii{DocumentType}{\ref{dom-documenttype-objects}} + {Information about the declarations needed to process a document.} \lineiii{Document}{\ref{dom-document-objects}} {Object which represents an entire document.} *************** *** 116,119 **** --- 121,137 ---- + \subsubsection{DOMImplementation Objects + \label{dom-implementation-objects}} + + The \class{DOMImplementation} interface provides a way for + applications to determine the availability of particular features in + the DOM they are using. DOM Level 2 added the ability to create new + \class{Document} and \class{DocumentType} objects using the + \class{DOMImplementation} as well. + + \begin{methoddesc}[DOMImplementation]{hasFeature}{feature, version} + \end{methoddesc} + + \subsubsection{Node Objects \label{dom-node-objects}} *************** *** 132,136 **** \begin{memberdesc}[Node]{parentNode} ! The parent of the current node. \code{None} for the document node. \end{memberdesc} --- 150,158 ---- \begin{memberdesc}[Node]{parentNode} ! The parent of the current node, or \code{None} for the document node. ! The value is always a \class{Node} object or \code{None}. For ! \class{Element} nodes, this will be the parent element, except for the ! root element, in which case it will be the \class{Document} object. ! For \class{Attr} nodes, this is always \code{None}. \end{memberdesc} *************** *** 145,154 **** \var{self} element's start-tag. Of course, XML documents are made up of more than just elements so the previous sibling could be text, a ! comment, or something else. \end{memberdesc} \begin{memberdesc}[Node]{nextSibling} The node that immediately follows this one with the same parent. See ! also \member{previousSibling}. \end{memberdesc} --- 167,178 ---- \var{self} element's start-tag. Of course, XML documents are made up of more than just elements so the previous sibling could be text, a ! comment, or something else. If this node is the first child of the ! parent, this attribute will be \code{None}. \end{memberdesc} \begin{memberdesc}[Node]{nextSibling} The node that immediately follows this one with the same parent. See ! also \member{previousSibling}. If this is the last child of the ! parent, this attribute will be \code{None}. \end{memberdesc} *************** *** 165,173 **** \end{memberdesc} \begin{memberdesc}[Node]{nodeName} Has a different meaning for each node type. See the DOM specification for details. You can always get the information you would get here from another property such as the \member{tagName} property for ! elements or the \member{name} property for attributes. \end{memberdesc} --- 189,204 ---- \end{memberdesc} + \begin{memberdesc}[Element]{namespaceURI} + The namespace associated with the element name. This will be a + string. + \end{memberdesc} + \begin{memberdesc}[Node]{nodeName} Has a different meaning for each node type. See the DOM specification for details. You can always get the information you would get here from another property such as the \member{tagName} property for ! elements or the \member{name} property for attributes. For all node ! types, the value of this attribute will be either a string or ! \code{None}. \end{memberdesc} *************** *** 214,225 **** \begin{methoddesc}[Node]{cloneNode}{deep} Clone this node. Setting \var{deep} means to clone all child nodes as ! well. ! \strong{Warning:} Although this method was present in the version of ! \refmodule{xml.dom.minidom} packaged with Python 2.0, it was seriously ! broken. This has been corrected for subsequent releases. \end{methoddesc} \subsubsection{Document Objects \label{dom-document-objects}} --- 245,334 ---- \begin{methoddesc}[Node]{cloneNode}{deep} Clone this node. Setting \var{deep} means to clone all child nodes as ! well. This returns the clone. ! \end{methoddesc} ! ! ! \subsubsection{NodeList Objects \label{dom-nodelist-objects}} ! ! A \class{NodeList} represents a sequence of nodes. These objects are ! used in two ways in the DOM Core recommendation: the ! \class{Element} objects provides one as it's list of child nodes, and ! the \method{getElementsByTagName()} and ! \method{getElementsByTagNameNS()} methods of \class{Node} return ! objects with this interface to represent query results. ! The DOM Level 2 recommendation defines one method and one attribute ! for these objects: ! ! \begin{methoddesc}[NodeList]{item}{i} ! Return the \var{i}'th item from the sequence, if there is one, or ! \code{None}. The index \var{i} is not allowed to be less then zero ! or greater than or equal to the length of the sequence. \end{methoddesc} + \begin{memberdesc}[NodeList]{length} + The number of nodes in the sequence. + \end{memberdesc} + + In addition, the Python DOM interface requires that some additional + support is provided to allow \class{NodeList} objects to be used as + Python sequences. All \class{NodeList} implementations must include + support for \method{__len__()} and \method{__getitem__()}; this allows + iteration over the \class{NodeList} in \keyword{for} statements and + proper support for the \function{len()} built-in function. + + If a DOM implementation supports modification of the document, the + \class{NodeList} implementation must also support the + \method{__setitem__()} and \method{__delitem__()} methods. + + + \subsubsection{DocumentType Objects \label{dom-documenttype-objects}} + + Information about the notations and entities declared by a document + (including the external subset if the parser uses it and can provide + the information) is available from a \class{DocumentType} object. The + \class{DocumentType} for a document is available from the + \class{Document} object's \member{doctype} attribute. + + \class{DocumentType} is a specialization of \class{Node}, and adds the + following attributes: + + \begin{memberdesc}[DocumentType]{publicId} + The public identifier for the external subset of the document type + definition. This will be a string or \code{None}. + \end{memberdesc} + + \begin{memberdesc}[DocumentType]{systemId} + The system identifier for the external subset of the document type + definition. This will be a URI as a string, or \code{None}. + \end{memberdesc} + + \begin{memberdesc}[DocumentType]{internalSubset} + A string giving the complete internal subset from the document. + \end{memberdesc} + + \begin{memberdesc}[DocumentType]{name} + The name of the root element as given in the \code{DOCTYPE} + declaration, if present. If the was no \code{DOCTYPE} declaration, + this will be \code{None}. + \end{memberdesc} + + \begin{memberdesc}[DocumentType]{entities} + This is a \class{NamedNodeMap} giving the definitions of external + entities. For entity names defined more than once, only the first + definition is provided (others are ignored as required by the XML + recommendation). This may be \code{None} if the information is not + provided by the parser, or if no entities are defined. + \end{memberdesc} + + \begin{memberdesc}[DocumentType]{notations} + This is a \class{NamedNodeMap} giving the definitions of notations. + For notation names defined more than once, only the first definition + is provided (others are ignored as required by the XML + recommendation). This may be \code{None} if the information is not + provided by the parser, or if no notations are defined. + \end{memberdesc} + \subsubsection{Document Objects \label{dom-document-objects}} *************** *** 233,270 **** \begin{methoddesc}[Document]{createElement}{tagName} ! Create a new element. The element is not inserted into the document ! when it is created. You need to explicitly insert it with one of the ! other methods such as \method{insertBefore()} or \method{appendChild()}. \end{methoddesc} \begin{methoddesc}[Document]{createElementNS}{namespaceURI, tagName} ! Create a new element with a namespace. The \var{tagName} may have a ! prefix. The element is not inserted into the document when it is ! created. You need to explicitly insert it with one of the other ! methods such as \method{insertBefore()} or \method{appendChild()}. \end{methoddesc} \begin{methoddesc}[Document]{createTextNode}{data} ! Create a text node containing the data passed as a parameter. As with ! the other creation methods, this one does not insert the node into the ! tree. \end{methoddesc} \begin{methoddesc}[Document]{createComment}{data} ! Create a comment node containing the data passed as a parameter. As ! with the other creation methods, this one does not insert the node ! into the tree. \end{methoddesc} \begin{methoddesc}[Document]{createProcessingInstruction}{target, data} ! Create a processing instruction node containing the \var{target} and ! \var{data} passed as parameters. As with the other creation methods, ! this one does not insert the node into the tree. \end{methoddesc} \begin{methoddesc}[Document]{createAttribute}{name} ! Create an attribute node. This method does not associate the ! attribute node with any particular element. You must use \method{setAttributeNode()} on the appropriate \class{Element} object to use the newly created attribute instance. --- 342,380 ---- \begin{methoddesc}[Document]{createElement}{tagName} ! Create and return a new element node. The element is not inserted ! into the document when it is created. You need to explicitly insert ! it with one of the other methods such as \method{insertBefore()} or \method{appendChild()}. \end{methoddesc} \begin{methoddesc}[Document]{createElementNS}{namespaceURI, tagName} ! Create and return a new element with a namespace. The ! \var{tagName} may have a prefix. The element is not inserted into the ! document when it is created. You need to explicitly insert it with ! one of the other methods such as \method{insertBefore()} or ! \method{appendChild()}. \end{methoddesc} \begin{methoddesc}[Document]{createTextNode}{data} ! Create and return a text node containing the data passed as a ! parameter. As with the other creation methods, this one does not ! insert the node into the tree. \end{methoddesc} \begin{methoddesc}[Document]{createComment}{data} ! Create and return a comment node containing the data passed as a ! parameter. As with the other creation methods, this one does not ! insert the node into the tree. \end{methoddesc} \begin{methoddesc}[Document]{createProcessingInstruction}{target, data} ! Create and return a processing instruction node containing the ! \var{target} and \var{data} passed as parameters. As with the other ! creation methods, this one does not insert the node into the tree. \end{methoddesc} \begin{methoddesc}[Document]{createAttribute}{name} ! Create and return an attribute node. This method does not associate ! the attribute node with any particular element. You must use \method{setAttributeNode()} on the appropriate \class{Element} object to use the newly created attribute instance. *************** *** 272,280 **** \begin{methoddesc}[Document]{createAttributeNS}{namespaceURI, qualifiedName} ! Create an attribute node with a namespace. The \var{tagName} may have ! a prefix. This method does not associate the attribute node with any ! particular element. You must use \method{setAttributeNode()} on the ! appropriate \class{Element} object to use the newly created attribute ! instance. \end{methoddesc} --- 382,390 ---- \begin{methoddesc}[Document]{createAttributeNS}{namespaceURI, qualifiedName} ! Create and return an attribute node with a namespace. The ! \var{tagName} may have a prefix. This method does not associate the ! attribute node with any particular element. You must use ! \method{setAttributeNode()} on the appropriate \class{Element} object ! to use the newly created attribute instance. \end{methoddesc} *************** *** 298,316 **** \begin{memberdesc}[Element]{tagName} The element type name. In a namespace-using document it may have ! colons in it. \end{memberdesc} \begin{memberdesc}[Element]{localName} The part of the \member{tagName} following the colon if there is one, ! else the entire \member{tagName}. \end{memberdesc} \begin{memberdesc}[Element]{prefix} The part of the \member{tagName} preceding the colon if there is one, ! else the empty string. ! \end{memberdesc} ! ! \begin{memberdesc}[Element]{namespaceURI} ! The namespace associated with the tagName. \end{memberdesc} --- 408,422 ---- \begin{memberdesc}[Element]{tagName} The element type name. In a namespace-using document it may have ! colons in it. The value is a string. \end{memberdesc} \begin{memberdesc}[Element]{localName} The part of the \member{tagName} following the colon if there is one, ! else the entire \member{tagName}. The value is a string. \end{memberdesc} \begin{memberdesc}[Element]{prefix} The part of the \member{tagName} preceding the colon if there is one, ! else the empty string. The value is a string, or \code{None} \end{memberdesc} *************** *** 319,322 **** --- 425,432 ---- \end{methoddesc} + \begin{methoddesc}[Element]{getAttributeNode}{attrname} + Return the \class{Attr} node for the attribute named by \var{attrname} + \end{methoddesc} + \begin{methoddesc}[Element]{setAttribute}{attname, value} Set an attribute value from a string. *************** *** 440,446 **** IDL mapping for Python. \subsubsection{Type Mapping \label{dom-type-mapping}} - XXX Explain what a \class{DOMString} maps to... \subsubsection{Accessor Methods \label{dom-accessor-methods}} --- 550,574 ---- IDL mapping for Python. + \subsubsection{Type Mapping \label{dom-type-mapping}} + + The primitive IDL types used in the DOM specification are mapped to + Python types according to the following table. + + \begin{tableii}{l|l}{code}{IDL Type}{Python Type} + \lineii{boolean}{\code{IntegerType} (with a value of \code{0} or \code{1})} + \lineii{int}{\code{IntegerType}} + \lineii{long int}{\code{IntegerType}} + \lineii{unsigned int}{\code{IntegerType}} + \end{tableii} + + Additionally, the \class{DOMString} defined in the recommendation is + mapped to a Python string or Unicode string. Applications should + be able to handle Unicode whenever a string is returned from the DOM. + + The IDL \keyword{null} value is mapped to \code{None}, which may be + accepted or provided by the implementation whenever \keyword{null} is + allowed by the API. \subsubsection{Accessor Methods \label{dom-accessor-methods}} *************** *** 477,479 **** they should take the form defined by the Python IDL mapping, but these methods are considered unnecessary since the attributes are ! accessible directly from Python. --- 605,608 ---- they should take the form defined by the Python IDL mapping, but these methods are considered unnecessary since the attributes are ! accessible directly from Python. ``Set'' accessors should never be ! provided for \keyword{readonly} attributes. Index: xmldomminidom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmldomminidom.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** xmldomminidom.tex 2000/11/29 06:10:22 1.1 --- xmldomminidom.tex 2000/12/07 04:47:51 1.2 *************** *** 262,268 **** list type, so don't support the official API, but are much more ``Pythonic.'' - - \item \class{NamedNodeMap} is implemented by the class - \class{AttributeList}. This should not impact user code. \end{itemize} --- 262,265 ---- *************** *** 274,280 **** \item DOMTimeStamp ! \item DocumentType (added for Python 2.1) ! \item DOMImplementation (added for Python 2.1) \item CharacterData --- 271,277 ---- \item DOMTimeStamp ! \item DocumentType (added in Python 2.1) ! \item DOMImplementation (added in Python 2.1) \item CharacterData From python-dev@python.org Thu Dec 7 04:49:36 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 6 Dec 2000 20:49:36 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref3.tex,1.52,1.53 Message-ID: <200012070449.UAA11761@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/ref In directory slayer.i.sourceforge.net:/tmp/cvs-serv11753/ref Modified Files: ref3.tex Log Message: Added a note that objects which emulate built-in types should only implement as many of the relevant methods as make sense for the particular information being modelled. Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -r1.52 -r1.53 *** ref3.tex 2000/09/21 22:27:16 1.52 --- ref3.tex 2000/12/07 04:49:34 1.53 *************** *** 842,845 **** --- 842,852 ---- \withsubitem{(mapping object method)}{\ttindex{__getitem__()}} + When implementing a class that emulates any built-in type, it is + important that the emulation only be implemented to the degree that it + makes sense for the object being modelled. For example, some + sequences may work well with retrieval of individual elements, but + extracting a slice may not make sense. (One example of this is the + \class{NodeList} interface in the W3C's Document Object Model.) + \subsection{Basic customization\label{customization}} From python-dev@python.org Thu Dec 7 04:54:05 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 6 Dec 2000 20:54:05 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref5.tex,1.38,1.39 Message-ID: <200012070454.UAA12047@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/ref In directory slayer.i.sourceforge.net:/tmp/cvs-serv12032/ref Modified Files: ref5.tex Log Message: Fix error noted by Gerrit Holl (old; had been buried in my INBOX): sequence repitition works just fine with long integers now, so we should not say that only plain integers are allowed. Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -r1.38 -r1.39 *** ref5.tex 2000/09/19 18:10:05 1.38 --- ref5.tex 2000/12/07 04:54:02 1.39 *************** *** 569,575 **** The \code{*} (multiplication) operator yields the product of its arguments. The arguments must either both be numbers, or one argument ! must be a plain integer and the other must be a sequence. In the ! former case, the numbers are converted to a common type and then ! multiplied together. In the latter case, sequence repetition is performed; a negative repetition factor yields an empty sequence. \index{multiplication} --- 569,575 ---- The \code{*} (multiplication) operator yields the product of its arguments. The arguments must either both be numbers, or one argument ! must be an integer (plain or long) and the other must be a sequence. ! In the former case, the numbers are converted to a common type and ! then multiplied together. In the latter case, sequence repetition is performed; a negative repetition factor yields an empty sequence. \index{multiplication} From python-dev@python.org Thu Dec 7 17:38:53 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 7 Dec 2000 09:38:53 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0230.txt,1.1,1.2 Message-ID: <200012071738.JAA25014@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv24990 Modified Files: pep-0230.txt Log Message: First stab at the Warnings PEP. I'm still working on the implementation... Index: pep-0230.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0230.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** pep-0230.txt 2000/11/28 22:23:25 1.1 --- pep-0230.txt 2000/12/07 17:38:50 1.2 *************** *** 20,23 **** --- 20,351 ---- + Motivation + + With Python 3000 looming, it is necessary to start issuing + warnings about the use of obsolete or deprecated features, in + addition to errors. There are also lots of other reasons to be + able to issue warnings, both from C and from Python code, both at + compile time and at run time. + + Warnings aren't fatal, and thus it's possible that a program + triggers the same warning many times during a single execution. + It would be annoying if a program emitted an endless stream of + identical warnings. Therefore, a mechanism is needed that + suppresses multiple identical warnings. + + It is also desirable to have user control over which warnings are + printed. While in general it is useful to see all warnings all + the time, there may be times where it is impractical to fix the + code right away in a production program. In this case, there + should be a way to suppress warnings. + + It is also useful to be able to suppress specific warnings during + program development, e.g. when a warning is generated by a piece + of 3rd party code that cannot be fixed right away, or when there + is no way to fix the code (possibly a warning message is generated + for a perfectly fine piece of code). It would be unwise to offer + to suppress all warnings in such cases: the developer would miss + warnings about the rest of the code. + + On the other hand, there are also situations conceivable where + some or all warnings are better treated as errors. For example, + it may be a local coding standard that a particular deprecated + feature should not be used. In order to enforce this, it is + useful to be able to turn the warning about this particular + feature into an error, raising an exception (without necessarily + turning all warnings into errors). + + Therefore, I propose to introduce a flexible "warning filter" + which can filter out warnings or change them into exceptions, + based on: + + - Where in the code they are generated (per package, module, or + function) + + - The warning category (warning categories are discussed below) + + - A specific warning message + + The warning filter must be controllable both from the command line + and from Python code. + + + APIs For Issuing Warnings + + - To issue a warning from Python: + + sys.warn(message[, category]) + + The category argument, if given, must be a warning category + class (see below); it defaults to warnings.UserWarning. This + may raise an exception if the particular warning issued is + changed into an error by the warnings filter. + + - To issue a warning from C: + + int Py_Warn(char *message, PyObject *category) + + Return 0 normally, 1 if an exception is raised. The category + argument must be a warning category class (see below). When + Py_Warn() function returns 1, the caller should do normal + exception handling. [Question: what about issuing warnings + during lexing or parsing, which don't have the exception + machinery available?] + + + Warnings Categories + + The "warnings" module defines classes representing warning + categories. This categorization is useful to be able to filter + out groups of warnings. The classes defined in this module have + no semantics attached to them and are never instantiated -- only + their names are used for filtering (see the section on the + warnings filter below). The following warnings category classes + are currently defined: + + - Warning -- this is the base class of all warning category + classes. A warning category must always be a subclass of this + class. + + - UserWarning -- the default category for sys.warn() + + - DeprecationWarning -- base category for warnings about deprecated + features + + - SyntaxWarning -- base category for warnings about dubious + syntactic features + + Other categories may be proposed during the review period for this + PEP. + + + The Warnings Filter + + The warnings filter control whether warnings are ignored, + displayed, or turned into errors (raising an exception). + + There are three sides to the warnings filter: + + - The data structures used to efficiently determine the + disposition of a particular Py_Warn() call. + + - The API to control the filter from Python source code. + + - The command line switches to control the filter. + + The warnings filter works in several stages. It is optimized for + the (expected to be common) case where the same warning is issued + from the same place in the code over and over. + + First, the warning filter collects the module and line number + where the warning is issued; this information is readily available + through PyEval_GetFrame(). + + Conceptually, the warnings filter maintains an ordered list of + filter specifications; any specific warning is matched against + each filter specification in the list in turn until a match is + found; the match determines the disposition of the match. Each + entry is a tuple as follows: + + (category, message, module, lineno, action) + + - category is a class (a subclass of warnings.Warning) of which + the warning category must be a subclass in order to match + + - message is a regular expression that the warning message must + match + + - module is a regular expression that the module name must match + + - lineno is an integer that the line number where the warning + occurred must match, or 0 to match all line numbers + + - action is one of the following strings: + + - "error" -- turn matching warnings into exceptions + + - "ignore" -- never print matching warnings + + - "always" -- always print matching warnings + + - "default" -- print the first occurrence of matching warnings + for each location where the warning is issued + + - "module" -- print the first occurrence of matching warnings + for each module where the warning is issued + + - "once" -- print only the first occurrence of matching + warnings + + The Warning class is derived from the built-in Exception class, so + that to turn a warning into an error we raise category(message). + + + The Warnings Output Hook + + When the warnings filter decides to issue a warning (but not when + it decides to raise an exception), it passes the information about + the function sys.showwarning(message, category, filename, lineno). + The default implementation of this function writes the warning text + to sys.stderr, and shows the source line of the filename. + + + TO DO + + - There should be a function sys.insertwarningfilter(message, + category, filename, lineno) that inserts items into the warnings + filter after some sanity checking. + + - There should be command line options to specify the most common + filtering actions, which I expect to include at least: + + - suppress all warnings + + - suppress a particular warning message everywhere + + - suppress all warnings in a particular module + + - turn all warnings into exceptions + + + Implementation + + Here is a mostly functional implementation: + + """Prototype implementation of sys.warn() and related stuff.""" + + import sys, re, linecache, getopt + + class Warning(Exception): + """Base class for warning categories. + + All warning categories must be subclasses of this. + """ + pass + + class UserWarning(Warning): + """Base class for warnings generated by user code.""" + pass + + class DeprecationWarning(Warning): + """Base class for warnings about deprecated features.""" + pass + + class SyntaxWarning(Warning): + """Base class for warnings about dubious syntax.""" + pass + + defaultaction = "default" + filter = [] + onceregistry = {} + + def warn(message, category=None, level=1): + """Issue a warning, or maybe ignore it or raise an exception.""" + # Check category argument + if category is None: + category = UserWarning + assert issubclass(category, Warning) + # Get context information + caller = sys._getframe(level) + globals = caller.f_globals + lineno = caller.f_lineno + module = globals['__name__'] + filename = globals.get('__file__') + if not filename: + if module == "__main__": + filename = sys.argv[0] + if not filename: + filename = module + # Quick test for common case + registry = globals.setdefault("__warningregistry__", {}) + key = (message, category, lineno) + if registry.get(key): + return + # Search the filter + for msg, cat, mod, ln, action in filter: + if (re.match(msg, message) and + issubclass(category, cat) and + re.match(mod, module) and + (ln == 0 or lineno == ln)): + break + else: + action = defaultaction + # Early exit actions + if action == "ignore": + registry[key] = 1 + return + if action == "error": + raise category(message) + # Other actions + if action == "once": + registry[key] = 1 + oncekey = (message, category) + if onceregistry.get(oncekey): + return + onceregistry[oncekey] = 1 + elif action == "always": + pass + elif action == "module": + registry[key] = 1 + altkey = (message, category, 0) + if registry.get(altkey): + return + registry[altkey] = 1 + elif action == "default": + registry[key] = 1 + else: + # Unrecognized actions are errors + raise RuntimeError( + "Unrecognized action (%s) in warnings.filter:\n %s" % + (`action`, str((cat, msg, mod, ln, action)))) + # Print message and context + showwarning(message, category, filename, lineno) + + def showwarning(message, category, filename, lineno): + print >>sys.stderr, "%s:%s: %s: %s" % (filename, lineno, + category.__name__, message) + line = linecache.getline(filename, lineno).strip() + if line: + print >>sys.stderr, " " + line + + def setupfilter(args): + """Set up the warnings filter based upon command line options. + + Return remaining command line arguments. + Raise getopt.error if an unrecognized option is found. + """ + opts, args = getopt.getop(args, "") + return args + + # Self-test + + def _test(): + hello = "hello world" + warn(hello) + warn(hello, UserWarning) + warn(hello, DeprecationWarning) + for i in range(3): + warn(hello) + filter.append(("", Warning, "", 0, "error")) + try: + warn(hello) + except Exception, msg: + print "Caught", msg.__class__.__name__ + ":", msg + else: + print "No exception" + filter[:] = [] + filter.append(("", Warning, "", 0, "booh")) + try: + warn(hello) + except Exception, msg: + print "Caught", msg.__class__.__name__ + ":", msg + else: + print "No exception" + + if __name__ == "__main__": + args = setupfilter(sys.argv[1:]) + _test() + + Local Variables: From python-dev@python.org Thu Dec 7 21:52:16 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 7 Dec 2000 13:52:16 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0230.txt,1.2,1.3 Message-ID: <200012072152.NAA25272@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv25254 Modified Files: pep-0230.txt Log Message: Revised version, completing a bunch of things that weren't resolved before. The implementation was removed from the PEP, it's now in the SF patch manager; I'm pretty happy with it! :-) Index: pep-0230.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0230.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** pep-0230.txt 2000/12/07 17:38:50 1.2 --- pep-0230.txt 2000/12/07 21:52:14 1.3 *************** *** 191,350 **** ! TO DO ! - There should be a function sys.insertwarningfilter(message, ! category, filename, lineno) that inserts items into the warnings ! filter after some sanity checking. ! - There should be command line options to specify the most common ! filtering actions, which I expect to include at least: ! - suppress all warnings ! - suppress a particular warning message everywhere ! - suppress all warnings in a particular module ! - turn all warnings into exceptions ! Implementation ! Here is a mostly functional implementation: ! """Prototype implementation of sys.warn() and related stuff.""" ! import sys, re, linecache, getopt ! class Warning(Exception): ! """Base class for warning categories. ! All warning categories must be subclasses of this. ! """ ! pass ! ! class UserWarning(Warning): ! """Base class for warnings generated by user code.""" ! pass ! ! class DeprecationWarning(Warning): ! """Base class for warnings about deprecated features.""" ! pass ! ! class SyntaxWarning(Warning): ! """Base class for warnings about dubious syntax.""" ! pass ! ! defaultaction = "default" ! filter = [] ! onceregistry = {} ! ! def warn(message, category=None, level=1): ! """Issue a warning, or maybe ignore it or raise an exception.""" ! # Check category argument ! if category is None: ! category = UserWarning ! assert issubclass(category, Warning) ! # Get context information ! caller = sys._getframe(level) ! globals = caller.f_globals ! lineno = caller.f_lineno ! module = globals['__name__'] ! filename = globals.get('__file__') ! if not filename: ! if module == "__main__": ! filename = sys.argv[0] ! if not filename: ! filename = module ! # Quick test for common case ! registry = globals.setdefault("__warningregistry__", {}) ! key = (message, category, lineno) ! if registry.get(key): ! return ! # Search the filter ! for msg, cat, mod, ln, action in filter: ! if (re.match(msg, message) and ! issubclass(category, cat) and ! re.match(mod, module) and ! (ln == 0 or lineno == ln)): ! break ! else: ! action = defaultaction ! # Early exit actions ! if action == "ignore": ! registry[key] = 1 ! return ! if action == "error": ! raise category(message) ! # Other actions ! if action == "once": ! registry[key] = 1 ! oncekey = (message, category) ! if onceregistry.get(oncekey): ! return ! onceregistry[oncekey] = 1 ! elif action == "always": ! pass ! elif action == "module": ! registry[key] = 1 ! altkey = (message, category, 0) ! if registry.get(altkey): ! return ! registry[altkey] = 1 ! elif action == "default": ! registry[key] = 1 ! else: ! # Unrecognized actions are errors ! raise RuntimeError( ! "Unrecognized action (%s) in warnings.filter:\n %s" % ! (`action`, str((cat, msg, mod, ln, action)))) ! # Print message and context ! showwarning(message, category, filename, lineno) ! ! def showwarning(message, category, filename, lineno): ! print >>sys.stderr, "%s:%s: %s: %s" % (filename, lineno, ! category.__name__, message) ! line = linecache.getline(filename, lineno).strip() ! if line: ! print >>sys.stderr, " " + line ! ! def setupfilter(args): ! """Set up the warnings filter based upon command line options. ! ! Return remaining command line arguments. ! Raise getopt.error if an unrecognized option is found. ! """ ! opts, args = getopt.getop(args, "") ! return args ! ! # Self-test ! ! def _test(): ! hello = "hello world" ! warn(hello) ! warn(hello, UserWarning) ! warn(hello, DeprecationWarning) ! for i in range(3): ! warn(hello) ! filter.append(("", Warning, "", 0, "error")) ! try: ! warn(hello) ! except Exception, msg: ! print "Caught", msg.__class__.__name__ + ":", msg ! else: ! print "No exception" ! filter[:] = [] ! filter.append(("", Warning, "", 0, "booh")) ! try: ! warn(hello) ! except Exception, msg: ! print "Caught", msg.__class__.__name__ + ":", msg ! else: ! print "No exception" ! ! if __name__ == "__main__": ! args = setupfilter(sys.argv[1:]) ! _test() --- 191,334 ---- ! API For Manipulating Warning Filters ! sys.filterwarnings(message, category, module, lineno, action) ! This checks the types of the arguments and inserts them as a tuple ! in front of the warnings filter. ! sys.resetwarnings() ! Reset the warnings filter to empty. ! sys.setupwarnings(args) ! Parse command line options and initialize the warnings filter ! accordingly. The argument should be sys.argv[1:] or equivalent. ! Unrecognized options raise getopt.error. The return value is a ! list containing the remaining (non-option) arguments. ! Command Line Syntax ! ! There should be command line options to specify the most common ! filtering actions, which I expect to include at least: ! ! - suppress all warnings ! ! - suppress a particular warning message everywhere ! ! - suppress all warnings in a particular module ! ! - turn all warnings into exceptions ! ! I propose the following command line option syntax: ! ! -Waction[:message[:category[:module[:lineno]]]] ! ! Where: ! ! - 'action' is an abbreviation of one of the allowed actions ! ("error", "default", "ignore", "always", "once", or "module") ! ! - 'message' is a message string; matches warnings whose message ! text is an initial substring of 'message' (matching is ! case-sensitive) ! ! - 'category' is an abbreviation of a standard warning category ! class name *or* a fully-qualified name for a user-defined ! warning category class of the form [package.]module.classname ! ! - 'module' is a module name (possibly package.module) ! ! - 'lineno' is an integral line number ! ! All parts except 'action' may be omitted, where an empty value ! after stripping whitespace is the same as an omitted value. ! ! Each -W option results into a call to sys.filterwarnings(); thus ! later -W options override earlier -W options for warnings they ! both match. ! ! Examples: ! ! -Werror ! Turn all warnings into errors ! ! -Wall ! Show all warnings ! ! -Wignore ! Ignore all warnings ! -Wi:hello ! Ignore warnings whose message text starts with "hello" ! -We::Deprecation ! Turn deprecation warnings into errors ! -Wi:::spam:10 ! Ignore all warnings on line 10 of module spam ! -Wi:::spam -Wd:::spam:10 ! Ignore all warnings in module spam except on line 10 ! ! -We::Deprecation -Wd::Deprecation:spam ! Turn deprecation warnings into errors except in module spam ! ! ! Open Issues ! ! Some open issues off the top of my head: ! ! - The proposal has all the Python API functions in the sys module, ! except that the warning categories are in the warnings module. ! Perhaps everything should be in the warnings module (like the ! prototype implementation)? Or perhaps warn() should be promoted ! to a built-in (i.e. in the __builtin__ module)? ! ! - It's tempting to leave the implementation in Python and add an ! absolute minimal amount of C code, only to make the standard ! warning categories available from C code. The Py_Warn() ! function could call warnings.warn(). Similarly, the Python ! main() function could collect -W options and pass them to ! warnings.setupwarnings(). ! ! - The prototype implements a third argument to warn(): ! ! warn(message, category=UserWarning, level=1) ! ! The 'level' argument could be used by wrapper functions written ! in Python, like this: ! ! def deprecation(message): ! warn(message, DeprecationWarning, level=2) ! ! This makes the warning refer to the deprecation()'s caller, ! rather than to the source of deprecation() itself (the latter ! would defeat the purpose of the warning message). ! ! - The proposed command line syntax is ugly (although the simple ! cases aren't so bad: -Werror, -Wignore, etc.). Anybody got a ! better idea? ! ! - I'm a bit worried that the filter specifications are too ! complex. Perhaps filtering only on category and module (not on ! message text and line number) would be enough? ! ! - There's a bit of confusion between module names and file names. ! The reporting uses file names, but the filter specification uses ! module names. Maybe it should allow filenames as well? ! ! - I'm not at all convinced that packages are handled right. ! ! - Better names for the various API functions? ! ! ! Implementation ! Here's a prototype implementation: + http://sourceforge.net/patch/?func=detailpatch&patch_id=102715&group_id=5470 From python-dev@python.org Fri Dec 8 06:54:54 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 7 Dec 2000 22:54:54 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib xmldom.tex,1.3,1.4 Message-ID: <200012080654.WAA08163@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv8155/lib Modified Files: xmldom.tex Log Message: Lots of small improvements and bits of added information on the DOM API. Index: xmldom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmldom.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** xmldom.tex 2000/12/07 04:47:51 1.3 --- xmldom.tex 2000/12/08 06:54:51 1.4 *************** *** 147,150 **** --- 147,151 ---- \constant{COMMENT_NODE}, \constant{DOCUMENT_NODE}, \constant{DOCUMENT_TYPE_NODE}, \constant{NOTATION_NODE}. + This is a read-only attribute. \end{memberdesc} *************** *** 155,158 **** --- 156,160 ---- root element, in which case it will be the \class{Document} object. For \class{Attr} nodes, this is always \code{None}. + This is a read-only attribute. \end{memberdesc} *************** *** 160,163 **** --- 162,166 ---- An \class{AttributeList} of attribute objects. Only elements have actual values for this; others provide \code{None} for this attribute. + This is a read-only attribute. \end{memberdesc} *************** *** 169,172 **** --- 172,176 ---- comment, or something else. If this node is the first child of the parent, this attribute will be \code{None}. + This is a read-only attribute. \end{memberdesc} *************** *** 175,225 **** also \member{previousSibling}. If this is the last child of the parent, this attribute will be \code{None}. \end{memberdesc} \begin{memberdesc}[Node]{childNodes} A list of nodes contained within this node. \end{memberdesc} \begin{memberdesc}[Node]{firstChild} The first child of the node, if there are any, or \code{None}. \end{memberdesc} \begin{memberdesc}[Node]{lastChild} The last child of the node, if there are any, or \code{None}. \end{memberdesc} ! \begin{memberdesc}[Element]{namespaceURI} The namespace associated with the element name. This will be a ! string. \end{memberdesc} \begin{memberdesc}[Node]{nodeName} ! Has a different meaning for each node type. See the DOM specification ! for details. You can always get the information you would get here ! from another property such as the \member{tagName} property for ! elements or the \member{name} property for attributes. For all node ! types, the value of this attribute will be either a string or ! \code{None}. \end{memberdesc} \begin{memberdesc}[Node]{nodeValue} ! Has a different meaning for each node type. See the DOM specification ! for details. The situation is similar to that with \member{nodeName}. \end{memberdesc} \begin{methoddesc}[Node]{hasChildNodes}{} Returns true if the node has any child nodes. \end{methoddesc} \begin{methoddesc}[Node]{insertBefore}{newChild, refChild} Insert a new child node before an existing child. It must be the case that \var{refChild} is a child of this node; if not, ! \exception{ValueError} is raised. ! \end{methoddesc} ! ! \begin{methoddesc}[Node]{replaceChild}{newChild, oldChild} ! Replace an existing node with a new node. It must be the case that ! \var{oldChild} is a child of this node; if not, ! \exception{ValueError} is raised. \end{methoddesc} --- 179,247 ---- also \member{previousSibling}. If this is the last child of the parent, this attribute will be \code{None}. + This is a read-only attribute. \end{memberdesc} \begin{memberdesc}[Node]{childNodes} A list of nodes contained within this node. + This is a read-only attribute. \end{memberdesc} \begin{memberdesc}[Node]{firstChild} The first child of the node, if there are any, or \code{None}. + This is a read-only attribute. \end{memberdesc} \begin{memberdesc}[Node]{lastChild} The last child of the node, if there are any, or \code{None}. + This is a read-only attribute. \end{memberdesc} ! \begin{memberdesc}[Node]{localName} ! The part of the \member{tagName} following the colon if there is one, ! else the entire \member{tagName}. The value is a string. ! \end{memberdesc} ! ! \begin{memberdesc}[Node]{prefix} ! The part of the \member{tagName} preceding the colon if there is one, ! else the empty string. The value is a string, or \code{None} ! \end{memberdesc} ! ! \begin{memberdesc}[Node]{namespaceURI} The namespace associated with the element name. This will be a ! string or \code{None}. This is a read-only attribute. \end{memberdesc} \begin{memberdesc}[Node]{nodeName} ! This has a different meaning for each node type; see the DOM ! specification for details. You can always get the information you ! would get here from another property such as the \member{tagName} ! property for elements or the \member{name} property for attributes. ! For all node types, the value of this attribute will be either a ! string or \code{None}. This is a read-only attribute. \end{memberdesc} \begin{memberdesc}[Node]{nodeValue} ! This has a different meaning for each node type; see the DOM ! specification for details. The situation is similar to that with ! \member{nodeName}. The value is a string or \code{None}. \end{memberdesc} + \begin{methoddesc}[Node]{hasAttributes}{} + Returns true if the node has any attributes. + \end{methoddesc} + \begin{methoddesc}[Node]{hasChildNodes}{} Returns true if the node has any child nodes. \end{methoddesc} + \begin{methoddesc}[Node]{appendChild}{newChild} + Add a new child node to this node at the end of the list of children, + returning \var{newChild}. + \end{methoddesc} + \begin{methoddesc}[Node]{insertBefore}{newChild, refChild} Insert a new child node before an existing child. It must be the case that \var{refChild} is a child of this node; if not, ! \exception{ValueError} is raised. \var{newChild} is returned. \end{methoddesc} *************** *** 231,237 **** \end{methoddesc} ! \begin{methoddesc}[Node]{appendChild}{newChild} ! Add a new child node to this node at the end of the list of children, ! returning \var{newChild}. \end{methoddesc} --- 253,260 ---- \end{methoddesc} ! \begin{methoddesc}[Node]{replaceChild}{newChild, oldChild} ! Replace an existing node with a new node. It must be the case that ! \var{oldChild} is a child of this node; if not, ! \exception{ValueError} is raised. \end{methoddesc} *************** *** 411,423 **** \end{memberdesc} ! \begin{memberdesc}[Element]{localName} ! The part of the \member{tagName} following the colon if there is one, ! else the entire \member{tagName}. The value is a string. ! \end{memberdesc} ! \begin{memberdesc}[Element]{prefix} ! The part of the \member{tagName} preceding the colon if there is one, ! else the empty string. The value is a string, or \code{None} ! \end{memberdesc} \begin{methoddesc}[Element]{getAttribute}{attname} --- 434,444 ---- \end{memberdesc} ! \begin{methoddesc}[Element]{getElementsByTagName}{tagName} ! Same as equivalent method in the \class{Document} class. ! \end{methoddesc} ! \begin{methoddesc}[Element]{getElementsByTagNameNS}{tagName} ! Same as equivalent method in the \class{Document} class. ! \end{methoddesc} \begin{methoddesc}[Element]{getAttribute}{attname} *************** *** 426,466 **** \begin{methoddesc}[Element]{getAttributeNode}{attrname} ! Return the \class{Attr} node for the attribute named by \var{attrname} \end{methoddesc} ! \begin{methoddesc}[Element]{setAttribute}{attname, value} ! Set an attribute value from a string. \end{methoddesc} ! \begin{methoddesc}[Element]{removeAttribute}{attname} ! Remove an attribute by name. \end{methoddesc} ! \begin{methoddesc}[Element]{getAttributeNS}{namespaceURI, localName} ! Return an attribute value as a string, given a \var{namespaceURI} and ! \var{localName}. Note that a localname is the part of a prefixed ! attribute name after the colon (if there is one). \end{methoddesc} ! \begin{methoddesc}[Element]{setAttributeNS}{namespaceURI, qname, value} ! Set an attribute value from a string, given a \var{namespaceURI} and a ! \var{qname}. Note that a qname is the whole attribute name. This is ! different than above. \end{methoddesc} \begin{methoddesc}[Element]{removeAttributeNS}{namespaceURI, localName} Remove an attribute by name. Note that it uses a localName, not a ! qname. \end{methoddesc} ! \begin{methoddesc}[Element]{getElementsByTagName}{tagName} ! Same as equivalent method in the \class{Document} class. \end{methoddesc} ! \begin{methoddesc}[Element]{getElementsByTagNameNS}{tagName} ! Same as equivalent method in the \class{Document} class. \end{methoddesc} \subsubsection{Attr Objects \label{dom-attr-objects}} --- 447,506 ---- \begin{methoddesc}[Element]{getAttributeNode}{attrname} ! Return the \class{Attr} node for the attribute named by ! \var{attrname}. \end{methoddesc} ! \begin{methoddesc}[Element]{getAttributeNS}{namespaceURI, localName} ! Return an attribute value as a string, given a \var{namespaceURI} and ! \var{localName}. \end{methoddesc} ! \begin{methoddesc}[Element]{getAttributeNodeNS}{namespaceURI, localName} ! Return an attribute value as a node, given a \var{namespaceURI} and ! \var{localName}. \end{methoddesc} ! \begin{methoddesc}[Element]{removeAttribute}{attname} ! Remove an attribute by name. No exception is raised if there is no ! matching attribute. \end{methoddesc} ! \begin{methoddesc}[Element]{removeAttributeNode}{oldAttr} ! Remove and return \var{oldAttr} from the attribute list, if present. ! If \var{oldAttr} is not present, \exception{NotFoundErr} is raised. \end{methoddesc} \begin{methoddesc}[Element]{removeAttributeNS}{namespaceURI, localName} Remove an attribute by name. Note that it uses a localName, not a ! qname. No exception is raised if there is no matching attribute. \end{methoddesc} ! \begin{methoddesc}[Element]{setAttribute}{attname, value} ! Set an attribute value from a string. \end{methoddesc} ! \begin{methoddesc}[Element]{setAttributeNode}{newAttr} ! Add a new attibute node to the element, replacing an existing ! attribute if necessary if the \member{name} attribute matches. If a ! replacement occurs, the old attribute node will be returned. If ! \var{newAttr} is already in use, \exception{InuseAttributeErr} will be ! raised. \end{methoddesc} + \begin{methoddesc}[Element]{setAttributeNodeNS}{newAttr} + Add a new attibute node to the element, replacing an existing + attribute if necessary if the \member{namespaceURI} and + \member{localName} attributes match. If a replacement occurs, the old + attribute node will be returned. If \var{newAttr} is already in use, + \exception{InuseAttributeErr} will be raised. + \end{methoddesc} + \begin{methoddesc}[Element]{setAttributeNS}{namespaceURI, qname, value} + Set an attribute value from a string, given a \var{namespaceURI} and a + \var{qname}. Note that a qname is the whole attribute name. This is + different than above. + \end{methoddesc} + + \subsubsection{Attr Objects \label{dom-attr-objects}} *************** *** 475,479 **** \begin{memberdesc}[Attr]{localName} The part of the name following the colon if there is one, else the ! entire name. \end{memberdesc} --- 515,519 ---- \begin{memberdesc}[Attr]{localName} The part of the name following the colon if there is one, else the ! entire name. This is a read-only attribute. \end{memberdesc} *************** *** 483,490 **** \end{memberdesc} - \begin{memberdesc}[Attr]{namespaceURI} - The namespace associated with the attribute name. - \end{memberdesc} - \subsubsection{NamedNodeMap Objects \label{dom-attributelist-objects}} --- 523,526 ---- *************** *** 511,539 **** \class{Comment} represents a comment in the XML document. It is a ! subclass of \class{Node}. \begin{memberdesc}[Comment]{data} ! The content of the comment. \end{memberdesc} ! \subsubsection{Text Objects \label{dom-text-objects}} ! The \class{Text} interface represents text in the XML document. It ! inherits from \class{Node}. \begin{memberdesc}[Text]{data} ! The content of the text node. \end{memberdesc} \subsubsection{ProcessingInstruction Objects \label{dom-pi-objects}} Represents a processing instruction in the XML document; this inherits ! from the \class{Node} interface. \begin{memberdesc}[ProcessingInstruction]{target} The content of the processing instruction up to the first whitespace ! character. \end{memberdesc} --- 547,590 ---- \class{Comment} represents a comment in the XML document. It is a ! subclass of \class{Node}, but cannot have child nodes. \begin{memberdesc}[Comment]{data} ! The content of the comment as a string. The attribute contains all ! characters between the leading \code{}, but does not include them. \end{memberdesc} ! \subsubsection{Text and CDATASection Objects \label{dom-text-objects}} ! The \class{Text} interface represents text in the XML document. If ! the parser and DOM implementation support the DOM's XML extension, ! portions of the text enclosed in CDATA marked sections are stored in ! \class{CDATASection} objects. These two interfaces are identical, but ! provide different values for the \member{nodeType} attribute. + These interfaces extend the \class{Node} interface. They cannot have + child nodes. + \begin{memberdesc}[Text]{data} ! The content of the text node as a string. \end{memberdesc} + \strong{Note:} The use of a \class{CDATASection} node does not + indicate that the node represents a complete CDATA marked section, + only that the content of the node was part of a CDATA section. A + single CDATA section may be represented by more than one node in the + document tree. There is no way to determine whether two adjacent + \class{CDATASection} nodes represent different CDATA marked sections. + \subsubsection{ProcessingInstruction Objects \label{dom-pi-objects}} Represents a processing instruction in the XML document; this inherits ! from the \class{Node} interface and cannot have child nodes. \begin{memberdesc}[ProcessingInstruction]{target} The content of the processing instruction up to the first whitespace ! character. This is a read-only attribute. \end{memberdesc} From python-dev@python.org Fri Dec 8 15:05:12 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 8 Dec 2000 07:05:12 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.55,1.56 Message-ID: <200012081505.HAA30197@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv30180 Modified Files: pep-0000.txt Log Message: __findattr__ is rejected -- the idea is too uncooked and you actually *can* do most of this with __getattr__. Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -r1.55 -r1.56 *** pep-0000.txt 2000/12/05 03:31:13 1.55 --- pep-0000.txt 2000/12/08 15:05:09 1.56 *************** *** 40,44 **** S 227 pep-0227.txt Statically Nested Scopes Hylton S 230 pep-0230.txt Warning Framework van Rossum - S 231 pep-0231.txt __findattr__() Warsaw Pie-in-the-sky PEPs (not ready; may become active yet) --- 40,43 ---- *************** *** 80,83 **** --- 79,83 ---- SR 204 pep-0204.txt Range Literals Wouters + SR 231 pep-0231.txt __findattr__() Warsaw *************** *** 127,131 **** S 229 pep-0229.txt Using Distutils to Build Python Kuchling S 230 pep-0230.txt Warning Framework van Rossum ! S 231 pep-0231.txt __findattr__() Warsaw Key --- 127,131 ---- S 229 pep-0229.txt Using Distutils to Build Python Kuchling S 230 pep-0230.txt Warning Framework van Rossum ! SR 231 pep-0231.txt __findattr__() Warsaw Key From python-dev@python.org Fri Dec 8 15:36:05 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 8 Dec 2000 07:36:05 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0231.txt,1.3,1.4 Message-ID: <200012081536.HAA01447@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv1430 Modified Files: pep-0231.txt Log Message: Rejection notice (with Barry's agreement). Index: pep-0231.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0231.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** pep-0231.txt 2000/12/02 15:12:35 1.3 --- pep-0231.txt 2000/12/08 15:36:03 1.4 *************** *** 603,606 **** --- 603,626 ---- + Rejection + + There are serious problems with the recursion-protection feature. + As described here it's not thread-safe, and a thread-safe solution + has other problems. In general, it's not clear how helpful the + recursion-protection feature is; it makes it hard to write code + that needs to be callable inside __findattr__ as well as outside + it. But without the recursion-protection, it's hard to implement + __findattr__ at all (since __findattr__ would invoke itself + recursively for every attribute it tries to access). There seems + to be no good solution here. + + It's also dubious how useful it is to support __findattr__ both + for getting and for setting attributes -- __setattr__ gets called + in all cases alrady. + + The examples can all be implemented using __getattr__ if care is + taken not to store instance variables under their own names. + + Copyright From python-dev@python.org Fri Dec 8 16:02:31 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 8 Dec 2000 08:02:31 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0225.txt,1.1,1.2 Message-ID: <200012081602.IAA06030@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv6017 Modified Files: pep-0225.txt Log Message: Add a missing colon to the first header line, to fix the HTML formatting. Index: pep-0225.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0225.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** pep-0225.txt 2000/09/19 15:29:58 1.1 --- pep-0225.txt 2000/12/08 16:02:28 1.2 *************** *** 1,3 **** ! PEP 225 Title: Elementwise/Objectwise Operators Version: $Revision$ --- 1,3 ---- ! PEP: 225 Title: Elementwise/Objectwise Operators Version: $Revision$ From python-dev@python.org Sat Dec 9 05:03:25 2000 From: python-dev@python.org (Tim Peters) Date: Fri, 8 Dec 2000 21:03:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/scripts ndiff.py,1.5,1.6 Message-ID: <200012090503.VAA01813@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/scripts In directory slayer.i.sourceforge.net:/tmp/cvs-serv1727/python/dist/src/tools/scripts Modified Files: ndiff.py Log Message: SF bug 124051: ndiff "?" lines can be confusing. Well, they still can, but after implementing it I liked Gregor's two-"?" line idea a lot. Index: ndiff.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/ndiff.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** ndiff.py 2000/11/01 02:51:27 1.5 --- ndiff.py 2000/12/09 05:03:22 1.6 *************** *** 1,7 **** #! /usr/bin/env python ! # Module ndiff version 1.5.0 ! # Released to the public domain 08-Oct-2000, ! # by Tim Peters (tim_one@email.msn.com). # Provided as-is; use at your own risk; no warranty; no promises; enjoy! --- 1,7 ---- #! /usr/bin/env python ! # Module ndiff version 1.6.0 ! # Released to the public domain 08-Dec-2000, ! # by Tim Peters (tim.one@home.com). # Provided as-is; use at your own risk; no warranty; no promises; enjoy! *************** *** 409,419 **** print tag, x[i], - # figure out which mark to stick under characters in lines that - # have changed (blank = same, - = deleted, + = inserted, ^ = replaced) - _combine = { ' ': ' ', - '. ': '-', - ' .': '+', - '..': '^' } - def plain_replace(a, alo, ahi, b, blo, bhi): assert alo < ahi and blo < bhi --- 409,412 ---- *************** *** 492,496 **** aelt, belt = a[best_i], b[best_j] if eqi is None: ! # pump out a '-', '+', '?' triple for the synched lines; atags = btags = "" cruncher.set_seqs(aelt, belt) --- 485,489 ---- aelt, belt = a[best_i], b[best_j] if eqi is None: ! # pump out a '-', '?', '+', '?' quad for the synched lines atags = btags = "" cruncher.set_seqs(aelt, belt) *************** *** 498,519 **** la, lb = ai2 - ai1, bj2 - bj1 if tag == 'replace': ! atags = atags + '.' * la ! btags = btags + '.' * lb elif tag == 'delete': ! atags = atags + '.' * la elif tag == 'insert': ! btags = btags + '.' * lb elif tag == 'equal': ! atags = atags + ' ' * la ! btags = btags + ' ' * lb else: raise ValueError, 'unknown tag ' + `tag` ! la, lb = len(atags), len(btags) ! if la < lb: ! atags = atags + ' ' * (lb - la) ! elif lb < la: ! btags = btags + ' ' * (la - lb) ! combined = map(lambda x,y: _combine[x+y], atags, btags) ! printq(aelt, belt, string.rstrip(string.join(combined, ''))) else: # the synch pair is identical --- 491,506 ---- la, lb = ai2 - ai1, bj2 - bj1 if tag == 'replace': ! atags += '^' * la ! btags += '^' * lb elif tag == 'delete': ! atags += '-' * la elif tag == 'insert': ! btags += '+' * lb elif tag == 'equal': ! atags += ' ' * la ! btags += ' ' * lb else: raise ValueError, 'unknown tag ' + `tag` ! printq(aelt, belt, atags, btags) else: # the synch pair is identical *************** *** 535,544 **** # probably help most of the time. ! def printq(aline, bline, qline): common = min(count_leading(aline, "\t"), count_leading(bline, "\t")) ! common = min(common, count_leading(qline[:common], " ")) ! qline = "\t" * common + qline[common:] ! print '-', aline, '+', bline, '?', qline def count_leading(line, ch): --- 522,535 ---- # probably help most of the time. ! def printq(aline, bline, atags, btags): common = min(count_leading(aline, "\t"), count_leading(bline, "\t")) ! common = min(common, count_leading(atags[:common], " ")) ! print "-", aline, ! if count_leading(atags, " ") < len(atags): ! print "?", "\t" * common + atags[common:] ! print "+", bline, ! if count_leading(btags, " ") < len(btags): ! print "?", "\t" * common + btags[common:] def count_leading(line, ch): From python-dev@python.org Sun Dec 10 15:12:17 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 10 Dec 2000 07:12:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib codecs.py,1.12,1.13 Message-ID: <200012101512.HAA20646@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv20536 Modified Files: codecs.py Log Message: (Patch #102698) Fix for a bug reported by Wade Leftwich: StreamReader ignores the 'errors' parameter passed to its constructor Index: codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codecs.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** codecs.py 2000/10/02 22:11:47 1.12 --- codecs.py 2000/12/10 15:12:14 1.13 *************** *** 206,210 **** # Unsliced reading: if size < 0: ! return self.decode(self.stream.read())[0] # Sliced reading: --- 206,210 ---- # Unsliced reading: if size < 0: ! return self.decode(self.stream.read(), self.errors)[0] # Sliced reading: *************** *** 215,219 **** while 1: try: ! object, decodedbytes = decode(data) except ValueError,why: # This method is slow but should work under pretty much --- 215,219 ---- while 1: try: ! object, decodedbytes = decode(data, self.errors) except ValueError,why: # This method is slow but should work under pretty much *************** *** 248,252 **** else: line = self.stream.readline(size) ! return self.decode(line)[0] --- 248,252 ---- else: line = self.stream.readline(size) ! return self.decode(line,self.errors)[0] *************** *** 267,271 **** else: data = self.stream.read(sizehint) ! return self.decode(data)[0].splitlines(1) def reset(self): --- 267,271 ---- else: data = self.stream.read(sizehint) ! return self.decode(data,self.errors)[0].splitlines(1) def reset(self): From python-dev@python.org Mon Dec 11 15:50:10 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 11 Dec 2000 07:50:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libselect.tex,1.16,1.17 Message-ID: <200012111550.HAA10913@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv10901/lib Modified Files: libselect.tex Log Message: select.select(): Add note that though this function accepts empty lists, using *only* empty lists may not be acceptable on all platforms, with the specific caveat that it does not work on Windows. Also clarified list of acceptable objects that may be in the lists, to let the user know that file objects are not usable here on Windows. Index: libselect.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libselect.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** libselect.tex 2000/08/25 01:21:28 1.16 --- libselect.tex 2000/12/11 15:50:07 1.17 *************** *** 34,45 **** This is a straightforward interface to the \UNIX{} \cfunction{select()} system call. The first three arguments are lists of `waitable ! objects': either integers representing \UNIX{} file descriptors or objects with a parameterless method named \method{fileno()} returning such an integer. The three lists of waitable objects are for input, output and `exceptional conditions', respectively. Empty lists are ! allowed. The optional \var{timeout} argument specifies a time-out as a ! floating point number in seconds. When the \var{timeout} argument ! is omitted the function blocks until at least one file descriptor is ! ready. A time-out value of zero specifies a poll and never blocks. The return value is a triple of lists of objects that are ready: --- 34,47 ---- This is a straightforward interface to the \UNIX{} \cfunction{select()} system call. The first three arguments are lists of `waitable ! objects': either integers representing file descriptors or objects with a parameterless method named \method{fileno()} returning such an integer. The three lists of waitable objects are for input, output and `exceptional conditions', respectively. Empty lists are ! allowed, but acceptance of three empty lists is platform-dependent. ! (It is known to work on \UNIX{} but not on Windows.) The optional ! \var{timeout} argument specifies a time-out as a floating point number ! in seconds. When the \var{timeout} argument is omitted the function ! blocks until at least one file descriptor is ready. A time-out value ! of zero specifies a poll and never blocks. The return value is a triple of lists of objects that are ready: *************** *** 53,64 **** returned by \function{socket.socket()},% \withsubitem{(in module socket)}{\ttindex{socket()}} ! \withsubitem{(in module os)}{\ttindex{popen()}} ! and the module \module{stdwin}\refbimodindex{stdwin} which happens to ! define a function ! \function{fileno()}\withsubitem{(in module stdwin)}{\ttindex{fileno()}} ! for just this purpose. You may ! also define a \dfn{wrapper} class yourself, as long as it has an ! appropriate \method{fileno()} method (that really returns a \UNIX{} ! file descriptor, not just a random integer). \end{funcdesc} --- 55,66 ---- returned by \function{socket.socket()},% \withsubitem{(in module socket)}{\ttindex{socket()}} ! \withsubitem{(in module os)}{\ttindex{popen()}}. ! You may also define a \dfn{wrapper} class yourself, as long as it has ! an appropriate \method{fileno()} method (that really returns a file ! descriptor, not just a random integer). ! \strong{Note:}\index{WinSock} File objects on Windows are not ! acceptable, but sockets are. On Windows, the underlying ! \cfunction{select()} function is provided by the WinSock library, and ! does not handle file desciptors that don't originate from WinSock. \end{funcdesc} From python-dev@python.org Mon Dec 11 16:34:37 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 11 Dec 2000 08:34:37 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0230.txt,1.3,1.4 Message-ID: <200012111634.IAA16062@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv16049 Modified Files: pep-0230.txt Log Message: New version of the PEP. Changes based upon the second (delayed-import) implentation. Address some of Paul's concerns. Index: pep-0230.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0230.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** pep-0230.txt 2000/12/07 21:52:14 1.3 --- pep-0230.txt 2000/12/11 16:34:34 1.4 *************** *** 17,21 **** on 05-Nov-2000, with some ideas (such as using classes to categorize warnings) merged in from Paul Prescod's ! counter-proposal posted on the same date. --- 17,22 ---- on 05-Nov-2000, with some ideas (such as using classes to categorize warnings) merged in from Paul Prescod's ! counter-proposal posted on the same date. Also, an attempt to ! implement the proposal caused several small tweaks. *************** *** 75,112 **** - To issue a warning from Python: ! sys.warn(message[, category]) The category argument, if given, must be a warning category class (see below); it defaults to warnings.UserWarning. This may raise an exception if the particular warning issued is ! changed into an error by the warnings filter. - To issue a warning from C: ! int Py_Warn(char *message, PyObject *category) ! Return 0 normally, 1 if an exception is raised. The category ! argument must be a warning category class (see below). When ! Py_Warn() function returns 1, the caller should do normal ! exception handling. [Question: what about issuing warnings ! during lexing or parsing, which don't have the exception ! machinery available?] Warnings Categories ! The "warnings" module defines classes representing warning categories. This categorization is useful to be able to filter ! out groups of warnings. The classes defined in this module have ! no semantics attached to them and are never instantiated -- only ! their names are used for filtering (see the section on the ! warnings filter below). The following warnings category classes are currently defined: - Warning -- this is the base class of all warning category ! classes. A warning category must always be a subclass of this ! class. ! - UserWarning -- the default category for sys.warn() - DeprecationWarning -- base category for warnings about deprecated --- 76,127 ---- - To issue a warning from Python: ! import warnings ! warnings.warn(message[, category[, stacklevel]]) The category argument, if given, must be a warning category class (see below); it defaults to warnings.UserWarning. This may raise an exception if the particular warning issued is ! changed into an error by the warnings filter. The stacklevel ! can be used by wrapper functions written in Python, like this: + def deprecation(message): + warn(message, DeprecationWarning, level=2) + + This makes the warning refer to the deprecation()'s caller, + rather than to the source of deprecation() itself (since the + latter would defeat the purpose of the warning message). + - To issue a warning from C: + + int PyErr_Warn(PyObject *category, char *message); ! Return 0 normally, 1 if an exception is raised (either because ! the warning was transformed into an exception, or because of a ! malfunction in the implementation, such as running out of ! memory). The category argument must be a warning category class ! (see below) or NULL, in which case it defaults to ! PyExc_RuntimeWarning. When PyErr_Warn() function returns 1, the ! caller should do normal exception handling. ! ! The current C implementation of PyErr_Warn() imports the ! warnings module (implemented in Python) and calls its warn() ! function. This minimizes the amount of C code that needs to be ! added to implement the warning feature. ! [XXX Open Issue: what about issuing warnings during lexing or ! parsing, which don't have the exception machinery available?] Warnings Categories ! There are a number of built-in exceptions that represent warning categories. This categorization is useful to be able to filter ! out groups of warnings. The following warnings category classes are currently defined: - Warning -- this is the base class of all warning category ! classes and it itself a subclass of Exception ! - UserWarning -- the default category for warnings.warn() - DeprecationWarning -- base category for warnings about deprecated *************** *** 115,121 **** - SyntaxWarning -- base category for warnings about dubious syntactic features ! Other categories may be proposed during the review period for this ! PEP. --- 130,147 ---- - SyntaxWarning -- base category for warnings about dubious syntactic features + + - RuntimeWarning -- base category for warnings about dubious + runtime features + + [XXX: Other warning categories may be proposed during the review + period for this PEP.] ! These standard warning categories are available from C as ! PyExc_Warning, PyExc_UserWarning, etc. From Python, they are ! available in the __builtin__ module, so no import is necessary. ! ! User code can define additional warning categories by subclassing ! one of the standard warning categories. A warning category must ! always be a subclass of the Warning class. *************** *** 128,132 **** - The data structures used to efficiently determine the ! disposition of a particular Py_Warn() call. - The API to control the filter from Python source code. --- 154,159 ---- - The data structures used to efficiently determine the ! disposition of a particular warnings.warn() or PyErr_Warn() ! call. - The API to control the filter from Python source code. *************** *** 140,144 **** First, the warning filter collects the module and line number where the warning is issued; this information is readily available ! through PyEval_GetFrame(). Conceptually, the warnings filter maintains an ordered list of --- 167,171 ---- First, the warning filter collects the module and line number where the warning is issued; this information is readily available ! through sys._getframe(). Conceptually, the warnings filter maintains an ordered list of *************** *** 153,160 **** the warning category must be a subclass in order to match ! - message is a regular expression that the warning message must ! match ! - module is a regular expression that the module name must match - lineno is an integer that the line number where the warning --- 180,188 ---- the warning category must be a subclass in order to match ! - message is a compiled regular expression that the warning ! message must match ! - module is a compiled regular expression that the module name ! must match - lineno is an integer that the line number where the warning *************** *** 178,213 **** warnings ! The Warning class is derived from the built-in Exception class, so ! that to turn a warning into an error we raise category(message). ! The Warnings Output Hook When the warnings filter decides to issue a warning (but not when it decides to raise an exception), it passes the information about ! the function sys.showwarning(message, category, filename, lineno). The default implementation of this function writes the warning text ! to sys.stderr, and shows the source line of the filename. API For Manipulating Warning Filters ! sys.filterwarnings(message, category, module, lineno, action) ! This checks the types of the arguments and inserts them as a tuple ! in front of the warnings filter. ! sys.resetwarnings() Reset the warnings filter to empty. - sys.setupwarnings(args) - Parse command line options and initialize the warnings filter - accordingly. The argument should be sys.argv[1:] or equivalent. - Unrecognized options raise getopt.error. The return value is a - list containing the remaining (non-option) arguments. - - Command Line Syntax --- 206,244 ---- warnings ! Since the Warning class is derived from the built-in Exception ! class, to turn a warning into an error we simply raise ! category(message). ! Warnings Output And Formatting Hooks When the warnings filter decides to issue a warning (but not when it decides to raise an exception), it passes the information about ! the function warnings.showwarning(message, category, filename, lineno). The default implementation of this function writes the warning text ! to sys.stderr, and shows the source line of the filename. It has ! an optional 5th argument which can be used to specify a different ! file than sys.stderr. ! ! The formatting of warnings is done by a separate function, ! warnings.formatwarning(message, category, filename, lineno). This ! returns a string (that may contain newlines and ends in a newline) ! that can be printed to get the identical effect of the ! showwarning() function. API For Manipulating Warning Filters ! warnings.filterwarnings(message, category, module, lineno, action) ! This checks the types of the arguments, compiles the message and ! module regular expressions, and inserts them as a tuple in front ! of the warnings filter. ! warnings.resetwarnings() Reset the warnings filter to empty. Command Line Syntax *************** *** 247,253 **** after stripping whitespace is the same as an omitted value. ! Each -W option results into a call to sys.filterwarnings(); thus ! later -W options override earlier -W options for warnings they ! both match. Examples: --- 278,287 ---- after stripping whitespace is the same as an omitted value. ! The C code that parses the Python command line saves the body of ! all -W options in a list of strings, which is made available to ! the warnings module as sys.warnoptions. The warnings module ! parses these when it is first imported. Errors detected during ! the parsing of sys.warnoptions are not fatal; a message is written ! to sys.stderr and processing continues with the option. Examples: *************** *** 281,315 **** Some open issues off the top of my head: - - - The proposal has all the Python API functions in the sys module, - except that the warning categories are in the warnings module. - Perhaps everything should be in the warnings module (like the - prototype implementation)? Or perhaps warn() should be promoted - to a built-in (i.e. in the __builtin__ module)? - - - It's tempting to leave the implementation in Python and add an - absolute minimal amount of C code, only to make the standard - warning categories available from C code. The Py_Warn() - function could call warnings.warn(). Similarly, the Python - main() function could collect -W options and pass them to - warnings.setupwarnings(). - - - The prototype implements a third argument to warn(): - - warn(message, category=UserWarning, level=1) - - The 'level' argument could be used by wrapper functions written - in Python, like this: - - def deprecation(message): - warn(message, DeprecationWarning, level=2) ! This makes the warning refer to the deprecation()'s caller, ! rather than to the source of deprecation() itself (the latter ! would defeat the purpose of the warning message). ! - The proposed command line syntax is ugly (although the simple ! cases aren't so bad: -Werror, -Wignore, etc.). Anybody got a ! better idea? - I'm a bit worried that the filter specifications are too --- 315,325 ---- Some open issues off the top of my head: ! - What about issuing warnings during lexing or parsing, which ! don't have the exception machinery available? ! - The proposed command line syntax is a bit ugly (although the ! simple cases aren't so bad: -Werror, -Wignore, etc.). Anybody ! got a better idea? - I'm a bit worried that the filter specifications are too *************** *** 322,327 **** - I'm not at all convinced that packages are handled right. ! - Better names for the various API functions? --- 332,372 ---- - I'm not at all convinced that packages are handled right. + + - Do we need more standard warning categories? Fewer? + + - In order to minimize the start-up overhead, the warnings module + is imported by the first call to PyErr_Warn(). It does the + command line parsing for -W options upon import. Therefore, it + is possible that warning-free programs will not complain about + invalid -W options. + + + Rejected Concerns + + Paul Prescod has brought up several additional concerns that I + feel aren't critical. I address them here (the concerns are + paraphrased, not necessarily exactly Paul's words). + + - Paul: warn() should be a built-in or a statement to make it easily + available. + + Response: "from warnings import warn" is easy enough. + + - Paul: What if I have a speed-critical module that triggers + warnings in an inner loop. It should be possible to disable the + overhead for detecting the warning (not just suppress the + warning). + + Response: rewrite the inner loop to avoid triggering the + warning. + + - Paul: What if I want to see the full context of a warning? + + Response: use -Werror to turn it into an exception. + + - Paul: I prefer ":*:*:" to ":::" for leaving parts of the warning + spec out. ! Response: I don't. From python-dev@python.org Mon Dec 11 16:50:13 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 11 Dec 2000 08:50:13 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0230.txt,1.4,1.5 Message-ID: <200012111650.IAA17535@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv17521 Modified Files: pep-0230.txt Log Message: Add responses to Barry's and Fred's concerns. Message matching is now case insensitive. Index: pep-0230.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0230.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** pep-0230.txt 2000/12/11 16:34:34 1.4 --- pep-0230.txt 2000/12/11 16:50:11 1.5 *************** *** 181,185 **** - message is a compiled regular expression that the warning ! message must match - module is a compiled regular expression that the module name --- 181,185 ---- - message is a compiled regular expression that the warning ! message must match (the match is case-insensitive) - module is a compiled regular expression that the module name *************** *** 265,269 **** - 'message' is a message string; matches warnings whose message text is an initial substring of 'message' (matching is ! case-sensitive) - 'category' is an abbreviation of a standard warning category --- 265,269 ---- - 'message' is a message string; matches warnings whose message text is an initial substring of 'message' (matching is ! case-insensitive) - 'category' is an abbreviation of a standard warning category *************** *** 344,350 **** Rejected Concerns ! Paul Prescod has brought up several additional concerns that I ! feel aren't critical. I address them here (the concerns are ! paraphrased, not necessarily exactly Paul's words). - Paul: warn() should be a built-in or a statement to make it easily --- 344,350 ---- Rejected Concerns ! Paul Prescod, Barry Warsaw and Fred Drake have brought up several ! additional concerns that I feel aren't critical. I address them ! here (the concerns are paraphrased, not exactly their words): - Paul: warn() should be a built-in or a statement to make it easily *************** *** 369,372 **** --- 369,391 ---- Response: I don't. + + - Barry: It would be nice if lineno can be a range specification. + + Response: Too much complexity already. + + - Barry: I'd like to add my own warning action. Maybe if `action' + could be a callable as well as a string. Then in my IDE, I + could set that to "mygui.popupWarningsDialog". + + Response: For that purpose you would override + warnings.showwarning(). + + - Fred: why do the Warning category classes have to be in + __builtin__? + + Response: that's the simplest implementation, given that the + warning categories must be available in C before the first + PyErr_Warn() call, which imports the warnings module. I see no + problem with making them available as built-ins. From python-dev@python.org Mon Dec 11 18:13:23 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 11 Dec 2000 10:13:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib ConfigParser.py,1.24,1.25 Message-ID: <200012111813.KAA28012@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv27989 Modified Files: ConfigParser.py Log Message: Make ConfigParser.Error inherit from Exception. Index: ConfigParser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ConfigParser.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** ConfigParser.py 2000/12/04 16:29:13 1.24 --- ConfigParser.py 2000/12/11 18:13:19 1.25 *************** *** 97,105 **** # exception classes ! class Error: def __init__(self, msg=''): self._msg = msg def __repr__(self): return self._msg class NoSectionError(Error): --- 97,107 ---- # exception classes ! class Error(Exception): def __init__(self, msg=''): self._msg = msg + Exception.__init__(self, msg) def __repr__(self): return self._msg + __str__ = __repr__ class NoSectionError(Error): From python-dev@python.org Mon Dec 11 20:01:59 2000 From: python-dev@python.org (Barry Warsaw) Date: Mon, 11 Dec 2000 12:01:59 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python getargs.c,2.50,2.51 Message-ID: <200012112001.MAA09260@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv9239 Modified Files: getargs.c Log Message: vgetargskeywords(): Patch for memory leak identified in bug #119862. Index: getargs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v retrieving revision 2.50 retrieving revision 2.51 diff -C2 -r2.50 -r2.51 *** getargs.c 2000/12/01 12:59:05 2.50 --- getargs.c 2000/12/11 20:01:55 2.51 *************** *** 1124,1127 **** --- 1124,1128 ---- } converted++; + Py_DECREF(item); } else { From python-dev@python.org Mon Dec 11 20:32:23 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 11 Dec 2000 12:32:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib httplib.py,1.24,1.25 Message-ID: <200012112032.MAA12901@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv12882 Modified Files: httplib.py Log Message: Hoepeful fix for SF bug #123924: Windows - using OpenSSL, problem with socket in httplib.py. The bug reports that on Windows, you must pass sock._sock to the socket.ssl() call. But on Unix, you must pass sock itself. (sock is a wrapper on Windows but not on Unix; the ssl() call wants the real socket object, not the wrapper.) So we see if sock has an _sock attribute and if so, extract it. Unfortunately, the submitter of the bug didn't confirm that this patch works, so I'll just have to believe it (can't test it myself since I don't have OpenSSL on Windows set up, and that's a nontrivial thing I believe). Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** httplib.py 2000/10/12 19:58:36 1.24 --- httplib.py 2000/12/11 20:32:20 1.25 *************** *** 614,618 **** sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((self.host, self.port)) ! ssl = socket.ssl(sock, self.key_file, self.cert_file) self.sock = FakeSocket(sock, ssl) --- 614,621 ---- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((self.host, self.port)) ! realsock = sock ! if hasattr(sock, "_sock"): ! realsock = sock._sock ! ssl = socket.ssl(realsock, self.key_file, self.cert_file) self.sock = FakeSocket(sock, ssl) From python-dev@python.org Mon Dec 11 20:33:55 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 11 Dec 2000 12:33:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib dumbdbm.py,1.5,1.6 Message-ID: <200012112033.MAA13052@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv13042 Modified Files: dumbdbm.py Log Message: Apply rstrip() to the lines read from _dirfile in _update(), so that a dumbdbm archive created on Windows can be read on Unix. Index: dumbdbm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dumbdbm.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** dumbdbm.py 2000/07/10 13:56:35 1.5 --- dumbdbm.py 2000/12/11 20:33:52 1.6 *************** *** 53,57 **** else: while 1: ! line = f.readline() if not line: break key, (pos, siz) = eval(line) --- 53,57 ---- else: while 1: ! line = f.readline().rstrip() if not line: break key, (pos, siz) = eval(line) From python-dev@python.org Mon Dec 11 20:57:17 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 11 Dec 2000 12:57:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libarray.tex,1.27,1.28 Message-ID: <200012112057.MAA16774@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv16764/lib Modified Files: libarray.tex Log Message: Added link to HTML version of the NumPy documentation. This closes bug #124943. Index: libarray.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libarray.tex,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** libarray.tex 2000/10/18 17:43:06 1.27 --- libarray.tex 2000/12/11 20:57:13 1.28 *************** *** 190,197 **** Representation (XDR) data as used in some remote procedure call systems.} ! \seetitle[http://numpy.sourceforge.net/numdoc/numdoc.pdf]{The Numerical Python Manual}{The Numeric Python extension (NumPy) defines another array type; see \url{http://numpy.sourceforge.net/} for further information ! about Numerical Python.} \end{seealso} --- 190,199 ---- Representation (XDR) data as used in some remote procedure call systems.} ! \seetitle[http://numpy.sourceforge.net/numdoc/HTML/numdoc.html]{The Numerical Python Manual}{The Numeric Python extension (NumPy) defines another array type; see \url{http://numpy.sourceforge.net/} for further information ! about Numerical Python. (A PDF version of the NumPy manual ! is available at ! \url{http://numpy.sourceforge.net/numdoc/numdoc.pdf}.} \end{seealso} From python-dev@python.org Mon Dec 11 22:12:12 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 11 Dec 2000 14:12:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_parser,1.2,1.3 Message-ID: <200012112212.OAA25590@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv25558/Lib/test/output Modified Files: test_parser Log Message: Added tests to avoid regression on bug #125375. roundtrip(): Show the offending syntax tree when things break; this makes it a little easier to debug the module by adding test cases. (Still need better tests for this module, but there's not enough time today.) Index: test_parser =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_parser,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_parser 2000/08/25 22:42:40 1.2 --- test_parser 2000/12/11 22:12:09 1.3 *************** *** 16,19 **** --- 16,31 ---- expr: foo(a, b, c, **kw) expr: foo + bar + expr: lambda: 0 + expr: lambda x: 0 + expr: lambda *y: 0 + expr: lambda *y, **z: 0 + expr: lambda **z: 0 + expr: lambda x, y: 0 + expr: lambda foo=bar: 0 + expr: lambda foo=bar, spaz=nifty+spit: 0 + expr: lambda foo=bar, **z: 0 + expr: lambda foo=bar, blaz=blat+2, **z: 0 + expr: lambda foo=bar, blaz=blat+2, *y, **z: 0 + expr: lambda x, *y, **z: 0 Statements: *************** *** 38,41 **** --- 50,55 ---- suite: a >>= b suite: a **= b + suite: def f(): pass + suite: def f(foo=bar): pass Invalid parse trees: From python-dev@python.org Mon Dec 11 22:12:12 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 11 Dec 2000 14:12:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_parser.py,1.2,1.3 Message-ID: <200012112212.OAA25589@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv25558/Lib/test Modified Files: test_parser.py Log Message: Added tests to avoid regression on bug #125375. roundtrip(): Show the offending syntax tree when things break; this makes it a little easier to debug the module by adding test cases. (Still need better tests for this module, but there's not enough time today.) Index: test_parser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_parser.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_parser.py 2000/08/25 22:42:40 1.2 --- test_parser.py 2000/12/11 22:12:09 1.3 *************** *** 16,20 **** st1 = f(s) t = st1.totuple() ! st2 = parser.sequence2ast(t) def roundtrip_fromfile(filename): --- 16,25 ---- st1 = f(s) t = st1.totuple() ! try: ! st2 = parser.sequence2ast(t) ! except parser.ParserError: ! print "Failing syntax tree:" ! pprint.pprint(t) ! raise def roundtrip_fromfile(filename): *************** *** 47,50 **** --- 52,67 ---- test_expr("foo(a, b, c, **kw)") test_expr("foo + bar") + test_expr("lambda: 0") + test_expr("lambda x: 0") + test_expr("lambda *y: 0") + test_expr("lambda *y, **z: 0") + test_expr("lambda **z: 0") + test_expr("lambda x, y: 0") + test_expr("lambda foo=bar: 0") + test_expr("lambda foo=bar, spaz=nifty+spit: 0") + test_expr("lambda foo=bar, **z: 0") + test_expr("lambda foo=bar, blaz=blat+2, **z: 0") + test_expr("lambda foo=bar, blaz=blat+2, *y, **z: 0") + test_expr("lambda x, *y, **z: 0") print *************** *** 72,75 **** --- 89,94 ---- test_suite("a >>= b") test_suite("a **= b") + test_suite("def f(): pass") + test_suite("def f(foo=bar): pass") #d = os.path.dirname(os.__file__) From python-dev@python.org Mon Dec 11 22:29:26 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 11 Dec 2000 14:29:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom __init__.py,1.1,1.2 Message-ID: <200012112229.OAA27333@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory slayer.i.sourceforge.net:/tmp/cvs-serv27311 Modified Files: __init__.py Log Message: Update the docstring. Add a Node class that defines the NodeType constants, based on discussion in the XML-SIG. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/__init__.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** __init__.py 2000/06/29 19:28:01 1.1 --- __init__.py 2000/12/11 22:29:23 1.2 *************** *** 1,10 **** """W3C Document Object Model implementation for Python. ! The Python mapping of the Document Object Model is documented in <...>. This package contains the following modules: minidom -- A simple implementation of the Level 1 DOM with namespace ! support added (based on the Level 2 specification). """ --- 1,39 ---- """W3C Document Object Model implementation for Python. ! The Python mapping of the Document Object Model is documented in the ! Python Library Reference in the section on the xml.dom package. This package contains the following modules: minidom -- A simple implementation of the Level 1 DOM with namespace ! support added (based on the Level 2 specification) and other ! minor Level 2 functionality. + pulldom -- DOM builder supporting on-demand tree-building for selected + subtrees of the document. + """ + + + class Node: + """Class giving the NodeType constants.""" + + # DOM implementations may use this as a base class for their own + # Node implementations. If they don't, the constants defined here + # should still be used as the canonical definitions as they match + # the values given in the W3C recommendation. Client code can + # safely refer to these values in all tests of Node.nodeType + # values. + + ELEMENT_NODE = 1 + ATTRIBUTE_NODE = 2 + TEXT_NODE = 3 + CDATA_SECTION_NODE = 4 + ENTITY_REFERENCE_NODE = 5 + ENTITY_NODE = 6 + PROCESSING_INSTRUCTION_NODE = 7 + COMMENT_NODE = 8 + DOCUMENT_NODE = 9 + DOCUMENT_TYPE_NODE = 10 + DOCUMENT_FRAGMENT_NODE = 11 + NOTATION_NODE = 12 From python-dev@python.org Mon Dec 11 22:39:28 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 11 Dec 2000 14:39:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref5.tex,1.39,1.40 Message-ID: <200012112239.OAA28726@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/ref In directory slayer.i.sourceforge.net:/tmp/cvs-serv28715/ref Modified Files: ref5.tex Log Message: Adjust explanation of operator precedence summary -- exponentiation groups from right to left! Closes bug #125391. Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -r1.39 -r1.40 *** ref5.tex 2000/12/07 04:54:02 1.39 --- ref5.tex 2000/12/11 22:39:24 1.40 *************** *** 900,904 **** is explicitly given, operators are binary. Operators in the same box group left to right (except for comparisons, which chain from left to ! right --- see above). \begin{tableii}{c|l}{textrm}{Operator}{Description} --- 900,905 ---- is explicitly given, operators are binary. Operators in the same box group left to right (except for comparisons, which chain from left to ! right --- see above, and exponentiation, which groups from right to ! left). \begin{tableii}{c|l}{textrm}{Operator}{Description} From python-dev@python.org Mon Dec 11 23:08:15 2000 From: python-dev@python.org (Thomas Wouters) Date: Mon, 11 Dec 2000 15:08:15 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.56,1.57 pep-0206.txt,1.9,1.10 pep-0216.txt,1.7,1.8 Message-ID: <200012112308.PAA31630@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv31550 Modified Files: pep-0000.txt pep-0206.txt pep-0216.txt Log Message: Update Moshe's email address to the one that won't stop working soon, and also test CVS write access on this new installation. Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -r1.56 -r1.57 *** pep-0000.txt 2000/12/08 15:05:09 1.56 --- pep-0000.txt 2000/12/11 23:08:11 1.57 *************** *** 161,165 **** Wouters, Thomas thomas@xs4all.net Yee, Ka-Ping ping@lfw.org ! Zadka, Moshe moshez@math.huji.ac.il Zhu, Huaiyu hzhu@users.sourceforge.net --- 161,165 ---- Wouters, Thomas thomas@xs4all.net Yee, Ka-Ping ping@lfw.org ! Zadka, Moshe moshez@zadka.site.co.il Zhu, Huaiyu hzhu@users.sourceforge.net Index: pep-0206.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0206.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** pep-0206.txt 2000/11/28 22:23:25 1.9 --- pep-0206.txt 2000/12/11 23:08:11 1.10 *************** *** 2,6 **** Title: 2.0 Batteries Included Version: $Revision$ ! Author: moshez@math.huji.ac.il (Moshe Zadka) Python-Version: 2.0 Status: Draft --- 2,6 ---- Title: 2.0 Batteries Included Version: $Revision$ ! Author: moshez@zadka.site.co.il (Moshe Zadka) Python-Version: 2.0 Status: Draft Index: pep-0216.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0216.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** pep-0216.txt 2000/11/10 17:00:05 1.7 --- pep-0216.txt 2000/12/11 23:08:11 1.8 *************** *** 2,6 **** Title: Docstring Format Version: $Revision$ ! Author: moshez@math.huji.ac.il (Moshe Zadka) Status: Draft Type: Informational --- 2,6 ---- Title: Docstring Format Version: $Revision$ ! Author: moshez@zadka.site.co.il (Moshe Zadka) Status: Draft Type: Informational From python-dev@python.org Mon Dec 11 23:11:56 2000 From: python-dev@python.org (Thomas Wouters) Date: Mon, 11 Dec 2000 15:11:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref3.tex,1.53,1.54 Message-ID: <200012112311.PAA32105@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/ref In directory slayer.i.sourceforge.net:/tmp/cvs-serv31968 Modified Files: ref3.tex Log Message: Additional docs for __iadd__ and family, closing SF bug #117178 and SF patch #102169. Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -r1.53 -r1.54 *** ref3.tex 2000/12/07 04:49:34 1.53 --- ref3.tex 2000/12/11 23:11:51 1.54 *************** *** 1294,1297 **** --- 1294,1323 ---- \end{methoddesc} + \begin{methoddesc}[numeric object]{__iadd__}{self, other} + \methodline[numeric object]{__isub__}{self, other} + \methodline[numeric object]{__imul__}{self, other} + \methodline[numeric object]{__idiv__}{self, other} + \methodline[numeric object]{__imod__}{self, other} + \methodline[numeric object]{__ipow__}{self, other\optional{, modulo}} + \methodline[numeric object]{__ilshift__}{self, other} + \methodline[numeric object]{__irshift__}{self, other} + \methodline[numeric object]{__iand__}{self, other} + \methodline[numeric object]{__ixor__}{self, other} + \methodline[numeric object]{__ior__}{self, other} + These methods are called to implement the augmented arithmetic operations + (\code{+=}, \code{-=}, \code{*=}, \code{/=}, \code{\%=}, \code{**=}, + \code{<<=}, \code{>>=}, \code{\&=}, \code{\^=}, \code{|=}). These methods + should attempt to do the operation in-place (modifying \var{self}) and + return the result (which could be, but does not have to be, \var{self}). If + a specific method is not defined, the augmented operation falls back to the + normal methods. For instance, to evaluate the expression + \var{x}\code{+=}\var{y}, where \var{x} is an instance of a class that has an + \method{__iadd__()} method, \code{\var{x}.__iadd__(\var{y})} is called. If + \var{x} is an instance of a class that does not define a \method{__iadd()} + method, \code{\var{x}.__add__(\var{y})} and \code{\var{y}.__radd__(\var{x})} + are considered, as with the evaluation of \var{x}\code{+}\var{y}. + + \end{methoddesc} + \begin{methoddesc}[numeric object]{__neg__}{self} \methodline[numeric object]{__pos__}{self} From python-dev@python.org Tue Dec 12 00:38:01 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 11 Dec 2000 16:38:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.178,2.179 Message-ID: <200012120038.QAA09946@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv9929 Modified Files: posixmodule.c Log Message: Trivial typo fix, submitted by Charles Waldman (SF patch #102794). Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.178 retrieving revision 2.179 diff -C2 -r2.178 -r2.179 *** posixmodule.c 2000/12/06 21:45:33 2.178 --- posixmodule.c 2000/12/12 00:37:58 2.179 *************** *** 2967,2971 **** static char posix_waitpid__doc__[] = "waitpid(pid, options) -> (pid, status)\n\ ! Wait for completion of a give child process."; static PyObject * --- 2967,2971 ---- static char posix_waitpid__doc__[] = "waitpid(pid, options) -> (pid, status)\n\ ! Wait for completion of a given child process."; static PyObject * From python-dev@python.org Tue Dec 12 01:18:43 2000 From: python-dev@python.org (Tim Peters) Date: Mon, 11 Dec 2000 17:18:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules selectmodule.c,2.48,2.49 Message-ID: <200012120118.RAA14117@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv14057/python/dist/src/Modules Modified Files: selectmodule.c Log Message: SF bug 110843: Low FD_SETSIZE limit on Win32 (PR#41). Boosted to 512. Index: selectmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/selectmodule.c,v retrieving revision 2.48 retrieving revision 2.49 diff -C2 -r2.48 -r2.49 *** selectmodule.c 2000/09/28 21:33:44 2.48 --- selectmodule.c 2000/12/12 01:18:41 2.49 *************** *** 1,3 **** - /* select - Module containing unix select(2) call. Under Unix, the file descriptors are small integers. --- 1,2 ---- *************** *** 9,12 **** --- 8,21 ---- #include "Python.h" + + /* Windows #defines FD_SETSIZE to 64 if FD_SETSIZE isn't already defined. + 64 is too small (too many people have bumped into that limit). + Here we boost it. + Users who want even more than the boosted limit should #define + FD_SETSIZE higher before this; e.g., via compiler /D switch. + */ + #if defined(MS_WINDOWS) && !defined(FD_SETSIZE) + #define FD_SETSIZE 512 + #endif #ifdef HAVE_UNISTD_H From python-dev@python.org Tue Dec 12 01:18:43 2000 From: python-dev@python.org (Tim Peters) Date: Mon, 11 Dec 2000 17:18:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.83,1.84 Message-ID: <200012120118.RAA14113@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv14057/python/dist/src/Misc Modified Files: NEWS Log Message: SF bug 110843: Low FD_SETSIZE limit on Win32 (PR#41). Boosted to 512. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -r1.83 -r1.84 *** NEWS 2000/12/01 07:59:35 1.83 --- NEWS 2000/12/12 01:18:39 1.84 *************** *** 28,31 **** --- 28,39 ---- via %u raised an error if it was too big to fit in an int. + Windows changes + + - select module: By default under Windows, a select() call + can specify no more than 64 sockets. Python now boosts + this Microsoft default to 512. If you need even more than + that, see the MS docs (you'll need to #define FD_SETSIZE + and recompile Python from source). + What's New in Python 2.0? From python-dev@python.org Tue Dec 12 01:58:59 2000 From: python-dev@python.org (Tim Peters) Date: Mon, 11 Dec 2000 17:58:59 -0800 Subject: [Python-checkins] CVS: python/dist/src/PC msvcrtmodule.c,1.5,1.6 Message-ID: <200012120158.RAA17281@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv17191/python/dist/src/pc Modified Files: msvcrtmodule.c Log Message: Partial fix for SF bug 122780 (msvcrt.locking constants aren't defined). Still needs docs; see bug report (which was reassigned to Fred) for MS's docs. Index: msvcrtmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/msvcrtmodule.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** msvcrtmodule.c 2000/06/30 17:48:51 1.5 --- msvcrtmodule.c 2000/12/12 01:58:56 1.6 *************** *** 19,26 **** #include "Python.h" #include "malloc.h" // Force the malloc heap to clean itself up, and free unused blocks // back to the OS. (According to the docs, only works on NT.) ! static PyObject *msvcrt_heapmin(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, ":heapmin")) --- 19,30 ---- #include "Python.h" #include "malloc.h" + #include + #include + #include // Force the malloc heap to clean itself up, and free unused blocks // back to the OS. (According to the docs, only works on NT.) ! static PyObject * ! msvcrt_heapmin(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, ":heapmin")) *************** *** 35,39 **** // Perform locking operations on a C runtime file descriptor. ! static PyObject *msvcrt_locking(PyObject *self, PyObject *args) { int fd; --- 39,44 ---- // Perform locking operations on a C runtime file descriptor. ! static PyObject * ! msvcrt_locking(PyObject *self, PyObject *args) { int fd; *************** *** 56,60 **** // Set the file translation mode for a C runtime file descriptor. ! static PyObject *msvcrt_setmode(PyObject *self, PyObject *args) { int fd; --- 61,66 ---- // Set the file translation mode for a C runtime file descriptor. ! static PyObject * ! msvcrt_setmode(PyObject *self, PyObject *args) { int fd; *************** *** 71,75 **** // Convert an OS file handle to a C runtime file descriptor. ! static PyObject *msvcrt_open_osfhandle(PyObject *self, PyObject *args) { long handle; --- 77,82 ---- // Convert an OS file handle to a C runtime file descriptor. ! static PyObject * ! msvcrt_open_osfhandle(PyObject *self, PyObject *args) { long handle; *************** *** 88,92 **** // Convert a C runtime file descriptor to an OS file handle. ! static PyObject *msvcrt_get_osfhandle(PyObject *self, PyObject *args) { int fd; --- 95,100 ---- // Convert a C runtime file descriptor to an OS file handle. ! static PyObject * ! msvcrt_get_osfhandle(PyObject *self, PyObject *args) { int fd; *************** *** 107,113 **** /* Console I/O */ - #include ! static PyObject *msvcrt_kbhit(PyObject *self, PyObject *args) { int ok; --- 115,121 ---- /* Console I/O */ ! static PyObject * ! msvcrt_kbhit(PyObject *self, PyObject *args) { int ok; *************** *** 120,124 **** } ! static PyObject *msvcrt_getch(PyObject *self, PyObject *args) { int ch; --- 128,133 ---- } ! static PyObject * ! msvcrt_getch(PyObject *self, PyObject *args) { int ch; *************** *** 135,139 **** } ! static PyObject *msvcrt_getche(PyObject *self, PyObject *args) { int ch; --- 144,149 ---- } ! static PyObject * ! msvcrt_getche(PyObject *self, PyObject *args) { int ch; *************** *** 150,154 **** } ! static PyObject *msvcrt_putch(PyObject *self, PyObject *args) { char ch; --- 160,165 ---- } ! static PyObject * ! msvcrt_putch(PyObject *self, PyObject *args) { char ch; *************** *** 162,166 **** } ! static PyObject *msvcrt_ungetch(PyObject *self, PyObject *args) { char ch; --- 173,178 ---- } ! static PyObject * ! msvcrt_ungetch(PyObject *self, PyObject *args) { char ch; *************** *** 176,179 **** --- 188,206 ---- + static void + insertint(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); + } + } + + /* List of functions exported by this module */ static struct PyMethodDef msvcrt_functions[] = { *************** *** 194,197 **** initmsvcrt(void) { ! Py_InitModule("msvcrt", msvcrt_functions); } --- 221,232 ---- initmsvcrt(void) { ! PyObject *m = Py_InitModule("msvcrt", msvcrt_functions); ! PyObject *d = PyModule_GetDict(m); ! ! /* constants for the locking() function's mode argument */ ! insertint(d, "LK_LOCK", _LK_LOCK); ! insertint(d, "LK_NBLCK", _LK_NBLCK); ! insertint(d, "LK_NBRLCK", _LK_NBRLCK); ! insertint(d, "LK_RLCK", _LK_RLCK); ! insertint(d, "LK_UNLCK", _LK_UNLCK); } From python-dev@python.org Tue Dec 12 02:00:40 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 11 Dec 2000 18:00:40 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0208.txt,1.6,1.7 Message-ID: <200012120200.SAA17448@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv17440 Modified Files: pep-0208.txt Log Message: Some stupid mechanical changes, such as remove trailing whitespace, double spaces between sentences. Also fix a few typos, add an XXX note, and change the URL for the implementation to be the patch detail page instead of the download page. I hope Neil doesn't mind. Index: pep-0208.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0208.txt,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** pep-0208.txt 2000/12/06 21:22:52 1.6 --- pep-0208.txt 2000/12/12 02:00:37 1.7 *************** *** 21,58 **** set the type flag are handled in a backwards compatible manner. Allowing operations handle different types is often simpler, more ! flexible, and faster then having the interpreter do coercion. ! Rational When implementing numeric or other related operations, it is often desirable to provide not only operations between operands of one type only, e.g. integer + integer, but to generalize the idea behind the ! operation to other type combinations as well, e.g. integer + float. A common approach to this mixed type situation is to provide a method of "lifting" the operands to a common type (coercion) and then use ! that type's operand method as execution mechanism. Yet, this strategy ! has a few drawbacks: * the "lifting" process creates at least one new (temporary) ! operand object, * since the coercion method is not being told about the operation that is to follow, it is not possible to implement operation ! specific coercion of types, * there is no elegant way to solve situations were a common type ! is not at hand, and * the coercion method will always have to be called prior to the ! operation's method itself. A fix for this situation is obviously needed, since these drawbacks make implementations of types needing these features very cumbersome, ! if not impossible. As an example, have a look at the DateTime and DateTimeDelta[1] types, the first being absolute, the second relative. You can always add a relative value to an absolute one, ! giving a new absolute value. Yet, there is no common type which the existing coercion mechanism could use to implement that operation. --- 21,58 ---- set the type flag are handled in a backwards compatible manner. Allowing operations handle different types is often simpler, more ! flexible, and faster than having the interpreter do coercion. ! Rationale When implementing numeric or other related operations, it is often desirable to provide not only operations between operands of one type only, e.g. integer + integer, but to generalize the idea behind the ! operation to other type combinations as well, e.g. integer + float. A common approach to this mixed type situation is to provide a method of "lifting" the operands to a common type (coercion) and then use ! that type's operand method as execution mechanism. Yet, this strategy ! has a few drawbacks: * the "lifting" process creates at least one new (temporary) ! operand object, * since the coercion method is not being told about the operation that is to follow, it is not possible to implement operation ! specific coercion of types, * there is no elegant way to solve situations were a common type ! is not at hand, and * the coercion method will always have to be called prior to the ! operation's method itself. A fix for this situation is obviously needed, since these drawbacks make implementations of types needing these features very cumbersome, ! if not impossible. As an example, have a look at the DateTime and DateTimeDelta[1] types, the first being absolute, the second relative. You can always add a relative value to an absolute one, ! giving a new absolute value. Yet, there is no common type which the existing coercion mechanism could use to implement that operation. *************** *** 67,73 **** Instead of using a central coercion method, the process of handling ! different operand types is simply left to the operation. If the operation finds that it cannot handle the given operand type ! combination, it may return a special singleton as indicator. Note that "numbers" (anything that implements the number protocol, or --- 67,73 ---- Instead of using a central coercion method, the process of handling ! different operand types is simply left to the operation. If the operation finds that it cannot handle the given operand type ! combination, it may return a special singleton as indicator. Note that "numbers" (anything that implements the number protocol, or *************** *** 78,84 **** careful to make numbers that don't know anything about the new strategy (old style numbers) work just as well as those that expect ! the new scheme (new style numbers). Furthermore, binary compatibility is a must, meaning that the interpreter may only access and use new ! style operations if the number indicates the availability of these. A new style number is considered by the interpreter as such if and --- 78,84 ---- careful to make numbers that don't know anything about the new strategy (old style numbers) work just as well as those that expect ! the new scheme (new style numbers). Furthermore, binary compatibility is a must, meaning that the interpreter may only access and use new ! style operations if the number indicates the availability of these. A new style number is considered by the interpreter as such if and *************** *** 86,118 **** difference between an old style number and a new style one is that the numeric slot functions can no longer assume to be passed arguments of ! identical type. New style slots must check all arguments for proper ! type and implement the necessary conversions themselves. This may seem to cause more work on the behalf of the type implementor, but is in fact no more difficult than writing the same kind of routines for an ! old style coercion slot. If a new style slot finds that it cannot handle the passed argument type combination, it may return a new reference of the special ! singleton Py_NotImplemented to the caller. This will cause the caller to try the other operands operation slots until it finds a slot that ! does implement the operation for the specific type combination. If ! none of the possible slots succeed, it raises a TypeError. To make the implementation easy to understand (the whole topic is esoteric enough), a new layer in the handling of numeric operations is ! introduced. This layer takes care of all the different cases that need to be taken into account when dealing with all the possible ! combinations of old and new style numbers. It is implemented by the ! two functions _PyNumber_BinaryOperation() and ! _PyNumber_TernaryOperation(), which both are internal functions that ! only the functions in Objects/abstract.c have access to. The numeric ! API (PyNumber_*) is easy to adapt to this new layer. As a side-effect all numeric slots can be NULL-checked (this has to be done anyway, so the added feature comes at no extra cost). ! The scheme used by the layer to execute a binary operation is as ! follows: v | w | Action taken --- 86,118 ---- difference between an old style number and a new style one is that the numeric slot functions can no longer assume to be passed arguments of ! identical type. New style slots must check all arguments for proper ! type and implement the necessary conversions themselves. This may seem to cause more work on the behalf of the type implementor, but is in fact no more difficult than writing the same kind of routines for an ! old style coercion slot. If a new style slot finds that it cannot handle the passed argument type combination, it may return a new reference of the special ! singleton Py_NotImplemented to the caller. This will cause the caller to try the other operands operation slots until it finds a slot that ! does implement the operation for the specific type combination. If ! none of the possible slots succeed, it raises a TypeError. To make the implementation easy to understand (the whole topic is esoteric enough), a new layer in the handling of numeric operations is ! introduced. This layer takes care of all the different cases that need to be taken into account when dealing with all the possible ! combinations of old and new style numbers. It is implemented by the ! two static functions binary_op() and ternary_op(), which are both ! internal functions that only the functions in Objects/abstract.c ! have access to. The numeric API (PyNumber_*) is easy to adapt to ! this new layer. As a side-effect all numeric slots can be NULL-checked (this has to be done anyway, so the added feature comes at no extra cost). ! The scheme used by the layer to execute a binary operation is as ! follows: v | w | Action taken *************** *** 125,137 **** The indicated action sequence is executed from left to right until either the operation succeeds and a valid result (!= ! Py_NotImplemented) is returned or an exception is raised. Exceptions ! are returned to the calling function as-is. If a slot returns ! Py_NotImplemented, the next item in the sequence is executed. Note that coerce(v,w) will use the old style nb_coerce slot methods ! via a call to PyNumber_Coerce(). - Ternary operations have a few more cases to handle: - v | w | z | Action taken ----+-----+-----+------------------------------------ --- 125,137 ---- The indicated action sequence is executed from left to right until either the operation succeeds and a valid result (!= ! Py_NotImplemented) is returned or an exception is raised. Exceptions ! are returned to the calling function as-is. If a slot returns ! Py_NotImplemented, the next item in the sequence is executed. Note that coerce(v,w) will use the old style nb_coerce slot methods ! via a call to PyNumber_Coerce(). ! ! Ternary operations have a few more cases to handle: v | w | z | Action taken ----+-----+-----+------------------------------------ *************** *** 144,198 **** old | new | old | w.op(v,w,z), coerce(v,w,z), v.op(v,w,z) old | old | old | coerce(v,w,z), v.op(v,w,z) ! The same notes as above, except that coerce(v,w,z) actually does: - if z != Py_None: - coerce(v,w), coerce(v,z), coerce(w,z) - else: - # treat z as absent variable - coerce(v,w) - The current implementation uses this scheme already (there's only one ! ternary slot: nb_pow(a,b,c)). Note that the numeric protocol is also used for some other related tasks, e.g. sequence concatenation. These can also benefit from the new mechanism by implementing right-hand operations for type ! combinations that would otherwise fail to work. As an example, take ! string concatenation: currently you can only do string + string. With the new mechanism, a new string-like type could implement new_type + string and string + new_type, even though strings don't know anything ! about new_type. Since comparisons also rely on coercion (every time you compare an integer to a float, the integer is first converted to float and then ! compared...), a new slot to handle numeric comparisons is needed: ! PyObject *nb_cmp(PyObject *v, PyObject *w) This slot should compare the two objects and return an integer object ! stating the result. Currently, this result integer may only be -1, 0, 1. If the slot cannot handle the type combination, it may return a ! reference to Py_NotImplemented. Note that this slot is still in flux ! since it should take into account rich comparisons (ie. PEP 207). ! Numeric comparisons are handled by a new numeric protocol API: ! PyObject *PyNumber_Compare(PyObject *v, PyObject *w) This function compare the two objects as "numbers" and return an ! integer object stating the result. Currently, this result integer may ! only be -1, 0, 1. In case the operation cannot be handled by the given ! objects, a TypeError is raised. The PyObject_Compare() API needs to adjusted accordingly to make use ! of this new API. Other changes include adapting some of the built-in functions (e.g. ! cmp()) to use this API as well. Also, PyNumber_CoerceEx() will need to ! check for new style numbers before calling the nb_coerce slot. New style numbers don't provide a coercion slot and thus cannot be ! explicitly coerced. --- 144,199 ---- old | new | old | w.op(v,w,z), coerce(v,w,z), v.op(v,w,z) old | old | old | coerce(v,w,z), v.op(v,w,z) + + The same notes as above, except that coerce(v,w,z) actually does: ! if z != Py_None: ! coerce(v,w), coerce(v,z), coerce(w,z) ! else: ! # treat z as absent variable ! coerce(v,w) The current implementation uses this scheme already (there's only one ! ternary slot: nb_pow(a,b,c)). Note that the numeric protocol is also used for some other related tasks, e.g. sequence concatenation. These can also benefit from the new mechanism by implementing right-hand operations for type ! combinations that would otherwise fail to work. As an example, take ! string concatenation: currently you can only do string + string. With the new mechanism, a new string-like type could implement new_type + string and string + new_type, even though strings don't know anything ! about new_type. Since comparisons also rely on coercion (every time you compare an integer to a float, the integer is first converted to float and then ! compared...), a new slot to handle numeric comparisons is needed: ! PyObject *nb_cmp(PyObject *v, PyObject *w) This slot should compare the two objects and return an integer object ! stating the result. Currently, this result integer may only be -1, 0, 1. If the slot cannot handle the type combination, it may return a ! reference to Py_NotImplemented. [XXX Note that this slot is still ! in flux since it should take into account rich comparisons ! (i.e. PEP 207).] ! Numeric comparisons are handled by a new numeric protocol API: ! PyObject *PyNumber_Compare(PyObject *v, PyObject *w) This function compare the two objects as "numbers" and return an ! integer object stating the result. Currently, this result integer may ! only be -1, 0, 1. In case the operation cannot be handled by the given ! objects, a TypeError is raised. The PyObject_Compare() API needs to adjusted accordingly to make use ! of this new API. Other changes include adapting some of the built-in functions (e.g. ! cmp()) to use this API as well. Also, PyNumber_CoerceEx() will need to ! check for new style numbers before calling the nb_coerce slot. New style numbers don't provide a coercion slot and thus cannot be ! explicitly coerced. *************** *** 217,221 **** [1] http://www.lemburg.com/files/python/mxDateTime.html ! [2] http://sourceforge.net/patch/download.php?id=102652 [3] http://www.lemburg.com/files/python/CoercionProposal.html --- 218,222 ---- [1] http://www.lemburg.com/files/python/mxDateTime.html ! [2] http://sourceforge.net/patch/?func=detailpatch&patch_id=102652&group_id=5470 [3] http://www.lemburg.com/files/python/CoercionProposal.html From python-dev@python.org Tue Dec 12 14:45:37 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Tue, 12 Dec 2000 06:45:37 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/encodings __init__.py,1.4,1.5 Message-ID: <200012121445.GAA25260@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/encodings In directory slayer.i.sourceforge.net:/tmp/cvs-serv25240 Modified Files: __init__.py Log Message: Changed .getaliases() support to register the new aliases in the encodings package aliases mapping dictionary rather than in the internal cache used by the search function. This enables aliases to take advantage of the full normalization process applied to encoding names which was previously not available. The patch restricts alias registration to new aliases. Existing aliases cannot be overridden anymore. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/__init__.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** __init__.py 2000/06/13 12:04:05 1.4 --- __init__.py 2000/12/12 14:45:35 1.5 *************** *** 19,25 **** * getaliases() -> sequence of encoding name strings to use as aliases ! Alias names returned by getaliases() must be lower-case. - Written by Marc-Andre Lemburg (mal@lemburg.com). --- 19,26 ---- * getaliases() -> sequence of encoding name strings to use as aliases ! Alias names returned by getaliases() must be standard encoding ! names as defined above (lower-case, hyphens converted to ! underscores). Written by Marc-Andre Lemburg (mal@lemburg.com). *************** *** 46,49 **** --- 47,51 ---- mod = __import__(modname,globals(),locals(),'*') except ImportError,why: + # cache misses _cache[encoding] = None return None *************** *** 64,69 **** (__name__,modname) ! # Cache the encoding and its aliases _cache[encoding] = entry try: codecaliases = mod.getaliases() --- 66,74 ---- (__name__,modname) ! # Cache the codec registry entry _cache[encoding] = entry + + # Register its aliases (without overwriting previously registered + # aliases) try: codecaliases = mod.getaliases() *************** *** 72,76 **** else: for alias in codecaliases: ! _cache[alias] = entry return entry --- 77,84 ---- else: for alias in codecaliases: ! if not aliases.aliases.has_key(alias): ! aliases.aliases[alias] = modname ! ! # Return the registry entry return entry From python-dev@python.org Tue Dec 12 15:25:00 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 12 Dec 2000 07:25:00 -0800 Subject: [Python-checkins] CVS: python/dist/src LICENSE,1.7,1.8 Message-ID: <200012121525.HAA29665@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv29653 Modified Files: LICENSE Log Message: Typo detected by "the miraculous Debian package lint tool "lintian" (http://package.debian.org/lintian), which includes a spellchecker for common typos in control files of packages... You see, we're so paranoid that we even have automatic tools that keep monitoring license files ;-)" (Gregor Hoffleit) Index: LICENSE =================================================================== RCS file: /cvsroot/python/python/dist/src/LICENSE,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** LICENSE 2000/10/10 14:49:44 1.7 --- LICENSE 2000/12/12 15:24:57 1.8 *************** *** 10,14 **** Virginia where he released several versions of the software. Python 1.6 was the last of the versions released by CNRI. In 2000, Guido and ! the Python core developement team moved to BeOpen.com to form the BeOpen PythonLabs team (www.pythonlabs.com). Python 2.0 is the first release from PythonLabs. Thanks to the many outside volunteers who --- 10,14 ---- Virginia where he released several versions of the software. Python 1.6 was the last of the versions released by CNRI. In 2000, Guido and ! the Python core development team moved to BeOpen.com to form the BeOpen PythonLabs team (www.pythonlabs.com). Python 2.0 is the first release from PythonLabs. Thanks to the many outside volunteers who From python-dev@python.org Tue Dec 12 17:34:42 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 12 Dec 2000 09:34:42 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0222.txt,1.5,1.6 Message-ID: <200012121734.JAA12727@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv12545 Modified Files: pep-0222.txt Log Message: Add a first cut at a proposed new interface (still incomplete) Index: pep-0222.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0222.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** pep-0222.txt 2000/11/10 17:06:53 1.5 --- pep-0222.txt 2000/12/12 17:34:39 1.6 *************** *** 57,70 **** seems to me that the main reason it is there is to accomodate ! form['field'].file syntax. How about the following: ! form['field'] = '' #no values for key ! form['field'] = 'string' #one value in submission for key ! form['field'] = ['string', 'string', ....] #multiple values ! form['field'] = {'fileName':'remote/path', ! 'binaryValue':'@UIHJBV29489erht...'} #one file ! form['field'] = [{'fileName':'remote/path', ! 'binaryValue':'@UIHJBV29489erht...'}, ! {'fileName':'another/path', ! 'binaryValue':'7r7w7@@@@'}] #multiple files cgi.py: I'd prefer "input" or "submission" for the suggested --- 57,70 ---- seems to me that the main reason it is there is to accomodate ! form['field'].file syntax. How about the following: ! form['field'] = '' #no values for key ! form['field'] = 'string' #one value in submission for key ! form['field'] = ['string', 'string', ....] #multiple values ! form['field'] = {'fileName':'remote/path', ! 'binaryValue':'@UIHJBV29489erht...'} #one file ! form['field'] = [{'fileName':'remote/path', ! 'binaryValue':'@UIHJBV29489erht...'}, ! {'fileName':'another/path', ! 'binaryValue':'7r7w7@@@@'}] #multiple files cgi.py: I'd prefer "input" or "submission" for the suggested *************** *** 130,136 **** inappropriate. - Copyright This document has been placed in the public domain. --- 130,269 ---- inappropriate. + * None yet + Proposed Interface + + XXX open issues: naming convention (studlycaps or underline-separated?); + no interface for file uploads yet; need to look at all the various + packages to see if there's anything else missing; need to look at + the cgi.parse*() functions and see if they can be simplified, too. + + Parsing functions: carry over most of the parse* functions from cgi.py + + # The Response class borrows most of its methods from Zope's + # HTTPResponse class. + + class Response: + """ + Attributes: + status: HTTP status code to return + headers: dictionary of response headers + body: string containing the body of the HTTP response + """ + + def __init__(self, status=200, headers={}, body=""): + pass + + def setStatus(self, status, reason=None): + "Set the numeric HTTP response code" + pass + + def setHeader(self, name, value): + "Set an HTTP header" + pass + + def setBody(self, body): + "Set the body of the response" + pass + + def setCookie(self, name, value, + path = XXX, # What to use as defaults? + comment = XXX, + domain = XXX, + max-age = XXX, + expires = XXX, + secure = XXX + ): + "Set a cookie" + pass + + def expireCookie(self, name): + "Remove a cookie from the user" + pass + + def redirect(self, url): + "Redirect the browser to another URL" + pass + + def __str__(self): + "Convert entire response to a string" + pass + + def dump(self): + "Return a string representation useful for debugging" + pass + + # XXX methods for specific classes of error:serverError, badRequest, etc.? + + + class Request: + + """ + Attributes: + .headers : dictionary containing HTTP headers + .cookies : dictionary of cookies + .form : data from the form + .env : environment dictionary + """ + + def __init__(self, environ=os.environ, stdin=sys.stdin, + keep_blank_values=0, strict_parsing=0): + """Initialize the request object, using the provided environment + and standard input.""" + pass + + # Should people just use the dictionaries directly? + def getHeader(self, name, default=None): + pass + + def getCookie(self, name, default=None): + pass + + def getField(self, name, default=None): + pass + + def getURL(self, n=0, query_string=0): + """Return the URL of the current request, chopping off 'n' path + components from the right. Eg. if the URL is + "http://foo.com/bar/baz/qux", n=2 would return + "http://foo.com/bar". Does not include the query string (if + any) + """ + + def getBaseURL(self, n=0): + """Return the base URL of the current request, adding 'n' path + components to the end to recreate more of the whole URL. + + Eg. if the request URL is + "http://foo.com/q/bar/baz/qux", n=0 would return + "http://foo.com/", and n=2 "http://foo.com/q/bar". + + Returned URL does not include the query string, if any. + """ + + def dump(self): + "String representation suitable for debugging output" + pass + + # Possibilities? + def getBrowser(self): + "Returns Mozilla/IE/Lynx/Opera/whatever" + + def isSecure(self): + "Return true if this is an SSLified request" + + + def wrapper(func, logfile=None): + """ + Calls the function 'func', passing it the arguments + (request, response, logfile). Exceptions are trapped and + sent to the file 'logfile'. + """ + pass + + + Copyright + This document has been placed in the public domain. From python-dev@python.org Tue Dec 12 17:53:13 2000 From: python-dev@python.org (Paul Prescod) Date: Tue, 12 Dec 2000 09:53:13 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/doctools onlinehelp.py,1.3,1.4 Message-ID: <200012121753.JAA15866@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/sandbox/doctools In directory slayer.i.sourceforge.net:/tmp/cvs-serv15796 Modified Files: onlinehelp.py Log Message: Fixed a case-typo. Index: onlinehelp.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/doctools/onlinehelp.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** onlinehelp.py 2000/07/22 19:27:43 1.3 --- onlinehelp.py 2000/12/12 17:53:10 1.4 *************** *** 293,297 **** docrl=docrl[1:] if docrl.endswith( ">" ): ! docrl=ob[:-1] path=docrl[4:] --- 293,297 ---- docrl=docrl[1:] if docrl.endswith( ">" ): ! docrl=docrl[:-1] path=docrl[4:] *************** *** 304,308 **** self.write( 'Topic: help( "%s" )\n' % docrl ) ! self.writeHTML( ob[:index], data ) def matchDocrlPattern( self, info ): --- 304,308 ---- self.write( 'Topic: help( "%s" )\n' % docrl ) ! self.writeHTML( docrl[:index], data ) def matchDocrlPattern( self, info ): *************** *** 320,324 **** match=self.matchDocrlPattern( info ) if match: # a first-line redirect ! self.handledocrl( match ) else: self.write( 'Topic: help( "%s" )\n' % topic ) --- 320,324 ---- match=self.matchDocrlPattern( info ) if match: # a first-line redirect ! self.handleDocrl( match ) else: self.write( 'Topic: help( "%s" )\n' % topic ) *************** *** 335,339 **** mod=my_import( topic ) if mod: - print mod self.handleObject( mod ) return None --- 335,338 ---- *************** *** 371,375 **** if match: # a first-line redirect ! self.handledocrl( match ) else: text=textdoc.document( ob ) --- 370,374 ---- if match: # a first-line redirect ! self.handleDocrl( match ) else: text=textdoc.document( ob ) From python-dev@python.org Tue Dec 12 21:07:13 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 12 Dec 2000 13:07:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.dist,1.1,1.2 Message-ID: <200012122107.NAA03525@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv3504 Modified Files: Setup.dist Log Message: Add URL with info for PIL. Index: Setup.dist =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.dist,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** Setup.dist 2000/10/26 17:06:02 1.1 --- Setup.dist 2000/12/12 21:07:08 1.2 *************** *** 291,294 **** --- 291,295 ---- # -DWITH_BLT -I/usr/local/blt/blt8.0-unoff/include -lBLT8.0 \ # *** Uncomment and edit for PIL (TkImaging) extension only: + # (See http://www.pythonware.com/products/pil/ for more info) # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \ # *** Uncomment and edit for TOGL extension only: From python-dev@python.org Tue Dec 12 22:02:21 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 12 Dec 2000 14:02:21 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects dictobject.c,2.67,2.68 Message-ID: <200012122202.OAA10580@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv10552 Modified Files: dictobject.c Log Message: Add popitem() -- SF patch #102733. Index: dictobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v retrieving revision 2.67 retrieving revision 2.68 diff -C2 -r2.67 -r2.68 *** dictobject.c 2000/11/30 19:30:19 2.67 --- dictobject.c 2000/12/12 22:02:18 2.68 *************** *** 1133,1136 **** --- 1133,1188 ---- } + static PyObject * + dict_popitem(dictobject *mp, PyObject *args) + { + int i = 0; + dictentry *ep; + PyObject *res; + + if (!PyArg_NoArgs(args)) + return NULL; + if (mp->ma_used == 0) { + PyErr_SetString(PyExc_KeyError, + "popitem(): dictionary is empty"); + return NULL; + } + /* Set ep to "the first" dict entry with a value. We abuse the hash + * field of slot 0 to hold a search finger: + * If slot 0 has a value, use slot 0. + * Else slot 0 is being used to hold a search finger, + * and we use its hash value as the first index to look. + */ + ep = &mp->ma_table[0]; + if (ep->me_value == NULL) { + i = (int)ep->me_hash; + /* The hash field may be uninitialized trash, or it + * may be a real hash value, or it may be a legit + * search finger, or it may be a once-legit search + * finger that's out of bounds now because it + * wrapped around or the table shrunk -- simply + * make sure it's in bounds now. + */ + if (i >= mp->ma_size || i < 1) + i = 1; /* skip slot 0 */ + while ((ep = &mp->ma_table[i])->me_value == NULL) { + i++; + if (i >= mp->ma_size) + i = 1; + } + } + res = PyTuple_New(2); + if (res != NULL) { + PyTuple_SET_ITEM(res, 0, ep->me_key); + PyTuple_SET_ITEM(res, 1, ep->me_value); + Py_INCREF(dummy); + ep->me_key = dummy; + ep->me_value = NULL; + mp->ma_used--; + assert(mp->ma_table[0].me_value == NULL); + mp->ma_table[0].me_hash = i + 1; /* next place to start */ + } + return res; + } + static int dict_traverse(PyObject *op, visitproc visit, void *arg) *************** *** 1168,1171 **** --- 1220,1224 ---- {"get", (PyCFunction)dict_get, METH_VARARGS}, {"setdefault", (PyCFunction)dict_setdefault, METH_VARARGS}, + {"popitem", (PyCFunction)dict_popitem}, {NULL, NULL} /* sentinel */ }; From python-dev@python.org Tue Dec 12 22:03:03 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 12 Dec 2000 14:03:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_types.py,1.17,1.18 Message-ID: <200012122203.OAA10694@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv10678 Modified Files: test_types.py Log Message: Added test for {}.popitem(). Index: test_types.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** test_types.py 2000/11/30 19:30:21 1.17 --- test_types.py 2000/12/12 22:02:59 1.18 *************** *** 266,267 **** --- 266,291 ---- if len(d['key']) <> 2: raise TestFailed, 'present {} setdefault, w/ 2nd arg' + # dict.popitem() + for copymode in -1, +1: + # -1: b has same structure as a + # +1: b is a.copy() + for log2size in range(12): + size = 2**log2size + a = {} + b = {} + for i in range(size): + a[`i`] = i + if copymode < 0: + b[`i`] = i + if copymode > 0: + b = a.copy() + for i in range(size): + ka, va = ta = a.popitem() + if va != int(ka): raise TestFailed, "a.popitem: %s" % str(ta) + kb, vb = tb = b.popitem() + if vb != int(kb): raise TestFailed, "b.popitem: %s" % str(tb) + if copymode < 0 and ta != tb: + raise TestFailed, "a.popitem != b.popitem: %s, %s" % ( + str(ta), str(tb)) + if a: raise TestFailed, 'a not empty after popitems: %s' % str(a) + if b: raise TestFailed, 'b not empty after popitems: %s' % str(b) From python-dev@python.org Tue Dec 12 22:03:50 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 12 Dec 2000 14:03:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libstdtypes.tex,1.44,1.45 Message-ID: <200012122203.OAA10809@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv10793 Modified Files: libstdtypes.tex Log Message: "Documentation" for {}.popitem(). Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -r1.44 -r1.45 *** libstdtypes.tex 2000/11/30 19:30:20 1.44 --- libstdtypes.tex 2000/12/12 22:03:47 1.45 *************** *** 818,821 **** --- 818,824 ---- else \var{x} (also setting it)} {(5)} + \lineiii{\var{a}.popitem()} + {remove and return an arbitrary (\var{key}, \var{value}) pair} + {(6)} \end{tableiii} *************** *** 842,845 **** --- 845,851 ---- that if \var{k} is missing, \var{x} is both returned and inserted into the dictionary as the value of \var{k}. + + \item[(6)] \function{popitem()} is useful to destructively iterate + over a dictionary, as often used in set algorithms. \end{description} From python-dev@python.org Tue Dec 12 22:06:02 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 12 Dec 2000 14:06:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib UserDict.py,1.8,1.9 Message-ID: <200012122206.OAA11180@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv11167 Modified Files: UserDict.py Log Message: Add popitem(). Index: UserDict.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/UserDict.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** UserDict.py 2000/08/08 16:12:54 1.8 --- UserDict.py 2000/12/12 22:06:00 1.9 *************** *** 39,40 **** --- 39,42 ---- self.data[key] = failobj return self.data[key] + def popitem(self): + return self.data.popitem() From python-dev@python.org Tue Dec 12 22:10:35 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 12 Dec 2000 14:10:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.84,1.85 Message-ID: <200012122210.OAA11671@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv11662 Modified Files: NEWS Log Message: Describe {}.popitem(). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -r1.84 -r1.85 *** NEWS 2000/12/12 01:18:39 1.84 --- NEWS 2000/12/12 22:10:31 1.85 *************** *** 28,31 **** --- 28,38 ---- via %u raised an error if it was too big to fit in an int. + - Dictionary objects have an odd new method, popitem(). This removes + an arbitrary item from the dictionary and returns it (in the form of + a (key, value) pair). This can be useful for algorithms that use a + dictionary as a bag of "to do" items and repeatedly need to pick one + item. Such algorithms normally end up running in quadratic time; + using popitem() they can usually be made to run in linear time. + Windows changes From python-dev@python.org Tue Dec 12 22:21:13 2000 From: python-dev@python.org (Jack Jansen) Date: Tue, 12 Dec 2000 14:21:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/bgen/bgen scantools.py,1.18,1.19 Message-ID: <200012122221.OAA12823@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/bgen/bgen In directory slayer.i.sourceforge.net:/tmp/cvs-serv12754 Modified Files: scantools.py Log Message: Added support for generating a single module from multiple .h files. Allow /* */ comments within function prototypes. Index: scantools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/scantools.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** scantools.py 2000/07/15 22:27:47 1.18 --- scantools.py 2000/12/12 22:21:11 1.19 *************** *** 252,256 **** self.comment1_pat = "\(.*\)//.*" # note that the next pattern only removes comments that are wholly within one line ! self.comment2_pat = "\(.*\)/\*.*\*/" def compilepatterns(self): --- 252,256 ---- self.comment1_pat = "\(.*\)//.*" # note that the next pattern only removes comments that are wholly within one line ! self.comment2_pat = "\(.*\)/\*.*\*/\(.*\)" def compilepatterns(self): *************** *** 329,332 **** --- 329,342 ---- def setinput(self, scan = sys.stdin): + if not type(scan) in (TupleType, ListType): + scan = [scan] + self.allscaninputs = scan + self._nextinput() + + def _nextinput(self): + if not self.allscaninputs: + return 0 + scan = self.allscaninputs[0] + self.allscaninputs = self.allscaninputs[1:] self.closescan() if scan: *************** *** 340,343 **** --- 350,354 ---- self.scanmine = mine self.lineno = 0 + return 1 def openinput(self, filename): *************** *** 361,364 **** --- 372,377 ---- self.line = self.scanfile.readline() if not self.line: + if self._nextinput(): + return self.getline() raise EOFError self.lineno = self.lineno + 1 *************** *** 389,394 **** if self.comment1.match(line) >= 0: line = self.comment1.group('rest') ! if self.comment2.match(line) >= 0: ! line = self.comment2.group('rest') if self.defsfile and self.sym.match(line) >= 0: self.dosymdef() --- 402,407 ---- if self.comment1.match(line) >= 0: line = self.comment1.group('rest') ! while self.comment2.match(line) >= 0: ! line = self.comment2.group('rest1')+self.comment2.group('rest2') if self.defsfile and self.sym.match(line) >= 0: self.dosymdef() *************** *** 413,416 **** --- 426,433 ---- while self.tail.search(raw) < 0: line = self.getline() + if self.comment1.match(line) >= 0: + line = self.comment1.group('rest') + while self.comment2.match(line) >= 0: + line = self.comment2.group('rest1')+self.comment2.group('rest2') raw = raw + line self.processrawspec(raw) From python-dev@python.org Tue Dec 12 22:21:41 2000 From: python-dev@python.org (Jack Jansen) Date: Tue, 12 Dec 2000 14:21:41 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/bgen/bgen macsupport.py,1.19,1.20 Message-ID: <200012122221.OAA12868@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/bgen/bgen In directory slayer.i.sourceforge.net:/tmp/cvs-serv12844 Modified Files: macsupport.py Log Message: Various new standard types. Index: macsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/macsupport.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** macsupport.py 2000/07/15 22:29:30 1.19 --- macsupport.py 2000/12/12 22:21:39 1.20 *************** *** 13,17 **** Boolean = Type("Boolean", "b") SignedByte = Type("SignedByte", "b") - ScriptCode = Type("ScriptCode", "h") Size = Type("Size", "l") Style = Type("Style", "b") --- 13,16 ---- *************** *** 19,22 **** --- 18,30 ---- CharParameter = Type("CharParameter", "h") TextEncoding = Type("TextEncoding", "l") + ByteCount = Type("ByteCount", "l") + Duration = Type("Duration", "l") + ByteOffset = Type("ByteOffset", "l") + OptionBits = Type("OptionBits", "l") + ItemCount = Type("ItemCount", "l") + PBVersion = Type("PBVersion", "l") + ScriptCode = Type("ScriptCode", "h") + LangCode = Type("LangCode", "h") + RegionCode = Type("RegionCode", "h") UInt8 = Type("UInt8", "b") *************** *** 26,33 **** --- 34,46 ---- UInt32 = Type("UInt32", "l") SInt32 = Type("SInt32", "l") + Float32 = Type("Float32", "f") + + wide = OpaqueByValueType("wide", "PyMac_Buildwide", "PyMac_Getwide") + wide_ptr = OpaqueType("wide", "PyMac_Buildwide", "PyMac_Getwide") # Pascal strings ConstStr255Param = OpaqueArrayType("Str255", "PyMac_BuildStr255", "PyMac_GetStr255") Str255 = OpaqueArrayType("Str255", "PyMac_BuildStr255", "PyMac_GetStr255") + StringPtr = OpaqueByValueType("StringPtr", "PyMac_BuildStr255", "BUG") # File System Specifications *************** *** 40,43 **** --- 53,57 ---- OSType = OSTypeType("OSType") ResType = OSTypeType("ResType") + FourCharCode = OSTypeType("FourCharCode") # Version numbers *************** *** 57,60 **** --- 71,75 ---- DialogRef = DialogPtr ExistingWindowPtr = OpaqueByValueType("WindowPtr", "WinObj_WhichWindow", "BUG") + # XXX This is incorrect: it returns a Window, not a Dialog! ExistingDialogPtr = OpaqueByValueType("DialogPtr", "WinObj_WhichWindow", "BUG") From python-dev@python.org Tue Dec 12 22:37:00 2000 From: python-dev@python.org (Jack Jansen) Date: Tue, 12 Dec 2000 14:37:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python dynload_mac.c,2.8,2.9 Message-ID: <200012122237.OAA14637@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv14484 Modified Files: dynload_mac.c Log Message: Use c2pstr() in stead of Pstring() to convert C-strings to Pascal-strings. Safer, because Pstring converts in-place and the pathname may be reused later for error messages. Index: dynload_mac.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/dynload_mac.c,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -r2.8 -r2.9 *** dynload_mac.c 2000/09/01 23:29:28 2.8 --- dynload_mac.c 2000/12/12 22:36:57 2.9 *************** *** 11,14 **** --- 11,15 ---- #endif #include + #include #include "macdefs.h" #include "macglue.h" *************** *** 57,66 **** err = Path2FSSpec(pathname, &libspec); #else ! (void)FSMakeFSSpec(0, 0, Pstring(pathname), &libspec); err = ResolveAliasFile(&libspec, 1, &isfolder, &didsomething); #endif if ( err ) { ! sprintf(buf, "%.255s: %.200s", ! pathname, PyMac_StrError(err)); PyErr_SetString(PyExc_ImportError, buf); return NULL; --- 58,67 ---- err = Path2FSSpec(pathname, &libspec); #else ! c2pstrcpy((unsigned char *)buf, pathname); ! (void)FSMakeFSSpec(0, 0, (unsigned char *)buf, &libspec); err = ResolveAliasFile(&libspec, 1, &isfolder, &didsomething); #endif if ( err ) { ! sprintf(buf, "%.200s: %.200s", pathname, PyMac_StrError(err)); PyErr_SetString(PyExc_ImportError, buf); return NULL; From python-dev@python.org Tue Dec 12 22:39:06 2000 From: python-dev@python.org (Jack Jansen) Date: Tue, 12 Dec 2000 14:39:06 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib site.py,1.21,1.22 Message-ID: <200012122239.OAA14981@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv14877 Modified Files: site.py Log Message: The ".pth" code knew about the layout of Python trees on unix and windows, but not on the mac. Fixed. Index: site.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/site.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** site.py 2000/12/06 22:20:07 1.21 --- site.py 2000/12/12 22:39:04 1.22 *************** *** 123,126 **** --- 123,128 ---- "site-packages"), makepath(prefix, "lib", "site-python")] + elif os.sep == ':': + sitedirs = [makepath(prefix, "lib", "site-packages")] else: sitedirs = [prefix] From python-dev@python.org Tue Dec 12 22:42:40 2000 From: python-dev@python.org (Jack Jansen) Date: Tue, 12 Dec 2000 14:42:40 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules timemodule.c,2.103,2.104 Message-ID: <200012122242.OAA15381@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv15218 Modified Files: timemodule.c Log Message: The Mac C library (MSL from CodeWarrior 6) and I/O library (GUSI 2.1.3) finally agree on when the epoch is, so the code to convert epochs has been disabled. Index: timemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v retrieving revision 2.103 retrieving revision 2.104 diff -C2 -r2.103 -r2.104 *** timemodule.c 2000/09/01 23:29:27 2.103 --- timemodule.c 2000/12/12 22:42:30 2.104 *************** *** 9,13 **** #include #include ! #ifdef USE_GUSI2 /* GUSI, the I/O library which has the time() function and such uses the ** Mac epoch of 1904. MSL, the C library which has localtime() and so uses --- 9,13 ---- #include #include ! #ifdef USE_GUSI211 /* GUSI, the I/O library which has the time() function and such uses the ** Mac epoch of 1904. MSL, the C library which has localtime() and so uses *************** *** 467,471 **** return NULL; } ! #if defined(macintosh) && defined(USE_GUSI2) tt = tt - GUSI_TO_MSL_EPOCH; #endif --- 467,471 ---- return NULL; } ! #if defined(macintosh) && defined(USE_GUSI211) tt = tt - GUSI_TO_MSL_EPOCH; #endif From python-dev@python.org Tue Dec 12 23:11:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 12 Dec 2000 15:11:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-tk Tkinter.py,1.150,1.151 Message-ID: <200012122311.PAA18727@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory slayer.i.sourceforge.net:/tmp/cvs-serv18670/lib-tk Modified Files: Tkinter.py Log Message: Update the code to better reflect recommended style: Use != instead of <> since <> is documented as "obsolescent". Use "is" and "is not" when comparing with None or type objects. Index: Tkinter.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tkinter.py,v retrieving revision 1.150 retrieving revision 1.151 diff -C2 -r1.150 -r1.151 *** Tkinter.py 2000/10/23 18:31:14 1.150 --- Tkinter.py 2000/12/12 23:11:41 1.151 *************** *** 340,344 **** If no parameter is given self is used.""" ! if window == None: window = self self.tk.call('tkwait', 'window', window._w) --- 340,344 ---- If no parameter is given self is used.""" ! if window is None: window = self self.tk.call('tkwait', 'window', window._w) *************** *** 348,352 **** If no parameter is given self is used.""" ! if window == None: window = self self.tk.call('tkwait', 'visibility', window._w) --- 348,352 ---- If no parameter is given self is used.""" ! if window is None: window = self self.tk.call('tkwait', 'visibility', window._w) From python-dev@python.org Tue Dec 12 23:11:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 12 Dec 2000 15:11:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils cygwinccompiler.py,1.8,1.9 Message-ID: <200012122311.PAA18719@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv18670/distutils Modified Files: cygwinccompiler.py Log Message: Update the code to better reflect recommended style: Use != instead of <> since <> is documented as "obsolescent". Use "is" and "is not" when comparing with None or type objects. Index: cygwinccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/cygwinccompiler.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** cygwinccompiler.py 2000/09/27 02:08:14 1.8 --- cygwinccompiler.py 2000/12/12 23:11:39 1.9 *************** *** 242,246 **** #end: if ((export_symbols is not None) and ! # (target_desc <> self.EXECUTABLE or self.linker_dll == "gcc")): # who wants symbols and a many times larger output file --- 242,246 ---- #end: if ((export_symbols is not None) and ! # (target_desc != self.EXECUTABLE or self.linker_dll == "gcc")): # who wants symbols and a many times larger output file From python-dev@python.org Tue Dec 12 23:11:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 12 Dec 2000 15:11:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-irix5 FL.py,1.7,1.8 cdplayer.py,1.6,1.7 flp.py,1.19,1.20 jpeg.py,1.3,1.4 panel.py,1.5,1.6 panelparser.py,1.2,1.3 readcd.py,1.11,1.12 torgb.py,1.5,1.6 Message-ID: <200012122311.PAA18752@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/plat-irix5 In directory slayer.i.sourceforge.net:/tmp/cvs-serv18670/plat-irix5 Modified Files: FL.py cdplayer.py flp.py jpeg.py panel.py panelparser.py readcd.py torgb.py Log Message: Update the code to better reflect recommended style: Use != instead of <> since <> is documented as "obsolescent". Use "is" and "is not" when comparing with None or type objects. Index: FL.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/FL.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** FL.py 1993/07/06 15:19:33 1.7 --- FL.py 2000/12/12 23:11:41 1.8 *************** *** 8,12 **** ##import fl ##try: ! ## _v20 = (fl.get_rgbmode <> None) ##except: ## _v20 = 0 --- 8,12 ---- ##import fl ##try: ! ## _v20 = (fl.get_rgbmode is not None) ##except: ## _v20 = 0 Index: cdplayer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/cdplayer.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** cdplayer.py 2000/07/16 11:57:19 1.6 --- cdplayer.py 2000/12/12 23:11:42 1.7 *************** *** 78,82 **** if line == '': break ! if line[:l] <> s: new.write(line) new.write(self.id + '.title:\t' + self.title + '\n') --- 78,82 ---- if line == '': break ! if line[:l] != s: new.write(line) new.write(self.id + '.title:\t' + self.title + '\n') Index: flp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/flp.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** flp.py 2000/08/18 14:57:26 1.19 --- flp.py 2000/12/12 23:11:42 1.20 *************** *** 37,41 **** def parse_forms(filename): forms = checkcache(filename) ! if forms != None: return forms fp = _open_formfile(filename) nforms = _parse_fd_header(fp) --- 37,41 ---- def parse_forms(filename): forms = checkcache(filename) ! if forms is not None: return forms fp = _open_formfile(filename) nforms = _parse_fd_header(fp) *************** *** 169,173 **** def _open_formfile2(filename): ! if filename[-3:] <> '.fd': filename = filename + '.fd' if filename[0] == '/': --- 169,173 ---- def _open_formfile2(filename): ! if filename[-3:] != '.fd': filename = filename + '.fd' if filename[0] == '/': *************** *** 185,189 **** except IOError: fp = None ! if fp == None: raise error, 'Cannot find forms file ' + filename return fp, filename --- 185,189 ---- except IOError: fp = None ! if fp is None: raise error, 'Cannot find forms file ' + filename return fp, filename *************** *** 195,199 **** # First read the magic header line datum = _parse_1_line(file) ! if datum <> ('Magic', 12321): raise error, 'Not a forms definition file' # Now skip until we know number of forms --- 195,199 ---- # First read the magic header line datum = _parse_1_line(file) ! if datum != ('Magic', 12321): raise error, 'Not a forms definition file' # Now skip until we know number of forms *************** *** 209,216 **** def _parse_fd_form(file, name): datum = _parse_1_line(file) ! if datum <> FORMLINE: raise error, 'Missing === FORM === line' form = _parse_object(file) ! if form.Name == name or name == None: objs = [] for j in range(form.Numberofobjects): --- 209,216 ---- def _parse_fd_form(file, name): datum = _parse_1_line(file) ! if datum != FORMLINE: raise error, 'Missing === FORM === line' form = _parse_object(file) ! if form.Name == name or name is None: objs = [] for j in range(form.Numberofobjects): *************** *** 317,321 **** file.seek(pos) return obj ! if type(datum) <> type(()) or len(datum) <> 2: raise error, 'Parse error, illegal line in object: '+datum obj.add(datum[0], datum[1]) --- 317,321 ---- file.seek(pos) return obj ! if type(datum) is not type(()) or len(datum) != 2: raise error, 'Parse error, illegal line in object: '+datum obj.add(datum[0], datum[1]) *************** *** 340,344 **** def merge_full_form(inst, form, (fdata, odatalist)): exec 'inst.'+fdata.Name+' = form\n' ! if odatalist[0].Class <> FL.BOX: raise error, 'merge_full_form() expects FL.BOX as first obj' for odata in odatalist[1:]: --- 340,344 ---- def merge_full_form(inst, form, (fdata, odatalist)): exec 'inst.'+fdata.Name+' = form\n' ! if odatalist[0].Class != FL.BOX: raise error, 'merge_full_form() expects FL.BOX as first obj' for odata in odatalist[1:]: Index: jpeg.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/jpeg.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** jpeg.py 2000/08/18 14:57:26 1.3 --- jpeg.py 2000/12/12 23:11:42 1.4 *************** *** 60,64 **** def setoption(name, value): ! if type(value) <> type(0): raise TypeError, 'jpeg.setoption: numeric options only' if name == 'forcegrey': --- 60,64 ---- def setoption(name, value): ! if type(value) is not type(0): raise TypeError, 'jpeg.setoption: numeric options only' if name == 'forcegrey': Index: panel.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/panel.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** panel.py 2000/06/28 14:48:01 1.5 --- panel.py 2000/12/12 23:11:42 1.6 *************** *** 208,212 **** # Sanity check # ! if (not descr) or descr[0] <> 'panel': raise panel_error, 'panel description must start with "panel"' # --- 208,212 ---- # Sanity check # ! if (not descr) or descr[0] != 'panel': raise panel_error, 'panel description must start with "panel"' # Index: panelparser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/panelparser.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** panelparser.py 1992/01/01 19:32:09 1.2 --- panelparser.py 2000/12/12 23:11:42 1.3 *************** *** 72,76 **** # def parse_expr(tokens): ! if (not tokens) or tokens[0] <> '(': raise syntax_error, 'expected "("' tokens = tokens[1:] --- 72,76 ---- # def parse_expr(tokens): ! if (not tokens) or tokens[0] != '(': raise syntax_error, 'expected "("' tokens = tokens[1:] Index: readcd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/readcd.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** readcd.py 2000/08/18 14:57:26 1.11 --- readcd.py 2000/12/12 23:11:42 1.12 *************** *** 94,98 **** raise Error, 'range error' end = self.pmsf2msf(prog, min, sec, frame) ! elif l <> 3: raise Error, 'syntax error' if type(start) == type(0): --- 94,98 ---- raise Error, 'range error' end = self.pmsf2msf(prog, min, sec, frame) ! elif l != 3: raise Error, 'syntax error' if type(start) == type(0): *************** *** 112,116 **** raise Error, 'range error' start = self.pmsf2msf(prog, min, sec, frame) ! elif l <> 3: raise Error, 'syntax error' self.list.append((start, end)) --- 112,116 ---- raise Error, 'range error' start = self.pmsf2msf(prog, min, sec, frame) ! elif l != 3: raise Error, 'syntax error' self.list.append((start, end)) *************** *** 128,135 **** start, end = self.list[self.listindex] if type(end) == type(0): ! if cb_type <> CD.PNUM: self.parser.setcallback(cb_type, func, arg) else: ! if cb_type <> CD.ATIME: self.parser.setcallback(cb_type, func, arg) --- 128,135 ---- start, end = self.list[self.listindex] if type(end) == type(0): ! if cb_type != CD.PNUM: self.parser.setcallback(cb_type, func, arg) else: ! if cb_type != CD.ATIME: self.parser.setcallback(cb_type, func, arg) *************** *** 141,148 **** start, end = self.list[self.listindex] if type(end) == type(0): ! if cb_type <> CD.PNUM: self.parser.removecallback(cb_type) else: ! if cb_type <> CD.ATIME: self.parser.removecallback(cb_type) --- 141,148 ---- start, end = self.list[self.listindex] if type(end) == type(0): ! if cb_type != CD.PNUM: self.parser.removecallback(cb_type) else: ! if cb_type != CD.ATIME: self.parser.removecallback(cb_type) Index: torgb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/torgb.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** torgb.py 2000/08/18 14:57:26 1.5 --- torgb.py 2000/12/12 23:11:42 1.6 *************** *** 61,65 **** finally: for temp in temps[:]: ! if temp <> ret: try: os.unlink(temp) --- 61,65 ---- finally: for temp in temps[:]: ! if temp != ret: try: os.unlink(temp) *************** *** 84,93 **** type(msg[0]) == type(0) and type(msg[1]) == type(''): msg = msg[1] ! if type(msg) <> type(''): msg = `msg` raise error, filename + ': ' + msg if ftype == 'rgb': return fname ! if ftype == None or not table.has_key(ftype): raise error, \ filename + ': unsupported image file type ' + `ftype` --- 84,93 ---- type(msg[0]) == type(0) and type(msg[1]) == type(''): msg = msg[1] ! if type(msg) is not type(''): msg = `msg` raise error, filename + ': ' + msg if ftype == 'rgb': return fname ! if ftype is None or not table.has_key(ftype): raise error, \ filename + ': unsupported image file type ' + `ftype` From python-dev@python.org Tue Dec 12 23:11:45 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 12 Dec 2000 15:11:45 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test regrtest.py,1.27,1.28 test_audioop.py,1.6,1.7 test_b1.py,1.27,1.28 test_b2.py,1.20,1.21 test_binascii.py,1.6,1.7 test_binhex.py,1.6,1.7 test_bsddb.py,1.4,1.5 test_grammar.py,1.20,1.21 test_math.py,1.9,1.10 test_md5.py,1.3,1.4 test_mmap.py,1.11,1.12 test_new.py,1.5,1.6 test_nis.py,1.8,1.9 test_opcodes.py,1.8,1.9 test_operator.py,1.3,1.4 test_pow.py,1.6,1.7 test_pty.py,1.6,1.7 test_pwd.py,1.7,1.8 test_re.py,1.26,1.27 test_rotor.py,1.4,1.5 test_sax.py,1.13,1.14 test_socket.py,1.14,1.15 test_sre.py,1.13,1.14 test_struct.py,1.6,1.7 test_support.py,1.8,1.9 test_time.py,1.5,1.6 test_types.py,1.18,1.19 test_unpack.py,1.4,1.5 Message-ID: <200012122311.PAA18793@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv18670/test Modified Files: regrtest.py test_audioop.py test_b1.py test_b2.py test_binascii.py test_binhex.py test_bsddb.py test_grammar.py test_math.py test_md5.py test_mmap.py test_new.py test_nis.py test_opcodes.py test_operator.py test_pow.py test_pty.py test_pwd.py test_re.py test_rotor.py test_sax.py test_socket.py test_sre.py test_struct.py test_support.py test_time.py test_types.py test_unpack.py Log Message: Update the code to better reflect recommended style: Use != instead of <> since <> is documented as "obsolescent". Use "is" and "is not" when comparing with None or type objects. Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** regrtest.py 2000/10/23 17:22:07 1.27 --- regrtest.py 2000/12/12 23:11:42 1.28 *************** *** 284,288 **** def write(self, data): expected = self.fp.read(len(data)) ! if data <> expected: raise test_support.TestFailed, \ 'Writing: '+`data`+', expected: '+`expected` --- 284,288 ---- def write(self, data): expected = self.fp.read(len(data)) ! if data != expected: raise test_support.TestFailed, \ 'Writing: '+`data`+', expected: '+`expected` Index: test_audioop.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_audioop.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_audioop.py 1998/03/26 19:41:42 1.6 --- test_audioop.py 2000/12/12 23:11:42 1.7 *************** *** 25,31 **** if verbose: print 'max' ! if audioop.max(data[0], 1) <> 2 or \ ! audioop.max(data[1], 2) <> 2 or \ ! audioop.max(data[2], 4) <> 2: return 0 return 1 --- 25,31 ---- if verbose: print 'max' ! if audioop.max(data[0], 1) != 2 or \ ! audioop.max(data[1], 2) != 2 or \ ! audioop.max(data[2], 4) != 2: return 0 return 1 *************** *** 34,40 **** if verbose: print 'minmax' ! if audioop.minmax(data[0], 1) <> (0, 2) or \ ! audioop.minmax(data[1], 2) <> (0, 2) or \ ! audioop.minmax(data[2], 4) <> (0, 2): return 0 return 1 --- 34,40 ---- if verbose: print 'minmax' ! if audioop.minmax(data[0], 1) != (0, 2) or \ ! audioop.minmax(data[1], 2) != (0, 2) or \ ! audioop.minmax(data[2], 4) != (0, 2): return 0 return 1 *************** *** 43,49 **** if verbose: print 'maxpp' ! if audioop.maxpp(data[0], 1) <> 0 or \ ! audioop.maxpp(data[1], 2) <> 0 or \ ! audioop.maxpp(data[2], 4) <> 0: return 0 return 1 --- 43,49 ---- if verbose: print 'maxpp' ! if audioop.maxpp(data[0], 1) != 0 or \ ! audioop.maxpp(data[1], 2) != 0 or \ ! audioop.maxpp(data[2], 4) != 0: return 0 return 1 *************** *** 52,58 **** if verbose: print 'avg' ! if audioop.avg(data[0], 1) <> 1 or \ ! audioop.avg(data[1], 2) <> 1 or \ ! audioop.avg(data[2], 4) <> 1: return 0 return 1 --- 52,58 ---- if verbose: print 'avg' ! if audioop.avg(data[0], 1) != 1 or \ ! audioop.avg(data[1], 2) != 1 or \ ! audioop.avg(data[2], 4) != 1: return 0 return 1 *************** *** 61,74 **** if verbose: print 'avgpp' ! if audioop.avgpp(data[0], 1) <> 0 or \ ! audioop.avgpp(data[1], 2) <> 0 or \ ! audioop.avgpp(data[2], 4) <> 0: return 0 return 1 def testrms(data): ! if audioop.rms(data[0], 1) <> 1 or \ ! audioop.rms(data[1], 2) <> 1 or \ ! audioop.rms(data[2], 4) <> 1: return 0 return 1 --- 61,74 ---- if verbose: print 'avgpp' ! if audioop.avgpp(data[0], 1) != 0 or \ ! audioop.avgpp(data[1], 2) != 0 or \ ! audioop.avgpp(data[2], 4) != 0: return 0 return 1 def testrms(data): ! if audioop.rms(data[0], 1) != 1 or \ ! audioop.rms(data[1], 2) != 1 or \ ! audioop.rms(data[2], 4) != 1: return 0 return 1 *************** *** 77,83 **** if verbose: print 'cross' ! if audioop.cross(data[0], 1) <> 0 or \ ! audioop.cross(data[1], 2) <> 0 or \ ! audioop.cross(data[2], 4) <> 0: return 0 return 1 --- 77,83 ---- if verbose: print 'cross' ! if audioop.cross(data[0], 1) != 0 or \ ! audioop.cross(data[1], 2) != 0 or \ ! audioop.cross(data[2], 4) != 0: return 0 return 1 *************** *** 92,98 **** str = str + chr(ord(s)*2) data2.append(str) ! if audioop.add(data[0], data[0], 1) <> data2[0] or \ ! audioop.add(data[1], data[1], 2) <> data2[1] or \ ! audioop.add(data[2], data[2], 4) <> data2[2]: return 0 return 1 --- 92,98 ---- str = str + chr(ord(s)*2) data2.append(str) ! if audioop.add(data[0], data[0], 1) != data2[0] or \ ! audioop.add(data[1], data[1], 2) != data2[1] or \ ! audioop.add(data[2], data[2], 4) != data2[2]: return 0 return 1 *************** *** 105,111 **** d2 = audioop.bias(data[1], 2, 100) d4 = audioop.bias(data[2], 4, 100) ! if audioop.avg(d1, 1) <> 101 or \ ! audioop.avg(d2, 2) <> 101 or \ ! audioop.avg(d4, 4) <> 101: return 0 return 1 --- 105,111 ---- d2 = audioop.bias(data[1], 2, 100) d4 = audioop.bias(data[2], 4, 100) ! if audioop.avg(d1, 1) != 101 or \ ! audioop.avg(d2, 2) != 101 or \ ! audioop.avg(d4, 4) != 101: return 0 return 1 *************** *** 119,123 **** got = len(d1)/3 wtd = len(d2)/3 ! if len(audioop.lin2lin(d1, got, wtd)) <> len(d2): return 0 return 1 --- 119,123 ---- got = len(d1)/3 wtd = len(d2)/3 ! if len(audioop.lin2lin(d1, got, wtd)) != len(d2): return 0 return 1 *************** *** 125,129 **** def testadpcm2lin(data): # Very cursory test ! if audioop.adpcm2lin('\0\0', 1, None) <> ('\0\0\0\0', (0,0)): return 0 return 1 --- 125,129 ---- def testadpcm2lin(data): # Very cursory test ! if audioop.adpcm2lin('\0\0', 1, None) != ('\0\0\0\0', (0,0)): return 0 return 1 *************** *** 133,137 **** print 'lin2adpcm' # Very cursory test ! if audioop.lin2adpcm('\0\0\0\0', 1, None) <> ('\0\0', (0,0)): return 0 return 1 --- 133,137 ---- print 'lin2adpcm' # Very cursory test ! if audioop.lin2adpcm('\0\0\0\0', 1, None) != ('\0\0', (0,0)): return 0 return 1 *************** *** 140,146 **** if verbose: print 'lin2ulaw' ! if audioop.lin2ulaw(data[0], 1) <> '\377\347\333' or \ ! audioop.lin2ulaw(data[1], 2) <> '\377\377\377' or \ ! audioop.lin2ulaw(data[2], 4) <> '\377\377\377': return 0 return 1 --- 140,146 ---- if verbose: print 'lin2ulaw' ! if audioop.lin2ulaw(data[0], 1) != '\377\347\333' or \ ! audioop.lin2ulaw(data[1], 2) != '\377\377\377' or \ ! audioop.lin2ulaw(data[2], 4) != '\377\377\377': return 0 return 1 *************** *** 151,155 **** # Cursory d = audioop.lin2ulaw(data[0], 1) ! if audioop.ulaw2lin(d, 1) <> data[0]: return 0 return 1 --- 151,155 ---- # Cursory d = audioop.lin2ulaw(data[0], 1) ! if audioop.ulaw2lin(d, 1) != data[0]: return 0 return 1 *************** *** 164,170 **** str = str + chr(ord(s)*2) data2.append(str) ! if audioop.mul(data[0], 1, 2) <> data2[0] or \ ! audioop.mul(data[1],2, 2) <> data2[1] or \ ! audioop.mul(data[2], 4, 2) <> data2[2]: return 0 return 1 --- 164,170 ---- str = str + chr(ord(s)*2) data2.append(str) ! if audioop.mul(data[0], 1, 2) != data2[0] or \ ! audioop.mul(data[1],2, 2) != data2[1] or \ ! audioop.mul(data[2], 4, 2) != data2[2]: return 0 return 1 *************** *** 183,187 **** if verbose: print 'reverse' ! if audioop.reverse(data[0], 1) <> '\2\1\0': return 0 return 1 --- 183,187 ---- if verbose: print 'reverse' ! if audioop.reverse(data[0], 1) != '\2\1\0': return 0 return 1 *************** *** 193,197 **** for d in data[0]: data2 = data2 + d + d ! if audioop.tomono(data2, 1, 0.5, 0.5) <> data[0]: return 0 return 1 --- 193,197 ---- for d in data[0]: data2 = data2 + d + d ! if audioop.tomono(data2, 1, 0.5, 0.5) != data[0]: return 0 return 1 *************** *** 203,207 **** for d in data[0]: data2 = data2 + d + d ! if audioop.tostereo(data[0], 1, 1, 1) <> data2: return 0 return 1 --- 203,207 ---- for d in data[0]: data2 = data2 + d + d ! if audioop.tostereo(data[0], 1, 1, 1) != data2: return 0 return 1 *************** *** 210,214 **** if verbose: print 'findfactor' ! if audioop.findfactor(data[1], data[1]) <> 1.0: return 0 return 1 --- 210,214 ---- if verbose: print 'findfactor' ! if audioop.findfactor(data[1], data[1]) != 1.0: return 0 return 1 *************** *** 217,221 **** if verbose: print 'findfit' ! if audioop.findfit(data[1], data[1]) <> (0, 1.0): return 0 return 1 --- 217,221 ---- if verbose: print 'findfit' ! if audioop.findfit(data[1], data[1]) != (0, 1.0): return 0 return 1 *************** *** 224,228 **** if verbose: print 'findmax' ! if audioop.findmax(data[1], 1) <> 2: return 0 return 1 --- 224,228 ---- if verbose: print 'findmax' ! if audioop.findmax(data[1], 1) != 2: return 0 return 1 *************** *** 232,238 **** print 'getsample' for i in range(3): ! if audioop.getsample(data[0], 1, i) <> i or \ ! audioop.getsample(data[1], 2, i) <> i or \ ! audioop.getsample(data[2], 4, i) <> i: return 0 return 1 --- 232,238 ---- print 'getsample' for i in range(3): ! if audioop.getsample(data[0], 1, i) != i or \ ! audioop.getsample(data[1], 2, i) != i or \ ! audioop.getsample(data[2], 4, i) != i: return 0 return 1 Index: test_b1.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b1.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** test_b1.py 2000/09/19 20:58:53 1.27 --- test_b1.py 2000/12/12 23:11:42 1.28 *************** *** 12,26 **** print 'abs' ! if abs(0) <> 0: raise TestFailed, 'abs(0)' ! if abs(1234) <> 1234: raise TestFailed, 'abs(1234)' ! if abs(-1234) <> 1234: raise TestFailed, 'abs(-1234)' # ! if abs(0.0) <> 0.0: raise TestFailed, 'abs(0.0)' ! if abs(3.14) <> 3.14: raise TestFailed, 'abs(3.14)' ! if abs(-3.14) <> 3.14: raise TestFailed, 'abs(-3.14)' # ! if abs(0L) <> 0L: raise TestFailed, 'abs(0L)' ! if abs(1234L) <> 1234L: raise TestFailed, 'abs(1234L)' ! if abs(-1234L) <> 1234L: raise TestFailed, 'abs(-1234L)' print 'apply' --- 12,26 ---- print 'abs' ! if abs(0) != 0: raise TestFailed, 'abs(0)' ! if abs(1234) != 1234: raise TestFailed, 'abs(1234)' ! if abs(-1234) != 1234: raise TestFailed, 'abs(-1234)' # ! if abs(0.0) != 0.0: raise TestFailed, 'abs(0.0)' ! if abs(3.14) != 3.14: raise TestFailed, 'abs(3.14)' ! if abs(-3.14) != 3.14: raise TestFailed, 'abs(-3.14)' # ! if abs(0L) != 0L: raise TestFailed, 'abs(0L)' ! if abs(1234L) != 1234L: raise TestFailed, 'abs(1234L)' ! if abs(-1234L) != 1234L: raise TestFailed, 'abs(-1234L)' print 'apply' *************** *** 56,67 **** print 'chr' ! if chr(32) <> ' ': raise TestFailed, 'chr(32)' ! if chr(65) <> 'A': raise TestFailed, 'chr(65)' ! if chr(97) <> 'a': raise TestFailed, 'chr(97)' print 'cmp' ! if cmp(-1, 1) <> -1: raise TestFailed, 'cmp(-1, 1)' ! if cmp(1, -1) <> 1: raise TestFailed, 'cmp(1, -1)' ! if cmp(1, 1) <> 0: raise TestFailed, 'cmp(1, 1)' # verify that circular objects are handled a = []; a.append(a) --- 56,67 ---- print 'chr' ! if chr(32) != ' ': raise TestFailed, 'chr(32)' ! if chr(65) != 'A': raise TestFailed, 'chr(65)' ! if chr(97) != 'a': raise TestFailed, 'chr(97)' print 'cmp' ! if cmp(-1, 1) != -1: raise TestFailed, 'cmp(-1, 1)' ! if cmp(1, -1) != 1: raise TestFailed, 'cmp(1, -1)' ! if cmp(1, 1) != 0: raise TestFailed, 'cmp(1, 1)' # verify that circular objects are handled a = []; a.append(a) *************** *** 78,82 **** print 'coerce' if fcmp(coerce(1, 1.1), (1.0, 1.1)): raise TestFailed, 'coerce(1, 1.1)' ! if coerce(1, 1L) <> (1L, 1L): raise TestFailed, 'coerce(1, 1L)' if fcmp(coerce(1L, 1.1), (1.0, 1.1)): raise TestFailed, 'coerce(1L, 1.1)' --- 78,82 ---- print 'coerce' if fcmp(coerce(1, 1.1), (1.0, 1.1)): raise TestFailed, 'coerce(1, 1.1)' ! if coerce(1, 1L) != (1L, 1L): raise TestFailed, 'coerce(1, 1L)' if fcmp(coerce(1L, 1.1), (1.0, 1.1)): raise TestFailed, 'coerce(1L, 1.1)' *************** *** 85,115 **** print 'complex' ! if complex(1,10) <> 1+10j: raise TestFailed, 'complex(1,10)' ! if complex(1,10L) <> 1+10j: raise TestFailed, 'complex(1,10L)' ! if complex(1,10.0) <> 1+10j: raise TestFailed, 'complex(1,10.0)' ! if complex(1L,10) <> 1+10j: raise TestFailed, 'complex(1L,10)' ! if complex(1L,10L) <> 1+10j: raise TestFailed, 'complex(1L,10L)' ! if complex(1L,10.0) <> 1+10j: raise TestFailed, 'complex(1L,10.0)' ! if complex(1.0,10) <> 1+10j: raise TestFailed, 'complex(1.0,10)' ! if complex(1.0,10L) <> 1+10j: raise TestFailed, 'complex(1.0,10L)' ! if complex(1.0,10.0) <> 1+10j: raise TestFailed, 'complex(1.0,10.0)' ! if complex(3.14+0j) <> 3.14+0j: raise TestFailed, 'complex(3.14)' ! if complex(3.14) <> 3.14+0j: raise TestFailed, 'complex(3.14)' ! if complex(314) <> 314.0+0j: raise TestFailed, 'complex(314)' ! if complex(314L) <> 314.0+0j: raise TestFailed, 'complex(314L)' ! if complex(3.14+0j, 0j) <> 3.14+0j: raise TestFailed, 'complex(3.14, 0j)' ! if complex(3.14, 0.0) <> 3.14+0j: raise TestFailed, 'complex(3.14, 0.0)' ! if complex(314, 0) <> 314.0+0j: raise TestFailed, 'complex(314, 0)' ! if complex(314L, 0L) <> 314.0+0j: raise TestFailed, 'complex(314L, 0L)' ! if complex(0j, 3.14j) <> -3.14+0j: raise TestFailed, 'complex(0j, 3.14j)' ! if complex(0.0, 3.14j) <> -3.14+0j: raise TestFailed, 'complex(0.0, 3.14j)' ! if complex(0j, 3.14) <> 3.14j: raise TestFailed, 'complex(0j, 3.14)' ! if complex(0.0, 3.14) <> 3.14j: raise TestFailed, 'complex(0.0, 3.14)' ! if complex(" 3.14+J ") <> 3.14+1j: raise TestFailed, 'complex(" 3.14+J )"' ! if complex(u" 3.14+J ") <> 3.14+1j: raise TestFailed, 'complex(u" 3.14+J )"' class Z: def __complex__(self): return 3.14j z = Z() ! if complex(z) <> 3.14j: raise TestFailed, 'complex(classinstance)' print 'delattr' --- 85,115 ---- print 'complex' ! if complex(1,10) != 1+10j: raise TestFailed, 'complex(1,10)' ! if complex(1,10L) != 1+10j: raise TestFailed, 'complex(1,10L)' ! if complex(1,10.0) != 1+10j: raise TestFailed, 'complex(1,10.0)' ! if complex(1L,10) != 1+10j: raise TestFailed, 'complex(1L,10)' ! if complex(1L,10L) != 1+10j: raise TestFailed, 'complex(1L,10L)' ! if complex(1L,10.0) != 1+10j: raise TestFailed, 'complex(1L,10.0)' ! if complex(1.0,10) != 1+10j: raise TestFailed, 'complex(1.0,10)' ! if complex(1.0,10L) != 1+10j: raise TestFailed, 'complex(1.0,10L)' ! if complex(1.0,10.0) != 1+10j: raise TestFailed, 'complex(1.0,10.0)' ! if complex(3.14+0j) != 3.14+0j: raise TestFailed, 'complex(3.14)' ! if complex(3.14) != 3.14+0j: raise TestFailed, 'complex(3.14)' ! if complex(314) != 314.0+0j: raise TestFailed, 'complex(314)' ! if complex(314L) != 314.0+0j: raise TestFailed, 'complex(314L)' ! if complex(3.14+0j, 0j) != 3.14+0j: raise TestFailed, 'complex(3.14, 0j)' ! if complex(3.14, 0.0) != 3.14+0j: raise TestFailed, 'complex(3.14, 0.0)' ! if complex(314, 0) != 314.0+0j: raise TestFailed, 'complex(314, 0)' ! if complex(314L, 0L) != 314.0+0j: raise TestFailed, 'complex(314L, 0L)' ! if complex(0j, 3.14j) != -3.14+0j: raise TestFailed, 'complex(0j, 3.14j)' ! if complex(0.0, 3.14j) != -3.14+0j: raise TestFailed, 'complex(0.0, 3.14j)' ! if complex(0j, 3.14) != 3.14j: raise TestFailed, 'complex(0j, 3.14)' ! if complex(0.0, 3.14) != 3.14j: raise TestFailed, 'complex(0.0, 3.14)' ! if complex(" 3.14+J ") != 3.14+1j: raise TestFailed, 'complex(" 3.14+J )"' ! if complex(u" 3.14+J ") != 3.14+1j: raise TestFailed, 'complex(u" 3.14+J )"' class Z: def __complex__(self): return 3.14j z = Z() ! if complex(z) != 3.14j: raise TestFailed, 'complex(classinstance)' print 'delattr' *************** *** 125,142 **** print 'divmod' ! if divmod(12, 7) <> (1, 5): raise TestFailed, 'divmod(12, 7)' ! if divmod(-12, 7) <> (-2, 2): raise TestFailed, 'divmod(-12, 7)' ! if divmod(12, -7) <> (-2, -2): raise TestFailed, 'divmod(12, -7)' ! if divmod(-12, -7) <> (1, -5): raise TestFailed, 'divmod(-12, -7)' # ! if divmod(12L, 7L) <> (1L, 5L): raise TestFailed, 'divmod(12L, 7L)' ! if divmod(-12L, 7L) <> (-2L, 2L): raise TestFailed, 'divmod(-12L, 7L)' ! if divmod(12L, -7L) <> (-2L, -2L): raise TestFailed, 'divmod(12L, -7L)' ! if divmod(-12L, -7L) <> (1L, -5L): raise TestFailed, 'divmod(-12L, -7L)' # ! if divmod(12, 7L) <> (1, 5L): raise TestFailed, 'divmod(12, 7L)' ! if divmod(-12, 7L) <> (-2, 2L): raise TestFailed, 'divmod(-12, 7L)' ! if divmod(12L, -7) <> (-2L, -2): raise TestFailed, 'divmod(12L, -7)' ! if divmod(-12L, -7) <> (1L, -5): raise TestFailed, 'divmod(-12L, -7)' # if fcmp(divmod(3.25, 1.0), (3.0, 0.25)): --- 125,142 ---- print 'divmod' ! if divmod(12, 7) != (1, 5): raise TestFailed, 'divmod(12, 7)' ! if divmod(-12, 7) != (-2, 2): raise TestFailed, 'divmod(-12, 7)' ! if divmod(12, -7) != (-2, -2): raise TestFailed, 'divmod(12, -7)' ! if divmod(-12, -7) != (1, -5): raise TestFailed, 'divmod(-12, -7)' # ! if divmod(12L, 7L) != (1L, 5L): raise TestFailed, 'divmod(12L, 7L)' ! if divmod(-12L, 7L) != (-2L, 2L): raise TestFailed, 'divmod(-12L, 7L)' ! if divmod(12L, -7L) != (-2L, -2L): raise TestFailed, 'divmod(12L, -7L)' ! if divmod(-12L, -7L) != (1L, -5L): raise TestFailed, 'divmod(-12L, -7L)' # ! if divmod(12, 7L) != (1, 5L): raise TestFailed, 'divmod(12, 7L)' ! if divmod(-12, 7L) != (-2, 2L): raise TestFailed, 'divmod(-12, 7L)' ! if divmod(12L, -7) != (-2L, -2): raise TestFailed, 'divmod(12L, -7)' ! if divmod(-12L, -7) != (1L, -5): raise TestFailed, 'divmod(-12L, -7)' # if fcmp(divmod(3.25, 1.0), (3.0, 0.25)): *************** *** 150,176 **** print 'eval' ! if eval('1+1') <> 2: raise TestFailed, 'eval(\'1+1\')' ! if eval(' 1+1\n') <> 2: raise TestFailed, 'eval(\' 1+1\\n\')' globals = {'a': 1, 'b': 2} locals = {'b': 200, 'c': 300} ! if eval('a', globals) <> 1: raise TestFailed, "eval(1) == %s" % eval('a', globals) ! if eval('a', globals, locals) <> 1: raise TestFailed, "eval(2)" ! if eval('b', globals, locals) <> 200: raise TestFailed, "eval(3)" ! if eval('c', globals, locals) <> 300: raise TestFailed, "eval(4)" ! if eval(u'1+1') <> 2: raise TestFailed, 'eval(u\'1+1\')' ! if eval(u' 1+1\n') <> 2: raise TestFailed, 'eval(u\' 1+1\\n\')' globals = {'a': 1, 'b': 2} locals = {'b': 200, 'c': 300} ! if eval(u'a', globals) <> 1: raise TestFailed, "eval(1) == %s" % eval(u'a', globals) ! if eval(u'a', globals, locals) <> 1: raise TestFailed, "eval(2)" ! if eval(u'b', globals, locals) <> 200: raise TestFailed, "eval(3)" ! if eval(u'c', globals, locals) <> 300: raise TestFailed, "eval(4)" --- 150,176 ---- print 'eval' ! if eval('1+1') != 2: raise TestFailed, 'eval(\'1+1\')' ! if eval(' 1+1\n') != 2: raise TestFailed, 'eval(\' 1+1\\n\')' globals = {'a': 1, 'b': 2} locals = {'b': 200, 'c': 300} ! if eval('a', globals) != 1: raise TestFailed, "eval(1) == %s" % eval('a', globals) ! if eval('a', globals, locals) != 1: raise TestFailed, "eval(2)" ! if eval('b', globals, locals) != 200: raise TestFailed, "eval(3)" ! if eval('c', globals, locals) != 300: raise TestFailed, "eval(4)" ! if eval(u'1+1') != 2: raise TestFailed, 'eval(u\'1+1\')' ! if eval(u' 1+1\n') != 2: raise TestFailed, 'eval(u\' 1+1\\n\')' globals = {'a': 1, 'b': 2} locals = {'b': 200, 'c': 300} ! if eval(u'a', globals) != 1: raise TestFailed, "eval(1) == %s" % eval(u'a', globals) ! if eval(u'a', globals, locals) != 1: raise TestFailed, "eval(2)" ! if eval(u'b', globals, locals) != 200: raise TestFailed, "eval(3)" ! if eval(u'c', globals, locals) != 300: raise TestFailed, "eval(4)" *************** *** 182,200 **** f.close() execfile(TESTFN) ! if z <> 2: raise TestFailed, "execfile(1)" globals['z'] = 0 execfile(TESTFN, globals) ! if globals['z'] <> 2: raise TestFailed, "execfile(1)" locals['z'] = 0 execfile(TESTFN, globals, locals) ! if locals['z'] <> 2: raise TestFailed, "execfile(1)" unlink(TESTFN) print 'filter' ! if filter(lambda c: 'a' <= c <= 'z', 'Hello World') <> 'elloorld': raise TestFailed, 'filter (filter a string)' ! if filter(None, [1, 'hello', [], [3], '', None, 9, 0]) <> [1, 'hello', [3], 9]: raise TestFailed, 'filter (remove false values)' ! if filter(lambda x: x > 0, [1, -3, 9, 0, 2]) <> [1, 9, 2]: raise TestFailed, 'filter (keep positives)' class Squares: --- 182,200 ---- f.close() execfile(TESTFN) ! if z != 2: raise TestFailed, "execfile(1)" globals['z'] = 0 execfile(TESTFN, globals) ! if globals['z'] != 2: raise TestFailed, "execfile(1)" locals['z'] = 0 execfile(TESTFN, globals, locals) ! if locals['z'] != 2: raise TestFailed, "execfile(1)" unlink(TESTFN) print 'filter' ! if filter(lambda c: 'a' <= c <= 'z', 'Hello World') != 'elloorld': raise TestFailed, 'filter (filter a string)' ! if filter(None, [1, 'hello', [], [3], '', None, 9, 0]) != [1, 'hello', [3], 9]: raise TestFailed, 'filter (remove false values)' ! if filter(lambda x: x > 0, [1, -3, 9, 0, 2]) != [1, 9, 2]: raise TestFailed, 'filter (keep positives)' class Squares: *************** *** 233,242 **** print 'float' ! if float(3.14) <> 3.14: raise TestFailed, 'float(3.14)' ! if float(314) <> 314.0: raise TestFailed, 'float(314)' ! if float(314L) <> 314.0: raise TestFailed, 'float(314L)' ! if float(" 3.14 ") <> 3.14: raise TestFailed, 'float(" 3.14 ")' ! if float(u" 3.14 ") <> 3.14: raise TestFailed, 'float(u" 3.14 ")' ! if float(u" \u0663.\u0661\u0664 ") <> 3.14: raise TestFailed, 'float(u" \u0663.\u0661\u0664 ")' --- 233,242 ---- print 'float' ! if float(3.14) != 3.14: raise TestFailed, 'float(3.14)' ! if float(314) != 314.0: raise TestFailed, 'float(314)' ! if float(314L) != 314.0: raise TestFailed, 'float(314L)' ! if float(" 3.14 ") != 3.14: raise TestFailed, 'float(" 3.14 ")' ! if float(u" 3.14 ") != 3.14: raise TestFailed, 'float(u" 3.14 ")' ! if float(u" \u0663.\u0661\u0664 ") != 3.14: raise TestFailed, 'float(u" \u0663.\u0661\u0664 ")' *************** *** 277,292 **** print 'int' ! if int(314) <> 314: raise TestFailed, 'int(314)' ! if int(3.14) <> 3: raise TestFailed, 'int(3.14)' ! if int(314L) <> 314: raise TestFailed, 'int(314L)' # Check that conversion from float truncates towards zero ! if int(-3.14) <> -3: raise TestFailed, 'int(-3.14)' ! if int(3.9) <> 3: raise TestFailed, 'int(3.9)' ! if int(-3.9) <> -3: raise TestFailed, 'int(-3.9)' ! if int(3.5) <> 3: raise TestFailed, 'int(3.5)' ! if int(-3.5) <> -3: raise TestFailed, 'int(-3.5)' # Different base: ! if int("10",16) <> 16L: raise TestFailed, 'int("10",16)' ! if int(u"10",16) <> 16L: raise TestFailed, 'int(u"10",16)' # Test conversion from strings and various anomalies L = [ --- 277,292 ---- print 'int' ! if int(314) != 314: raise TestFailed, 'int(314)' ! if int(3.14) != 3: raise TestFailed, 'int(3.14)' ! if int(314L) != 314: raise TestFailed, 'int(314L)' # Check that conversion from float truncates towards zero ! if int(-3.14) != -3: raise TestFailed, 'int(-3.14)' ! if int(3.9) != 3: raise TestFailed, 'int(3.9)' ! if int(-3.9) != -3: raise TestFailed, 'int(-3.9)' ! if int(3.5) != 3: raise TestFailed, 'int(3.5)' ! if int(-3.5) != -3: raise TestFailed, 'int(-3.5)' # Different base: ! if int("10",16) != 16L: raise TestFailed, 'int("10",16)' ! if int(u"10",16) != 16L: raise TestFailed, 'int(u"10",16)' # Test conversion from strings and various anomalies L = [ *************** *** 386,411 **** print 'len' ! if len('123') <> 3: raise TestFailed, 'len(\'123\')' ! if len(()) <> 0: raise TestFailed, 'len(())' ! if len((1, 2, 3, 4)) <> 4: raise TestFailed, 'len((1, 2, 3, 4))' ! if len([1, 2, 3, 4]) <> 4: raise TestFailed, 'len([1, 2, 3, 4])' ! if len({}) <> 0: raise TestFailed, 'len({})' ! if len({'a':1, 'b': 2}) <> 2: raise TestFailed, 'len({\'a\':1, \'b\': 2})' print 'long' ! if long(314) <> 314L: raise TestFailed, 'long(314)' ! if long(3.14) <> 3L: raise TestFailed, 'long(3.14)' ! if long(314L) <> 314L: raise TestFailed, 'long(314L)' # Check that conversion from float truncates towards zero ! if long(-3.14) <> -3L: raise TestFailed, 'long(-3.14)' ! if long(3.9) <> 3L: raise TestFailed, 'long(3.9)' ! if long(-3.9) <> -3L: raise TestFailed, 'long(-3.9)' ! if long(3.5) <> 3L: raise TestFailed, 'long(3.5)' ! if long(-3.5) <> -3L: raise TestFailed, 'long(-3.5)' ! if long("-3") <> -3L: raise TestFailed, 'long("-3")' ! if long(u"-3") <> -3L: raise TestFailed, 'long(u"-3")' # Different base: ! if long("10",16) <> 16L: raise TestFailed, 'long("10",16)' ! if long(u"10",16) <> 16L: raise TestFailed, 'long(u"10",16)' # Check conversions from string (same test set as for int(), and then some) LL = [ --- 386,411 ---- print 'len' ! if len('123') != 3: raise TestFailed, 'len(\'123\')' ! if len(()) != 0: raise TestFailed, 'len(())' ! if len((1, 2, 3, 4)) != 4: raise TestFailed, 'len((1, 2, 3, 4))' ! if len([1, 2, 3, 4]) != 4: raise TestFailed, 'len([1, 2, 3, 4])' ! if len({}) != 0: raise TestFailed, 'len({})' ! if len({'a':1, 'b': 2}) != 2: raise TestFailed, 'len({\'a\':1, \'b\': 2})' print 'long' ! if long(314) != 314L: raise TestFailed, 'long(314)' ! if long(3.14) != 3L: raise TestFailed, 'long(3.14)' ! if long(314L) != 314L: raise TestFailed, 'long(314L)' # Check that conversion from float truncates towards zero ! if long(-3.14) != -3L: raise TestFailed, 'long(-3.14)' ! if long(3.9) != 3L: raise TestFailed, 'long(3.9)' ! if long(-3.9) != -3L: raise TestFailed, 'long(-3.9)' ! if long(3.5) != 3L: raise TestFailed, 'long(3.5)' ! if long(-3.5) != -3L: raise TestFailed, 'long(-3.5)' ! if long("-3") != -3L: raise TestFailed, 'long("-3")' ! if long(u"-3") != -3L: raise TestFailed, 'long(u"-3")' # Different base: ! if long("10",16) != 16L: raise TestFailed, 'long("10",16)' ! if long(u"10",16) != 16L: raise TestFailed, 'long(u"10",16)' # Check conversions from string (same test set as for int(), and then some) LL = [ *************** *** 431,442 **** print 'map' ! if map(None, 'hello world') <> ['h','e','l','l','o',' ','w','o','r','l','d']: raise TestFailed, 'map(None, \'hello world\')' ! if map(None, 'abcd', 'efg') <> \ [('a', 'e'), ('b', 'f'), ('c', 'g'), ('d', None)]: raise TestFailed, 'map(None, \'abcd\', \'efg\')' ! if map(None, range(10)) <> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]: raise TestFailed, 'map(None, range(10))' ! if map(lambda x: x*x, range(1,4)) <> [1, 4, 9]: raise TestFailed, 'map(lambda x: x*x, range(1,4))' try: --- 431,442 ---- print 'map' ! if map(None, 'hello world') != ['h','e','l','l','o',' ','w','o','r','l','d']: raise TestFailed, 'map(None, \'hello world\')' ! if map(None, 'abcd', 'efg') != \ [('a', 'e'), ('b', 'f'), ('c', 'g'), ('d', None)]: raise TestFailed, 'map(None, \'abcd\', \'efg\')' ! if map(None, range(10)) != [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]: raise TestFailed, 'map(None, range(10))' ! if map(lambda x: x*x, range(1,4)) != [1, 4, 9]: raise TestFailed, 'map(lambda x: x*x, range(1,4))' try: *************** *** 445,451 **** def sqrt(x): return pow(x, 0.5) ! if map(lambda x: map(sqrt,x), [[16, 4], [81, 9]]) <> [[4.0, 2.0], [9.0, 3.0]]: raise TestFailed, 'map(lambda x: map(sqrt,x), [[16, 4], [81, 9]])' ! if map(lambda x, y: x+y, [1,3,2], [9,1,4]) <> [10, 4, 6]: raise TestFailed, 'map(lambda x,y: x+y, [1,3,2], [9,1,4])' def plus(*v): --- 445,451 ---- def sqrt(x): return pow(x, 0.5) ! if map(lambda x: map(sqrt,x), [[16, 4], [81, 9]]) != [[4.0, 2.0], [9.0, 3.0]]: raise TestFailed, 'map(lambda x: map(sqrt,x), [[16, 4], [81, 9]])' ! if map(lambda x, y: x+y, [1,3,2], [9,1,4]) != [10, 4, 6]: raise TestFailed, 'map(lambda x,y: x+y, [1,3,2], [9,1,4])' def plus(*v): *************** *** 453,461 **** for i in v: accu = accu + i return accu ! if map(plus, [1, 3, 7]) <> [1, 3, 7]: raise TestFailed, 'map(plus, [1, 3, 7])' ! if map(plus, [1, 3, 7], [4, 9, 2]) <> [1+4, 3+9, 7+2]: raise TestFailed, 'map(plus, [1, 3, 7], [4, 9, 2])' ! if map(plus, [1, 3, 7], [4, 9, 2], [1, 1, 0]) <> [1+4+1, 3+9+1, 7+2+0]: raise TestFailed, 'map(plus, [1, 3, 7], [4, 9, 2], [1, 1, 0])' if map(None, Squares(10)) != [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]: --- 453,461 ---- for i in v: accu = accu + i return accu ! if map(plus, [1, 3, 7]) != [1, 3, 7]: raise TestFailed, 'map(plus, [1, 3, 7])' ! if map(plus, [1, 3, 7], [4, 9, 2]) != [1+4, 3+9, 7+2]: raise TestFailed, 'map(plus, [1, 3, 7], [4, 9, 2])' ! if map(plus, [1, 3, 7], [4, 9, 2], [1, 1, 0]) != [1+4+1, 3+9+1, 7+2+0]: raise TestFailed, 'map(plus, [1, 3, 7], [4, 9, 2], [1, 1, 0])' if map(None, Squares(10)) != [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]: *************** *** 469,488 **** print 'max' ! if max('123123') <> '3': raise TestFailed, 'max(\'123123\')' ! if max(1, 2, 3) <> 3: raise TestFailed, 'max(1, 2, 3)' ! if max((1, 2, 3, 1, 2, 3)) <> 3: raise TestFailed, 'max((1, 2, 3, 1, 2, 3))' ! if max([1, 2, 3, 1, 2, 3]) <> 3: raise TestFailed, 'max([1, 2, 3, 1, 2, 3])' # ! if max(1, 2L, 3.0) <> 3.0: raise TestFailed, 'max(1, 2L, 3.0)' ! if max(1L, 2.0, 3) <> 3: raise TestFailed, 'max(1L, 2.0, 3)' ! if max(1.0, 2, 3L) <> 3L: raise TestFailed, 'max(1.0, 2, 3L)' print 'min' ! if min('123123') <> '1': raise TestFailed, 'min(\'123123\')' ! if min(1, 2, 3) <> 1: raise TestFailed, 'min(1, 2, 3)' ! if min((1, 2, 3, 1, 2, 3)) <> 1: raise TestFailed, 'min((1, 2, 3, 1, 2, 3))' ! if min([1, 2, 3, 1, 2, 3]) <> 1: raise TestFailed, 'min([1, 2, 3, 1, 2, 3])' # ! if min(1, 2L, 3.0) <> 1: raise TestFailed, 'min(1, 2L, 3.0)' ! if min(1L, 2.0, 3) <> 1L: raise TestFailed, 'min(1L, 2.0, 3)' ! if min(1.0, 2, 3L) <> 1.0: raise TestFailed, 'min(1.0, 2, 3L)' --- 469,488 ---- print 'max' ! if max('123123') != '3': raise TestFailed, 'max(\'123123\')' ! if max(1, 2, 3) != 3: raise TestFailed, 'max(1, 2, 3)' ! if max((1, 2, 3, 1, 2, 3)) != 3: raise TestFailed, 'max((1, 2, 3, 1, 2, 3))' ! if max([1, 2, 3, 1, 2, 3]) != 3: raise TestFailed, 'max([1, 2, 3, 1, 2, 3])' # ! if max(1, 2L, 3.0) != 3.0: raise TestFailed, 'max(1, 2L, 3.0)' ! if max(1L, 2.0, 3) != 3: raise TestFailed, 'max(1L, 2.0, 3)' ! if max(1.0, 2, 3L) != 3L: raise TestFailed, 'max(1.0, 2, 3L)' print 'min' ! if min('123123') != '1': raise TestFailed, 'min(\'123123\')' ! if min(1, 2, 3) != 1: raise TestFailed, 'min(1, 2, 3)' ! if min((1, 2, 3, 1, 2, 3)) != 1: raise TestFailed, 'min((1, 2, 3, 1, 2, 3))' ! if min([1, 2, 3, 1, 2, 3]) != 1: raise TestFailed, 'min([1, 2, 3, 1, 2, 3])' # ! if min(1, 2L, 3.0) != 1: raise TestFailed, 'min(1, 2L, 3.0)' ! if min(1L, 2.0, 3) != 1L: raise TestFailed, 'min(1L, 2.0, 3)' ! if min(1.0, 2, 3L) != 1.0: raise TestFailed, 'min(1.0, 2, 3L)' Index: test_b2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b2.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** test_b2.py 2000/11/08 19:51:25 1.20 --- test_b2.py 2000/12/12 23:11:42 1.21 *************** *** 26,75 **** fp = open(TESTFN, 'r') try: ! if fp.readline(4) <> '1+1\n': raise TestFailed, 'readline(4) # exact' ! if fp.readline(4) <> '1+1\n': raise TestFailed, 'readline(4) # exact' ! if fp.readline() <> 'The quick brown fox jumps over the lazy dog.\n': raise TestFailed, 'readline() # default' ! if fp.readline(4) <> 'Dear': raise TestFailed, 'readline(4) # short' ! if fp.readline(100) <> ' John\n': raise TestFailed, 'readline(100)' ! if fp.read(300) <> 'XXX'*100: raise TestFailed, 'read(300)' ! if fp.read(1000) <> 'YYY'*100: raise TestFailed, 'read(1000) # truncate' finally: fp.close() print 'ord' ! if ord(' ') <> 32: raise TestFailed, 'ord(\' \')' ! if ord('A') <> 65: raise TestFailed, 'ord(\'A\')' ! if ord('a') <> 97: raise TestFailed, 'ord(\'a\')' print 'pow' ! if pow(0,0) <> 1: raise TestFailed, 'pow(0,0)' ! if pow(0,1) <> 0: raise TestFailed, 'pow(0,1)' ! if pow(1,0) <> 1: raise TestFailed, 'pow(1,0)' ! if pow(1,1) <> 1: raise TestFailed, 'pow(1,1)' # ! if pow(2,0) <> 1: raise TestFailed, 'pow(2,0)' ! if pow(2,10) <> 1024: raise TestFailed, 'pow(2,10)' ! if pow(2,20) <> 1024*1024: raise TestFailed, 'pow(2,20)' ! if pow(2,30) <> 1024*1024*1024: raise TestFailed, 'pow(2,30)' # ! if pow(-2,0) <> 1: raise TestFailed, 'pow(-2,0)' ! if pow(-2,1) <> -2: raise TestFailed, 'pow(-2,1)' ! if pow(-2,2) <> 4: raise TestFailed, 'pow(-2,2)' ! if pow(-2,3) <> -8: raise TestFailed, 'pow(-2,3)' # ! if pow(0L,0) <> 1: raise TestFailed, 'pow(0L,0)' ! if pow(0L,1) <> 0: raise TestFailed, 'pow(0L,1)' ! if pow(1L,0) <> 1: raise TestFailed, 'pow(1L,0)' ! if pow(1L,1) <> 1: raise TestFailed, 'pow(1L,1)' # ! if pow(2L,0) <> 1: raise TestFailed, 'pow(2L,0)' ! if pow(2L,10) <> 1024: raise TestFailed, 'pow(2L,10)' ! if pow(2L,20) <> 1024*1024: raise TestFailed, 'pow(2L,20)' ! if pow(2L,30) <> 1024*1024*1024: raise TestFailed, 'pow(2L,30)' # ! if pow(-2L,0) <> 1: raise TestFailed, 'pow(-2L,0)' ! if pow(-2L,1) <> -2: raise TestFailed, 'pow(-2L,1)' ! if pow(-2L,2) <> 4: raise TestFailed, 'pow(-2L,2)' ! if pow(-2L,3) <> -8: raise TestFailed, 'pow(-2L,3)' # if fcmp(pow(0.,0), 1.): raise TestFailed, 'pow(0.,0)' --- 26,75 ---- fp = open(TESTFN, 'r') try: ! if fp.readline(4) != '1+1\n': raise TestFailed, 'readline(4) # exact' ! if fp.readline(4) != '1+1\n': raise TestFailed, 'readline(4) # exact' ! if fp.readline() != 'The quick brown fox jumps over the lazy dog.\n': raise TestFailed, 'readline() # default' ! if fp.readline(4) != 'Dear': raise TestFailed, 'readline(4) # short' ! if fp.readline(100) != ' John\n': raise TestFailed, 'readline(100)' ! if fp.read(300) != 'XXX'*100: raise TestFailed, 'read(300)' ! if fp.read(1000) != 'YYY'*100: raise TestFailed, 'read(1000) # truncate' finally: fp.close() print 'ord' ! if ord(' ') != 32: raise TestFailed, 'ord(\' \')' ! if ord('A') != 65: raise TestFailed, 'ord(\'A\')' ! if ord('a') != 97: raise TestFailed, 'ord(\'a\')' print 'pow' ! if pow(0,0) != 1: raise TestFailed, 'pow(0,0)' ! if pow(0,1) != 0: raise TestFailed, 'pow(0,1)' ! if pow(1,0) != 1: raise TestFailed, 'pow(1,0)' ! if pow(1,1) != 1: raise TestFailed, 'pow(1,1)' # ! if pow(2,0) != 1: raise TestFailed, 'pow(2,0)' ! if pow(2,10) != 1024: raise TestFailed, 'pow(2,10)' ! if pow(2,20) != 1024*1024: raise TestFailed, 'pow(2,20)' ! if pow(2,30) != 1024*1024*1024: raise TestFailed, 'pow(2,30)' # ! if pow(-2,0) != 1: raise TestFailed, 'pow(-2,0)' ! if pow(-2,1) != -2: raise TestFailed, 'pow(-2,1)' ! if pow(-2,2) != 4: raise TestFailed, 'pow(-2,2)' ! if pow(-2,3) != -8: raise TestFailed, 'pow(-2,3)' # ! if pow(0L,0) != 1: raise TestFailed, 'pow(0L,0)' ! if pow(0L,1) != 0: raise TestFailed, 'pow(0L,1)' ! if pow(1L,0) != 1: raise TestFailed, 'pow(1L,0)' ! if pow(1L,1) != 1: raise TestFailed, 'pow(1L,1)' # ! if pow(2L,0) != 1: raise TestFailed, 'pow(2L,0)' ! if pow(2L,10) != 1024: raise TestFailed, 'pow(2L,10)' ! if pow(2L,20) != 1024*1024: raise TestFailed, 'pow(2L,20)' ! if pow(2L,30) != 1024*1024*1024: raise TestFailed, 'pow(2L,30)' # ! if pow(-2L,0) != 1: raise TestFailed, 'pow(-2L,0)' ! if pow(-2L,1) != -2: raise TestFailed, 'pow(-2L,1)' ! if pow(-2L,2) != 4: raise TestFailed, 'pow(-2L,2)' ! if pow(-2L,3) != -8: raise TestFailed, 'pow(-2L,3)' # if fcmp(pow(0.,0), 1.): raise TestFailed, 'pow(0.,0)' *************** *** 96,105 **** print 'range' ! if range(3) <> [0, 1, 2]: raise TestFailed, 'range(3)' ! if range(1, 5) <> [1, 2, 3, 4]: raise TestFailed, 'range(1, 5)' ! if range(0) <> []: raise TestFailed, 'range(0)' ! if range(-3) <> []: raise TestFailed, 'range(-3)' ! if range(1, 10, 3) <> [1, 4, 7]: raise TestFailed, 'range(1, 10, 3)' ! if range(5, -5, -3) <> [5, 2, -1, -4]: raise TestFailed, 'range(5, -5, -3)' print 'input and raw_input' --- 96,105 ---- print 'range' ! if range(3) != [0, 1, 2]: raise TestFailed, 'range(3)' ! if range(1, 5) != [1, 2, 3, 4]: raise TestFailed, 'range(1, 5)' ! if range(0) != []: raise TestFailed, 'range(0)' ! if range(-3) != []: raise TestFailed, 'range(-3)' ! if range(1, 10, 3) != [1, 4, 7]: raise TestFailed, 'range(1, 10, 3)' ! if range(5, -5, -3) != [5, 2, -1, -4]: raise TestFailed, 'range(5, -5, -3)' print 'input and raw_input' *************** *** 109,117 **** try: sys.stdin = fp ! if input() <> 2: raise TestFailed, 'input()' ! if input('testing\n') <> 2: raise TestFailed, 'input()' ! if raw_input() <> 'The quick brown fox jumps over the lazy dog.': raise TestFailed, 'raw_input()' ! if raw_input('testing\n') <> 'Dear John': raise TestFailed, 'raw_input(\'testing\\n\')' finally: --- 109,117 ---- try: sys.stdin = fp ! if input() != 2: raise TestFailed, 'input()' ! if input('testing\n') != 2: raise TestFailed, 'input()' ! if raw_input() != 'The quick brown fox jumps over the lazy dog.': raise TestFailed, 'raw_input()' ! if raw_input('testing\n') != 'Dear John': raise TestFailed, 'raw_input(\'testing\\n\')' finally: *************** *** 120,131 **** print 'reduce' ! if reduce(lambda x, y: x+y, ['a', 'b', 'c'], '') <> 'abc': raise TestFailed, 'reduce(): implode a string' if reduce(lambda x, y: x+y, ! [['a', 'c'], [], ['d', 'w']], []) <> ['a','c','d','w']: raise TestFailed, 'reduce(): append' ! if reduce(lambda x, y: x*y, range(2,8), 1) <> 5040: raise TestFailed, 'reduce(): compute 7!' ! if reduce(lambda x, y: x*y, range(2,21), 1L) <> 2432902008176640000L: raise TestFailed, 'reduce(): compute 20!, use long' class Squares: --- 120,131 ---- print 'reduce' ! if reduce(lambda x, y: x+y, ['a', 'b', 'c'], '') != 'abc': raise TestFailed, 'reduce(): implode a string' if reduce(lambda x, y: x+y, ! [['a', 'c'], [], ['d', 'w']], []) != ['a','c','d','w']: raise TestFailed, 'reduce(): append' ! if reduce(lambda x, y: x*y, range(2,8), 1) != 5040: raise TestFailed, 'reduce(): compute 7!' ! if reduce(lambda x, y: x*y, range(2,21), 1L) != 2432902008176640000L: raise TestFailed, 'reduce(): compute 20!, use long' class Squares: *************** *** 160,203 **** print 'repr' ! if repr('') <> '\'\'': raise TestFailed, 'repr(\'\')' ! if repr(0) <> '0': raise TestFailed, 'repr(0)' ! if repr(0L) <> '0L': raise TestFailed, 'repr(0L)' ! if repr(()) <> '()': raise TestFailed, 'repr(())' ! if repr([]) <> '[]': raise TestFailed, 'repr([])' ! if repr({}) <> '{}': raise TestFailed, 'repr({})' print 'round' ! if round(0.0) <> 0.0: raise TestFailed, 'round(0.0)' ! if round(1.0) <> 1.0: raise TestFailed, 'round(1.0)' ! if round(10.0) <> 10.0: raise TestFailed, 'round(10.0)' ! if round(1000000000.0) <> 1000000000.0: raise TestFailed, 'round(1000000000.0)' ! if round(1e20) <> 1e20: raise TestFailed, 'round(1e20)' ! if round(-1.0) <> -1.0: raise TestFailed, 'round(-1.0)' ! if round(-10.0) <> -10.0: raise TestFailed, 'round(-10.0)' ! if round(-1000000000.0) <> -1000000000.0: raise TestFailed, 'round(-1000000000.0)' ! if round(-1e20) <> -1e20: raise TestFailed, 'round(-1e20)' ! if round(0.1) <> 0.0: raise TestFailed, 'round(0.0)' ! if round(1.1) <> 1.0: raise TestFailed, 'round(1.0)' ! if round(10.1) <> 10.0: raise TestFailed, 'round(10.0)' ! if round(1000000000.1) <> 1000000000.0: raise TestFailed, 'round(1000000000.0)' ! if round(-1.1) <> -1.0: raise TestFailed, 'round(-1.0)' ! if round(-10.1) <> -10.0: raise TestFailed, 'round(-10.0)' ! if round(-1000000000.1) <> -1000000000.0: raise TestFailed, 'round(-1000000000.0)' ! if round(0.9) <> 1.0: raise TestFailed, 'round(0.9)' ! if round(9.9) <> 10.0: raise TestFailed, 'round(9.9)' ! if round(999999999.9) <> 1000000000.0: raise TestFailed, 'round(999999999.9)' ! if round(-0.9) <> -1.0: raise TestFailed, 'round(-0.9)' ! if round(-9.9) <> -10.0: raise TestFailed, 'round(-9.9)' ! if round(-999999999.9) <> -1000000000.0: raise TestFailed, 'round(-999999999.9)' --- 160,203 ---- print 'repr' ! if repr('') != '\'\'': raise TestFailed, 'repr(\'\')' ! if repr(0) != '0': raise TestFailed, 'repr(0)' ! if repr(0L) != '0L': raise TestFailed, 'repr(0L)' ! if repr(()) != '()': raise TestFailed, 'repr(())' ! if repr([]) != '[]': raise TestFailed, 'repr([])' ! if repr({}) != '{}': raise TestFailed, 'repr({})' print 'round' ! if round(0.0) != 0.0: raise TestFailed, 'round(0.0)' ! if round(1.0) != 1.0: raise TestFailed, 'round(1.0)' ! if round(10.0) != 10.0: raise TestFailed, 'round(10.0)' ! if round(1000000000.0) != 1000000000.0: raise TestFailed, 'round(1000000000.0)' ! if round(1e20) != 1e20: raise TestFailed, 'round(1e20)' ! if round(-1.0) != -1.0: raise TestFailed, 'round(-1.0)' ! if round(-10.0) != -10.0: raise TestFailed, 'round(-10.0)' ! if round(-1000000000.0) != -1000000000.0: raise TestFailed, 'round(-1000000000.0)' ! if round(-1e20) != -1e20: raise TestFailed, 'round(-1e20)' ! if round(0.1) != 0.0: raise TestFailed, 'round(0.0)' ! if round(1.1) != 1.0: raise TestFailed, 'round(1.0)' ! if round(10.1) != 10.0: raise TestFailed, 'round(10.0)' ! if round(1000000000.1) != 1000000000.0: raise TestFailed, 'round(1000000000.0)' ! if round(-1.1) != -1.0: raise TestFailed, 'round(-1.0)' ! if round(-10.1) != -10.0: raise TestFailed, 'round(-10.0)' ! if round(-1000000000.1) != -1000000000.0: raise TestFailed, 'round(-1000000000.0)' ! if round(0.9) != 1.0: raise TestFailed, 'round(0.9)' ! if round(9.9) != 10.0: raise TestFailed, 'round(9.9)' ! if round(999999999.9) != 1000000000.0: raise TestFailed, 'round(999999999.9)' ! if round(-0.9) != -1.0: raise TestFailed, 'round(-0.9)' ! if round(-9.9) != -10.0: raise TestFailed, 'round(-9.9)' ! if round(-999999999.9) != -1000000000.0: raise TestFailed, 'round(-999999999.9)' *************** *** 208,228 **** print 'str' ! if str('') <> '': raise TestFailed, 'str(\'\')' ! if str(0) <> '0': raise TestFailed, 'str(0)' ! if str(0L) <> '0': raise TestFailed, 'str(0L)' ! if str(()) <> '()': raise TestFailed, 'str(())' ! if str([]) <> '[]': raise TestFailed, 'str([])' ! if str({}) <> '{}': raise TestFailed, 'str({})' print 'tuple' ! if tuple(()) <> (): raise TestFailed, 'tuple(())' ! if tuple((0, 1, 2, 3)) <> (0, 1, 2, 3): raise TestFailed, 'tuple((0, 1, 2, 3))' ! if tuple([]) <> (): raise TestFailed, 'tuple([])' ! if tuple([0, 1, 2, 3]) <> (0, 1, 2, 3): raise TestFailed, 'tuple([0, 1, 2, 3])' ! if tuple('') <> (): raise TestFailed, 'tuple('')' ! if tuple('spam') <> ('s', 'p', 'a', 'm'): raise TestFailed, "tuple('spam')" print 'type' ! if type('') <> type('123') or type('') == type(()): raise TestFailed, 'type()' --- 208,228 ---- print 'str' ! if str('') != '': raise TestFailed, 'str(\'\')' ! if str(0) != '0': raise TestFailed, 'str(0)' ! if str(0L) != '0': raise TestFailed, 'str(0L)' ! if str(()) != '()': raise TestFailed, 'str(())' ! if str([]) != '[]': raise TestFailed, 'str([])' ! if str({}) != '{}': raise TestFailed, 'str({})' print 'tuple' ! if tuple(()) != (): raise TestFailed, 'tuple(())' ! if tuple((0, 1, 2, 3)) != (0, 1, 2, 3): raise TestFailed, 'tuple((0, 1, 2, 3))' ! if tuple([]) != (): raise TestFailed, 'tuple([])' ! if tuple([0, 1, 2, 3]) != (0, 1, 2, 3): raise TestFailed, 'tuple([0, 1, 2, 3])' ! if tuple('') != (): raise TestFailed, 'tuple('')' ! if tuple('spam') != ('s', 'p', 'a', 'm'): raise TestFailed, "tuple('spam')" print 'type' ! if type('') != type('123') or type('') == type(()): raise TestFailed, 'type()' *************** *** 233,237 **** a.sort() b.sort() ! if a <> b: raise TestFailed, 'vars()' import sys a = vars(sys).keys() --- 233,237 ---- a.sort() b.sort() ! if a != b: raise TestFailed, 'vars()' import sys a = vars(sys).keys() *************** *** 239,243 **** a.sort() b.sort() ! if a <> b: raise TestFailed, 'vars(sys)' def f0(): if vars() != {}: raise TestFailed, 'vars() in f0()' --- 239,243 ---- a.sort() b.sort() ! if a != b: raise TestFailed, 'vars(sys)' def f0(): if vars() != {}: raise TestFailed, 'vars() in f0()' *************** *** 251,257 **** print 'xrange' ! 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)' # regression tests for SourceForge bug #121695 --- 251,257 ---- print 'xrange' ! 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)' # regression tests for SourceForge bug #121695 *************** *** 274,287 **** b = (4, 5, 6) t = [(1, 4), (2, 5), (3, 6)] ! if zip(a, b) <> t: raise TestFailed, 'zip(a, b) - same size, both tuples' b = [4, 5, 6] ! if zip(a, b) <> t: raise TestFailed, 'zip(a, b) - same size, tuple/list' b = (4, 5, 6, 7) ! if zip(a, b) <> t: raise TestFailed, 'zip(a, b) - b is longer' class I: def __getitem__(self, i): if i < 0 or i > 2: raise IndexError return i + 4 ! if zip(a, I()) <> t: raise TestFailed, 'zip(a, b) - b is instance' exc = 0 try: --- 274,287 ---- b = (4, 5, 6) t = [(1, 4), (2, 5), (3, 6)] ! if zip(a, b) != t: raise TestFailed, 'zip(a, b) - same size, both tuples' b = [4, 5, 6] ! if zip(a, b) != t: raise TestFailed, 'zip(a, b) - same size, tuple/list' b = (4, 5, 6, 7) ! if zip(a, b) != t: raise TestFailed, 'zip(a, b) - b is longer' class I: def __getitem__(self, i): if i < 0 or i > 2: raise IndexError return i + 4 ! if zip(a, I()) != t: raise TestFailed, 'zip(a, b) - b is instance' exc = 0 try: Index: test_binascii.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_binascii.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_binascii.py 2000/08/15 06:08:31 1.6 --- test_binascii.py 2000/12/12 23:11:42 1.7 *************** *** 97,101 **** t = binascii.b2a_hex(s) u = binascii.a2b_hex(t) ! if s <> u: print 'binascii hexlification failed' try: --- 97,101 ---- t = binascii.b2a_hex(s) u = binascii.a2b_hex(t) ! if s != u: print 'binascii hexlification failed' try: Index: test_binhex.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_binhex.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_binhex.py 2000/10/23 17:22:07 1.6 --- test_binhex.py 2000/12/12 23:11:42 1.7 *************** *** 33,38 **** finish = f.readline() ! if start <> finish: ! print 'Error: binhex <> hexbin' elif verbose: print 'binhex == hexbin' --- 33,38 ---- finish = f.readline() ! if start != finish: ! print 'Error: binhex != hexbin' elif verbose: print 'binhex == hexbin' Index: test_bsddb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_bsddb.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** test_bsddb.py 2000/10/23 17:22:07 1.4 --- test_bsddb.py 2000/12/12 23:11:42 1.5 *************** *** 35,40 **** rec = f.next() except KeyError: ! if rec <> f.last(): ! print 'Error, last <> last!' f.previous() break --- 35,40 ---- rec = f.next() except KeyError: ! if rec != f.last(): ! print 'Error, last != last!' f.previous() break Index: test_grammar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_grammar.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** test_grammar.py 2000/10/23 17:22:07 1.20 --- test_grammar.py 2000/12/12 23:11:42 1.21 *************** *** 13,27 **** x = 1 \ + 1 ! if x <> 2: raise TestFailed, 'backslash for line continuation' # Backslash does not means continuation in comments :\ x = 0 ! if x <> 0: raise TestFailed, 'backslash ending comment' print '1.1.2 Numeric literals' print '1.1.2.1 Plain integers' ! if 0xff <> 255: raise TestFailed, 'hex int' ! if 0377 <> 255: raise TestFailed, 'octal int' if 2147483647 != 017777777777: raise TestFailed, 'large positive int' try: --- 13,27 ---- x = 1 \ + 1 ! if x != 2: raise TestFailed, 'backslash for line continuation' # Backslash does not means continuation in comments :\ x = 0 ! if x != 0: raise TestFailed, 'backslash ending comment' print '1.1.2 Numeric literals' print '1.1.2.1 Plain integers' ! if 0xff != 255: raise TestFailed, 'hex int' ! if 0377 != 255: raise TestFailed, 'octal int' if 2147483647 != 017777777777: raise TestFailed, 'large positive int' try: *************** *** 360,379 **** del z exec 'z=1+1\n' ! if z <> 2: raise TestFailed, 'exec \'z=1+1\'\\n' del z exec 'z=1+1' ! if z <> 2: raise TestFailed, 'exec \'z=1+1\'' z = None del z exec u'z=1+1\n' ! if z <> 2: raise TestFailed, 'exec u\'z=1+1\'\\n' del z exec u'z=1+1' ! if z <> 2: raise TestFailed, 'exec u\'z=1+1\'' f() g = {} exec 'z = 1' in g if g.has_key('__builtins__'): del g['__builtins__'] ! if g <> {'z': 1}: raise TestFailed, 'exec \'z = 1\' in g' g = {} l = {} --- 360,379 ---- del z exec 'z=1+1\n' ! if z != 2: raise TestFailed, 'exec \'z=1+1\'\\n' del z exec 'z=1+1' ! if z != 2: raise TestFailed, 'exec \'z=1+1\'' z = None del z exec u'z=1+1\n' ! if z != 2: raise TestFailed, 'exec u\'z=1+1\'\\n' del z exec u'z=1+1' ! if z != 2: raise TestFailed, 'exec u\'z=1+1\'' f() g = {} exec 'z = 1' in g if g.has_key('__builtins__'): del g['__builtins__'] ! if g != {'z': 1}: raise TestFailed, 'exec \'z = 1\' in g' g = {} l = {} *************** *** 381,385 **** if g.has_key('__builtins__'): del g['__builtins__'] if l.has_key('__builtins__'): del l['__builtins__'] ! if (g, l) <> ({'a':1}, {'b':2}): raise TestFailed, 'exec ... in g, l' --- 381,385 ---- if g.has_key('__builtins__'): del g['__builtins__'] if l.has_key('__builtins__'): del l['__builtins__'] ! if (g, l) != ({'a':1}, {'b':2}): raise TestFailed, 'exec ... in g, l' Index: test_math.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_math.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** test_math.py 2000/10/23 17:22:07 1.9 --- test_math.py 2000/12/12 23:11:42 1.10 *************** *** 86,90 **** print 'frexp' def testfrexp(name, (mant, exp), (emant, eexp)): ! if abs(mant-emant) > eps or exp <> eexp: raise TestFailed, '%s returned %s, expected %s'%\ (name, `mant, exp`, `emant,eexp`) --- 86,90 ---- print 'frexp' def testfrexp(name, (mant, exp), (emant, eexp)): ! if abs(mant-emant) > eps or exp != eexp: raise TestFailed, '%s returned %s, expected %s'%\ (name, `mant, exp`, `emant,eexp`) Index: test_md5.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_md5.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_md5.py 2000/10/23 17:22:07 1.3 --- test_md5.py 2000/12/12 23:11:42 1.4 *************** *** 27,30 **** m = md5('testing the hexdigest method') h = m.hexdigest() ! if hexstr(m.digest()) <> h: print 'hexdigest() failed' --- 27,30 ---- m = md5('testing the hexdigest method') h = m.hexdigest() ! if hexstr(m.digest()) != h: print 'hexdigest() failed' Index: test_mmap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mmap.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** test_mmap.py 2000/10/23 17:22:07 1.11 --- test_mmap.py 2000/12/12 23:11:42 1.12 *************** *** 47,51 **** # Test doing a regular expression match in an mmap'ed file match=re.search('[A-Za-z]+', m) ! if match == None: print ' ERROR: regex match on mmap failed!' else: --- 47,51 ---- # Test doing a regular expression match in an mmap'ed file match=re.search('[A-Za-z]+', m) ! if match is None: print ' ERROR: regex match on mmap failed!' else: Index: test_new.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_new.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** test_new.py 1998/03/26 19:42:19 1.5 --- test_new.py 2000/12/12 23:11:42 1.6 *************** *** 34,41 **** print im ! if c.get_yolks() <> 3 and c.get_more_yolks() <> 6: print 'Broken call of hand-crafted class instance' im() ! if c.get_yolks() <> 1 and c.get_more_yolks() <> 4: print 'Broken call of hand-crafted instance method' --- 34,41 ---- print im ! if c.get_yolks() != 3 and c.get_more_yolks() != 6: print 'Broken call of hand-crafted class instance' im() ! if c.get_yolks() != 1 and c.get_more_yolks() != 4: print 'Broken call of hand-crafted instance method' *************** *** 54,58 **** print func func() ! if g['c'] <> 3: print 'Could not create a proper function object' --- 54,58 ---- print func func() ! if g['c'] != 3: print 'Could not create a proper function object' Index: test_nis.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_nis.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** test_nis.py 2000/08/04 13:34:43 1.8 --- test_nis.py 2000/12/12 23:11:42 1.9 *************** *** 22,26 **** if not k: continue ! if nis.match(k, nismap) <> v: print "NIS match failed for key `%s' in map `%s'" % (k, nismap) else: --- 22,26 ---- if not k: continue ! if nis.match(k, nismap) != v: print "NIS match failed for key `%s' in map `%s'" % (k, nismap) else: Index: test_opcodes.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_opcodes.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** test_opcodes.py 2000/10/23 17:22:07 1.8 --- test_opcodes.py 2000/12/12 23:11:42 1.9 *************** *** 20,24 **** finally: pass n = n+i ! if n <> 90: raise TestFailed, 'try inside for' --- 20,24 ---- finally: pass n = n+i ! if n != 90: raise TestFailed, 'try inside for' Index: test_operator.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_operator.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_operator.py 1998/03/26 19:42:25 1.3 --- test_operator.py 2000/12/12 23:11:42 1.4 *************** *** 10,14 **** except: val = sys.exc_type ! if val <> output: print '%s%s = %s: %s expected' % (f.__name__, params, `val`, `output`) --- 10,14 ---- except: val = sys.exc_type ! if val != output: print '%s%s = %s: %s expected' % (f.__name__, params, `val`, `output`) *************** *** 22,31 **** a = [4, 3, 2, 1] test('delitem', a, None, 1) ! if a <> [4, 2, 1]: print 'delitem() failed' a = range(10) test('delslice', a, None, 2, 8) ! if a <> [0, 1, 8, 9]: print 'delslice() failed' --- 22,31 ---- a = [4, 3, 2, 1] test('delitem', a, None, 1) ! if a != [4, 2, 1]: print 'delitem() failed' a = range(10) test('delslice', a, None, 2, 8) ! if a != [0, 1, 8, 9]: print 'delslice() failed' *************** *** 60,69 **** test('setitem', a, None, 0, 2) ! if a <> [2, 1, 2]: print 'setitem() failed' a = range(4) test('setslice', a, None, 1, 3, [2, 1]) ! if a <> [0, 2, 1, 3]: print 'setslice() failed:', a --- 60,69 ---- test('setitem', a, None, 0, 2) ! if a != [2, 1, 2]: print 'setitem() failed' a = range(4) test('setslice', a, None, 1, 3, [2, 1]) ! if a != [0, 2, 1, 3]: print 'setslice() failed:', a Index: test_pow.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pow.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_pow.py 2000/10/23 17:22:07 1.6 --- test_pow.py 2000/12/12 23:11:42 1.7 *************** *** 111,119 **** n = pow(i,j,k) if o != n: print 'Integer mismatch:', i,j,k ! if j >= 0 and k <> 0: o = pow(long(i),j) % k n = pow(long(i),j,k) if o != n: print 'Long mismatch:', i,j,k ! if i >= 0 and k <> 0: o = pow(float(i),j) % k n = pow(float(i),j,k) --- 111,119 ---- n = pow(i,j,k) if o != n: print 'Integer mismatch:', i,j,k ! if j >= 0 and k != 0: o = pow(long(i),j) % k n = pow(long(i),j,k) if o != n: print 'Long mismatch:', i,j,k ! if i >= 0 and k != 0: o = pow(float(i),j) % k n = pow(float(i),j,k) Index: test_pty.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pty.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_pty.py 2000/10/23 17:22:07 1.6 --- test_pty.py 2000/12/12 23:11:42 1.7 *************** *** 82,86 **** elif status / 256 == 3: raise TestFailed, "Child spawned by pty.fork() did not have a tty as stdout" ! elif status / 256 <> 4: raise TestFailed, "pty.fork() failed for unknown reasons:" print os.read(master_fd, 65536) --- 82,86 ---- elif status / 256 == 3: raise TestFailed, "Child spawned by pty.fork() did not have a tty as stdout" ! elif status / 256 != 4: raise TestFailed, "pty.fork() failed for unknown reasons:" print os.read(master_fd, 65536) Index: test_pwd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pwd.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** test_pwd.py 2000/10/23 17:22:07 1.7 --- test_pwd.py 2000/12/12 23:11:42 1.8 *************** *** 13,21 **** print 'pwd.getpwuid()' dbuid = pwd.getpwuid(uid) ! if dbuid[0] <> name: print 'Mismatch in pwd.getpwuid()' print 'pwd.getpwnam()' dbname = pwd.getpwnam(name) ! if dbname[2] <> uid: print 'Mismatch in pwd.getpwnam()' else: --- 13,21 ---- print 'pwd.getpwuid()' dbuid = pwd.getpwuid(uid) ! if dbuid[0] != name: print 'Mismatch in pwd.getpwuid()' print 'pwd.getpwnam()' dbname = pwd.getpwnam(name) ! if dbname[2] != uid: print 'Mismatch in pwd.getpwnam()' else: Index: test_re.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_re.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** test_re.py 2000/10/23 17:22:08 1.26 --- test_re.py 2000/12/12 23:11:42 1.27 *************** *** 16,20 **** assert re.search('x+', 'axx').span(0) == (1, 3) assert re.search('x+', 'axx').span() == (1, 3) ! assert re.search('x', 'aaa') == None except: raise TestFailed, "re.search" --- 16,20 ---- assert re.search('x+', 'axx').span(0) == (1, 3) assert re.search('x+', 'axx').span() == (1, 3) ! assert re.search('x', 'aaa') is None except: raise TestFailed, "re.search" *************** *** 25,29 **** assert re.match('x*', 'xxxa').span(0) == (0, 3) assert re.match('x*', 'xxxa').span() == (0, 3) ! assert re.match('a+', 'xxx') == None except: raise TestFailed, "re.search" --- 25,29 ---- assert re.match('x*', 'xxxa').span(0) == (0, 3) assert re.match('x*', 'xxxa').span() == (0, 3) ! assert re.match('a+', 'xxx') is None except: raise TestFailed, "re.search" *************** *** 217,225 **** for i in range(0, 256): p = p + chr(i) ! assert re.match(re.escape(chr(i)), chr(i)) != None assert re.match(re.escape(chr(i)), chr(i)).span() == (0,1) pat=re.compile( re.escape(p) ) ! assert pat.match(p) != None assert pat.match(p).span() == (0,256) except AssertionError: --- 217,225 ---- for i in range(0, 256): p = p + chr(i) ! assert re.match(re.escape(chr(i)), chr(i)) is not None assert re.match(re.escape(chr(i)), chr(i)).span() == (0,1) pat=re.compile( re.escape(p) ) ! assert pat.match(p) is not None assert pat.match(p).span() == (0,256) except AssertionError: *************** *** 336,340 **** # still succeeds. result = obj.search(unicode(s, "latin-1")) ! if result == None: print '=== Fails on unicode match', t --- 336,340 ---- # still succeeds. result = obj.search(unicode(s, "latin-1")) ! if result is None: print '=== Fails on unicode match', t *************** *** 343,347 **** obj=re.compile(unicode(pattern, "latin-1")) result = obj.search(s) ! if result == None: print '=== Fails on unicode pattern match', t --- 343,347 ---- obj=re.compile(unicode(pattern, "latin-1")) result = obj.search(s) ! if result is None: print '=== Fails on unicode pattern match', t *************** *** 352,359 **** if pattern[:2] != '\\B' and pattern[-2:] != '\\B' \ ! and result != None: obj = re.compile(pattern) result = obj.search(s, result.start(0), result.end(0) + 1) ! if result == None: print '=== Failed on range-limited match', t --- 352,359 ---- if pattern[:2] != '\\B' and pattern[-2:] != '\\B' \ ! and result is not None: obj = re.compile(pattern) result = obj.search(s, result.start(0), result.end(0) + 1) ! if result is None: print '=== Failed on range-limited match', t *************** *** 362,366 **** obj = re.compile(pattern, re.IGNORECASE) result = obj.search(s) ! if result == None: print '=== Fails on case-insensitive match', t --- 362,366 ---- obj = re.compile(pattern, re.IGNORECASE) result = obj.search(s) ! if result is None: print '=== Fails on case-insensitive match', t *************** *** 369,373 **** obj = re.compile(pattern, re.LOCALE) result = obj.search(s) ! if result == None: print '=== Fails on locale-sensitive match', t --- 369,373 ---- obj = re.compile(pattern, re.LOCALE) result = obj.search(s) ! if result is None: print '=== Fails on locale-sensitive match', t *************** *** 376,379 **** obj = re.compile(pattern, re.UNICODE) result = obj.search(s) ! if result == None: print '=== Fails on unicode-sensitive match', t --- 376,379 ---- obj = re.compile(pattern, re.UNICODE) result = obj.search(s) ! if result is None: print '=== Fails on unicode-sensitive match', t Index: test_rotor.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_rotor.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** test_rotor.py 1997/08/18 13:42:28 1.4 --- test_rotor.py 2000/12/12 23:11:42 1.5 *************** *** 14,23 **** A1 = r.decrypt(a) print A1 ! if A1 <> A: print 'decrypt failed' B1 = r.decryptmore(b) print B1 ! if B1 <> B: print 'decryptmore failed' --- 14,23 ---- A1 = r.decrypt(a) print A1 ! if A1 != A: print 'decrypt failed' B1 = r.decryptmore(b) print B1 ! if B1 != B: print 'decryptmore failed' Index: test_sax.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sax.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** test_sax.py 2000/10/24 16:00:22 1.13 --- test_sax.py 2000/12/12 23:11:42 1.14 *************** *** 396,401 **** parser.close() ! return parser.getSystemId() == None and \ ! parser.getPublicId() == None and \ parser.getLineNumber() == 1 --- 396,401 ---- parser.close() ! return parser.getSystemId() is None and \ ! parser.getPublicId() is None and \ parser.getLineNumber() == 1 *************** *** 408,412 **** return parser.getSystemId() == findfile("test.xml") and \ ! parser.getPublicId() == None --- 408,412 ---- return parser.getSystemId() == findfile("test.xml") and \ ! parser.getPublicId() is None *************** *** 485,489 **** not attrs.has_key("attr") and \ attrs.keys() == [] and \ ! attrs.get("attrs") == None and \ attrs.get("attrs", 25) == 25 and \ attrs.items() == [] and \ --- 485,489 ---- not attrs.has_key("attr") and \ attrs.keys() == [] and \ ! attrs.get("attrs") is None and \ attrs.get("attrs", 25) == 25 and \ attrs.items() == [] and \ *************** *** 553,557 **** not attrs.has_key((ns_uri, "attr")) and \ attrs.keys() == [] and \ ! attrs.get((ns_uri, "attr")) == None and \ attrs.get((ns_uri, "attr"), 25) == 25 and \ attrs.items() == [] and \ --- 553,557 ---- not attrs.has_key((ns_uri, "attr")) and \ attrs.keys() == [] and \ ! attrs.get((ns_uri, "attr")) is None and \ attrs.get((ns_uri, "attr"), 25) == 25 and \ attrs.items() == [] and \ Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** test_socket.py 2000/06/29 17:00:54 1.14 --- test_socket.py 2000/12/12 23:11:42 1.15 *************** *** 138,142 **** s.send(msg) data = s.recv(1024) ! if msg <> data: print 'parent/client mismatch' s.close() --- 138,142 ---- s.send(msg) data = s.recv(1024) ! if msg != data: print 'parent/client mismatch' s.close() Index: test_sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sre.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** test_sre.py 2000/10/28 19:30:41 1.13 --- test_sre.py 2000/12/12 23:11:42 1.14 *************** *** 48,57 **** for i in [0, 8, 16, 32, 64, 127, 128, 255]: ! test(r"""sre.match(r"\%03o" % i, chr(i)) != None""", 1) ! test(r"""sre.match(r"\%03o0" % i, chr(i)+"0") != None""", 1) ! test(r"""sre.match(r"\%03o8" % i, chr(i)+"8") != None""", 1) ! test(r"""sre.match(r"\x%02x" % i, chr(i)) != None""", 1) ! test(r"""sre.match(r"\x%02x0" % i, chr(i)+"0") != None""", 1) ! test(r"""sre.match(r"\x%02xz" % i, chr(i)+"z") != None""", 1) test(r"""sre.match("\911", "")""", None, sre.error) --- 48,57 ---- for i in [0, 8, 16, 32, 64, 127, 128, 255]: ! test(r"""sre.match(r"\%03o" % i, chr(i)) is not None""", 1) ! test(r"""sre.match(r"\%03o0" % i, chr(i)+"0") is not None""", 1) ! test(r"""sre.match(r"\%03o8" % i, chr(i)+"8") is not None""", 1) ! test(r"""sre.match(r"\x%02x" % i, chr(i)) is not None""", 1) ! test(r"""sre.match(r"\x%02x0" % i, chr(i)+"0") is not None""", 1) ! test(r"""sre.match(r"\x%02xz" % i, chr(i)+"z") is not None""", 1) test(r"""sre.match("\911", "")""", None, sre.error) *************** *** 198,206 **** for i in range(0, 256): p = p + chr(i) ! test(r"""sre.match(sre.escape(chr(i)), chr(i)) != None""", 1) test(r"""sre.match(sre.escape(chr(i)), chr(i)).span()""", (0,1)) pat = sre.compile(sre.escape(p)) ! test(r"""pat.match(p) != None""", 1) test(r"""pat.match(p).span()""", (0,256)) --- 198,206 ---- for i in range(0, 256): p = p + chr(i) ! test(r"""sre.match(sre.escape(chr(i)), chr(i)) is not None""", 1) test(r"""sre.match(sre.escape(chr(i)), chr(i)).span()""", (0,1)) pat = sre.compile(sre.escape(p)) ! test(r"""pat.match(p) is not None""", 1) test(r"""pat.match(p).span()""", (0,256)) Index: test_struct.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_struct.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_struct.py 2000/10/23 17:22:08 1.6 --- test_struct.py 2000/12/12 23:11:42 1.7 *************** *** 16,20 **** sz = struct.calcsize('i') ! if sz * 3 <> struct.calcsize('iii'): raise TestFailed, 'inconsistent sizes' --- 16,20 ---- sz = struct.calcsize('i') ! if sz * 3 != struct.calcsize('iii'): raise TestFailed, 'inconsistent sizes' *************** *** 23,27 **** sz = struct.calcsize(fmt) sz3 = struct.calcsize(fmt3) ! if sz * 3 <> sz3: raise TestFailed, 'inconsistent sizes (3*%s -> 3*%d = %d, %s -> %d)' % ( `fmt`, sz, 3*sz, `fmt3`, sz3) --- 23,27 ---- sz = struct.calcsize(fmt) sz3 = struct.calcsize(fmt3) ! if sz * 3 != sz3: raise TestFailed, 'inconsistent sizes (3*%s -> 3*%d = %d, %s -> %d)' % ( `fmt`, sz, 3*sz, `fmt3`, sz3) *************** *** 50,55 **** s = struct.pack(format, c, b, h, i, l, f, d) cp, bp, hp, ip, lp, fp, dp = struct.unpack(format, s) ! if (cp <> c or bp <> b or hp <> h or ip <> i or lp <> l or ! int(100 * fp) <> int(100 * f) or int(100 * dp) <> int(100 * d)): # ^^^ calculate only to two decimal places raise TestFailed, "unpack/pack not transitive (%s, %s)" % ( --- 50,55 ---- s = struct.pack(format, c, b, h, i, l, f, d) cp, bp, hp, ip, lp, fp, dp = struct.unpack(format, s) ! if (cp != c or bp != b or hp != h or ip != i or lp != l or ! int(100 * fp) != int(100 * f) or int(100 * dp) != int(100 * d)): # ^^^ calculate only to two decimal places raise TestFailed, "unpack/pack not transitive (%s, %s)" % ( Index: test_support.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_support.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** test_support.py 2000/10/23 17:22:08 1.8 --- test_support.py 2000/12/12 23:11:42 1.9 *************** *** 53,57 **** for i in range(min(len(x), len(y))): outcome = fcmp(x[i], y[i]) ! if outcome <> 0: return outcome return cmp(len(x), len(y)) --- 53,57 ---- for i in range(min(len(x), len(y))): outcome = fcmp(x[i], y[i]) ! if outcome != 0: return outcome return cmp(len(x), len(y)) Index: test_time.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_time.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** test_time.py 1998/03/26 19:42:56 1.5 --- test_time.py 2000/12/12 23:11:42 1.6 *************** *** 5,14 **** t = time.time() time.asctime(time.gmtime(t)) ! if time.ctime(t) <> time.asctime(time.localtime(t)): ! print 'time.ctime(t) <> time.asctime(time.localtime(t))' time.daylight ! if long(time.mktime(time.localtime(t))) <> long(t): ! print 'time.mktime(time.localtime(t)) <> t' time.sleep(1.2) --- 5,14 ---- t = time.time() time.asctime(time.gmtime(t)) ! if time.ctime(t) != time.asctime(time.localtime(t)): ! print 'time.ctime(t) != time.asctime(time.localtime(t))' time.daylight ! if long(time.mktime(time.localtime(t))) != long(t): ! print 'time.mktime(time.localtime(t)) != t' time.sleep(1.2) Index: test_types.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** test_types.py 2000/12/12 22:02:59 1.18 --- test_types.py 2000/12/12 23:11:42 1.19 *************** *** 37,45 **** print '6.3 Comparisons' ! if 0 < 1 <= 1 == 1 >= 1 > 0 <> 1: pass else: raise TestFailed, 'int comparisons failed' ! if 0L < 1L <= 1L == 1L >= 1L > 0L <> 1L: pass else: raise TestFailed, 'long int comparisons failed' ! if 0.0 < 1.0 <= 1.0 == 1.0 >= 1.0 > 0.0 <> 1.0: pass else: raise TestFailed, 'float comparisons failed' if '' < 'a' <= 'a' == 'a' < 'abc' < 'abd' < 'b': pass --- 37,45 ---- print '6.3 Comparisons' ! if 0 < 1 <= 1 == 1 >= 1 > 0 != 1: pass else: raise TestFailed, 'int comparisons failed' ! if 0L < 1L <= 1L == 1L >= 1L > 0L != 1L: pass else: raise TestFailed, 'long int comparisons failed' ! if 0.0 < 1.0 <= 1.0 == 1.0 >= 1.0 > 0.0 != 1.0: pass else: raise TestFailed, 'float comparisons failed' if '' < 'a' <= 'a' == 'a' < 'abc' < 'abd' < 'b': pass *************** *** 51,57 **** print '6.4 Numeric types (mostly conversions)' ! if 0 <> 0L or 0 <> 0.0 or 0L <> 0.0: raise TestFailed, 'mixed comparisons' ! if 1 <> 1L or 1 <> 1.0 or 1L <> 1.0: raise TestFailed, 'mixed comparisons' ! if -1 <> -1L or -1 <> -1.0 or -1L <> -1.0: raise TestFailed, 'int/long/float value not equal' if int(1.9) == 1 == int(1.1) and int(-1.1) == -1 == int(-1.9): pass --- 51,57 ---- print '6.4 Numeric types (mostly conversions)' ! if 0 != 0L or 0 != 0.0 or 0L != 0.0: raise TestFailed, 'mixed comparisons' ! if 1 != 1L or 1 != 1.0 or 1L != 1.0: raise TestFailed, 'mixed comparisons' ! if -1 != -1L or -1 != -1.0 or -1L != -1.0: raise TestFailed, 'int/long/float value not equal' if int(1.9) == 1 == int(1.1) and int(-1.1) == -1 == int(-1.9): pass *************** *** 62,69 **** else: raise TestFailed, 'float() does not work properly' print '6.4.1 32-bit integers' ! if 12 + 24 <> 36: raise TestFailed, 'int op' ! if 12 + (-24) <> -12: raise TestFailed, 'int op' ! if (-12) + 24 <> 12: raise TestFailed, 'int op' ! if (-12) + (-24) <> -36: raise TestFailed, 'int op' if not 12 < 24: raise TestFailed, 'int op' if not -24 < -12: raise TestFailed, 'int op' --- 62,69 ---- else: raise TestFailed, 'float() does not work properly' print '6.4.1 32-bit integers' ! if 12 + 24 != 36: raise TestFailed, 'int op' ! if 12 + (-24) != -12: raise TestFailed, 'int op' ! if (-12) + 24 != 12: raise TestFailed, 'int op' ! if (-12) + (-24) != -36: raise TestFailed, 'int op' if not 12 < 24: raise TestFailed, 'int op' if not -24 < -12: raise TestFailed, 'int op' *************** *** 73,80 **** raise TestFailed, 'int mul commutativity' print '6.4.2 Long integers' ! if 12L + 24L <> 36L: raise TestFailed, 'long op' ! if 12L + (-24L) <> -12L: raise TestFailed, 'long op' ! if (-12L) + 24L <> 12L: raise TestFailed, 'long op' ! if (-12L) + (-24L) <> -36L: raise TestFailed, 'long op' if not 12L < 24L: raise TestFailed, 'long op' if not -24L < -12L: raise TestFailed, 'long op' --- 73,80 ---- raise TestFailed, 'int mul commutativity' print '6.4.2 Long integers' ! if 12L + 24L != 36L: raise TestFailed, 'long op' ! if 12L + (-24L) != -12L: raise TestFailed, 'long op' ! if (-12L) + 24L != 12L: raise TestFailed, 'long op' ! if (-12L) + (-24L) != -36L: raise TestFailed, 'long op' if not 12L < 24L: raise TestFailed, 'long op' if not -24L < -12L: raise TestFailed, 'long op' *************** *** 92,99 **** else:raise TestFailed, 'long op' print '6.4.3 Floating point numbers' ! if 12.0 + 24.0 <> 36.0: raise TestFailed, 'float op' ! if 12.0 + (-24.0) <> -12.0: raise TestFailed, 'float op' ! if (-12.0) + 24.0 <> 12.0: raise TestFailed, 'float op' ! if (-12.0) + (-24.0) <> -36.0: raise TestFailed, 'float op' if not 12.0 < 24.0: raise TestFailed, 'float op' if not -24.0 < -12.0: raise TestFailed, 'float op' --- 92,99 ---- else:raise TestFailed, 'long op' print '6.4.3 Floating point numbers' ! if 12.0 + 24.0 != 36.0: raise TestFailed, 'float op' ! if 12.0 + (-24.0) != -12.0: raise TestFailed, 'float op' ! if (-12.0) + 24.0 != 12.0: raise TestFailed, 'float op' ! if (-12.0) + (-24.0) != -36.0: raise TestFailed, 'float op' if not 12.0 < 24.0: raise TestFailed, 'float op' if not -24.0 < -12.0: raise TestFailed, 'float op' *************** *** 102,112 **** print '6.5.1 Strings' ! if len('') <> 0: raise TestFailed, 'len(\'\')' ! if len('a') <> 1: raise TestFailed, 'len(\'a\')' ! if len('abcdef') <> 6: raise TestFailed, 'len(\'abcdef\')' ! if 'xyz' + 'abcde' <> 'xyzabcde': raise TestFailed, 'string concatenation' ! if 'xyz'*3 <> 'xyzxyzxyz': raise TestFailed, 'string repetition *3' ! if 0*'abcde' <> '': raise TestFailed, 'string repetition 0*' ! if min('abc') <> 'a' or max('abc') <> 'c': raise TestFailed, 'min/max string' if 'a' in 'abc' and 'b' in 'abc' and 'c' in 'abc' and 'd' not in 'abc': pass else: raise TestFailed, 'in/not in string' --- 102,112 ---- print '6.5.1 Strings' ! if len('') != 0: raise TestFailed, 'len(\'\')' ! if len('a') != 1: raise TestFailed, 'len(\'a\')' ! if len('abcdef') != 6: raise TestFailed, 'len(\'abcdef\')' ! if 'xyz' + 'abcde' != 'xyzabcde': raise TestFailed, 'string concatenation' ! if 'xyz'*3 != 'xyzxyzxyz': raise TestFailed, 'string repetition *3' ! if 0*'abcde' != '': raise TestFailed, 'string repetition 0*' ! if min('abc') != 'a' or max('abc') != 'c': raise TestFailed, 'min/max string' if 'a' in 'abc' and 'b' in 'abc' and 'c' in 'abc' and 'd' not in 'abc': pass else: raise TestFailed, 'in/not in string' *************** *** 115,138 **** print '6.5.2 Tuples' ! if len(()) <> 0: raise TestFailed, 'len(())' ! if len((1,)) <> 1: raise TestFailed, 'len((1,))' ! if len((1,2,3,4,5,6)) <> 6: raise TestFailed, 'len((1,2,3,4,5,6))' ! if (1,2)+(3,4) <> (1,2,3,4): raise TestFailed, 'tuple concatenation' ! if (1,2)*3 <> (1,2,1,2,1,2): raise TestFailed, 'tuple repetition *3' ! if 0*(1,2,3) <> (): raise TestFailed, 'tuple repetition 0*' ! if min((1,2)) <> 1 or max((1,2)) <> 2: raise TestFailed, 'min/max tuple' if 0 in (0,1,2) and 1 in (0,1,2) and 2 in (0,1,2) and 3 not in (0,1,2): pass else: raise TestFailed, 'in/not in tuple' print '6.5.3 Lists' ! if len([]) <> 0: raise TestFailed, 'len([])' ! if len([1,]) <> 1: raise TestFailed, 'len([1,])' ! if len([1,2,3,4,5,6]) <> 6: raise TestFailed, 'len([1,2,3,4,5,6])' ! if [1,2]+[3,4] <> [1,2,3,4]: raise TestFailed, 'list concatenation' ! if [1,2]*3 <> [1,2,1,2,1,2]: raise TestFailed, 'list repetition *3' ! if [1,2]*3L <> [1,2,1,2,1,2]: raise TestFailed, 'list repetition *3L' ! if 0*[1,2,3] <> []: raise TestFailed, 'list repetition 0*' ! if 0L*[1,2,3] <> []: raise TestFailed, 'list repetition 0L*' ! if min([1,2]) <> 1 or max([1,2]) <> 2: raise TestFailed, 'min/max list' if 0 in [0,1,2] and 1 in [0,1,2] and 2 in [0,1,2] and 3 not in [0,1,2]: pass else: raise TestFailed, 'in/not in list' --- 115,138 ---- print '6.5.2 Tuples' ! if len(()) != 0: raise TestFailed, 'len(())' ! if len((1,)) != 1: raise TestFailed, 'len((1,))' ! if len((1,2,3,4,5,6)) != 6: raise TestFailed, 'len((1,2,3,4,5,6))' ! if (1,2)+(3,4) != (1,2,3,4): raise TestFailed, 'tuple concatenation' ! if (1,2)*3 != (1,2,1,2,1,2): raise TestFailed, 'tuple repetition *3' ! if 0*(1,2,3) != (): raise TestFailed, 'tuple repetition 0*' ! if min((1,2)) != 1 or max((1,2)) != 2: raise TestFailed, 'min/max tuple' if 0 in (0,1,2) and 1 in (0,1,2) and 2 in (0,1,2) and 3 not in (0,1,2): pass else: raise TestFailed, 'in/not in tuple' print '6.5.3 Lists' ! if len([]) != 0: raise TestFailed, 'len([])' ! if len([1,]) != 1: raise TestFailed, 'len([1,])' ! if len([1,2,3,4,5,6]) != 6: raise TestFailed, 'len([1,2,3,4,5,6])' ! if [1,2]+[3,4] != [1,2,3,4]: raise TestFailed, 'list concatenation' ! if [1,2]*3 != [1,2,1,2,1,2]: raise TestFailed, 'list repetition *3' ! if [1,2]*3L != [1,2,1,2,1,2]: raise TestFailed, 'list repetition *3L' ! if 0*[1,2,3] != []: raise TestFailed, 'list repetition 0*' ! if 0L*[1,2,3] != []: raise TestFailed, 'list repetition 0L*' ! if min([1,2]) != 1 or max([1,2]) != 2: raise TestFailed, 'min/max list' if 0 in [0,1,2] and 1 in [0,1,2] and 2 in [0,1,2] and 3 not in [0,1,2]: pass else: raise TestFailed, 'in/not in list' *************** *** 156,208 **** a[1L] = 2 a[2L] = 3 ! if a <> [1,2,3,3,4]: raise TestFailed, 'list item assignment [0L], [1L], [2L]' a[0] = 5 a[1] = 6 a[2] = 7 ! if a <> [5,6,7,3,4]: raise TestFailed, 'list item assignment [0], [1], [2]' a[-2L] = 88 a[-1L] = 99 ! if a <> [5,6,7,88,99]: raise TestFailed, 'list item assignment [-2L], [-1L]' a[-2] = 8 a[-1] = 9 ! if a <> [5,6,7,8,9]: raise TestFailed, 'list item assignment [-2], [-1]' a[:2] = [0,4] a[-3:] = [] a[1:1] = [1,2,3] ! if a <> [0,1,2,3,4]: raise TestFailed, 'list slice assignment' a[ 1L : 4L] = [7,8,9] ! if a <> [0,7,8,9,4]: raise TestFailed, 'list slice assignment using long ints' del a[1:4] ! if a <> [0,4]: raise TestFailed, 'list slice deletion' del a[0] ! if a <> [4]: raise TestFailed, 'list item deletion [0]' del a[-1] ! if a <> []: raise TestFailed, 'list item deletion [-1]' a=range(0,5) del a[1L:4L] ! if a <> [0,4]: raise TestFailed, 'list slice deletion' del a[0L] ! if a <> [4]: raise TestFailed, 'list item deletion [0]' del a[-1L] ! if a <> []: raise TestFailed, 'list item deletion [-1]' a.append(0) a.append(1) a.append(2) ! if a <> [0,1,2]: raise TestFailed, 'list append' a.insert(0, -2) a.insert(1, -1) a.insert(2,0) ! if a <> [-2,-1,0,0,1,2]: raise TestFailed, 'list insert' ! if a.count(0) <> 2: raise TestFailed, ' list count' ! if a.index(0) <> 2: raise TestFailed, 'list index' a.remove(0) ! if a <> [-2,-1,0,1,2]: raise TestFailed, 'list remove' a.reverse() ! if a <> [2,1,0,-1,-2]: raise TestFailed, 'list reverse' a.sort() ! if a <> [-2,-1,0,1,2]: raise TestFailed, 'list sort' def revcmp(a, b): return cmp(b, a) a.sort(revcmp) ! if a <> [2,1,0,-1,-2]: raise TestFailed, 'list sort with cmp func' # The following dumps core in unpatched Python 1.5: def myComparison(x,y): --- 156,208 ---- a[1L] = 2 a[2L] = 3 ! if a != [1,2,3,3,4]: raise TestFailed, 'list item assignment [0L], [1L], [2L]' a[0] = 5 a[1] = 6 a[2] = 7 ! if a != [5,6,7,3,4]: raise TestFailed, 'list item assignment [0], [1], [2]' a[-2L] = 88 a[-1L] = 99 ! if a != [5,6,7,88,99]: raise TestFailed, 'list item assignment [-2L], [-1L]' a[-2] = 8 a[-1] = 9 ! if a != [5,6,7,8,9]: raise TestFailed, 'list item assignment [-2], [-1]' a[:2] = [0,4] a[-3:] = [] a[1:1] = [1,2,3] ! if a != [0,1,2,3,4]: raise TestFailed, 'list slice assignment' a[ 1L : 4L] = [7,8,9] ! if a != [0,7,8,9,4]: raise TestFailed, 'list slice assignment using long ints' del a[1:4] ! if a != [0,4]: raise TestFailed, 'list slice deletion' del a[0] ! if a != [4]: raise TestFailed, 'list item deletion [0]' del a[-1] ! if a != []: raise TestFailed, 'list item deletion [-1]' a=range(0,5) del a[1L:4L] ! if a != [0,4]: raise TestFailed, 'list slice deletion' del a[0L] ! if a != [4]: raise TestFailed, 'list item deletion [0]' del a[-1L] ! if a != []: raise TestFailed, 'list item deletion [-1]' a.append(0) a.append(1) a.append(2) ! if a != [0,1,2]: raise TestFailed, 'list append' a.insert(0, -2) a.insert(1, -1) a.insert(2,0) ! if a != [-2,-1,0,0,1,2]: raise TestFailed, 'list insert' ! if a.count(0) != 2: raise TestFailed, ' list count' ! if a.index(0) != 2: raise TestFailed, 'list index' a.remove(0) ! if a != [-2,-1,0,1,2]: raise TestFailed, 'list remove' a.reverse() ! if a != [2,1,0,-1,-2]: raise TestFailed, 'list reverse' a.sort() ! if a != [-2,-1,0,1,2]: raise TestFailed, 'list sort' def revcmp(a, b): return cmp(b, a) a.sort(revcmp) ! if a != [2,1,0,-1,-2]: raise TestFailed, 'list sort with cmp func' # The following dumps core in unpatched Python 1.5: def myComparison(x,y): *************** *** 220,239 **** print '6.6 Mappings == Dictionaries' d = {} ! if d.keys() <> []: raise TestFailed, '{}.keys()' ! if d.has_key('a') <> 0: raise TestFailed, '{}.has_key(\'a\')' ! if len(d) <> 0: raise TestFailed, 'len({})' d = {'a': 1, 'b': 2} ! if len(d) <> 2: raise TestFailed, 'len(dict)' k = d.keys() k.sort() ! if k <> ['a', 'b']: raise TestFailed, 'dict keys()' if d.has_key('a') and d.has_key('b') and not d.has_key('c'): pass else: raise TestFailed, 'dict keys()' ! if d['a'] <> 1 or d['b'] <> 2: raise TestFailed, 'dict item' d['c'] = 3 d['a'] = 4 ! if d['c'] <> 3 or d['a'] <> 4: raise TestFailed, 'dict item assignment' del d['b'] ! if d <> {'a': 4, 'c': 3}: raise TestFailed, 'dict item deletion' d = {1:1, 2:2, 3:3} d.clear() --- 220,239 ---- print '6.6 Mappings == Dictionaries' d = {} ! if d.keys() != []: raise TestFailed, '{}.keys()' ! if d.has_key('a') != 0: raise TestFailed, '{}.has_key(\'a\')' ! if len(d) != 0: raise TestFailed, 'len({})' d = {'a': 1, 'b': 2} ! if len(d) != 2: raise TestFailed, 'len(dict)' k = d.keys() k.sort() ! if k != ['a', 'b']: raise TestFailed, 'dict keys()' if d.has_key('a') and d.has_key('b') and not d.has_key('c'): pass else: raise TestFailed, 'dict keys()' ! if d['a'] != 1 or d['b'] != 2: raise TestFailed, 'dict item' d['c'] = 3 d['a'] = 4 ! if d['c'] != 3 or d['a'] != 4: raise TestFailed, 'dict item assignment' del d['b'] ! if d != {'a': 4, 'c': 3}: raise TestFailed, 'dict item deletion' d = {1:1, 2:2, 3:3} d.clear() *************** *** 247,254 **** # dict.get() d = {} ! if d.get('c') != None: raise TestFailed, 'missing {} get, no 2nd arg' if d.get('c', 3) != 3: raise TestFailed, 'missing {} get, w/ 2nd arg' d = {'a' : 1, 'b' : 2} ! if d.get('c') != None: raise TestFailed, 'missing dict get, no 2nd arg' if d.get('c', 3) != 3: raise TestFailed, 'missing dict get, w/ 2nd arg' if d.get('a') != 1: raise TestFailed, 'present dict get, no 2nd arg' --- 247,254 ---- # dict.get() d = {} ! if d.get('c') is not None: raise TestFailed, 'missing {} get, no 2nd arg' if d.get('c', 3) != 3: raise TestFailed, 'missing {} get, w/ 2nd arg' d = {'a' : 1, 'b' : 2} ! if d.get('c') is not None: raise TestFailed, 'missing dict get, no 2nd arg' if d.get('c', 3) != 3: raise TestFailed, 'missing dict get, w/ 2nd arg' if d.get('a') != 1: raise TestFailed, 'present dict get, no 2nd arg' *************** *** 256,268 **** # dict.setdefault() d = {} ! if d.setdefault('key0') <> None: raise TestFailed, 'missing {} setdefault, no 2nd arg' ! if d.setdefault('key0') <> None: raise TestFailed, 'present {} setdefault, no 2nd arg' d.setdefault('key', []).append(3) ! if d['key'][0] <> 3: raise TestFailed, 'missing {} setdefault, w/ 2nd arg' d.setdefault('key', []).append(4) ! if len(d['key']) <> 2: raise TestFailed, 'present {} setdefault, w/ 2nd arg' # dict.popitem() --- 256,268 ---- # dict.setdefault() d = {} ! if d.setdefault('key0') is not None: raise TestFailed, 'missing {} setdefault, no 2nd arg' ! if d.setdefault('key0') is not None: raise TestFailed, 'present {} setdefault, no 2nd arg' d.setdefault('key', []).append(3) ! if d['key'][0] != 3: raise TestFailed, 'missing {} setdefault, w/ 2nd arg' d.setdefault('key', []).append(4) ! if len(d['key']) != 2: raise TestFailed, 'present {} setdefault, w/ 2nd arg' # dict.popitem() Index: test_unpack.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unpack.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** test_unpack.py 2000/10/12 14:45:58 1.4 --- test_unpack.py 2000/12/12 23:11:42 1.5 *************** *** 17,21 **** print 'unpack tuple' a, b, c = t ! if a <> 1 or b <> 2 or c <> 3: raise TestFailed --- 17,21 ---- print 'unpack tuple' a, b, c = t ! if a != 1 or b != 2 or c != 3: raise TestFailed *************** *** 24,28 **** print 'unpack list' a, b, c = l ! if a <> 4 or b <> 5 or c <> 6: raise TestFailed --- 24,28 ---- print 'unpack list' a, b, c = l ! if a != 4 or b != 5 or c != 6: raise TestFailed *************** *** 31,35 **** print 'unpack implied tuple' a, b, c = 7, 8, 9 ! if a <> 7 or b <> 8 or c <> 9: raise TestFailed --- 31,35 ---- print 'unpack implied tuple' a, b, c = 7, 8, 9 ! if a != 7 or b != 8 or c != 9: raise TestFailed *************** *** 38,42 **** print 'unpack string' a, b, c = 'one' ! if a <> 'o' or b <> 'n' or c <> 'e': raise TestFailed --- 38,42 ---- print 'unpack string' a, b, c = 'one' ! if a != 'o' or b != 'n' or c != 'e': raise TestFailed *************** *** 45,49 **** print 'unpack sequence' a, b, c = Seq() ! if a <> 0 or b <> 1 or c <> 2: raise TestFailed --- 45,49 ---- print 'unpack sequence' a, b, c = Seq() ! if a != 0 or b != 1 or c != 2: raise TestFailed *************** *** 54,61 **** sl = [100] a, = st ! if a <> 99: raise TestFailed b, = sl ! if b <> 100: raise TestFailed --- 54,61 ---- sl = [100] a, = st ! if a != 99: raise TestFailed b, = sl ! if b != 100: raise TestFailed From python-dev@python.org Tue Dec 12 23:11:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 12 Dec 2000 15:11:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-old Para.py,1.6,1.7 cmp.py,1.1,1.2 cmpcache.py,1.1,1.2 dircmp.py,1.1,1.2 fmt.py,1.5,1.6 grep.py,1.7,1.8 packmail.py,1.7,1.8 tb.py,1.7,1.8 zmod.py,1.1,1.2 Message-ID: <200012122311.PAA18731@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/lib-old In directory slayer.i.sourceforge.net:/tmp/cvs-serv18670/lib-old Modified Files: Para.py cmp.py cmpcache.py dircmp.py fmt.py grep.py packmail.py tb.py zmod.py Log Message: Update the code to better reflect recommended style: Use != instead of <> since <> is documented as "obsolescent". Use "is" and "is not" when comparing with None or type objects. Index: Para.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/Para.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** Para.py 2000/07/16 12:04:31 1.6 --- Para.py 2000/12/12 23:11:41 1.7 *************** *** 29,33 **** # (font, text, width, space, stretch, ascent, descent) def addword(self, d, font, text, space, stretch): ! if font <> None: d.setfont(font) width = d.textwidth(text) --- 29,33 ---- # (font, text, width, space, stretch, ascent, descent) def addword(self, d, font, text, space, stretch): ! if font is not None: d.setfont(font) width = d.textwidth(text) *************** *** 51,55 **** total = 0 for word in self.words: ! if type(word) <> Int: total = total + word[2] + word[3] return total --- 51,55 ---- total = 0 for word in self.words: ! if type(word) is not Int: total = total + word[2] + word[3] return total *************** *** 64,68 **** for i in range(len(self.words)): word = self.words[i] ! if type(word) == Int: continue (fo, te, wi, sp, st, as, de) = word self.words[i] = (fo, te, wi, sp, 0, as, de) --- 64,68 ---- for i in range(len(self.words)): word = self.words[i] ! if type(word) is Int: continue (fo, te, wi, sp, st, as, de) = word self.words[i] = (fo, te, wi, sp, 0, as, de) *************** *** 100,104 **** while i < n: word = words[i] ! if type(word) == Int: if word > 0 and width >= avail: break --- 100,104 ---- while i < n: word = words[i] ! if type(word) is Int: if word > 0 and width >= avail: break *************** *** 108,112 **** if width + wi > avail and width > 0 and wi > 0: break ! if fo <> None: lastfont = fo if width == 0: --- 108,112 ---- if width + wi > avail and width > 0 and wi > 0: break ! if fo is not None: lastfont = fo if width == 0: *************** *** 120,124 **** descent = max(descent, de) i = i+1 ! while i > j and type(words[i-1]) == Int and \ words[i-1] > 0: i = i-1 width = width - lsp --- 120,124 ---- descent = max(descent, de) i = i+1 ! while i > j and type(words[i-1]) is Int and \ words[i-1] > 0: i = i-1 width = width - lsp *************** *** 153,160 **** for j in range(i, i+wordcount): word = self.words[j] ! if type(word) == Int: ok = anchorfunc(self, tuple, word, \ h, v) ! if ok <> None: return ok continue fo, te, wi, sp, st, as, de = word --- 153,160 ---- for j in range(i, i+wordcount): word = self.words[j] ! if type(word) is Int: ok = anchorfunc(self, tuple, word, \ h, v) ! if ok is not None: return ok continue fo, te, wi, sp, st, as, de = word *************** *** 168,172 **** ok = wordfunc(self, tuple, word, h, v, \ h2, v2, (j==i), (j==i+wordcount-1)) ! if ok <> None: return ok h = h2 v = v2 --- 168,172 ---- ok = wordfunc(self, tuple, word, h, v, \ h2, v2, (j==i), (j==i+wordcount-1)) ! if ok is not None: return ok h = h2 v = v2 *************** *** 178,182 **** # Return the computed bottom of the text. def render(self, d, left, top, right): ! if self.width <> right-left: self.layout(right-left) self.left = left --- 178,182 ---- # Return the computed bottom of the text. def render(self, d, left, top, right): ! if self.width != right-left: self.layout(right-left) self.left = left *************** *** 194,198 **** # def _renderword(self, tuple, word, h, v, h2, v2, isfirst, islast): ! if word[0] <> None: self.d.setfont(word[0]) baseline = v + tuple[5] self.d.text((h, baseline - word[5]), word[1]) --- 194,198 ---- # def _renderword(self, tuple, word, h, v, h2, v2, isfirst, islast): ! if word[0] is not None: self.d.setfont(word[0]) baseline = v + tuple[5] self.d.text((h, baseline - word[5]), word[1]) *************** *** 230,234 **** text = '' for w in self.words: ! if type(w) <> Int: word = w[1] if w[3]: word = word + ' ' --- 230,234 ---- text = '' for w in self.words: ! if type(w) is not Int: word = w[1] if w[3]: word = word + ' ' *************** *** 255,259 **** def _whereisword(self, tuple, word, h1, v1, h2, v2, isfirst, islast): fo, te, wi, sp, st, as, de = word ! if fo <> None: self.lastfont = fo h = h1 if isfirst: h1 = 0 --- 255,259 ---- def _whereisword(self, tuple, word, h1, v1, h2, v2, isfirst, islast): fo, te, wi, sp, st, as, de = word ! if fo is not None: self.lastfont = fo h = h1 if isfirst: h1 = 0 *************** *** 262,266 **** self.charcount = self.charcount + len(te) + (sp > 0) return ! if self.lastfont <> None: self.d.setfont(self.lastfont) cc = 0 --- 262,266 ---- self.charcount = self.charcount + len(te) + (sp > 0) return ! if self.lastfont is not None: self.d.setfont(self.lastfont) cc = 0 *************** *** 296,300 **** finally: self.d = None ! if ok == None: ascent, descent = self.lines[-1][5:7] ok = self.right, self.bottom - ascent - descent, \ --- 296,300 ---- finally: self.d = None ! if ok is None: ascent, descent = self.lines[-1][5:7] ok = self.right, self.bottom - ascent - descent, \ *************** *** 304,308 **** def _screenposword(self, tuple, word, h1, v1, h2, v2, isfirst, islast): fo, te, wi, sp, st, as, de = word ! if fo <> None: self.lastfont = fo cc = len(te) + (sp > 0) if self.pos > cc: --- 304,308 ---- def _screenposword(self, tuple, word, h1, v1, h2, v2, isfirst, islast): fo, te, wi, sp, st, as, de = word ! if fo is not None: self.lastfont = fo cc = len(te) + (sp > 0) if self.pos > cc: *************** *** 325,333 **** # Undoes its own effect when called again with the same arguments def invert(self, d, pos1, pos2): ! if pos1 == None: pos1 = self.left, self.top, self.top, self.top else: pos1 = self.screenpos(d, pos1) ! if pos2 == None: pos2 = self.right, self.bottom,self.bottom,self.bottom else: --- 325,333 ---- # Undoes its own effect when called again with the same arguments def invert(self, d, pos1, pos2): ! if pos1 is None: pos1 = self.left, self.top, self.top, self.top else: pos1 = self.screenpos(d, pos1) ! if pos2 is None: pos2 = self.right, self.bottom,self.bottom,self.bottom else: Index: cmp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/cmp.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** cmp.py 2000/02/03 15:25:32 1.1 --- cmp.py 2000/12/12 23:11:41 1.2 *************** *** 17,21 **** Raise exceptions if either file could not be statted, read, etc.""" s1, s2 = sig(os.stat(f1)), sig(os.stat(f2)) ! if s1[0] <> 8 or s2[0] <> 8: # Either is a not a plain file -- always report as different return 0 --- 17,21 ---- Raise exceptions if either file could not be statted, read, etc.""" s1, s2 = sig(os.stat(f1)), sig(os.stat(f2)) ! if s1[0] != 8 or s2[0] != 8: # Either is a not a plain file -- always report as different return 0 *************** *** 23,27 **** # type, size & mtime match -- report same return 1 ! if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother # types or sizes differ -- report different return 0 --- 23,27 ---- # type, size & mtime match -- report same return 1 ! if s1[:2] != s2[:2]: # Types or sizes differ, don't bother # types or sizes differ -- report different return 0 *************** *** 60,63 **** b1 = fp1.read(bufsize) b2 = fp2.read(bufsize) ! if b1 <> b2: return 0 if not b1: return 1 --- 60,63 ---- b1 = fp1.read(bufsize) b2 = fp2.read(bufsize) ! if b1 != b2: return 0 if not b1: return 1 Index: cmpcache.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/cmpcache.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** cmpcache.py 2000/02/03 15:25:32 1.1 --- cmpcache.py 2000/12/12 23:11:41 1.2 *************** *** 31,35 **** # type, size & mtime match -- report same return 1 ! if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother # types or sizes differ -- report different return 0 --- 31,35 ---- # type, size & mtime match -- report same return 1 ! if s1[:2] != s2[:2]: # Types or sizes differ, don't bother # types or sizes differ -- report different return 0 *************** *** 61,64 **** b1 = fp1.read(bufsize) b2 = fp2.read(bufsize) ! if b1 <> b2: return 0 if not b1: return 1 --- 61,64 ---- b1 = fp1.read(bufsize) b2 = fp2.read(bufsize) ! if b1 != b2: return 0 if not b1: return 1 Index: dircmp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/dircmp.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** dircmp.py 2000/02/03 15:25:32 1.1 --- dircmp.py 2000/12/12 23:11:41 1.2 *************** *** 71,75 **** a_type = S_IFMT(a_stat[ST_MODE]) b_type = S_IFMT(b_stat[ST_MODE]) ! if a_type <> b_type: self.common_funny.append(x) elif S_ISDIR(a_type): --- 71,75 ---- a_type = S_IFMT(a_stat[ST_MODE]) b_type = S_IFMT(b_stat[ST_MODE]) ! if a_type != b_type: self.common_funny.append(x) elif S_ISDIR(a_type): *************** *** 190,194 **** import getopt options, args = getopt.getopt(sys.argv[1:], 'r') ! if len(args) <> 2: raise getopt.error, 'need exactly two args' dd = dircmp().new(args[0], args[1]) dd.run() --- 190,195 ---- import getopt options, args = getopt.getopt(sys.argv[1:], 'r') ! if len(args) != 2: ! raise getopt.error, 'need exactly two args' dd = dircmp().new(args[0], args[1]) dd.run() Index: fmt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/fmt.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** fmt.py 2000/02/27 15:34:29 1.5 --- fmt.py 2000/12/12 23:11:41 1.6 *************** *** 69,73 **** p = self.paralist[i] result = p.whereis(d, h, v) ! if result <> None: return i, result return None --- 69,73 ---- p = self.paralist[i] result = p.whereis(d, h, v) ! if result is not None: return i, result return None *************** *** 76,80 **** i, offset = long1 text = self.paralist[i].extract() ! while offset > 0 and text[offset-1] <> ' ': offset = offset-1 long1 = i, offset # --- 76,80 ---- i, offset = long1 text = self.paralist[i].extract() ! while offset > 0 and text[offset-1] != ' ': offset = offset-1 long1 = i, offset # *************** *** 82,86 **** text = self.paralist[i].extract() n = len(text) ! while offset < n-1 and text[offset] <> ' ': offset = offset+1 long2 = i, offset # --- 82,86 ---- text = self.paralist[i].extract() n = len(text) ! while offset < n-1 and text[offset] != ' ': offset = offset+1 long2 = i, offset # *************** *** 160,164 **** # def setfont(self, font): ! if font == None: return self.font = self.nextfont = font d = self.d --- 160,164 ---- # def setfont(self, font): ! if font is None: return self.font = self.nextfont = font d = self.d *************** *** 194,198 **** self.b.addpara(self.para) self.para = None ! if self.font <> None: self.d.setfont(self.font) self.nospace = 1 --- 194,198 ---- self.b.addpara(self.para) self.para = None ! if self.font is not None: self.d.setfont(self.font) self.nospace = 1 *************** *** 339,344 **** for i in range(len(para.words)): fo, te, wi = para.words[i][:3] ! if fo <> None: curfont = fo ! if curfont <> oldfont: if closechar.has_key(oldfont): c = closechar[oldfont] --- 339,344 ---- for i in range(len(para.words)): fo, te, wi = para.words[i][:3] ! if fo is not None: curfont = fo ! if curfont != oldfont: if closechar.has_key(oldfont): c = closechar[oldfont] *************** *** 431,435 **** pos2 = long2[:3] new = pos1, pos2 ! if new <> self.selection: d = self.window.begindrawing() if self.selection: --- 431,435 ---- pos2 = long2[:3] new = pos1, pos2 ! if new != self.selection: d = self.window.begindrawing() if self.selection: *************** *** 463,467 **** def search(self, prog): import re, string ! if type(prog) == type(''): prog = re.compile(string.lower(prog)) if self.selection: --- 463,467 ---- def search(self, prog): import re, string ! if type(prog) is type(''): prog = re.compile(string.lower(prog)) if self.selection: *************** *** 552,556 **** self.fontcache[key] = handle self.fontkey = fontkey ! if self.fonthandle <> handle: self.fonthandle = handle self.fontinfo = handle.getfontinfo() --- 552,556 ---- self.fontcache[key] = handle self.fontkey = fontkey ! if self.fonthandle != handle: self.fonthandle = handle self.fontinfo = handle.getfontinfo() *************** *** 583,587 **** oldhandle = self.fonthandle GLFontCache.setfont(fontkey) ! if self.fonthandle <> oldhandle: handle.setfont() --- 583,587 ---- oldhandle = self.fonthandle GLFontCache.setfont(fontkey) ! if self.fonthandle != oldhandle: handle.setfont() *************** *** 613,617 **** gl.winset(self.wid) width = gl.getsize()[1] ! if width <> self.width: setdocsize = 1 self.width = width --- 613,617 ---- gl.winset(self.wid) width = gl.getsize()[1] ! if width != self.width: setdocsize = 1 self.width = width Index: grep.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/grep.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** grep.py 1997/10/22 20:44:58 1.7 --- grep.py 2000/12/12 23:11:41 1.8 *************** *** 74,78 **** prefix = ' ' * len(prefix) for c in line: ! if c <> '\t': c = ' ' prefix = prefix + c if start == end: prefix = prefix + '\\' --- 74,78 ---- prefix = ' ' * len(prefix) for c in line: ! if c != '\t': c = ' ' prefix = prefix + c if start == end: prefix = prefix + '\\' Index: packmail.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/packmail.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** packmail.py 1998/04/28 16:03:03 1.7 --- packmail.py 2000/12/12 23:11:41 1.8 *************** *** 26,30 **** line = fp.readline() if not line: break ! if line[-1:] <> '\n': line = line + '\n' outfp.write('X' + line) --- 26,30 ---- line = fp.readline() if not line: break ! if line[-1:] != '\n': line = line + '\n' outfp.write('X' + line) Index: tb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/tb.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** tb.py 1997/09/29 23:21:47 1.7 --- tb.py 2000/12/12 23:11:41 1.8 *************** *** 24,28 **** tb = tblist[ptr] while 1: ! if tb <> tblist[ptr]: tb = tblist[ptr] print `ptr` + ':', --- 24,28 ---- tb = tblist[ptr] while 1: ! if tb != tblist[ptr]: tb = tblist[ptr] print `ptr` + ':', *************** *** 77,85 **** t, v = sys.exc_info()[:2] print '*** Exception:', ! if type(t) == type(''): print t, else: print t.__name__, ! if v <> None: print ':', v, print --- 77,85 ---- t, v = sys.exc_info()[:2] print '*** Exception:', ! if type(t) is type(''): print t, else: print t.__name__, ! if v is not None: print ':', v, print *************** *** 128,149 **** def printobject(v, maxlevel): ! if v == None: print 'None', elif type(v) in (type(0), type(0.0)): print v, ! elif type(v) == type(''): if len(v) > 20: print `v[:17] + '...'`, else: print `v`, ! elif type(v) == type(()): print '(', printlist(v, maxlevel) print ')', ! elif type(v) == type([]): print '[', printlist(v, maxlevel) print ']', ! elif type(v) == type({}): print '{', printdict(v, maxlevel) --- 128,149 ---- def printobject(v, maxlevel): ! if v is None: print 'None', elif type(v) in (type(0), type(0.0)): print v, ! elif type(v) is type(''): if len(v) > 20: print `v[:17] + '...'`, else: print `v`, ! elif type(v) is type(()): print '(', printlist(v, maxlevel) print ')', ! elif type(v) is type([]): print '[', printlist(v, maxlevel) print ']', ! elif type(v) is type({}): print '{', printdict(v, maxlevel) Index: zmod.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/zmod.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** zmod.py 1998/11/02 15:38:51 1.1 --- zmod.py 2000/12/12 23:11:41 1.2 *************** *** 83,87 **** def rj(s, width): ! if type(s) <> type(''): s = `s` n = len(s) if n >= width: return s --- 83,87 ---- def rj(s, width): ! if type(s) is not type(''): s = `s` n = len(s) if n >= width: return s *************** *** 89,93 **** def lj(s, width): ! if type(s) <> type(''): s = `s` n = len(s) if n >= width: return s --- 89,93 ---- def lj(s, width): ! if type(s) is not type(''): s = `s` n = len(s) if n >= width: return s From python-dev@python.org Tue Dec 12 23:11:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 12 Dec 2000 15:11:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-irix6 FL.py,1.1,1.2 cdplayer.py,1.3,1.4 flp.py,1.6,1.7 jpeg.py,1.3,1.4 panel.py,1.2,1.3 panelparser.py,1.1,1.2 readcd.py,1.2,1.3 torgb.py,1.2,1.3 Message-ID: <200012122311.PAA18760@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/plat-irix6 In directory slayer.i.sourceforge.net:/tmp/cvs-serv18670/plat-irix6 Modified Files: FL.py cdplayer.py flp.py jpeg.py panel.py panelparser.py readcd.py torgb.py Log Message: Update the code to better reflect recommended style: Use != instead of <> since <> is documented as "obsolescent". Use "is" and "is not" when comparing with None or type objects. Index: FL.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/FL.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** FL.py 1997/01/15 19:18:42 1.1 --- FL.py 2000/12/12 23:11:42 1.2 *************** *** 8,12 **** ##import fl ##try: ! ## _v20 = (fl.get_rgbmode <> None) ##except: ## _v20 = 0 --- 8,12 ---- ##import fl ##try: ! ## _v20 = (fl.get_rgbmode is not None) ##except: ## _v20 = 0 Index: cdplayer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/cdplayer.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** cdplayer.py 2000/07/16 11:57:20 1.3 --- cdplayer.py 2000/12/12 23:11:42 1.4 *************** *** 78,82 **** if line == '': break ! if line[:l] <> s: new.write(line) new.write(self.id + '.title:\t' + self.title + '\n') --- 78,82 ---- if line == '': break ! if line[:l] != s: new.write(line) new.write(self.id + '.title:\t' + self.title + '\n') Index: flp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/flp.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** flp.py 2000/08/18 14:59:32 1.6 --- flp.py 2000/12/12 23:11:42 1.7 *************** *** 37,41 **** def parse_forms(filename): forms = checkcache(filename) ! if forms != None: return forms fp = _open_formfile(filename) nforms = _parse_fd_header(fp) --- 37,41 ---- def parse_forms(filename): forms = checkcache(filename) ! if forms is not None: return forms fp = _open_formfile(filename) nforms = _parse_fd_header(fp) *************** *** 169,173 **** def _open_formfile2(filename): ! if filename[-3:] <> '.fd': filename = filename + '.fd' if filename[0] == '/': --- 169,173 ---- def _open_formfile2(filename): ! if filename[-3:] != '.fd': filename = filename + '.fd' if filename[0] == '/': *************** *** 185,189 **** except IOError: fp = None ! if fp == None: raise error, 'Cannot find forms file ' + filename return fp, filename --- 185,189 ---- except IOError: fp = None ! if fp is None: raise error, 'Cannot find forms file ' + filename return fp, filename *************** *** 195,199 **** # First read the magic header line datum = _parse_1_line(file) ! if datum <> ('Magic', 12321): raise error, 'Not a forms definition file' # Now skip until we know number of forms --- 195,199 ---- # First read the magic header line datum = _parse_1_line(file) ! if datum != ('Magic', 12321): raise error, 'Not a forms definition file' # Now skip until we know number of forms *************** *** 209,216 **** def _parse_fd_form(file, name): datum = _parse_1_line(file) ! if datum <> FORMLINE: raise error, 'Missing === FORM === line' form = _parse_object(file) ! if form.Name == name or name == None: objs = [] for j in range(form.Numberofobjects): --- 209,216 ---- def _parse_fd_form(file, name): datum = _parse_1_line(file) ! if datum != FORMLINE: raise error, 'Missing === FORM === line' form = _parse_object(file) ! if form.Name == name or name is None: objs = [] for j in range(form.Numberofobjects): *************** *** 317,321 **** file.seek(pos) return obj ! if type(datum) <> type(()) or len(datum) <> 2: raise error, 'Parse error, illegal line in object: '+datum obj.add(datum[0], datum[1]) --- 317,321 ---- file.seek(pos) return obj ! if type(datum) is not type(()) or len(datum) != 2: raise error, 'Parse error, illegal line in object: '+datum obj.add(datum[0], datum[1]) *************** *** 340,344 **** def merge_full_form(inst, form, (fdata, odatalist)): exec 'inst.'+fdata.Name+' = form\n' ! if odatalist[0].Class <> FL.BOX: raise error, 'merge_full_form() expects FL.BOX as first obj' for odata in odatalist[1:]: --- 340,344 ---- def merge_full_form(inst, form, (fdata, odatalist)): exec 'inst.'+fdata.Name+' = form\n' ! if odatalist[0].Class != FL.BOX: raise error, 'merge_full_form() expects FL.BOX as first obj' for odata in odatalist[1:]: Index: jpeg.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/jpeg.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** jpeg.py 2000/08/18 14:59:33 1.3 --- jpeg.py 2000/12/12 23:11:42 1.4 *************** *** 60,64 **** def setoption(name, value): ! if type(value) <> type(0): raise TypeError, 'jpeg.setoption: numeric options only' if name == 'forcegrey': --- 60,64 ---- def setoption(name, value): ! if type(value) is not type(0): raise TypeError, 'jpeg.setoption: numeric options only' if name == 'forcegrey': Index: panel.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/panel.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** panel.py 2000/06/28 14:48:01 1.2 --- panel.py 2000/12/12 23:11:42 1.3 *************** *** 208,212 **** # Sanity check # ! if (not descr) or descr[0] <> 'panel': raise panel_error, 'panel description must start with "panel"' # --- 208,212 ---- # Sanity check # ! if (not descr) or descr[0] != 'panel': raise panel_error, 'panel description must start with "panel"' # Index: panelparser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/panelparser.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** panelparser.py 1997/01/15 19:19:12 1.1 --- panelparser.py 2000/12/12 23:11:42 1.2 *************** *** 72,76 **** # def parse_expr(tokens): ! if (not tokens) or tokens[0] <> '(': raise syntax_error, 'expected "("' tokens = tokens[1:] --- 72,76 ---- # def parse_expr(tokens): ! if (not tokens) or tokens[0] != '(': raise syntax_error, 'expected "("' tokens = tokens[1:] Index: readcd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/readcd.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** readcd.py 2000/08/18 14:59:33 1.2 --- readcd.py 2000/12/12 23:11:42 1.3 *************** *** 94,98 **** raise Error, 'range error' end = self.pmsf2msf(prog, min, sec, frame) ! elif l <> 3: raise Error, 'syntax error' if type(start) == type(0): --- 94,98 ---- raise Error, 'range error' end = self.pmsf2msf(prog, min, sec, frame) ! elif l != 3: raise Error, 'syntax error' if type(start) == type(0): *************** *** 112,116 **** raise Error, 'range error' start = self.pmsf2msf(prog, min, sec, frame) ! elif l <> 3: raise Error, 'syntax error' self.list.append((start, end)) --- 112,116 ---- raise Error, 'range error' start = self.pmsf2msf(prog, min, sec, frame) ! elif l != 3: raise Error, 'syntax error' self.list.append((start, end)) *************** *** 128,135 **** start, end = self.list[self.listindex] if type(end) == type(0): ! if cb_type <> CD.PNUM: self.parser.setcallback(cb_type, func, arg) else: ! if cb_type <> CD.ATIME: self.parser.setcallback(cb_type, func, arg) --- 128,135 ---- start, end = self.list[self.listindex] if type(end) == type(0): ! if cb_type != CD.PNUM: self.parser.setcallback(cb_type, func, arg) else: ! if cb_type != CD.ATIME: self.parser.setcallback(cb_type, func, arg) *************** *** 141,148 **** start, end = self.list[self.listindex] if type(end) == type(0): ! if cb_type <> CD.PNUM: self.parser.removecallback(cb_type) else: ! if cb_type <> CD.ATIME: self.parser.removecallback(cb_type) --- 141,148 ---- start, end = self.list[self.listindex] if type(end) == type(0): ! if cb_type != CD.PNUM: self.parser.removecallback(cb_type) else: ! if cb_type != CD.ATIME: self.parser.removecallback(cb_type) Index: torgb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/torgb.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** torgb.py 2000/08/18 14:59:33 1.2 --- torgb.py 2000/12/12 23:11:42 1.3 *************** *** 61,65 **** finally: for temp in temps[:]: ! if temp <> ret: try: os.unlink(temp) --- 61,65 ---- finally: for temp in temps[:]: ! if temp != ret: try: os.unlink(temp) *************** *** 84,93 **** type(msg[0]) == type(0) and type(msg[1]) == type(''): msg = msg[1] ! if type(msg) <> type(''): msg = `msg` raise error, filename + ': ' + msg if ftype == 'rgb': return fname ! if ftype == None or not table.has_key(ftype): raise error, \ filename + ': unsupported image file type ' + `ftype` --- 84,93 ---- type(msg[0]) == type(0) and type(msg[1]) == type(''): msg = msg[1] ! if type(msg) is not type(''): msg = `msg` raise error, filename + ': ' + msg if ftype == 'rgb': return fname ! if ftype is None or not table.has_key(ftype): raise error, \ filename + ': unsupported image file type ' + `ftype` From python-dev@python.org Tue Dec 12 23:12:26 2000 From: python-dev@python.org (Barry Warsaw) Date: Tue, 12 Dec 2000 15:12:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib StringIO.py,1.12,1.13 Message-ID: <200012122312.PAA18890@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv18874 Modified Files: StringIO.py Log Message: Accept Finn Bock's patch #102208 to hardcode EINVAL to 22 when errno can't be imported. This makes StringIO.py work with Jython. Also, get rid of the string module by converting to string methods. Shorten some lines by using augmented assignment where appropriate. Index: StringIO.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/StringIO.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** StringIO.py 2000/10/12 16:45:37 1.12 --- StringIO.py 2000/12/12 23:12:23 1.13 *************** *** 30,36 **** """ ! import errno ! import string class StringIO: def __init__(self, buf = ''): --- 30,40 ---- """ ! try: ! from errno import EINVAL ! except ImportError: ! EINVAL = 22 + EMPTYSTRING = '' + class StringIO: def __init__(self, buf = ''): *************** *** 53,62 **** raise ValueError, "I/O operation on closed file" if self.buflist: ! self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] if mode == 1: ! pos = pos + self.pos elif mode == 2: ! pos = pos + self.len self.pos = max(0, pos) def tell(self): --- 57,66 ---- raise ValueError, "I/O operation on closed file" if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] if mode == 1: ! pos += self.pos elif mode == 2: ! pos += self.len self.pos = max(0, pos) def tell(self): *************** *** 68,72 **** raise ValueError, "I/O operation on closed file" if self.buflist: ! self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] if n < 0: --- 72,76 ---- raise ValueError, "I/O operation on closed file" if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] if n < 0: *************** *** 81,87 **** raise ValueError, "I/O operation on closed file" if self.buflist: ! self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] ! i = string.find(self.buf, '\n', self.pos) if i < 0: newpos = self.len --- 85,91 ---- raise ValueError, "I/O operation on closed file" if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] ! i = self.buf.find('\n', self.pos) if i < 0: newpos = self.len *************** *** 111,116 **** size = self.pos elif size < 0: ! raise IOError(errno.EINVAL, ! "Negative size not allowed") elif size < self.pos: self.pos = size --- 115,119 ---- size = self.pos elif size < 0: ! raise IOError(EINVAL, "Negative size not allowed") elif size < self.pos: self.pos = size *************** *** 126,130 **** if self.pos < self.len: if self.buflist: ! self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] self.buflist = [self.buf[:self.pos], s, self.buf[newpos:]] --- 129,133 ---- if self.pos < self.len: if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] self.buflist = [self.buf[:self.pos], s, self.buf[newpos:]] *************** *** 137,141 **** self.pos = newpos def writelines(self, list): ! self.write(string.joinfields(list, '')) def flush(self): if self.closed: --- 140,144 ---- self.pos = newpos def writelines(self, list): ! self.write(EMPTYSTRING.join(list)) def flush(self): if self.closed: *************** *** 143,147 **** def getvalue(self): if self.buflist: ! self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] return self.buf --- 146,150 ---- def getvalue(self): if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] return self.buf From python-dev@python.org Tue Dec 12 23:16:57 2000 From: python-dev@python.org (Barry Warsaw) Date: Tue, 12 Dec 2000 15:16:57 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib StringIO.py,1.13,1.14 Message-ID: <200012122316.PAA19453@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv19434 Modified Files: StringIO.py Log Message: Change the file's indentation from tabs to 4 spaces per level. Index: StringIO.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/StringIO.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** StringIO.py 2000/12/12 23:12:23 1.13 --- StringIO.py 2000/12/12 23:16:51 1.14 *************** *** 31,152 **** try: ! from errno import EINVAL except ImportError: ! EINVAL = 22 EMPTYSTRING = '' class StringIO: ! def __init__(self, buf = ''): ! self.buf = buf ! self.len = len(buf) self.buflist = [] ! self.pos = 0 ! self.closed = 0 ! self.softspace = 0 ! def close(self): ! if not self.closed: ! self.closed = 1 ! del self.buf, self.pos ! def isatty(self): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! return 0 ! def seek(self, pos, mode = 0): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) ! self.buflist = [] ! if mode == 1: ! pos += self.pos ! elif mode == 2: ! pos += self.len ! self.pos = max(0, pos) ! def tell(self): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! return self.pos ! def read(self, n = -1): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) ! self.buflist = [] ! if n < 0: ! newpos = self.len ! else: ! newpos = min(self.pos+n, self.len) ! r = self.buf[self.pos:newpos] ! self.pos = newpos ! return r ! def readline(self, length=None): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) ! self.buflist = [] ! i = self.buf.find('\n', self.pos) ! if i < 0: ! newpos = self.len ! else: ! newpos = i+1 ! if length is not None: ! if self.pos + length < newpos: ! newpos = self.pos + length ! r = self.buf[self.pos:newpos] ! self.pos = newpos ! return r ! def readlines(self, sizehint = 0): ! total = 0 ! lines = [] ! line = self.readline() ! while line: ! lines.append(line) ! total += len(line) ! if 0 < sizehint <= total: ! break ! line = self.readline() ! return lines ! def truncate(self, size=None): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if size is None: ! size = self.pos ! elif size < 0: ! raise IOError(EINVAL, "Negative size not allowed") ! elif size < self.pos: ! self.pos = size ! self.buf = self.getvalue()[:size] ! def write(self, s): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if not s: return ! if self.pos > self.len: ! self.buflist.append('\0'*(self.pos - self.len)) ! self.len = self.pos ! newpos = self.pos + len(s) ! if self.pos < self.len: ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) ! self.buflist = [] ! self.buflist = [self.buf[:self.pos], s, self.buf[newpos:]] ! self.buf = '' ! if newpos > self.len: ! self.len = newpos ! else: ! self.buflist.append(s) ! self.len = newpos ! self.pos = newpos ! def writelines(self, list): ! self.write(EMPTYSTRING.join(list)) ! def flush(self): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! def getvalue(self): ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) ! self.buflist = [] ! return self.buf --- 31,164 ---- try: ! from errno import EINVAL except ImportError: ! EINVAL = 22 EMPTYSTRING = '' class StringIO: ! def __init__(self, buf = ''): ! self.buf = buf ! self.len = len(buf) ! self.buflist = [] ! self.pos = 0 ! self.closed = 0 ! self.softspace = 0 ! ! def close(self): ! if not self.closed: ! self.closed = 1 ! del self.buf, self.pos ! ! def isatty(self): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! return 0 ! ! def seek(self, pos, mode = 0): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) ! self.buflist = [] ! if mode == 1: ! pos += self.pos ! elif mode == 2: ! pos += self.len ! self.pos = max(0, pos) ! ! def tell(self): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! return self.pos ! ! def read(self, n = -1): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) ! self.buflist = [] ! if n < 0: ! newpos = self.len ! else: ! newpos = min(self.pos+n, self.len) ! r = self.buf[self.pos:newpos] ! self.pos = newpos ! return r ! ! def readline(self, length=None): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) ! self.buflist = [] ! i = self.buf.find('\n', self.pos) ! if i < 0: ! newpos = self.len ! else: ! newpos = i+1 ! if length is not None: ! if self.pos + length < newpos: ! newpos = self.pos + length ! r = self.buf[self.pos:newpos] ! self.pos = newpos ! return r ! ! def readlines(self, sizehint = 0): ! total = 0 ! lines = [] ! line = self.readline() ! while line: ! lines.append(line) ! total += len(line) ! if 0 < sizehint <= total: ! break ! line = self.readline() ! return lines ! ! def truncate(self, size=None): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if size is None: ! size = self.pos ! elif size < 0: ! raise IOError(EINVAL, "Negative size not allowed") ! elif size < self.pos: ! self.pos = size ! self.buf = self.getvalue()[:size] ! ! def write(self, s): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if not s: return ! if self.pos > self.len: ! self.buflist.append('\0'*(self.pos - self.len)) ! self.len = self.pos ! newpos = self.pos + len(s) ! if self.pos < self.len: ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] ! self.buflist = [self.buf[:self.pos], s, self.buf[newpos:]] ! self.buf = '' ! if newpos > self.len: ! self.len = newpos ! else: ! self.buflist.append(s) ! self.len = newpos ! self.pos = newpos ! ! def writelines(self, list): ! self.write(EMPTYSTRING.join(list)) ! ! def flush(self): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! ! def getvalue(self): ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) ! self.buflist = [] ! return self.buf *************** *** 154,196 **** def test(): ! import sys ! if sys.argv[1:]: ! file = sys.argv[1] ! else: ! file = '/etc/passwd' ! lines = open(file, 'r').readlines() ! text = open(file, 'r').read() ! f = StringIO() ! for line in lines[:-2]: ! f.write(line) ! f.writelines(lines[-2:]) ! if f.getvalue() != text: ! raise RuntimeError, 'write failed' ! length = f.tell() ! print 'File length =', length ! f.seek(len(lines[0])) ! f.write(lines[1]) ! f.seek(0) ! print 'First line =', `f.readline()` ! here = f.tell() ! line = f.readline() ! print 'Second line =', `line` ! f.seek(-len(line), 1) ! line2 = f.read(len(line)) ! if line != line2: ! raise RuntimeError, 'bad result after seek back' ! f.seek(len(line2), 1) ! list = f.readlines() ! line = list[-1] ! f.seek(f.tell() - len(line)) ! line2 = f.read() ! if line != line2: ! raise RuntimeError, 'bad result after seek back from EOF' ! print 'Read', len(list), 'more lines' ! print 'File length =', f.tell() ! if f.tell() != length: ! raise RuntimeError, 'bad length' ! f.close() if __name__ == '__main__': ! test() --- 166,208 ---- def test(): ! import sys ! if sys.argv[1:]: ! file = sys.argv[1] ! else: ! file = '/etc/passwd' ! lines = open(file, 'r').readlines() ! text = open(file, 'r').read() ! f = StringIO() ! for line in lines[:-2]: ! f.write(line) ! f.writelines(lines[-2:]) ! if f.getvalue() != text: ! raise RuntimeError, 'write failed' ! length = f.tell() ! print 'File length =', length ! f.seek(len(lines[0])) ! f.write(lines[1]) ! f.seek(0) ! print 'First line =', `f.readline()` ! here = f.tell() ! line = f.readline() ! print 'Second line =', `line` ! f.seek(-len(line), 1) ! line2 = f.read(len(line)) ! if line != line2: ! raise RuntimeError, 'bad result after seek back' ! f.seek(len(line2), 1) ! list = f.readlines() ! line = list[-1] ! f.seek(f.tell() - len(line)) ! line2 = f.read() ! if line != line2: ! raise RuntimeError, 'bad result after seek back from EOF' ! print 'Read', len(list), 'more lines' ! print 'File length =', f.tell() ! if f.tell() != length: ! raise RuntimeError, 'bad length' ! f.close() if __name__ == '__main__': ! test() From python-dev@python.org Tue Dec 12 23:20:48 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 12 Dec 2000 15:20:48 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib Cookie.py,1.3,1.4 binhex.py,1.15,1.16 calendar.py,1.18,1.19 cmd.py,1.18,1.19 commands.py,1.12,1.13 dircache.py,1.6,1.7 dospath.py,1.19,1.20 filecmp.py,1.7,1.8 ftplib.py,1.45,1.46 imputil.py,1.14,1.15 linecache.py,1.5,1.6 macpath.py,1.26,1.27 macurl2path.py,1.7,1.8 mailbox.py,1.26,1.27 mailcap.py,1.5,1.6 mhlib.py,1.21,1.22 mimetools.py,1.18,1.19 multifile.py,1.11,1.12 netrc.py,1.6,1.7 nntplib.py,1.20,1.21 ntpath.py,1.31,1.32 pdb.py,1.44,1.45 pipes.py,1.5,1.6 posixpath.py,1.37,1.38 quopri.py,1.7,1.8 regsub.py,1.7,1.8 sgmllib.py,1.21,1.22 smtplib.py,1.30,1.31 sndhdr.py,1.3,1.4 statcache.py,1.7,1.8 sunaudio.py,1.5,1.6 toaiff.py,1.7,1.8 tzparse.py,1.7,1.8 uu.py,1.12,1.13 xdrlib.py,1.9,1.10 xmllib.py,1.24,1.25 Message-ID: <200012122320.PAA19916@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv19858 Modified Files: Cookie.py binhex.py calendar.py cmd.py commands.py dircache.py dospath.py filecmp.py ftplib.py imputil.py linecache.py macpath.py macurl2path.py mailbox.py mailcap.py mhlib.py mimetools.py multifile.py netrc.py nntplib.py ntpath.py pdb.py pipes.py posixpath.py quopri.py regsub.py sgmllib.py smtplib.py sndhdr.py statcache.py sunaudio.py toaiff.py tzparse.py uu.py xdrlib.py xmllib.py Log Message: Update the code to better reflect recommended style: Use != instead of <> since <> is documented as "obsolescent". Use "is" and "is not" when comparing with None or type objects. Index: Cookie.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/Cookie.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** Cookie.py 2000/08/24 14:40:35 1.3 --- Cookie.py 2000/12/12 23:20:44 1.4 *************** *** 490,494 **** # Now add any defined attributes ! if attrs == None: attrs = self._reserved_keys for K,V in self.items(): --- 490,494 ---- # Now add any defined attributes ! if attrs is None: attrs = self._reserved_keys for K,V in self.items(): Index: binhex.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/binhex.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** binhex.py 2000/08/17 05:06:49 1.15 --- binhex.py 2000/12/12 23:20:44 1.16 *************** *** 190,194 **** self.ofp = _Rlecoderengine(hqxer) self.crc = 0 ! if finfo == None: finfo = FInfo() self.dlen = dlen --- 190,194 ---- self.ofp = _Rlecoderengine(hqxer) self.crc = 0 ! if finfo is None: finfo = FInfo() self.dlen = dlen *************** *** 229,233 **** def close_data(self): ! if self.dlen <> 0: raise Error, 'Incorrect data size, diff='+`self.rlen` self._writecrc() --- 229,233 ---- def close_data(self): ! if self.dlen != 0: raise Error, 'Incorrect data size, diff='+`self.rlen` self._writecrc() *************** *** 247,251 **** if self.state != _DID_DATA: raise Error, 'Close at the wrong time' ! if self.rlen <> 0: raise Error, \ "Incorrect resource-datasize, diff="+`self.rlen` --- 247,251 ---- if self.state != _DID_DATA: raise Error, 'Close at the wrong time' ! if self.rlen != 0: raise Error, \ "Incorrect resource-datasize, diff="+`self.rlen` Index: calendar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/calendar.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** calendar.py 2000/10/09 12:42:04 1.18 --- calendar.py 2000/12/12 23:20:44 1.19 *************** *** 51,55 **** def isleap(year): """Return 1 for leap years, 0 for non-leap years.""" ! return year % 4 == 0 and (year % 100 <> 0 or year % 400 == 0) def leapdays(y1, y2): --- 51,55 ---- def isleap(year): """Return 1 for leap years, 0 for non-leap years.""" ! return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) def leapdays(y1, y2): Index: cmd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cmd.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** cmd.py 2000/07/11 13:03:55 1.18 --- cmd.py 2000/12/12 23:20:44 1.19 *************** *** 58,62 **** def cmdloop(self, intro=None): self.preloop() ! if intro != None: self.intro = intro if self.intro: --- 58,62 ---- def cmdloop(self, intro=None): self.preloop() ! if intro is not None: self.intro = intro if self.intro: Index: commands.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/commands.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** commands.py 1998/03/26 21:11:54 1.12 --- commands.py 2000/12/12 23:20:44 1.13 *************** *** 52,56 **** text = pipe.read() sts = pipe.close() ! if sts == None: sts = 0 if text[-1:] == '\n': text = text[:-1] return sts, text --- 52,56 ---- text = pipe.read() sts = pipe.close() ! if sts is None: sts = 0 if text[-1:] == '\n': text = text[:-1] return sts, text Index: dircache.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dircache.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** dircache.py 2000/02/04 15:39:29 1.6 --- dircache.py 2000/12/12 23:20:44 1.7 *************** *** 20,24 **** except os.error: return [] ! if mtime <> cached_mtime: try: list = os.listdir(path) --- 20,24 ---- except os.error: return [] ! if mtime != cached_mtime: try: list = os.listdir(path) Index: dospath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dospath.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** dospath.py 2000/09/28 16:25:20 1.19 --- dospath.py 2000/12/12 23:20:44 1.20 *************** *** 109,113 **** for item in m: for i in range(len(prefix)): ! if prefix[:i+1] <> item[:i+1]: prefix = prefix[:i] if i == 0: return '' --- 109,113 ---- for item in m: for i in range(len(prefix)): ! if prefix[:i+1] != item[:i+1]: prefix = prefix[:i] if i == 0: return '' *************** *** 211,215 **** variable expansion.)""" ! if path[:1] <> '~': return path i, n = 1, len(path) --- 211,215 ---- variable expansion.)""" ! if path[:1] != '~': return path i, n = 1, len(path) *************** *** 304,308 **** del comps[i-1:i+1] i = i - 1 ! elif comps[i] == '' and i > 0 and comps[i-1] <> '': del comps[i] elif '.' in comps[i]: --- 304,308 ---- del comps[i-1:i+1] i = i - 1 ! elif comps[i] == '' and i > 0 and comps[i-1] != '': del comps[i] elif '.' in comps[i]: Index: filecmp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/filecmp.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** filecmp.py 2000/12/03 20:48:07 1.7 --- filecmp.py 2000/12/12 23:20:44 1.8 *************** *** 200,204 **** a_type = stat.S_IFMT(a_stat[stat.ST_MODE]) b_type = stat.S_IFMT(b_stat[stat.ST_MODE]) ! if a_type <> b_type: self.common_funny.append(x) elif stat.S_ISDIR(a_type): --- 200,204 ---- a_type = stat.S_IFMT(a_stat[stat.ST_MODE]) b_type = stat.S_IFMT(b_stat[stat.ST_MODE]) ! if a_type != b_type: self.common_funny.append(x) elif stat.S_ISDIR(a_type): *************** *** 318,322 **** import getopt options, args = getopt.getopt(sys.argv[1:], 'r') ! if len(args) <> 2: raise getopt.error, 'need exactly two args' dd = dircmp(args[0], args[1]) if ('-r', '') in options: --- 318,323 ---- import getopt options, args = getopt.getopt(sys.argv[1:], 'r') ! if len(args) != 2: ! raise getopt.error, 'need exactly two args' dd = dircmp(args[0], args[1]) if ('-r', '') in options: Index: ftplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ftplib.py,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -r1.45 -r1.46 *** ftplib.py 2000/09/01 06:09:23 1.45 --- ftplib.py 2000/12/12 23:20:44 1.46 *************** *** 186,190 **** line = line + ('\n' + nextline) if nextline[:3] == code and \ ! nextline[3:4] <> '-': break return line --- 186,190 ---- line = line + ('\n' + nextline) if nextline[:3] == code and \ ! nextline[3:4] != '-': break return line *************** *** 208,212 **** """Expect a response beginning with '2'.""" resp = self.getresp() ! if resp[0] <> '2': raise error_reply, resp return resp --- 208,212 ---- """Expect a response beginning with '2'.""" resp = self.getresp() ! if resp[0] != '2': raise error_reply, resp return resp *************** *** 278,282 **** self.sendcmd("REST %s" % rest) resp = self.sendcmd(cmd) ! if resp[0] <> '1': raise error_reply, resp else: --- 278,282 ---- self.sendcmd("REST %s" % rest) resp = self.sendcmd(cmd) ! if resp[0] != '1': raise error_reply, resp else: *************** *** 285,289 **** self.sendcmd("REST %s" % rest) resp = self.sendcmd(cmd) ! if resp[0] <> '1': raise error_reply, resp conn, sockaddr = sock.accept() --- 285,289 ---- self.sendcmd("REST %s" % rest) resp = self.sendcmd(cmd) ! if resp[0] != '1': raise error_reply, resp conn, sockaddr = sock.accept() *************** *** 319,323 **** if resp[0] == '3': resp = self.sendcmd('PASS ' + passwd) if resp[0] == '3': resp = self.sendcmd('ACCT ' + acct) ! if resp[0] <> '2': raise error_reply, resp return resp --- 319,323 ---- if resp[0] == '3': resp = self.sendcmd('PASS ' + passwd) if resp[0] == '3': resp = self.sendcmd('ACCT ' + acct) ! if resp[0] != '2': raise error_reply, resp return resp *************** *** 385,389 **** buf = fp.readline() if not buf: break ! if buf[-2:] <> CRLF: if buf[-1] in CRLF: buf = buf[:-1] buf = buf + CRLF --- 385,389 ---- buf = fp.readline() if not buf: break ! if buf[-2:] != CRLF: if buf[-1] in CRLF: buf = buf[:-1] buf = buf + CRLF *************** *** 424,428 **** '''Rename a file.''' resp = self.sendcmd('RNFR ' + fromname) ! if resp[0] <> '3': raise error_reply, resp return self.voidcmd('RNTO ' + toname) --- 424,428 ---- '''Rename a file.''' resp = self.sendcmd('RNFR ' + fromname) ! if resp[0] != '3': raise error_reply, resp return self.voidcmd('RNTO ' + toname) *************** *** 509,513 **** Return ('host.addr.as.numbers', port#) tuple.''' ! if resp[:3] <> '227': raise error_reply, resp left = string.find(resp, '(') --- 509,513 ---- Return ('host.addr.as.numbers', port#) tuple.''' ! if resp[:3] != '227': raise error_reply, resp left = string.find(resp, '(') *************** *** 517,521 **** raise error_proto, resp # should contain '(h1,h2,h3,h4,p1,p2)' numbers = string.split(resp[left+1:right], ',') ! if len(numbers) <> 6: raise error_proto, resp host = string.join(numbers[:4], '.') --- 517,521 ---- raise error_proto, resp # should contain '(h1,h2,h3,h4,p1,p2)' numbers = string.split(resp[left+1:right], ',') ! if len(numbers) != 6: raise error_proto, resp host = string.join(numbers[:4], '.') *************** *** 529,535 **** Returns the directoryname in the 257 reply.''' ! if resp[:3] <> '257': raise error_reply, resp ! if resp[3:5] <> ' "': return '' # Not compliant to RFC 959, but UNIX ftpd does this dirname = '' --- 529,535 ---- Returns the directoryname in the 257 reply.''' ! if resp[:3] != '257': raise error_reply, resp ! if resp[3:5] != ' "': return '' # Not compliant to RFC 959, but UNIX ftpd does this dirname = '' *************** *** 540,544 **** i = i+1 if c == '"': ! if i >= n or resp[i] <> '"': break i = i+1 --- 540,544 ---- i = i+1 if c == '"': ! if i >= n or resp[i] != '"': break i = i+1 Index: imputil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imputil.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** imputil.py 2000/07/18 09:09:47 1.14 --- imputil.py 2000/12/12 23:20:44 1.15 *************** *** 435,439 **** if ':' not in a: a = ':' + a ! if a[-1:] <> ':': a = a + ':' return a + b --- 435,439 ---- if ':' not in a: a = ':' + a ! if a[-1:] != ':': a = a + ':' return a + b *************** *** 644,648 **** # need to change sys.* references for rexec environs # need hook for MAL's walk-me-up import strategy, or Tim's absolute strategy ! # watch out for sys.modules[...] == None # flag to force absolute imports? (speeds _determine_import_context and # checking for a relative module) --- 644,648 ---- # need to change sys.* references for rexec environs # need hook for MAL's walk-me-up import strategy, or Tim's absolute strategy ! # watch out for sys.modules[...] is None # flag to force absolute imports? (speeds _determine_import_context and # checking for a relative module) Index: linecache.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/linecache.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** linecache.py 2000/02/04 15:10:33 1.5 --- linecache.py 2000/12/12 23:20:44 1.6 *************** *** 51,55 **** del cache[filename] continue ! if size <> stat[ST_SIZE] or mtime <> stat[ST_MTIME]: del cache[filename] --- 51,55 ---- del cache[filename] continue ! if size != stat[ST_SIZE] or mtime != stat[ST_MTIME]: del cache[filename] Index: macpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/macpath.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** macpath.py 2000/09/28 16:25:20 1.26 --- macpath.py 2000/12/12 23:20:44 1.27 *************** *** 18,22 **** volume name).""" ! return ':' in s and s[0] <> ':' --- 18,22 ---- volume name).""" ! return ':' in s and s[0] != ':' *************** *** 31,35 **** if ':' not in path: path = ':' + path ! if path[-1:] <> ':': path = path + ':' path = path + t --- 31,35 ---- if ':' not in path: path = ':' + path ! if path[-1:] != ':': path = path + ':' path = path + t *************** *** 152,156 **** for item in m: for i in range(len(prefix)): ! if prefix[:i+1] <> item[:i+1]: prefix = prefix[:i] if i == 0: return '' --- 152,156 ---- for item in m: for i in range(len(prefix)): ! if prefix[:i+1] != item[:i+1]: prefix = prefix[:i] if i == 0: return '' Index: macurl2path.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/macurl2path.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** macurl2path.py 2000/02/04 15:39:29 1.7 --- macurl2path.py 2000/12/12 23:20:44 1.8 *************** *** 13,17 **** # tp = urllib.splittype(pathname)[0] ! if tp and tp <> 'file': raise RuntimeError, 'Cannot convert non-local URL to pathname' # Turn starting /// into /, an empty hostname means current host --- 13,17 ---- # tp = urllib.splittype(pathname)[0] ! if tp and tp != 'file': raise RuntimeError, 'Cannot convert non-local URL to pathname' # Turn starting /// into /, an empty hostname means current host *************** *** 30,34 **** del components[i-1:i+1] i = i-1 ! elif components[i] == '' and i > 0 and components[i-1] <> '': del components[i] else: --- 30,34 ---- del components[i-1:i+1] i = i-1 ! elif components[i] == '' and i > 0 and components[i-1] != '': del components[i] else: Index: mailbox.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mailbox.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** mailbox.py 2000/10/23 13:37:01 1.26 --- mailbox.py 2000/12/12 23:20:44 1.27 *************** *** 31,35 **** self._search_end() self.seekp = stop = self.fp.tell() ! if start <> stop: break return rfc822.Message(_Subfile(self.fp, start, stop)) --- 31,35 ---- self._search_end() self.seekp = stop = self.fp.tell() ! if start != stop: break return rfc822.Message(_Subfile(self.fp, start, stop)) Index: mailcap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mailcap.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** mailcap.py 2000/02/04 15:10:33 1.5 --- mailcap.py 2000/12/12 23:20:44 1.6 *************** *** 174,178 **** while i < n: c = field[i]; i = i+1 ! if c <> '%': if c == '\\': c = field[i:i+1]; i = i+1 --- 174,178 ---- while i < n: c = field[i]; i = i+1 ! if c != '%': if c == '\\': c = field[i:i+1]; i = i+1 *************** *** 188,192 **** elif c == '{': start = i ! while i < n and field[i] <> '}': i = i+1 name = field[start:i] --- 188,192 ---- elif c == '{': start = i ! while i < n and field[i] != '}': i = i+1 name = field[start:i] Index: mhlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mhlib.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** mhlib.py 2000/07/16 12:04:30 1.21 --- mhlib.py 2000/12/12 23:20:44 1.22 *************** *** 306,310 **** if not line: break fields = string.splitfields(line, ':') ! if len(fields) <> 2: self.error('bad sequence in %s: %s' % (fullname, string.strip(line))) --- 306,310 ---- if not line: break fields = string.splitfields(line, ':') ! if len(fields) != 2: self.error('bad sequence in %s: %s' % (fullname, string.strip(line))) Index: mimetools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mimetools.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** mimetools.py 2000/09/30 16:52:45 1.18 --- mimetools.py 2000/12/12 23:20:44 1.19 *************** *** 23,27 **** def parsetype(self): str = self.typeheader ! if str == None: str = 'text/plain' if ';' in str: --- 23,27 ---- def parsetype(self): str = self.typeheader ! if str is None: str = 'text/plain' if ';' in str: *************** *** 76,80 **** def getencoding(self): ! if self.encodingheader == None: return '7bit' return string.lower(self.encodingheader) --- 76,80 ---- def getencoding(self): ! if self.encodingheader is None: return '7bit' return string.lower(self.encodingheader) *************** *** 110,114 **** import time import random ! if _prefix == None: import socket import os --- 110,114 ---- import time import random ! if _prefix is None: import socket import os Index: multifile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/multifile.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** multifile.py 2000/08/17 05:06:49 1.11 --- multifile.py 2000/12/12 23:20:44 1.12 *************** *** 156,160 **** def is_data(self, line): ! return line[:2] <> '--' def section_divider(self, str): --- 156,160 ---- def is_data(self, line): ! return line[:2] != '--' def section_divider(self, str): Index: netrc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/netrc.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** netrc.py 2000/07/13 13:25:07 1.6 --- netrc.py 2000/12/12 23:20:44 1.7 *************** *** 18,22 **** # Look for a machine, default, or macdef top-level keyword toplevel = tt = lexer.get_token() ! if tt == '' or tt == None: break elif tt == 'machine': --- 18,22 ---- # Look for a machine, default, or macdef top-level keyword toplevel = tt = lexer.get_token() ! if not tt: break elif tt == 'machine': Index: nntplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/nntplib.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** nntplib.py 2000/07/16 12:04:30 1.20 --- nntplib.py 2000/12/12 23:20:45 1.21 *************** *** 259,263 **** resp = self.shortcmd('GROUP ' + name) ! if resp[:3] <> '211': raise NNTPReplyError(resp) words = string.split(resp) --- 259,263 ---- resp = self.shortcmd('GROUP ' + name) ! if resp[:3] != '211': raise NNTPReplyError(resp) words = string.split(resp) *************** *** 283,287 **** def statparse(self, resp): """Internal: parse the response of a STAT, NEXT or LAST command.""" ! if resp[:2] <> '22': raise NNTPReplyError(resp) words = string.split(resp) --- 283,287 ---- def statparse(self, resp): """Internal: parse the response of a STAT, NEXT or LAST command.""" ! if resp[:2] != '22': raise NNTPReplyError(resp) words = string.split(resp) *************** *** 430,434 **** resp = self.shortcmd("XPATH " + id) ! if resp[:3] <> '223': raise NNTPReplyError(resp) try: --- 430,434 ---- resp = self.shortcmd("XPATH " + id) ! if resp[:3] != '223': raise NNTPReplyError(resp) try: *************** *** 448,452 **** resp = self.shortcmd("DATE") ! if resp[:3] <> '111': raise NNTPReplyError(resp) elem = string.split(resp) --- 448,452 ---- resp = self.shortcmd("DATE") ! if resp[:3] != '111': raise NNTPReplyError(resp) elem = string.split(resp) *************** *** 468,472 **** resp = self.shortcmd('POST') # Raises error_??? if posting is not allowed ! if resp[0] <> '3': raise NNTPReplyError(resp) while 1: --- 468,472 ---- resp = self.shortcmd('POST') # Raises error_??? if posting is not allowed ! if resp[0] != '3': raise NNTPReplyError(resp) while 1: *************** *** 492,496 **** resp = self.shortcmd('IHAVE ' + id) # Raises error_??? if the server already has it ! if resp[0] <> '3': raise NNTPReplyError(resp) while 1: --- 492,496 ---- resp = self.shortcmd('IHAVE ' + id) # Raises error_??? if the server already has it ! if resp[0] != '3': raise NNTPReplyError(resp) while 1: Index: ntpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ntpath.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -r1.31 -r1.32 *** ntpath.py 2000/09/28 16:25:20 1.31 --- ntpath.py 2000/12/12 23:20:45 1.32 *************** *** 161,165 **** for item in m: for i in range(len(prefix)): ! if prefix[:i+1] <> item[:i+1]: prefix = prefix[:i] if i == 0: return '' --- 161,165 ---- for item in m: for i in range(len(prefix)): ! if prefix[:i+1] != item[:i+1]: prefix = prefix[:i] if i == 0: return '' *************** *** 284,288 **** If user or $HOME is unknown, do nothing.""" ! if path[:1] <> '~': return path i, n = 1, len(path) --- 284,288 ---- If user or $HOME is unknown, do nothing.""" ! if path[:1] != '~': return path i, n = 1, len(path) *************** *** 388,392 **** del comps[i-1:i+1] i = i - 1 ! elif comps[i] == '' and i > 0 and comps[i-1] <> '': del comps[i] else: --- 388,392 ---- del comps[i-1:i+1] i = i - 1 ! elif comps[i] == '' and i > 0 and comps[i-1] != '': del comps[i] else: Index: pdb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pdb.py,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -r1.44 -r1.45 *** pdb.py 2000/07/16 12:04:30 1.44 --- pdb.py 2000/12/12 23:20:45 1.45 *************** *** 554,558 **** else: first = self.lineno + 1 ! if last == None: last = first + 10 filename = self.curframe.f_code.co_filename --- 554,558 ---- else: first = self.lineno + 1 ! if last is None: last = first + 10 filename = self.curframe.f_code.co_filename *************** *** 896,900 **** p = Pdb() p.reset() ! while t.tb_next <> None: t = t.tb_next p.interaction(t.tb_frame, t) --- 896,901 ---- p = Pdb() p.reset() ! while t.tb_next is not None: ! t = t.tb_next p.interaction(t.tb_frame, t) Index: pipes.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pipes.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** pipes.py 2000/02/04 15:10:34 1.5 --- pipes.py 2000/12/12 23:20:45 1.6 *************** *** 111,115 **** def append(self, cmd, kind): """t.append(cmd, kind) adds a new step at the end.""" ! if type(cmd) <> type(''): raise TypeError, \ 'Template.append: cmd must be a string' --- 111,115 ---- def append(self, cmd, kind): """t.append(cmd, kind) adds a new step at the end.""" ! if type(cmd) is not type(''): raise TypeError, \ 'Template.append: cmd must be a string' *************** *** 120,124 **** raise ValueError, \ 'Template.append: SOURCE can only be prepended' ! if self.steps <> [] and self.steps[-1][1] == SINK: raise ValueError, \ 'Template.append: already ends with SINK' --- 120,124 ---- raise ValueError, \ 'Template.append: SOURCE can only be prepended' ! if self.steps and self.steps[-1][1] == SINK: raise ValueError, \ 'Template.append: already ends with SINK' *************** *** 133,137 **** def prepend(self, cmd, kind): """t.prepend(cmd, kind) adds a new step at the front.""" ! if type(cmd) <> type(''): raise TypeError, \ 'Template.prepend: cmd must be a string' --- 133,137 ---- def prepend(self, cmd, kind): """t.prepend(cmd, kind) adds a new step at the front.""" ! if type(cmd) is not type(''): raise TypeError, \ 'Template.prepend: cmd must be a string' *************** *** 142,146 **** raise ValueError, \ 'Template.prepend: SINK can only be appended' ! if self.steps <> [] and self.steps[0][1] == SOURCE: raise ValueError, \ 'Template.prepend: already begins with SOURCE' --- 142,146 ---- raise ValueError, \ 'Template.prepend: SINK can only be appended' ! if self.steps and self.steps[0][1] == SOURCE: raise ValueError, \ 'Template.prepend: already begins with SOURCE' *************** *** 166,170 **** """t.open_r(file) and t.open_w(file) implement t.open(file, 'r') and t.open(file, 'w') respectively.""" ! if self.steps == []: return open(file, 'r') if self.steps[-1][1] == SINK: --- 166,170 ---- """t.open_r(file) and t.open_w(file) implement t.open(file, 'r') and t.open(file, 'w') respectively.""" ! if not self.steps: return open(file, 'r') if self.steps[-1][1] == SINK: *************** *** 175,179 **** def open_w(self, file): ! if self.steps == []: return open(file, 'w') if self.steps[0][1] == SOURCE: --- 175,179 ---- def open_w(self, file): ! if not self.steps: return open(file, 'w') if self.steps[0][1] == SOURCE: *************** *** 204,208 **** # Make sure there is at least one step # ! if list == []: list.append(['', 'cat', '--', '']) # --- 204,208 ---- # Make sure there is at least one step # ! if not list: list.append(['', 'cat', '--', '']) # Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -r1.37 -r1.38 *** posixpath.py 2000/09/28 16:22:52 1.37 --- posixpath.py 2000/12/12 23:20:45 1.38 *************** *** 60,64 **** i = p.rfind('/') + 1 head, tail = p[:i], p[i:] ! if head and head <> '/'*len(head): while head[-1] == '/': head = head[:-1] --- 60,64 ---- i = p.rfind('/') + 1 head, tail = p[:i], p[i:] ! if head and head != '/'*len(head): while head[-1] == '/': head = head[:-1] *************** *** 121,125 **** for item in m: for i in range(len(prefix)): ! if prefix[:i+1] <> item[:i+1]: prefix = prefix[:i] if i == 0: return '' --- 121,125 ---- for item in m: for i in range(len(prefix)): ! if prefix[:i+1] != item[:i+1]: prefix = prefix[:i] if i == 0: return '' *************** *** 282,289 **** """Expand ~ and ~user constructions. If user or $HOME is unknown, do nothing.""" ! if path[:1] <> '~': return path i, n = 1, len(path) ! while i < n and path[i] <> '/': i = i + 1 if i == 1: --- 282,289 ---- """Expand ~ and ~user constructions. If user or $HOME is unknown, do nothing.""" ! if path[:1] != '~': return path i, n = 1, len(path) ! while i < n and path[i] != '/': i = i + 1 if i == 1: Index: quopri.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/quopri.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** quopri.py 2000/10/05 17:24:33 1.7 --- quopri.py 2000/12/12 23:20:45 1.8 *************** *** 70,74 **** while i < n: c = line[i] ! if c <> ESCAPE: new = new + c; i = i+1 elif i+1 == n and not partial: --- 70,74 ---- while i < n: c = line[i] ! if c != ESCAPE: new = new + c; i = i+1 elif i+1 == n and not partial: Index: regsub.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/regsub.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** regsub.py 2000/02/04 15:28:40 1.7 --- regsub.py 2000/12/12 23:20:45 1.8 *************** *** 125,129 **** def compile(pat): ! if type(pat) <> type(''): return pat # Assume it is a compiled regex key = (pat, regex.get_syntax()) --- 125,129 ---- def compile(pat): ! if type(pat) != type(''): return pat # Assume it is a compiled regex key = (pat, regex.get_syntax()) *************** *** 154,158 **** while i < len(repl): c = repl[i]; i = i+1 ! if c <> '\\' or i >= len(repl): new = new + c else: --- 154,158 ---- while i < len(repl): c = repl[i]; i = i+1 ! if c != '\\' or i >= len(repl): new = new + c else: *************** *** 183,187 **** if line[-1] == '\n': line = line[:-1] fields = split(line, delpat) ! if len(fields) <> 3: print 'Sorry, not three fields' print 'split:', `fields` --- 183,187 ---- if line[-1] == '\n': line = line[:-1] fields = split(line, delpat) ! if len(fields) != 3: print 'Sorry, not three fields' print 'split:', `fields` Index: sgmllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sgmllib.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** sgmllib.py 2000/06/29 18:50:59 1.21 --- sgmllib.py 2000/12/12 23:20:45 1.22 *************** *** 186,190 **** def parse_comment(self, i): rawdata = self.rawdata ! if rawdata[i:i+4] <> '", "LAST"] stdscr.refresh() for y in range(0, curses.LINES - 1): for x in range(0, curses.COLS): stdscr.addstr("%d" % ((y + x) % 10)) for y in range(0, 1): p1 = mkpanel(curses.COLOR_RED, curses.LINES / 2 - 2, curses.COLS / 8 + 1, 0, 0) p1.set_userptr("p1") p2 = mkpanel(curses.COLOR_GREEN, curses.LINES / 2 + 1, curses.COLS / 7, curses.LINES / 4, curses.COLS / 10) p2.set_userptr("p2") p3 = mkpanel(curses.COLOR_YELLOW, curses.LINES / 4, curses.COLS / 10, curses.LINES / 2, curses.COLS / 9) p3.set_userptr("p3") p4 = mkpanel(curses.COLOR_BLUE, curses.LINES / 2 - 2, curses.COLS / 8, curses.LINES / 2 - 2, curses.COLS / 3) p4.set_userptr("p4") p5 = mkpanel(curses.COLOR_MAGENTA, curses.LINES / 2 - 2, curses.COLS / 8, curses.LINES / 2, curses.COLS / 2 - 2) p5.set_userptr("p5") fill_panel(p1) fill_panel(p2) fill_panel(p3) fill_panel(p4) fill_panel(p5) p4.hide() p5.hide() pflush() saywhat("press any key to continue") wait_a_while() saywhat("h3 s1 s2 s4 s5;press any key to continue") p1.move(0, 0) p3.hide() p1.show() p2.show() p4.show() p5.show() pflush() wait_a_while() saywhat("s1; press any key to continue") p1.show() pflush() wait_a_while() saywhat("s2; press any key to continue") p2.show() pflush() wait_a_while() saywhat("m2; press any key to continue") p2.move(curses.LINES / 3 + 1, curses.COLS / 8) pflush() wait_a_while() saywhat("s3; press any key to continue") p3.show() pflush() wait_a_while() saywhat("m3; press any key to continue") p3.move(curses.LINES / 4 + 1, curses.COLS / 15) pflush() wait_a_while() saywhat("b3; press any key to continue") p3.bottom() pflush() wait_a_while() saywhat("s4; press any key to continue") p4.show() pflush() wait_a_while() saywhat("s5; press any key to continue") p5.show() pflush() wait_a_while() saywhat("t3; press any key to continue") p3.top() pflush() wait_a_while() saywhat("t1; press any key to continue") p1.show() pflush() wait_a_while() saywhat("t2; press any key to continue") p2.show() pflush() wait_a_while() saywhat("t3; press any key to continue") p3.show() pflush() wait_a_while() saywhat("t4; press any key to continue") p4.show() pflush() wait_a_while() for itmp in range(0, 6): w4 = p4.window() w5 = p5.window() saywhat("m4; press any key to continue") w4.move(curses.LINES / 8, 1) w4.addstr(mod[itmp]) p4.move(curses.LINES / 6, itmp * curses.COLS / 8) w5.move(curses.LINES / 6, 1) w5.addstr(mod[itmp]) pflush() wait_a_while() saywhat("m5; press any key to continue") w4.move(curses.LINES / 6, 1) w4.addstr(mod[itmp]) p5.move(curses.LINES / 3 - 1, itmp * 10 + 6) w5.move(curses.LINES / 8, 1) w5.addstr(mod[itmp]) pflush() wait_a_while() saywhat("m4; press any key to continue") p4.move(curses.LINES / 6, (itmp + 1) * curses.COLS / 8) pflush() wait_a_while() saywhat("t5; press any key to continue") p5.top() pflush() wait_a_while() saywhat("t2; press any key to continue") p2.top() pflush() wait_a_while() saywhat("t1; press any key to continue") p1.top() pflush() wait_a_while() saywhat("d2; press any key to continue") del p2 pflush() wait_a_while() saywhat("h3; press any key to continue") p3.hide() pflush() wait_a_while() saywhat("d1; press any key to continue") del p1 pflush() wait_a_while() saywhat("d4; press any key to continue") del p4 pflush() wait_a_while() saywhat("d5; press any key to continue") del p5 pflush() wait_a_while() if nap_msec == 1: break nap_msec = 100 # # one fine day there'll be the menu at this place # curses.wrapper(demo_panels) --- NEW FILE: rain.py --- #!/usr/bin/env python # # $Id: rain.py,v 1.1 2000/12/15 00:41:48 akuchling Exp $ # # somebody should probably check the randrange()s... import curses from random import randrange def next_j(j): if j == 0: j = 4 else: j -= 1 if curses.has_colors(): z = randrange(0, 3) color = curses.color_pair(z) if z: color = color | curses.A_BOLD stdscr.attrset(color) return j def main(win): # we know that the first argument from curses.wrapper() is stdscr. # Initialize it globally for convenience. global stdscr stdscr = win if curses.has_colors(): bg = curses.COLOR_BLACK curses.init_pair(1, curses.COLOR_BLUE, bg) curses.init_pair(2, curses.COLOR_CYAN, bg) curses.nl() curses.noecho() # XXX curs_set() always returns ERR # curses.curs_set(0) stdscr.timeout(0) c = curses.COLS - 4 r = curses.LINES - 4 xpos = [0] * c ypos = [0] * r for j in range(4, -1, -1): xpos[j] = randrange(0, c) + 2 ypos[j] = randrange(0, r) + 2 j = 0 while 1: x = randrange(0, c) + 2 y = randrange(0, r) + 2 stdscr.addch(y, x, ord('.')) stdscr.addch(ypos[j], xpos[j], ord('o')) j = next_j(j) stdscr.addch(ypos[j], xpos[j], ord('O')) j = next_j(j) stdscr.addch( ypos[j] - 1, xpos[j], ord('-')) stdscr.addstr(ypos[j], xpos[j] - 1, "|.|") stdscr.addch( ypos[j] + 1, xpos[j], ord('-')) j = next_j(j) stdscr.addch( ypos[j] - 2, xpos[j], ord('-')) stdscr.addstr(ypos[j] - 1, xpos[j] - 1, "/ \\") stdscr.addstr(ypos[j], xpos[j] - 2, "| O |") stdscr.addstr(ypos[j] + 1, xpos[j] - 1, "\\ /") stdscr.addch( ypos[j] + 2, xpos[j], ord('-')) j = next_j(j) stdscr.addch( ypos[j] - 2, xpos[j], ord(' ')) stdscr.addstr(ypos[j] - 1, xpos[j] - 1, " ") stdscr.addstr(ypos[j], xpos[j] - 2, " ") stdscr.addstr(ypos[j] + 1, xpos[j] - 1, " ") stdscr.addch( ypos[j] + 2, xpos[j], ord(' ')) xpos[j] = x ypos[j] = y ch = stdscr.getch() if ch == ord('q') or ch == ord('Q'): return 0 elif ch == ord('s'): stdscr.nodelay(0) elif ch == ord(' '): stdscr.nodelay(1) curses.napms(50) curses.wrapper(main) --- NEW FILE: tclock.py --- #!/usr/bin/env python # # $Id: tclock.py,v 1.1 2000/12/15 00:41:48 akuchling Exp $ # # From tclock.c, Copyright Howard Jones , September 1994. from math import * import curses, time ASPECT = 2.2 def sign(_x): if _x < 0: return -1 return 1 def A2XY(angle, radius): return int(round(ASPECT * radius * sin(angle))), int(round(radius * cos(angle))) def plot(x, y, col): stdscr.addch(y, x, col) # draw a diagonal line using Bresenham's algorithm def dline(pair, from_x, from_y, x2, y2, ch): if curses.has_colors(): stdscr.attrset(curses.color_pair(pair)) dx = x2 - from_x dy = y2 - from_y ax = abs(dx * 2) ay = abs(dy * 2) sx = sign(dx) sy = sign(dy) x = from_x y = from_y if ax > ay: d = ay - ax / 2 while 1: plot(x, y, ch) if x == x2: return if d >= 0: y += sy d -= ax x += sx d += ay else: d = ax - ay / 2 while 1: plot(x, y, ch) if y == y2: return if d >= 0: x += sx d -= ay y += sy d += ax def main(win): global stdscr stdscr = win lastbeep = -1 my_bg = curses.COLOR_BLACK stdscr.nodelay(1) stdscr.timeout(0) # curses.curs_set(0) if curses.has_colors(): curses.init_pair(1, curses.COLOR_RED, my_bg) curses.init_pair(2, curses.COLOR_MAGENTA, my_bg) curses.init_pair(3, curses.COLOR_GREEN, my_bg) cx = (curses.COLS - 1) / 2 cy = curses.LINES / 2 if cx > cy: ch = cy else: ch = cx mradius = (3 * cy) / 4 hradius = cy / 2 sradius = (2 * cy) / 3 for i in range(0, 12): sangle = (i + 1) * 2.0 * pi / 12.0 sradius = 5 * cy / 6 sdx, sdy = A2XY(sangle, sradius) stdscr.addstr(cy - sdy, cx + sdx, "%d" % (i + 1)) stdscr.addstr(0, 0, "ASCII Clock by Howard Jones , 1994") sradius = 8 while 1: curses.napms(1000) tim = time.time() t = time.localtime(tim) hours = t[3] + t[4] / 60.0 if hours > 12.0: hours -= 12.0 mangle = t[4] * 2 * pi / 60.0 mdx, mdy = A2XY(mangle, mradius) hangle = hours * 2 * pi / 12.0 hdx, hdy = A2XY(hangle, hradius) sangle = t[5] * 2 * pi / 60.0 sdx, sdy = A2XY(sangle, sradius) dline(3, cx, cy, cx + mdx, cy - mdy, ord('#')) stdscr.attrset(curses.A_REVERSE) dline(2, cx, cy, cx + hdx, cy - hdy, ord('.')) stdscr.attroff(curses.A_REVERSE) if curses.has_colors(): stdscr.attrset(curses.color_pair(1)) plot(cx + sdx, cy - sdy, ord('O')) if curses.has_colors(): stdscr.attrset(curses.color_pair(0)) stdscr.addstr(curses.LINES - 2, 0, time.ctime(tim)) stdscr.refresh() if (t[5] % 5) == 0 and t[5] != lastbeep: lastbeep = t[5] curses.beep() ch = stdscr.getch() if ch == ord('q'): return 0 plot(cx + sdx, cy - sdy, ord(' ')) dline(0, cx, cy, cx + hdx, cy - hdy, ord(' ')) dline(0, cx, cy, cx + mdx, cy - mdy, ord(' ')) curses.wrapper(main) Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/curses/README,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** README 2000/12/13 03:50:20 1.1 --- README 2000/12/15 00:41:48 1.2 *************** *** 1,3 **** ! Sample programs that use the curses package: life.py Simple game of Life --- 1,28 ---- ! This is a collection of demos and tests for the curses module. + ncurses demos + ============= + + These demos are converted from the C versions in the ncurses + distribution, and were contributed by Thomas Gellekum + I didn't strive for a `pythonic' style, but bluntly copied the + originals. I won't attempt to `beautify' the program anytime soon, but + I wouldn't mind someone else making an effort in that direction, of + course. + + ncurses.py -- currently only a panels demo + XXX this won't work until panel support is checked in + rain.py -- raindrops keep falling on my desktop + tclock.py -- ASCII clock, by Howard Jones + + Please send bugfixes and new contributions to me or, even better, + submit them to the Python Bug Tracker on SourceForge + (). + + + Other demos + =========== + life.py Simple game of Life + + From python-dev@python.org Fri Dec 15 00:44:04 2000 From: python-dev@python.org (A.M. Kuchling) Date: Thu, 14 Dec 2000 16:44:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.42,2.43 Message-ID: <200012150044.QAA01033@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv993 Modified Files: _cursesmodule.c Log Message: Wrapper for napms() function, contributed by Thomas Gellekum Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.42 retrieving revision 2.43 diff -C2 -r2.42 -r2.43 *** _cursesmodule.c 2000/11/18 17:45:59 2.42 --- _cursesmodule.c 2000/12/15 00:44:02 2.43 *************** *** 44,48 **** mcprint mvaddchnstr mvaddchstr mvchgat mvcur mvinchnstr mvinchstr mvinnstr mmvwaddchnstr mvwaddchstr mvwchgat ! mvwgetnstr mvwinchnstr mvwinchstr mvwinnstr napms newterm overlay overwrite resizeterm restartterm ripoffline scr_dump scr_init scr_restore scr_set scrl set_curterm set_term setterm --- 44,48 ---- mcprint mvaddchnstr mvaddchstr mvchgat mvcur mvinchnstr mvinchstr mvinnstr mmvwaddchnstr mvwaddchstr mvwchgat ! mvwgetnstr mvwinchnstr mvwinchstr mvwinnstr newterm overlay overwrite resizeterm restartterm ripoffline scr_dump scr_init scr_restore scr_set scrl set_curterm set_term setterm *************** *** 56,59 **** --- 56,95 ---- slk_noutrefresh slk_refresh slk_restore slk_set slk_touch + Menu extension (ncurses and probably SYSV): + current_item free_item free_menu item_count item_description + item_index item_init item_name item_opts item_opts_off + item_opts_on item_term item_userptr item_value item_visible + menu_back menu_driver menu_fore menu_format menu_grey + menu_init menu_items menu_mark menu_opts menu_opts_off + menu_opts_on menu_pad menu_pattern menu_request_by_name + menu_request_name menu_spacing menu_sub menu_term menu_userptr + menu_win new_item new_menu pos_menu_cursor post_menu + scale_menu set_current_item set_item_init set_item_opts + set_item_term set_item_userptr set_item_value set_menu_back + set_menu_fore set_menu_format set_menu_grey set_menu_init + set_menu_items set_menu_mark set_menu_opts set_menu_pad + set_menu_pattern set_menu_spacing set_menu_sub set_menu_term + set_menu_userptr set_menu_win set_top_row top_row unpost_menu + + Form extension (ncurses and probably SYSV): + current_field data_ahead data_behind dup_field + dynamic_fieldinfo field_arg field_back field_buffer + field_count field_fore field_index field_info field_init + field_just field_opts field_opts_off field_opts_on field_pad + field_status field_term field_type field_userptr form_driver + form_fields form_init form_opts form_opts_off form_opts_on + form_page form_request_by_name form_request_name form_sub + form_term form_userptr form_win free_field free_form + link_field link_fieldtype move_field new_field new_form + new_page pos_form_cursor post_form scale_form + set_current_field set_field_back set_field_buffer + set_field_fore set_field_init set_field_just set_field_opts + set_field_pad set_field_status set_field_term set_field_type + set_field_userptr set_fieldtype_arg set_fieldtype_choice + set_form_fields set_form_init set_form_opts set_form_page + set_form_sub set_form_term set_form_userptr set_form_win + set_max_field set_new_page unpost_form + + */ *************** *** 1934,1937 **** --- 1970,1985 ---- static PyObject * + PyCurses_Napms(PyObject *self, PyObject *args) + { + int ms; + + PyCursesInitialised + if (!PyArg_Parse(args, "i;ms", &ms)) return NULL; + + return Py_BuildValue("i", napms(ms)); + } + + + static PyObject * PyCurses_NewPad(PyObject *self, PyObject *args) { *************** *** 2333,2336 **** --- 2381,2385 ---- {"mousemask", (PyCFunction)PyCurses_MouseMask}, #endif + {"napms", (PyCFunction)PyCurses_Napms}, {"newpad", (PyCFunction)PyCurses_NewPad}, {"newwin", (PyCFunction)PyCurses_NewWindow}, From python-dev@python.org Fri Dec 15 00:59:34 2000 From: python-dev@python.org (A.M. Kuchling) Date: Thu, 14 Dec 2000 16:59:34 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules bsddbmodule.c,1.25,1.26 Message-ID: <200012150059.QAA02005@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv1941 Modified Files: bsddbmodule.c Log Message: [Patch #102827] Fix for PR#119558, avoiding core dumps by checking for malloc() returning NULL Index: bsddbmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/bsddbmodule.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** bsddbmodule.c 2000/09/01 23:29:26 1.25 --- bsddbmodule.c 2000/12/15 00:59:32 1.26 *************** *** 267,273 **** if (drec.size > sizeof(buf)) data = malloc(drec.size); else data = buf; ! memcpy(data,drec.data,drec.size); } BSDDB_END_SAVE(dp) if (status != 0) { if (status < 0) --- 267,274 ---- if (drec.size > sizeof(buf)) data = malloc(drec.size); else data = buf; ! if (data!=NULL) memcpy(data,drec.data,drec.size); } BSDDB_END_SAVE(dp) + if (data==NULL) return PyErr_NoMemory(); if (status != 0) { if (status < 0) *************** *** 388,394 **** if (krec.size > sizeof(buf)) data = malloc(krec.size); else data = buf; ! memcpy(data,krec.data,krec.size); } BSDDB_END_SAVE(dp) while (status == 0) { item = PyString_FromStringAndSize(data, (int)krec.size); --- 389,396 ---- if (krec.size > sizeof(buf)) data = malloc(krec.size); else data = buf; ! if (data!=NULL) memcpy(data,krec.data,krec.size); } BSDDB_END_SAVE(dp) + if (data==NULL) return PyErr_NoMemory(); while (status == 0) { item = PyString_FromStringAndSize(data, (int)krec.size); *************** *** 409,415 **** if (krec.size > sizeof(buf)) data = malloc(krec.size); else data = buf; ! memcpy(data,krec.data,krec.size); } BSDDB_END_SAVE(dp) } if (status < 0) { --- 411,418 ---- if (krec.size > sizeof(buf)) data = malloc(krec.size); else data = buf; ! if (data!=NULL) memcpy(data,krec.data,krec.size); } BSDDB_END_SAVE(dp) + if (data==NULL) return PyErr_NoMemory(); } if (status < 0) { *************** *** 468,474 **** if (drec.size > sizeof(buf)) data = malloc(drec.size); else data = buf; ! memcpy(data,drec.data,drec.size); } BSDDB_END_SAVE(dp) if (status != 0) { if (status < 0) --- 471,478 ---- if (drec.size > sizeof(buf)) data = malloc(drec.size); else data = buf; ! if (data!=NULL) memcpy(data,drec.data,drec.size); } BSDDB_END_SAVE(dp) + if (data==NULL) return PyErr_NoMemory(); if (status != 0) { if (status < 0) *************** *** 506,516 **** if (krec.size > sizeof(kbuf)) kdata = malloc(krec.size); else kdata = kbuf; ! memcpy(kdata,krec.data,krec.size); if (drec.size > sizeof(dbuf)) ddata = malloc(drec.size); else ddata = dbuf; ! memcpy(ddata,drec.data,drec.size); } BSDDB_END_SAVE(dp) ! if (status != 0) { if (status < 0) PyErr_SetFromErrno(BsddbError); --- 510,525 ---- if (krec.size > sizeof(kbuf)) kdata = malloc(krec.size); else kdata = kbuf; ! if (kdata!=NULL) memcpy(kdata,krec.data,krec.size); if (drec.size > sizeof(dbuf)) ddata = malloc(drec.size); else ddata = dbuf; ! if (ddata!=NULL) memcpy(ddata,drec.data,drec.size); } BSDDB_END_SAVE(dp) ! if (status == 0) { ! if ((kdata==NULL) || (ddata==NULL)) ! return PyErr_NoMemory(); ! } ! else { ! /* (status != 0) */ if (status < 0) PyErr_SetFromErrno(BsddbError); From python-dev@python.org Fri Dec 15 01:03:25 2000 From: python-dev@python.org (A.M. Kuchling) Date: Thu, 14 Dec 2000 17:03:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcurses.tex,1.23,1.24 Message-ID: <200012150103.RAA02258@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv2234 Modified Files: libcurses.tex Log Message: Document napms() Add reference to demo directory Index: libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** libcurses.tex 2000/12/01 15:25:23 1.23 --- libcurses.tex 2000/12/15 01:03:23 1.24 *************** *** 34,37 **** --- 34,38 ---- with Python, by Andrew Kuchling, is available on the Python Web site.} + \seetitle[Demo/curses]{}{Some example programs.} \end{seealso} *************** *** 309,312 **** --- 310,317 ---- event mask. If this function is never called, no mouse events are ever reported. + \end{funcdesc} + + \begin{funcdesc}{napms}{ms} + Sleep for \var{ms} milliseconds. \end{funcdesc} From python-dev@python.org Fri Dec 15 01:16:47 2000 From: python-dev@python.org (A.M. Kuchling) Date: Thu, 14 Dec 2000 17:16:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.85,1.86 Message-ID: <200012150116.RAA03058@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv3041 Modified Files: NEWS Log Message: Fix typo Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -r1.85 -r1.86 *** NEWS 2000/12/12 22:10:31 1.85 --- NEWS 2000/12/15 01:16:43 1.86 *************** *** 475,479 **** it works when argv[0] is a relative path. ! - Added a true tnicode_internal_encode() function and fixed the unicode_internal_decode function() to support Unicode objects directly rather than by generating a copy of the object. --- 475,479 ---- it works when argv[0] is a relative path. ! - Added a true unicode_internal_encode() function and fixed the unicode_internal_decode function() to support Unicode objects directly rather than by generating a copy of the object. From python-dev@python.org Fri Dec 15 05:41:52 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 14 Dec 2000 21:41:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib liboperator.tex,1.18,1.19 Message-ID: <200012150541.VAA12810@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv12800/lib Modified Files: liboperator.tex Log Message: Grant Griffin : Clarify that invert() is a *bitwise* operation. Index: liboperator.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liboperator.tex,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** liboperator.tex 2000/10/22 03:19:30 1.18 --- liboperator.tex 2000/12/15 05:41:49 1.19 *************** *** 59,64 **** \funcline{__inv__}{o} \funcline{__invert__}{o} ! Return the inverse of \var{o}. The names \function{invert()} and ! \function{__invert__()} were added in Python 2.0. \end{funcdesc} --- 59,65 ---- \funcline{__inv__}{o} \funcline{__invert__}{o} ! Return the bitwise inverse of the number \var{o}. The names ! \function{invert()} and \function{__invert__()} were added in Python ! 2.0. \end{funcdesc} From python-dev@python.org Fri Dec 15 13:07:49 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 15 Dec 2000 05:07:49 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.95,2.96 unicodeobject.c,2.67,2.68 Message-ID: <200012151307.FAA10566@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv10322 Modified Files: stringobject.c unicodeobject.c Log Message: [ Patch #102852 ] Make % error a bit more informative by indicates the index at which an unknown %-escape was found Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.95 retrieving revision 2.96 diff -C2 -r2.95 -r2.96 *** stringobject.c 2000/12/06 14:27:49 2.95 --- stringobject.c 2000/12/15 13:07:46 2.96 *************** *** 2940,2945 **** default: PyErr_Format(PyExc_ValueError, ! "unsupported format character '%c' (0x%x)", ! c, c); goto error; } --- 2940,2946 ---- default: PyErr_Format(PyExc_ValueError, ! "unsupported format character '%c' (0x%x) " ! "at index %i", ! c, c, fmt - 1 - PyString_AsString(format)); goto error; } Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.67 retrieving revision 2.68 diff -C2 -r2.67 -r2.68 *** unicodeobject.c 2000/11/30 05:22:44 2.67 --- unicodeobject.c 2000/12/15 13:07:46 2.68 *************** *** 5068,5073 **** default: PyErr_Format(PyExc_ValueError, ! "unsupported format character '%c' (0x%x)", ! c, c); goto onError; } --- 5068,5074 ---- default: PyErr_Format(PyExc_ValueError, ! "unsupported format character '%c' (0x%x) " ! "at index %i", ! c, c, fmt -1 - PyUnicode_AS_UNICODE(uformat)); goto onError; } From python-dev@python.org Fri Dec 15 13:09:09 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 15 Dec 2000 05:09:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_format.py,1.3,1.4 Message-ID: <200012151309.FAA10690@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv10608 Modified Files: test_format.py Log Message: Add test case for error message raised by bad % format character (Oh, look, it adds another little utility function for testing) Index: test_format.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_format.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_format.py 2000/11/30 05:22:41 1.3 --- test_format.py 2000/12/15 13:09:06 1.4 *************** *** 175,176 **** --- 175,201 ---- testboth("%o", 042L, "42") testboth("%o", -042L, "-42") + + # Test exception for unknown format characters + if verbose: + print 'Testing exceptions' + + def test_exc(formatstr, args, exception, excmsg): + try: + testformat(formatstr, args) + except exception, exc: + if str(exc) == excmsg: + if verbose: + print "yes" + else: + if verbose: print 'no' + print 'Unexpected ', exception, ':', repr(str(exc)) + except: + if verbose: print 'no' + print 'Unexpected exception' + raise + + test_exc('abc %a', 1, ValueError, + "unsupported format character 'a' (0x61) at index 5") + test_exc(u'abc %\u3000', 1, ValueError, + "unsupported format character '\000' (0x3000) at index 5") + From python-dev@python.org Fri Dec 15 15:01:40 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 15 Dec 2000 07:01:40 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib urllib.py,1.108,1.109 Message-ID: <200012151501.HAA17427@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv17415 Modified Files: urllib.py Log Message: Get rid of string functions, except maketrans() (which is *not* obsolete!). Fix a bug in ftpwrapper.retrfile() where somehow ftplib.error_perm was assumed to be a string. (The fix applies str().) Also break some long lines and change the output from test() slightly. Index: urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.108 retrieving revision 1.109 diff -C2 -r1.108 -r1.109 *** urllib.py 2000/12/03 18:30:10 1.108 --- urllib.py 2000/12/15 15:01:37 1.109 *************** *** 29,33 **** import types ! __version__ = '1.14' # XXX This version is not always updated :-( MAXFTPCACHE = 10 # Trim the ftp cache beyond this size --- 29,33 ---- import types ! __version__ = '1.15' # XXX This version is not always updated :-( MAXFTPCACHE = 10 # Trim the ftp cache beyond this size *************** *** 156,160 **** if '-' in name: # replace - with _ ! name = string.join(string.split(name, '-'), '_') if not hasattr(self, name): if proxy: --- 156,160 ---- if '-' in name: # replace - with _ ! name = '_'.join(name.split('-')) if not hasattr(self, name): if proxy: *************** *** 250,254 **** url = rest user_passwd = None ! if string.lower(urltype) != 'http': realhost = None else: --- 250,254 ---- url = rest user_passwd = None ! if urltype.lower() != 'http': realhost = None else: *************** *** 262,266 **** if user_passwd: import base64 ! auth = string.strip(base64.encodestring(user_passwd)) else: auth = None --- 262,266 ---- if user_passwd: import base64 ! auth = base64.encodestring(user_passwd).strip() else: auth = None *************** *** 325,329 **** url = rest user_passwd = None ! if string.lower(urltype) != 'https': realhost = None else: --- 325,329 ---- url = rest user_passwd = None ! if urltype.lower() != 'https': realhost = None else: *************** *** 337,341 **** if user_passwd: import base64 ! auth = string.strip(base64.encodestring(user_passwd)) else: auth = None --- 337,341 ---- if user_passwd: import base64 ! auth = base64.encodestring(user_passwd).strip() else: auth = None *************** *** 364,368 **** return self.http_error(url, fp, errcode, errmsg, headers) else: ! return self.http_error(url, fp, errcode, errmsg, headers, data) def open_gopher(self, url): --- 364,369 ---- return self.http_error(url, fp, errcode, errmsg, headers) else: ! return self.http_error(url, fp, errcode, errmsg, headers, ! data) def open_gopher(self, url): *************** *** 431,439 **** path, attrs = splitattr(path) path = unquote(path) ! dirs = string.splitfields(path, '/') dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] if dirs and not dirs[0]: dirs[0] = '/' ! key = user, host, port, string.join(dirs, '/') # XXX thread unsafe! if len(self.ftpcache) > MAXFTPCACHE: --- 432,440 ---- path, attrs = splitattr(path) path = unquote(path) ! dirs = path.split('/') dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] if dirs and not dirs[0]: dirs[0] = '/' ! key = user, host, port, '/'.join(dirs) # XXX thread unsafe! if len(self.ftpcache) > MAXFTPCACHE: *************** *** 452,458 **** for attr in attrs: attr, value = splitvalue(attr) ! if string.lower(attr) == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): ! type = string.upper(value) (fp, retrlen) = self.ftpcache[key].retrfile(file, type) if retrlen is not None and retrlen >= 0: --- 453,459 ---- for attr in attrs: attr, value = splitvalue(attr) ! if attr.lower() == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): ! type = value.upper() (fp, retrlen) = self.ftpcache[key].retrfile(file, type) if retrlen is not None and retrlen >= 0: *************** *** 477,486 **** import StringIO, mimetools, time try: ! [type, data] = string.split(url, ',', 1) except ValueError: raise IOError, ('data error', 'bad data URL') if not type: type = 'text/plain;charset=US-ASCII' ! semi = string.rfind(type, ';') if semi >= 0 and '=' not in type[semi:]: encoding = type[semi+1:] --- 478,487 ---- import StringIO, mimetools, time try: ! [type, data] = url.split(',', 1) except ValueError: raise IOError, ('data error', 'bad data URL') if not type: type = 'text/plain;charset=US-ASCII' ! semi = type.rfind(';') if semi >= 0 and '=' not in type[semi:]: encoding = type[semi+1:] *************** *** 500,504 **** msg.append('') msg.append(data) ! msg = string.join(msg, '\n') f = StringIO.StringIO(msg) headers = mimetools.Message(f, 0) --- 501,505 ---- msg.append('') msg.append(data) ! msg = '\n'.join(msg) f = StringIO.StringIO(msg) headers = mimetools.Message(f, 0) *************** *** 550,554 **** if match: scheme, realm = match.groups() ! if string.lower(scheme) == 'basic': name = 'retry_' + self.type + '_basic_auth' if data is None: --- 551,555 ---- if match: scheme, realm = match.groups() ! if scheme.lower() == 'basic': name = 'retry_' + self.type + '_basic_auth' if data is None: *************** *** 559,563 **** def retry_http_basic_auth(self, url, realm, data=None): host, selector = splithost(url) ! i = string.find(host, '@') + 1 host = host[i:] user, passwd = self.get_user_passwd(host, realm, i) --- 560,564 ---- def retry_http_basic_auth(self, url, realm, data=None): host, selector = splithost(url) ! i = host.find('@') + 1 host = host[i:] user, passwd = self.get_user_passwd(host, realm, i) *************** *** 572,576 **** def retry_https_basic_auth(self, url, realm, data=None): host, selector = splithost(url) ! i = string.find(host, '@') + 1 host = host[i:] user, passwd = self.get_user_passwd(host, realm, i) --- 573,577 ---- def retry_https_basic_auth(self, url, realm, data=None): host, selector = splithost(url) ! i = host.find('@') + 1 host = host[i:] user, passwd = self.get_user_passwd(host, realm, i) *************** *** 581,585 **** def get_user_passwd(self, host, realm, clear_cache = 0): ! key = realm + '@' + string.lower(host) if self.auth_cache.has_key(key): if clear_cache: --- 582,586 ---- def get_user_passwd(self, host, realm, clear_cache = 0): ! key = realm + '@' + host.lower() if self.auth_cache.has_key(key): if clear_cache: *************** *** 690,694 **** conn = self.ftp.ntransfercmd(cmd) except ftplib.error_perm, reason: ! if reason[:3] != '550': raise IOError, ('ftp error', reason), sys.exc_info()[2] if not conn: --- 691,695 ---- conn = self.ftp.ntransfercmd(cmd) except ftplib.error_perm, reason: ! if str(reason)[:3] != '550': raise IOError, ('ftp error', reason), sys.exc_info()[2] if not conn: *************** *** 806,810 **** else: # else replace last component ! i = string.rfind(basepath, '/') if i < 0: # basepath not absolute --- 807,811 ---- else: # else replace last component ! i = basepath.rfind('/') if i < 0: # basepath not absolute *************** *** 821,825 **** while basepath and path[:3] == '../': path = path[3:] ! i = string.rfind(basepath[:-1], '/') if i > 0: basepath = basepath[:i+1] --- 822,826 ---- while basepath and path[:3] == '../': path = path[3:] ! i = basepath[:-1].rfind('/') if i > 0: basepath = basepath[:i+1] *************** *** 861,873 **** url = url.encode("ASCII") except UnicodeError: ! raise UnicodeError("URL "+repr(url)+" contains non-ASCII characters") return url def unwrap(url): """unwrap('') --> 'type://host/path'.""" ! url = string.strip(url) if url[:1] == '<' and url[-1:] == '>': ! url = string.strip(url[1:-1]) ! if url[:4] == 'URL:': url = string.strip(url[4:]) return url --- 862,875 ---- url = url.encode("ASCII") except UnicodeError: ! raise UnicodeError("URL " + repr(url) + ! " contains non-ASCII characters") return url def unwrap(url): """unwrap('') --> 'type://host/path'.""" ! url = url.strip() if url[:1] == '<' and url[-1:] == '>': ! url = url[1:-1].strip() ! if url[:4] == 'URL:': url = url[4:].strip() return url *************** *** 950,956 **** host, port = match.group(1, 2) try: ! if not port: raise string.atoi_error, "no digits" ! nport = string.atoi(port) ! except string.atoi_error: nport = None return host, nport --- 952,958 ---- host, port = match.group(1, 2) try: ! if not port: raise ValueError, "no digits" ! nport = int(port) ! except ValueError: nport = None return host, nport *************** *** 984,988 **** """splitattr('/path;attr1=value1;attr2=value2;...') -> '/path', ['attr1=value1', 'attr2=value2', ...].""" ! words = string.splitfields(url, ';') return words[0], words[1:] --- 986,990 ---- """splitattr('/path;attr1=value1;attr2=value2;...') -> '/path', ['attr1=value1', 'attr2=value2', ...].""" ! words = url.split(';') return words[0], words[1:] *************** *** 1008,1013 **** """unquote('abc%20def') -> 'abc def'.""" mychr = chr ! myatoi = string.atoi ! list = string.split(s, '%') res = [list[0]] myappend = res.append --- 1010,1015 ---- """unquote('abc%20def') -> 'abc def'.""" mychr = chr ! myatoi = int ! list = s.split('%') res = [list[0]] myappend = res.append *************** *** 1022,1026 **** else: myappend('%' + item) ! return string.join(res, "") def unquote_plus(s): --- 1024,1028 ---- else: myappend('%' + item) ! return "".join(res) def unquote_plus(s): *************** *** 1028,1032 **** if '+' in s: # replace '+' with ' ' ! s = string.join(string.split(s, '+'), ' ') return unquote(s) --- 1030,1034 ---- if '+' in s: # replace '+' with ' ' ! s = ' '.join(s.split('+')) return unquote(s) *************** *** 1049,1053 **** if not _fast_safe.has_key(c): res[i] = '%%%02x' % ord(c) ! return string.join(res, '') def quote(s, safe = '/'): --- 1051,1055 ---- if not _fast_safe.has_key(c): res[i] = '%%%02x' % ord(c) ! return ''.join(res) def quote(s, safe = '/'): *************** *** 1080,1092 **** if c not in safe: res[i] = '%%%02x' % ord(c) ! return string.join(res, '') def quote_plus(s, safe = ''): """Quote the query fragment of a URL; replacing ' ' with '+'""" if ' ' in s: ! l = string.split(s, ' ') for i in range(len(l)): l[i] = quote(l[i], safe) ! return string.join(l, '+') else: return quote(s, safe) --- 1082,1094 ---- if c not in safe: res[i] = '%%%02x' % ord(c) ! return ''.join(res) def quote_plus(s, safe = ''): """Quote the query fragment of a URL; replacing ' ' with '+'""" if ' ' in s: ! l = s.split(' ') for i in range(len(l)): l[i] = quote(l[i], safe) ! return '+'.join(l) else: return quote(s, safe) *************** *** 1099,1103 **** v = quote_plus(str(v)) l.append(k + '=' + v) ! return string.join(l, '&') # Proxy handling --- 1101,1105 ---- v = quote_plus(str(v)) l.append(k + '=' + v) ! return '&'.join(l) # Proxy handling *************** *** 1113,1117 **** proxies = {} for name, value in os.environ.items(): ! name = string.lower(name) if value and name[-6:] == '_proxy': proxies[name[:-6]] = value --- 1115,1119 ---- proxies = {} for name, value in os.environ.items(): ! name = name.lower() if value and name[-6:] == '_proxy': proxies[name[:-6]] = value *************** *** 1224,1228 **** def reporthook(blocknum, blocksize, totalsize): # Report during remote transfers ! print "Block number: %d, Block size: %d, Total size: %d" % (blocknum, blocksize, totalsize) # Test program --- 1226,1231 ---- def reporthook(blocknum, blocksize, totalsize): # Report during remote transfers ! print "Block number: %d, Block size: %d, Total size: %d" % ( ! blocknum, blocksize, totalsize) # Test program *************** *** 1243,1247 **** print '-'*10, url, '-'*10 fn, h = urlretrieve(url, None, reporthook) ! print fn, h if h: print '======' --- 1246,1250 ---- print '-'*10, url, '-'*10 fn, h = urlretrieve(url, None, reporthook) ! print fn if h: print '======' *************** *** 1253,1257 **** if '\r' in data: table = string.maketrans("", "") ! data = string.translate(data, table, "\r") print data fn, h = None, None --- 1256,1260 ---- if '\r' in data: table = string.maketrans("", "") ! data = data.translate(table, "\r") print data fn, h = None, None From python-dev@python.org Fri Dec 15 15:09:46 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 15 Dec 2000 07:09:46 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib httplib.py,1.25,1.26 Message-ID: <200012151509.HAA18093@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv18082 Modified Files: httplib.py Log Message: Get rid of string functions. There should really be a little tool to help with this -- it's rather tedious and there are lots of special cases! Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** httplib.py 2000/12/11 20:32:20 1.25 --- httplib.py 2000/12/15 15:09:42 1.26 *************** *** 68,72 **** import socket - import string import mimetools --- 68,71 ---- *************** *** 113,120 **** print "reply:", repr(line) try: ! [version, status, reason] = string.split(line, None, 2) except ValueError: try: ! [version, status] = string.split(line, None, 1) reason = "" except ValueError: --- 112,119 ---- print "reply:", repr(line) try: ! [version, status, reason] = line.split(None, 2) except ValueError: try: ! [version, status] = line.split(None, 1) reason = "" except ValueError: *************** *** 127,131 **** self.status = status = int(status) ! self.reason = string.strip(reason) if version == 'HTTP/1.0': --- 126,130 ---- self.status = status = int(status) ! self.reason = reason.strip() if version == 'HTTP/1.0': *************** *** 153,157 **** tr_enc = self.msg.getheader('transfer-encoding') if tr_enc: ! if string.lower(tr_enc) != 'chunked': raise UnknownTransferEncoding() self.chunked = 1 --- 152,156 ---- tr_enc = self.msg.getheader('transfer-encoding') if tr_enc: ! if tr_enc.lower() != 'chunked': raise UnknownTransferEncoding() self.chunked = 1 *************** *** 163,171 **** conn = self.msg.getheader('connection') if conn: ! conn = string.lower(conn) # a "Connection: close" will always close the connection. if we # don't see that and this is not HTTP/1.1, then the connection will # close unless we see a Keep-Alive header. ! self.will_close = string.find(conn, 'close') != -1 or \ ( self.version != 11 and \ not self.msg.getheader('keep-alive') ) --- 162,170 ---- conn = self.msg.getheader('connection') if conn: ! conn = conn.lower() # a "Connection: close" will always close the connection. if we # don't see that and this is not HTTP/1.1, then the connection will # close unless we see a Keep-Alive header. ! self.will_close = conn.find('close') != -1 or \ ( self.version != 11 and \ not self.msg.getheader('keep-alive') ) *************** *** 225,232 **** if chunk_left is None: line = self.fp.readline() ! i = string.find(line, ';') if i >= 0: line = line[:i] # strip chunk-extensions ! chunk_left = string.atoi(line, 16) if chunk_left == 0: break --- 224,231 ---- if chunk_left is None: line = self.fp.readline() ! i = line.find(';') if i >= 0: line = line[:i] # strip chunk-extensions ! chunk_left = int(line, 16) if chunk_left == 0: break *************** *** 332,336 **** def _set_hostport(self, host, port): if port is None: ! i = string.find(host, ':') if i >= 0: port = int(host[i+1:]) --- 331,335 ---- def _set_hostport(self, host, port): if port is None: ! i = host.find(':') if i >= 0: port = int(host[i+1:]) *************** *** 672,677 **** def putheader(self, header, *values): "The superclass allows only one value argument." ! self._conn.putheader(header, ! string.joinfields(values, '\r\n\t')) def getreply(self): --- 671,675 ---- def putheader(self, header, *values): "The superclass allows only one value argument." ! self._conn.putheader(header, '\r\n\t'.join(values)) def getreply(self): *************** *** 799,803 **** print if headers: ! for header in headers.headers: print string.strip(header) print print h.getfile().read() --- 797,801 ---- print if headers: ! for header in headers.headers: print header.strip() print print h.getfile().read() *************** *** 814,818 **** print if headers: ! for header in headers.headers: print string.strip(header) print print hs.getfile().read() --- 812,816 ---- print if headers: ! for header in headers.headers: print header.strip() print print hs.getfile().read() From python-dev@python.org Fri Dec 15 15:37:52 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 15 Dec 2000 07:37:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib rfc822.py,1.50,1.51 Message-ID: <200012151537.HAA20340@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv20326 Modified Files: rfc822.py Log Message: Get rid of string functions. References to string.whitespace, string.digits are left. Index: rfc822.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/rfc822.py,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -r1.50 -r1.51 *** rfc822.py 2000/11/09 18:05:24 1.50 --- rfc822.py 2000/12/15 15:37:48 1.51 *************** *** 143,147 **** break # Skip unix From name time lines ! if firstline and line[:5] == 'From ': self.unixfrom = self.unixfrom + line continue --- 143,147 ---- break # Skip unix From name time lines ! if firstline and line.startswith('From '): self.unixfrom = self.unixfrom + line continue *************** *** 150,155 **** # It's a continuation line. list.append(line) ! x = (self.dict[headerseen] + "\n " + string.strip(line)) ! self.dict[headerseen] = string.strip(x) continue elif self.iscomment(line): --- 150,155 ---- # It's a continuation line. list.append(line) ! x = (self.dict[headerseen] + "\n " + line.strip()) ! self.dict[headerseen] = x.strip() continue elif self.iscomment(line): *************** *** 163,167 **** # It's a legal header line, save it. list.append(line) ! self.dict[headerseen] = string.strip(line[len(headerseen)+1:]) continue else: --- 163,167 ---- # It's a legal header line, save it. list.append(line) ! self.dict[headerseen] = line[len(headerseen)+1:].strip() continue else: *************** *** 187,193 **** on tagged data in RFC822-like formats with special header formats. """ ! i = string.find(line, ':') if i > 0: ! return string.lower(line[:i]) else: return None --- 187,193 ---- on tagged data in RFC822-like formats with special header formats. """ ! i = line.find(':') if i > 0: ! return line[:i].lower() else: return None *************** *** 224,233 **** important in the header name. """ ! name = string.lower(name) + ':' n = len(name) list = [] hit = 0 for line in self.headers: ! if string.lower(line[:n]) == name: hit = 1 elif line[:1] not in string.whitespace: --- 224,233 ---- important in the header name. """ ! name = name.lower() + ':' n = len(name) list = [] hit = 0 for line in self.headers: ! if line[:n].lower() == name: hit = 1 elif line[:1] not in string.whitespace: *************** *** 244,248 **** lines). """ ! name = string.lower(name) + ':' n = len(name) list = [] --- 244,248 ---- lines). """ ! name = name.lower() + ':' n = len(name) list = [] *************** *** 252,256 **** if line[:1] not in string.whitespace: break ! elif string.lower(line[:n]) == name: hit = 1 if hit: --- 252,256 ---- if line[:1] not in string.whitespace: break ! elif line[:n].lower() == name: hit = 1 if hit: *************** *** 272,276 **** return None list[0] = list[0][len(name) + 1:] ! return string.joinfields(list, '') def getheader(self, name, default=None): --- 272,276 ---- return None list[0] = list[0][len(name) + 1:] ! return ''.join(list) def getheader(self, name, default=None): *************** *** 283,287 **** """ try: ! return self.dict[string.lower(name)] except KeyError: return default --- 283,287 ---- """ try: ! return self.dict[name.lower()] except KeyError: return default *************** *** 302,312 **** if s[0] in string.whitespace: if current: ! current = "%s\n %s" % (current, string.strip(s)) else: ! current = string.strip(s) else: if have_header: result.append(current) ! current = string.strip(s[string.find(s, ":") + 1:]) have_header = 1 if have_header: --- 302,312 ---- if s[0] in string.whitespace: if current: ! current = "%s\n %s" % (current, s.strip()) else: ! current = s.strip() else: if have_header: result.append(current) ! current = s[s.find(":") + 1:].strip() have_header = 1 if have_header: *************** *** 342,350 **** if raw: raw.append(', ') ! i = string.find(h, ':') if i > 0: addr = h[i+1:] raw.append(addr) ! alladdrs = string.join(raw, '') a = AddrlistClass(alladdrs) return a.getaddrlist() --- 342,350 ---- if raw: raw.append(', ') ! i = h.find(':') if i > 0: addr = h[i+1:] raw.append(addr) ! alladdrs = ''.join(raw) a = AddrlistClass(alladdrs) return a.getaddrlist() *************** *** 384,388 **** def __getitem__(self, name): """Get a specific header, as from a dictionary.""" ! return self.dict[string.lower(name)] def __setitem__(self, name, value): --- 384,388 ---- def __getitem__(self, name): """Get a specific header, as from a dictionary.""" ! return self.dict[name.lower()] def __setitem__(self, name, value): *************** *** 394,400 **** """ del self[name] # Won't fail if it doesn't exist ! self.dict[string.lower(name)] = value text = name + ": " + value ! lines = string.split(text, "\n") for line in lines: self.headers.append(line + "\n") --- 394,400 ---- """ del self[name] # Won't fail if it doesn't exist ! self.dict[name.lower()] = value text = name + ": " + value ! lines = text.split("\n") for line in lines: self.headers.append(line + "\n") *************** *** 402,406 **** def __delitem__(self, name): """Delete all occurrences of a specific header, if it is present.""" ! name = string.lower(name) if not self.dict.has_key(name): return --- 402,406 ---- def __delitem__(self, name): """Delete all occurrences of a specific header, if it is present.""" ! name = name.lower() if not self.dict.has_key(name): return *************** *** 412,416 **** for i in range(len(self.headers)): line = self.headers[i] ! if string.lower(line[:n]) == name: hit = 1 elif line[:1] not in string.whitespace: --- 412,416 ---- for i in range(len(self.headers)): line = self.headers[i] ! if line[:n].lower() == name: hit = 1 elif line[:1] not in string.whitespace: *************** *** 424,428 **** def has_key(self, name): """Determine whether a message contains the named header.""" ! return self.dict.has_key(string.lower(name)) def keys(self): --- 424,428 ---- def has_key(self, name): """Determine whether a message contains the named header.""" ! return self.dict.has_key(name.lower()) def keys(self): *************** *** 467,477 **** def quote(str): """Add quotes around a string.""" ! return '"%s"' % string.join( ! string.split( ! string.join( ! string.split(str, '\\'), ! '\\\\'), ! '"'), ! '\\"') --- 467,471 ---- def quote(str): """Add quotes around a string.""" ! return str.replace('\\', '\\\\').replace('"', '\\"') *************** *** 544,548 **** # Bad email address technically, no domain. if plist: ! returnlist = [(string.join(self.commentlist), plist[0])] elif self.field[self.pos] in '.@': --- 538,542 ---- # Bad email address technically, no domain. if plist: ! returnlist = [(' '.join(self.commentlist), plist[0])] elif self.field[self.pos] in '.@': *************** *** 552,556 **** self.commentlist = oldcl addrspec = self.getaddrspec() ! returnlist = [(string.join(self.commentlist), addrspec)] elif self.field[self.pos] == ':': --- 546,550 ---- self.commentlist = oldcl addrspec = self.getaddrspec() ! returnlist = [(' '.join(self.commentlist), addrspec)] elif self.field[self.pos] == ':': *************** *** 572,582 **** if self.commentlist: ! returnlist = [(string.join(plist) + ' (' + \ ! string.join(self.commentlist) + ')', routeaddr)] ! else: returnlist = [(string.join(plist), routeaddr)] else: if plist: ! returnlist = [(string.join(self.commentlist), plist[0])] elif self.field[self.pos] in self.specials: self.pos = self.pos + 1 --- 566,576 ---- if self.commentlist: ! returnlist = [(' '.join(plist) + ' (' + \ ! ' '.join(self.commentlist) + ')', routeaddr)] ! else: returnlist = [(' '.join(plist), routeaddr)] else: if plist: ! returnlist = [(' '.join(self.commentlist), plist[0])] elif self.field[self.pos] in self.specials: self.pos = self.pos + 1 *************** *** 637,646 **** if self.pos >= len(self.field) or self.field[self.pos] != '@': ! return string.join(aslist, '') aslist.append('@') self.pos = self.pos + 1 self.gotonext() ! return string.join(aslist, '') + self.getdomain() def getdomain(self): --- 631,640 ---- if self.pos >= len(self.field) or self.field[self.pos] != '@': ! return ''.join(aslist) aslist.append('@') self.pos = self.pos + 1 self.gotonext() ! return ''.join(aslist) + self.getdomain() def getdomain(self): *************** *** 660,664 **** break else: sdlist.append(self.getatom()) ! return string.join(sdlist, '') def getdelimited(self, beginchar, endchars, allowcomments = 1): --- 654,658 ---- break else: sdlist.append(self.getatom()) ! return ''.join(sdlist) def getdelimited(self, beginchar, endchars, allowcomments = 1): *************** *** 696,700 **** self.pos = self.pos + 1 ! return string.join(slist, '') def getquote(self): --- 690,694 ---- self.pos = self.pos + 1 ! return ''.join(slist) def getquote(self): *************** *** 720,724 **** self.pos = self.pos + 1 ! return string.join(atomlist, '') def getphraselist(self): --- 714,718 ---- self.pos = self.pos + 1 ! return ''.join(atomlist) def getphraselist(self): *************** *** 757,761 **** def __str__(self): ! return string.joinfields(map(dump_address_pair, self.addresslist),", ") def __add__(self, other): --- 751,755 ---- def __str__(self): ! return ", ".join(map(dump_address_pair, self.addresslist)) def __add__(self, other): *************** *** 829,843 **** Accounts for military timezones. """ ! data = string.split(data) ! if data[0][-1] in (',', '.') or string.lower(data[0]) in _daynames: # There's a dayname here. Skip it del data[0] if len(data) == 3: # RFC 850 date, deprecated ! stuff = string.split(data[0], '-') if len(stuff) == 3: data = stuff + data[1:] if len(data) == 4: s = data[3] ! i = string.find(s, '+') if i > 0: data[3:] = [s[:i], s[i+1:]] --- 823,837 ---- Accounts for military timezones. """ ! data = data.split() ! if data[0][-1] in (',', '.') or data[0].lower() in _daynames: # There's a dayname here. Skip it del data[0] if len(data) == 3: # RFC 850 date, deprecated ! stuff = data[0].split('-') if len(stuff) == 3: data = stuff + data[1:] if len(data) == 4: s = data[3] ! i = s.find('+') if i > 0: data[3:] = [s[:i], s[i+1:]] *************** *** 848,854 **** data = data[:5] [dd, mm, yy, tm, tz] = data ! mm = string.lower(mm) if not mm in _monthnames: ! dd, mm = mm, string.lower(dd) if not mm in _monthnames: return None --- 842,848 ---- data = data[:5] [dd, mm, yy, tm, tz] = data ! mm = mm.lower() if not mm in _monthnames: ! dd, mm = mm, dd.lower() if not mm in _monthnames: return None *************** *** 857,861 **** if dd[-1] == ',': dd = dd[:-1] ! i = string.find(yy, ':') if i > 0: yy, tm = tm, yy --- 851,855 ---- if dd[-1] == ',': dd = dd[:-1] ! i = yy.find(':') if i > 0: yy, tm = tm, yy *************** *** 866,870 **** if tm[-1] == ',': tm = tm[:-1] ! tm = string.splitfields(tm, ':') if len(tm) == 2: [thh, tmm] = tm --- 860,864 ---- if tm[-1] == ',': tm = tm[:-1] ! tm = tm.split(':') if len(tm) == 2: [thh, tmm] = tm *************** *** 875,893 **** return None try: ! yy = string.atoi(yy) ! dd = string.atoi(dd) ! thh = string.atoi(thh) ! tmm = string.atoi(tmm) ! tss = string.atoi(tss) ! except string.atoi_error: return None ! tzoffset=None ! tz=string.upper(tz) if _timezones.has_key(tz): ! tzoffset=_timezones[tz] else: try: ! tzoffset=string.atoi(tz) ! except string.atoi_error: pass # Convert a timezone offset into seconds ; -0500 -> -18000 --- 869,887 ---- return None try: ! yy = int(yy) ! dd = int(dd) ! thh = int(thh) ! tmm = int(tmm) ! tss = int(tss) ! except ValueError: return None ! tzoffset = None ! tz = tz.upper() if _timezones.has_key(tz): ! tzoffset = _timezones[tz] else: try: ! tzoffset = int(tz) ! except ValueError: pass # Convert a timezone offset into seconds ; -0500 -> -18000 *************** *** 905,910 **** def parsedate(data): """Convert a time string to a time tuple.""" ! t=parsedate_tz(data) ! if type(t)==type( () ): return t[:9] else: return t --- 899,904 ---- def parsedate(data): """Convert a time string to a time tuple.""" ! t = parsedate_tz(data) ! if type(t) == type( () ): return t[:9] else: return t From python-dev@python.org Fri Dec 15 15:49:14 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 15 Dec 2000 07:49:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib mimetools.py,1.19,1.20 Message-ID: <200012151549.HAA21195@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv21183 Modified Files: mimetools.py Log Message: Get rid of string functions. Index: mimetools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mimetools.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** mimetools.py 2000/12/12 23:20:44 1.19 --- mimetools.py 2000/12/15 15:49:08 1.20 *************** *** 4,8 **** import os import rfc822 - import string import tempfile --- 4,7 ---- *************** *** 26,40 **** str = 'text/plain' if ';' in str: ! i = string.index(str, ';') self.plisttext = str[i:] str = str[:i] else: self.plisttext = '' ! fields = string.splitfields(str, '/') for i in range(len(fields)): ! fields[i] = string.lower(string.strip(fields[i])) ! self.type = string.joinfields(fields, '/') self.maintype = fields[0] ! self.subtype = string.joinfields(fields[1:], '/') def parseplist(self): --- 25,39 ---- str = 'text/plain' if ';' in str: ! i = str.index(';') self.plisttext = str[i:] str = str[:i] else: self.plisttext = '' ! fields = str.split('/') for i in range(len(fields)): ! fields[i] = fields[i].strip().lower() ! self.type = '/'.join(fields) self.maintype = fields[0] ! self.subtype = '/'.join(fields[1:]) def parseplist(self): *************** *** 45,57 **** if ';' in str: # XXX Should parse quotes! ! end = string.index(str, ';') else: end = len(str) f = str[:end] if '=' in f: ! i = string.index(f, '=') ! f = string.lower(string.strip(f[:i])) + \ ! '=' + string.strip(f[i+1:]) ! self.plist.append(string.strip(f)) str = str[end:] --- 44,56 ---- if ';' in str: # XXX Should parse quotes! ! end = str.index(';') else: end = len(str) f = str[:end] if '=' in f: ! i = f.index('=') ! f = f[:i].strip().lower() + \ ! '=' + f[i+1:].strip() ! self.plist.append(f.strip()) str = str[end:] *************** *** 60,64 **** def getparam(self, name): ! name = string.lower(name) + '=' n = len(name) for p in self.plist: --- 59,63 ---- def getparam(self, name): ! name = name.lower() + '=' n = len(name) for p in self.plist: *************** *** 70,76 **** result = [] for p in self.plist: ! i = string.find(p, '=') if i >= 0: ! result.append(string.lower(p[:i])) return result --- 69,75 ---- result = [] for p in self.plist: ! i = p.find('=') if i >= 0: ! result.append(p[:i].lower()) return result *************** *** 78,82 **** if self.encodingheader is None: return '7bit' ! return string.lower(self.encodingheader) def gettype(self): --- 77,81 ---- if self.encodingheader is None: return '7bit' ! return self.encodingheader.lower() def gettype(self): From python-dev@python.org Fri Dec 15 19:07:20 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 15 Dec 2000 11:07:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib librandom.tex,1.14,1.15 Message-ID: <200012151907.LAA01315@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv1307/lib Modified Files: librandom.tex Log Message: Added documentation for random.shuffle(). Index: librandom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/librandom.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** librandom.tex 2000/06/30 15:32:31 1.14 --- librandom.tex 2000/12/15 19:07:17 1.15 *************** *** 89,92 **** --- 89,109 ---- \end{funcdesc} + + This function does not represent a specific distribution, but + implements a standard useful algorithm: + + \begin{funcdesc}{shuffle}{x\optional{, random}} + Shuffle the sequence \var{x} in place. + The optional argument \var{random} is a 0-argument function returning + a random float in [0.0, 1.0); by default, this is the function + \function{random()}. + + Note that for even rather small \code{len(\var{x})}, the total number + of permutations of \var{x} is larger than the period of most random + number generators; this implies that most permutations of a long + sequence can never be generated. + \end{funcdesc} + + \begin{seealso} \seemodule{whrandom}{The standard Python random number generator.} From python-dev@python.org Fri Dec 15 20:08:43 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 15 Dec 2000 12:08:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib threading.py,1.9,1.10 Message-ID: <200012152008.MAA05958@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv5943 Modified Files: threading.py Log Message: Comment out a debugging print statement that triggered a complaint in c.l.py. Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** threading.py 2000/08/18 15:50:54 1.9 --- threading.py 2000/12/15 20:08:39 1.10 *************** *** 518,522 **** return _active[_get_ident()] except KeyError: ! print "currentThread(): no current thread for", _get_ident() return _DummyThread() --- 518,522 ---- return _active[_get_ident()] except KeyError: ! ##print "currentThread(): no current thread for", _get_ident() return _DummyThread() From python-dev@python.org Fri Dec 15 21:08:05 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 15 Dec 2000 13:08:05 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom __init__.py,1.4,1.5 Message-ID: <200012152108.NAA09470@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory slayer.i.sourceforge.net:/tmp/cvs-serv9455 Modified Files: __init__.py Log Message: DOMException.__init__(): Remember to pass self to Exception.__init__(). Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/__init__.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** __init__.py 2000/12/13 16:35:53 1.4 --- __init__.py 2000/12/15 21:07:59 1.5 *************** *** 66,70 **** raise RuntimeError( "DOMException should not be instaniated directly") ! apply(Exception.__init__, args, kw) --- 66,70 ---- raise RuntimeError( "DOMException should not be instaniated directly") ! apply(Exception.__init__, (self,) + args, kw) From python-dev@python.org Tue Dec 19 20:59:07 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 19 Dec 2000 12:59:07 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects fileobject.c,2.94,2.95 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv1678 Modified Files: fileobject.c Log Message: Patch #102868 from cgw: fix memory leak when an EOF is encountered using GNU libc's getline() Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.94 retrieving revision 2.95 diff -C2 -r2.94 -r2.95 *** fileobject.c 2000/11/30 18:27:50 2.94 --- fileobject.c 2000/12/19 20:59:04 2.95 *************** *** 661,664 **** --- 661,667 ---- Py_END_ALLOW_THREADS if (n1 == -1) { + if (buf){ + free(buf); + } clearerr(fp); if (PyErr_CheckSignals()) { From python-dev@python.org Tue Dec 19 22:49:09 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 19 Dec 2000 14:49:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.69,2.70 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv18623 Modified Files: unicodeobject.c Log Message: Patch #102940: use only printable Unicode chars in reporting incorrect % characters; characters outside the printable range are replaced with '?' Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.69 retrieving revision 2.70 diff -C2 -r2.69 -r2.70 *** unicodeobject.c 2000/12/19 02:23:19 2.69 --- unicodeobject.c 2000/12/19 22:49:06 2.70 *************** *** 5070,5074 **** "unsupported format character '%c' (0x%x) " "at index %i", ! c, c, fmt -1 - PyUnicode_AS_UNICODE(uformat)); goto onError; } --- 5070,5075 ---- "unsupported format character '%c' (0x%x) " "at index %i", ! (31<=c && c<=126) ? c : '?', ! c, fmt -1 - PyUnicode_AS_UNICODE(uformat)); goto onError; } From python-dev@python.org Wed Dec 20 00:48:15 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 19 Dec 2000 16:48:15 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils/command install.py,1.54,1.55 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv4764 Modified Files: install.py Log Message: Add forgotten initialization. Fixes bug #120994, "Traceback with DISTUTILS_DEBUG set" Index: install.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/install.py,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -r1.54 -r1.55 *** install.py 2000/10/14 04:06:40 1.54 --- install.py 2000/12/20 00:48:12 1.55 *************** *** 147,150 **** --- 147,151 ---- self.compile = None + self.no_compile = None self.optimize = None From python-dev@python.org Wed Dec 20 00:55:09 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 19 Dec 2000 16:55:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects fileobject.c,2.95,2.96 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv5580 Modified Files: fileobject.c Log Message: Make the indentation consistently use tabs instead of using spaces just in one place. Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.95 retrieving revision 2.96 diff -C2 -r2.95 -r2.96 *** fileobject.c 2000/12/19 20:59:04 2.95 --- fileobject.c 2000/12/20 00:55:07 2.96 *************** *** 661,667 **** Py_END_ALLOW_THREADS if (n1 == -1) { ! if (buf){ ! free(buf); ! } clearerr(fp); if (PyErr_CheckSignals()) { --- 661,667 ---- Py_END_ALLOW_THREADS if (n1 == -1) { ! if (buf){ ! free(buf); ! } clearerr(fp); if (PyErr_CheckSignals()) { From python-dev@python.org Wed Dec 20 00:55:48 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 19 Dec 2000 16:55:48 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_format.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv5603 Modified Files: test_format.py Log Message: Change expected message for ValueError, fixing bug #126400 Index: test_format.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_format.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** test_format.py 2000/12/15 13:09:06 1.4 --- test_format.py 2000/12/20 00:55:46 1.5 *************** *** 198,201 **** "unsupported format character 'a' (0x61) at index 5") test_exc(u'abc %\u3000', 1, ValueError, ! "unsupported format character '\000' (0x3000) at index 5") --- 198,201 ---- "unsupported format character 'a' (0x61) at index 5") test_exc(u'abc %\u3000', 1, ValueError, ! "unsupported format character '?' (0x3000) at index 5") From python-dev@python.org Wed Dec 20 14:36:58 2000 From: python-dev@python.org (A.M. Kuchling) Date: Wed, 20 Dec 2000 06:36:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.183,2.184 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv17873 Modified Files: bltinmodule.c Log Message: Patch #102955, fixing one of the warnings in bug #121479: Simplifies ord()'s logic at the cost of some code duplication, removing a " `ord' might be used uninitialized in this function" warning Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.183 retrieving revision 2.184 diff -C2 -r2.183 -r2.184 *** bltinmodule.c 2000/12/04 15:42:11 2.183 --- bltinmodule.c 2000/12/20 14:36:56 2.184 *************** *** 1,3 **** ! /* Built-in functions */ --- 1,3 ---- ! fo /* Built-in functions */ *************** *** 1513,1522 **** if (PyString_Check(obj)) { size = PyString_GET_SIZE(obj); ! if (size == 1) ord = (long)((unsigned char)*PyString_AS_STRING(obj)); } else if (PyUnicode_Check(obj)) { size = PyUnicode_GET_SIZE(obj); ! if (size == 1) ord = (long)*PyUnicode_AS_UNICODE(obj); } else { PyErr_Format(PyExc_TypeError, --- 1513,1526 ---- if (PyString_Check(obj)) { size = PyString_GET_SIZE(obj); ! if (size == 1) { ord = (long)((unsigned char)*PyString_AS_STRING(obj)); + return PyInt_FromLong(ord); + } } else if (PyUnicode_Check(obj)) { size = PyUnicode_GET_SIZE(obj); ! if (size == 1) { ord = (long)*PyUnicode_AS_UNICODE(obj); + return PyInt_FromLong(ord); + } } else { PyErr_Format(PyExc_TypeError, *************** *** 1525,1530 **** return NULL; } - if (size == 1) - return PyInt_FromLong(ord); PyErr_Format(PyExc_TypeError, --- 1529,1532 ---- From python-dev@python.org Wed Dec 20 14:47:26 2000 From: python-dev@python.org (A.M. Kuchling) Date: Wed, 20 Dec 2000 06:47:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom minidom.py,1.15,1.16 pulldom.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory usw-pr-cvs1:/tmp/cvs-serv20506 Modified Files: minidom.py pulldom.py Log Message: Patch #102492, fixing bug #116677: give minidom.py behaviour that complies with the DOM Level 1 REC, which says that when a node newChild is added to the tree, "if the newChild is already in the tree, it is first removed." pulldom.py is patched to use the public minidom interface instead of setting .parentNode itself. Possibly this reduces pulldom's efficiency; someone else will have to pronounce on that. Index: minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/minidom.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** minidom.py 2000/12/14 18:16:11 1.15 --- minidom.py 2000/12/20 14:47:24 1.16 *************** *** 41,44 **** --- 41,45 ---- def __init__(self): self.childNodes = [] + self.parentNode = None if Node._debug: index = repr(id(self)) + repr(self.__class__) *************** *** 99,102 **** --- 100,105 ---- def insertBefore(self, newChild, refChild): + if newChild.parentNode is not None: + newChild.parentNode.removeChild(newChild) if refChild is None: self.appendChild(newChild) *************** *** 117,120 **** --- 120,125 ---- def appendChild(self, node): + if node.parentNode is not None: + node.parentNode.removeChild(node) if self.childNodes: last = self.lastChild *************** *** 130,133 **** --- 135,140 ---- def replaceChild(self, newChild, oldChild): + if newChild.parentNode is not None: + newChild.parentNode.removeChild(newChild) if newChild is oldChild: return *************** *** 145,148 **** --- 152,161 ---- def removeChild(self, oldChild): self.childNodes.remove(oldChild) + if oldChild.nextSibling is not None: + oldChild.nextSibling.previousSibling = oldChild.previousSibling + if oldChild.previousSibling is not None: + oldChild.previousSibling.nextSibling = oldChild.nextSibling + oldChild.nextSibling = oldChild.previousSibling = None + if self._makeParentNodes: oldChild.parentNode = None *************** *** 607,614 **** --- 620,639 ---- def appendChild(self, node): + if node.parentNode is not None: + node.parentNode.removeChild(node) + if node.nodeType == Node.ELEMENT_NODE \ and self._get_documentElement(): raise TypeError, "two document elements disallowed" return Node.appendChild(self, node) + + def removeChild(self, oldChild): + self.childNodes.remove(oldChild) + oldChild.nextSibling = oldChild.previousSibling = None + oldChild.parentNode = None + if self.documentElement is oldChild: + self.documentElement = None + + return oldChild def _get_documentElement(self): Index: pulldom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/pulldom.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** pulldom.py 2000/12/14 18:00:18 1.12 --- pulldom.py 2000/12/20 14:47:24 1.13 *************** *** 56,60 **** node.setAttributeNode(attr) ! node.parentNode = self.curNode self.curNode = node --- 56,62 ---- node.setAttributeNode(attr) ! ## print self.curNode, self.curNode.childNodes, node, node.parentNode ! self.curNode.appendChild(node) ! # node.parentNode = self.curNode self.curNode = node *************** *** 78,82 **** node.setAttributeNode(attr) ! node.parentNode = self.curNode self.curNode = node --- 80,85 ---- node.setAttributeNode(attr) ! #node.parentNode = self.curNode ! self.curNode.appendChild(node) self.curNode = node *************** *** 94,99 **** def comment(self, s): node = self.document.createComment(s) ! parent = self.curNode ! node.parentNode = parent self.lastEvent[1] = [(COMMENT, node), None] self.lastEvent = self.lastEvent[1] --- 97,103 ---- def comment(self, s): node = self.document.createComment(s) ! self.curNode.appendChild(node) ! # parent = self.curNode ! # node.parentNode = parent self.lastEvent[1] = [(COMMENT, node), None] self.lastEvent = self.lastEvent[1] *************** *** 103,108 **** node = self.document.createProcessingInstruction(target, data) ! parent = self.curNode ! node.parentNode = parent self.lastEvent[1] = [(PROCESSING_INSTRUCTION, node), None] self.lastEvent = self.lastEvent[1] --- 107,113 ---- node = self.document.createProcessingInstruction(target, data) ! self.curNode.appendChild(node) ! # parent = self.curNode ! # node.parentNode = parent self.lastEvent[1] = [(PROCESSING_INSTRUCTION, node), None] self.lastEvent = self.lastEvent[1] *************** *** 111,116 **** def ignorableWhitespace(self, chars): node = self.document.createTextNode(chars) ! parent = self.curNode ! node.parentNode = parent self.lastEvent[1] = [(IGNORABLE_WHITESPACE, node), None] self.lastEvent = self.lastEvent[1] --- 116,122 ---- def ignorableWhitespace(self, chars): node = self.document.createTextNode(chars) ! self.curNode.appendChild(node) ! # parent = self.curNode ! # node.parentNode = parent self.lastEvent[1] = [(IGNORABLE_WHITESPACE, node), None] self.lastEvent = self.lastEvent[1] *************** *** 119,124 **** def characters(self, chars): node = self.document.createTextNode(chars) ! parent = self.curNode ! node.parentNode = parent self.lastEvent[1] = [(CHARACTERS, node), None] self.lastEvent = self.lastEvent[1] --- 125,131 ---- def characters(self, chars): node = self.document.createTextNode(chars) ! self.curNode.appendChild(node) ! # parent = self.curNode ! # node.parentNode = parent self.lastEvent[1] = [(CHARACTERS, node), None] self.lastEvent = self.lastEvent[1] From python-dev@python.org Wed Dec 20 15:07:37 2000 From: python-dev@python.org (A.M. Kuchling) Date: Wed, 20 Dec 2000 07:07:37 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.184,2.185 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv24457 Modified Files: bltinmodule.c Log Message: Whoops! Two stray characters crept in to my last check-in Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.184 retrieving revision 2.185 diff -C2 -r2.184 -r2.185 *** bltinmodule.c 2000/12/20 14:36:56 2.184 --- bltinmodule.c 2000/12/20 15:07:34 2.185 *************** *** 1,3 **** ! fo /* Built-in functions */ --- 1,3 ---- ! /* Built-in functions */ From python-dev@python.org Wed Dec 20 16:43:01 2000 From: python-dev@python.org (Barry Warsaw) Date: Wed, 20 Dec 2000 08:43:01 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0232.txt,1.2,1.3 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv14147 Modified Files: pep-0232.txt Log Message: Another suggested syntax for inlining attributes, by Aaron Digulla. Index: pep-0232.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0232.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** pep-0232.txt 2000/12/14 17:20:46 1.2 --- pep-0232.txt 2000/12/20 16:42:59 1.3 *************** *** 100,105 **** syntactic support for conveniently setting. It may be worthwhile to enhance the language for supporting easy function ! attribute setting. One suggestion that has been raised in ! previous discussions is this syntax: def a { --- 100,104 ---- syntactic support for conveniently setting. It may be worthwhile to enhance the language for supporting easy function ! attribute setting. Here are some suggested syntaxes: def a { *************** *** 110,115 **** # ... ! I.e., that a dictionary literal placed between the function ! name and the argument parentheses be assigned to func_dict. It isn't currently clear if special syntax is necessary or --- 109,118 ---- # ... ! def a(args): ! """The usual docstring.""" ! {'publish' : 1, ! 'unittest': '''...''', ! # etc. ! } It isn't currently clear if special syntax is necessary or From python-dev@python.org Thu Dec 21 16:22:24 2000 From: python-dev@python.org (A.M. Kuchling) Date: Thu, 21 Dec 2000 08:22:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.43,2.44 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv4442 Modified Files: _cursesmodule.c Log Message: Another patch from Thomas Gellekum: add .overlay() and .overwrite() window methods Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.43 retrieving revision 2.44 diff -C2 -r2.43 -r2.44 *** _cursesmodule.c 2000/12/15 00:44:02 2.43 --- _cursesmodule.c 2000/12/21 16:22:22 2.44 *************** *** 40,49 **** unsupported functions: ! addchnstr addchstr chgat color_set copywin define_key del_curterm delscreen dupwin inchnstr inchstr innstr keyok mcprint mvaddchnstr mvaddchstr mvchgat mvcur mvinchnstr mvinchstr mvinnstr mmvwaddchnstr mvwaddchstr mvwchgat mvwgetnstr mvwinchnstr mvwinchstr mvwinnstr newterm ! overlay overwrite resizeterm restartterm ripoffline scr_dump scr_init scr_restore scr_set scrl set_curterm set_term setterm tgetent tgetflag tgetnum tgetstr tgoto timeout tputs --- 40,49 ---- unsupported functions: ! addchnstr addchstr chgat color_set define_key del_curterm delscreen dupwin inchnstr inchstr innstr keyok mcprint mvaddchnstr mvaddchstr mvchgat mvcur mvinchnstr mvinchstr mvinnstr mmvwaddchnstr mvwaddchstr mvwchgat mvwgetnstr mvwinchnstr mvwinchstr mvwinnstr newterm ! resizeterm restartterm ripoffline scr_dump scr_init scr_restore scr_set scrl set_curterm set_term setterm tgetent tgetflag tgetnum tgetstr tgoto timeout tputs *************** *** 1083,1086 **** --- 1083,1162 ---- static PyObject * + PyCursesWindow_Overlay(PyCursesWindowObject *self, PyObject *args) + { + PyCursesWindowObject *temp; + int use_copywin = FALSE; + int sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol; + int rtn; + + switch (ARG_COUNT(args)) { + case 1: + if (!PyArg_ParseTuple(args, "O!;window object", + &PyCursesWindow_Type, &temp)) + return NULL; + break; + case 7: + if (!PyArg_ParseTuple(args, "(O!iiiiii);window object, int, int, int, int, int, int", + &PyCursesWindow_Type, &temp, &sminrow, &smincol, + &dminrow, &dmincol, &dmaxrow, &dmaxcol)) + return NULL; + use_copywin = TRUE; + break; + default: + PyErr_SetString(PyExc_TypeError, + "overlay requires one or seven arguments"); + return NULL; + } + + if (use_copywin == TRUE) { + rtn = copywin(self->win, temp->win, sminrow, smincol, + dminrow, dmincol, dmaxrow, dmaxcol, TRUE); + return PyCursesCheckERR(rtn, "copywin"); + } + else { + rtn = overlay(self->win, temp->win); + return PyCursesCheckERR(rtn, "overlay"); + } + } + + static PyObject * + PyCursesWindow_Overwrite(PyCursesWindowObject *self, PyObject *args) + { + PyCursesWindowObject *temp; + int use_copywin = FALSE; + int sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol; + int rtn; + + switch (ARG_COUNT(args)) { + case 1: + if (!PyArg_ParseTuple(args, "O!;window object", + &PyCursesWindow_Type, &temp)) + return NULL; + break; + case 7: + if (!PyArg_ParseTuple(args, "(O!iiiiii);window object, int, int, int, int, int, int", + &PyCursesWindow_Type, &temp, &sminrow, &smincol, + &dminrow, &dmincol, &dmaxrow, &dmaxcol)) + return NULL; + use_copywin = TRUE; + break; + default: + PyErr_SetString(PyExc_TypeError, + "overwrite requires one or seven arguments"); + return NULL; + } + + if (use_copywin == TRUE) { + rtn = copywin(self->win, temp->win, sminrow, smincol, + dminrow, dmincol, dmaxrow, dmaxcol, FALSE); + return PyCursesCheckERR(rtn, "copywin"); + } + else { + rtn = overwrite(self->win, temp->win); + return PyCursesCheckERR(rtn, "overwrite"); + } + } + + static PyObject * PyCursesWindow_PutWin(PyCursesWindowObject *self, PyObject *args) { *************** *** 1324,1328 **** {"noutrefresh", (PyCFunction)PyCursesWindow_NoOutRefresh}, /* Backward compatibility alias -- remove in Python 2.1 */ ! {"nooutrefresh", (PyCFunction)PyCursesWindow_NoOutRefresh}, {"putwin", (PyCFunction)PyCursesWindow_PutWin}, {"redrawln", (PyCFunction)PyCursesWindow_RedrawLine}, --- 1400,1406 ---- {"noutrefresh", (PyCFunction)PyCursesWindow_NoOutRefresh}, /* Backward compatibility alias -- remove in Python 2.1 */ ! {"nooutrefresh", (PyCFunction)PyCursesWindow_NoOutRefresh}, ! {"overlay", (PyCFunction)PyCursesWindow_Overlay, METH_VARARGS}, ! {"overwrite", (PyCFunction)PyCursesWindow_Overwrite, METH_VARARGS}, {"putwin", (PyCFunction)PyCursesWindow_PutWin}, {"redrawln", (PyCFunction)PyCursesWindow_RedrawLine}, From python-dev@python.org Thu Dec 21 16:25:47 2000 From: python-dev@python.org (A.M. Kuchling) Date: Thu, 21 Dec 2000 08:25:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcurses.tex,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv4799 Modified Files: libcurses.tex Log Message: Document the window.overlay() and .overwrite() methods Index: libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** libcurses.tex 2000/12/15 01:03:23 1.24 --- libcurses.tex 2000/12/21 16:25:44 1.25 *************** *** 861,864 **** --- 861,890 ---- \end{methoddesc} + \begin{methoddesc}{overlay}{destwin\optional{, sminrow, smincol, + dminrow, dmincol, dmaxrow, dmaxcol}} + Overlay the window on top of \var{destwin}. The windows need not be + the same size, only the overlapping region is copied. This copy is + non-destructive, which means that the current background character + does not overwrite the old contents of \var{destwin}. + + To get fine-grained control over the copied region, the second form + of \method{overlay} can be used. \var{sminrow} and \var{smincol} are + the upper-left coordinates of the source window, and the other variables + mark a rectangle in the destination window. + \end{methoddesc} + + \begin{methoddesc}{overwrite}{destwin\optional{, sminrow, smincol, + dminrow, dmincol, dmaxrow, dmaxcol}} + Overwrite the window on top of \var{destwin}. The windows need not be + the same size, in which case only the overlapping region is copied. This copy is + destructive, which means that the current background character + overwrites the old contents of \var{destwin}. + + To get fine-grained control over the copied region, the second form + of \method{overwrite} can be used. \var{sminrow} and \var{smincol} are + the upper-left coordinates of the source window, the other variables + mark a rectangle in the destination window. + \end{methoddesc} + \begin{methoddesc}{putwin}{file} Writes all data associated with the window into the provided file From python-dev@python.org Thu Dec 21 16:26:39 2000 From: python-dev@python.org (A.M. Kuchling) Date: Thu, 21 Dec 2000 08:26:39 -0800 Subject: [Python-checkins] CVS: python/dist/src/Demo/curses xmas.py,NONE,1.1 README,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/curses In directory usw-pr-cvs1:/tmp/cvs-serv4902 Modified Files: README Added Files: xmas.py Log Message: Another demo from Thomas Gellekum (seasonally-themed, too) --- NEW FILE: xmas.py --- # asciixmas # December 1989 Larry Bartz Indianapolis, IN # # $Id: xmas.py,v 1.1 2000/12/21 16:26:37 akuchling Exp $ # # I'm dreaming of an ascii character-based monochrome Christmas, # Just like the one's I used to know! # Via a full duplex communications channel, # At 9600 bits per second, # Even though it's kinda slow. # # I'm dreaming of an ascii character-based monochrome Christmas, # With ev'ry C program I write! # May your screen be merry and bright! # And may all your Christmases be amber or green, # (for reduced eyestrain and improved visibility)! # # # Notes on the Python version: # I used a couple of `try...except curses.error' to get around some functions # returning ERR. The errors come from using wrapping functions to fill # windows to the last character cell. The C version doesn't have this problem, # it simply ignores any return values. # import curses import sys FROMWHO = "Thomas Gellekum " def set_color(win, color): if curses.has_colors(): n = color + 1 curses.init_pair(n, color, my_bg) win.attroff(curses.A_COLOR) win.attron(curses.color_pair(n)) def unset_color(win): if curses.has_colors(): win.attrset(curses.color_pair(0)) def look_out(msecs): curses.napms(msecs) if stdscr.getch() != -1: curses.beep() sys.exit(0) def boxit(): for y in range(0, 20): stdscr.addch(y, 7, ord('|')) for x in range(8, 80): stdscr.addch(19, x, ord('_')) for x in range(0, 80): stdscr.addch(22, x, ord('_')) return def seas(): stdscr.addch(4, 1, ord('S')) stdscr.addch(6, 1, ord('E')) stdscr.addch(8, 1, ord('A')) stdscr.addch(10, 1, ord('S')) stdscr.addch(12, 1, ord('O')) stdscr.addch(14, 1, ord('N')) stdscr.addch(16, 1, ord("'")) stdscr.addch(18, 1, ord('S')) return def greet(): stdscr.addch(3, 5, ord('G')) stdscr.addch(5, 5, ord('R')) stdscr.addch(7, 5, ord('E')) stdscr.addch(9, 5, ord('E')) stdscr.addch(11, 5, ord('T')) stdscr.addch(13, 5, ord('I')) stdscr.addch(15, 5, ord('N')) stdscr.addch(17, 5, ord('G')) stdscr.addch(19, 5, ord('S')) return def fromwho(): stdscr.addstr(21, 13, FROMWHO) return def tree(): set_color(treescrn, curses.COLOR_GREEN) treescrn.addch(1, 11, ord('/')) treescrn.addch(2, 11, ord('/')) treescrn.addch(3, 10, ord('/')) treescrn.addch(4, 9, ord('/')) treescrn.addch(5, 9, ord('/')) treescrn.addch(6, 8, ord('/')) treescrn.addch(7, 7, ord('/')) treescrn.addch(8, 6, ord('/')) treescrn.addch(9, 6, ord('/')) treescrn.addch(10, 5, ord('/')) treescrn.addch(11, 3, ord('/')) treescrn.addch(12, 2, ord('/')) treescrn.addch(1, 13, ord('\\')) treescrn.addch(2, 13, ord('\\')) treescrn.addch(3, 14, ord('\\')) treescrn.addch(4, 15, ord('\\')) treescrn.addch(5, 15, ord('\\')) treescrn.addch(6, 16, ord('\\')) treescrn.addch(7, 17, ord('\\')) treescrn.addch(8, 18, ord('\\')) treescrn.addch(9, 18, ord('\\')) treescrn.addch(10, 19, ord('\\')) treescrn.addch(11, 21, ord('\\')) treescrn.addch(12, 22, ord('\\')) treescrn.addch(4, 10, ord('_')) treescrn.addch(4, 14, ord('_')) treescrn.addch(8, 7, ord('_')) treescrn.addch(8, 17, ord('_')) treescrn.addstr(13, 0, "//////////// \\\\\\\\\\\\\\\\\\\\\\\\") treescrn.addstr(14, 11, "| |") treescrn.addstr(15, 11, "|_|") unset_color(treescrn) treescrn.refresh() w_del_msg.refresh() return def balls(): treescrn.overlay(treescrn2) set_color(treescrn2, curses.COLOR_BLUE) treescrn2.addch(3, 9, ord('@')) treescrn2.addch(3, 15, ord('@')) treescrn2.addch(4, 8, ord('@')) treescrn2.addch(4, 16, ord('@')) treescrn2.addch(5, 7, ord('@')) treescrn2.addch(5, 17, ord('@')) treescrn2.addch(7, 6, ord('@')) treescrn2.addch(7, 18, ord('@')) treescrn2.addch(8, 5, ord('@')) treescrn2.addch(8, 19, ord('@')) treescrn2.addch(10, 4, ord('@')) treescrn2.addch(10, 20, ord('@')) treescrn2.addch(11, 2, ord('@')) treescrn2.addch(11, 22, ord('@')) treescrn2.addch(12, 1, ord('@')) treescrn2.addch(12, 23, ord('@')) unset_color(treescrn2) treescrn2.refresh() w_del_msg.refresh() return def star(): treescrn2.attrset(curses.A_BOLD | curses.A_BLINK) set_color(treescrn2, curses.COLOR_YELLOW) treescrn2.addch(0, 12, ord('*')) treescrn2.standend() unset_color(treescrn2) treescrn2.refresh() w_del_msg.refresh() return def strng1(): treescrn2.attrset(curses.A_BOLD | curses.A_BLINK) set_color(treescrn2, curses.COLOR_WHITE) treescrn2.addch(3, 13, ord('\'')) treescrn2.addch(3, 12, ord(':')) treescrn2.addch(3, 11, ord('.')) treescrn2.attroff(curses.A_BOLD | curses.A_BLINK) unset_color(treescrn2) treescrn2.refresh() w_del_msg.refresh() return def strng2(): treescrn2.attrset(curses.A_BOLD | curses.A_BLINK) set_color(treescrn2, curses.COLOR_WHITE) treescrn2.addch(5, 14, ord('\'')) treescrn2.addch(5, 13, ord(':')) treescrn2.addch(5, 12, ord('.')) treescrn2.addch(5, 11, ord(',')) treescrn2.addch(6, 10, ord('\'')) treescrn2.addch(6, 9, ord(':')) treescrn2.attroff(curses.A_BOLD | curses.A_BLINK) unset_color(treescrn2) treescrn2.refresh() w_del_msg.refresh() return def strng3(): treescrn2.attrset(curses.A_BOLD | curses.A_BLINK) set_color(treescrn2, curses.COLOR_WHITE) treescrn2.addch(7, 16, ord('\'')) treescrn2.addch(7, 15, ord(':')) treescrn2.addch(7, 14, ord('.')) treescrn2.addch(7, 13, ord(',')) treescrn2.addch(8, 12, ord('\'')) treescrn2.addch(8, 11, ord(':')) treescrn2.addch(8, 10, ord('.')) treescrn2.addch(8, 9, ord(',')) treescrn2.attroff(curses.A_BOLD | curses.A_BLINK) unset_color(treescrn2) treescrn2.refresh() w_del_msg.refresh() return def strng4(): treescrn2.attrset(curses.A_BOLD | curses.A_BLINK) set_color(treescrn2, curses.COLOR_WHITE) treescrn2.addch(9, 17, ord('\'')) treescrn2.addch(9, 16, ord(':')) treescrn2.addch(9, 15, ord('.')) treescrn2.addch(9, 14, ord(',')) treescrn2.addch(10, 13, ord('\'')) treescrn2.addch(10, 12, ord(':')) treescrn2.addch(10, 11, ord('.')) treescrn2.addch(10, 10, ord(',')) treescrn2.addch(11, 9, ord('\'')) treescrn2.addch(11, 8, ord(':')) treescrn2.addch(11, 7, ord('.')) treescrn2.addch(11, 6, ord(',')) treescrn2.addch(12, 5, ord('\'')) treescrn2.attroff(curses.A_BOLD | curses.A_BLINK) unset_color(treescrn2) treescrn2.refresh() w_del_msg.refresh() return def strng5(): treescrn2.attrset(curses.A_BOLD | curses.A_BLINK) set_color(treescrn2, curses.COLOR_WHITE) treescrn2.addch(11, 19, ord('\'')) treescrn2.addch(11, 18, ord(':')) treescrn2.addch(11, 17, ord('.')) treescrn2.addch(11, 16, ord(',')) treescrn2.addch(12, 15, ord('\'')) treescrn2.addch(12, 14, ord(':')) treescrn2.addch(12, 13, ord('.')) treescrn2.addch(12, 12, ord(',')) treescrn2.attroff(curses.A_BOLD | curses.A_BLINK) unset_color(treescrn2) # save a fully lit tree treescrn2.overlay(treescrn) treescrn2.refresh() w_del_msg.refresh() return def blinkit(): treescrn8.touchwin() for cycle in range(0, 5): if cycle == 0: treescrn3.overlay(treescrn8) treescrn8.refresh() w_del_msg.refresh() break elif cycle == 1: treescrn4.overlay(treescrn8) treescrn8.refresh() w_del_msg.refresh() break elif cycle == 2: treescrn5.overlay(treescrn8) treescrn8.refresh() w_del_msg.refresh() break elif cycle == 3: treescrn6.overlay(treescrn8) treescrn8.refresh() w_del_msg.refresh() break elif cycle == 4: treescrn7.overlay(treescrn8) treescrn8.refresh() w_del_msg.refresh() break treescrn8.touchwin() # ALL ON treescrn.overlay(treescrn8) treescrn8.refresh() w_del_msg.refresh() return def deer_step(win, y, x): win.mvwin(y, x) win.refresh() w_del_msg.refresh() look_out(5) def reindeer(): y_pos = 0 for x_pos in range(70, 62, -1): if x_pos < 66: y_pos = 1 for looper in range(0, 4): dotdeer0.addch(y_pos, x_pos, ord('.')) dotdeer0.refresh() w_del_msg.refresh() dotdeer0.erase() dotdeer0.refresh() w_del_msg.refresh() look_out(50) y_pos = 2 for x_pos in range(x_pos - 1, 50, -1): for looper in range(0, 4): if x_pos < 56: y_pos = 3 try: stardeer0.addch(y_pos, x_pos, ord('*')) except curses.error: pass stardeer0.refresh() w_del_msg.refresh() stardeer0.erase() stardeer0.refresh() w_del_msg.refresh() else: dotdeer0.addch(y_pos, x_pos, ord('*')) dotdeer0.refresh() w_del_msg.refresh() dotdeer0.erase() dotdeer0.refresh() w_del_msg.refresh() x_pos = 58 for y_pos in range(2, 5): lildeer0.touchwin() lildeer0.refresh() w_del_msg.refresh() for looper in range(0, 4): deer_step(lildeer3, y_pos, x_pos) deer_step(lildeer2, y_pos, x_pos) deer_step(lildeer1, y_pos, x_pos) deer_step(lildeer2, y_pos, x_pos) deer_step(lildeer3, y_pos, x_pos) lildeer0.touchwin() lildeer0.refresh() w_del_msg.refresh() x_pos -= 2 x_pos = 35 for y_pos in range(5, 10): middeer0.touchwin() middeer0.refresh() w_del_msg.refresh() for looper in range(0, 2): deer_step(middeer3, y_pos, x_pos) deer_step(middeer2, y_pos, x_pos) deer_step(middeer1, y_pos, x_pos) deer_step(middeer2, y_pos, x_pos) deer_step(middeer3, y_pos, x_pos) middeer0.touchwin() middeer0.refresh() w_del_msg.refresh() x_pos -= 3 look_out(300) y_pos = 1 for x_pos in range(8, 16): deer_step(bigdeer4, y_pos, x_pos) deer_step(bigdeer3, y_pos, x_pos) deer_step(bigdeer2, y_pos, x_pos) deer_step(bigdeer1, y_pos, x_pos) deer_step(bigdeer2, y_pos, x_pos) deer_step(bigdeer3, y_pos, x_pos) deer_step(bigdeer4, y_pos, x_pos) deer_step(bigdeer0, y_pos, x_pos) x_pos -= 1 for looper in range(0, 6): deer_step(lookdeer4, y_pos, x_pos) deer_step(lookdeer3, y_pos, x_pos) deer_step(lookdeer2, y_pos, x_pos) deer_step(lookdeer1, y_pos, x_pos) deer_step(lookdeer2, y_pos, x_pos) deer_step(lookdeer3, y_pos, x_pos) deer_step(lookdeer4, y_pos, x_pos) deer_step(lookdeer0, y_pos, x_pos) for y_pos in range(y_pos, 10): for looper in range(0, 2): deer_step(bigdeer4, y_pos, x_pos) deer_step(bigdeer3, y_pos, x_pos) deer_step(bigdeer2, y_pos, x_pos) deer_step(bigdeer1, y_pos, x_pos) deer_step(bigdeer2, y_pos, x_pos) deer_step(bigdeer3, y_pos, x_pos) deer_step(bigdeer4, y_pos, x_pos) deer_step(bigdeer0, y_pos, x_pos) y_pos -= 1 deer_step(lookdeer3, y_pos, x_pos) return def main(win): global stdscr stdscr = win global my_bg, y_pos, x_pos global treescrn, treescrn2, treescrn3, treescrn4 global treescrn5, treescrn6, treescrn7, treescrn8 global dotdeer0, stardeer0 global lildeer0, lildeer1, lildeer2, lildeer3 global middeer0, middeer1, middeer2, middeer3 global bigdeer0, bigdeer1, bigdeer2, bigdeer3, bigdeer4 global lookdeer0, lookdeer1, lookdeer2, lookdeer3, lookdeer4 global w_holiday, w_del_msg my_bg = curses.COLOR_BLACK # curses.curs_set(0) treescrn = curses.newwin(16, 27, 3, 53) treescrn2 = curses.newwin(16, 27, 3, 53) treescrn3 = curses.newwin(16, 27, 3, 53) treescrn4 = curses.newwin(16, 27, 3, 53) treescrn5 = curses.newwin(16, 27, 3, 53) treescrn6 = curses.newwin(16, 27, 3, 53) treescrn7 = curses.newwin(16, 27, 3, 53) treescrn8 = curses.newwin(16, 27, 3, 53) dotdeer0 = curses.newwin(3, 71, 0, 8) stardeer0 = curses.newwin(4, 56, 0, 8) lildeer0 = curses.newwin(7, 53, 0, 8) lildeer1 = curses.newwin(2, 4, 0, 0) lildeer2 = curses.newwin(2, 4, 0, 0) lildeer3 = curses.newwin(2, 4, 0, 0) middeer0 = curses.newwin(15, 42, 0, 8) middeer1 = curses.newwin(3, 7, 0, 0) middeer2 = curses.newwin(3, 7, 0, 0) middeer3 = curses.newwin(3, 7, 0, 0) bigdeer0 = curses.newwin(10, 23, 0, 0) bigdeer1 = curses.newwin(10, 23, 0, 0) bigdeer2 = curses.newwin(10, 23, 0, 0) bigdeer3 = curses.newwin(10, 23, 0, 0) bigdeer4 = curses.newwin(10, 23, 0, 0) lookdeer0 = curses.newwin(10, 25, 0, 0) lookdeer1 = curses.newwin(10, 25, 0, 0) lookdeer2 = curses.newwin(10, 25, 0, 0) lookdeer3 = curses.newwin(10, 25, 0, 0) lookdeer4 = curses.newwin(10, 25, 0, 0) w_holiday = curses.newwin(1, 27, 3, 27) w_del_msg = curses.newwin(1, 20, 23, 60) try: w_del_msg.addstr(0, 0, "Hit any key to quit") except curses.error: pass try: w_holiday.addstr(0, 0, "H A P P Y H O L I D A Y S") except curses.error: pass # set up the windows for our various reindeer lildeer1.addch(0, 0, ord('V')) lildeer1.addch(1, 0, ord('@')) lildeer1.addch(1, 1, ord('<')) lildeer1.addch(1, 2, ord('>')) try: lildeer1.addch(1, 3, ord('~')) except curses.error: pass lildeer2.addch(0, 0, ord('V')) lildeer2.addch(1, 0, ord('@')) lildeer2.addch(1, 1, ord('|')) lildeer2.addch(1, 2, ord('|')) try: lildeer2.addch(1, 3, ord('~')) except curses.error: pass lildeer3.addch(0, 0, ord('V')) lildeer3.addch(1, 0, ord('@')) lildeer3.addch(1, 1, ord('>')) lildeer3.addch(1, 2, ord('<')) try: lildeer2.addch(1, 3, ord('~')) # XXX except curses.error: pass middeer1.addch(0, 2, ord('y')) middeer1.addch(0, 3, ord('y')) middeer1.addch(1, 2, ord('0')) middeer1.addch(1, 3, ord('(')) middeer1.addch(1, 4, ord('=')) middeer1.addch(1, 5, ord(')')) middeer1.addch(1, 6, ord('~')) middeer1.addch(2, 3, ord('\\')) middeer1.addch(2, 5, ord('/')) middeer2.addch(0, 2, ord('y')) middeer2.addch(0, 3, ord('y')) middeer2.addch(1, 2, ord('0')) middeer2.addch(1, 3, ord('(')) middeer2.addch(1, 4, ord('=')) middeer2.addch(1, 5, ord(')')) middeer2.addch(1, 6, ord('~')) middeer2.addch(2, 3, ord('|')) middeer2.addch(2, 5, ord('|')) middeer3.addch(0, 2, ord('y')) middeer3.addch(0, 3, ord('y')) middeer3.addch(1, 2, ord('0')) middeer3.addch(1, 3, ord('(')) middeer3.addch(1, 4, ord('=')) middeer3.addch(1, 5, ord(')')) middeer3.addch(1, 6, ord('~')) middeer3.addch(2, 3, ord('/')) middeer3.addch(2, 5, ord('\\')) bigdeer1.addch(0, 17, ord('\\')) bigdeer1.addch(0, 18, ord('/')) bigdeer1.addch(0, 19, ord('\\')) bigdeer1.addch(0, 20, ord('/')) bigdeer1.addch(1, 18, ord('\\')) bigdeer1.addch(1, 20, ord('/')) bigdeer1.addch(2, 19, ord('|')) bigdeer1.addch(2, 20, ord('_')) bigdeer1.addch(3, 18, ord('/')) bigdeer1.addch(3, 19, ord('^')) bigdeer1.addch(3, 20, ord('0')) bigdeer1.addch(3, 21, ord('\\')) bigdeer1.addch(4, 17, ord('/')) bigdeer1.addch(4, 18, ord('/')) bigdeer1.addch(4, 19, ord('\\')) bigdeer1.addch(4, 22, ord('\\')) bigdeer1.addstr(5, 7, "^~~~~~~~~// ~~U") bigdeer1.addstr(6, 7, "( \\_____( /") # )) bigdeer1.addstr(7, 8, "( ) /") bigdeer1.addstr(8, 9, "\\\\ /") bigdeer1.addstr(9, 11, "\\>/>") bigdeer2.addch(0, 17, ord('\\')) bigdeer2.addch(0, 18, ord('/')) bigdeer2.addch(0, 19, ord('\\')) bigdeer2.addch(0, 20, ord('/')) bigdeer2.addch(1, 18, ord('\\')) bigdeer2.addch(1, 20, ord('/')) bigdeer2.addch(2, 19, ord('|')) bigdeer2.addch(2, 20, ord('_')) bigdeer2.addch(3, 18, ord('/')) bigdeer2.addch(3, 19, ord('^')) bigdeer2.addch(3, 20, ord('0')) bigdeer2.addch(3, 21, ord('\\')) bigdeer2.addch(4, 17, ord('/')) bigdeer2.addch(4, 18, ord('/')) bigdeer2.addch(4, 19, ord('\\')) bigdeer2.addch(4, 22, ord('\\')) bigdeer2.addstr(5, 7, "^~~~~~~~~// ~~U") bigdeer2.addstr(6, 7, "(( )____( /") # )) bigdeer2.addstr(7, 7, "( / |") bigdeer2.addstr(8, 8, "\\/ |") bigdeer2.addstr(9, 9, "|> |>") bigdeer3.addch(0, 17, ord('\\')) bigdeer3.addch(0, 18, ord('/')) bigdeer3.addch(0, 19, ord('\\')) bigdeer3.addch(0, 20, ord('/')) bigdeer3.addch(1, 18, ord('\\')) bigdeer3.addch(1, 20, ord('/')) bigdeer3.addch(2, 19, ord('|')) bigdeer3.addch(2, 20, ord('_')) bigdeer3.addch(3, 18, ord('/')) bigdeer3.addch(3, 19, ord('^')) bigdeer3.addch(3, 20, ord('0')) bigdeer3.addch(3, 21, ord('\\')) bigdeer3.addch(4, 17, ord('/')) bigdeer3.addch(4, 18, ord('/')) bigdeer3.addch(4, 19, ord('\\')) bigdeer3.addch(4, 22, ord('\\')) bigdeer3.addstr(5, 7, "^~~~~~~~~// ~~U") bigdeer3.addstr(6, 6, "( ()_____( /") # )) bigdeer3.addstr(7, 6, "/ / /") bigdeer3.addstr(8, 5, "|/ \\") bigdeer3.addstr(9, 5, "/> \\>") bigdeer4.addch(0, 17, ord('\\')) bigdeer4.addch(0, 18, ord('/')) bigdeer4.addch(0, 19, ord('\\')) bigdeer4.addch(0, 20, ord('/')) bigdeer4.addch(1, 18, ord('\\')) bigdeer4.addch(1, 20, ord('/')) bigdeer4.addch(2, 19, ord('|')) bigdeer4.addch(2, 20, ord('_')) bigdeer4.addch(3, 18, ord('/')) bigdeer4.addch(3, 19, ord('^')) bigdeer4.addch(3, 20, ord('0')) bigdeer4.addch(3, 21, ord('\\')) bigdeer4.addch(4, 17, ord('/')) bigdeer4.addch(4, 18, ord('/')) bigdeer4.addch(4, 19, ord('\\')) bigdeer4.addch(4, 22, ord('\\')) bigdeer4.addstr(5, 7, "^~~~~~~~~// ~~U") bigdeer4.addstr(6, 6, "( )______( /") # ) bigdeer4.addstr(7, 5, "(/ \\") # ) bigdeer4.addstr(8, 0, "v___= ----^") lookdeer1.addstr(0, 16, "\\/ \\/") lookdeer1.addstr(1, 17, "\\Y/ \\Y/") lookdeer1.addstr(2, 19, "\\=/") lookdeer1.addstr(3, 17, "^\\o o/^") lookdeer1.addstr(4, 17, "//( )") lookdeer1.addstr(5, 7, "^~~~~~~~~// \\O/") lookdeer1.addstr(6, 7, "( \\_____( /") # )) lookdeer1.addstr(7, 8, "( ) /") lookdeer1.addstr(8, 9, "\\\\ /") lookdeer1.addstr(9, 11, "\\>/>") lookdeer2.addstr(0, 16, "\\/ \\/") lookdeer2.addstr(1, 17, "\\Y/ \\Y/") lookdeer2.addstr(2, 19, "\\=/") lookdeer2.addstr(3, 17, "^\\o o/^") lookdeer2.addstr(4, 17, "//( )") lookdeer2.addstr(5, 7, "^~~~~~~~~// \\O/") lookdeer2.addstr(6, 7, "(( )____( /") # )) lookdeer2.addstr(7, 7, "( / |") lookdeer2.addstr(8, 8, "\\/ |") lookdeer2.addstr(9, 9, "|> |>") lookdeer3.addstr(0, 16, "\\/ \\/") lookdeer3.addstr(1, 17, "\\Y/ \\Y/") lookdeer3.addstr(2, 19, "\\=/") lookdeer3.addstr(3, 17, "^\\o o/^") lookdeer3.addstr(4, 17, "//( )") lookdeer3.addstr(5, 7, "^~~~~~~~~// \\O/") lookdeer3.addstr(6, 6, "( ()_____( /") # )) lookdeer3.addstr(7, 6, "/ / /") lookdeer3.addstr(8, 5, "|/ \\") lookdeer3.addstr(9, 5, "/> \\>") lookdeer4.addstr(0, 16, "\\/ \\/") lookdeer4.addstr(1, 17, "\\Y/ \\Y/") lookdeer4.addstr(2, 19, "\\=/") lookdeer4.addstr(3, 17, "^\\o o/^") lookdeer4.addstr(4, 17, "//( )") lookdeer4.addstr(5, 7, "^~~~~~~~~// \\O/") lookdeer4.addstr(6, 6, "( )______( /") # ) lookdeer4.addstr(7, 5, "(/ \\") # ) lookdeer4.addstr(8, 0, "v___= ----^") ############################################### curses.cbreak() stdscr.nodelay(1) while 1: stdscr.clear() treescrn.erase() w_del_msg.touchwin() treescrn.touchwin() treescrn2.erase() treescrn2.touchwin() treescrn8.erase() treescrn8.touchwin() stdscr.refresh() look_out(150) boxit() stdscr.refresh() look_out(150) seas() stdscr.refresh() greet() stdscr.refresh() look_out(150) fromwho() stdscr.refresh() look_out(150) tree() look_out(150) balls() look_out(150) star() look_out(150) strng1() strng2() strng3() strng4() strng5() # set up the windows for our blinking trees # # treescrn3 treescrn.overlay(treescrn3) # balls treescrn3.addch(4, 18, ord(' ')) treescrn3.addch(7, 6, ord(' ')) treescrn3.addch(8, 19, ord(' ')) treescrn3.addch(11, 22, ord(' ')) # star treescrn3.addch(0, 12, ord('*')) # strng1 treescrn3.addch(3, 11, ord(' ')) # strng2 treescrn3.addch(5, 13, ord(' ')) treescrn3.addch(6, 10, ord(' ')) # strng3 treescrn3.addch(7, 16, ord(' ')) treescrn3.addch(7, 14, ord(' ')) # strng4 treescrn3.addch(10, 13, ord(' ')) treescrn3.addch(10, 10, ord(' ')) treescrn3.addch(11, 8, ord(' ')) # strng5 treescrn3.addch(11, 18, ord(' ')) treescrn3.addch(12, 13, ord(' ')) # treescrn4 treescrn.overlay(treescrn4) # balls treescrn4.addch(3, 9, ord(' ')) treescrn4.addch(4, 16, ord(' ')) treescrn4.addch(7, 6, ord(' ')) treescrn4.addch(8, 19, ord(' ')) treescrn4.addch(11, 2, ord(' ')) treescrn4.addch(12, 23, ord(' ')) # star treescrn4.standout() treescrn4.addch(0, 12, ord('*')) treescrn4.standend() # strng1 treescrn4.addch(3, 13, ord(' ')) # strng2 # strng3 treescrn4.addch(7, 15, ord(' ')) treescrn4.addch(8, 11, ord(' ')) # strng4 treescrn4.addch(9, 16, ord(' ')) treescrn4.addch(10, 12, ord(' ')) treescrn4.addch(11, 8, ord(' ')) # strng5 treescrn4.addch(11, 18, ord(' ')) treescrn4.addch(12, 14, ord(' ')) # treescrn5 treescrn.overlay(treescrn5) # balls treescrn5.addch(3, 15, ord(' ')) treescrn5.addch(10, 20, ord(' ')) treescrn5.addch(12, 1, ord(' ')) # star treescrn5.addch(0, 12, ord(' ')) # strng1 treescrn5.addch(3, 11, ord(' ')) # strng2 treescrn5.addch(5, 12, ord(' ')) # strng3 treescrn5.addch(7, 14, ord(' ')) treescrn5.addch(8, 10, ord(' ')) # strng4 treescrn5.addch(9, 15, ord(' ')) treescrn5.addch(10, 11, ord(' ')) treescrn5.addch(11, 7, ord(' ')) # strng5 treescrn5.addch(11, 17, ord(' ')) treescrn5.addch(12, 13, ord(' ')) # treescrn6 treescrn.overlay(treescrn6) # balls treescrn6.addch(6, 7, ord(' ')) treescrn6.addch(7, 18, ord(' ')) treescrn6.addch(10, 4, ord(' ')) treescrn6.addch(11, 23, ord(' ')) # star treescrn6.standout() treescrn6.addch(0, 12, ord('*')) treescrn6.standend() # strng1 # strng2 treescrn6.addch(5, 11, ord(' ')) # strng3 treescrn6.addch(7, 13, ord(' ')) treescrn6.addch(8, 9, ord(' ')) # strng4 treescrn6.addch(9, 14, ord(' ')) treescrn6.addch(10, 10, ord(' ')) treescrn6.addch(11, 6, ord(' ')) # strng5 treescrn6.addch(11, 16, ord(' ')) treescrn6.addch(12, 12, ord(' ')) # treescrn7 treescrn.overlay(treescrn7) # balls treescrn7.addch(3, 15, ord(' ')) treescrn7.addch(6, 7, ord(' ')) treescrn7.addch(7, 18, ord(' ')) treescrn7.addch(10, 4, ord(' ')) treescrn7.addch(11, 22, ord(' ')) # star treescrn7.addch(0, 12, ord('*')) # strng1 treescrn7.addch(3, 12, ord(' ')) # strng2 treescrn7.addch(5, 13, ord(' ')) treescrn7.addch(6, 9, ord(' ')) # strng3 treescrn7.addch(7, 15, ord(' ')) treescrn7.addch(8, 11, ord(' ')) # strng4 treescrn7.addch(9, 16, ord(' ')) treescrn7.addch(10, 12, ord(' ')) treescrn7.addch(11, 8, ord(' ')) # strng5 treescrn7.addch(11, 18, ord(' ')) treescrn7.addch(12, 14, ord(' ')) look_out(150) reindeer() w_holiday.touchwin() w_holiday.refresh() w_del_msg.refresh() look_out(500) for i in range(0, 20): blinkit() curses.wrapper(main) Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/curses/README,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** README 2000/12/15 00:41:48 1.2 --- README 2000/12/21 16:26:37 1.3 *************** *** 15,18 **** --- 15,19 ---- rain.py -- raindrops keep falling on my desktop tclock.py -- ASCII clock, by Howard Jones + xmas.py -- I'm dreaming of an ASCII christmas Please send bugfixes and new contributions to me or, even better, From python-dev@python.org Fri Dec 22 14:39:12 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 06:39:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.46,2.47 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv6312 Modified Files: _sre.c Log Message: Fix bug 126587: matchobject.groupdict() leaks memory because of a missing DECREF Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.46 retrieving revision 2.47 diff -C2 -r2.46 -r2.47 *** _sre.c 2000/10/28 19:30:40 2.46 --- _sre.c 2000/12/22 14:39:10 2.47 *************** *** 1997,2000 **** --- 1997,2001 ---- /* FIXME: this can fail, right? */ PyDict_SetItem(result, key, item); + Py_DECREF(item); } From python-dev@python.org Fri Dec 22 20:35:22 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 12:35:22 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0222.txt,1.7,1.8 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv2267 Modified Files: pep-0222.txt Log Message: Fill out the proposed interface some more. Remove some items that have been taken care of. Index: pep-0222.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0222.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** pep-0222.txt 2000/12/18 03:01:23 1.7 --- pep-0222.txt 2000/12/22 20:35:20 1.8 *************** *** 7,11 **** Python-Version: 2.1 Created: 18-Aug-2000 ! Post-History: --- 7,11 ---- Python-Version: 2.1 Created: 18-Aug-2000 ! Post-History: 22-Dec-2000 *************** *** 22,26 **** ! Proposed Changes This section lists changes that have been suggested, but about --- 22,26 ---- ! Open Issues This section lists changes that have been suggested, but about *************** *** 29,48 **** be classified as accepted or rejected. - fcgi.py : A new module adding support for the FastCGI protocol. - Robin Dunn's code needs to be ported to Windows, though. - - Better debugging support for CGIs from the Unix command line. - Using Perl's CGI.pm [1], if you run a script from the command - line, you can enter name=value pairs on standard input. - cgimodel [2] provides this already. - - Should the existing cgi.py be deprecated and everything moved into - a 'web' or 'cgi' package? That would allow removing some - backward-compatibility cruft. - - cgi.py: keep_blank_values should be on by default. The 'if - form.has_key()/if form[key].value' nested syntax is unnecessarily - convoluted. - cgi.py: We should not be told to create our own subclass just so we can handle file uploads. As a practical matter, I have yet to --- 29,32 ---- *************** *** 53,76 **** with its __init__ call and associated overhead. - cgi.py: Ideally, the pseudo-dictionary syntax would go away. It - seems to me that the main reason it is there is to accomodate - - form['field'].file syntax. How about the following: - form['field'] = '' #no values for key - form['field'] = 'string' #one value in submission for key - form['field'] = ['string', 'string', ....] #multiple values - form['field'] = {'fileName':'remote/path', - 'binaryValue':'@UIHJBV29489erht...'} #one file - form['field'] = [{'fileName':'remote/path', - 'binaryValue':'@UIHJBV29489erht...'}, - {'fileName':'another/path', - 'binaryValue':'7r7w7@@@@'}] #multiple files - - cgi.py: I'd prefer "input" or "submission" for the suggested - FieldStorage() name. The html page into which the data represented - by FieldStorage() is input is commonly known as a "form", which - means that when someone refers to "the form" you aren't always - sure what they are talking about. - cgi.py: Currently, query data with no `=' are ignored. Even if keep_blank_values is set, queries like `...?value=&...' are --- 37,40 ---- *************** *** 82,88 **** Utility function: build a query string from a list of 2-tuples - Higher-level frameworks: add something like Webware or Zope's - HTTPReqest/HTTPResponse objects. - Dictionary-related utility classes: NoKeyErrors (returns an empty string, never a KeyError), PartialStringSubstitution (returns --- 46,49 ---- *************** *** 96,99 **** --- 57,62 ---- that should be added to the Python standard library. + * fcgi.py : A new module adding support for the FastCGI protocol. + Robin Dunn's code needs to be ported to Windows, though. Major Changes to Existing Modules *************** *** 103,107 **** section therefore carry greater degrees of risk, either in introducing bugs or a backward incompatibility. ! Minor Changes to Existing Modules --- 66,72 ---- section therefore carry greater degrees of risk, either in introducing bugs or a backward incompatibility. ! ! The cgi.py module would be deprecated. (XXX A new module or ! package name hasn't been chosen yet: 'web'? 'cgilib'?) Minor Changes to Existing Modules *************** *** 133,144 **** Proposed Interface ! XXX open issues: naming convention (studlycaps or underline-separated?); ! no interface for file uploads yet; need to look at all the various ! packages to see if there's anything else missing; need to look at ! the cgi.parse*() functions and see if they can be simplified, too. ! XXX file uploads ! ! Parsing functions: carry over most of the parse* functions from cgi.py # The Response class borrows most of its methods from Zope's --- 98,107 ---- Proposed Interface ! XXX open issues: naming convention (studlycaps or ! underline-separated?); need to look at the cgi.parse*() functions ! and see if they can be simplified, too. ! Parsing functions: carry over most of the parse* functions from ! cgi.py # The Response class borrows most of its methods from Zope's *************** *** 169,178 **** def setCookie(self, name, value, ! path = XXX, # What to use as defaults? ! comment = XXX, ! domain = XXX, ! max-age = XXX, ! expires = XXX, ! secure = XXX ): "Set a cookie" --- 132,141 ---- def setCookie(self, name, value, ! path = '/', ! comment = None, ! domain = None, ! max-age = None, ! expires = None, ! secure = 0 ): "Set a cookie" *************** *** 195,199 **** pass ! # XXX methods for specific classes of error:serverError, badRequest, etc.? --- 158,163 ---- pass ! # XXX methods for specific classes of error:serverError, ! # badRequest, etc.? *************** *** 201,213 **** """ ! Attributes: .headers : dictionary containing HTTP headers .cookies : dictionary of cookies ! .form : data from the form .env : environment dictionary """ def __init__(self, environ=os.environ, stdin=sys.stdin, ! keep_blank_values=0, strict_parsing=0): """Initialize the request object, using the provided environment and standard input.""" --- 165,179 ---- """ ! Attributes: ! ! XXX should these be dictionaries, or dictionary-like objects? .headers : dictionary containing HTTP headers .cookies : dictionary of cookies ! .fields : data from the form .env : environment dictionary """ def __init__(self, environ=os.environ, stdin=sys.stdin, ! keep_blank_values=1, strict_parsing=0): """Initialize the request object, using the provided environment and standard input.""" *************** *** 222,231 **** def getField(self, name, default=None): pass ! def getURL(self, n=0, query_string=0): """Return the URL of the current request, chopping off 'n' path components from the right. Eg. if the URL is ! "http://foo.com/bar/baz/qux", n=2 would return "http://foo.com/bar". Does not include the query string (if any) --- 188,205 ---- def getField(self, name, default=None): + "Return field's value as a string (even if it's an uploaded file)" pass ! ! def getUploadedFile(self, name): ! """Returns a file object that can be read to obtain the contents ! of an uploaded file. XXX should this report an error if the ! field isn't actually an uploaded file? Or should it wrap ! a StringIO around simple fields for consistency? ! """ ! def getURL(self, n=0, query_string=0): """Return the URL of the current request, chopping off 'n' path components from the right. Eg. if the URL is ! "http://foo.com/bar/baz/quux", n=2 would return "http://foo.com/bar". Does not include the query string (if any) *************** *** 247,251 **** pass ! # Possibilities? def getBrowser(self): "Returns Mozilla/IE/Lynx/Opera/whatever" --- 221,226 ---- pass ! # Possibilities? I don't know if these are worth doing in the ! # basic objects. def getBrowser(self): "Returns Mozilla/IE/Lynx/Opera/whatever" *************** *** 254,259 **** "Return true if this is an SSLified request" ! ! def wrapper(func, logfile=None): """ Calls the function 'func', passing it the arguments --- 229,235 ---- "Return true if this is an SSLified request" ! ! # Module-level function ! def wrapper(func, logfile=sys.stderr): """ Calls the function 'func', passing it the arguments *************** *** 261,265 **** sent to the file 'logfile'. """ ! pass --- 237,244 ---- sent to the file 'logfile'. """ ! # This wrapper will detect if it's being called from the command-line, ! # and if so, it will run in a debugging mode; name=value pairs ! # can be entered on standard input to set field values. ! # (XXX how to do file uploads in this syntax?) *************** *** 267,277 **** This document has been placed in the public domain. - - - References and Footnotes - - [1] CGI.pm: - - [2] http://www.embl-heidelberg.de/~chenna/pythonpages/ --- 246,249 ---- From python-dev@python.org Fri Dec 22 21:50:03 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 13:50:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Demo/curses ncurses.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/curses In directory usw-pr-cvs1:/tmp/cvs-serv19559 Modified Files: ncurses.py Log Message: Update this demo to use curses.panel Index: ncurses.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/curses/ncurses.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** ncurses.py 2000/12/15 00:41:48 1.1 --- ncurses.py 2000/12/22 21:50:01 1.2 *************** *** 7,10 **** --- 7,11 ---- import curses + from curses import panel def wGetchar(win = None): *************** *** 31,35 **** def mkpanel(color, rows, cols, tly, tlx): win = curses.newwin(rows, cols, tly, tlx) ! pan = win.new_panel() if curses.has_colors(): if color == curses.COLOR_BLUE: --- 32,36 ---- def mkpanel(color, rows, cols, tly, tlx): win = curses.newwin(rows, cols, tly, tlx) ! pan = panel.new_panel(win) if curses.has_colors(): if color == curses.COLOR_BLUE: *************** *** 46,50 **** def pflush(): ! curses.update_panels() curses.doupdate() --- 47,51 ---- def pflush(): ! panel.update_panels() curses.doupdate() From python-dev@python.org Fri Dec 22 21:51:12 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 13:51:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include py_curses.h,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv19666 Added Files: py_curses.h Log Message: Added header file for C API exported by _cursesmodule.c --- NEW FILE: py_curses.h --- #ifndef Py_CURSES_H #define Py_CURSES_H #ifdef HAVE_NCURSES_H #include #else #include #endif #ifdef __cplusplus extern "C" { #endif #define PyCurses_API_pointers 4 /* Type declarations */ typedef struct { PyObject_HEAD WINDOW *win; } PyCursesWindowObject; #define PyCursesWindow_Check(v) ((v)->ob_type == &PyCursesWindow_Type) #ifdef CURSES_MODULE /* This section is used when compiling _cursesmodule.c */ #else /* This section is used in modules that use the _cursesmodule API */ static void **PyCurses_API; #define PyCursesWindow_Type (*(PyTypeObject *) PyCurses_API[0]) #define PyCursesSetupTermCalled {if (! ((int (*)(void))PyCurses_API[1]) () ) return NULL;} #define PyCursesInitialised {if (! ((int (*)(void))PyCurses_API[2]) () ) return NULL;} #define PyCursesInitialisedColor {if (! ((int (*)(void))PyCurses_API[3]) () ) return NULL;} #define import_curses() \ { \ PyObject *module = PyImport_ImportModule("_curses"); \ if (module != NULL) { \ PyObject *module_dict = PyModule_GetDict(module); \ PyObject *c_api_object = PyDict_GetItemString(module_dict, "_C_API"); \ if (PyCObject_Check(c_api_object)) { \ PyCurses_API = (void **)PyCObject_AsVoidPtr(c_api_object); \ } \ } \ } #endif /* general error messages */ static char *catchall_ERR = "curses function returned ERR"; static char *catchall_NULL = "curses function returned NULL"; /* Utility macros */ #define ARG_COUNT(X) \ (((X) == NULL) ? 0 : (PyTuple_Check(X) ? PyTuple_Size(X) : 1)) /* Function Prototype Macros - They are ugly but very, very useful. ;-) X - function name TYPE - parameter Type ERGSTR - format string for construction of the return value PARSESTR - format string for argument parsing */ #define NoArgNoReturnFunction(X) \ static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ { \ PyCursesInitialised \ if (!PyArg_NoArgs(args)) return NULL; \ return PyCursesCheckERR(X(), # X); } #define NoArgOrFlagNoReturnFunction(X) \ static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ { \ int flag = 0; \ PyCursesInitialised \ switch(ARG_COUNT(args)) { \ case 0: \ return PyCursesCheckERR(X(), # X); \ case 1: \ if (!PyArg_Parse(args, "i;True(1) or False(0)", &flag)) return NULL; \ if (flag) return PyCursesCheckERR(X(), # X); \ else return PyCursesCheckERR(no ## X (), # X); \ default: \ PyErr_SetString(PyExc_TypeError, # X " requires 0 or 1 arguments"); \ return NULL; } } #define NoArgReturnIntFunction(X) \ static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ { \ PyCursesInitialised \ if (!PyArg_NoArgs(args)) return NULL; \ return PyInt_FromLong((long) X()); } #define NoArgReturnStringFunction(X) \ static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ { \ PyCursesInitialised \ if (!PyArg_NoArgs(args)) return NULL; \ return PyString_FromString(X()); } #define NoArgTrueFalseFunction(X) \ static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ { \ PyCursesInitialised \ if (!PyArg_NoArgs(args)) return NULL; \ if (X () == FALSE) { \ Py_INCREF(Py_False); \ return Py_False; \ } \ Py_INCREF(Py_True); \ return Py_True; } #define NoArgNoReturnVoidFunction(X) \ static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ { \ PyCursesInitialised \ if (!PyArg_NoArgs(args)) return NULL; \ X(); \ Py_INCREF(Py_None); \ return Py_None; } #ifdef __cplusplus } #endif #endif /* !defined(Py_CURSES_H) */ From python-dev@python.org Fri Dec 22 21:52:30 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 13:52:30 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.44,2.45 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv19738 Modified Files: _cursesmodule.c Log Message: Export C API from this module. Remove several macros and #includes; py_curses.h contains them now. Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.44 retrieving revision 2.45 diff -C2 -r2.44 -r2.45 *** _cursesmodule.c 2000/12/21 16:22:22 2.44 --- _cursesmodule.c 2000/12/22 21:52:27 2.45 *************** *** 96,104 **** /* Release Number */ ! char *PyCursesVersion = "1.6"; /* Includes */ #include "Python.h" #ifdef __osf__ --- 96,106 ---- /* Release Number */ ! char *PyCursesVersion = "2.1"; /* Includes */ #include "Python.h" + #define CURSES_MODULE + #include "py_curses.h" #ifdef __osf__ *************** *** 107,116 **** #endif - #ifdef HAVE_NCURSES_H - #include - #else - #include - #endif - /* These prototypes are in , but including this header #defines many common symbols (such as "lines") which breaks the --- 109,112 ---- *************** *** 131,138 **** static PyObject *PyCursesError; - /* general error messages */ - static char *catchall_ERR = "curses function returned ERR"; - static char *catchall_NULL = "curses function returned NULL"; - /* Tells whether setupterm() has been called to initialise terminfo. */ static int initialised_setupterm = FALSE; --- 127,130 ---- *************** *** 141,156 **** static int initialised = FALSE; ! /* Tells whether start_color() has been called to initialise colorusage. */ static int initialisedcolors = FALSE; /* Utility Macros */ - #define ARG_COUNT(X) \ - (((X) == NULL) ? 0 : (PyTuple_Check(X) ? PyTuple_Size(X) : 1)) - #define PyCursesSetupTermCalled \ if (initialised_setupterm != TRUE) { \ PyErr_SetString(PyCursesError, \ "must call (at least) setupterm() first"); \ ! return NULL; } #define PyCursesInitialised \ --- 133,145 ---- static int initialised = FALSE; ! /* Tells whether start_color() has been called to initialise color usage. */ static int initialisedcolors = FALSE; /* Utility Macros */ #define PyCursesSetupTermCalled \ if (initialised_setupterm != TRUE) { \ PyErr_SetString(PyCursesError, \ "must call (at least) setupterm() first"); \ ! return 0; } #define PyCursesInitialised \ *************** *** 158,162 **** PyErr_SetString(PyCursesError, \ "must call initscr() first"); \ ! return NULL; } #define PyCursesInitialisedColor \ --- 147,151 ---- PyErr_SetString(PyCursesError, \ "must call initscr() first"); \ ! return 0; } #define PyCursesInitialisedColor \ *************** *** 164,168 **** PyErr_SetString(PyCursesError, \ "must call start_color() first"); \ ! return NULL; } /* Utility Functions */ --- 153,157 ---- PyErr_SetString(PyCursesError, \ "must call start_color() first"); \ ! return 0; } /* Utility Functions */ *************** *** 170,174 **** /* * Check the return code from a curses function and return None ! * or raise an exception as appropriate. */ --- 159,164 ---- /* * Check the return code from a curses function and return None ! * or raise an exception as appropriate. These are exported using the ! * CObject API. */ *************** *** 203,223 **** } /***************************************************************************** The Window Object ******************************************************************************/ - - /* Definition of the window object and window type */ ! typedef struct { ! PyObject_HEAD ! WINDOW *win; ! } PyCursesWindowObject; PyTypeObject PyCursesWindow_Type; ! #define PyCursesWindow_Check(v) ((v)->ob_type == &PyCursesWindow_Type) - /* Function Prototype Macros - They are ugly but very, very useful. ;-) - X - function name TYPE - parameter Type --- 193,227 ---- } + /* Function versions of the 3 functions for tested whether curses has been + initialised or not. */ + + static int func_PyCursesSetupTermCalled(void) + { + PyCursesSetupTermCalled; + return 1; + } + + static int func_PyCursesInitialised(void) + { + PyCursesInitialised; + return 1; + } + + static int func_PyCursesInitialisedColor(void) + { + PyCursesInitialisedColor; + return 1; + } + /***************************************************************************** The Window Object ******************************************************************************/ ! /* Definition of the window type */ PyTypeObject PyCursesWindow_Type; ! /* Function prototype macros for Window object X - function name TYPE - parameter Type *************** *** 1459,1531 **** **********************************************************************/ - static PyObject *ModDict; - - /* Function Prototype Macros - They are ugly but very, very useful. ;-) - - X - function name - TYPE - parameter Type - ERGSTR - format string for construction of the return value - PARSESTR - format string for argument parsing - */ - - #define NoArgNoReturnFunction(X) \ - static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ - { \ - PyCursesInitialised \ - if (!PyArg_NoArgs(args)) return NULL; \ - return PyCursesCheckERR(X(), # X); } - - #define NoArgOrFlagNoReturnFunction(X) \ - static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ - { \ - int flag = 0; \ - PyCursesInitialised \ - switch(ARG_COUNT(args)) { \ - case 0: \ - return PyCursesCheckERR(X(), # X); \ - case 1: \ - if (!PyArg_Parse(args, "i;True(1) or False(0)", &flag)) return NULL; \ - if (flag) return PyCursesCheckERR(X(), # X); \ - else return PyCursesCheckERR(no ## X (), # X); \ - default: \ - PyErr_SetString(PyExc_TypeError, # X " requires 0 or 1 arguments"); \ - return NULL; } } - - #define NoArgReturnIntFunction(X) \ - static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ - { \ - PyCursesInitialised \ - if (!PyArg_NoArgs(args)) return NULL; \ - return PyInt_FromLong((long) X()); } - - - #define NoArgReturnStringFunction(X) \ - static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ - { \ - PyCursesInitialised \ - if (!PyArg_NoArgs(args)) return NULL; \ - return PyString_FromString(X()); } - - #define NoArgTrueFalseFunction(X) \ - static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ - { \ - PyCursesInitialised \ - if (!PyArg_NoArgs(args)) return NULL; \ - if (X () == FALSE) { \ - Py_INCREF(Py_False); \ - return Py_False; \ - } \ - Py_INCREF(Py_True); \ - return Py_True; } - - #define NoArgNoReturnVoidFunction(X) \ - static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ - { \ - PyCursesInitialised \ - if (!PyArg_NoArgs(args)) return NULL; \ - X(); \ - Py_INCREF(Py_None); \ - return Py_None; } - NoArgNoReturnFunction(beep) NoArgNoReturnFunction(def_prog_mode) --- 1463,1466 ---- *************** *** 1806,1809 **** --- 1741,1746 ---- } + static PyObject *ModDict; + static PyObject * PyCurses_InitScr(PyObject *self, PyObject *args) *************** *** 2498,2503 **** init_curses(void) { ! PyObject *m, *d, *v; /* Create the module and add the functions */ m = Py_InitModule("_curses", PyCurses_methods); --- 2435,2447 ---- init_curses(void) { ! PyObject *m, *d, *v, *c_api_object; ! static void *PyCurses_API[PyCurses_API_pointers]; + /* Initialize the C API pointer array */ + PyCurses_API[0] = (void *)&PyCursesWindow_Type; + PyCurses_API[1] = (void *)func_PyCursesSetupTermCalled; + PyCurses_API[2] = (void *)func_PyCursesInitialised; + PyCurses_API[3] = (void *)func_PyCursesInitialisedColor; + /* Create the module and add the functions */ m = Py_InitModule("_curses", PyCurses_methods); *************** *** 2505,2509 **** /* Add some symbolic constants to the module */ d = PyModule_GetDict(m); ! ModDict = d; /* For PyCurses_InitScr */ /* For exception curses.error */ --- 2449,2457 ---- /* Add some symbolic constants to the module */ d = PyModule_GetDict(m); ! ModDict = d; /* For PyCurses_InitScr to use later */ ! ! /* Add a CObject for the C API */ ! c_api_object = PyCObject_FromVoidPtr((void *)PyCurses_API, NULL); ! PyDict_SetItemString(d, "_C_API", c_api_object); /* For exception curses.error */ From python-dev@python.org Fri Dec 22 21:54:14 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 13:54:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _curses_panel.c,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv19887 Added Files: _curses_panel.c Log Message: Patch #102813: add a wrapper for the panel library included with ncurses. Original version written by Thomas Gellekum, reshaped into a separate module by AMK. --- NEW FILE: _curses_panel.c --- /* * Interface to the ncurses panel library * * Original version by Thomas Gellekum */ /* Release Number */ static char *PyCursesVersion = "2.1"; /* Includes */ #include "Python.h" #include "py_curses.h" #include static PyObject *PyCursesError; /* Utility Functions */ /* * Check the return code from a curses function and return None * or raise an exception as appropriate. */ static PyObject * PyCursesCheckERR(int code, char *fname) { if (code != ERR) { Py_INCREF(Py_None); return Py_None; } else { if (fname == NULL) { PyErr_SetString(PyCursesError, catchall_ERR); } else { PyErr_Format(PyCursesError, "%s() returned ERR", fname); } return NULL; } } /***************************************************************************** The Panel Object ******************************************************************************/ /* Definition of the panel object and panel type */ typedef struct { PyObject_HEAD PANEL *pan; PyCursesWindowObject *wo; /* for reference counts */ } PyCursesPanelObject; PyTypeObject PyCursesPanel_Type; #define PyCursesPanel_Check(v) ((v)->ob_type == &PyCursesPanel_Type) /* Some helper functions. The problem is that there's always a window associated with a panel. To ensure that Python's GC doesn't pull this window from under our feet we need to keep track of references to the corresponding window object within Python. We can't use dupwin(oldwin) to keep a copy of the curses WINDOW because the contents of oldwin is copied only once; code like win = newwin(...) pan = win.panel() win.addstr(some_string) pan.window().addstr(other_string) will fail. */ /* We keep a linked list of PyCursesPanelObjects, lop. A list should suffice, I don't expect more than a handful or at most a few dozens of panel objects within a typical program. */ typedef struct _list_of_panels { PyCursesPanelObject *po; struct _list_of_panels *next; } list_of_panels; /* list anchor */ static list_of_panels *lop; /* Insert a new panel object into lop */ static int insert_lop(PyCursesPanelObject *po) { list_of_panels *new; if ((new = (list_of_panels *)malloc(sizeof(list_of_panels))) == NULL) { PyErr_NoMemory(); return -1; } new->po = po; new->next = lop; lop = new; return 0; } /* Remove the panel object from lop */ static void remove_lop(PyCursesPanelObject *po) { list_of_panels *temp, *n; temp = lop; if (temp->po == po) { lop = temp->next; free(temp); return; } while (temp->next->po != po) { if (temp->next == NULL) PyErr_SetString(PyExc_RuntimeError, "remove_lop: can't find Panel Object"); temp = temp->next; } n = temp->next->next; free(temp->next); temp->next = n; return; } /* Return the panel object that corresponds to pan */ static PyCursesPanelObject * find_po(PANEL *pan) { list_of_panels *temp; for (temp = lop; temp->po->pan != pan; temp = temp->next) if (temp->next == NULL) return NULL; /* not found!? */ return temp->po; } /* Function Prototype Macros - They are ugly but very, very useful. ;-) X - function name TYPE - parameter Type ERGSTR - format string for construction of the return value PARSESTR - format string for argument parsing */ #define Panel_NoArgNoReturnFunction(X) \ static PyObject *PyCursesPanel_ ## X (PyCursesPanelObject *self, PyObject *args) \ { if (!PyArg_NoArgs(args)) return NULL; \ return PyCursesCheckERR(X(self->pan), # X); } #define Panel_NoArgReturnStringFunction(X) \ static PyObject *PyCursesPanel_ ## X (PyCursesPanelObject *self, PyObject *args) \ { if (!PyArg_NoArgs(args)) return NULL; \ return PyString_FromString(X(self->pan)); } #define Panel_NoArgTrueFalseFunction(X) \ static PyObject * PyCursesPanel_ ## X (PyCursesPanelObject *self, PyObject *args) \ { \ if (!PyArg_NoArgs(args)) return NULL; \ if (X (self->pan) == FALSE) { Py_INCREF(Py_False); return Py_False; } \ else { Py_INCREF(Py_True); return Py_True; } } #define Panel_TwoArgNoReturnFunction(X, TYPE, PARSESTR) \ static PyObject * PyCursesPanel_ ## X (PyCursesPanelObject *self, PyObject *args) \ { \ TYPE arg1, arg2; \ if (!PyArg_Parse(args,PARSESTR, &arg1, &arg2)) return NULL; \ return PyCursesCheckERR(X(self->pan, arg1, arg2), # X); } /* ------------- PANEL routines --------------- */ Panel_NoArgNoReturnFunction(bottom_panel) Panel_NoArgNoReturnFunction(hide_panel) Panel_NoArgNoReturnFunction(show_panel) Panel_NoArgNoReturnFunction(top_panel) Panel_NoArgTrueFalseFunction(panel_hidden) Panel_TwoArgNoReturnFunction(move_panel, int, "(ii);y,x") /* Allocation and deallocation of Panel Objects */ static PyObject * PyCursesPanel_New(PANEL *pan, PyCursesWindowObject *wo) { PyCursesPanelObject *po; po = PyObject_NEW(PyCursesPanelObject, &PyCursesPanel_Type); if (po == NULL) return NULL; po->pan = pan; po->wo = wo; Py_INCREF(wo); if (insert_lop(po) < 0) { PyObject_DEL(po); return NULL; } return (PyObject *)po; } static void PyCursesPanel_Dealloc(PyCursesPanelObject *po) { (void)del_panel(po->pan); Py_DECREF(po->wo); remove_lop(po); PyMem_DEL(po); } /* panel_above(NULL) returns the bottom panel in the stack. To get this behaviour we use curses.panel.bottom_panel(). */ static PyObject * PyCursesPanel_above(PyCursesPanelObject *self, PyObject *args) { PANEL *pan; PyCursesPanelObject *po; if (!PyArg_NoArgs(args)) return NULL; pan = panel_above(self->pan); if (pan == NULL) { /* valid output, it means the calling panel is on top of the stack */ Py_INCREF(Py_None); return Py_None; } po = find_po(pan); if (po == NULL) { PyErr_SetString(PyExc_RuntimeError, "panel_above: can't find Panel Object"); return NULL; } Py_INCREF(po); return (PyObject *)po; } /* panel_below(NULL) returns the top panel in the stack. To get this behaviour we use curses.panel_below(). */ static PyObject * PyCursesPanel_below(PyCursesPanelObject *self, PyObject *args) { PANEL *pan; PyCursesPanelObject *po; if (!PyArg_NoArgs(args)) return NULL; pan = panel_below(self->pan); if (pan == NULL) { /* valid output, it means the calling panel is on the bottom of the stack */ Py_INCREF(Py_None); return Py_None; } po = find_po(pan); if (po == NULL) { PyErr_SetString(PyExc_RuntimeError, "panel_below: can't find Panel Object"); return NULL; } Py_INCREF(po); return (PyObject *)po; } static PyObject * PyCursesPanel_window(PyCursesPanelObject *self, PyObject *args) { if (!PyArg_NoArgs(args)) return NULL; Py_INCREF(self->wo); return (PyObject *)self->wo; } static PyObject * PyCursesPanel_replace_panel(PyCursesPanelObject *self, PyObject *args) { PyCursesPanelObject *po; PyCursesWindowObject *temp; int rtn; if (ARG_COUNT(args) != 1) { PyErr_SetString(PyExc_TypeError, "replace requires one argument"); return NULL; } if (!PyArg_ParseTuple(args, "O!;window object", &PyCursesWindow_Type, &temp)) return NULL; po = find_po(self->pan); if (po == NULL) { PyErr_SetString(PyExc_RuntimeError, "replace_panel: can't find Panel Object"); return NULL; } rtn = replace_panel(self->pan, temp->win); if (rtn == ERR) { PyErr_SetString(PyCursesError, "replace_panel() returned ERR"); return NULL; } Py_DECREF(po->wo); po->wo = temp; Py_INCREF(po->wo); Py_INCREF(Py_None); return Py_None; } static PyObject * PyCursesPanel_set_panel_userptr(PyCursesPanelObject *self, PyObject *args) { PyObject *obj; if (ARG_COUNT(args) != 1) { PyErr_SetString(PyExc_TypeError, "set_userptr requires one argument"); return NULL; } obj = PyTuple_GetItem(args, 0); Py_INCREF(obj); return PyCursesCheckERR(set_panel_userptr(self->pan, obj), "set_panel_userptr"); } static PyObject *PyCursesPanel_userptr (PyCursesPanelObject *self, PyObject *args) { PyObject *obj; PyCursesInitialised; if (!PyArg_NoArgs(args)) return NULL; obj = panel_userptr(self->pan); Py_INCREF(obj); return obj; } /* Module interface */ static PyMethodDef PyCursesPanel_Methods[] = { {"above", (PyCFunction)PyCursesPanel_above}, {"below", (PyCFunction)PyCursesPanel_below}, {"bottom", (PyCFunction)PyCursesPanel_bottom_panel}, {"hidden", (PyCFunction)PyCursesPanel_panel_hidden}, {"hide", (PyCFunction)PyCursesPanel_hide_panel}, {"move", (PyCFunction)PyCursesPanel_move_panel}, {"replace", (PyCFunction)PyCursesPanel_replace_panel}, {"set_userptr", (PyCFunction)PyCursesPanel_set_panel_userptr, METH_VARARGS}, {"show", (PyCFunction)PyCursesPanel_show_panel}, {"top", (PyCFunction)PyCursesPanel_top_panel}, {"userptr", (PyCFunction)PyCursesPanel_userptr}, {"window", (PyCFunction)PyCursesPanel_window}, {NULL, NULL} /* sentinel */ }; static PyObject * PyCursesPanel_GetAttr(PyCursesPanelObject *self, char *name) { return Py_FindMethod(PyCursesPanel_Methods, (PyObject *)self, name); } /* -------------------------------------------------------*/ PyTypeObject PyCursesPanel_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /*ob_size*/ "curses panel", /*tp_name*/ sizeof(PyCursesPanelObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor)PyCursesPanel_Dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc)PyCursesPanel_GetAttr, /*tp_getattr*/ (setattrfunc)0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ }; /* Wrapper for panel_above(NULL). This function returns the bottom panel of the stack, so it's renamed to bottom_panel(). panel.above() *requires* a panel object in the first place which may be undesirable. */ static PyObject * PyCurses_bottom_panel(PyObject *self, PyObject *args) { PANEL *pan; PyCursesPanelObject *po; PyCursesInitialised; if (!PyArg_NoArgs(args)) return NULL; pan = panel_above(NULL); if (pan == NULL) { /* valid output, it means there's no panel at all */ Py_INCREF(Py_None); return Py_None; } po = find_po(pan); if (po == NULL) { PyErr_SetString(PyExc_RuntimeError, "panel_above: can't find Panel Object"); return NULL; } Py_INCREF(po); return (PyObject *)po; } static PyObject * PyCurses_new_panel(PyObject *self, PyObject *args) { PyCursesWindowObject *win; PANEL *pan; if (!PyArg_ParseTuple(args, "O!", &PyCursesWindow_Type, &win)) return NULL; pan = new_panel(win->win); if (pan == NULL) { PyErr_SetString(PyCursesError, catchall_NULL); return NULL; } return (PyObject *)PyCursesPanel_New(pan, win); } /* Wrapper for panel_below(NULL). This function returns the top panel of the stack, so it's renamed to top_panel(). panel.below() *requires* a panel object in the first place which may be undesirable. */ static PyObject * PyCurses_top_panel(PyObject *self, PyObject *args) { PANEL *pan; PyCursesPanelObject *po; PyCursesInitialised; if (!PyArg_NoArgs(args)) return NULL; pan = panel_below(NULL); if (pan == NULL) { /* valid output, it means there's no panel at all */ Py_INCREF(Py_None); return Py_None; } po = find_po(pan); if (po == NULL) { PyErr_SetString(PyExc_RuntimeError, "panel_below: can't find Panel Object"); return NULL; } Py_INCREF(po); return (PyObject *)po; } static PyObject *PyCurses_update_panels(PyObject *self, PyObject *args) { PyCursesInitialised; if (!PyArg_NoArgs(args)) return NULL; update_panels(); Py_INCREF(Py_None); return Py_None; } /* List of functions defined in the module */ static PyMethodDef PyCurses_methods[] = { {"bottom_panel", (PyCFunction)PyCurses_bottom_panel}, {"new_panel", (PyCFunction)PyCurses_new_panel, METH_VARARGS}, {"top_panel", (PyCFunction)PyCurses_top_panel}, {"update_panels", (PyCFunction)PyCurses_update_panels}, {NULL, NULL} /* sentinel */ }; /* Initialization function for the module */ void init_curses_panel(void) { PyObject *m, *d, *v; import_curses(); /* Create the module and add the functions */ m = Py_InitModule("_curses_panel", PyCurses_methods); d = PyModule_GetDict(m); /* For exception _curses_panel.error */ PyCursesError = PyErr_NewException("_curses_panel.error", NULL, NULL); PyDict_SetItemString(d, "error", PyCursesError); /* Make the version available */ v = PyString_FromString(PyCursesVersion); PyDict_SetItemString(d, "version", v); PyDict_SetItemString(d, "__version__", v); Py_DECREF(v); } From python-dev@python.org Fri Dec 22 21:57:35 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 13:57:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.dist,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv20343 Modified Files: Setup.dist Log Message: Add _curses_panel to Setup Index: Setup.dist =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.dist,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** Setup.dist 2000/12/12 21:07:08 1.2 --- Setup.dist 2000/12/22 21:57:33 1.3 *************** *** 322,326 **** #_curses _cursesmodule.c -lcurses -ltermcap ! --- 322,327 ---- #_curses _cursesmodule.c -lcurses -ltermcap ! # Wrapper for the panel library that's part of ncurses and SYSV curses. ! #_curses_panel _curses_panel.c -lpanel -lncurses From python-dev@python.org Fri Dec 22 21:57:44 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 13:57:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcursespanel.tex,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv20359 Added Files: libcursespanel.tex Log Message: Added documentation for the panel wrapper module --- NEW FILE: libcursespanel.tex --- \section{\module{curses.panel} --- A panel stack extension for curses.} \declaremodule{standard}{curses.panel} \sectionauthor{A.M. Kuchling}{amk1@bigfoot.com} \modulesynopsis{A panel stack extension that adds depth to curses windows.} Panels are windows with the added feature of depth, so they can be stacked on top of each other, and only the visible portions of each window will be displayed. Panels can be added, moved up or down in the stack, and removed. \subsection{Functions \label{cursespanel-functions}} The module \module{curses.panel} defines the following functions: \begin{funcdesc}{bottom_panel}{} Returns the bottom panel in the panel stack. \end{funcdesc} \begin{methoddesc}{new_panel}{win} Returns a panel object, associating it with the given window \var{win}. \end{methoddesc} \begin{funcdesc}{top_panel}{} Returns the top panel in the panel stack. \end{funcdesc} \begin{funcdesc}{update_panels}{} Updates the virtual screen after changes in the panel stack. This does not call \function{curses.doupdate()}, so you'll have to do this yourself. \end{funcdesc} \subsection{Panel Objects \label{curses-panel-objects}} Panel objects, as returned by \function{new_panel()} above, are windows with a stacking order. There's always a window associated with a panel which determines the content, while the panel methods are responsible for the window's depth in the panel stack. Panel objects have the following methods: \begin{methoddesc}{above} Returns the panel above the current panel. \end{methoddesc} \begin{methoddesc}{below} Returns the panel below the current panel. \end{methoddesc} \begin{methoddesc}{bottom} Push the panel to the bottom of the stack. \end{methoddesc} \begin{methoddesc}{hidden} Returns true if the panel is hidden (not visible), false otherwise. \end{methoddesc} \begin{methoddesc}{hide} Hide the panel. This does not delete the object, it just makes the window on screen invisible. \end{methoddesc} \begin{methoddesc}{move}{y, x} Move the panel to the screen coordinates \code{(\var{y}, \var{x})}. \end{methoddesc} \begin{methoddesc}{replace}{win} Change the window associated with the panel to the window \var{win}. \end{methoddesc} \begin{methoddesc}{set_userptr}{obj} Set the panel's user pointer to \var{obj}. This is used to associate an arbitrary piece of data with the panel, and can be any Python object. \end{methoddesc} \begin{methoddesc}{show} Display the panel (which might have been hidden). \end{methoddesc} \begin{methoddesc}{top} Push panel to the top of the stack. \end{methoddesc} \begin{methoddesc}{userptr} Returns the user pointer for the panel. This might be any Python object. \end{methoddesc} \begin{methoddesc}{window} Returns the window object associated with the panel. \end{methoddesc} From python-dev@python.org Fri Dec 22 21:58:31 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 13:58:31 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses panel.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/curses In directory usw-pr-cvs1:/tmp/cvs-serv20446 Added Files: panel.py Log Message: Wrapper for _curses_panel module; currently this adds nothing extra beyond what's in _curses_panel --- NEW FILE: panel.py --- """curses.panel Module for using panels with curses. """ __revision__ = "$Id: panel.py,v 1.1 2000/12/22 21:58:29 akuchling Exp $" from _curses_panel import * From python-dev@python.org Fri Dec 22 22:03:17 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 14:03:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _curses_panel.c,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv21050 Modified Files: _curses_panel.c Log Message: Add correction caught by Thomas Gellekum (and sitting in my e-mail) Index: _curses_panel.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_curses_panel.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** _curses_panel.c 2000/12/22 21:54:12 1.1 --- _curses_panel.c 2000/12/22 22:03:15 1.2 *************** *** 334,338 **** {"hide", (PyCFunction)PyCursesPanel_hide_panel}, {"move", (PyCFunction)PyCursesPanel_move_panel}, ! {"replace", (PyCFunction)PyCursesPanel_replace_panel}, {"set_userptr", (PyCFunction)PyCursesPanel_set_panel_userptr, METH_VARARGS}, --- 334,339 ---- {"hide", (PyCFunction)PyCursesPanel_hide_panel}, {"move", (PyCFunction)PyCursesPanel_move_panel}, ! {"replace", (PyCFunction)PyCursesPanel_replace_panel, ! METH_VARARGS}, {"set_userptr", (PyCFunction)PyCursesPanel_set_panel_userptr, METH_VARARGS}, From python-dev@python.org Fri Dec 22 22:06:45 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 14:06:45 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcurses.tex,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv21355 Modified Files: libcurses.tex Log Message: Add 'see also' link to curses.panel Index: libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** libcurses.tex 2000/12/21 17:04:31 1.26 --- libcurses.tex 2000/12/22 22:06:43 1.27 *************** *** 25,28 **** --- 25,30 ---- characters, regardless of your locale settings.} + \seemodule{curses.panel}{A panel stack extension that adds depth to + curses windows.} \seemodule{curses.textpad}{Editable text widget for curses supporting \program{Emacs}-like bindings.} From python-dev@python.org Sat Dec 23 05:46:25 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 22 Dec 2000 21:46:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _curses_panel.c,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv18355/Modules Modified Files: _curses_panel.c Log Message: Shortened / wrapped some long lines. Removed warning on use of panel_userptr() in PyCursesPanel_userptr(). Index: _curses_panel.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_curses_panel.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** _curses_panel.c 2000/12/22 22:03:15 1.2 --- _curses_panel.c 2000/12/23 05:46:23 1.3 *************** *** 142,156 **** #define Panel_NoArgNoReturnFunction(X) \ ! static PyObject *PyCursesPanel_ ## X (PyCursesPanelObject *self, PyObject *args) \ { if (!PyArg_NoArgs(args)) return NULL; \ return PyCursesCheckERR(X(self->pan), # X); } #define Panel_NoArgReturnStringFunction(X) \ ! static PyObject *PyCursesPanel_ ## X (PyCursesPanelObject *self, PyObject *args) \ { if (!PyArg_NoArgs(args)) return NULL; \ return PyString_FromString(X(self->pan)); } #define Panel_NoArgTrueFalseFunction(X) \ ! static PyObject * PyCursesPanel_ ## X (PyCursesPanelObject *self, PyObject *args) \ { \ if (!PyArg_NoArgs(args)) return NULL; \ --- 142,156 ---- #define Panel_NoArgNoReturnFunction(X) \ ! static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self, PyObject *args) \ { if (!PyArg_NoArgs(args)) return NULL; \ return PyCursesCheckERR(X(self->pan), # X); } #define Panel_NoArgReturnStringFunction(X) \ ! static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self, PyObject *args) \ { if (!PyArg_NoArgs(args)) return NULL; \ return PyString_FromString(X(self->pan)); } #define Panel_NoArgTrueFalseFunction(X) \ ! static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self, PyObject *args) \ { \ if (!PyArg_NoArgs(args)) return NULL; \ *************** *** 159,163 **** #define Panel_TwoArgNoReturnFunction(X, TYPE, PARSESTR) \ ! static PyObject * PyCursesPanel_ ## X (PyCursesPanelObject *self, PyObject *args) \ { \ TYPE arg1, arg2; \ --- 159,163 ---- #define Panel_TwoArgNoReturnFunction(X, TYPE, PARSESTR) \ ! static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self, PyObject *args) \ { \ TYPE arg1, arg2; \ *************** *** 310,314 **** obj = PyTuple_GetItem(args, 0); Py_INCREF(obj); ! return PyCursesCheckERR(set_panel_userptr(self->pan, obj), "set_panel_userptr"); } --- 310,315 ---- obj = PyTuple_GetItem(args, 0); Py_INCREF(obj); ! return PyCursesCheckERR(set_panel_userptr(self->pan, obj), ! "set_panel_userptr"); } *************** *** 318,323 **** PyObject *obj; PyCursesInitialised; ! if (!PyArg_NoArgs(args)) return NULL; ! obj = panel_userptr(self->pan); Py_INCREF(obj); return obj; --- 319,325 ---- PyObject *obj; PyCursesInitialised; ! if (!PyArg_NoArgs(args)) ! return NULL; ! obj = (PyObject *) panel_userptr(self->pan); Py_INCREF(obj); return obj; *************** *** 409,413 **** PANEL *pan; ! if (!PyArg_ParseTuple(args, "O!", &PyCursesWindow_Type, &win)) return NULL; pan = new_panel(win->win); if (pan == NULL) { --- 411,416 ---- PANEL *pan; ! if (!PyArg_ParseTuple(args, "O!", &PyCursesWindow_Type, &win)) ! return NULL; pan = new_panel(win->win); if (pan == NULL) { From python-dev@python.org Sat Dec 23 14:11:30 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 23 Dec 2000 06:11:30 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.185,2.186 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv16346 Modified Files: bltinmodule.c Log Message: CHange error messages for ord(), using "string" instead of "string or Unicode" Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.185 retrieving revision 2.186 diff -C2 -r2.185 -r2.186 *** bltinmodule.c 2000/12/20 15:07:34 2.185 --- bltinmodule.c 2000/12/23 14:11:28 2.186 *************** *** 1525,1529 **** } else { PyErr_Format(PyExc_TypeError, ! "ord() expected string or Unicode character, " \ "%.200s found", obj->ob_type->tp_name); return NULL; --- 1525,1529 ---- } else { PyErr_Format(PyExc_TypeError, ! "ord() expected string of length 1, but " \ "%.200s found", obj->ob_type->tp_name); return NULL; *************** *** 1531,1535 **** PyErr_Format(PyExc_TypeError, ! "ord() expected a character, length-%d string found", size); return NULL; --- 1531,1536 ---- PyErr_Format(PyExc_TypeError, ! "ord() expected a character, " ! "but string of length %d found", size); return NULL; From python-dev@python.org Sat Dec 23 14:20:26 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 23 Dec 2000 06:20:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib shlex.py,1.9,1.10 netrc.py,1.7,1.8 multifile.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv18929 Modified Files: shlex.py netrc.py multifile.py Log Message: Remove superfluous semicolons Index: shlex.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/shlex.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** shlex.py 2000/07/09 16:44:26 1.9 --- shlex.py 2000/12/23 14:20:23 1.10 *************** *** 23,27 **** self.quotes = '\'"' self.state = ' ' ! self.pushback = []; self.lineno = 1 self.debug = 0 --- 23,27 ---- self.quotes = '\'"' self.state = ' ' ! self.pushback = [] self.lineno = 1 self.debug = 0 *************** *** 37,41 **** if self.debug >= 1: print "shlex: pushing token " + `tok` ! self.pushback = [tok] + self.pushback; def get_token(self): --- 37,41 ---- if self.debug >= 1: print "shlex: pushing token " + `tok` ! self.pushback = [tok] + self.pushback def get_token(self): *************** *** 84,88 **** tok = '' while 1: ! nextchar = self.instream.read(1); if nextchar == '\n': self.lineno = self.lineno + 1 --- 84,88 ---- tok = '' while 1: ! nextchar = self.instream.read(1) if nextchar == '\n': self.lineno = self.lineno + 1 *************** *** 91,99 **** "I see character:", repr(nextchar) if self.state is None: ! self.token = ''; # past end of file break elif self.state == ' ': if not nextchar: ! self.state = None; # end of file break elif nextchar in self.whitespace: --- 91,99 ---- "I see character:", repr(nextchar) if self.state is None: ! self.token = '' # past end of file break elif self.state == ' ': if not nextchar: ! self.state = None # end of file break elif nextchar in self.whitespace: *************** *** 126,130 **** elif self.state == 'a': if not nextchar: ! self.state = None; # end of file break elif nextchar in self.whitespace: --- 126,130 ---- elif self.state == 'a': if not nextchar: ! self.state = None # end of file break elif nextchar in self.whitespace: Index: netrc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/netrc.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** netrc.py 2000/12/12 23:20:44 1.7 --- netrc.py 2000/12/23 14:20:24 1.8 *************** *** 47,51 **** if tt=='' or tt == 'machine' or tt == 'default' or tt == 'macdef': if toplevel == 'macdef': ! break; elif login and password: self.hosts[entryname] = (login, account, password) --- 47,51 ---- if tt=='' or tt == 'machine' or tt == 'default' or tt == 'macdef': if toplevel == 'macdef': ! break elif login and password: self.hosts[entryname] = (login, account, password) Index: multifile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/multifile.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** multifile.py 2000/12/12 23:20:44 1.12 --- multifile.py 2000/12/23 14:20:24 1.13 *************** *** 87,91 **** else: # Ignore trailing whitespace on marker lines ! k = len(line) - 1; while line[k] in string.whitespace: k = k - 1 --- 87,91 ---- else: # Ignore trailing whitespace on marker lines ! k = len(line) - 1 while line[k] in string.whitespace: k = k - 1 From python-dev@python.org Sat Dec 23 14:50:21 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 23 Dec 2000 06:50:21 -0800 Subject: [Python-checkins] CVS: python/dist/src/Demo/curses tclock.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/curses In directory usw-pr-cvs1:/tmp/cvs-serv28253 Modified Files: tclock.py Log Message: Choose the smallest value of x,y for the clock's radius (instead of just taking the y coordinate), and change radius of second indicator to compensate Remove redundant setting of sradius Index: tclock.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/curses/tclock.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** tclock.py 2000/12/15 00:41:48 1.1 --- tclock.py 2000/12/23 14:50:18 1.2 *************** *** 81,95 **** cx = (curses.COLS - 1) / 2 cy = curses.LINES / 2 ! if cx > cy: ! ch = cy ! else: ! ch = cx ! mradius = (3 * cy) / 4 ! hradius = cy / 2 ! sradius = (2 * cy) / 3 for i in range(0, 12): sangle = (i + 1) * 2.0 * pi / 12.0 - sradius = 5 * cy / 6 sdx, sdy = A2XY(sangle, sradius) --- 81,91 ---- cx = (curses.COLS - 1) / 2 cy = curses.LINES / 2 ! ch = min( cy-1, int(cx / ASPECT) - 1) ! mradius = (3 * ch) / 4 ! hradius = ch / 2 ! sradius = 5 * ch / 6 for i in range(0, 12): sangle = (i + 1) * 2.0 * pi / 12.0 sdx, sdy = A2XY(sangle, sradius) *************** *** 99,103 **** "ASCII Clock by Howard Jones , 1994") ! sradius = 8 while 1: curses.napms(1000) --- 95,100 ---- "ASCII Clock by Howard Jones , 1994") ! sradius = max(sradius-4, 8) ! while 1: curses.napms(1000) From python-dev@python.org Sat Dec 23 22:08:30 2000 From: python-dev@python.org (Fred L. Drake) Date: Sat, 23 Dec 2000 14:08:30 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_regex.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv15551/Lib/test Modified Files: test_regex.py Log Message: The regression test for the regex module should not trip the deprecation warning for that module, so suppress just that one warning. Index: test_regex.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_regex.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** test_regex.py 2000/10/23 17:22:08 1.5 --- test_regex.py 2000/12/23 22:08:27 1.6 *************** *** 1,3 **** --- 1,6 ---- from test_support import verbose + import warnings + warnings.filterwarnings("ignore", "the regex module is deprecated", + DeprecationWarning, "test_regex") import regex from regex_syntax import * From python-dev@python.org Sat Dec 23 22:12:09 2000 From: python-dev@python.org (Fred L. Drake) Date: Sat, 23 Dec 2000 14:12:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_pyexpat.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv18271/test Modified Files: test_pyexpat.py Log Message: The "context" parameter to the ExternalEntityRefParameter exposes internal information from the Expat library that is not part of its public API. Do not print this information as the format of the string may (and will) change as Expat evolves. Add additional tests to make sure the ParserCreate() function raises the right exceptions on illegal parameters. Index: test_pyexpat.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pyexpat.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_pyexpat.py 2000/10/23 17:22:07 1.6 --- test_pyexpat.py 2000/12/23 22:12:07 1.7 *************** *** 51,55 **** def ExternalEntityRefHandler(self, *args): context, base, sysId, pubId = args ! print 'External entity ref:', args return 1 --- 51,55 ---- def ExternalEntityRefHandler(self, *args): context, base, sysId, pubId = args ! print 'External entity ref:', args[1:] return 1 *************** *** 151,152 **** --- 151,183 ---- print '** Column', parser.ErrorColumnNumber print '** Byte', parser.ErrorByteIndex + + + # Tests that make sure we get errors when the namespace_separator value + # is illegal, and that we don't for good values: + print + print "Testing constructor for proper handling of namespace_separator values:" + expat.ParserCreate() + expat.ParserCreate(namespace_separator=None) + expat.ParserCreate(namespace_separator=' ') + print "Legal values tested o.k." + try: + expat.ParserCreate(namespace_separator=42) + except TypeError, e: + print "Caught expected TypeError:" + print e + else: + print "Failed to catch expected TypeError." + try: + expat.ParserCreate(namespace_separator='too long') + except ValueError, e: + print "Caught expected ValueError:" + print e + else: + print "Failed to catch expected ValueError." + try: + expat.ParserCreate(namespace_separator='') # too short + except ValueError, e: + print "Caught expected ValueError:" + print e + else: + print "Failed to catch expected ValueError." From python-dev@python.org Sat Dec 23 22:12:09 2000 From: python-dev@python.org (Fred L. Drake) Date: Sat, 23 Dec 2000 14:12:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_pyexpat,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv18271/test/output Modified Files: test_pyexpat Log Message: The "context" parameter to the ExternalEntityRefParameter exposes internal information from the Expat library that is not part of its public API. Do not print this information as the format of the string may (and will) change as Expat evolves. Add additional tests to make sure the ParserCreate() function raises the right exceptions on illegal parameters. Index: test_pyexpat =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_pyexpat,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_pyexpat 2000/09/21 20:32:13 1.3 --- test_pyexpat 2000/12/23 22:12:07 1.4 *************** *** 31,35 **** End element: 'sub2' ! External entity ref: ('http://www.python.org/namespace=http://www.w3.org/XML/1998/namespace\014external_entity', None, 'entity.file', None) End element: 'root' --- 31,35 ---- End element: 'sub2' ! External entity ref: (None, 'entity.file', None) End element: 'root' *************** *** 61,65 **** End element: u'sub2' ! External entity ref: (u'http://www.python.org/namespace=http://www.w3.org/XML/1998/namespace\014external_entity', None, u'entity.file', None) End element: u'root' --- 61,65 ---- End element: u'sub2' ! External entity ref: (None, u'entity.file', None) End element: u'root' *************** *** 91,95 **** End element: u'sub2' ! External entity ref: (u'http://www.python.org/namespace=http://www.w3.org/XML/1998/namespace\014external_entity', None, u'entity.file', None) End element: u'root' --- 91,104 ---- End element: u'sub2' ! External entity ref: (None, u'entity.file', None) End element: u'root' + + Testing constructor for proper handling of namespace_separator values: + Legal values tested o.k. + Caught expected TypeError: + ParserCreate, argument 2: expected string or None, int found + Caught expected ValueError: + namespace_separator must be one character, omitted, or None + Caught expected ValueError: + namespace_separator must be one character, omitted, or None From python-dev@python.org Sat Dec 23 22:19:07 2000 From: python-dev@python.org (Fred L. Drake) Date: Sat, 23 Dec 2000 14:19:07 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libpyexpat.tex,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv19645 Modified Files: libpyexpat.tex Log Message: Added information on the ExternalEntityParserCreate() method. Index: libpyexpat.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpyexpat.tex,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** libpyexpat.tex 2000/12/07 00:00:21 1.9 --- libpyexpat.tex 2000/12/23 22:19:05 1.10 *************** *** 81,87 **** elem2 \end{verbatim} - \end{funcdesc} \class{xmlparser} objects have the following methods: --- 81,89 ---- elem2 \end{verbatim} \end{funcdesc} + + \subsection{XMLParser Objects \label{xmlparser-objects}} + \class{xmlparser} objects have the following methods: *************** *** 89,93 **** Parses the contents of the string \var{data}, calling the appropriate handler functions to process the parsed data. \var{isfinal} must be ! true on the final call to this method. \var{data} can be the empty string at any time. \end{methoddesc} --- 91,95 ---- Parses the contents of the string \var{data}, calling the appropriate handler functions to process the parsed data. \var{isfinal} must be ! true on the final call to this method. \var{data} can be the empty string at any time. \end{methoddesc} *************** *** 111,114 **** --- 113,124 ---- \method{SetBase()}, or \code{None} if \method{SetBase()} hasn't been called. + \end{methoddesc} + + \begin{methoddesc}[xmlparser]{ExternalEntityParserCreate}{context\optional{, + encoding}} + Create a ``child'' parser which can be used to parse an external + parsed entity referred to by content parsed by the parent parser. The + \var{content} parameter should be the string passed to the + \method{ExternalEntityRefHandler()} handler function, described below. \end{methoddesc} From python-dev@python.org Mon Dec 25 06:19:11 2000 From: python-dev@python.org (Fred L. Drake) Date: Sun, 24 Dec 2000 22:19:11 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libwarnings.tex,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv28673/Doc/lib Modified Files: libwarnings.tex Log Message: Make sure subsections are formatted into HTML pages with reasonable names. Index: libwarnings.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwarnings.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** libwarnings.tex 2000/12/19 06:01:23 1.1 --- libwarnings.tex 2000/12/25 06:19:08 1.2 *************** *** 44,48 **** ! \subsection{Warning Categories} There are a number of built-in exceptions that represent warning --- 44,48 ---- ! \subsection{Warning Categories \label{warning-categories}} There are a number of built-in exceptions that represent warning *************** *** 77,81 **** ! \subsection{The Warnings Filter} The warnings filter controls whether warnings are ignored, displayed, --- 77,81 ---- ! \subsection{The Warnings Filter \label{warning-filter}} The warnings filter controls whether warnings are ignored, displayed, *************** *** 139,143 **** ! \subsection{Available Functions} \begin{funcdesc}{warn}{message\optional{, category\optional{, stacklevel}}} --- 139,143 ---- ! \subsection{Available Functions \label{warning-functions}} \begin{funcdesc}{warn}{message\optional{, category\optional{, stacklevel}}} *************** *** 176,180 **** \begin{funcdesc}{filterwarnings}{action\optional{, ! message\optional{, category\optional{, module\optional{, lineno}}}}} Insert an entry into the list of warnings filters (at the front). This checks the types of the arguments, compiles the message and --- 176,181 ---- \begin{funcdesc}{filterwarnings}{action\optional{, ! message\optional{, category\optional{, ! module\optional{, lineno}}}}} Insert an entry into the list of warnings filters (at the front). This checks the types of the arguments, compiles the message and From python-dev@python.org Tue Dec 26 15:57:05 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 26 Dec 2000 07:57:05 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.45,2.46 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv12097 Modified Files: _cursesmodule.c Log Message: Add the curses constants ERR and OK to the module at TG's suggestion Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.45 retrieving revision 2.46 diff -C2 -r2.45 -r2.46 *** _cursesmodule.c 2000/12/22 21:52:27 2.45 --- _cursesmodule.c 2000/12/26 15:57:01 2.46 *************** *** 2465,2468 **** --- 2465,2471 ---- Py_DECREF(v); + SetDictInt("ERR", ERR); + SetDictInt("OK", OK); + /* Here are some attributes you can add to chars to print */ From python-dev@python.org Tue Dec 26 15:58:29 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 26 Dec 2000 07:58:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcurses.tex,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv12340 Modified Files: libcurses.tex Log Message: Document ERR and OK Index: libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** libcurses.tex 2000/12/22 22:06:43 1.27 --- libcurses.tex 2000/12/26 15:58:27 1.28 *************** *** 1027,1030 **** --- 1027,1041 ---- The \module{curses} module defines the following data members: + \begin{datadesc}{ERR} + Some curses routines that return an integer, such as + \function{getch()}, return ERR upon failure. + \end{datadesc} + + \begin{datadesc}{OK} + Some curses routines that return an integer, such as + \function{napms()}, return OK upon success. + + \end{datadesc} + \begin{datadesc}{version} A string representing the current version of the module. From python-dev@python.org Tue Dec 26 16:08:01 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 26 Dec 2000 08:08:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses ascii.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/curses In directory usw-pr-cvs1:/tmp/cvs-serv14257 Modified Files: ascii.py Log Message: Make isspace(chr(32)) return true Index: ascii.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/curses/ascii.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** ascii.py 2000/07/11 10:38:24 1.3 --- ascii.py 2000/12/26 16:07:59 1.4 *************** *** 62,66 **** def isprint(c): return _ctoi(c) >= 32 and _ctoi(c) <= 126 def ispunct(c): return _ctoi(c) != 32 and not isalnum(c) ! def isspace(c): return _ctoi(c) in (12, 10, 13, 9, 11) def isupper(c): return _ctoi(c) >= 65 and _ctoi(c) <= 90 def isxdigit(c): return isdigit(c) or \ --- 62,66 ---- def isprint(c): return _ctoi(c) >= 32 and _ctoi(c) <= 126 def ispunct(c): return _ctoi(c) != 32 and not isalnum(c) ! def isspace(c): return _ctoi(c) in (9, 10, 11, 12, 13, 32) def isupper(c): return _ctoi(c) >= 65 and _ctoi(c) <= 90 def isxdigit(c): return isdigit(c) or \ From python-dev@python.org Tue Dec 26 16:09:39 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 26 Dec 2000 08:09:39 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libascii.tex,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv16315 Modified Files: libascii.tex Log Message: Remove redundant reference to tab (since it = 'horizontal tab') Index: libascii.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libascii.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** libascii.tex 2000/08/09 14:36:11 1.5 --- libascii.tex 2000/12/26 16:09:37 1.6 *************** *** 105,109 **** \begin{funcdesc}{isspace}{c} ! Checks for \ASCII{} white-space characters; space, tab, line feed, carriage return, form feed, horizontal tab, vertical tab. \end{funcdesc} --- 105,109 ---- \begin{funcdesc}{isspace}{c} ! Checks for \ASCII{} white-space characters; space, line feed, carriage return, form feed, horizontal tab, vertical tab. \end{funcdesc} From python-dev@python.org Tue Dec 26 16:14:35 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 26 Dec 2000 08:14:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libstring.tex,1.41,1.42 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv21730 Modified Files: libstring.tex Log Message: Fix doubled word Index: libstring.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstring.tex,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -r1.41 -r1.42 *** libstring.tex 2000/10/04 13:59:52 1.41 --- libstring.tex 2000/12/26 16:14:32 1.42 *************** *** 11,15 **** expressions. ! The constants defined in this module are are: \begin{datadesc}{digits} --- 11,15 ---- expressions. ! The constants defined in this module are: \begin{datadesc}{digits} From python-dev@python.org Wed Dec 27 08:03:22 2000 From: python-dev@python.org (Tim Peters) Date: Wed, 27 Dec 2000 00:03:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_getopt.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv715/python/dist/src/lib/test Modified Files: test_getopt.py Log Message: Add test case for SF bug https://sourceforge.net/bugs/?func=detailbug&bug_id=126863&group_id=5470 Index: test_getopt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_getopt.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_getopt.py 2000/08/21 22:59:26 1.2 --- test_getopt.py 2000/12/27 08:03:20 1.3 *************** *** 75,78 **** --- 75,87 ---- assert opts == [('--abcd', '1')] assert args == [] + opts, args = getopt.do_longs([], 'abc', ['ab', 'abc', 'abcd'], []) + assert opts == [('--abc', '')] + assert args == [] + # Much like the preceding, except with a non-alpha character ("-") in + # option name that precedes "="; failed in + # http://sourceforge.net/bugs/?func=detailbug&bug_id=126863&group_id=5470 + opts, args = getopt.do_longs([], 'foo=42', ['foo-bar', 'foo=',], []) + assert opts == [('--foo', '42')] + assert args == [] expectException("opts, args = getopt.do_longs([], 'abc=1', ['abc'], [])", GetoptError) From python-dev@python.org Wed Dec 27 08:05:07 2000 From: python-dev@python.org (Tim Peters) Date: Wed, 27 Dec 2000 00:05:07 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib getopt.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv796/python/dist/src/lib Modified Files: getopt.py Log Message: Fix for SF bug https://sourceforge.net/bugs/?func=detailbug&bug_id=126863&group_id=5470 "getopt long option handling broken". Tossed the excruciating logic in long_has_args in favor of something obviously correct. Index: getopt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/getopt.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** getopt.py 2000/02/25 16:34:11 1.11 --- getopt.py 2000/12/27 08:05:05 1.12 *************** *** 67,71 **** longopts = list(longopts) longopts.sort() ! while args and args[0][:1] == '-' and args[0] != '-': if args[0] == '--': args = args[1:] --- 67,71 ---- longopts = list(longopts) longopts.sort() ! while args and args[0].startswith('-') and args[0] != '-': if args[0] == '--': args = args[1:] *************** *** 81,87 **** try: i = opt.index('=') - opt, optarg = opt[:i], opt[i+1:] except ValueError: optarg = None has_arg, opt = long_has_args(opt, longopts) --- 81,88 ---- try: i = opt.index('=') except ValueError: optarg = None + else: + opt, optarg = opt[:i], opt[i+1:] has_arg, opt = long_has_args(opt, longopts) *************** *** 99,115 **** # has_arg? # full option name def long_has_args(opt, longopts): - optlen = len(opt) for i in range(len(longopts)): ! x, y = longopts[i][:optlen], longopts[i][optlen:] ! if opt != x: ! continue ! if y != '' and y != '=' and i+1 < len(longopts): ! if opt == longopts[i+1][:optlen]: ! raise GetoptError('option --%s not a unique prefix' % opt, opt) ! if longopts[i][-1:] in ('=', ): ! return 1, longopts[i][:-1] ! return 0, longopts[i] ! raise GetoptError('option --%s not recognized' % opt, opt) def do_shorts(opts, optstring, shortopts, args): --- 100,132 ---- # has_arg? # full option name + # Assumes longopts has been sorted (ASCII order). def long_has_args(opt, longopts): for i in range(len(longopts)): ! if longopts[i].startswith(opt): ! break ! else: ! raise GetoptError('option --%s not recognized' % opt, opt) ! # opt is a prefix of longopts[i]; find j s.t. opt is a prefix of ! # each possibility in longopts[i:j] ! j = i+1 ! while j < len(longopts) and longopts[j].startswith(opt): ! j += 1 ! possibilities = longopts[i:j] ! # Is there an exact match? ! if opt in possibilities: ! return 0, opt ! elif opt + '=' in possibilities: ! return 1, opt ! # No exact match, so better be unique. ! if len(possibilities) > 1: ! # XXX since possibilities contains all valid continuations, might be ! # nice to work them into the error msg ! raise GetoptError('option --%s not a unique prefix' % opt, opt) ! assert len(possibilities) == 1 ! unique_match = possibilities[0] ! has_arg = unique_match.endswith('=') ! if has_arg: ! unique_match = unique_match[:-1] ! return has_arg, unique_match def do_shorts(opts, optstring, shortopts, args): From python-dev@python.org Wed Dec 27 17:41:49 2000 From: python-dev@python.org (Barry Warsaw) Date: Wed, 27 Dec 2000 09:41:49 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc python-mode.el,3.108,3.109 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv16451 Modified Files: python-mode.el Log Message: (python-font-lock-keywords): Add highlighting of `as' as a keyword, but only in "import foo as bar" statements (including optional preceding `from' clause). Index: python-mode.el =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/python-mode.el,v retrieving revision 3.108 retrieving revision 3.109 diff -C2 -r3.108 -r3.109 *** python-mode.el 2000/10/27 05:00:25 3.108 --- python-mode.el 2000/12/27 17:41:47 3.109 *************** *** 333,336 **** --- 333,338 ---- ;; Yes "except" is in both lists. (cons (concat "\\b\\(" kw2 "\\)[ \n\t(]") 1) + ;; `as' but only in "import foo as bar" + '("[ \t]*\\(\\bfrom\\b.*\\)?\\bimport\\b.*\\b\\(as\\)\\b" . 2) ;; classes '("\\bclass[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)" From python-dev@python.org Wed Dec 27 19:13:00 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 27 Dec 2000 11:13:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib code.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv14677 Modified Files: code.py Log Message: Make Traceback header conform to new traceback ("innermost last" -> "most recent call last"). Index: code.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/code.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** code.py 2000/02/28 15:12:25 1.9 --- code.py 2000/12/27 19:12:58 1.10 *************** *** 142,146 **** list = traceback.format_list(tblist) if list: ! list.insert(0, "Traceback (innermost last):\n") list[len(list):] = traceback.format_exception_only(type, value) finally: --- 142,146 ---- list = traceback.format_list(tblist) if list: ! list.insert(0, "Traceback (most recent call last):\n") list[len(list):] = traceback.format_exception_only(type, value) finally: From python-dev@python.org Wed Dec 27 19:12:42 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 27 Dec 2000 11:12:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib cgi.py,1.56,1.57 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv14652 Modified Files: cgi.py Log Message: Make Traceback header conform to new traceback ("innermost last" -> "most recent call last"). Index: cgi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cgi.py,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -r1.56 -r1.57 *** cgi.py 2000/11/06 18:46:09 1.56 --- cgi.py 2000/12/27 19:12:40 1.57 *************** *** 865,869 **** import traceback print ! print "

Traceback (innermost last):

" list = traceback.format_tb(tb, limit) + \ traceback.format_exception_only(type, value) --- 865,869 ---- import traceback print ! print "

Traceback (most recent call last):

" list = traceback.format_tb(tb, limit) + \ traceback.format_exception_only(type, value) From python-dev@python.org Wed Dec 27 22:26:10 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 27 Dec 2000 14:26:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/idle/Icons minusnode.gif,1.1,1.2 python.gif,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/idle/Icons In directory usw-pr-cvs1:/tmp/cvs-serv15026 Modified Files: minusnode.gif python.gif Log Message: Fixed snake logo and minus image by Daniel Calvelo. Index: minusnode.gif =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/idle/Icons/minusnode.gif,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 Binary files /tmp/cvsjcgx1G and /tmp/cvsunMJTd differ Index: python.gif =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/idle/Icons/python.gif,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 Binary files /tmp/cvs7iQv1I and /tmp/cvsQkGuQh differ From python-dev@python.org Thu Dec 28 00:44:29 2000 From: python-dev@python.org (Tim Peters) Date: Wed, 27 Dec 2000 19:44:29 -0500 Subject: [Python-checkins] CVS: python/dist/src/Misc python-mode.el,3.108,3.109 In-Reply-To: Message-ID: [Barry Warsaw] > Modified Files: > python-mode.el > Log Message: > (python-font-lock-keywords): Add highlighting of `as' as a keyword, > but only in "import foo as bar" statements (including optional > preceding `from' clause). Oh, that's right, try to make IDLE look bad, will you? I've got half a mind to take up the challenge. Unfortunately, I only have half a mind in total, so you may get away with this backstabbing for a while . From python-dev@python.org Thu Dec 28 16:00:36 2000 From: python-dev@python.org (Barry A. Warsaw) Date: Thu, 28 Dec 2000 11:00:36 -0500 Subject: [Python-checkins] CVS: python/dist/src/Misc python-mode.el,3.108,3.109 References: Message-ID: <14923.25508.668453.186209@anthem.concentric.net> >>>>> "TP" == Tim Peters writes: TP> [Barry Warsaw] >> Modified Files: python-mode.el Log Message: >> (python-font-lock-keywords): Add highlighting of `as' as a >> keyword, but only in "import foo as bar" statements (including >> optional preceding `from' clause). TP> Oh, that's right, try to make IDLE look bad, will you? I've TP> got half a mind to take up the challenge. Unfortunately, I TP> only have half a mind in total, so you may get away with this TP> backstabbing for a while . With my current network (un)connectivity, I feel like a nuclear sub which can only surface once a month to receive low frequency orders from some remote antenna farm out in New Brunswick. Just think of me as a rogue commander who tries to do as much damage as possible when he's not joyriding in the draft-wake of giant squids. rehoming-all-remaining-missiles-at-the-Kingdom-of-Timbotia-ly y'rs, -Barry From python-dev@python.org Thu Dec 28 18:40:58 2000 From: python-dev@python.org (Martin v. Löwis) Date: Thu, 28 Dec 2000 10:40:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom minidom.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory usw-pr-cvs1:/tmp/cvs-serv16398 Modified Files: minidom.py Log Message: Merge changes up to 1.10 from PyXML: - implement hasAttribute and hasAttributeNS (1.7) - Node.replaceChild(): Update the sibling nodes to point to newChild. Set the .nextSibling attribute on oldChild instead of adding a .newChild attribute (1.9). Index: minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/minidom.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** minidom.py 2000/12/20 14:47:24 1.16 --- minidom.py 2000/12/28 18:40:56 1.17 *************** *** 146,151 **** newChild.nextSibling = oldChild.nextSibling newChild.previousSibling = oldChild.previousSibling ! oldChild.newChild = None oldChild.previousSibling = None return oldChild --- 146,155 ---- newChild.nextSibling = oldChild.nextSibling newChild.previousSibling = oldChild.previousSibling ! oldChild.nextSibling = None oldChild.previousSibling = None + if newChild.previousSibling: + newChild.previousSibling.nextSibling = newChild + if newChild.nextSibling: + newChild.nextSibling.previousSibling = newChild return oldChild *************** *** 464,467 **** --- 468,477 ---- del self._attrsNS[(node.namespaceURI, node.localName)] + def hasAttribute(self, name): + return self._attrs.has_key(name) + + def hasAttributeNS(self, namespaceURI, localName): + return self._attrsNS.has_key((namespaceURI, localName)) + def getElementsByTagName(self, name): return _getElementsByTagNameHelper(self, name, []) From python-dev@python.org Thu Dec 28 18:43:04 2000 From: python-dev@python.org (Martin v. Löwis) Date: Thu, 28 Dec 2000 10:43:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom pulldom.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory usw-pr-cvs1:/tmp/cvs-serv22869 Modified Files: pulldom.py Log Message: Merge with 1.8 of pulldom.py: Use types.UnicodeType if available, not type(u""). Index: pulldom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/pulldom.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** pulldom.py 2000/12/20 14:47:24 1.13 --- pulldom.py 2000/12/28 18:43:02 1.14 *************** *** 1,5 **** --- 1,11 ---- import xml.sax import xml.sax.handler + import types + try: + _StringTypes = [types.StringType, types.UnicodeType] + except AttributeError: + _StringTypes = [types.StringType] + START_ELEMENT = "START_ELEMENT" END_ELEMENT = "END_ELEMENT" *************** *** 236,240 **** if bufsize is None: bufsize = default_bufsize ! if type(stream_or_string) in [type(""), type(u"")]: stream = open(stream_or_string) else: --- 242,246 ---- if bufsize is None: bufsize = default_bufsize ! if type(stream_or_string) in _StringTypes: stream = open(stream_or_string) else: From python-dev@python.org Fri Dec 29 02:06:47 2000 From: python-dev@python.org (Tim Peters) Date: Thu, 28 Dec 2000 18:06:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_bisect.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv26508/python/dist/src/Lib/test Added Files: test_bisect.py Log Message: Fred, THIS NEEDS DOCS! The function docstrings tell the tale. Christmas present to myself: the bisect module didn't define what happened if the new element was already in the list. It so happens that it inserted the new element "to the right" of all equal elements. Since it wasn't defined, among other bad implications it was a mystery how to use bisect to determine whether an element was already in the list (I've seen code that *assumed* "to the right" without justification). Added new methods bisect_left and insort_left that insert "to the left" instead; made the old names bisect and insort aliases for the new names bisect_right and insort_right; beefed up docstrings to explain what these actually do; and added a std test for the bisect module. --- NEW FILE: test_bisect.py --- from test_support import TestFailed import bisect import sys nerrors = 0 def check_bisect(func, list, elt, expected): global nerrors got = func(list, elt) if got != expected: print >> sys.stderr, \ "expected %s(%s, %s) -> %s, but got %s" % (func.__name__, list, elt, expected, got) nerrors += 1 # XXX optional slice arguments need tests. check_bisect(bisect.bisect_right, [], 1, 0) check_bisect(bisect.bisect_right, [1], 0, 0) check_bisect(bisect.bisect_right, [1], 1, 1) check_bisect(bisect.bisect_right, [1], 2, 1) check_bisect(bisect.bisect_right, [1, 1], 0, 0) check_bisect(bisect.bisect_right, [1, 1], 1, 2) check_bisect(bisect.bisect_right, [1, 1], 2, 2) check_bisect(bisect.bisect_right, [1, 1, 1], 0, 0) check_bisect(bisect.bisect_right, [1, 1, 1], 1, 3) check_bisect(bisect.bisect_right, [1, 1, 1], 2, 3) check_bisect(bisect.bisect_right, [1, 1, 1, 1], 0, 0) check_bisect(bisect.bisect_right, [1, 1, 1, 1], 1, 4) check_bisect(bisect.bisect_right, [1, 1, 1, 1], 2, 4) check_bisect(bisect.bisect_right, [1, 2], 0, 0) check_bisect(bisect.bisect_right, [1, 2], 1, 1) check_bisect(bisect.bisect_right, [1, 2], 1.5, 1) check_bisect(bisect.bisect_right, [1, 2], 2, 2) check_bisect(bisect.bisect_right, [1, 2], 3, 2) check_bisect(bisect.bisect_right, [1, 1, 2, 2], 0, 0) check_bisect(bisect.bisect_right, [1, 1, 2, 2], 1, 2) check_bisect(bisect.bisect_right, [1, 1, 2, 2], 1.5, 2) check_bisect(bisect.bisect_right, [1, 1, 2, 2], 2, 4) check_bisect(bisect.bisect_right, [1, 1, 2, 2], 3, 4) check_bisect(bisect.bisect_right, [1, 2, 3], 0, 0) check_bisect(bisect.bisect_right, [1, 2, 3], 1, 1) check_bisect(bisect.bisect_right, [1, 2, 3], 1.5, 1) check_bisect(bisect.bisect_right, [1, 2, 3], 2, 2) check_bisect(bisect.bisect_right, [1, 2, 3], 2.5, 2) check_bisect(bisect.bisect_right, [1, 2, 3], 3, 3) check_bisect(bisect.bisect_right, [1, 2, 3], 4, 3) check_bisect(bisect.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 0, 0) check_bisect(bisect.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1, 1) check_bisect(bisect.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1.5, 1) check_bisect(bisect.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2, 3) check_bisect(bisect.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2.5, 3) check_bisect(bisect.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3, 6) check_bisect(bisect.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3.5, 6) check_bisect(bisect.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 4, 10) check_bisect(bisect.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 5, 10) check_bisect(bisect.bisect_left, [], 1, 0) check_bisect(bisect.bisect_left, [1], 0, 0) check_bisect(bisect.bisect_left, [1], 1, 0) check_bisect(bisect.bisect_left, [1], 2, 1) check_bisect(bisect.bisect_left, [1, 1], 0, 0) check_bisect(bisect.bisect_left, [1, 1], 1, 0) check_bisect(bisect.bisect_left, [1, 1], 2, 2) check_bisect(bisect.bisect_left, [1, 1, 1], 0, 0) check_bisect(bisect.bisect_left, [1, 1, 1], 1, 0) check_bisect(bisect.bisect_left, [1, 1, 1], 2, 3) check_bisect(bisect.bisect_left, [1, 1, 1, 1], 0, 0) check_bisect(bisect.bisect_left, [1, 1, 1, 1], 1, 0) check_bisect(bisect.bisect_left, [1, 1, 1, 1], 2, 4) check_bisect(bisect.bisect_left, [1, 2], 0, 0) check_bisect(bisect.bisect_left, [1, 2], 1, 0) check_bisect(bisect.bisect_left, [1, 2], 1.5, 1) check_bisect(bisect.bisect_left, [1, 2], 2, 1) check_bisect(bisect.bisect_left, [1, 2], 3, 2) check_bisect(bisect.bisect_left, [1, 1, 2, 2], 0, 0) check_bisect(bisect.bisect_left, [1, 1, 2, 2], 1, 0) check_bisect(bisect.bisect_left, [1, 1, 2, 2], 1.5, 2) check_bisect(bisect.bisect_left, [1, 1, 2, 2], 2, 2) check_bisect(bisect.bisect_left, [1, 1, 2, 2], 3, 4) check_bisect(bisect.bisect_left, [1, 2, 3], 0, 0) check_bisect(bisect.bisect_left, [1, 2, 3], 1, 0) check_bisect(bisect.bisect_left, [1, 2, 3], 1.5, 1) check_bisect(bisect.bisect_left, [1, 2, 3], 2, 1) check_bisect(bisect.bisect_left, [1, 2, 3], 2.5, 2) check_bisect(bisect.bisect_left, [1, 2, 3], 3, 2) check_bisect(bisect.bisect_left, [1, 2, 3], 4, 3) check_bisect(bisect.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 0, 0) check_bisect(bisect.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1, 0) check_bisect(bisect.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1.5, 1) check_bisect(bisect.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2, 1) check_bisect(bisect.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2.5, 3) check_bisect(bisect.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3, 3) check_bisect(bisect.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3.5, 6) check_bisect(bisect.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 4, 6) check_bisect(bisect.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 5, 10) def check_insort(n): global nerrors from random import choice import sys digits = "0123456789" raw = [] insorted = [] for i in range(n): digit = choice(digits) raw.append(digit) if digit in "02468": f = bisect.insort_left else: f = bisect.insort_right f(insorted, digit) sorted = raw[:] sorted.sort() if sorted == insorted: return print >> sys.stderr, "insort test failed: raw %s got %s" % (raw, insorted) nerrors += 1 check_insort(500) if nerrors: raise TestFailed("%d errors in test_bisect" % nerrors) From python-dev@python.org Fri Dec 29 02:06:47 2000 From: python-dev@python.org (Tim Peters) Date: Thu, 28 Dec 2000 18:06:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_bisect,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv26508/python/dist/src/Lib/test/output Added Files: test_bisect Log Message: Fred, THIS NEEDS DOCS! The function docstrings tell the tale. Christmas present to myself: the bisect module didn't define what happened if the new element was already in the list. It so happens that it inserted the new element "to the right" of all equal elements. Since it wasn't defined, among other bad implications it was a mystery how to use bisect to determine whether an element was already in the list (I've seen code that *assumed* "to the right" without justification). Added new methods bisect_left and insort_left that insert "to the left" instead; made the old names bisect and insort aliases for the new names bisect_right and insort_right; beefed up docstrings to explain what these actually do; and added a std test for the bisect module. --- NEW FILE: test_bisect --- test_bisect From python-dev@python.org Fri Dec 29 02:06:47 2000 From: python-dev@python.org (Tim Peters) Date: Thu, 28 Dec 2000 18:06:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib bisect.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv26508/python/dist/src/Lib Modified Files: bisect.py Log Message: Fred, THIS NEEDS DOCS! The function docstrings tell the tale. Christmas present to myself: the bisect module didn't define what happened if the new element was already in the list. It so happens that it inserted the new element "to the right" of all equal elements. Since it wasn't defined, among other bad implications it was a mystery how to use bisect to determine whether an element was already in the list (I've seen code that *assumed* "to the right" without justification). Added new methods bisect_left and insort_left that insert "to the left" instead; made the old names bisect and insort aliases for the new names bisect_right and insort_right; beefed up docstrings to explain what these actually do; and added a std test for the bisect module. Index: bisect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/bisect.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** bisect.py 2000/02/02 15:10:14 1.4 --- bisect.py 2000/12/29 02:06:45 1.5 *************** *** 2,7 **** ! def insort(a, x, lo=0, hi=None): ! """Insert item x in list a, and keep it sorted assuming a is sorted.""" if hi is None: hi = len(a) --- 2,14 ---- ! def insort_right(a, x, lo=0, hi=None): ! """Insert item x in list a, and keep it sorted assuming a is sorted. ! ! If x is already in a, insert it to the right of the rightmost x. ! ! Optional args lo (default 0) and hi (default len(a)) bound the ! slice of a to be searched. ! """ ! if hi is None: hi = len(a) *************** *** 12,18 **** a.insert(lo, x) ! def bisect(a, x, lo=0, hi=None): ! """Find the index where to insert item x in list a, assuming a is sorted.""" if hi is None: hi = len(a) --- 19,35 ---- a.insert(lo, x) + insort = insort_right # backward compatibility + + def bisect_right(a, x, lo=0, hi=None): + """Return the index where to insert item x in list a, assuming a is sorted. ! The return value i is such that all e in a[:i] have e <= x, and all e in ! a[i:] have e > x. So if x already appears in the list, i points just ! beyond the rightmost x already there. ! ! Optional args lo (default 0) and hi (default len(a)) bound the ! slice of a to be searched. ! """ ! if hi is None: hi = len(a) *************** *** 21,23 **** --- 38,79 ---- if x < a[mid]: hi = mid else: lo = mid+1 + return lo + + bisect = bisect_right # backward compatibility + + def insort_left(a, x, lo=0, hi=None): + """Insert item x in list a, and keep it sorted assuming a is sorted. + + If x is already in a, insert it to the left of the leftmost x. + + Optional args lo (default 0) and hi (default len(a)) bound the + slice of a to be searched. + """ + + if hi is None: + hi = len(a) + while lo < hi: + mid = (lo+hi)/2 + if a[mid] < x: lo = mid+1 + else: hi = mid + a.insert(lo, x) + + + def bisect_left(a, x, lo=0, hi=None): + """Return the index where to insert item x in list a, assuming a is sorted. + + The return value i is such that all e in a[:i] have e < x, and all e in + a[i:] have e >= x. So if x already appears in the list, i points just + before the leftmost x already there. + + Optional args lo (default 0) and hi (default len(a)) bound the + slice of a to be searched. + """ + + if hi is None: + hi = len(a) + while lo < hi: + mid = (lo+hi)/2 + if a[mid] < x: lo = mid+1 + else: hi = mid return lo From python-dev@python.org Fri Dec 29 02:06:47 2000 From: python-dev@python.org (Tim Peters) Date: Thu, 28 Dec 2000 18:06:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.86,1.87 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv26508/python/dist/src/Misc Modified Files: NEWS Log Message: Fred, THIS NEEDS DOCS! The function docstrings tell the tale. Christmas present to myself: the bisect module didn't define what happened if the new element was already in the list. It so happens that it inserted the new element "to the right" of all equal elements. Since it wasn't defined, among other bad implications it was a mystery how to use bisect to determine whether an element was already in the list (I've seen code that *assumed* "to the right" without justification). Added new methods bisect_left and insort_left that insert "to the left" instead; made the old names bisect and insort aliases for the new names bisect_right and insort_right; beefed up docstrings to explain what these actually do; and added a std test for the bisect module. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -r1.86 -r1.87 *** NEWS 2000/12/15 01:16:43 1.86 --- NEWS 2000/12/29 02:06:45 1.87 *************** *** 35,38 **** --- 35,50 ---- using popitem() they can usually be made to run in linear time. + + Standard library + + - The bisect module has new functions bisect_left, insort_left, + bisect_right and insort_right. The old names bisect and insort + are now aliases for bisect_right and insort_right. XXX_right + and XXX_left methods differ in what happens when the new element + compares equal to one or more elements already in the list: the + XXX_left methods insert to the left, the XXX_right methods to the + right. + + Windows changes From python-dev@python.org Fri Dec 29 02:17:58 2000 From: python-dev@python.org (Tim Peters) Date: Thu, 28 Dec 2000 18:17:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib getopt.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv28119/python/dist/src/Lib Modified Files: getopt.py Log Message: getopt used to sort the long option names, in an attempt to simplify the logic. That resulted in a bug. My previous getopt checkin repaired the bug but left the sorting. The solution is significantly simpler if we don't bother sorting at all, so this checkin gets rid of the sort and the code that relied on it. Index: getopt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/getopt.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** getopt.py 2000/12/27 08:05:05 1.12 --- getopt.py 2000/12/29 02:17:56 1.13 *************** *** 66,70 **** else: longopts = list(longopts) - longopts.sort() while args and args[0].startswith('-') and args[0] != '-': if args[0] == '--': --- 66,69 ---- *************** *** 100,116 **** # has_arg? # full option name - # Assumes longopts has been sorted (ASCII order). def long_has_args(opt, longopts): ! for i in range(len(longopts)): ! if longopts[i].startswith(opt): ! break ! else: raise GetoptError('option --%s not recognized' % opt, opt) - # opt is a prefix of longopts[i]; find j s.t. opt is a prefix of - # each possibility in longopts[i:j] - j = i+1 - while j < len(longopts) and longopts[j].startswith(opt): - j += 1 - possibilities = longopts[i:j] # Is there an exact match? if opt in possibilities: --- 99,106 ---- # has_arg? # full option name def long_has_args(opt, longopts): ! possibilities = [o for o in longopts if o.startswith(opt)] ! if not possibilities: raise GetoptError('option --%s not recognized' % opt, opt) # Is there an exact match? if opt in possibilities: From python-dev@python.org Sat Dec 30 22:21:25 2000 From: python-dev@python.org (Tim Peters) Date: Sat, 30 Dec 2000 14:21:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test regrtest.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv20342/python/dist/src/lib/test Modified Files: regrtest.py Log Message: Christmas present to myself: changed regrtest in two ways: 1. When running in verbose mode, if any test happens to pass, print a warning that the apparent success may be bogus (stdout isn't compared in verbose mode). Been fooled by that too often. 2. When a test fails because the expected stdout doesn't match the actual stdout, print as much of stdout as did match before the first failing write. Else we get failures of the form "expected 'a', got 'b'" and a glance at the expected output file shows 500 instances of 'a' -- no idea where it failed, and, as in #1, trying to run in verbose mode instead doesn't help because stdout isn't compared then. Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -r1.28 -r1.29 *** regrtest.py 2000/12/12 23:11:42 1.28 --- regrtest.py 2000/12/30 22:21:22 1.29 *************** *** 159,162 **** --- 159,165 ---- print "All", print count(len(good), "test"), "OK." + if verbose: + print "CAUTION: stdout isn't compared in verbose mode: a test" + print "that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:", *************** *** 281,290 **** def __init__(self, filename): self.fp = open(filename, 'r') def write(self, data): expected = self.fp.read(len(data)) ! if data != expected: ! raise test_support.TestFailed, \ ! 'Writing: '+`data`+', expected: '+`expected` def writelines(self, listoflines): --- 284,315 ---- def __init__(self, filename): self.fp = open(filename, 'r') + self.stuffthatmatched = [] def write(self, data): expected = self.fp.read(len(data)) ! if data == expected: ! self.stuffthatmatched.append(expected) ! else: ! # This Compare instance is spoofing stdout, so we need to write ! # to stderr instead. ! from sys import stderr as e ! print >> e, "The actual stdout doesn't match the expected stdout." ! if self.stuffthatmatched: ! print >> e, "This much did match (between asterisk lines):" ! print >> e, "*" * 70 ! good = "".join(self.stuffthatmatched) ! e.write(good) ! if not good.endswith("\n"): ! e.write("\n") ! print >> e, "*" * 70 ! print >> e, "Then ..." ! else: ! print >> e, "The first write to stdout clashed:" ! # Note that the prompts are the same length in next two lines. ! # This is so what we expected and what we got line up. ! print >> e, "We expected (repr):", `expected` ! print >> e, "But instead we got:", `data` ! raise test_support.TestFailed('Writing: ' + `data`+ ! ', expected: ' + `expected`) def writelines(self, listoflines): *************** *** 297,301 **** leftover = self.fp.read() if leftover: ! raise test_support.TestFailed, 'Unread: '+`leftover` self.fp.close() --- 322,327 ---- leftover = self.fp.read() if leftover: ! raise test_support.TestFailed('Tail of expected stdout unseen: ' + ! `leftover`) self.fp.close() From python-dev@python.org Sun Dec 31 03:50:25 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 30 Dec 2000 19:50:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom minidom.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory usw-pr-cvs1:/tmp/cvs-serv29110 Modified Files: minidom.py Log Message: Patch #102485 ] Check for legal children when adding children to a DOM node Index: minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/minidom.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** minidom.py 2000/12/28 18:40:56 1.17 --- minidom.py 2000/12/31 03:50:23 1.18 *************** *** 19,22 **** --- 19,24 ---- del string + from xml.dom import HierarchyRequestErr + # localize the types, and allow support for Unicode values if available: import types *************** *** 38,42 **** _makeParentNodes = 1 debug = None ! def __init__(self): self.childNodes = [] --- 40,45 ---- _makeParentNodes = 1 debug = None ! childNodeTypes = () ! def __init__(self): self.childNodes = [] *************** *** 100,103 **** --- 103,109 ---- def insertBefore(self, newChild, refChild): + if newChild.nodeType not in self.childNodeTypes: + raise HierarchyRequestErr, \ + "%s cannot be child of %s" % (repr(newChild), repr(self) ) if newChild.parentNode is not None: newChild.parentNode.removeChild(newChild) *************** *** 120,123 **** --- 126,132 ---- def appendChild(self, node): + if node.nodeType not in self.childNodeTypes: + raise HierarchyRequestErr, \ + "%s cannot be child of %s" % (repr(node), repr(self) ) if node.parentNode is not None: node.parentNode.removeChild(node) *************** *** 135,138 **** --- 144,150 ---- def replaceChild(self, newChild, oldChild): + if newChild.nodeType not in self.childNodeTypes: + raise HierarchyRequestErr, \ + "%s cannot be child of %s" % (repr(newChild), repr(self) ) if newChild.parentNode is not None: newChild.parentNode.removeChild(newChild) *************** *** 251,255 **** attributes = None ownerElement = None ! def __init__(self, qName, namespaceURI="", localName=None, prefix=None): # skip setattr for performance --- 263,268 ---- attributes = None ownerElement = None ! childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) ! def __init__(self, qName, namespaceURI="", localName=None, prefix=None): # skip setattr for performance *************** *** 375,379 **** nextSibling = None previousSibling = None ! def __init__(self, tagName, namespaceURI="", prefix="", localName=None): --- 388,395 ---- nextSibling = None previousSibling = None ! childNodeTypes = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, ! Node.COMMENT_NODE, Node.TEXT_NODE, ! Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE) ! def __init__(self, tagName, namespaceURI="", prefix="", localName=None): *************** *** 509,513 **** nodeName = "#comment" attributes = None ! def __init__(self, data): Node.__init__(self) --- 525,530 ---- nodeName = "#comment" attributes = None ! childNodeTypes = () ! def __init__(self, data): Node.__init__(self) *************** *** 520,524 **** nodeType = Node.PROCESSING_INSTRUCTION_NODE attributes = None ! def __init__(self, target, data): Node.__init__(self) --- 537,542 ---- nodeType = Node.PROCESSING_INSTRUCTION_NODE attributes = None ! childNodeTypes = () ! def __init__(self, target, data): Node.__init__(self) *************** *** 533,537 **** nodeName = "#text" attributes = None ! def __init__(self, data): Node.__init__(self) --- 551,556 ---- nodeName = "#text" attributes = None ! childNodeTypes = () ! def __init__(self, data): Node.__init__(self) *************** *** 628,633 **** --- 647,657 ---- implementation = DOMImplementation() + childNodeTypes = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, + Node.COMMENT_NODE, Node.DOCUMENT_TYPE_NODE) def appendChild(self, node): + if node.nodeType not in self.childNodeTypes: + raise HierarchyRequestErr, \ + "%s cannot be child of %s" % (repr(node), repr(self) ) if node.parentNode is not None: node.parentNode.removeChild(node) From python-dev@python.org Sun Dec 31 04:03:29 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 30 Dec 2000 20:03:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_minidom.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv29510 Modified Files: test_minidom.py Log Message: Added test case for legal DOM children Index: test_minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_minidom.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** test_minidom.py 2000/12/15 21:31:59 1.17 --- test_minidom.py 2000/12/31 04:03:27 1.18 *************** *** 77,80 **** --- 77,104 ---- dom.unlink() + def testLegalChildren(): + dom = Document() + elem = dom.createElement('element') + text = dom.createTextNode('text') + + try: dom.appendChild(text) + except HierarchyRequestErr: pass + else: + print "dom.appendChild didn't raise HierarchyRequestErr" + + dom.appendChild(elem) + try: dom.insertBefore(text, elem) + except HierarchyRequestErr: pass + else: + print "dom.appendChild didn't raise HierarchyRequestErr" + + try: dom.replaceChild(text, elem) + except HierarchyRequestErr: pass + else: + print "dom.appendChild didn't raise HierarchyRequestErr" + + elem.appendChild(text) + dom.unlink() + def testNonZero(): dom = parse(tstfile) *************** *** 280,284 **** def testCreateElementNS(): pass ! def testCreatAttributeNS(): pass def testParse(): pass --- 304,308 ---- def testCreateElementNS(): pass ! def testCreateAttributeNS(): pass def testParse(): pass From python-dev@python.org Sun Dec 31 04:03:29 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 30 Dec 2000 20:03:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_minidom,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv29510/output Modified Files: test_minidom Log Message: Added test case for legal DOM children Index: test_minidom =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_minidom,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** test_minidom 2000/12/14 18:20:22 1.11 --- test_minidom 2000/12/31 04:03:27 1.12 *************** *** 77,81 **** Test Succeeded testComment Passed assertion: len(Node.allnodes) == 0 ! Test Succeeded testCreatAttributeNS Passed assertion: len(Node.allnodes) == 0 Test Succeeded testCreateElementNS --- 77,81 ---- Test Succeeded testComment Passed assertion: len(Node.allnodes) == 0 ! Test Succeeded testCreateAttributeNS Passed assertion: len(Node.allnodes) == 0 Test Succeeded testCreateElementNS *************** *** 121,124 **** --- 121,126 ---- Passed testInsertBefore -- node properly placed in tree Test Succeeded testInsertBefore + Passed assertion: len(Node.allnodes) == 0 + Test Succeeded testLegalChildren Passed assertion: len(Node.allnodes) == 0 Passed Test From python-dev@python.org Sun Dec 31 22:53:01 2000 From: python-dev@python.org (Thomas Wouters) Date: Sun, 31 Dec 2000 14:53:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref7.tex,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv27527 Modified Files: ref7.tex Log Message: Change documentation of 'else' clause of 'try/except' to make clear that it doesn't get triggered by 'return', 'break' or 'continue'. If the 'try-inside-continue' patch does not get accepted before next release, the 'or continue' should be removed ;P Closes SF patch #103045 and SF bug #127098. Index: ref7.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref7.tex,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** ref7.tex 2000/07/16 19:05:38 1.20 --- ref7.tex 2000/12/31 22:52:59 1.21 *************** *** 243,249 **** \ttindex{exc_value}\ttindex{exc_traceback}} ! The optional \keyword{else} clause is executed when no exception occurs ! in the \keyword{try} clause. Exceptions in the \keyword{else} clause are ! not handled by the preceding \keyword{except} clauses. \kwindex{else} --- 243,251 ---- \ttindex{exc_value}\ttindex{exc_traceback}} ! The optional \keyword{else} clause is executed when the \keyword{try} clause ! terminates by any means other than an exception or executing a ! \keyword{return}, \keyword{continue} or \keyword{break} statement. ! Exceptions in the \keyword{else} clause are not handled by the preceding ! \keyword{except} clauses. \kwindex{else} From python-dev@python.org Fri Dec 1 07:59:38 2000 From: python-dev@python.org (Tim Peters) Date: Thu, 30 Nov 2000 23:59:38 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.82,1.83 Message-ID: <200012010759.XAA29918@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv29841/python/dist/src/misc Modified Files: NEWS Log Message: Made the description of %[udxXo] formats of negative longs in 2.1 more accurate. I suggested to Guido that %u be deprecated (it seems useless in Python to me). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -r1.82 -r1.83 *** NEWS 2000/11/30 05:22:43 1.82 --- NEWS 2000/12/01 07:59:35 1.83 *************** *** 4,8 **** Core language, builtins, and interpreter ! - %[duxXo] formats of negative Python longs now produce a sign character. In 1.6 and earlier, they never produced a sign, and raised an error if the value of the long was too large --- 4,8 ---- Core language, builtins, and interpreter ! - %[xXo] formats of negative Python longs now produce a sign character. In 1.6 and earlier, they never produced a sign, and raised an error if the value of the long was too large *************** *** 13,20 **** >>> "%x" % -0x42L ! '-42' # in 2.1 'ffffffbe' # in 2.0 and before, on 32-bit machines >>> hex(-0x42L) '-0x42L' # in all versions of Python --- 13,30 ---- >>> "%x" % -0x42L ! '-42' # in 2.1 'ffffffbe' # in 2.0 and before, on 32-bit machines >>> hex(-0x42L) '-0x42L' # in all versions of Python + + The behavior of %d formats for negative Python longs remains + the same as in 2.0 (although in 1.6 and before, they raised + an error if the long didn't fit in a Python int). + + %u formats don't make sense for Python longs, but are allowed + and treated the same as %d in 2.1. In 2.0, a negative long + formatted via %u produced a sign if and only if too large to + fit in an int. In 1.6 and earlier, a negative long formatted + via %u raised an error if it was too big to fit in an int. From python-dev@python.org Fri Dec 1 12:59:07 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 1 Dec 2000 04:59:07 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python getargs.c,2.49,2.50 Message-ID: <200012011259.EAA13346@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv13337 Modified Files: getargs.c Log Message: Clarified some of the error messages, esp. "read-only character buffer" replaced by "string or read-only character buffer". Index: getargs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v retrieving revision 2.49 retrieving revision 2.50 diff -C2 -r2.49 -r2.50 *** getargs.c 2000/09/26 05:46:01 2.49 --- getargs.c 2000/12/01 12:59:05 2.50 *************** *** 566,570 **** arg, NULL); if (arg == NULL) ! return "unicode conversion error"; *p = PyString_AS_STRING(arg); *q = PyString_GET_SIZE(arg); --- 566,570 ---- arg, NULL); if (arg == NULL) ! return "(unicode conversion error)"; *p = PyString_AS_STRING(arg); *q = PyString_GET_SIZE(arg); *************** *** 576,582 **** pb->bf_getreadbuffer == NULL || pb->bf_getsegcount == NULL ) ! return "read-only buffer"; if ( (*pb->bf_getsegcount)(arg, NULL) != 1 ) ! return "single-segment read-only buffer"; if ( (count = (*pb->bf_getreadbuffer)(arg, 0, p)) < 0 ) --- 576,582 ---- pb->bf_getreadbuffer == NULL || pb->bf_getsegcount == NULL ) ! return "string or read-only buffer"; if ( (*pb->bf_getsegcount)(arg, NULL) != 1 ) ! return "string or single-segment read-only buffer"; if ( (count = (*pb->bf_getreadbuffer)(arg, 0, p)) < 0 ) *************** *** 594,598 **** arg, NULL); if (arg == NULL) ! return "unicode conversion error"; *p = PyString_AS_STRING(arg); } --- 594,598 ---- arg, NULL); if (arg == NULL) ! return "(unicode conversion error)"; *p = PyString_AS_STRING(arg); } *************** *** 623,627 **** arg, NULL); if (arg == NULL) ! return "unicode conversion error"; *p = PyString_AS_STRING(arg); *q = PyString_GET_SIZE(arg); --- 623,627 ---- arg, NULL); if (arg == NULL) ! return "(unicode conversion error)"; *p = PyString_AS_STRING(arg); *q = PyString_GET_SIZE(arg); *************** *** 633,639 **** pb->bf_getreadbuffer == NULL || pb->bf_getsegcount == NULL ) ! return "read-only buffer"; if ( (*pb->bf_getsegcount)(arg, NULL) != 1 ) ! return "single-segment read-only buffer"; if ( (count = (*pb->bf_getreadbuffer)(arg, 0, p)) < 0 ) --- 633,639 ---- pb->bf_getreadbuffer == NULL || pb->bf_getsegcount == NULL ) ! return "string or read-only buffer"; if ( (*pb->bf_getsegcount)(arg, NULL) != 1 ) ! return "string or single-segment read-only buffer"; if ( (count = (*pb->bf_getreadbuffer)(arg, 0, p)) < 0 ) *************** *** 653,661 **** arg, NULL); if (arg == NULL) ! return "unicode conversion error"; *p = PyString_AS_STRING(arg); } else ! return "None or string"; if (*format == '#') { int *q = va_arg(*p_va, int *); --- 653,661 ---- arg, NULL); if (arg == NULL) ! return "(unicode conversion error)"; *p = PyString_AS_STRING(arg); } else ! return "string or None"; if (*format == '#') { int *q = va_arg(*p_va, int *); *************** *** 668,672 **** else if (*p != NULL && (int)strlen(*p) != PyString_Size(arg)) ! return "None or string without null bytes"; } break; --- 668,672 ---- else if (*p != NULL && (int)strlen(*p) != PyString_Size(arg)) ! return "string without null bytes or None"; } break; *************** *** 696,700 **** u = PyUnicode_FromObject(arg); if (u == NULL) ! return "string, unicode or text buffer"; /* Encode object; use default error handling */ --- 696,700 ---- u = PyUnicode_FromObject(arg); if (u == NULL) ! return "string or unicode or text buffer"; /* Encode object; use default error handling */ *************** *** 774,779 **** */ if ((int)strlen(PyString_AS_STRING(s)) != size) ! return "(encoded string without "\ ! "NULL bytes)"; *buffer = PyMem_NEW(char, size + 1); if (*buffer == NULL) { --- 774,778 ---- */ if ((int)strlen(PyString_AS_STRING(s)) != size) ! return "(encoded string without NULL bytes)"; *buffer = PyMem_NEW(char, size + 1); if (*buffer == NULL) { *************** *** 800,806 **** pb->bf_getreadbuffer == NULL || pb->bf_getsegcount == NULL ) ! return "read-only buffer"; if ( (*pb->bf_getsegcount)(arg, NULL) != 1 ) ! return "single-segment read-only buffer"; if ( (count = (*pb->bf_getreadbuffer)(arg, 0, p)) < 0 ) --- 799,805 ---- pb->bf_getreadbuffer == NULL || pb->bf_getsegcount == NULL ) ! return "unicode or read-only buffer"; if ( (*pb->bf_getsegcount)(arg, NULL) != 1 ) ! return "unicode or single-segment read-only buffer"; if ( (count = (*pb->bf_getreadbuffer)(arg, 0, p)) < 0 ) *************** *** 917,923 **** pb->bf_getcharbuffer == NULL || pb->bf_getsegcount == NULL ) ! return "read-only character buffer"; if ( (*pb->bf_getsegcount)(arg, NULL) != 1 ) ! return "single-segment read-only buffer"; if ( (count = pb->bf_getcharbuffer(arg, 0, p)) < 0 ) return "(unspecified)"; --- 916,922 ---- pb->bf_getcharbuffer == NULL || pb->bf_getsegcount == NULL ) ! return "string or read-only character buffer"; if ( (*pb->bf_getsegcount)(arg, NULL) != 1 ) ! return "string or single-segment read-only buffer"; if ( (count = pb->bf_getcharbuffer(arg, 0, p)) < 0 ) return "(unspecified)"; From python-dev@python.org Fri Dec 1 13:13:14 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 1 Dec 2000 05:13:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules socketmodule.c,1.128,1.129 Message-ID: <200012011313.FAA14368@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv14356 Modified Files: socketmodule.c Log Message: Patch by Michael Hudson to clarify the error message from getsockaddrarg when the address is not a tuple. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.128 retrieving revision 1.129 diff -C2 -r1.128 -r1.129 *** socketmodule.c 2000/10/06 15:37:06 1.128 --- socketmodule.c 2000/12/01 13:13:11 1.129 *************** *** 606,610 **** int port; addr=(struct sockaddr_in*)&(s->sock_addr).in; ! if (!PyArg_Parse(args, "(si)", &host, &port)) return 0; if (setipaddr(host, addr) < 0) --- 606,616 ---- int port; addr=(struct sockaddr_in*)&(s->sock_addr).in; ! if (!PyTuple_Check(args)) { ! PyErr_Format(PyExc_TypeError, ! "getsockaddrarg: AF_INET address must be tuple, not %.500s", ! args->ob_type->tp_name); ! return 0; ! } ! if (!PyArg_ParseTuple(args, "si:getsockaddrarg", &host, &port)) return 0; if (setipaddr(host, addr) < 0) From python-dev@python.org Fri Dec 1 15:25:26 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 1 Dec 2000 07:25:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcgihttp.tex,1.4,1.5 libcmpcache.tex,1.3,1.4 libcmp.tex,1.2,1.3 libcodeop.tex,1.2,1.3 libcurses.tex,1.22,1.23 libdircache.tex,1.3,1.4 libdl.tex,1.2,1.3 libfilecmp.tex,1.2,1.3 libfpformat.tex,1.2,1.3 liblinecache.tex,1.3,1.4 libmutex.tex,1.3,1.4 libnew.tex,1.6,1.7 libnis.tex,1.4,1.5 libpipes.tex,1.3,1.4 libpty.tex,1.3,1.4 librlcompleter.tex,1.4,1.5 libsched.tex,1.4,1.5 libsimplehttp.tex,1.2,1.3 libstatcache.tex,1.2,1.3 libstatvfs.tex,1.3,1.4 libsunau.tex,1.4,1.5 libtty.tex,1.1,1.2 libturtle.tex,1.2,1.3 libwave.tex,1.4,1.5 Message-ID: <200012011525.HAA25749@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv25715 Modified Files: libcgihttp.tex libcmpcache.tex libcmp.tex libcodeop.tex libcurses.tex libdircache.tex libdl.tex libfilecmp.tex libfpformat.tex liblinecache.tex libmutex.tex libnew.tex libnis.tex libpipes.tex libpty.tex librlcompleter.tex libsched.tex libsimplehttp.tex libstatcache.tex libstatvfs.tex libsunau.tex libtty.tex libturtle.tex libwave.tex Log Message: Update Moshe Zadka's email address to one works and might last a while. Index: libcgihttp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcgihttp.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** libcgihttp.tex 2000/10/10 16:56:41 1.4 --- libcgihttp.tex 2000/12/01 15:25:23 1.5 *************** *** 5,9 **** \declaremodule{standard}{CGIHTTPServer} \platform{Unix} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{This module provides a request handler for HTTP servers which can run CGI scripts.} --- 5,9 ---- \declaremodule{standard}{CGIHTTPServer} \platform{Unix} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{This module provides a request handler for HTTP servers which can run CGI scripts.} Index: libcmpcache.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcmpcache.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** libcmpcache.tex 1999/10/26 16:31:51 1.3 --- libcmpcache.tex 2000/12/01 15:25:23 1.4 *************** *** 3,7 **** \declaremodule{standard}{cmpcache} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Compare files very efficiently.} --- 3,7 ---- \declaremodule{standard}{cmpcache} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Compare files very efficiently.} Index: libcmp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcmp.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libcmp.tex 1999/10/26 16:31:51 1.2 --- libcmp.tex 2000/12/01 15:25:23 1.3 *************** *** 3,7 **** \declaremodule{standard}{cmp} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Compare files very efficiently.} --- 3,7 ---- \declaremodule{standard}{cmp} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Compare files very efficiently.} Index: libcodeop.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcodeop.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libcodeop.tex 2000/04/03 20:13:53 1.2 --- libcodeop.tex 2000/12/01 15:25:23 1.3 *************** *** 5,9 **** \declaremodule{standard}{codeop} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Compile (possibly incomplete) Python code.} --- 5,9 ---- \declaremodule{standard}{codeop} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Compile (possibly incomplete) Python code.} Index: libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** libcurses.tex 2000/11/18 17:57:33 1.22 --- libcurses.tex 2000/12/01 15:25:23 1.23 *************** *** 3,7 **** \declaremodule{standard}{curses} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \sectionauthor{Eric Raymond}{esr@thyrsus.com} \modulesynopsis{An interface to the curses library, providing portable --- 3,7 ---- \declaremodule{standard}{curses} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \sectionauthor{Eric Raymond}{esr@thyrsus.com} \modulesynopsis{An interface to the curses library, providing portable Index: libdircache.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdircache.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** libdircache.tex 2000/07/16 19:01:09 1.3 --- libdircache.tex 2000/12/01 15:25:23 1.4 *************** *** 3,7 **** \declaremodule{standard}{dircache} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Return directory listing, with cache mechanism.} --- 3,7 ---- \declaremodule{standard}{dircache} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Return directory listing, with cache mechanism.} Index: libdl.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdl.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libdl.tex 2000/07/16 19:01:09 1.2 --- libdl.tex 2000/12/01 15:25:23 1.3 *************** *** 3,7 **** \declaremodule{extension}{dl} \platform{Unix} %?????????? Anyone???????????? ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Call C functions in shared objects.} --- 3,7 ---- \declaremodule{extension}{dl} \platform{Unix} %?????????? Anyone???????????? ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Call C functions in shared objects.} Index: libfilecmp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfilecmp.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libfilecmp.tex 2000/07/03 08:24:49 1.2 --- libfilecmp.tex 2000/12/01 15:25:23 1.3 *************** *** 3,7 **** \declaremodule{standard}{filecmp} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Compare files efficiently.} --- 3,7 ---- \declaremodule{standard}{filecmp} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Compare files efficiently.} Index: libfpformat.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfpformat.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libfpformat.tex 1999/12/21 18:45:16 1.2 --- libfpformat.tex 2000/12/01 15:25:23 1.3 *************** *** 3,7 **** \declaremodule{standard}{fpformat} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{General floating point formatting functions.} --- 3,7 ---- \declaremodule{standard}{fpformat} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{General floating point formatting functions.} Index: liblinecache.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liblinecache.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** liblinecache.tex 2000/04/03 20:13:53 1.3 --- liblinecache.tex 2000/12/01 15:25:23 1.4 *************** *** 3,7 **** \declaremodule{standard}{linecache} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{This module provides random access to individual lines from text files.} --- 3,7 ---- \declaremodule{standard}{linecache} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{This module provides random access to individual lines from text files.} Index: libmutex.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmutex.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** libmutex.tex 2000/07/16 19:01:09 1.3 --- libmutex.tex 2000/12/01 15:25:23 1.4 *************** *** 4,8 **** \declaremodule{standard}{mutex} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Lock and queue for mutual exclusion.} --- 4,8 ---- \declaremodule{standard}{mutex} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Lock and queue for mutual exclusion.} Index: libnew.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libnew.tex,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** libnew.tex 2000/10/10 22:00:03 1.6 --- libnew.tex 2000/12/01 15:25:23 1.7 *************** *** 3,7 **** \declaremodule{builtin}{new} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Interface to the creation of runtime implementation objects.} --- 3,7 ---- \declaremodule{builtin}{new} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Interface to the creation of runtime implementation objects.} Index: libnis.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libnis.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** libnis.tex 2000/07/16 19:01:09 1.4 --- libnis.tex 2000/12/01 15:25:23 1.5 *************** *** 5,9 **** \platform{UNIX} \moduleauthor{Fred Gansevles}{Fred.Gansevles@cs.utwente.nl} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Interface to Sun's NIS (a.k.a. Yellow Pages) library.} --- 5,9 ---- \platform{UNIX} \moduleauthor{Fred Gansevles}{Fred.Gansevles@cs.utwente.nl} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Interface to Sun's NIS (a.k.a. Yellow Pages) library.} Index: libpipes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpipes.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** libpipes.tex 2000/07/16 19:01:10 1.3 --- libpipes.tex 2000/12/01 15:25:23 1.4 *************** *** 4,8 **** \declaremodule{standard}{pipes} \platform{Unix} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{A Python interface to \UNIX{} shell pipelines.} --- 4,8 ---- \declaremodule{standard}{pipes} \platform{Unix} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{A Python interface to \UNIX{} shell pipelines.} Index: libpty.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpty.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** libpty.tex 2000/06/28 17:27:48 1.3 --- libpty.tex 2000/12/01 15:25:23 1.4 *************** *** 5,9 **** \modulesynopsis{Pseudo-Terminal Handling for SGI and Linux.} \moduleauthor{Steen Lumholt}{} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} --- 5,9 ---- \modulesynopsis{Pseudo-Terminal Handling for SGI and Linux.} \moduleauthor{Steen Lumholt}{} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} Index: librlcompleter.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/librlcompleter.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** librlcompleter.tex 2000/10/10 17:03:45 1.4 --- librlcompleter.tex 2000/12/01 15:25:23 1.5 *************** *** 4,8 **** \declaremodule{standard}{rlcompleter} \platform{Unix} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Python identifier completion for the GNU readline library.} --- 4,8 ---- \declaremodule{standard}{rlcompleter} \platform{Unix} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Python identifier completion for the GNU readline library.} Index: libsched.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsched.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** libsched.tex 2000/07/16 19:01:10 1.4 --- libsched.tex 2000/12/01 15:25:23 1.5 *************** *** 5,9 **** \declaremodule{standard}{sched} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{General purpose event scheduler.} --- 5,9 ---- \declaremodule{standard}{sched} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{General purpose event scheduler.} Index: libsimplehttp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsimplehttp.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libsimplehttp.tex 2000/10/10 16:59:53 1.2 --- libsimplehttp.tex 2000/12/01 15:25:23 1.3 *************** *** 3,7 **** \declaremodule{standard}{SimpleHTTPServer} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{This module provides a basic request handler for HTTP servers.} --- 3,7 ---- \declaremodule{standard}{SimpleHTTPServer} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{This module provides a basic request handler for HTTP servers.} Index: libstatcache.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstatcache.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libstatcache.tex 1999/06/17 17:09:23 1.2 --- libstatcache.tex 2000/12/01 15:25:23 1.3 *************** *** 3,7 **** \declaremodule{standard}{statcache} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Stat files, and remember results.} --- 3,7 ---- \declaremodule{standard}{statcache} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Stat files, and remember results.} Index: libstatvfs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstatvfs.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** libstatvfs.tex 2000/07/16 19:01:10 1.3 --- libstatvfs.tex 2000/12/01 15:25:23 1.4 *************** *** 4,8 **** \declaremodule{standard}{statvfs} % LaTeX'ed from comments in module ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Constants for interpreting the result of \function{os.statvfs()}.} --- 4,8 ---- \declaremodule{standard}{statvfs} % LaTeX'ed from comments in module ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Constants for interpreting the result of \function{os.statvfs()}.} Index: libsunau.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsunau.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** libsunau.tex 2000/11/17 19:05:11 1.4 --- libsunau.tex 2000/12/01 15:25:23 1.5 *************** *** 3,7 **** \declaremodule{standard}{sunau} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Provide an interface to the Sun AU sound format.} --- 3,7 ---- \declaremodule{standard}{sunau} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Provide an interface to the Sun AU sound format.} Index: libtty.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtty.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** libtty.tex 1999/06/23 14:30:19 1.1 --- libtty.tex 2000/12/01 15:25:23 1.2 *************** *** 5,9 **** \platform{Unix} \moduleauthor{Steen Lumholt}{} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Utility functions that perform common terminal control operations.} --- 5,9 ---- \platform{Unix} \moduleauthor{Steen Lumholt}{} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Utility functions that perform common terminal control operations.} Index: libturtle.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libturtle.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libturtle.tex 1999/11/17 16:09:57 1.2 --- libturtle.tex 2000/12/01 15:25:23 1.3 *************** *** 7,11 **** \modulesynopsis{An environment for turtle graphics.} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} --- 7,11 ---- \modulesynopsis{An environment for turtle graphics.} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} Index: libwave.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwave.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** libwave.tex 2000/07/16 19:01:10 1.4 --- libwave.tex 2000/12/01 15:25:23 1.5 *************** *** 4,8 **** \declaremodule{standard}{wave} ! \sectionauthor{Moshe Zadka}{mzadka@geocities.com} \modulesynopsis{Provide an interface to the WAV sound format.} --- 4,8 ---- \declaremodule{standard}{wave} ! \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} \modulesynopsis{Provide an interface to the WAV sound format.} From python-dev@python.org Fri Dec 1 23:50:48 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 1 Dec 2000 15:50:48 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0229.txt,1.1,1.2 Message-ID: <200012012350.PAA31895@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv31855 Modified Files: pep-0229.txt Log Message: Refer to SF patch Add apparent resolution of one open issue Index: pep-0229.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0229.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** pep-0229.txt 2000/11/22 19:17:06 1.1 --- pep-0229.txt 2000/12/01 23:50:46 1.2 *************** *** 51,54 **** --- 51,69 ---- + Implementation + + Patch #102588 on SourceForge will contain the proposed patch. + As of Dec. 1, the patch does the following: + + * Removes the use of makesetup in building the interpreter. + * Hard-codes the presence of the strop, posix, and _sre modules. + * Adds an empty top-level setup.py file. + + Still to be done: + + * Write the top-level setup.py + * Handle a few tricky bits such as the signal module. + + Unresolved Issues *************** *** 60,63 **** --- 75,83 ---- we support compiling them statically into the resulting Python binary? + + [Answer: building a Python binary with the Distutils should be + feasible, though no one has implemented it yet. This will need to + be done, though the main setup.py will probably need to implement + its own BuildExt subclass anyway.] makesetup and the other contents of $(LIBPL)/config need to be From python-dev@python.org Sat Dec 2 03:38:01 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 1 Dec 2000 19:38:01 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0231.txt,NONE,1.1 Message-ID: <200012020338.TAA14006@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv13988 Added Files: pep-0231.txt Log Message: PEP 231, __findattr__(), Barry Warsaw --- NEW FILE --- PEP: 231 Title: __findattr__() Version: $Revision: 1.1 $ Author: barry@digicool.com (Barry A. Warsaw) Python-Version: 2.1 Status: Draft Created: 30-Nov-2000 Post-History: Introduction This PEP describes an extension to instance attribute lookup and modification machinery, which allows pure-Python implementations of many interesting programming models. This PEP tracks the status and ownership of this feature. It contains a description of the feature and outlines changes necessary to support the feature. This PEP summarizes discussions held in mailing list forums, and provides URLs for further information, where appropriate. The CVS revision history of this file contains the definitive historical record. Background The semantics for Python instances allow the programmer to customize some aspects of attribute lookup and attribute modification, through the special methods __getattr__() and __setattr__() [1]. However, because of certain restrictions imposed by these methods, there are useful programming techniques that can not be written in Python alone, e.g. strict Java Bean-like[2] interfaces and Zope style acquisitions[3]. In the latter case, Zope solves this by including a C extension called ExtensionClass[5] which modifies the standard class semantics, and uses a metaclass hook in Python's class model called alternatively the "Don Beaudry Hook" or "Don Beaudry Hack"[6]. While Zope's approach works, it has several disadvantages. First, it requires a C extension. Second it employs a very arcane, but truck-sized loophole in the Python machinery. Third, it can be difficult for other programmers to use and understand (the metaclass has well-known brain exploding properties). And fourth, because ExtensionClass instances aren't "real" Python instances, some aspects of the Python runtime system don't work with ExtensionClass instances. Proposals for fixing this problem have often been lumped under the rubric of fixing the "class/type dichotomy"; that is, eliminating the difference between built-in types and classes[7]. While a laudable goal itself, repairing this rift is not necessary in order to achieve the types of programming constructs described above. This proposal provides an 80% solution with a minimum of modification to Python's class and instance objects. It does nothing to address the type/class dichotomy. Proposal This proposal adds a new special method called __findattr__() with the following semantics: * If defined in a class, it will be called on all instance attribute resolutions instead of __getattr__() and __setattr__(). * __findattr__() is never called recursively. That is, when a specific instance's __findattr__() is on the call stack, further attribute accesses for that instance will use the standard __getattr__() and __setattr__() methods. * __findattr__() is called for both attribute access (`getting') and attribute modification (`setting'). It is not called for attribute deletion. * When called for getting, it is passed a single argument (not counting `self'): the name of the attribute being accessed. * When called for setting, it is called with third argument, which is the value to set the attribute to. * __findattr__() methods have the same caching semantics as __getattr__() and __setattr__(); i.e. if they are present in the class at class definition time, they are used, but if they are subsequently added to a class later they are not. Key Differences with the Existing Protocol __findattr__()'s semantics are different from the existing protocol in key ways: First, __getattr__() is never called if the attribute is found in the instance's __dict__. This is done for efficiency reasons, and because otherwise, __setattr__() would have no way to get to the instance's attributes. Second, __setattr__() cannot use "normal" syntax for setting instance attributes, e.g. "self.name = foo" because that would cause recursive calls to __setattr__(). __findattr__() is always called regardless of whether the attribute is in __dict__ or not, and a flag in the instance object prevents recursive calls to __findattr__(). This gives the class a chance to perform some action for every attribute access. And because it is called for both gets and sets, it is easy to write similar policy for all attribute access. Further, efficiency is not a problem because it is only paid when the extended mechanism is used. Examples One programming style that this proposal allows is a Java Bean-like interface to objects, where unadorned attribute access and modification is transparently mapped to a functional interface. E.g. class Bean: def __init__(self, x): self.__myfoo = x def __findattr__(self, name, *args): if name.startswith('_'): # Private names if args: setattr(self, name, args[0]) else: return getattr(self, name) else: # Public names if args: name = '_set_' + name else: name = '_get_' + name return getattr(self, name)(*args) def _set_foo(self, x): self.__myfoo = x def _get_foo(self): return self.__myfoo b = Bean(3) print b.foo b.foo = 9 print b.foo A second, more elaborate example is the implementation of both implicit and explicit acquisition in pure Python: import types class MethodWrapper: def __init__(self, container, method): self.__container = container self.__method = method def __call__(self, *args, **kws): return self.__method.im_func(self.__container, *args, **kws) class WrapperImplicit: def __init__(self, contained, container): self.__contained = contained self.__container = container def __repr__(self): return '' % (self.__container, self.__contained) def __findattr__(self, name, *args): # Some things are our own if name.startswith('_WrapperImplicit__'): if args: return setattr(self, name, *args) else: return getattr(self, name) # setattr stores the name on the contained object directly if args: return setattr(self.__contained, name, args[0]) # Other special names if name == 'aq_parent': return self.__container elif name == 'aq_self': return self.__contained elif name == 'aq_base': base = self.__contained try: while 1: base = base.aq_self except AttributeError: return base # no acquisition for _ names if name.startswith('_'): return getattr(self.__contained, name) # Everything else gets wrapped missing = () which = self.__contained obj = getattr(which, name, missing) if obj is missing: which = self.__container obj = getattr(which, name, missing) if obj is missing: raise AttributeError, name of = getattr(obj, '__of__', missing) if of is not missing: return of(self) elif type(obj) == types.MethodType: return MethodWrapper(self, obj) return obj class WrapperExplicit: def __init__(self, contained, container): self.__contained = contained self.__container = container def __repr__(self): return '' % (self.__container, self.__contained) def __findattr__(self, name, *args): # Some things are our own if name.startswith('_WrapperExplicit__'): if args: return setattr(self, name, *args) else: return getattr(self, name) # setattr stores the name on the contained object directly if args: return setattr(self.__contained, name, args[0]) # Other special names if name == 'aq_parent': return self.__container elif name == 'aq_self': return self.__contained elif name == 'aq_base': base = self.__contained try: while 1: base = base.aq_self except AttributeError: return base elif name == 'aq_acquire': return self.aq_acquire # explicit acquisition only obj = getattr(self.__contained, name) if type(obj) == types.MethodType: return MethodWrapper(self, obj) return obj def aq_acquire(self, name): # Everything else gets wrapped missing = () which = self.__contained obj = getattr(which, name, missing) if obj is missing: which = self.__container obj = getattr(which, name, missing) if obj is missing: raise AttributeError, name of = getattr(obj, '__of__', missing) if of is not missing: return of(self) elif type(obj) == types.MethodType: return MethodWrapper(self, obj) return obj class Implicit: def __of__(self, container): return WrapperImplicit(self, container) def __findattr__(self, name, *args): # ignore setattrs if args: return setattr(self, name, args[0]) obj = getattr(self, name) missing = () of = getattr(obj, '__of__', missing) if of is not missing: return of(self) return obj class Explicit(Implicit): def __of__(self, container): return WrapperExplicit(self, container) # tests class C(Implicit): color = 'red' class A(Implicit): def report(self): return self.color # simple implicit acquisition c = C() a = A() c.a = a assert c.a.report() == 'red' d = C() d.color = 'green' d.a = a assert d.a.report() == 'green' try: a.report() except AttributeError: pass else: assert 0, 'AttributeError expected' # special names assert c.a.aq_parent is c assert c.a.aq_self is a c.a.d = d assert c.a.d.aq_base is d assert c.a is not a # no acquisiton on _ names class E(Implicit): _color = 'purple' class F(Implicit): def report(self): return self._color e = E() f = F() e.f = f try: e.f.report() except AttributeError: pass else: assert 0, 'AttributeError expected' # explicit class G(Explicit): color = 'pink' class H(Explicit): def report(self): return self.aq_acquire('color') def barf(self): return self.color g = G() h = H() g.h = h assert g.h.report() == 'pink' i = G() i.color = 'cyan' i.h = h assert i.h.report() == 'cyan' try: g.i.barf() except AttributeError: pass else: assert 0, 'AttributeError expected' And finally, C++-like access control can also be accomplished, although less cleanly because of the difficulty of figuring out what method is being called from the runtime call stack: import sys import types PUBLIC = 0 PROTECTED = 1 PRIVATE = 2 try: getframe = sys._getframe except ImportError: def getframe(n): try: raise Exception except Exception: frame = sys.exc_info()[2].tb_frame while n > 0: frame = frame.f_back if frame is None: raise ValueError, 'call stack is not deep enough' return frame class AccessViolation(Exception): pass class Access: def __findattr__(self, name, *args): methcache = self.__dict__.setdefault('__cache__', {}) missing = () obj = getattr(self, name, missing) # if obj is missing we better be doing a setattr for # the first time if obj is not missing and type(obj) == types.MethodType: # Digusting hack because there's no way to # dynamically figure out what the method being # called is from the stack frame. methcache[obj.im_func.func_code] = obj.im_class # # What's the access permissions for this name? access, klass = getattr(self, '__access__', {}).get( name, (PUBLIC, 0)) if access is not PUBLIC: # Now try to see which method is calling us frame = getframe(0).f_back if frame is None: raise AccessViolation # Get the class of the method that's accessing # this attribute, by using the code object cache if frame.f_code.co_name == '__init__': # There aren't entries in the cache for ctors, # because the calling mechanism doesn't go # through __findattr__(). Are there other # methods that might have the same behavior? # Since we can't know who's __init__ we're in, # for now we'll assume that only protected and # public attrs can be accessed. if access is PRIVATE: raise AccessViolation else: methclass = self.__cache__.get(frame.f_code) if not methclass: raise AccessViolation if access is PRIVATE and methclass is not klass: raise AccessViolation if access is PROTECTED and not issubclass(methclass, klass): raise AccessViolation # If we got here, it must be okay to access the attribute if args: return setattr(self, name, *args) return obj # tests class A(Access): def __init__(self, foo=0, name='A'): self._foo = foo # can't set private names in __init__ self.__initprivate(name) def __initprivate(self, name): self._name = name def getfoo(self): return self._foo def setfoo(self, newfoo): self._foo = newfoo def getname(self): return self._name A.__access__ = {'_foo' : (PROTECTED, A), '_name' : (PRIVATE, A), '__dict__' : (PRIVATE, A), '__access__': (PRIVATE, A), } class B(A): def setfoo(self, newfoo): self._foo = newfoo + 3 def setname(self, name): self._name = name b = B(1) b.getfoo() a = A(1) assert a.getfoo() == 1 a.setfoo(2) assert a.getfoo() == 2 try: a._foo except AccessViolation: pass else: assert 0, 'AccessViolation expected' try: a._foo = 3 except AccessViolation: pass else: assert 0, 'AccessViolation expected' try: a.__dict__['_foo'] except AccessViolation: pass else: assert 0, 'AccessViolation expected' b = B() assert b.getfoo() == 0 b.setfoo(2) assert b.getfoo() == 5 try: b.setname('B') except AccessViolation: pass else: assert 0, 'AccessViolation expected' assert b.getname() == 'A' Reference Implementation The reference implementation, as a patch to the Python core, can be found at this URL: http://sourceforge.net/patch/?func=detailpatch&patch_id=102613&group_id=5470 References [1] http://www.python.org/doc/current/ref/attribute-access.html [2] http://www.javasoft.com/products/javabeans/ [3] http://www.digicool.com/releases/ExtensionClass/Acquisition.html [5] http://www.digicool.com/releases/ExtensionClass [6] http://www.python.org/doc/essays/metaclasses/ [7] http://www.foretec.com/python/workshops/1998-11/dd-ascher-sum.html [8] http://www.python.org/doc/howto/rexec/rexec.html Copyright This document has been placed in the Public Domain. Local Variables: mode: indented-text indent-tabs-mode: nil End: From python-dev@python.org Sat Dec 2 03:38:50 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 1 Dec 2000 19:38:50 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.52,1.53 Message-ID: <200012020338.TAA14175@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv14167 Modified Files: pep-0000.txt Log Message: PEP 231, __findattr__(), Barry Warsaw Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -r1.52 -r1.53 *** pep-0000.txt 2000/11/28 22:23:25 1.52 --- pep-0000.txt 2000/12/02 03:38:48 1.53 *************** *** 40,43 **** --- 40,44 ---- S 227 pep-0227.txt Statically Nested Scopes Hylton S 230 pep-0230.txt Warning Framework van Rossum + S 231 pep-0231.txt __findattr__() Warsaw Pie-in-the-sky PEPs (not ready; may become active yet) *************** *** 126,129 **** --- 127,131 ---- S 229 pep-0229.txt Using Distutils to Build Python Kuchling S 230 pep-0230.txt Warning Framework van Rossum + S 231 pep-0231.txt __findattr__() Warsaw Key From python-dev@python.org Sat Dec 2 04:11:35 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 1 Dec 2000 20:11:35 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0231.txt,1.1,1.2 Message-ID: <200012020411.UAA17734@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv17723 Modified Files: pep-0231.txt Log Message: Talk about PEP 213, which is related and can be (mostly) implemented using the __findattr__() hook. Index: pep-0231.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0231.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** pep-0231.txt 2000/12/02 03:37:58 1.1 --- pep-0231.txt 2000/12/02 04:11:32 1.2 *************** *** 111,114 **** --- 111,124 ---- + Related Work + + PEP 213 [9] describes a different approach to hooking into + attribute access and modification. The semantics proposed in PEP + 213 can be implemented using the __findattr__() hook described + here, with one caveat. The current reference implementation of + __findattr__() does not support hooking on attribute deletion. + This could be added if it's found desirable. See example below. + + Examples *************** *** 369,375 **** ! And finally, C++-like access control can also be accomplished, ! although less cleanly because of the difficulty of figuring out ! what method is being called from the runtime call stack: import sys --- 379,385 ---- ! C++-like access control can also be accomplished, although less ! cleanly because of the difficulty of figuring out what method is ! being called from the runtime call stack: import sys *************** *** 521,524 **** --- 531,586 ---- + Here's an implementation of the attribute hook described in PEP + 213 (except that hooking on attribute deletion isn't supported by + the current reference implementation). + + class Pep213: + def __findattr__(self, name, *args): + hookname = '__attr_%s__' % name + if args: + op = 'set' + else: + op = 'get' + # XXX: op = 'del' currently not supported + missing = () + meth = getattr(self, hookname, missing) + if meth is missing: + if op == 'set': + return setattr(self, name, *args) + else: + return getattr(self, name) + else: + return meth(op, *args) + + + def computation(i): + print 'doing computation:', i + return i + 3 + + + def rev_computation(i): + print 'doing rev_computation:', i + return i - 3 + + + class X(Pep213): + def __init__(self, foo=0): + self.__foo = foo + + def __attr_foo__(self, op, val=None): + if op == 'get': + return computation(self.__foo) + elif op == 'set': + self.__foo = rev_computation(val) + # XXX: 'del' not yet supported + + x = X() + fooval = x.foo + print fooval + x.foo = fooval + 5 + print x.foo + # del x.foo + + Reference Implementation *************** *** 538,541 **** --- 600,604 ---- [7] http://www.foretec.com/python/workshops/1998-11/dd-ascher-sum.html [8] http://www.python.org/doc/howto/rexec/rexec.html + [9] http://python.sourceforge.net/peps/pep-0213.html From python-dev@python.org Sat Dec 2 15:12:38 2000 From: python-dev@python.org (Barry Warsaw) Date: Sat, 2 Dec 2000 07:12:38 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0231.txt,1.2,1.3 Message-ID: <200012021512.HAA25553@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv25539 Modified Files: pep-0231.txt Log Message: Back out last second change in the examples. `missing' should be an empty mutable (i.e. list) since empty tuples are shared. Thanks Just! Index: pep-0231.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0231.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** pep-0231.txt 2000/12/02 04:11:32 1.2 --- pep-0231.txt 2000/12/02 15:12:35 1.3 *************** *** 203,207 **** return getattr(self.__contained, name) # Everything else gets wrapped ! missing = () which = self.__contained obj = getattr(which, name, missing) --- 203,207 ---- return getattr(self.__contained, name) # Everything else gets wrapped ! missing = [] which = self.__contained obj = getattr(which, name, missing) *************** *** 258,262 **** def aq_acquire(self, name): # Everything else gets wrapped ! missing = () which = self.__contained obj = getattr(which, name, missing) --- 258,262 ---- def aq_acquire(self, name): # Everything else gets wrapped ! missing = [] which = self.__contained obj = getattr(which, name, missing) *************** *** 283,287 **** return setattr(self, name, args[0]) obj = getattr(self, name) ! missing = () of = getattr(obj, '__of__', missing) if of is not missing: --- 283,287 ---- return setattr(self, name, args[0]) obj = getattr(self, name) ! missing = [] of = getattr(obj, '__of__', missing) if of is not missing: *************** *** 411,415 **** def __findattr__(self, name, *args): methcache = self.__dict__.setdefault('__cache__', {}) ! missing = () obj = getattr(self, name, missing) # if obj is missing we better be doing a setattr for --- 411,415 ---- def __findattr__(self, name, *args): methcache = self.__dict__.setdefault('__cache__', {}) ! missing = [] obj = getattr(self, name, missing) # if obj is missing we better be doing a setattr for *************** *** 543,547 **** op = 'get' # XXX: op = 'del' currently not supported ! missing = () meth = getattr(self, hookname, missing) if meth is missing: --- 543,547 ---- op = 'get' # XXX: op = 'del' currently not supported ! missing = [] meth = getattr(self, hookname, missing) if meth is missing: From python-dev@python.org Sun Dec 3 18:30:13 2000 From: python-dev@python.org (Martin v. Löwis) Date: Sun, 3 Dec 2000 10:30:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib urllib.py,1.107,1.108 Message-ID: <200012031830.KAA30620@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv30506 Modified Files: urllib.py Log Message: Convert Unicode strings to byte strings before passing them into specific protocols. Closes bug #119822. Index: urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.107 retrieving revision 1.108 diff -C2 -r1.107 -r1.108 *** urllib.py 2000/10/02 23:04:02 1.107 --- urllib.py 2000/12/03 18:30:10 1.108 *************** *** 27,34 **** import os import sys - __version__ = '1.13' # XXX This version is not always updated :-( - MAXFTPCACHE = 10 # Trim the ftp cache beyond this size --- 27,34 ---- import os import sys + import types + __version__ = '1.14' # XXX This version is not always updated :-( MAXFTPCACHE = 10 # Trim the ftp cache beyond this size *************** *** 137,157 **** def open(self, fullurl, data=None): """Use URLopener().open(file) instead of open(file, 'r').""" ! fullurl = unwrap(fullurl) if self.tempcache and self.tempcache.has_key(fullurl): filename, headers = self.tempcache[fullurl] fp = open(filename, 'rb') return addinfourl(fp, headers, fullurl) ! type, url = splittype(fullurl) ! if not type: ! type = 'file' ! if self.proxies.has_key(type): ! proxy = self.proxies[type] ! type, proxyhost = splittype(proxy) host, selector = splithost(proxyhost) url = (host, fullurl) # Signal special case to open_*() else: proxy = None ! name = 'open_' + type ! self.type = type if '-' in name: # replace - with _ --- 137,157 ---- def open(self, fullurl, data=None): """Use URLopener().open(file) instead of open(file, 'r').""" ! fullurl = unwrap(toBytes(fullurl)) if self.tempcache and self.tempcache.has_key(fullurl): filename, headers = self.tempcache[fullurl] fp = open(filename, 'rb') return addinfourl(fp, headers, fullurl) ! urltype, url = splittype(fullurl) ! if not urltype: ! urltype = 'file' ! if self.proxies.has_key(urltype): ! proxy = self.proxies[urltype] ! urltype, proxyhost = splittype(proxy) host, selector = splithost(proxyhost) url = (host, fullurl) # Signal special case to open_*() else: proxy = None ! name = 'open_' + urltype ! self.type = urltype if '-' in name: # replace - with _ *************** *** 184,188 **** """retrieve(url) returns (filename, None) for a local object or (tempfilename, headers) for a remote object.""" ! url = unwrap(url) if self.tempcache and self.tempcache.has_key(url): return self.tempcache[url] --- 184,188 ---- """retrieve(url) returns (filename, None) for a local object or (tempfilename, headers) for a remote object.""" ! url = unwrap(toBytes(url)) if self.tempcache and self.tempcache.has_key(url): return self.tempcache[url] *************** *** 239,243 **** import httplib user_passwd = None ! if type(url) is type(""): host, selector = splithost(url) if host: --- 239,243 ---- import httplib user_passwd = None ! if type(url) is types.StringType: host, selector = splithost(url) if host: *************** *** 314,318 **** import httplib user_passwd = None ! if type(url) is type(""): host, selector = splithost(url) if host: --- 314,318 ---- import httplib user_passwd = None ! if type(url) in types.StringTypes: host, selector = splithost(url) if host: *************** *** 852,855 **** --- 852,866 ---- # unquote('abc%20def') -> 'abc def' # quote('abc def') -> 'abc%20def') + + def toBytes(url): + """toBytes(u"URL") --> '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") + except UnicodeError: + raise UnicodeError("URL "+repr(url)+" contains non-ASCII characters") + return url def unwrap(url): From python-dev@python.org Sun Dec 3 19:21:11 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Sun, 03 Dec 2000 20:21:11 +0100 Subject: [Python-checkins] CVS: python/dist/src/Lib urllib.py,1.107,1.108 References: <200012031830.KAA30620@slayer.i.sourceforge.net> Message-ID: <3A2A9D27.AF43D665@lemburg.com> "Martin v. Löwis" wrote: > > Update of /cvsroot/python/python/dist/src/Lib > In directory slayer.i.sourceforge.net:/tmp/cvs-serv30506 > > Modified Files: > urllib.py > Log Message: > Convert Unicode strings to byte strings before passing them into specific > protocols. Closes bug #119822. > > ... > + > + def toBytes(url): > + """toBytes(u"URL") --> '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") You should make this: 'ascii' -- encoding names are lower case per convention (and the implementation has a short-cut to speed up conversion to 'ascii' -- not for 'ASCII'). > + except UnicodeError: > + raise UnicodeError("URL "+repr(url)+" contains non-ASCII characters") Would it be better to use a simple ValueError here ? (UnicodeError is a subclass of ValueError, but the error doesn't really have something to do with Unicode conversions...) > + return url > > def unwrap(url): -- Marc-Andre Lemburg ______________________________________________________________________ Company: http://www.egenix.com/ Consulting: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From python-dev@python.org Sun Dec 3 20:48:11 2000 From: python-dev@python.org (Moshe Zadka) Date: Sun, 3 Dec 2000 12:48:11 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib filecmp.py,1.6,1.7 Message-ID: <200012032048.MAA10353@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv9465 Modified Files: filecmp.py Log Message: Call of _cmp had wrong number of paramereters. Fixed definition of _cmp. Index: filecmp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/filecmp.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** filecmp.py 2000/07/03 08:18:47 1.6 --- filecmp.py 2000/12/03 20:48:07 1.7 *************** *** 296,302 **** # 2 for funny cases (can't stat, etc.) # ! def _cmp(a, b): try: ! return not abs(cmp(a, b)) except os.error: return 2 --- 296,302 ---- # 2 for funny cases (can't stat, etc.) # ! def _cmp(a, b, sh, st): try: ! return not abs(cmp(a, b, sh, st)) except os.error: return 2 From python-dev@python.org Mon Dec 4 15:42:14 2000 From: python-dev@python.org (Neil Schemenauer) Date: Mon, 4 Dec 2000 07:42:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.182,2.183 Message-ID: <200012041542.HAA17908@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv17504/Python Modified Files: bltinmodule.c Log Message: Make isinstance() more permissive in what types of arguments it accepts. Clarify exception messages for isinstance() and issubclass(). Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.182 retrieving revision 2.183 diff -C2 -r2.182 -r2.183 *** bltinmodule.c 2000/10/24 19:57:45 2.182 --- bltinmodule.c 2000/12/04 15:42:11 2.183 *************** *** 1996,2000 **** static int ! abstract_issubclass(PyObject *derived, PyObject *cls, char *err, int first) { static PyObject *__bases__ = NULL; --- 1996,2000 ---- static int ! abstract_issubclass(PyObject *derived, PyObject *cls, int first) { static PyObject *__bases__ = NULL; *************** *** 2013,2017 **** if (bases == NULL || !PyTuple_Check(bases)) { Py_XDECREF(bases); ! PyErr_SetString(PyExc_TypeError, err); return -1; } --- 2013,2018 ---- if (bases == NULL || !PyTuple_Check(bases)) { Py_XDECREF(bases); ! PyErr_SetString(PyExc_TypeError, ! "arg 2 must be a class or type"); return -1; } *************** *** 2025,2029 **** if (bases == NULL || !PyTuple_Check(bases)) { Py_XDECREF(bases); ! PyErr_SetString(PyExc_TypeError, err); return -1; } --- 2026,2031 ---- if (bases == NULL || !PyTuple_Check(bases)) { Py_XDECREF(bases); ! PyErr_SetString(PyExc_TypeError, ! "arg 2 must be a class or type"); return -1; } *************** *** 2031,2036 **** n = PyTuple_GET_SIZE(bases); for (i = 0; i < n; i++) { ! r = abstract_issubclass(PyTuple_GET_ITEM(bases, i), ! cls, err, 0); if (r != 0) break; --- 2033,2037 ---- n = PyTuple_GET_SIZE(bases); for (i = 0; i < n; i++) { ! r = abstract_issubclass(PyTuple_GET_ITEM(bases, i), cls, 0); if (r != 0) break; *************** *** 2072,2079 **** icls = PyObject_GetAttr(inst, __class__); if (icls != NULL) { ! retval = abstract_issubclass( ! icls, cls, ! "isinstance() arg 2 must be a class", ! 1); Py_DECREF(icls); if (retval < 0) --- 2073,2077 ---- icls = PyObject_GetAttr(inst, __class__); if (icls != NULL) { ! retval = abstract_issubclass( icls, cls, 1); Py_DECREF(icls); if (retval < 0) *************** *** 2082,2094 **** else { PyErr_SetString(PyExc_TypeError, ! "isinstance() arg 2 must be a class"); return NULL; } } - else { - PyErr_SetString(PyExc_TypeError, - "isinstance() arg 2 must be a class"); - return NULL; - } return PyInt_FromLong(retval); } --- 2080,2087 ---- else { PyErr_SetString(PyExc_TypeError, ! "arg 2 must be a class or type"); return NULL; } } return PyInt_FromLong(retval); } *************** *** 2112,2117 **** if (!PyClass_Check(derived) || !PyClass_Check(cls)) { ! retval = abstract_issubclass( ! derived, cls, "arguments must be classes", 1); if (retval < 0) return NULL; --- 2105,2109 ---- if (!PyClass_Check(derived) || !PyClass_Check(cls)) { ! retval = abstract_issubclass(derived, cls, 1); if (retval < 0) return NULL; From python-dev@python.org Mon Dec 4 16:29:16 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 4 Dec 2000 08:29:16 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib ConfigParser.py,1.23,1.24 Message-ID: <200012041629.IAA23683@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv23670 Modified Files: ConfigParser.py Log Message: remove_option(): Use the right variable name for the option name! This closes bug #124324. Index: ConfigParser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ConfigParser.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** ConfigParser.py 2000/09/27 22:43:54 1.23 --- ConfigParser.py 2000/12/04 16:29:13 1.24 *************** *** 362,368 **** except KeyError: raise NoSectionError(section) ! existed = sectdict.has_key(key) if existed: ! del sectdict[key] return existed --- 362,368 ---- except KeyError: raise NoSectionError(section) ! existed = sectdict.has_key(option) if existed: ! del sectdict[option] return existed From python-dev@python.org Mon Dec 4 16:30:43 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 4 Dec 2000 08:30:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_cfgparser.py,1.3,1.4 Message-ID: <200012041630.IAA23889@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv23878/test Modified Files: test_cfgparser.py Log Message: Add test cases for ConfigParser.remove_option() behavior. This includes coverage to ensure bug #124324 does not re-surface. Index: test_cfgparser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cfgparser.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_cfgparser.py 2000/10/23 17:22:07 1.3 --- test_cfgparser.py 2000/12/04 16:30:40 1.4 *************** *** 2,5 **** --- 2,8 ---- import StringIO + from test_support import TestFailed + + def basic(src): print *************** *** 25,28 **** --- 28,52 ---- else: print '__name__ "option" properly hidden by the API.' + + # Make sure the right things happen for remove_option(); + # added to include check for SourceForge bug #123324: + if not cf.remove_option('Foo Bar', 'foo'): + raise TestFailed( + "remove_option() failed to report existance of option") + if cf.has_option('Foo Bar', 'foo'): + raise TestFailed("remove_option() failed to remove option") + if cf.remove_option('Foo Bar', 'foo'): + raise TestFailed( + "remove_option() failed to report non-existance of option" + " that was removed") + try: + cf.remove_option('No Such Section', 'foo') + except ConfigParser.NoSectionError: + pass + else: + raise TestFailed( + "remove_option() failed to report non-existance of option" + " that never existed") + def interpolation(src): From python-dev@python.org Mon Dec 4 20:32:16 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 4 Dec 2000 12:32:16 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0207.txt,1.5,1.6 Message-ID: <200012042032.MAA12195@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv12181 Modified Files: pep-0207.txt Log Message: Checking in some text. Most of this is simply an Appendix repeating what David Ascher said in 1998 (before the starship bites the dust again). Index: pep-0207.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0207.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** pep-0207.txt 2000/11/28 22:23:25 1.5 --- pep-0207.txt 2000/12/04 20:32:13 1.6 *************** *** 2,9 **** Title: Rich Comparisions Version: $Revision$ ! Author: mal@lemburg.com (Marc-Andre Lemburg), guido@python.org (Guido van Rossum) Python-Version: 2.1 Status: Incomplete --- 2,330 ---- Title: Rich Comparisions Version: $Revision$ ! Author: guido@python.org (Guido van Rossum), mal@lemburg.com (Marc-Andre Lemburg) Python-Version: 2.1 Status: Incomplete + + Abstract + + This PEP proposes several new features for comparisons: + + - Allow separately overloading of <, >, <=, >=, ==, !=, both in + classes and in C extensions. + + - Allow any of those overloaded operators to return something else + besides a Boolean result. + + + Motivation + + The main motivation comes from NumPy, whose users agree that A", ">=", "==", "!=", "<>" (the last two have the same + meaning). When called with one of these strings as the third + argument, cmp() can return any Python object. Otherwise, it can + only return -1, 0 or 1 as before. + + Chained Comparisons + + Problem + + It would be nice to allow objects for which the comparison returns + something other than -1, 0, or 1 to be used in chained + comparisons, such as: + + x < y < z + + Currently, this is interpreted by Python as: + + temp1 = x < y + if temp1: + return y < z + else: + return temp1 + + Note that this requires testing the truth value of the result of + comparisons, with potential "shortcutting" of the right-side + comparison testings. In other words, the truth-value of the result + of the result of the comparison determines the result of a chained + operation. This is problematic in the case of arrays, since if x, + y and z are three arrays, then the user expects: + + x < y < z + + to be an array of 0's and 1's where 1's are in the locations + corresponding to the elements of y which are between the + corresponding elements in x and z. In other words, the right-hand + side must be evaluated regardless of the result of x < y, which is + incompatible with the mechanism currently in use by the parser. + + Solution + + Guido mentioned that one possible way out would be to change the + code generated by chained comparisons to allow arrays to be + chained-compared intelligently. What follows is a mixture of his + idea and my suggestions. The code generated for x < y < z would be + equivalent to: + + temp1 = x < y + if temp1: + temp2 = y < z + return boolean_combine(temp1, temp2) + else: + return temp1 + + where boolean_combine is a new function which does something like + the following: + + def boolean_combine(a, b): + if hasattr(a, '__boolean_and__') or \ + hasattr(b, '__boolean_and__'): + try: + return a.__boolean_and__(b) + except: + return b.__boolean_and__(a) + else: # standard behavior + if a: + return b + else: + return 0 + + where the __boolean_and__ special method is implemented for + C-level types by another value of the third argument to the + richcmp function. This method would perform a boolean comparison + of the arrays (currently implemented in the umath module as the + logical_and ufunc). + + Thus, objects returned by rich comparisons should always test + true, but should define another special method which creates + boolean combinations of them and their argument. + + This solution has the advantage of allowing chained comparisons to + work for arrays, but the disadvantage that it requires comparison + arrays to always return true (in an ideal world, I'd have them + always raise an exception on truth testing, since the meaning of + testing "if a>b:" is massively ambiguous. + + The inlining already present which deals with integer comparisons + would still apply, resulting in no performance cost for the most + common cases. From python-dev@python.org Mon Dec 4 22:04:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 4 Dec 2000 14:04:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib xmlsaxhandler.tex,1.1,1.2 Message-ID: <200012042204.OAA26596@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv26556/lib Modified Files: xmlsaxhandler.tex Log Message: Added a comment for ContentHandler.characters() explaining how to migrate SAX1 code to SAX2, based on bug #123695. Index: xmlsaxhandler.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmlsaxhandler.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** xmlsaxhandler.tex 2000/10/12 20:05:09 1.1 --- xmlsaxhandler.tex 2000/12/04 22:04:15 1.2 *************** *** 256,259 **** --- 256,267 ---- \var{content} may be a Unicode string or a byte string; the \code{expat} reader module produces always Unicode strings. + + \strong{Note:} The earlier SAX 1 interface provided by the Python + XML Special Interest Group used a more Java-like interface for this + method. Since most parsers used from Python did not take advatage + of the older interface, the simpler signature was chosen to replace + it. To convert old code to the new interface, use \var{content} + instead of slicing content with the old \var{offset} and + \var{lenght} parameters. \end{methoddesc} From python-dev@python.org Mon Dec 4 22:29:20 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 4 Dec 2000 14:29:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib xmlsaxhandler.tex,1.2,1.3 Message-ID: <200012042229.OAA29741@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv29719/Doc/lib Modified Files: xmlsaxhandler.tex Log Message: Two typos caught by /F; thanks! Index: xmlsaxhandler.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmlsaxhandler.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** xmlsaxhandler.tex 2000/12/04 22:04:15 1.2 --- xmlsaxhandler.tex 2000/12/04 22:29:17 1.3 *************** *** 259,267 **** \strong{Note:} The earlier SAX 1 interface provided by the Python XML Special Interest Group used a more Java-like interface for this ! method. Since most parsers used from Python did not take advatage of the older interface, the simpler signature was chosen to replace it. To convert old code to the new interface, use \var{content} instead of slicing content with the old \var{offset} and ! \var{lenght} parameters. \end{methoddesc} --- 259,267 ---- \strong{Note:} The earlier SAX 1 interface provided by the Python XML Special Interest Group used a more Java-like interface for this ! method. Since most parsers used from Python did not take advantage of the older interface, the simpler signature was chosen to replace it. To convert old code to the new interface, use \var{content} instead of slicing content with the old \var{offset} and ! \var{length} parameters. \end{methoddesc} From python-dev@python.org Tue Dec 5 03:16:36 2000 From: python-dev@python.org (Neil Schemenauer) Date: Mon, 4 Dec 2000 19:16:36 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.53,1.54 Message-ID: <200012050316.TAA28626@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv28587 Modified Files: pep-0000.txt Log Message: Make Neil Schemenauer the owner of 208. Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -r1.53 -r1.54 *** pep-0000.txt 2000/12/02 03:38:48 1.53 --- pep-0000.txt 2000/12/05 03:16:33 1.54 *************** *** 34,38 **** SD 205 pep-0205.txt Weak References Drake S 207 pep-0207.txt Rich Comparisons Lemburg, van Rossum ! S 208 pep-0208.txt Reworking the Coercion Model Ascher, Zadka S 217 pep-0217.txt Display Hook for Interactive Use Zadka S 222 pep-0222.txt Web Library Enhancements Kuchling --- 34,38 ---- SD 205 pep-0205.txt Weak References Drake S 207 pep-0207.txt Rich Comparisons Lemburg, van Rossum ! S 208 pep-0208.txt Reworking the Coercion Model Schemenauer S 217 pep-0217.txt Display Hook for Interactive Use Zadka S 222 pep-0222.txt Web Library Enhancements Kuchling *************** *** 155,158 **** --- 155,159 ---- Raymond, Eric esr@snark.thyrsus.com van Rossum, Guido guido@python.org + Schemenauer, Neil nas@arctrix.com Schneider-Kamp, Peter nownder@nowonder.de Warsaw, Barry barry@digicool.com From python-dev@python.org Tue Dec 5 03:17:11 2000 From: python-dev@python.org (Neil Schemenauer) Date: Mon, 4 Dec 2000 19:17:11 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0208.txt,1.3,1.4 Message-ID: <200012050317.TAA28678@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv28644 Modified Files: pep-0208.txt Log Message: Add some meat to the PEP (mostly from Marc-Andre's web page). Index: pep-0208.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0208.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** pep-0208.txt 2000/11/28 22:23:25 1.3 --- pep-0208.txt 2000/12/05 03:17:08 1.4 *************** *** 2,8 **** Title: Reworking the Coercion Model Version: $Revision$ ! Author: davida@activestate.com (David Ascher), pep@zadka.site.co.il (Moshe Zadka) Python-Version: 2.1 ! Status: Incomplete --- 2,211 ---- Title: Reworking the Coercion Model Version: $Revision$ ! Author: Neil Schemenauer ! Status: Draft ! Type: Standards Track ! Created: 04-Dec-2000 ! Post-History: Python-Version: 2.1 ! ! ! Abstract ! ! Many Python types implement numeric operations. When the arguments of ! a numeric operation are of different types, the interpreter tries to ! coerce the arguments into a common type. The numeric operation is ! then performed using this common type. This PEP proposes a new type ! flag to indicate that arguments to a type's numeric operations should ! not be coerced. Operations that do not support the supplied types ! indicate it by returning a new singleton object. Types which do not ! set the type flag are handled in a backwards compatible manner. ! Allowing operations handle different types is often simpler, more ! flexible, and faster then having the interpreter do coercion. ! ! ! Rational ! ! When implementing numeric or other related operations, it is often ! desirable to provide not only operations between operands of one type ! only, e.g. integer + integer, but to generalize the idea behind the ! operation to other type combinations as well, e.g. integer + float. ! ! A common approach to this mixed type situation is to provide a method ! of "lifting" the operands to a common type (coercion) and then use ! that type's operand method as execution mechanism. Yet, this strategy ! has a few drawbacks: ! ! * the "lifting" process creates at least one new (temporary) ! operand object, ! ! * since the coercion method is not being told about the operation ! that is to follow, it is not possible to implement operation ! specific coercion of types, ! ! * there is no elegant way to solve situations were a common type ! is not at hand, and ! ! * the coercion method will always have to be called prior to the ! operation's method itself. ! ! A fix for this situation is obviously needed, since these drawbacks ! make implementations of types needing these features very cumbersome, ! if not impossible. As an example, have a look at the DateTime and ! DateTimeDelta[1] types, the first being absolute, the second ! relative. You can always add a relative value to an absolute one, ! giving a new absolute value. Yet, there is no common type which the ! existing coercion mechanism could use to implement that operation. ! ! Currently, PyInstance types are treated specially by the interpreter ! in that their numeric methods are passed arguments of different types. ! Removing this special case simplifies the interpreter and allows other ! types to implement numeric methods that behave like instance types. ! This is especially useful for extension types like ExtensionClass. ! ! ! Specification ! ! Instead of using a central coercion method, the process of handling ! different operand types is simply left to the operation. If the ! operation finds that it cannot handle the given operand type ! combination, it may return a special singleton as indicator. ! ! Note that "numbers" (anything that implements the number protocol, or ! part of it) written in Python already use the first part of this ! strategy - it is the C level API that we focus on here. ! ! To maintain nearly 100% backward compatibility we have to be very ! careful to make numbers that don't know anything about the new ! strategy (old style numbers) work just as well as those that expect ! the new scheme (new style numbers). Furthermore, binary compatibility ! is a must, meaning that the interpreter may only access and use new ! style operations if the number indicates the availability of these. ! ! A new style number is considered by the interpreter as such if and ! only it it sets the type flag Py_TPFLAGS_NEWSTYLENUMBER. The main ! difference between an old style number and a new style one is that the ! numeric slot functions can no longer assume to be passed arguments of ! identical type. New style slots must check all arguments for proper ! type and implement the necessary conversions themselves. This may seem ! to cause more work on the behalf of the type implementor, but is in ! fact no more difficult than writing the same kind of routines for an ! old style coercion slot. ! ! If a new style slot finds that it cannot handle the passed argument ! type combination, it may return a new reference of the special ! singleton Py_NotImplemented to the caller. This will cause the caller ! to try the other operands operation slots until it finds a slot that ! does implement the operation for the specific type combination. If ! none of the possible slots succeed, it raises a TypeError. ! ! To make the implementation easy to understand (the whole topic is ! esoteric enough), a new layer in the handling of numeric operations is ! introduced. This layer takes care of all the different cases that need ! to be taken into account when dealing with all the possible ! combinations of old and new style numbers. It is implemented by the ! two functions _PyNumber_BinaryOperation() and ! _PyNumber_TernaryOperation(), which both are internal functions that ! only the functions in Objects/abstract.c have access to. The numeric ! API (PyNumber_*) is easy to adapt to this new layer. ! ! As a side-effect all numeric slots can be NULL-checked (this has to be ! done anyway, so the added feature comes at no extra cost). ! ! ! The scheme used by the layer to execute a binary operation is as ! follows: ! ! v | w | Action taken ! ---------+------------+---------------------------------- ! new | new | v.op(v,w), w.op(v,w) ! new | old | v.op(v,w), coerce(v,w), v.op(v,w) ! old | new | w.op(v,w), coerce(v,w), v.op(v,w) ! old | old | coerce(v,w), v.op(v,w) ! ! The indicated action sequence is executed from left to right until ! either the operation succeeds and a valid result (!= ! Py_NotImplemented) is returned or an exception is raised. Exceptions ! are returned to the calling function as-is. If a slot returns ! Py_NotImplemented, the next item in the sequence is executed. ! ! Note that coerce(v,w) will use the old style nb_coerce slot methods ! via a call to PyNumber_Coerce(). ! ! Ternary operations have a few more cases to handle: ! ! v | w | z | Action taken ! ----+-----+-----+------------------------------------ ! new | new | new | v.op(v,w,z), w.op(v,w,z), z.op(v,w,z) ! new | old | new | v.op(v,w,z), z.op(v,w,z), coerce(v,w,z), v.op(v,w,z) ! old | new | new | w.op(v,w,z), z.op(v,w,z), coerce(v,w,z), v.op(v,w,z) ! old | old | new | z.op(v,w,z), coerce(v,w,z), v.op(v,w,z) ! new | new | old | v.op(v,w,z), w.op(v,w,z), coerce(v,w,z), v.op(v,w,z) ! new | old | old | v.op(v,w,z), coerce(v,w,z), v.op(v,w,z) ! old | new | old | w.op(v,w,z), coerce(v,w,z), v.op(v,w,z) ! old | old | old | coerce(v,w,z), v.op(v,w,z) ! ! The same notes as above, except that coerce(v,w,z) actually does: ! ! if z != Py_None: ! coerce(v,w), coerce(v,z), coerce(w,z) ! else: ! # treat z as absent variable ! coerce(v,w) ! ! ! The current implementation uses this scheme already (there's only one ! ternary slot: nb_pow(a,b,c)). ! ! Note that the numeric protocol is also used for some other related ! tasks, e.g. sequence concatenation. These can also benefit from the ! new mechanism by implementing right-hand operations for type ! combinations that would otherwise fail to work. As an example, take ! string concatenation: currently you can only do string + string. With ! the new mechanism, a new string-like type could implement new_type + ! string and string + new_type, even though strings don't know anything ! about new_type. ! ! Since comparisons also rely on coercion (every time you compare an ! integer to a float, the integer is first converted to float and then ! compared...), a new slot to handle numeric comparisons is needed: ! ! PyObject *nb_cmp(PyObject *v, PyObject *w) ! ! This slot should compare the two objects and return an integer object ! stating the result. Currently, this result integer may only be -1, 0, ! 1. If the slot cannot handle the type combination, it may return a ! reference to Py_NotImplemented. Note that this slot is still in flux ! since it should take into account rich comparisons (ie. PEP 207). ! ! Numeric comparisons are handled by a new numeric protocol API: ! ! PyObject *PyNumber_Compare(PyObject *v, PyObject *w) ! ! This function compare the two objects as "numbers" and return an ! integer object stating the result. Currently, this result integer may ! only be -1, 0, 1. In case the operation cannot be handled by the given ! objects, a TypeError is raised. ! ! The PyObject_Compare() API needs to adjusted accordingly to make use ! of this new API. ! ! Other changes include adapting some of the built-in functions (e.g. ! cmp()) to use this API as well. Also, PyNumber_CoerceEx() will need to ! check for new style numbers before calling the nb_coerce slot. New ! style numbers don't provide a coercion slot and thus cannot be ! explicitly coerced. ! ! ! Reference Implementation ! ! A preliminary patch for the CVS version of Python is available through ! the Source Forge patch manager[2]. ! ! ! References ! ! [1] http://www.lemburg.com/files/python/mxDateTime.html ! [2] http://sourceforge.net/patch/download.php?id=102652 ! From python-dev@python.org Tue Dec 5 03:31:15 2000 From: python-dev@python.org (Neil Schemenauer) Date: Mon, 4 Dec 2000 19:31:15 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.54,1.55 Message-ID: <200012050331.TAA29515@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv29447 Modified Files: pep-0000.txt Log Message: Update some names in the numerical index to be consistent with the PEPs themselves. Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -r1.54 -r1.55 *** pep-0000.txt 2000/12/05 03:16:33 1.54 --- pep-0000.txt 2000/12/05 03:31:13 1.55 *************** *** 103,108 **** SD 205 pep-0205.txt Weak References Drake I 206 pep-0206.txt 2.0 Batteries Included Zadka ! S 207 pep-0207.txt Rich Comparisons Zadka, Lemburg ! S 208 pep-0208.txt Reworking the Coercion Model Ascher SD 209 pep-0209.txt Adding Multidimensional Arrays Ascher SD 210 pep-0210.txt Decoupling the Interpreter Loop Ascher --- 103,108 ---- SD 205 pep-0205.txt Weak References Drake I 206 pep-0206.txt 2.0 Batteries Included Zadka ! S 207 pep-0207.txt Rich Comparisons Lemburg, van Rossum ! S 208 pep-0208.txt Reworking the Coercion Model Schemenauer SD 209 pep-0209.txt Adding Multidimensional Arrays Ascher SD 210 pep-0210.txt Decoupling the Interpreter Loop Ascher From python-dev@python.org Tue Dec 5 15:05:17 2000 From: python-dev@python.org (Neil Schemenauer) Date: Tue, 5 Dec 2000 07:05:17 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0208.txt,1.4,1.5 Message-ID: <200012051505.HAA07133@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv7041 Modified Files: pep-0208.txt Log Message: - give credit where due - add copyright section Index: pep-0208.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0208.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** pep-0208.txt 2000/12/05 03:17:08 1.4 --- pep-0208.txt 2000/12/05 15:05:14 1.5 *************** *** 203,210 **** --- 203,222 ---- + Credits + + This PEP and the patch are heavily based on work done by Marc-André + Lemburg[3]. + + + Copyright + + This document has been placed in the public domain. + + References [1] http://www.lemburg.com/files/python/mxDateTime.html [2] http://sourceforge.net/patch/download.php?id=102652 + [3] http://www.lemburg.com/files/python/CoercionProposal.html From python-dev@python.org Wed Dec 6 10:38:00 2000 From: python-dev@python.org (Sjoerd Mullender) Date: Wed, 6 Dec 2000 02:38:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib xmllib.py,1.23,1.24 Message-ID: <200012061038.CAA19417@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv19399 Modified Files: xmllib.py Log Message: Two changes: - Use new Error class (subclass of RuntimeError so is backward compatible) which is raised when RuntimeError used to be raised. - Report original attribute name in error messages instead of name mangled with namespace URL. Index: xmllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmllib.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** xmllib.py 2000/08/31 10:26:52 1.23 --- xmllib.py 2000/12/06 10:37:57 1.24 *************** *** 9,12 **** --- 9,15 ---- version = '0.3' + class Error(RuntimeError): + pass + # Regular expressions used for parsing *************** *** 310,314 **** 'standalone') if version[1:-1] != '1.0': ! raise RuntimeError, 'only XML version 1.0 supported' if encoding: encoding = encoding[1:-1] if standalone: standalone = standalone[1:-1] --- 313,317 ---- 'standalone') if version[1:-1] != '1.0': ! raise Error('only XML version 1.0 supported') if encoding: encoding = encoding[1:-1] if standalone: standalone = standalone[1:-1] *************** *** 391,395 **** continue else: ! raise RuntimeError, 'neither < nor & ??' # We get here only if incomplete matches but # nothing else --- 394,398 ---- continue else: ! raise Error('neither < nor & ??') # We get here only if incomplete matches but # nothing else *************** *** 420,424 **** rawdata = self.rawdata if rawdata[i:i+4] <> ' The Index: libcfgparser.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcfgparser.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** libcfgparser.tex 2000/09/27 22:48:44 1.14 --- libcfgparser.tex 2000/12/07 00:03:24 1.15 *************** *** 46,50 **** Return a new instance of the \class{ConfigParser} class. When \var{defaults} is given, it is initialized into the dictionary of ! intrinsic defaults. They keys must be strings, and the values must be appropriate for the \samp{\%()s} string interpolation. Note that \var{__name__} is an intrinsic default; its value is the section name, --- 46,50 ---- Return a new instance of the \class{ConfigParser} class. When \var{defaults} is given, it is initialized into the dictionary of ! intrinsic defaults. The keys must be strings, and the values must be appropriate for the \samp{\%()s} string interpolation. Note that \var{__name__} is an intrinsic default; its value is the section name, From python-dev@python.org Thu Dec 7 00:06:49 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 6 Dec 2000 16:06:49 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc ACKS,1.10,1.11 Message-ID: <200012070006.QAA25739@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv25727 Modified Files: ACKS Log Message: Another name! Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ACKS,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** ACKS 2000/11/30 07:09:59 1.10 --- ACKS 2000/12/07 00:06:46 1.11 *************** *** 146,149 **** --- 146,150 ---- Mark Summerfield Reuben Sumner + Jim Tittsler Martijn Vries Charles G. Waldman From python-dev@python.org Thu Dec 7 04:47:54 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 6 Dec 2000 20:47:54 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib xmldom.tex,1.2,1.3 xmldomminidom.tex,1.1,1.2 Message-ID: <200012070447.UAA11641@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv11629/lib Modified Files: xmldom.tex xmldomminidom.tex Log Message: Lots of additional information. Not done, but much better. Index: xmldom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmldom.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** xmldom.tex 2000/11/29 06:10:22 1.2 --- xmldom.tex 2000/12/07 04:47:51 1.3 *************** *** 90,95 **** The definitive documentation for the DOM is the DOM specification from ! the W3C. This section lists the properties and methods supported by ! \refmodule{xml.dom.minidom}. Note that DOM attributes may also be manipulated as nodes instead of --- 90,94 ---- The definitive documentation for the DOM is the DOM specification from ! the W3C. Note that DOM attributes may also be manipulated as nodes instead of *************** *** 99,104 **** --- 98,109 ---- \begin{tableiii}{l|l|l}{class}{Interface}{Section}{Purpose} + \lineiii{DOMImplementation}{\ref{dom-implementation-objects}} + {Interface to the underlying implementation.} \lineiii{Node}{\ref{dom-node-objects}} {Base interface for most objects in a document.} + \lineiii{NodeList}{\ref{dom-nodelist-objects}} + {Interface for a sequence of nodes.} + \lineiii{DocumentType}{\ref{dom-documenttype-objects}} + {Information about the declarations needed to process a document.} \lineiii{Document}{\ref{dom-document-objects}} {Object which represents an entire document.} *************** *** 116,119 **** --- 121,137 ---- + \subsubsection{DOMImplementation Objects + \label{dom-implementation-objects}} + + The \class{DOMImplementation} interface provides a way for + applications to determine the availability of particular features in + the DOM they are using. DOM Level 2 added the ability to create new + \class{Document} and \class{DocumentType} objects using the + \class{DOMImplementation} as well. + + \begin{methoddesc}[DOMImplementation]{hasFeature}{feature, version} + \end{methoddesc} + + \subsubsection{Node Objects \label{dom-node-objects}} *************** *** 132,136 **** \begin{memberdesc}[Node]{parentNode} ! The parent of the current node. \code{None} for the document node. \end{memberdesc} --- 150,158 ---- \begin{memberdesc}[Node]{parentNode} ! The parent of the current node, or \code{None} for the document node. ! The value is always a \class{Node} object or \code{None}. For ! \class{Element} nodes, this will be the parent element, except for the ! root element, in which case it will be the \class{Document} object. ! For \class{Attr} nodes, this is always \code{None}. \end{memberdesc} *************** *** 145,154 **** \var{self} element's start-tag. Of course, XML documents are made up of more than just elements so the previous sibling could be text, a ! comment, or something else. \end{memberdesc} \begin{memberdesc}[Node]{nextSibling} The node that immediately follows this one with the same parent. See ! also \member{previousSibling}. \end{memberdesc} --- 167,178 ---- \var{self} element's start-tag. Of course, XML documents are made up of more than just elements so the previous sibling could be text, a ! comment, or something else. If this node is the first child of the ! parent, this attribute will be \code{None}. \end{memberdesc} \begin{memberdesc}[Node]{nextSibling} The node that immediately follows this one with the same parent. See ! also \member{previousSibling}. If this is the last child of the ! parent, this attribute will be \code{None}. \end{memberdesc} *************** *** 165,173 **** \end{memberdesc} \begin{memberdesc}[Node]{nodeName} Has a different meaning for each node type. See the DOM specification for details. You can always get the information you would get here from another property such as the \member{tagName} property for ! elements or the \member{name} property for attributes. \end{memberdesc} --- 189,204 ---- \end{memberdesc} + \begin{memberdesc}[Element]{namespaceURI} + The namespace associated with the element name. This will be a + string. + \end{memberdesc} + \begin{memberdesc}[Node]{nodeName} Has a different meaning for each node type. See the DOM specification for details. You can always get the information you would get here from another property such as the \member{tagName} property for ! elements or the \member{name} property for attributes. For all node ! types, the value of this attribute will be either a string or ! \code{None}. \end{memberdesc} *************** *** 214,225 **** \begin{methoddesc}[Node]{cloneNode}{deep} Clone this node. Setting \var{deep} means to clone all child nodes as ! well. ! \strong{Warning:} Although this method was present in the version of ! \refmodule{xml.dom.minidom} packaged with Python 2.0, it was seriously ! broken. This has been corrected for subsequent releases. \end{methoddesc} \subsubsection{Document Objects \label{dom-document-objects}} --- 245,334 ---- \begin{methoddesc}[Node]{cloneNode}{deep} Clone this node. Setting \var{deep} means to clone all child nodes as ! well. This returns the clone. ! \end{methoddesc} ! ! ! \subsubsection{NodeList Objects \label{dom-nodelist-objects}} ! ! A \class{NodeList} represents a sequence of nodes. These objects are ! used in two ways in the DOM Core recommendation: the ! \class{Element} objects provides one as it's list of child nodes, and ! the \method{getElementsByTagName()} and ! \method{getElementsByTagNameNS()} methods of \class{Node} return ! objects with this interface to represent query results. ! The DOM Level 2 recommendation defines one method and one attribute ! for these objects: ! ! \begin{methoddesc}[NodeList]{item}{i} ! Return the \var{i}'th item from the sequence, if there is one, or ! \code{None}. The index \var{i} is not allowed to be less then zero ! or greater than or equal to the length of the sequence. \end{methoddesc} + \begin{memberdesc}[NodeList]{length} + The number of nodes in the sequence. + \end{memberdesc} + + In addition, the Python DOM interface requires that some additional + support is provided to allow \class{NodeList} objects to be used as + Python sequences. All \class{NodeList} implementations must include + support for \method{__len__()} and \method{__getitem__()}; this allows + iteration over the \class{NodeList} in \keyword{for} statements and + proper support for the \function{len()} built-in function. + + If a DOM implementation supports modification of the document, the + \class{NodeList} implementation must also support the + \method{__setitem__()} and \method{__delitem__()} methods. + + + \subsubsection{DocumentType Objects \label{dom-documenttype-objects}} + + Information about the notations and entities declared by a document + (including the external subset if the parser uses it and can provide + the information) is available from a \class{DocumentType} object. The + \class{DocumentType} for a document is available from the + \class{Document} object's \member{doctype} attribute. + + \class{DocumentType} is a specialization of \class{Node}, and adds the + following attributes: + + \begin{memberdesc}[DocumentType]{publicId} + The public identifier for the external subset of the document type + definition. This will be a string or \code{None}. + \end{memberdesc} + + \begin{memberdesc}[DocumentType]{systemId} + The system identifier for the external subset of the document type + definition. This will be a URI as a string, or \code{None}. + \end{memberdesc} + + \begin{memberdesc}[DocumentType]{internalSubset} + A string giving the complete internal subset from the document. + \end{memberdesc} + + \begin{memberdesc}[DocumentType]{name} + The name of the root element as given in the \code{DOCTYPE} + declaration, if present. If the was no \code{DOCTYPE} declaration, + this will be \code{None}. + \end{memberdesc} + + \begin{memberdesc}[DocumentType]{entities} + This is a \class{NamedNodeMap} giving the definitions of external + entities. For entity names defined more than once, only the first + definition is provided (others are ignored as required by the XML + recommendation). This may be \code{None} if the information is not + provided by the parser, or if no entities are defined. + \end{memberdesc} + + \begin{memberdesc}[DocumentType]{notations} + This is a \class{NamedNodeMap} giving the definitions of notations. + For notation names defined more than once, only the first definition + is provided (others are ignored as required by the XML + recommendation). This may be \code{None} if the information is not + provided by the parser, or if no notations are defined. + \end{memberdesc} + \subsubsection{Document Objects \label{dom-document-objects}} *************** *** 233,270 **** \begin{methoddesc}[Document]{createElement}{tagName} ! Create a new element. The element is not inserted into the document ! when it is created. You need to explicitly insert it with one of the ! other methods such as \method{insertBefore()} or \method{appendChild()}. \end{methoddesc} \begin{methoddesc}[Document]{createElementNS}{namespaceURI, tagName} ! Create a new element with a namespace. The \var{tagName} may have a ! prefix. The element is not inserted into the document when it is ! created. You need to explicitly insert it with one of the other ! methods such as \method{insertBefore()} or \method{appendChild()}. \end{methoddesc} \begin{methoddesc}[Document]{createTextNode}{data} ! Create a text node containing the data passed as a parameter. As with ! the other creation methods, this one does not insert the node into the ! tree. \end{methoddesc} \begin{methoddesc}[Document]{createComment}{data} ! Create a comment node containing the data passed as a parameter. As ! with the other creation methods, this one does not insert the node ! into the tree. \end{methoddesc} \begin{methoddesc}[Document]{createProcessingInstruction}{target, data} ! Create a processing instruction node containing the \var{target} and ! \var{data} passed as parameters. As with the other creation methods, ! this one does not insert the node into the tree. \end{methoddesc} \begin{methoddesc}[Document]{createAttribute}{name} ! Create an attribute node. This method does not associate the ! attribute node with any particular element. You must use \method{setAttributeNode()} on the appropriate \class{Element} object to use the newly created attribute instance. --- 342,380 ---- \begin{methoddesc}[Document]{createElement}{tagName} ! Create and return a new element node. The element is not inserted ! into the document when it is created. You need to explicitly insert ! it with one of the other methods such as \method{insertBefore()} or \method{appendChild()}. \end{methoddesc} \begin{methoddesc}[Document]{createElementNS}{namespaceURI, tagName} ! Create and return a new element with a namespace. The ! \var{tagName} may have a prefix. The element is not inserted into the ! document when it is created. You need to explicitly insert it with ! one of the other methods such as \method{insertBefore()} or ! \method{appendChild()}. \end{methoddesc} \begin{methoddesc}[Document]{createTextNode}{data} ! Create and return a text node containing the data passed as a ! parameter. As with the other creation methods, this one does not ! insert the node into the tree. \end{methoddesc} \begin{methoddesc}[Document]{createComment}{data} ! Create and return a comment node containing the data passed as a ! parameter. As with the other creation methods, this one does not ! insert the node into the tree. \end{methoddesc} \begin{methoddesc}[Document]{createProcessingInstruction}{target, data} ! Create and return a processing instruction node containing the ! \var{target} and \var{data} passed as parameters. As with the other ! creation methods, this one does not insert the node into the tree. \end{methoddesc} \begin{methoddesc}[Document]{createAttribute}{name} ! Create and return an attribute node. This method does not associate ! the attribute node with any particular element. You must use \method{setAttributeNode()} on the appropriate \class{Element} object to use the newly created attribute instance. *************** *** 272,280 **** \begin{methoddesc}[Document]{createAttributeNS}{namespaceURI, qualifiedName} ! Create an attribute node with a namespace. The \var{tagName} may have ! a prefix. This method does not associate the attribute node with any ! particular element. You must use \method{setAttributeNode()} on the ! appropriate \class{Element} object to use the newly created attribute ! instance. \end{methoddesc} --- 382,390 ---- \begin{methoddesc}[Document]{createAttributeNS}{namespaceURI, qualifiedName} ! Create and return an attribute node with a namespace. The ! \var{tagName} may have a prefix. This method does not associate the ! attribute node with any particular element. You must use ! \method{setAttributeNode()} on the appropriate \class{Element} object ! to use the newly created attribute instance. \end{methoddesc} *************** *** 298,316 **** \begin{memberdesc}[Element]{tagName} The element type name. In a namespace-using document it may have ! colons in it. \end{memberdesc} \begin{memberdesc}[Element]{localName} The part of the \member{tagName} following the colon if there is one, ! else the entire \member{tagName}. \end{memberdesc} \begin{memberdesc}[Element]{prefix} The part of the \member{tagName} preceding the colon if there is one, ! else the empty string. ! \end{memberdesc} ! ! \begin{memberdesc}[Element]{namespaceURI} ! The namespace associated with the tagName. \end{memberdesc} --- 408,422 ---- \begin{memberdesc}[Element]{tagName} The element type name. In a namespace-using document it may have ! colons in it. The value is a string. \end{memberdesc} \begin{memberdesc}[Element]{localName} The part of the \member{tagName} following the colon if there is one, ! else the entire \member{tagName}. The value is a string. \end{memberdesc} \begin{memberdesc}[Element]{prefix} The part of the \member{tagName} preceding the colon if there is one, ! else the empty string. The value is a string, or \code{None} \end{memberdesc} *************** *** 319,322 **** --- 425,432 ---- \end{methoddesc} + \begin{methoddesc}[Element]{getAttributeNode}{attrname} + Return the \class{Attr} node for the attribute named by \var{attrname} + \end{methoddesc} + \begin{methoddesc}[Element]{setAttribute}{attname, value} Set an attribute value from a string. *************** *** 440,446 **** IDL mapping for Python. \subsubsection{Type Mapping \label{dom-type-mapping}} - XXX Explain what a \class{DOMString} maps to... \subsubsection{Accessor Methods \label{dom-accessor-methods}} --- 550,574 ---- IDL mapping for Python. + \subsubsection{Type Mapping \label{dom-type-mapping}} + + The primitive IDL types used in the DOM specification are mapped to + Python types according to the following table. + + \begin{tableii}{l|l}{code}{IDL Type}{Python Type} + \lineii{boolean}{\code{IntegerType} (with a value of \code{0} or \code{1})} + \lineii{int}{\code{IntegerType}} + \lineii{long int}{\code{IntegerType}} + \lineii{unsigned int}{\code{IntegerType}} + \end{tableii} + + Additionally, the \class{DOMString} defined in the recommendation is + mapped to a Python string or Unicode string. Applications should + be able to handle Unicode whenever a string is returned from the DOM. + + The IDL \keyword{null} value is mapped to \code{None}, which may be + accepted or provided by the implementation whenever \keyword{null} is + allowed by the API. \subsubsection{Accessor Methods \label{dom-accessor-methods}} *************** *** 477,479 **** they should take the form defined by the Python IDL mapping, but these methods are considered unnecessary since the attributes are ! accessible directly from Python. --- 605,608 ---- they should take the form defined by the Python IDL mapping, but these methods are considered unnecessary since the attributes are ! accessible directly from Python. ``Set'' accessors should never be ! provided for \keyword{readonly} attributes. Index: xmldomminidom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmldomminidom.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** xmldomminidom.tex 2000/11/29 06:10:22 1.1 --- xmldomminidom.tex 2000/12/07 04:47:51 1.2 *************** *** 262,268 **** list type, so don't support the official API, but are much more ``Pythonic.'' - - \item \class{NamedNodeMap} is implemented by the class - \class{AttributeList}. This should not impact user code. \end{itemize} --- 262,265 ---- *************** *** 274,280 **** \item DOMTimeStamp ! \item DocumentType (added for Python 2.1) ! \item DOMImplementation (added for Python 2.1) \item CharacterData --- 271,277 ---- \item DOMTimeStamp ! \item DocumentType (added in Python 2.1) ! \item DOMImplementation (added in Python 2.1) \item CharacterData From python-dev@python.org Thu Dec 7 04:49:36 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 6 Dec 2000 20:49:36 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref3.tex,1.52,1.53 Message-ID: <200012070449.UAA11761@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/ref In directory slayer.i.sourceforge.net:/tmp/cvs-serv11753/ref Modified Files: ref3.tex Log Message: Added a note that objects which emulate built-in types should only implement as many of the relevant methods as make sense for the particular information being modelled. Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -r1.52 -r1.53 *** ref3.tex 2000/09/21 22:27:16 1.52 --- ref3.tex 2000/12/07 04:49:34 1.53 *************** *** 842,845 **** --- 842,852 ---- \withsubitem{(mapping object method)}{\ttindex{__getitem__()}} + When implementing a class that emulates any built-in type, it is + important that the emulation only be implemented to the degree that it + makes sense for the object being modelled. For example, some + sequences may work well with retrieval of individual elements, but + extracting a slice may not make sense. (One example of this is the + \class{NodeList} interface in the W3C's Document Object Model.) + \subsection{Basic customization\label{customization}} From python-dev@python.org Thu Dec 7 04:54:05 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 6 Dec 2000 20:54:05 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref5.tex,1.38,1.39 Message-ID: <200012070454.UAA12047@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/ref In directory slayer.i.sourceforge.net:/tmp/cvs-serv12032/ref Modified Files: ref5.tex Log Message: Fix error noted by Gerrit Holl (old; had been buried in my INBOX): sequence repitition works just fine with long integers now, so we should not say that only plain integers are allowed. Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -r1.38 -r1.39 *** ref5.tex 2000/09/19 18:10:05 1.38 --- ref5.tex 2000/12/07 04:54:02 1.39 *************** *** 569,575 **** The \code{*} (multiplication) operator yields the product of its arguments. The arguments must either both be numbers, or one argument ! must be a plain integer and the other must be a sequence. In the ! former case, the numbers are converted to a common type and then ! multiplied together. In the latter case, sequence repetition is performed; a negative repetition factor yields an empty sequence. \index{multiplication} --- 569,575 ---- The \code{*} (multiplication) operator yields the product of its arguments. The arguments must either both be numbers, or one argument ! must be an integer (plain or long) and the other must be a sequence. ! In the former case, the numbers are converted to a common type and ! then multiplied together. In the latter case, sequence repetition is performed; a negative repetition factor yields an empty sequence. \index{multiplication} From python-dev@python.org Thu Dec 7 17:38:53 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 7 Dec 2000 09:38:53 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0230.txt,1.1,1.2 Message-ID: <200012071738.JAA25014@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv24990 Modified Files: pep-0230.txt Log Message: First stab at the Warnings PEP. I'm still working on the implementation... Index: pep-0230.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0230.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** pep-0230.txt 2000/11/28 22:23:25 1.1 --- pep-0230.txt 2000/12/07 17:38:50 1.2 *************** *** 20,23 **** --- 20,351 ---- + Motivation + + With Python 3000 looming, it is necessary to start issuing + warnings about the use of obsolete or deprecated features, in + addition to errors. There are also lots of other reasons to be + able to issue warnings, both from C and from Python code, both at + compile time and at run time. + + Warnings aren't fatal, and thus it's possible that a program + triggers the same warning many times during a single execution. + It would be annoying if a program emitted an endless stream of + identical warnings. Therefore, a mechanism is needed that + suppresses multiple identical warnings. + + It is also desirable to have user control over which warnings are + printed. While in general it is useful to see all warnings all + the time, there may be times where it is impractical to fix the + code right away in a production program. In this case, there + should be a way to suppress warnings. + + It is also useful to be able to suppress specific warnings during + program development, e.g. when a warning is generated by a piece + of 3rd party code that cannot be fixed right away, or when there + is no way to fix the code (possibly a warning message is generated + for a perfectly fine piece of code). It would be unwise to offer + to suppress all warnings in such cases: the developer would miss + warnings about the rest of the code. + + On the other hand, there are also situations conceivable where + some or all warnings are better treated as errors. For example, + it may be a local coding standard that a particular deprecated + feature should not be used. In order to enforce this, it is + useful to be able to turn the warning about this particular + feature into an error, raising an exception (without necessarily + turning all warnings into errors). + + Therefore, I propose to introduce a flexible "warning filter" + which can filter out warnings or change them into exceptions, + based on: + + - Where in the code they are generated (per package, module, or + function) + + - The warning category (warning categories are discussed below) + + - A specific warning message + + The warning filter must be controllable both from the command line + and from Python code. + + + APIs For Issuing Warnings + + - To issue a warning from Python: + + sys.warn(message[, category]) + + The category argument, if given, must be a warning category + class (see below); it defaults to warnings.UserWarning. This + may raise an exception if the particular warning issued is + changed into an error by the warnings filter. + + - To issue a warning from C: + + int Py_Warn(char *message, PyObject *category) + + Return 0 normally, 1 if an exception is raised. The category + argument must be a warning category class (see below). When + Py_Warn() function returns 1, the caller should do normal + exception handling. [Question: what about issuing warnings + during lexing or parsing, which don't have the exception + machinery available?] + + + Warnings Categories + + The "warnings" module defines classes representing warning + categories. This categorization is useful to be able to filter + out groups of warnings. The classes defined in this module have + no semantics attached to them and are never instantiated -- only + their names are used for filtering (see the section on the + warnings filter below). The following warnings category classes + are currently defined: + + - Warning -- this is the base class of all warning category + classes. A warning category must always be a subclass of this + class. + + - UserWarning -- the default category for sys.warn() + + - DeprecationWarning -- base category for warnings about deprecated + features + + - SyntaxWarning -- base category for warnings about dubious + syntactic features + + Other categories may be proposed during the review period for this + PEP. + + + The Warnings Filter + + The warnings filter control whether warnings are ignored, + displayed, or turned into errors (raising an exception). + + There are three sides to the warnings filter: + + - The data structures used to efficiently determine the + disposition of a particular Py_Warn() call. + + - The API to control the filter from Python source code. + + - The command line switches to control the filter. + + The warnings filter works in several stages. It is optimized for + the (expected to be common) case where the same warning is issued + from the same place in the code over and over. + + First, the warning filter collects the module and line number + where the warning is issued; this information is readily available + through PyEval_GetFrame(). + + Conceptually, the warnings filter maintains an ordered list of + filter specifications; any specific warning is matched against + each filter specification in the list in turn until a match is + found; the match determines the disposition of the match. Each + entry is a tuple as follows: + + (category, message, module, lineno, action) + + - category is a class (a subclass of warnings.Warning) of which + the warning category must be a subclass in order to match + + - message is a regular expression that the warning message must + match + + - module is a regular expression that the module name must match + + - lineno is an integer that the line number where the warning + occurred must match, or 0 to match all line numbers + + - action is one of the following strings: + + - "error" -- turn matching warnings into exceptions + + - "ignore" -- never print matching warnings + + - "always" -- always print matching warnings + + - "default" -- print the first occurrence of matching warnings + for each location where the warning is issued + + - "module" -- print the first occurrence of matching warnings + for each module where the warning is issued + + - "once" -- print only the first occurrence of matching + warnings + + The Warning class is derived from the built-in Exception class, so + that to turn a warning into an error we raise category(message). + + + The Warnings Output Hook + + When the warnings filter decides to issue a warning (but not when + it decides to raise an exception), it passes the information about + the function sys.showwarning(message, category, filename, lineno). + The default implementation of this function writes the warning text + to sys.stderr, and shows the source line of the filename. + + + TO DO + + - There should be a function sys.insertwarningfilter(message, + category, filename, lineno) that inserts items into the warnings + filter after some sanity checking. + + - There should be command line options to specify the most common + filtering actions, which I expect to include at least: + + - suppress all warnings + + - suppress a particular warning message everywhere + + - suppress all warnings in a particular module + + - turn all warnings into exceptions + + + Implementation + + Here is a mostly functional implementation: + + """Prototype implementation of sys.warn() and related stuff.""" + + import sys, re, linecache, getopt + + class Warning(Exception): + """Base class for warning categories. + + All warning categories must be subclasses of this. + """ + pass + + class UserWarning(Warning): + """Base class for warnings generated by user code.""" + pass + + class DeprecationWarning(Warning): + """Base class for warnings about deprecated features.""" + pass + + class SyntaxWarning(Warning): + """Base class for warnings about dubious syntax.""" + pass + + defaultaction = "default" + filter = [] + onceregistry = {} + + def warn(message, category=None, level=1): + """Issue a warning, or maybe ignore it or raise an exception.""" + # Check category argument + if category is None: + category = UserWarning + assert issubclass(category, Warning) + # Get context information + caller = sys._getframe(level) + globals = caller.f_globals + lineno = caller.f_lineno + module = globals['__name__'] + filename = globals.get('__file__') + if not filename: + if module == "__main__": + filename = sys.argv[0] + if not filename: + filename = module + # Quick test for common case + registry = globals.setdefault("__warningregistry__", {}) + key = (message, category, lineno) + if registry.get(key): + return + # Search the filter + for msg, cat, mod, ln, action in filter: + if (re.match(msg, message) and + issubclass(category, cat) and + re.match(mod, module) and + (ln == 0 or lineno == ln)): + break + else: + action = defaultaction + # Early exit actions + if action == "ignore": + registry[key] = 1 + return + if action == "error": + raise category(message) + # Other actions + if action == "once": + registry[key] = 1 + oncekey = (message, category) + if onceregistry.get(oncekey): + return + onceregistry[oncekey] = 1 + elif action == "always": + pass + elif action == "module": + registry[key] = 1 + altkey = (message, category, 0) + if registry.get(altkey): + return + registry[altkey] = 1 + elif action == "default": + registry[key] = 1 + else: + # Unrecognized actions are errors + raise RuntimeError( + "Unrecognized action (%s) in warnings.filter:\n %s" % + (`action`, str((cat, msg, mod, ln, action)))) + # Print message and context + showwarning(message, category, filename, lineno) + + def showwarning(message, category, filename, lineno): + print >>sys.stderr, "%s:%s: %s: %s" % (filename, lineno, + category.__name__, message) + line = linecache.getline(filename, lineno).strip() + if line: + print >>sys.stderr, " " + line + + def setupfilter(args): + """Set up the warnings filter based upon command line options. + + Return remaining command line arguments. + Raise getopt.error if an unrecognized option is found. + """ + opts, args = getopt.getop(args, "") + return args + + # Self-test + + def _test(): + hello = "hello world" + warn(hello) + warn(hello, UserWarning) + warn(hello, DeprecationWarning) + for i in range(3): + warn(hello) + filter.append(("", Warning, "", 0, "error")) + try: + warn(hello) + except Exception, msg: + print "Caught", msg.__class__.__name__ + ":", msg + else: + print "No exception" + filter[:] = [] + filter.append(("", Warning, "", 0, "booh")) + try: + warn(hello) + except Exception, msg: + print "Caught", msg.__class__.__name__ + ":", msg + else: + print "No exception" + + if __name__ == "__main__": + args = setupfilter(sys.argv[1:]) + _test() + + Local Variables: From python-dev@python.org Thu Dec 7 21:52:16 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 7 Dec 2000 13:52:16 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0230.txt,1.2,1.3 Message-ID: <200012072152.NAA25272@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv25254 Modified Files: pep-0230.txt Log Message: Revised version, completing a bunch of things that weren't resolved before. The implementation was removed from the PEP, it's now in the SF patch manager; I'm pretty happy with it! :-) Index: pep-0230.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0230.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** pep-0230.txt 2000/12/07 17:38:50 1.2 --- pep-0230.txt 2000/12/07 21:52:14 1.3 *************** *** 191,350 **** ! TO DO ! - There should be a function sys.insertwarningfilter(message, ! category, filename, lineno) that inserts items into the warnings ! filter after some sanity checking. ! - There should be command line options to specify the most common ! filtering actions, which I expect to include at least: ! - suppress all warnings ! - suppress a particular warning message everywhere ! - suppress all warnings in a particular module ! - turn all warnings into exceptions ! Implementation ! Here is a mostly functional implementation: ! """Prototype implementation of sys.warn() and related stuff.""" ! import sys, re, linecache, getopt ! class Warning(Exception): ! """Base class for warning categories. ! All warning categories must be subclasses of this. ! """ ! pass ! ! class UserWarning(Warning): ! """Base class for warnings generated by user code.""" ! pass ! ! class DeprecationWarning(Warning): ! """Base class for warnings about deprecated features.""" ! pass ! ! class SyntaxWarning(Warning): ! """Base class for warnings about dubious syntax.""" ! pass ! ! defaultaction = "default" ! filter = [] ! onceregistry = {} ! ! def warn(message, category=None, level=1): ! """Issue a warning, or maybe ignore it or raise an exception.""" ! # Check category argument ! if category is None: ! category = UserWarning ! assert issubclass(category, Warning) ! # Get context information ! caller = sys._getframe(level) ! globals = caller.f_globals ! lineno = caller.f_lineno ! module = globals['__name__'] ! filename = globals.get('__file__') ! if not filename: ! if module == "__main__": ! filename = sys.argv[0] ! if not filename: ! filename = module ! # Quick test for common case ! registry = globals.setdefault("__warningregistry__", {}) ! key = (message, category, lineno) ! if registry.get(key): ! return ! # Search the filter ! for msg, cat, mod, ln, action in filter: ! if (re.match(msg, message) and ! issubclass(category, cat) and ! re.match(mod, module) and ! (ln == 0 or lineno == ln)): ! break ! else: ! action = defaultaction ! # Early exit actions ! if action == "ignore": ! registry[key] = 1 ! return ! if action == "error": ! raise category(message) ! # Other actions ! if action == "once": ! registry[key] = 1 ! oncekey = (message, category) ! if onceregistry.get(oncekey): ! return ! onceregistry[oncekey] = 1 ! elif action == "always": ! pass ! elif action == "module": ! registry[key] = 1 ! altkey = (message, category, 0) ! if registry.get(altkey): ! return ! registry[altkey] = 1 ! elif action == "default": ! registry[key] = 1 ! else: ! # Unrecognized actions are errors ! raise RuntimeError( ! "Unrecognized action (%s) in warnings.filter:\n %s" % ! (`action`, str((cat, msg, mod, ln, action)))) ! # Print message and context ! showwarning(message, category, filename, lineno) ! ! def showwarning(message, category, filename, lineno): ! print >>sys.stderr, "%s:%s: %s: %s" % (filename, lineno, ! category.__name__, message) ! line = linecache.getline(filename, lineno).strip() ! if line: ! print >>sys.stderr, " " + line ! ! def setupfilter(args): ! """Set up the warnings filter based upon command line options. ! ! Return remaining command line arguments. ! Raise getopt.error if an unrecognized option is found. ! """ ! opts, args = getopt.getop(args, "") ! return args ! ! # Self-test ! ! def _test(): ! hello = "hello world" ! warn(hello) ! warn(hello, UserWarning) ! warn(hello, DeprecationWarning) ! for i in range(3): ! warn(hello) ! filter.append(("", Warning, "", 0, "error")) ! try: ! warn(hello) ! except Exception, msg: ! print "Caught", msg.__class__.__name__ + ":", msg ! else: ! print "No exception" ! filter[:] = [] ! filter.append(("", Warning, "", 0, "booh")) ! try: ! warn(hello) ! except Exception, msg: ! print "Caught", msg.__class__.__name__ + ":", msg ! else: ! print "No exception" ! ! if __name__ == "__main__": ! args = setupfilter(sys.argv[1:]) ! _test() --- 191,334 ---- ! API For Manipulating Warning Filters ! sys.filterwarnings(message, category, module, lineno, action) ! This checks the types of the arguments and inserts them as a tuple ! in front of the warnings filter. ! sys.resetwarnings() ! Reset the warnings filter to empty. ! sys.setupwarnings(args) ! Parse command line options and initialize the warnings filter ! accordingly. The argument should be sys.argv[1:] or equivalent. ! Unrecognized options raise getopt.error. The return value is a ! list containing the remaining (non-option) arguments. ! Command Line Syntax ! ! There should be command line options to specify the most common ! filtering actions, which I expect to include at least: ! ! - suppress all warnings ! ! - suppress a particular warning message everywhere ! ! - suppress all warnings in a particular module ! ! - turn all warnings into exceptions ! ! I propose the following command line option syntax: ! ! -Waction[:message[:category[:module[:lineno]]]] ! ! Where: ! ! - 'action' is an abbreviation of one of the allowed actions ! ("error", "default", "ignore", "always", "once", or "module") ! ! - 'message' is a message string; matches warnings whose message ! text is an initial substring of 'message' (matching is ! case-sensitive) ! ! - 'category' is an abbreviation of a standard warning category ! class name *or* a fully-qualified name for a user-defined ! warning category class of the form [package.]module.classname ! ! - 'module' is a module name (possibly package.module) ! ! - 'lineno' is an integral line number ! ! All parts except 'action' may be omitted, where an empty value ! after stripping whitespace is the same as an omitted value. ! ! Each -W option results into a call to sys.filterwarnings(); thus ! later -W options override earlier -W options for warnings they ! both match. ! ! Examples: ! ! -Werror ! Turn all warnings into errors ! ! -Wall ! Show all warnings ! ! -Wignore ! Ignore all warnings ! -Wi:hello ! Ignore warnings whose message text starts with "hello" ! -We::Deprecation ! Turn deprecation warnings into errors ! -Wi:::spam:10 ! Ignore all warnings on line 10 of module spam ! -Wi:::spam -Wd:::spam:10 ! Ignore all warnings in module spam except on line 10 ! ! -We::Deprecation -Wd::Deprecation:spam ! Turn deprecation warnings into errors except in module spam ! ! ! Open Issues ! ! Some open issues off the top of my head: ! ! - The proposal has all the Python API functions in the sys module, ! except that the warning categories are in the warnings module. ! Perhaps everything should be in the warnings module (like the ! prototype implementation)? Or perhaps warn() should be promoted ! to a built-in (i.e. in the __builtin__ module)? ! ! - It's tempting to leave the implementation in Python and add an ! absolute minimal amount of C code, only to make the standard ! warning categories available from C code. The Py_Warn() ! function could call warnings.warn(). Similarly, the Python ! main() function could collect -W options and pass them to ! warnings.setupwarnings(). ! ! - The prototype implements a third argument to warn(): ! ! warn(message, category=UserWarning, level=1) ! ! The 'level' argument could be used by wrapper functions written ! in Python, like this: ! ! def deprecation(message): ! warn(message, DeprecationWarning, level=2) ! ! This makes the warning refer to the deprecation()'s caller, ! rather than to the source of deprecation() itself (the latter ! would defeat the purpose of the warning message). ! ! - The proposed command line syntax is ugly (although the simple ! cases aren't so bad: -Werror, -Wignore, etc.). Anybody got a ! better idea? ! ! - I'm a bit worried that the filter specifications are too ! complex. Perhaps filtering only on category and module (not on ! message text and line number) would be enough? ! ! - There's a bit of confusion between module names and file names. ! The reporting uses file names, but the filter specification uses ! module names. Maybe it should allow filenames as well? ! ! - I'm not at all convinced that packages are handled right. ! ! - Better names for the various API functions? ! ! ! Implementation ! Here's a prototype implementation: + http://sourceforge.net/patch/?func=detailpatch&patch_id=102715&group_id=5470 From python-dev@python.org Fri Dec 8 06:54:54 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 7 Dec 2000 22:54:54 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib xmldom.tex,1.3,1.4 Message-ID: <200012080654.WAA08163@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv8155/lib Modified Files: xmldom.tex Log Message: Lots of small improvements and bits of added information on the DOM API. Index: xmldom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmldom.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** xmldom.tex 2000/12/07 04:47:51 1.3 --- xmldom.tex 2000/12/08 06:54:51 1.4 *************** *** 147,150 **** --- 147,151 ---- \constant{COMMENT_NODE}, \constant{DOCUMENT_NODE}, \constant{DOCUMENT_TYPE_NODE}, \constant{NOTATION_NODE}. + This is a read-only attribute. \end{memberdesc} *************** *** 155,158 **** --- 156,160 ---- root element, in which case it will be the \class{Document} object. For \class{Attr} nodes, this is always \code{None}. + This is a read-only attribute. \end{memberdesc} *************** *** 160,163 **** --- 162,166 ---- An \class{AttributeList} of attribute objects. Only elements have actual values for this; others provide \code{None} for this attribute. + This is a read-only attribute. \end{memberdesc} *************** *** 169,172 **** --- 172,176 ---- comment, or something else. If this node is the first child of the parent, this attribute will be \code{None}. + This is a read-only attribute. \end{memberdesc} *************** *** 175,225 **** also \member{previousSibling}. If this is the last child of the parent, this attribute will be \code{None}. \end{memberdesc} \begin{memberdesc}[Node]{childNodes} A list of nodes contained within this node. \end{memberdesc} \begin{memberdesc}[Node]{firstChild} The first child of the node, if there are any, or \code{None}. \end{memberdesc} \begin{memberdesc}[Node]{lastChild} The last child of the node, if there are any, or \code{None}. \end{memberdesc} ! \begin{memberdesc}[Element]{namespaceURI} The namespace associated with the element name. This will be a ! string. \end{memberdesc} \begin{memberdesc}[Node]{nodeName} ! Has a different meaning for each node type. See the DOM specification ! for details. You can always get the information you would get here ! from another property such as the \member{tagName} property for ! elements or the \member{name} property for attributes. For all node ! types, the value of this attribute will be either a string or ! \code{None}. \end{memberdesc} \begin{memberdesc}[Node]{nodeValue} ! Has a different meaning for each node type. See the DOM specification ! for details. The situation is similar to that with \member{nodeName}. \end{memberdesc} \begin{methoddesc}[Node]{hasChildNodes}{} Returns true if the node has any child nodes. \end{methoddesc} \begin{methoddesc}[Node]{insertBefore}{newChild, refChild} Insert a new child node before an existing child. It must be the case that \var{refChild} is a child of this node; if not, ! \exception{ValueError} is raised. ! \end{methoddesc} ! ! \begin{methoddesc}[Node]{replaceChild}{newChild, oldChild} ! Replace an existing node with a new node. It must be the case that ! \var{oldChild} is a child of this node; if not, ! \exception{ValueError} is raised. \end{methoddesc} --- 179,247 ---- also \member{previousSibling}. If this is the last child of the parent, this attribute will be \code{None}. + This is a read-only attribute. \end{memberdesc} \begin{memberdesc}[Node]{childNodes} A list of nodes contained within this node. + This is a read-only attribute. \end{memberdesc} \begin{memberdesc}[Node]{firstChild} The first child of the node, if there are any, or \code{None}. + This is a read-only attribute. \end{memberdesc} \begin{memberdesc}[Node]{lastChild} The last child of the node, if there are any, or \code{None}. + This is a read-only attribute. \end{memberdesc} ! \begin{memberdesc}[Node]{localName} ! The part of the \member{tagName} following the colon if there is one, ! else the entire \member{tagName}. The value is a string. ! \end{memberdesc} ! ! \begin{memberdesc}[Node]{prefix} ! The part of the \member{tagName} preceding the colon if there is one, ! else the empty string. The value is a string, or \code{None} ! \end{memberdesc} ! ! \begin{memberdesc}[Node]{namespaceURI} The namespace associated with the element name. This will be a ! string or \code{None}. This is a read-only attribute. \end{memberdesc} \begin{memberdesc}[Node]{nodeName} ! This has a different meaning for each node type; see the DOM ! specification for details. You can always get the information you ! would get here from another property such as the \member{tagName} ! property for elements or the \member{name} property for attributes. ! For all node types, the value of this attribute will be either a ! string or \code{None}. This is a read-only attribute. \end{memberdesc} \begin{memberdesc}[Node]{nodeValue} ! This has a different meaning for each node type; see the DOM ! specification for details. The situation is similar to that with ! \member{nodeName}. The value is a string or \code{None}. \end{memberdesc} + \begin{methoddesc}[Node]{hasAttributes}{} + Returns true if the node has any attributes. + \end{methoddesc} + \begin{methoddesc}[Node]{hasChildNodes}{} Returns true if the node has any child nodes. \end{methoddesc} + \begin{methoddesc}[Node]{appendChild}{newChild} + Add a new child node to this node at the end of the list of children, + returning \var{newChild}. + \end{methoddesc} + \begin{methoddesc}[Node]{insertBefore}{newChild, refChild} Insert a new child node before an existing child. It must be the case that \var{refChild} is a child of this node; if not, ! \exception{ValueError} is raised. \var{newChild} is returned. \end{methoddesc} *************** *** 231,237 **** \end{methoddesc} ! \begin{methoddesc}[Node]{appendChild}{newChild} ! Add a new child node to this node at the end of the list of children, ! returning \var{newChild}. \end{methoddesc} --- 253,260 ---- \end{methoddesc} ! \begin{methoddesc}[Node]{replaceChild}{newChild, oldChild} ! Replace an existing node with a new node. It must be the case that ! \var{oldChild} is a child of this node; if not, ! \exception{ValueError} is raised. \end{methoddesc} *************** *** 411,423 **** \end{memberdesc} ! \begin{memberdesc}[Element]{localName} ! The part of the \member{tagName} following the colon if there is one, ! else the entire \member{tagName}. The value is a string. ! \end{memberdesc} ! \begin{memberdesc}[Element]{prefix} ! The part of the \member{tagName} preceding the colon if there is one, ! else the empty string. The value is a string, or \code{None} ! \end{memberdesc} \begin{methoddesc}[Element]{getAttribute}{attname} --- 434,444 ---- \end{memberdesc} ! \begin{methoddesc}[Element]{getElementsByTagName}{tagName} ! Same as equivalent method in the \class{Document} class. ! \end{methoddesc} ! \begin{methoddesc}[Element]{getElementsByTagNameNS}{tagName} ! Same as equivalent method in the \class{Document} class. ! \end{methoddesc} \begin{methoddesc}[Element]{getAttribute}{attname} *************** *** 426,466 **** \begin{methoddesc}[Element]{getAttributeNode}{attrname} ! Return the \class{Attr} node for the attribute named by \var{attrname} \end{methoddesc} ! \begin{methoddesc}[Element]{setAttribute}{attname, value} ! Set an attribute value from a string. \end{methoddesc} ! \begin{methoddesc}[Element]{removeAttribute}{attname} ! Remove an attribute by name. \end{methoddesc} ! \begin{methoddesc}[Element]{getAttributeNS}{namespaceURI, localName} ! Return an attribute value as a string, given a \var{namespaceURI} and ! \var{localName}. Note that a localname is the part of a prefixed ! attribute name after the colon (if there is one). \end{methoddesc} ! \begin{methoddesc}[Element]{setAttributeNS}{namespaceURI, qname, value} ! Set an attribute value from a string, given a \var{namespaceURI} and a ! \var{qname}. Note that a qname is the whole attribute name. This is ! different than above. \end{methoddesc} \begin{methoddesc}[Element]{removeAttributeNS}{namespaceURI, localName} Remove an attribute by name. Note that it uses a localName, not a ! qname. \end{methoddesc} ! \begin{methoddesc}[Element]{getElementsByTagName}{tagName} ! Same as equivalent method in the \class{Document} class. \end{methoddesc} ! \begin{methoddesc}[Element]{getElementsByTagNameNS}{tagName} ! Same as equivalent method in the \class{Document} class. \end{methoddesc} \subsubsection{Attr Objects \label{dom-attr-objects}} --- 447,506 ---- \begin{methoddesc}[Element]{getAttributeNode}{attrname} ! Return the \class{Attr} node for the attribute named by ! \var{attrname}. \end{methoddesc} ! \begin{methoddesc}[Element]{getAttributeNS}{namespaceURI, localName} ! Return an attribute value as a string, given a \var{namespaceURI} and ! \var{localName}. \end{methoddesc} ! \begin{methoddesc}[Element]{getAttributeNodeNS}{namespaceURI, localName} ! Return an attribute value as a node, given a \var{namespaceURI} and ! \var{localName}. \end{methoddesc} ! \begin{methoddesc}[Element]{removeAttribute}{attname} ! Remove an attribute by name. No exception is raised if there is no ! matching attribute. \end{methoddesc} ! \begin{methoddesc}[Element]{removeAttributeNode}{oldAttr} ! Remove and return \var{oldAttr} from the attribute list, if present. ! If \var{oldAttr} is not present, \exception{NotFoundErr} is raised. \end{methoddesc} \begin{methoddesc}[Element]{removeAttributeNS}{namespaceURI, localName} Remove an attribute by name. Note that it uses a localName, not a ! qname. No exception is raised if there is no matching attribute. \end{methoddesc} ! \begin{methoddesc}[Element]{setAttribute}{attname, value} ! Set an attribute value from a string. \end{methoddesc} ! \begin{methoddesc}[Element]{setAttributeNode}{newAttr} ! Add a new attibute node to the element, replacing an existing ! attribute if necessary if the \member{name} attribute matches. If a ! replacement occurs, the old attribute node will be returned. If ! \var{newAttr} is already in use, \exception{InuseAttributeErr} will be ! raised. \end{methoddesc} + \begin{methoddesc}[Element]{setAttributeNodeNS}{newAttr} + Add a new attibute node to the element, replacing an existing + attribute if necessary if the \member{namespaceURI} and + \member{localName} attributes match. If a replacement occurs, the old + attribute node will be returned. If \var{newAttr} is already in use, + \exception{InuseAttributeErr} will be raised. + \end{methoddesc} + \begin{methoddesc}[Element]{setAttributeNS}{namespaceURI, qname, value} + Set an attribute value from a string, given a \var{namespaceURI} and a + \var{qname}. Note that a qname is the whole attribute name. This is + different than above. + \end{methoddesc} + + \subsubsection{Attr Objects \label{dom-attr-objects}} *************** *** 475,479 **** \begin{memberdesc}[Attr]{localName} The part of the name following the colon if there is one, else the ! entire name. \end{memberdesc} --- 515,519 ---- \begin{memberdesc}[Attr]{localName} The part of the name following the colon if there is one, else the ! entire name. This is a read-only attribute. \end{memberdesc} *************** *** 483,490 **** \end{memberdesc} - \begin{memberdesc}[Attr]{namespaceURI} - The namespace associated with the attribute name. - \end{memberdesc} - \subsubsection{NamedNodeMap Objects \label{dom-attributelist-objects}} --- 523,526 ---- *************** *** 511,539 **** \class{Comment} represents a comment in the XML document. It is a ! subclass of \class{Node}. \begin{memberdesc}[Comment]{data} ! The content of the comment. \end{memberdesc} ! \subsubsection{Text Objects \label{dom-text-objects}} ! The \class{Text} interface represents text in the XML document. It ! inherits from \class{Node}. \begin{memberdesc}[Text]{data} ! The content of the text node. \end{memberdesc} \subsubsection{ProcessingInstruction Objects \label{dom-pi-objects}} Represents a processing instruction in the XML document; this inherits ! from the \class{Node} interface. \begin{memberdesc}[ProcessingInstruction]{target} The content of the processing instruction up to the first whitespace ! character. \end{memberdesc} --- 547,590 ---- \class{Comment} represents a comment in the XML document. It is a ! subclass of \class{Node}, but cannot have child nodes. \begin{memberdesc}[Comment]{data} ! The content of the comment as a string. The attribute contains all ! characters between the leading \code{}, but does not include them. \end{memberdesc} ! \subsubsection{Text and CDATASection Objects \label{dom-text-objects}} ! The \class{Text} interface represents text in the XML document. If ! the parser and DOM implementation support the DOM's XML extension, ! portions of the text enclosed in CDATA marked sections are stored in ! \class{CDATASection} objects. These two interfaces are identical, but ! provide different values for the \member{nodeType} attribute. + These interfaces extend the \class{Node} interface. They cannot have + child nodes. + \begin{memberdesc}[Text]{data} ! The content of the text node as a string. \end{memberdesc} + \strong{Note:} The use of a \class{CDATASection} node does not + indicate that the node represents a complete CDATA marked section, + only that the content of the node was part of a CDATA section. A + single CDATA section may be represented by more than one node in the + document tree. There is no way to determine whether two adjacent + \class{CDATASection} nodes represent different CDATA marked sections. + \subsubsection{ProcessingInstruction Objects \label{dom-pi-objects}} Represents a processing instruction in the XML document; this inherits ! from the \class{Node} interface and cannot have child nodes. \begin{memberdesc}[ProcessingInstruction]{target} The content of the processing instruction up to the first whitespace ! character. This is a read-only attribute. \end{memberdesc} From python-dev@python.org Fri Dec 8 15:05:12 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 8 Dec 2000 07:05:12 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.55,1.56 Message-ID: <200012081505.HAA30197@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv30180 Modified Files: pep-0000.txt Log Message: __findattr__ is rejected -- the idea is too uncooked and you actually *can* do most of this with __getattr__. Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -r1.55 -r1.56 *** pep-0000.txt 2000/12/05 03:31:13 1.55 --- pep-0000.txt 2000/12/08 15:05:09 1.56 *************** *** 40,44 **** S 227 pep-0227.txt Statically Nested Scopes Hylton S 230 pep-0230.txt Warning Framework van Rossum - S 231 pep-0231.txt __findattr__() Warsaw Pie-in-the-sky PEPs (not ready; may become active yet) --- 40,43 ---- *************** *** 80,83 **** --- 79,83 ---- SR 204 pep-0204.txt Range Literals Wouters + SR 231 pep-0231.txt __findattr__() Warsaw *************** *** 127,131 **** S 229 pep-0229.txt Using Distutils to Build Python Kuchling S 230 pep-0230.txt Warning Framework van Rossum ! S 231 pep-0231.txt __findattr__() Warsaw Key --- 127,131 ---- S 229 pep-0229.txt Using Distutils to Build Python Kuchling S 230 pep-0230.txt Warning Framework van Rossum ! SR 231 pep-0231.txt __findattr__() Warsaw Key From python-dev@python.org Fri Dec 8 15:36:05 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 8 Dec 2000 07:36:05 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0231.txt,1.3,1.4 Message-ID: <200012081536.HAA01447@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv1430 Modified Files: pep-0231.txt Log Message: Rejection notice (with Barry's agreement). Index: pep-0231.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0231.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** pep-0231.txt 2000/12/02 15:12:35 1.3 --- pep-0231.txt 2000/12/08 15:36:03 1.4 *************** *** 603,606 **** --- 603,626 ---- + Rejection + + There are serious problems with the recursion-protection feature. + As described here it's not thread-safe, and a thread-safe solution + has other problems. In general, it's not clear how helpful the + recursion-protection feature is; it makes it hard to write code + that needs to be callable inside __findattr__ as well as outside + it. But without the recursion-protection, it's hard to implement + __findattr__ at all (since __findattr__ would invoke itself + recursively for every attribute it tries to access). There seems + to be no good solution here. + + It's also dubious how useful it is to support __findattr__ both + for getting and for setting attributes -- __setattr__ gets called + in all cases alrady. + + The examples can all be implemented using __getattr__ if care is + taken not to store instance variables under their own names. + + Copyright From python-dev@python.org Fri Dec 8 16:02:31 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 8 Dec 2000 08:02:31 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0225.txt,1.1,1.2 Message-ID: <200012081602.IAA06030@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv6017 Modified Files: pep-0225.txt Log Message: Add a missing colon to the first header line, to fix the HTML formatting. Index: pep-0225.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0225.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** pep-0225.txt 2000/09/19 15:29:58 1.1 --- pep-0225.txt 2000/12/08 16:02:28 1.2 *************** *** 1,3 **** ! PEP 225 Title: Elementwise/Objectwise Operators Version: $Revision$ --- 1,3 ---- ! PEP: 225 Title: Elementwise/Objectwise Operators Version: $Revision$ From python-dev@python.org Sat Dec 9 05:03:25 2000 From: python-dev@python.org (Tim Peters) Date: Fri, 8 Dec 2000 21:03:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/scripts ndiff.py,1.5,1.6 Message-ID: <200012090503.VAA01813@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/scripts In directory slayer.i.sourceforge.net:/tmp/cvs-serv1727/python/dist/src/tools/scripts Modified Files: ndiff.py Log Message: SF bug 124051: ndiff "?" lines can be confusing. Well, they still can, but after implementing it I liked Gregor's two-"?" line idea a lot. Index: ndiff.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/ndiff.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** ndiff.py 2000/11/01 02:51:27 1.5 --- ndiff.py 2000/12/09 05:03:22 1.6 *************** *** 1,7 **** #! /usr/bin/env python ! # Module ndiff version 1.5.0 ! # Released to the public domain 08-Oct-2000, ! # by Tim Peters (tim_one@email.msn.com). # Provided as-is; use at your own risk; no warranty; no promises; enjoy! --- 1,7 ---- #! /usr/bin/env python ! # Module ndiff version 1.6.0 ! # Released to the public domain 08-Dec-2000, ! # by Tim Peters (tim.one@home.com). # Provided as-is; use at your own risk; no warranty; no promises; enjoy! *************** *** 409,419 **** print tag, x[i], - # figure out which mark to stick under characters in lines that - # have changed (blank = same, - = deleted, + = inserted, ^ = replaced) - _combine = { ' ': ' ', - '. ': '-', - ' .': '+', - '..': '^' } - def plain_replace(a, alo, ahi, b, blo, bhi): assert alo < ahi and blo < bhi --- 409,412 ---- *************** *** 492,496 **** aelt, belt = a[best_i], b[best_j] if eqi is None: ! # pump out a '-', '+', '?' triple for the synched lines; atags = btags = "" cruncher.set_seqs(aelt, belt) --- 485,489 ---- aelt, belt = a[best_i], b[best_j] if eqi is None: ! # pump out a '-', '?', '+', '?' quad for the synched lines atags = btags = "" cruncher.set_seqs(aelt, belt) *************** *** 498,519 **** la, lb = ai2 - ai1, bj2 - bj1 if tag == 'replace': ! atags = atags + '.' * la ! btags = btags + '.' * lb elif tag == 'delete': ! atags = atags + '.' * la elif tag == 'insert': ! btags = btags + '.' * lb elif tag == 'equal': ! atags = atags + ' ' * la ! btags = btags + ' ' * lb else: raise ValueError, 'unknown tag ' + `tag` ! la, lb = len(atags), len(btags) ! if la < lb: ! atags = atags + ' ' * (lb - la) ! elif lb < la: ! btags = btags + ' ' * (la - lb) ! combined = map(lambda x,y: _combine[x+y], atags, btags) ! printq(aelt, belt, string.rstrip(string.join(combined, ''))) else: # the synch pair is identical --- 491,506 ---- la, lb = ai2 - ai1, bj2 - bj1 if tag == 'replace': ! atags += '^' * la ! btags += '^' * lb elif tag == 'delete': ! atags += '-' * la elif tag == 'insert': ! btags += '+' * lb elif tag == 'equal': ! atags += ' ' * la ! btags += ' ' * lb else: raise ValueError, 'unknown tag ' + `tag` ! printq(aelt, belt, atags, btags) else: # the synch pair is identical *************** *** 535,544 **** # probably help most of the time. ! def printq(aline, bline, qline): common = min(count_leading(aline, "\t"), count_leading(bline, "\t")) ! common = min(common, count_leading(qline[:common], " ")) ! qline = "\t" * common + qline[common:] ! print '-', aline, '+', bline, '?', qline def count_leading(line, ch): --- 522,535 ---- # probably help most of the time. ! def printq(aline, bline, atags, btags): common = min(count_leading(aline, "\t"), count_leading(bline, "\t")) ! common = min(common, count_leading(atags[:common], " ")) ! print "-", aline, ! if count_leading(atags, " ") < len(atags): ! print "?", "\t" * common + atags[common:] ! print "+", bline, ! if count_leading(btags, " ") < len(btags): ! print "?", "\t" * common + btags[common:] def count_leading(line, ch): From python-dev@python.org Sun Dec 10 15:12:17 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 10 Dec 2000 07:12:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib codecs.py,1.12,1.13 Message-ID: <200012101512.HAA20646@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv20536 Modified Files: codecs.py Log Message: (Patch #102698) Fix for a bug reported by Wade Leftwich: StreamReader ignores the 'errors' parameter passed to its constructor Index: codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codecs.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** codecs.py 2000/10/02 22:11:47 1.12 --- codecs.py 2000/12/10 15:12:14 1.13 *************** *** 206,210 **** # Unsliced reading: if size < 0: ! return self.decode(self.stream.read())[0] # Sliced reading: --- 206,210 ---- # Unsliced reading: if size < 0: ! return self.decode(self.stream.read(), self.errors)[0] # Sliced reading: *************** *** 215,219 **** while 1: try: ! object, decodedbytes = decode(data) except ValueError,why: # This method is slow but should work under pretty much --- 215,219 ---- while 1: try: ! object, decodedbytes = decode(data, self.errors) except ValueError,why: # This method is slow but should work under pretty much *************** *** 248,252 **** else: line = self.stream.readline(size) ! return self.decode(line)[0] --- 248,252 ---- else: line = self.stream.readline(size) ! return self.decode(line,self.errors)[0] *************** *** 267,271 **** else: data = self.stream.read(sizehint) ! return self.decode(data)[0].splitlines(1) def reset(self): --- 267,271 ---- else: data = self.stream.read(sizehint) ! return self.decode(data,self.errors)[0].splitlines(1) def reset(self): From python-dev@python.org Mon Dec 11 15:50:10 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 11 Dec 2000 07:50:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libselect.tex,1.16,1.17 Message-ID: <200012111550.HAA10913@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv10901/lib Modified Files: libselect.tex Log Message: select.select(): Add note that though this function accepts empty lists, using *only* empty lists may not be acceptable on all platforms, with the specific caveat that it does not work on Windows. Also clarified list of acceptable objects that may be in the lists, to let the user know that file objects are not usable here on Windows. Index: libselect.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libselect.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** libselect.tex 2000/08/25 01:21:28 1.16 --- libselect.tex 2000/12/11 15:50:07 1.17 *************** *** 34,45 **** This is a straightforward interface to the \UNIX{} \cfunction{select()} system call. The first three arguments are lists of `waitable ! objects': either integers representing \UNIX{} file descriptors or objects with a parameterless method named \method{fileno()} returning such an integer. The three lists of waitable objects are for input, output and `exceptional conditions', respectively. Empty lists are ! allowed. The optional \var{timeout} argument specifies a time-out as a ! floating point number in seconds. When the \var{timeout} argument ! is omitted the function blocks until at least one file descriptor is ! ready. A time-out value of zero specifies a poll and never blocks. The return value is a triple of lists of objects that are ready: --- 34,47 ---- This is a straightforward interface to the \UNIX{} \cfunction{select()} system call. The first three arguments are lists of `waitable ! objects': either integers representing file descriptors or objects with a parameterless method named \method{fileno()} returning such an integer. The three lists of waitable objects are for input, output and `exceptional conditions', respectively. Empty lists are ! allowed, but acceptance of three empty lists is platform-dependent. ! (It is known to work on \UNIX{} but not on Windows.) The optional ! \var{timeout} argument specifies a time-out as a floating point number ! in seconds. When the \var{timeout} argument is omitted the function ! blocks until at least one file descriptor is ready. A time-out value ! of zero specifies a poll and never blocks. The return value is a triple of lists of objects that are ready: *************** *** 53,64 **** returned by \function{socket.socket()},% \withsubitem{(in module socket)}{\ttindex{socket()}} ! \withsubitem{(in module os)}{\ttindex{popen()}} ! and the module \module{stdwin}\refbimodindex{stdwin} which happens to ! define a function ! \function{fileno()}\withsubitem{(in module stdwin)}{\ttindex{fileno()}} ! for just this purpose. You may ! also define a \dfn{wrapper} class yourself, as long as it has an ! appropriate \method{fileno()} method (that really returns a \UNIX{} ! file descriptor, not just a random integer). \end{funcdesc} --- 55,66 ---- returned by \function{socket.socket()},% \withsubitem{(in module socket)}{\ttindex{socket()}} ! \withsubitem{(in module os)}{\ttindex{popen()}}. ! You may also define a \dfn{wrapper} class yourself, as long as it has ! an appropriate \method{fileno()} method (that really returns a file ! descriptor, not just a random integer). ! \strong{Note:}\index{WinSock} File objects on Windows are not ! acceptable, but sockets are. On Windows, the underlying ! \cfunction{select()} function is provided by the WinSock library, and ! does not handle file desciptors that don't originate from WinSock. \end{funcdesc} From python-dev@python.org Mon Dec 11 16:34:37 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 11 Dec 2000 08:34:37 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0230.txt,1.3,1.4 Message-ID: <200012111634.IAA16062@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv16049 Modified Files: pep-0230.txt Log Message: New version of the PEP. Changes based upon the second (delayed-import) implentation. Address some of Paul's concerns. Index: pep-0230.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0230.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** pep-0230.txt 2000/12/07 21:52:14 1.3 --- pep-0230.txt 2000/12/11 16:34:34 1.4 *************** *** 17,21 **** on 05-Nov-2000, with some ideas (such as using classes to categorize warnings) merged in from Paul Prescod's ! counter-proposal posted on the same date. --- 17,22 ---- on 05-Nov-2000, with some ideas (such as using classes to categorize warnings) merged in from Paul Prescod's ! counter-proposal posted on the same date. Also, an attempt to ! implement the proposal caused several small tweaks. *************** *** 75,112 **** - To issue a warning from Python: ! sys.warn(message[, category]) The category argument, if given, must be a warning category class (see below); it defaults to warnings.UserWarning. This may raise an exception if the particular warning issued is ! changed into an error by the warnings filter. - To issue a warning from C: ! int Py_Warn(char *message, PyObject *category) ! Return 0 normally, 1 if an exception is raised. The category ! argument must be a warning category class (see below). When ! Py_Warn() function returns 1, the caller should do normal ! exception handling. [Question: what about issuing warnings ! during lexing or parsing, which don't have the exception ! machinery available?] Warnings Categories ! The "warnings" module defines classes representing warning categories. This categorization is useful to be able to filter ! out groups of warnings. The classes defined in this module have ! no semantics attached to them and are never instantiated -- only ! their names are used for filtering (see the section on the ! warnings filter below). The following warnings category classes are currently defined: - Warning -- this is the base class of all warning category ! classes. A warning category must always be a subclass of this ! class. ! - UserWarning -- the default category for sys.warn() - DeprecationWarning -- base category for warnings about deprecated --- 76,127 ---- - To issue a warning from Python: ! import warnings ! warnings.warn(message[, category[, stacklevel]]) The category argument, if given, must be a warning category class (see below); it defaults to warnings.UserWarning. This may raise an exception if the particular warning issued is ! changed into an error by the warnings filter. The stacklevel ! can be used by wrapper functions written in Python, like this: + def deprecation(message): + warn(message, DeprecationWarning, level=2) + + This makes the warning refer to the deprecation()'s caller, + rather than to the source of deprecation() itself (since the + latter would defeat the purpose of the warning message). + - To issue a warning from C: + + int PyErr_Warn(PyObject *category, char *message); ! Return 0 normally, 1 if an exception is raised (either because ! the warning was transformed into an exception, or because of a ! malfunction in the implementation, such as running out of ! memory). The category argument must be a warning category class ! (see below) or NULL, in which case it defaults to ! PyExc_RuntimeWarning. When PyErr_Warn() function returns 1, the ! caller should do normal exception handling. ! ! The current C implementation of PyErr_Warn() imports the ! warnings module (implemented in Python) and calls its warn() ! function. This minimizes the amount of C code that needs to be ! added to implement the warning feature. ! [XXX Open Issue: what about issuing warnings during lexing or ! parsing, which don't have the exception machinery available?] Warnings Categories ! There are a number of built-in exceptions that represent warning categories. This categorization is useful to be able to filter ! out groups of warnings. The following warnings category classes are currently defined: - Warning -- this is the base class of all warning category ! classes and it itself a subclass of Exception ! - UserWarning -- the default category for warnings.warn() - DeprecationWarning -- base category for warnings about deprecated *************** *** 115,121 **** - SyntaxWarning -- base category for warnings about dubious syntactic features ! Other categories may be proposed during the review period for this ! PEP. --- 130,147 ---- - SyntaxWarning -- base category for warnings about dubious syntactic features + + - RuntimeWarning -- base category for warnings about dubious + runtime features + + [XXX: Other warning categories may be proposed during the review + period for this PEP.] ! These standard warning categories are available from C as ! PyExc_Warning, PyExc_UserWarning, etc. From Python, they are ! available in the __builtin__ module, so no import is necessary. ! ! User code can define additional warning categories by subclassing ! one of the standard warning categories. A warning category must ! always be a subclass of the Warning class. *************** *** 128,132 **** - The data structures used to efficiently determine the ! disposition of a particular Py_Warn() call. - The API to control the filter from Python source code. --- 154,159 ---- - The data structures used to efficiently determine the ! disposition of a particular warnings.warn() or PyErr_Warn() ! call. - The API to control the filter from Python source code. *************** *** 140,144 **** First, the warning filter collects the module and line number where the warning is issued; this information is readily available ! through PyEval_GetFrame(). Conceptually, the warnings filter maintains an ordered list of --- 167,171 ---- First, the warning filter collects the module and line number where the warning is issued; this information is readily available ! through sys._getframe(). Conceptually, the warnings filter maintains an ordered list of *************** *** 153,160 **** the warning category must be a subclass in order to match ! - message is a regular expression that the warning message must ! match ! - module is a regular expression that the module name must match - lineno is an integer that the line number where the warning --- 180,188 ---- the warning category must be a subclass in order to match ! - message is a compiled regular expression that the warning ! message must match ! - module is a compiled regular expression that the module name ! must match - lineno is an integer that the line number where the warning *************** *** 178,213 **** warnings ! The Warning class is derived from the built-in Exception class, so ! that to turn a warning into an error we raise category(message). ! The Warnings Output Hook When the warnings filter decides to issue a warning (but not when it decides to raise an exception), it passes the information about ! the function sys.showwarning(message, category, filename, lineno). The default implementation of this function writes the warning text ! to sys.stderr, and shows the source line of the filename. API For Manipulating Warning Filters ! sys.filterwarnings(message, category, module, lineno, action) ! This checks the types of the arguments and inserts them as a tuple ! in front of the warnings filter. ! sys.resetwarnings() Reset the warnings filter to empty. - sys.setupwarnings(args) - Parse command line options and initialize the warnings filter - accordingly. The argument should be sys.argv[1:] or equivalent. - Unrecognized options raise getopt.error. The return value is a - list containing the remaining (non-option) arguments. - - Command Line Syntax --- 206,244 ---- warnings ! Since the Warning class is derived from the built-in Exception ! class, to turn a warning into an error we simply raise ! category(message). ! Warnings Output And Formatting Hooks When the warnings filter decides to issue a warning (but not when it decides to raise an exception), it passes the information about ! the function warnings.showwarning(message, category, filename, lineno). The default implementation of this function writes the warning text ! to sys.stderr, and shows the source line of the filename. It has ! an optional 5th argument which can be used to specify a different ! file than sys.stderr. ! ! The formatting of warnings is done by a separate function, ! warnings.formatwarning(message, category, filename, lineno). This ! returns a string (that may contain newlines and ends in a newline) ! that can be printed to get the identical effect of the ! showwarning() function. API For Manipulating Warning Filters ! warnings.filterwarnings(message, category, module, lineno, action) ! This checks the types of the arguments, compiles the message and ! module regular expressions, and inserts them as a tuple in front ! of the warnings filter. ! warnings.resetwarnings() Reset the warnings filter to empty. Command Line Syntax *************** *** 247,253 **** after stripping whitespace is the same as an omitted value. ! Each -W option results into a call to sys.filterwarnings(); thus ! later -W options override earlier -W options for warnings they ! both match. Examples: --- 278,287 ---- after stripping whitespace is the same as an omitted value. ! The C code that parses the Python command line saves the body of ! all -W options in a list of strings, which is made available to ! the warnings module as sys.warnoptions. The warnings module ! parses these when it is first imported. Errors detected during ! the parsing of sys.warnoptions are not fatal; a message is written ! to sys.stderr and processing continues with the option. Examples: *************** *** 281,315 **** Some open issues off the top of my head: - - - The proposal has all the Python API functions in the sys module, - except that the warning categories are in the warnings module. - Perhaps everything should be in the warnings module (like the - prototype implementation)? Or perhaps warn() should be promoted - to a built-in (i.e. in the __builtin__ module)? - - - It's tempting to leave the implementation in Python and add an - absolute minimal amount of C code, only to make the standard - warning categories available from C code. The Py_Warn() - function could call warnings.warn(). Similarly, the Python - main() function could collect -W options and pass them to - warnings.setupwarnings(). - - - The prototype implements a third argument to warn(): - - warn(message, category=UserWarning, level=1) - - The 'level' argument could be used by wrapper functions written - in Python, like this: - - def deprecation(message): - warn(message, DeprecationWarning, level=2) ! This makes the warning refer to the deprecation()'s caller, ! rather than to the source of deprecation() itself (the latter ! would defeat the purpose of the warning message). ! - The proposed command line syntax is ugly (although the simple ! cases aren't so bad: -Werror, -Wignore, etc.). Anybody got a ! better idea? - I'm a bit worried that the filter specifications are too --- 315,325 ---- Some open issues off the top of my head: ! - What about issuing warnings during lexing or parsing, which ! don't have the exception machinery available? ! - The proposed command line syntax is a bit ugly (although the ! simple cases aren't so bad: -Werror, -Wignore, etc.). Anybody ! got a better idea? - I'm a bit worried that the filter specifications are too *************** *** 322,327 **** - I'm not at all convinced that packages are handled right. ! - Better names for the various API functions? --- 332,372 ---- - I'm not at all convinced that packages are handled right. + + - Do we need more standard warning categories? Fewer? + + - In order to minimize the start-up overhead, the warnings module + is imported by the first call to PyErr_Warn(). It does the + command line parsing for -W options upon import. Therefore, it + is possible that warning-free programs will not complain about + invalid -W options. + + + Rejected Concerns + + Paul Prescod has brought up several additional concerns that I + feel aren't critical. I address them here (the concerns are + paraphrased, not necessarily exactly Paul's words). + + - Paul: warn() should be a built-in or a statement to make it easily + available. + + Response: "from warnings import warn" is easy enough. + + - Paul: What if I have a speed-critical module that triggers + warnings in an inner loop. It should be possible to disable the + overhead for detecting the warning (not just suppress the + warning). + + Response: rewrite the inner loop to avoid triggering the + warning. + + - Paul: What if I want to see the full context of a warning? + + Response: use -Werror to turn it into an exception. + + - Paul: I prefer ":*:*:" to ":::" for leaving parts of the warning + spec out. ! Response: I don't. From python-dev@python.org Mon Dec 11 16:50:13 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 11 Dec 2000 08:50:13 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0230.txt,1.4,1.5 Message-ID: <200012111650.IAA17535@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv17521 Modified Files: pep-0230.txt Log Message: Add responses to Barry's and Fred's concerns. Message matching is now case insensitive. Index: pep-0230.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0230.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** pep-0230.txt 2000/12/11 16:34:34 1.4 --- pep-0230.txt 2000/12/11 16:50:11 1.5 *************** *** 181,185 **** - message is a compiled regular expression that the warning ! message must match - module is a compiled regular expression that the module name --- 181,185 ---- - message is a compiled regular expression that the warning ! message must match (the match is case-insensitive) - module is a compiled regular expression that the module name *************** *** 265,269 **** - 'message' is a message string; matches warnings whose message text is an initial substring of 'message' (matching is ! case-sensitive) - 'category' is an abbreviation of a standard warning category --- 265,269 ---- - 'message' is a message string; matches warnings whose message text is an initial substring of 'message' (matching is ! case-insensitive) - 'category' is an abbreviation of a standard warning category *************** *** 344,350 **** Rejected Concerns ! Paul Prescod has brought up several additional concerns that I ! feel aren't critical. I address them here (the concerns are ! paraphrased, not necessarily exactly Paul's words). - Paul: warn() should be a built-in or a statement to make it easily --- 344,350 ---- Rejected Concerns ! Paul Prescod, Barry Warsaw and Fred Drake have brought up several ! additional concerns that I feel aren't critical. I address them ! here (the concerns are paraphrased, not exactly their words): - Paul: warn() should be a built-in or a statement to make it easily *************** *** 369,372 **** --- 369,391 ---- Response: I don't. + + - Barry: It would be nice if lineno can be a range specification. + + Response: Too much complexity already. + + - Barry: I'd like to add my own warning action. Maybe if `action' + could be a callable as well as a string. Then in my IDE, I + could set that to "mygui.popupWarningsDialog". + + Response: For that purpose you would override + warnings.showwarning(). + + - Fred: why do the Warning category classes have to be in + __builtin__? + + Response: that's the simplest implementation, given that the + warning categories must be available in C before the first + PyErr_Warn() call, which imports the warnings module. I see no + problem with making them available as built-ins. From python-dev@python.org Mon Dec 11 18:13:23 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 11 Dec 2000 10:13:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib ConfigParser.py,1.24,1.25 Message-ID: <200012111813.KAA28012@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv27989 Modified Files: ConfigParser.py Log Message: Make ConfigParser.Error inherit from Exception. Index: ConfigParser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ConfigParser.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** ConfigParser.py 2000/12/04 16:29:13 1.24 --- ConfigParser.py 2000/12/11 18:13:19 1.25 *************** *** 97,105 **** # exception classes ! class Error: def __init__(self, msg=''): self._msg = msg def __repr__(self): return self._msg class NoSectionError(Error): --- 97,107 ---- # exception classes ! class Error(Exception): def __init__(self, msg=''): self._msg = msg + Exception.__init__(self, msg) def __repr__(self): return self._msg + __str__ = __repr__ class NoSectionError(Error): From python-dev@python.org Mon Dec 11 20:01:59 2000 From: python-dev@python.org (Barry Warsaw) Date: Mon, 11 Dec 2000 12:01:59 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python getargs.c,2.50,2.51 Message-ID: <200012112001.MAA09260@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv9239 Modified Files: getargs.c Log Message: vgetargskeywords(): Patch for memory leak identified in bug #119862. Index: getargs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v retrieving revision 2.50 retrieving revision 2.51 diff -C2 -r2.50 -r2.51 *** getargs.c 2000/12/01 12:59:05 2.50 --- getargs.c 2000/12/11 20:01:55 2.51 *************** *** 1124,1127 **** --- 1124,1128 ---- } converted++; + Py_DECREF(item); } else { From python-dev@python.org Mon Dec 11 20:32:23 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 11 Dec 2000 12:32:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib httplib.py,1.24,1.25 Message-ID: <200012112032.MAA12901@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv12882 Modified Files: httplib.py Log Message: Hoepeful fix for SF bug #123924: Windows - using OpenSSL, problem with socket in httplib.py. The bug reports that on Windows, you must pass sock._sock to the socket.ssl() call. But on Unix, you must pass sock itself. (sock is a wrapper on Windows but not on Unix; the ssl() call wants the real socket object, not the wrapper.) So we see if sock has an _sock attribute and if so, extract it. Unfortunately, the submitter of the bug didn't confirm that this patch works, so I'll just have to believe it (can't test it myself since I don't have OpenSSL on Windows set up, and that's a nontrivial thing I believe). Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** httplib.py 2000/10/12 19:58:36 1.24 --- httplib.py 2000/12/11 20:32:20 1.25 *************** *** 614,618 **** sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((self.host, self.port)) ! ssl = socket.ssl(sock, self.key_file, self.cert_file) self.sock = FakeSocket(sock, ssl) --- 614,621 ---- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((self.host, self.port)) ! realsock = sock ! if hasattr(sock, "_sock"): ! realsock = sock._sock ! ssl = socket.ssl(realsock, self.key_file, self.cert_file) self.sock = FakeSocket(sock, ssl) From python-dev@python.org Mon Dec 11 20:33:55 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 11 Dec 2000 12:33:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib dumbdbm.py,1.5,1.6 Message-ID: <200012112033.MAA13052@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv13042 Modified Files: dumbdbm.py Log Message: Apply rstrip() to the lines read from _dirfile in _update(), so that a dumbdbm archive created on Windows can be read on Unix. Index: dumbdbm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dumbdbm.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** dumbdbm.py 2000/07/10 13:56:35 1.5 --- dumbdbm.py 2000/12/11 20:33:52 1.6 *************** *** 53,57 **** else: while 1: ! line = f.readline() if not line: break key, (pos, siz) = eval(line) --- 53,57 ---- else: while 1: ! line = f.readline().rstrip() if not line: break key, (pos, siz) = eval(line) From python-dev@python.org Mon Dec 11 20:57:17 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 11 Dec 2000 12:57:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libarray.tex,1.27,1.28 Message-ID: <200012112057.MAA16774@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv16764/lib Modified Files: libarray.tex Log Message: Added link to HTML version of the NumPy documentation. This closes bug #124943. Index: libarray.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libarray.tex,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** libarray.tex 2000/10/18 17:43:06 1.27 --- libarray.tex 2000/12/11 20:57:13 1.28 *************** *** 190,197 **** Representation (XDR) data as used in some remote procedure call systems.} ! \seetitle[http://numpy.sourceforge.net/numdoc/numdoc.pdf]{The Numerical Python Manual}{The Numeric Python extension (NumPy) defines another array type; see \url{http://numpy.sourceforge.net/} for further information ! about Numerical Python.} \end{seealso} --- 190,199 ---- Representation (XDR) data as used in some remote procedure call systems.} ! \seetitle[http://numpy.sourceforge.net/numdoc/HTML/numdoc.html]{The Numerical Python Manual}{The Numeric Python extension (NumPy) defines another array type; see \url{http://numpy.sourceforge.net/} for further information ! about Numerical Python. (A PDF version of the NumPy manual ! is available at ! \url{http://numpy.sourceforge.net/numdoc/numdoc.pdf}.} \end{seealso} From python-dev@python.org Mon Dec 11 22:12:12 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 11 Dec 2000 14:12:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_parser,1.2,1.3 Message-ID: <200012112212.OAA25590@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv25558/Lib/test/output Modified Files: test_parser Log Message: Added tests to avoid regression on bug #125375. roundtrip(): Show the offending syntax tree when things break; this makes it a little easier to debug the module by adding test cases. (Still need better tests for this module, but there's not enough time today.) Index: test_parser =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_parser,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_parser 2000/08/25 22:42:40 1.2 --- test_parser 2000/12/11 22:12:09 1.3 *************** *** 16,19 **** --- 16,31 ---- expr: foo(a, b, c, **kw) expr: foo + bar + expr: lambda: 0 + expr: lambda x: 0 + expr: lambda *y: 0 + expr: lambda *y, **z: 0 + expr: lambda **z: 0 + expr: lambda x, y: 0 + expr: lambda foo=bar: 0 + expr: lambda foo=bar, spaz=nifty+spit: 0 + expr: lambda foo=bar, **z: 0 + expr: lambda foo=bar, blaz=blat+2, **z: 0 + expr: lambda foo=bar, blaz=blat+2, *y, **z: 0 + expr: lambda x, *y, **z: 0 Statements: *************** *** 38,41 **** --- 50,55 ---- suite: a >>= b suite: a **= b + suite: def f(): pass + suite: def f(foo=bar): pass Invalid parse trees: From python-dev@python.org Mon Dec 11 22:12:12 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 11 Dec 2000 14:12:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_parser.py,1.2,1.3 Message-ID: <200012112212.OAA25589@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv25558/Lib/test Modified Files: test_parser.py Log Message: Added tests to avoid regression on bug #125375. roundtrip(): Show the offending syntax tree when things break; this makes it a little easier to debug the module by adding test cases. (Still need better tests for this module, but there's not enough time today.) Index: test_parser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_parser.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_parser.py 2000/08/25 22:42:40 1.2 --- test_parser.py 2000/12/11 22:12:09 1.3 *************** *** 16,20 **** st1 = f(s) t = st1.totuple() ! st2 = parser.sequence2ast(t) def roundtrip_fromfile(filename): --- 16,25 ---- st1 = f(s) t = st1.totuple() ! try: ! st2 = parser.sequence2ast(t) ! except parser.ParserError: ! print "Failing syntax tree:" ! pprint.pprint(t) ! raise def roundtrip_fromfile(filename): *************** *** 47,50 **** --- 52,67 ---- test_expr("foo(a, b, c, **kw)") test_expr("foo + bar") + test_expr("lambda: 0") + test_expr("lambda x: 0") + test_expr("lambda *y: 0") + test_expr("lambda *y, **z: 0") + test_expr("lambda **z: 0") + test_expr("lambda x, y: 0") + test_expr("lambda foo=bar: 0") + test_expr("lambda foo=bar, spaz=nifty+spit: 0") + test_expr("lambda foo=bar, **z: 0") + test_expr("lambda foo=bar, blaz=blat+2, **z: 0") + test_expr("lambda foo=bar, blaz=blat+2, *y, **z: 0") + test_expr("lambda x, *y, **z: 0") print *************** *** 72,75 **** --- 89,94 ---- test_suite("a >>= b") test_suite("a **= b") + test_suite("def f(): pass") + test_suite("def f(foo=bar): pass") #d = os.path.dirname(os.__file__) From python-dev@python.org Mon Dec 11 22:29:26 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 11 Dec 2000 14:29:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom __init__.py,1.1,1.2 Message-ID: <200012112229.OAA27333@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory slayer.i.sourceforge.net:/tmp/cvs-serv27311 Modified Files: __init__.py Log Message: Update the docstring. Add a Node class that defines the NodeType constants, based on discussion in the XML-SIG. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/__init__.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** __init__.py 2000/06/29 19:28:01 1.1 --- __init__.py 2000/12/11 22:29:23 1.2 *************** *** 1,10 **** """W3C Document Object Model implementation for Python. ! The Python mapping of the Document Object Model is documented in <...>. This package contains the following modules: minidom -- A simple implementation of the Level 1 DOM with namespace ! support added (based on the Level 2 specification). """ --- 1,39 ---- """W3C Document Object Model implementation for Python. ! The Python mapping of the Document Object Model is documented in the ! Python Library Reference in the section on the xml.dom package. This package contains the following modules: minidom -- A simple implementation of the Level 1 DOM with namespace ! support added (based on the Level 2 specification) and other ! minor Level 2 functionality. + pulldom -- DOM builder supporting on-demand tree-building for selected + subtrees of the document. + """ + + + class Node: + """Class giving the NodeType constants.""" + + # DOM implementations may use this as a base class for their own + # Node implementations. If they don't, the constants defined here + # should still be used as the canonical definitions as they match + # the values given in the W3C recommendation. Client code can + # safely refer to these values in all tests of Node.nodeType + # values. + + ELEMENT_NODE = 1 + ATTRIBUTE_NODE = 2 + TEXT_NODE = 3 + CDATA_SECTION_NODE = 4 + ENTITY_REFERENCE_NODE = 5 + ENTITY_NODE = 6 + PROCESSING_INSTRUCTION_NODE = 7 + COMMENT_NODE = 8 + DOCUMENT_NODE = 9 + DOCUMENT_TYPE_NODE = 10 + DOCUMENT_FRAGMENT_NODE = 11 + NOTATION_NODE = 12 From python-dev@python.org Mon Dec 11 22:39:28 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 11 Dec 2000 14:39:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref5.tex,1.39,1.40 Message-ID: <200012112239.OAA28726@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/ref In directory slayer.i.sourceforge.net:/tmp/cvs-serv28715/ref Modified Files: ref5.tex Log Message: Adjust explanation of operator precedence summary -- exponentiation groups from right to left! Closes bug #125391. Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -r1.39 -r1.40 *** ref5.tex 2000/12/07 04:54:02 1.39 --- ref5.tex 2000/12/11 22:39:24 1.40 *************** *** 900,904 **** is explicitly given, operators are binary. Operators in the same box group left to right (except for comparisons, which chain from left to ! right --- see above). \begin{tableii}{c|l}{textrm}{Operator}{Description} --- 900,905 ---- is explicitly given, operators are binary. Operators in the same box group left to right (except for comparisons, which chain from left to ! right --- see above, and exponentiation, which groups from right to ! left). \begin{tableii}{c|l}{textrm}{Operator}{Description} From python-dev@python.org Mon Dec 11 23:08:15 2000 From: python-dev@python.org (Thomas Wouters) Date: Mon, 11 Dec 2000 15:08:15 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.56,1.57 pep-0206.txt,1.9,1.10 pep-0216.txt,1.7,1.8 Message-ID: <200012112308.PAA31630@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv31550 Modified Files: pep-0000.txt pep-0206.txt pep-0216.txt Log Message: Update Moshe's email address to the one that won't stop working soon, and also test CVS write access on this new installation. Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -r1.56 -r1.57 *** pep-0000.txt 2000/12/08 15:05:09 1.56 --- pep-0000.txt 2000/12/11 23:08:11 1.57 *************** *** 161,165 **** Wouters, Thomas thomas@xs4all.net Yee, Ka-Ping ping@lfw.org ! Zadka, Moshe moshez@math.huji.ac.il Zhu, Huaiyu hzhu@users.sourceforge.net --- 161,165 ---- Wouters, Thomas thomas@xs4all.net Yee, Ka-Ping ping@lfw.org ! Zadka, Moshe moshez@zadka.site.co.il Zhu, Huaiyu hzhu@users.sourceforge.net Index: pep-0206.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0206.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** pep-0206.txt 2000/11/28 22:23:25 1.9 --- pep-0206.txt 2000/12/11 23:08:11 1.10 *************** *** 2,6 **** Title: 2.0 Batteries Included Version: $Revision$ ! Author: moshez@math.huji.ac.il (Moshe Zadka) Python-Version: 2.0 Status: Draft --- 2,6 ---- Title: 2.0 Batteries Included Version: $Revision$ ! Author: moshez@zadka.site.co.il (Moshe Zadka) Python-Version: 2.0 Status: Draft Index: pep-0216.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0216.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** pep-0216.txt 2000/11/10 17:00:05 1.7 --- pep-0216.txt 2000/12/11 23:08:11 1.8 *************** *** 2,6 **** Title: Docstring Format Version: $Revision$ ! Author: moshez@math.huji.ac.il (Moshe Zadka) Status: Draft Type: Informational --- 2,6 ---- Title: Docstring Format Version: $Revision$ ! Author: moshez@zadka.site.co.il (Moshe Zadka) Status: Draft Type: Informational From python-dev@python.org Mon Dec 11 23:11:56 2000 From: python-dev@python.org (Thomas Wouters) Date: Mon, 11 Dec 2000 15:11:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref3.tex,1.53,1.54 Message-ID: <200012112311.PAA32105@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/ref In directory slayer.i.sourceforge.net:/tmp/cvs-serv31968 Modified Files: ref3.tex Log Message: Additional docs for __iadd__ and family, closing SF bug #117178 and SF patch #102169. Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -r1.53 -r1.54 *** ref3.tex 2000/12/07 04:49:34 1.53 --- ref3.tex 2000/12/11 23:11:51 1.54 *************** *** 1294,1297 **** --- 1294,1323 ---- \end{methoddesc} + \begin{methoddesc}[numeric object]{__iadd__}{self, other} + \methodline[numeric object]{__isub__}{self, other} + \methodline[numeric object]{__imul__}{self, other} + \methodline[numeric object]{__idiv__}{self, other} + \methodline[numeric object]{__imod__}{self, other} + \methodline[numeric object]{__ipow__}{self, other\optional{, modulo}} + \methodline[numeric object]{__ilshift__}{self, other} + \methodline[numeric object]{__irshift__}{self, other} + \methodline[numeric object]{__iand__}{self, other} + \methodline[numeric object]{__ixor__}{self, other} + \methodline[numeric object]{__ior__}{self, other} + These methods are called to implement the augmented arithmetic operations + (\code{+=}, \code{-=}, \code{*=}, \code{/=}, \code{\%=}, \code{**=}, + \code{<<=}, \code{>>=}, \code{\&=}, \code{\^=}, \code{|=}). These methods + should attempt to do the operation in-place (modifying \var{self}) and + return the result (which could be, but does not have to be, \var{self}). If + a specific method is not defined, the augmented operation falls back to the + normal methods. For instance, to evaluate the expression + \var{x}\code{+=}\var{y}, where \var{x} is an instance of a class that has an + \method{__iadd__()} method, \code{\var{x}.__iadd__(\var{y})} is called. If + \var{x} is an instance of a class that does not define a \method{__iadd()} + method, \code{\var{x}.__add__(\var{y})} and \code{\var{y}.__radd__(\var{x})} + are considered, as with the evaluation of \var{x}\code{+}\var{y}. + + \end{methoddesc} + \begin{methoddesc}[numeric object]{__neg__}{self} \methodline[numeric object]{__pos__}{self} From python-dev@python.org Tue Dec 12 00:38:01 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 11 Dec 2000 16:38:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.178,2.179 Message-ID: <200012120038.QAA09946@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv9929 Modified Files: posixmodule.c Log Message: Trivial typo fix, submitted by Charles Waldman (SF patch #102794). Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.178 retrieving revision 2.179 diff -C2 -r2.178 -r2.179 *** posixmodule.c 2000/12/06 21:45:33 2.178 --- posixmodule.c 2000/12/12 00:37:58 2.179 *************** *** 2967,2971 **** static char posix_waitpid__doc__[] = "waitpid(pid, options) -> (pid, status)\n\ ! Wait for completion of a give child process."; static PyObject * --- 2967,2971 ---- static char posix_waitpid__doc__[] = "waitpid(pid, options) -> (pid, status)\n\ ! Wait for completion of a given child process."; static PyObject * From python-dev@python.org Tue Dec 12 01:18:43 2000 From: python-dev@python.org (Tim Peters) Date: Mon, 11 Dec 2000 17:18:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules selectmodule.c,2.48,2.49 Message-ID: <200012120118.RAA14117@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv14057/python/dist/src/Modules Modified Files: selectmodule.c Log Message: SF bug 110843: Low FD_SETSIZE limit on Win32 (PR#41). Boosted to 512. Index: selectmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/selectmodule.c,v retrieving revision 2.48 retrieving revision 2.49 diff -C2 -r2.48 -r2.49 *** selectmodule.c 2000/09/28 21:33:44 2.48 --- selectmodule.c 2000/12/12 01:18:41 2.49 *************** *** 1,3 **** - /* select - Module containing unix select(2) call. Under Unix, the file descriptors are small integers. --- 1,2 ---- *************** *** 9,12 **** --- 8,21 ---- #include "Python.h" + + /* Windows #defines FD_SETSIZE to 64 if FD_SETSIZE isn't already defined. + 64 is too small (too many people have bumped into that limit). + Here we boost it. + Users who want even more than the boosted limit should #define + FD_SETSIZE higher before this; e.g., via compiler /D switch. + */ + #if defined(MS_WINDOWS) && !defined(FD_SETSIZE) + #define FD_SETSIZE 512 + #endif #ifdef HAVE_UNISTD_H From python-dev@python.org Tue Dec 12 01:18:43 2000 From: python-dev@python.org (Tim Peters) Date: Mon, 11 Dec 2000 17:18:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.83,1.84 Message-ID: <200012120118.RAA14113@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv14057/python/dist/src/Misc Modified Files: NEWS Log Message: SF bug 110843: Low FD_SETSIZE limit on Win32 (PR#41). Boosted to 512. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -r1.83 -r1.84 *** NEWS 2000/12/01 07:59:35 1.83 --- NEWS 2000/12/12 01:18:39 1.84 *************** *** 28,31 **** --- 28,39 ---- via %u raised an error if it was too big to fit in an int. + Windows changes + + - select module: By default under Windows, a select() call + can specify no more than 64 sockets. Python now boosts + this Microsoft default to 512. If you need even more than + that, see the MS docs (you'll need to #define FD_SETSIZE + and recompile Python from source). + What's New in Python 2.0? From python-dev@python.org Tue Dec 12 01:58:59 2000 From: python-dev@python.org (Tim Peters) Date: Mon, 11 Dec 2000 17:58:59 -0800 Subject: [Python-checkins] CVS: python/dist/src/PC msvcrtmodule.c,1.5,1.6 Message-ID: <200012120158.RAA17281@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv17191/python/dist/src/pc Modified Files: msvcrtmodule.c Log Message: Partial fix for SF bug 122780 (msvcrt.locking constants aren't defined). Still needs docs; see bug report (which was reassigned to Fred) for MS's docs. Index: msvcrtmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/msvcrtmodule.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** msvcrtmodule.c 2000/06/30 17:48:51 1.5 --- msvcrtmodule.c 2000/12/12 01:58:56 1.6 *************** *** 19,26 **** #include "Python.h" #include "malloc.h" // Force the malloc heap to clean itself up, and free unused blocks // back to the OS. (According to the docs, only works on NT.) ! static PyObject *msvcrt_heapmin(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, ":heapmin")) --- 19,30 ---- #include "Python.h" #include "malloc.h" + #include + #include + #include // Force the malloc heap to clean itself up, and free unused blocks // back to the OS. (According to the docs, only works on NT.) ! static PyObject * ! msvcrt_heapmin(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, ":heapmin")) *************** *** 35,39 **** // Perform locking operations on a C runtime file descriptor. ! static PyObject *msvcrt_locking(PyObject *self, PyObject *args) { int fd; --- 39,44 ---- // Perform locking operations on a C runtime file descriptor. ! static PyObject * ! msvcrt_locking(PyObject *self, PyObject *args) { int fd; *************** *** 56,60 **** // Set the file translation mode for a C runtime file descriptor. ! static PyObject *msvcrt_setmode(PyObject *self, PyObject *args) { int fd; --- 61,66 ---- // Set the file translation mode for a C runtime file descriptor. ! static PyObject * ! msvcrt_setmode(PyObject *self, PyObject *args) { int fd; *************** *** 71,75 **** // Convert an OS file handle to a C runtime file descriptor. ! static PyObject *msvcrt_open_osfhandle(PyObject *self, PyObject *args) { long handle; --- 77,82 ---- // Convert an OS file handle to a C runtime file descriptor. ! static PyObject * ! msvcrt_open_osfhandle(PyObject *self, PyObject *args) { long handle; *************** *** 88,92 **** // Convert a C runtime file descriptor to an OS file handle. ! static PyObject *msvcrt_get_osfhandle(PyObject *self, PyObject *args) { int fd; --- 95,100 ---- // Convert a C runtime file descriptor to an OS file handle. ! static PyObject * ! msvcrt_get_osfhandle(PyObject *self, PyObject *args) { int fd; *************** *** 107,113 **** /* Console I/O */ - #include ! static PyObject *msvcrt_kbhit(PyObject *self, PyObject *args) { int ok; --- 115,121 ---- /* Console I/O */ ! static PyObject * ! msvcrt_kbhit(PyObject *self, PyObject *args) { int ok; *************** *** 120,124 **** } ! static PyObject *msvcrt_getch(PyObject *self, PyObject *args) { int ch; --- 128,133 ---- } ! static PyObject * ! msvcrt_getch(PyObject *self, PyObject *args) { int ch; *************** *** 135,139 **** } ! static PyObject *msvcrt_getche(PyObject *self, PyObject *args) { int ch; --- 144,149 ---- } ! static PyObject * ! msvcrt_getche(PyObject *self, PyObject *args) { int ch; *************** *** 150,154 **** } ! static PyObject *msvcrt_putch(PyObject *self, PyObject *args) { char ch; --- 160,165 ---- } ! static PyObject * ! msvcrt_putch(PyObject *self, PyObject *args) { char ch; *************** *** 162,166 **** } ! static PyObject *msvcrt_ungetch(PyObject *self, PyObject *args) { char ch; --- 173,178 ---- } ! static PyObject * ! msvcrt_ungetch(PyObject *self, PyObject *args) { char ch; *************** *** 176,179 **** --- 188,206 ---- + static void + insertint(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); + } + } + + /* List of functions exported by this module */ static struct PyMethodDef msvcrt_functions[] = { *************** *** 194,197 **** initmsvcrt(void) { ! Py_InitModule("msvcrt", msvcrt_functions); } --- 221,232 ---- initmsvcrt(void) { ! PyObject *m = Py_InitModule("msvcrt", msvcrt_functions); ! PyObject *d = PyModule_GetDict(m); ! ! /* constants for the locking() function's mode argument */ ! insertint(d, "LK_LOCK", _LK_LOCK); ! insertint(d, "LK_NBLCK", _LK_NBLCK); ! insertint(d, "LK_NBRLCK", _LK_NBRLCK); ! insertint(d, "LK_RLCK", _LK_RLCK); ! insertint(d, "LK_UNLCK", _LK_UNLCK); } From python-dev@python.org Tue Dec 12 02:00:40 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 11 Dec 2000 18:00:40 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0208.txt,1.6,1.7 Message-ID: <200012120200.SAA17448@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv17440 Modified Files: pep-0208.txt Log Message: Some stupid mechanical changes, such as remove trailing whitespace, double spaces between sentences. Also fix a few typos, add an XXX note, and change the URL for the implementation to be the patch detail page instead of the download page. I hope Neil doesn't mind. Index: pep-0208.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0208.txt,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** pep-0208.txt 2000/12/06 21:22:52 1.6 --- pep-0208.txt 2000/12/12 02:00:37 1.7 *************** *** 21,58 **** set the type flag are handled in a backwards compatible manner. Allowing operations handle different types is often simpler, more ! flexible, and faster then having the interpreter do coercion. ! Rational When implementing numeric or other related operations, it is often desirable to provide not only operations between operands of one type only, e.g. integer + integer, but to generalize the idea behind the ! operation to other type combinations as well, e.g. integer + float. A common approach to this mixed type situation is to provide a method of "lifting" the operands to a common type (coercion) and then use ! that type's operand method as execution mechanism. Yet, this strategy ! has a few drawbacks: * the "lifting" process creates at least one new (temporary) ! operand object, * since the coercion method is not being told about the operation that is to follow, it is not possible to implement operation ! specific coercion of types, * there is no elegant way to solve situations were a common type ! is not at hand, and * the coercion method will always have to be called prior to the ! operation's method itself. A fix for this situation is obviously needed, since these drawbacks make implementations of types needing these features very cumbersome, ! if not impossible. As an example, have a look at the DateTime and DateTimeDelta[1] types, the first being absolute, the second relative. You can always add a relative value to an absolute one, ! giving a new absolute value. Yet, there is no common type which the existing coercion mechanism could use to implement that operation. --- 21,58 ---- set the type flag are handled in a backwards compatible manner. Allowing operations handle different types is often simpler, more ! flexible, and faster than having the interpreter do coercion. ! Rationale When implementing numeric or other related operations, it is often desirable to provide not only operations between operands of one type only, e.g. integer + integer, but to generalize the idea behind the ! operation to other type combinations as well, e.g. integer + float. A common approach to this mixed type situation is to provide a method of "lifting" the operands to a common type (coercion) and then use ! that type's operand method as execution mechanism. Yet, this strategy ! has a few drawbacks: * the "lifting" process creates at least one new (temporary) ! operand object, * since the coercion method is not being told about the operation that is to follow, it is not possible to implement operation ! specific coercion of types, * there is no elegant way to solve situations were a common type ! is not at hand, and * the coercion method will always have to be called prior to the ! operation's method itself. A fix for this situation is obviously needed, since these drawbacks make implementations of types needing these features very cumbersome, ! if not impossible. As an example, have a look at the DateTime and DateTimeDelta[1] types, the first being absolute, the second relative. You can always add a relative value to an absolute one, ! giving a new absolute value. Yet, there is no common type which the existing coercion mechanism could use to implement that operation. *************** *** 67,73 **** Instead of using a central coercion method, the process of handling ! different operand types is simply left to the operation. If the operation finds that it cannot handle the given operand type ! combination, it may return a special singleton as indicator. Note that "numbers" (anything that implements the number protocol, or --- 67,73 ---- Instead of using a central coercion method, the process of handling ! different operand types is simply left to the operation. If the operation finds that it cannot handle the given operand type ! combination, it may return a special singleton as indicator. Note that "numbers" (anything that implements the number protocol, or *************** *** 78,84 **** careful to make numbers that don't know anything about the new strategy (old style numbers) work just as well as those that expect ! the new scheme (new style numbers). Furthermore, binary compatibility is a must, meaning that the interpreter may only access and use new ! style operations if the number indicates the availability of these. A new style number is considered by the interpreter as such if and --- 78,84 ---- careful to make numbers that don't know anything about the new strategy (old style numbers) work just as well as those that expect ! the new scheme (new style numbers). Furthermore, binary compatibility is a must, meaning that the interpreter may only access and use new ! style operations if the number indicates the availability of these. A new style number is considered by the interpreter as such if and *************** *** 86,118 **** difference between an old style number and a new style one is that the numeric slot functions can no longer assume to be passed arguments of ! identical type. New style slots must check all arguments for proper ! type and implement the necessary conversions themselves. This may seem to cause more work on the behalf of the type implementor, but is in fact no more difficult than writing the same kind of routines for an ! old style coercion slot. If a new style slot finds that it cannot handle the passed argument type combination, it may return a new reference of the special ! singleton Py_NotImplemented to the caller. This will cause the caller to try the other operands operation slots until it finds a slot that ! does implement the operation for the specific type combination. If ! none of the possible slots succeed, it raises a TypeError. To make the implementation easy to understand (the whole topic is esoteric enough), a new layer in the handling of numeric operations is ! introduced. This layer takes care of all the different cases that need to be taken into account when dealing with all the possible ! combinations of old and new style numbers. It is implemented by the ! two functions _PyNumber_BinaryOperation() and ! _PyNumber_TernaryOperation(), which both are internal functions that ! only the functions in Objects/abstract.c have access to. The numeric ! API (PyNumber_*) is easy to adapt to this new layer. As a side-effect all numeric slots can be NULL-checked (this has to be done anyway, so the added feature comes at no extra cost). ! The scheme used by the layer to execute a binary operation is as ! follows: v | w | Action taken --- 86,118 ---- difference between an old style number and a new style one is that the numeric slot functions can no longer assume to be passed arguments of ! identical type. New style slots must check all arguments for proper ! type and implement the necessary conversions themselves. This may seem to cause more work on the behalf of the type implementor, but is in fact no more difficult than writing the same kind of routines for an ! old style coercion slot. If a new style slot finds that it cannot handle the passed argument type combination, it may return a new reference of the special ! singleton Py_NotImplemented to the caller. This will cause the caller to try the other operands operation slots until it finds a slot that ! does implement the operation for the specific type combination. If ! none of the possible slots succeed, it raises a TypeError. To make the implementation easy to understand (the whole topic is esoteric enough), a new layer in the handling of numeric operations is ! introduced. This layer takes care of all the different cases that need to be taken into account when dealing with all the possible ! combinations of old and new style numbers. It is implemented by the ! two static functions binary_op() and ternary_op(), which are both ! internal functions that only the functions in Objects/abstract.c ! have access to. The numeric API (PyNumber_*) is easy to adapt to ! this new layer. As a side-effect all numeric slots can be NULL-checked (this has to be done anyway, so the added feature comes at no extra cost). ! The scheme used by the layer to execute a binary operation is as ! follows: v | w | Action taken *************** *** 125,137 **** The indicated action sequence is executed from left to right until either the operation succeeds and a valid result (!= ! Py_NotImplemented) is returned or an exception is raised. Exceptions ! are returned to the calling function as-is. If a slot returns ! Py_NotImplemented, the next item in the sequence is executed. Note that coerce(v,w) will use the old style nb_coerce slot methods ! via a call to PyNumber_Coerce(). - Ternary operations have a few more cases to handle: - v | w | z | Action taken ----+-----+-----+------------------------------------ --- 125,137 ---- The indicated action sequence is executed from left to right until either the operation succeeds and a valid result (!= ! Py_NotImplemented) is returned or an exception is raised. Exceptions ! are returned to the calling function as-is. If a slot returns ! Py_NotImplemented, the next item in the sequence is executed. Note that coerce(v,w) will use the old style nb_coerce slot methods ! via a call to PyNumber_Coerce(). ! ! Ternary operations have a few more cases to handle: v | w | z | Action taken ----+-----+-----+------------------------------------ *************** *** 144,198 **** old | new | old | w.op(v,w,z), coerce(v,w,z), v.op(v,w,z) old | old | old | coerce(v,w,z), v.op(v,w,z) ! The same notes as above, except that coerce(v,w,z) actually does: - if z != Py_None: - coerce(v,w), coerce(v,z), coerce(w,z) - else: - # treat z as absent variable - coerce(v,w) - The current implementation uses this scheme already (there's only one ! ternary slot: nb_pow(a,b,c)). Note that the numeric protocol is also used for some other related tasks, e.g. sequence concatenation. These can also benefit from the new mechanism by implementing right-hand operations for type ! combinations that would otherwise fail to work. As an example, take ! string concatenation: currently you can only do string + string. With the new mechanism, a new string-like type could implement new_type + string and string + new_type, even though strings don't know anything ! about new_type. Since comparisons also rely on coercion (every time you compare an integer to a float, the integer is first converted to float and then ! compared...), a new slot to handle numeric comparisons is needed: ! PyObject *nb_cmp(PyObject *v, PyObject *w) This slot should compare the two objects and return an integer object ! stating the result. Currently, this result integer may only be -1, 0, 1. If the slot cannot handle the type combination, it may return a ! reference to Py_NotImplemented. Note that this slot is still in flux ! since it should take into account rich comparisons (ie. PEP 207). ! Numeric comparisons are handled by a new numeric protocol API: ! PyObject *PyNumber_Compare(PyObject *v, PyObject *w) This function compare the two objects as "numbers" and return an ! integer object stating the result. Currently, this result integer may ! only be -1, 0, 1. In case the operation cannot be handled by the given ! objects, a TypeError is raised. The PyObject_Compare() API needs to adjusted accordingly to make use ! of this new API. Other changes include adapting some of the built-in functions (e.g. ! cmp()) to use this API as well. Also, PyNumber_CoerceEx() will need to ! check for new style numbers before calling the nb_coerce slot. New style numbers don't provide a coercion slot and thus cannot be ! explicitly coerced. --- 144,199 ---- old | new | old | w.op(v,w,z), coerce(v,w,z), v.op(v,w,z) old | old | old | coerce(v,w,z), v.op(v,w,z) + + The same notes as above, except that coerce(v,w,z) actually does: ! if z != Py_None: ! coerce(v,w), coerce(v,z), coerce(w,z) ! else: ! # treat z as absent variable ! coerce(v,w) The current implementation uses this scheme already (there's only one ! ternary slot: nb_pow(a,b,c)). Note that the numeric protocol is also used for some other related tasks, e.g. sequence concatenation. These can also benefit from the new mechanism by implementing right-hand operations for type ! combinations that would otherwise fail to work. As an example, take ! string concatenation: currently you can only do string + string. With the new mechanism, a new string-like type could implement new_type + string and string + new_type, even though strings don't know anything ! about new_type. Since comparisons also rely on coercion (every time you compare an integer to a float, the integer is first converted to float and then ! compared...), a new slot to handle numeric comparisons is needed: ! PyObject *nb_cmp(PyObject *v, PyObject *w) This slot should compare the two objects and return an integer object ! stating the result. Currently, this result integer may only be -1, 0, 1. If the slot cannot handle the type combination, it may return a ! reference to Py_NotImplemented. [XXX Note that this slot is still ! in flux since it should take into account rich comparisons ! (i.e. PEP 207).] ! Numeric comparisons are handled by a new numeric protocol API: ! PyObject *PyNumber_Compare(PyObject *v, PyObject *w) This function compare the two objects as "numbers" and return an ! integer object stating the result. Currently, this result integer may ! only be -1, 0, 1. In case the operation cannot be handled by the given ! objects, a TypeError is raised. The PyObject_Compare() API needs to adjusted accordingly to make use ! of this new API. Other changes include adapting some of the built-in functions (e.g. ! cmp()) to use this API as well. Also, PyNumber_CoerceEx() will need to ! check for new style numbers before calling the nb_coerce slot. New style numbers don't provide a coercion slot and thus cannot be ! explicitly coerced. *************** *** 217,221 **** [1] http://www.lemburg.com/files/python/mxDateTime.html ! [2] http://sourceforge.net/patch/download.php?id=102652 [3] http://www.lemburg.com/files/python/CoercionProposal.html --- 218,222 ---- [1] http://www.lemburg.com/files/python/mxDateTime.html ! [2] http://sourceforge.net/patch/?func=detailpatch&patch_id=102652&group_id=5470 [3] http://www.lemburg.com/files/python/CoercionProposal.html From python-dev@python.org Tue Dec 12 14:45:37 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Tue, 12 Dec 2000 06:45:37 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/encodings __init__.py,1.4,1.5 Message-ID: <200012121445.GAA25260@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/encodings In directory slayer.i.sourceforge.net:/tmp/cvs-serv25240 Modified Files: __init__.py Log Message: Changed .getaliases() support to register the new aliases in the encodings package aliases mapping dictionary rather than in the internal cache used by the search function. This enables aliases to take advantage of the full normalization process applied to encoding names which was previously not available. The patch restricts alias registration to new aliases. Existing aliases cannot be overridden anymore. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/__init__.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** __init__.py 2000/06/13 12:04:05 1.4 --- __init__.py 2000/12/12 14:45:35 1.5 *************** *** 19,25 **** * getaliases() -> sequence of encoding name strings to use as aliases ! Alias names returned by getaliases() must be lower-case. - Written by Marc-Andre Lemburg (mal@lemburg.com). --- 19,26 ---- * getaliases() -> sequence of encoding name strings to use as aliases ! Alias names returned by getaliases() must be standard encoding ! names as defined above (lower-case, hyphens converted to ! underscores). Written by Marc-Andre Lemburg (mal@lemburg.com). *************** *** 46,49 **** --- 47,51 ---- mod = __import__(modname,globals(),locals(),'*') except ImportError,why: + # cache misses _cache[encoding] = None return None *************** *** 64,69 **** (__name__,modname) ! # Cache the encoding and its aliases _cache[encoding] = entry try: codecaliases = mod.getaliases() --- 66,74 ---- (__name__,modname) ! # Cache the codec registry entry _cache[encoding] = entry + + # Register its aliases (without overwriting previously registered + # aliases) try: codecaliases = mod.getaliases() *************** *** 72,76 **** else: for alias in codecaliases: ! _cache[alias] = entry return entry --- 77,84 ---- else: for alias in codecaliases: ! if not aliases.aliases.has_key(alias): ! aliases.aliases[alias] = modname ! ! # Return the registry entry return entry From python-dev@python.org Tue Dec 12 15:25:00 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 12 Dec 2000 07:25:00 -0800 Subject: [Python-checkins] CVS: python/dist/src LICENSE,1.7,1.8 Message-ID: <200012121525.HAA29665@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv29653 Modified Files: LICENSE Log Message: Typo detected by "the miraculous Debian package lint tool "lintian" (http://package.debian.org/lintian), which includes a spellchecker for common typos in control files of packages... You see, we're so paranoid that we even have automatic tools that keep monitoring license files ;-)" (Gregor Hoffleit) Index: LICENSE =================================================================== RCS file: /cvsroot/python/python/dist/src/LICENSE,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** LICENSE 2000/10/10 14:49:44 1.7 --- LICENSE 2000/12/12 15:24:57 1.8 *************** *** 10,14 **** Virginia where he released several versions of the software. Python 1.6 was the last of the versions released by CNRI. In 2000, Guido and ! the Python core developement team moved to BeOpen.com to form the BeOpen PythonLabs team (www.pythonlabs.com). Python 2.0 is the first release from PythonLabs. Thanks to the many outside volunteers who --- 10,14 ---- Virginia where he released several versions of the software. Python 1.6 was the last of the versions released by CNRI. In 2000, Guido and ! the Python core development team moved to BeOpen.com to form the BeOpen PythonLabs team (www.pythonlabs.com). Python 2.0 is the first release from PythonLabs. Thanks to the many outside volunteers who From python-dev@python.org Tue Dec 12 17:34:42 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 12 Dec 2000 09:34:42 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0222.txt,1.5,1.6 Message-ID: <200012121734.JAA12727@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/peps In directory slayer.i.sourceforge.net:/tmp/cvs-serv12545 Modified Files: pep-0222.txt Log Message: Add a first cut at a proposed new interface (still incomplete) Index: pep-0222.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0222.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** pep-0222.txt 2000/11/10 17:06:53 1.5 --- pep-0222.txt 2000/12/12 17:34:39 1.6 *************** *** 57,70 **** seems to me that the main reason it is there is to accomodate ! form['field'].file syntax. How about the following: ! form['field'] = '' #no values for key ! form['field'] = 'string' #one value in submission for key ! form['field'] = ['string', 'string', ....] #multiple values ! form['field'] = {'fileName':'remote/path', ! 'binaryValue':'@UIHJBV29489erht...'} #one file ! form['field'] = [{'fileName':'remote/path', ! 'binaryValue':'@UIHJBV29489erht...'}, ! {'fileName':'another/path', ! 'binaryValue':'7r7w7@@@@'}] #multiple files cgi.py: I'd prefer "input" or "submission" for the suggested --- 57,70 ---- seems to me that the main reason it is there is to accomodate ! form['field'].file syntax. How about the following: ! form['field'] = '' #no values for key ! form['field'] = 'string' #one value in submission for key ! form['field'] = ['string', 'string', ....] #multiple values ! form['field'] = {'fileName':'remote/path', ! 'binaryValue':'@UIHJBV29489erht...'} #one file ! form['field'] = [{'fileName':'remote/path', ! 'binaryValue':'@UIHJBV29489erht...'}, ! {'fileName':'another/path', ! 'binaryValue':'7r7w7@@@@'}] #multiple files cgi.py: I'd prefer "input" or "submission" for the suggested *************** *** 130,136 **** inappropriate. - Copyright This document has been placed in the public domain. --- 130,269 ---- inappropriate. + * None yet + Proposed Interface + + XXX open issues: naming convention (studlycaps or underline-separated?); + no interface for file uploads yet; need to look at all the various + packages to see if there's anything else missing; need to look at + the cgi.parse*() functions and see if they can be simplified, too. + + Parsing functions: carry over most of the parse* functions from cgi.py + + # The Response class borrows most of its methods from Zope's + # HTTPResponse class. + + class Response: + """ + Attributes: + status: HTTP status code to return + headers: dictionary of response headers + body: string containing the body of the HTTP response + """ + + def __init__(self, status=200, headers={}, body=""): + pass + + def setStatus(self, status, reason=None): + "Set the numeric HTTP response code" + pass + + def setHeader(self, name, value): + "Set an HTTP header" + pass + + def setBody(self, body): + "Set the body of the response" + pass + + def setCookie(self, name, value, + path = XXX, # What to use as defaults? + comment = XXX, + domain = XXX, + max-age = XXX, + expires = XXX, + secure = XXX + ): + "Set a cookie" + pass + + def expireCookie(self, name): + "Remove a cookie from the user" + pass + + def redirect(self, url): + "Redirect the browser to another URL" + pass + + def __str__(self): + "Convert entire response to a string" + pass + + def dump(self): + "Return a string representation useful for debugging" + pass + + # XXX methods for specific classes of error:serverError, badRequest, etc.? + + + class Request: + + """ + Attributes: + .headers : dictionary containing HTTP headers + .cookies : dictionary of cookies + .form : data from the form + .env : environment dictionary + """ + + def __init__(self, environ=os.environ, stdin=sys.stdin, + keep_blank_values=0, strict_parsing=0): + """Initialize the request object, using the provided environment + and standard input.""" + pass + + # Should people just use the dictionaries directly? + def getHeader(self, name, default=None): + pass + + def getCookie(self, name, default=None): + pass + + def getField(self, name, default=None): + pass + + def getURL(self, n=0, query_string=0): + """Return the URL of the current request, chopping off 'n' path + components from the right. Eg. if the URL is + "http://foo.com/bar/baz/qux", n=2 would return + "http://foo.com/bar". Does not include the query string (if + any) + """ + + def getBaseURL(self, n=0): + """Return the base URL of the current request, adding 'n' path + components to the end to recreate more of the whole URL. + + Eg. if the request URL is + "http://foo.com/q/bar/baz/qux", n=0 would return + "http://foo.com/", and n=2 "http://foo.com/q/bar". + + Returned URL does not include the query string, if any. + """ + + def dump(self): + "String representation suitable for debugging output" + pass + + # Possibilities? + def getBrowser(self): + "Returns Mozilla/IE/Lynx/Opera/whatever" + + def isSecure(self): + "Return true if this is an SSLified request" + + + def wrapper(func, logfile=None): + """ + Calls the function 'func', passing it the arguments + (request, response, logfile). Exceptions are trapped and + sent to the file 'logfile'. + """ + pass + + + Copyright + This document has been placed in the public domain. From python-dev@python.org Tue Dec 12 17:53:13 2000 From: python-dev@python.org (Paul Prescod) Date: Tue, 12 Dec 2000 09:53:13 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/doctools onlinehelp.py,1.3,1.4 Message-ID: <200012121753.JAA15866@slayer.i.sourceforge.net> Update of /cvsroot/python/python/nondist/sandbox/doctools In directory slayer.i.sourceforge.net:/tmp/cvs-serv15796 Modified Files: onlinehelp.py Log Message: Fixed a case-typo. Index: onlinehelp.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/doctools/onlinehelp.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** onlinehelp.py 2000/07/22 19:27:43 1.3 --- onlinehelp.py 2000/12/12 17:53:10 1.4 *************** *** 293,297 **** docrl=docrl[1:] if docrl.endswith( ">" ): ! docrl=ob[:-1] path=docrl[4:] --- 293,297 ---- docrl=docrl[1:] if docrl.endswith( ">" ): ! docrl=docrl[:-1] path=docrl[4:] *************** *** 304,308 **** self.write( 'Topic: help( "%s" )\n' % docrl ) ! self.writeHTML( ob[:index], data ) def matchDocrlPattern( self, info ): --- 304,308 ---- self.write( 'Topic: help( "%s" )\n' % docrl ) ! self.writeHTML( docrl[:index], data ) def matchDocrlPattern( self, info ): *************** *** 320,324 **** match=self.matchDocrlPattern( info ) if match: # a first-line redirect ! self.handledocrl( match ) else: self.write( 'Topic: help( "%s" )\n' % topic ) --- 320,324 ---- match=self.matchDocrlPattern( info ) if match: # a first-line redirect ! self.handleDocrl( match ) else: self.write( 'Topic: help( "%s" )\n' % topic ) *************** *** 335,339 **** mod=my_import( topic ) if mod: - print mod self.handleObject( mod ) return None --- 335,338 ---- *************** *** 371,375 **** if match: # a first-line redirect ! self.handledocrl( match ) else: text=textdoc.document( ob ) --- 370,374 ---- if match: # a first-line redirect ! self.handleDocrl( match ) else: text=textdoc.document( ob ) From python-dev@python.org Tue Dec 12 21:07:13 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 12 Dec 2000 13:07:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.dist,1.1,1.2 Message-ID: <200012122107.NAA03525@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv3504 Modified Files: Setup.dist Log Message: Add URL with info for PIL. Index: Setup.dist =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.dist,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** Setup.dist 2000/10/26 17:06:02 1.1 --- Setup.dist 2000/12/12 21:07:08 1.2 *************** *** 291,294 **** --- 291,295 ---- # -DWITH_BLT -I/usr/local/blt/blt8.0-unoff/include -lBLT8.0 \ # *** Uncomment and edit for PIL (TkImaging) extension only: + # (See http://www.pythonware.com/products/pil/ for more info) # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \ # *** Uncomment and edit for TOGL extension only: From python-dev@python.org Tue Dec 12 22:02:21 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 12 Dec 2000 14:02:21 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects dictobject.c,2.67,2.68 Message-ID: <200012122202.OAA10580@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv10552 Modified Files: dictobject.c Log Message: Add popitem() -- SF patch #102733. Index: dictobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v retrieving revision 2.67 retrieving revision 2.68 diff -C2 -r2.67 -r2.68 *** dictobject.c 2000/11/30 19:30:19 2.67 --- dictobject.c 2000/12/12 22:02:18 2.68 *************** *** 1133,1136 **** --- 1133,1188 ---- } + static PyObject * + dict_popitem(dictobject *mp, PyObject *args) + { + int i = 0; + dictentry *ep; + PyObject *res; + + if (!PyArg_NoArgs(args)) + return NULL; + if (mp->ma_used == 0) { + PyErr_SetString(PyExc_KeyError, + "popitem(): dictionary is empty"); + return NULL; + } + /* Set ep to "the first" dict entry with a value. We abuse the hash + * field of slot 0 to hold a search finger: + * If slot 0 has a value, use slot 0. + * Else slot 0 is being used to hold a search finger, + * and we use its hash value as the first index to look. + */ + ep = &mp->ma_table[0]; + if (ep->me_value == NULL) { + i = (int)ep->me_hash; + /* The hash field may be uninitialized trash, or it + * may be a real hash value, or it may be a legit + * search finger, or it may be a once-legit search + * finger that's out of bounds now because it + * wrapped around or the table shrunk -- simply + * make sure it's in bounds now. + */ + if (i >= mp->ma_size || i < 1) + i = 1; /* skip slot 0 */ + while ((ep = &mp->ma_table[i])->me_value == NULL) { + i++; + if (i >= mp->ma_size) + i = 1; + } + } + res = PyTuple_New(2); + if (res != NULL) { + PyTuple_SET_ITEM(res, 0, ep->me_key); + PyTuple_SET_ITEM(res, 1, ep->me_value); + Py_INCREF(dummy); + ep->me_key = dummy; + ep->me_value = NULL; + mp->ma_used--; + assert(mp->ma_table[0].me_value == NULL); + mp->ma_table[0].me_hash = i + 1; /* next place to start */ + } + return res; + } + static int dict_traverse(PyObject *op, visitproc visit, void *arg) *************** *** 1168,1171 **** --- 1220,1224 ---- {"get", (PyCFunction)dict_get, METH_VARARGS}, {"setdefault", (PyCFunction)dict_setdefault, METH_VARARGS}, + {"popitem", (PyCFunction)dict_popitem}, {NULL, NULL} /* sentinel */ }; From python-dev@python.org Tue Dec 12 22:03:03 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 12 Dec 2000 14:03:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_types.py,1.17,1.18 Message-ID: <200012122203.OAA10694@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv10678 Modified Files: test_types.py Log Message: Added test for {}.popitem(). Index: test_types.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** test_types.py 2000/11/30 19:30:21 1.17 --- test_types.py 2000/12/12 22:02:59 1.18 *************** *** 266,267 **** --- 266,291 ---- if len(d['key']) <> 2: raise TestFailed, 'present {} setdefault, w/ 2nd arg' + # dict.popitem() + for copymode in -1, +1: + # -1: b has same structure as a + # +1: b is a.copy() + for log2size in range(12): + size = 2**log2size + a = {} + b = {} + for i in range(size): + a[`i`] = i + if copymode < 0: + b[`i`] = i + if copymode > 0: + b = a.copy() + for i in range(size): + ka, va = ta = a.popitem() + if va != int(ka): raise TestFailed, "a.popitem: %s" % str(ta) + kb, vb = tb = b.popitem() + if vb != int(kb): raise TestFailed, "b.popitem: %s" % str(tb) + if copymode < 0 and ta != tb: + raise TestFailed, "a.popitem != b.popitem: %s, %s" % ( + str(ta), str(tb)) + if a: raise TestFailed, 'a not empty after popitems: %s' % str(a) + if b: raise TestFailed, 'b not empty after popitems: %s' % str(b) From python-dev@python.org Tue Dec 12 22:03:50 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 12 Dec 2000 14:03:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libstdtypes.tex,1.44,1.45 Message-ID: <200012122203.OAA10809@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv10793 Modified Files: libstdtypes.tex Log Message: "Documentation" for {}.popitem(). Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -r1.44 -r1.45 *** libstdtypes.tex 2000/11/30 19:30:20 1.44 --- libstdtypes.tex 2000/12/12 22:03:47 1.45 *************** *** 818,821 **** --- 818,824 ---- else \var{x} (also setting it)} {(5)} + \lineiii{\var{a}.popitem()} + {remove and return an arbitrary (\var{key}, \var{value}) pair} + {(6)} \end{tableiii} *************** *** 842,845 **** --- 845,851 ---- that if \var{k} is missing, \var{x} is both returned and inserted into the dictionary as the value of \var{k}. + + \item[(6)] \function{popitem()} is useful to destructively iterate + over a dictionary, as often used in set algorithms. \end{description} From python-dev@python.org Tue Dec 12 22:06:02 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 12 Dec 2000 14:06:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib UserDict.py,1.8,1.9 Message-ID: <200012122206.OAA11180@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv11167 Modified Files: UserDict.py Log Message: Add popitem(). Index: UserDict.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/UserDict.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** UserDict.py 2000/08/08 16:12:54 1.8 --- UserDict.py 2000/12/12 22:06:00 1.9 *************** *** 39,40 **** --- 39,42 ---- self.data[key] = failobj return self.data[key] + def popitem(self): + return self.data.popitem() From python-dev@python.org Tue Dec 12 22:10:35 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 12 Dec 2000 14:10:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.84,1.85 Message-ID: <200012122210.OAA11671@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv11662 Modified Files: NEWS Log Message: Describe {}.popitem(). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -r1.84 -r1.85 *** NEWS 2000/12/12 01:18:39 1.84 --- NEWS 2000/12/12 22:10:31 1.85 *************** *** 28,31 **** --- 28,38 ---- via %u raised an error if it was too big to fit in an int. + - Dictionary objects have an odd new method, popitem(). This removes + an arbitrary item from the dictionary and returns it (in the form of + a (key, value) pair). This can be useful for algorithms that use a + dictionary as a bag of "to do" items and repeatedly need to pick one + item. Such algorithms normally end up running in quadratic time; + using popitem() they can usually be made to run in linear time. + Windows changes From python-dev@python.org Tue Dec 12 22:21:13 2000 From: python-dev@python.org (Jack Jansen) Date: Tue, 12 Dec 2000 14:21:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/bgen/bgen scantools.py,1.18,1.19 Message-ID: <200012122221.OAA12823@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/bgen/bgen In directory slayer.i.sourceforge.net:/tmp/cvs-serv12754 Modified Files: scantools.py Log Message: Added support for generating a single module from multiple .h files. Allow /* */ comments within function prototypes. Index: scantools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/scantools.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** scantools.py 2000/07/15 22:27:47 1.18 --- scantools.py 2000/12/12 22:21:11 1.19 *************** *** 252,256 **** self.comment1_pat = "\(.*\)//.*" # note that the next pattern only removes comments that are wholly within one line ! self.comment2_pat = "\(.*\)/\*.*\*/" def compilepatterns(self): --- 252,256 ---- self.comment1_pat = "\(.*\)//.*" # note that the next pattern only removes comments that are wholly within one line ! self.comment2_pat = "\(.*\)/\*.*\*/\(.*\)" def compilepatterns(self): *************** *** 329,332 **** --- 329,342 ---- def setinput(self, scan = sys.stdin): + if not type(scan) in (TupleType, ListType): + scan = [scan] + self.allscaninputs = scan + self._nextinput() + + def _nextinput(self): + if not self.allscaninputs: + return 0 + scan = self.allscaninputs[0] + self.allscaninputs = self.allscaninputs[1:] self.closescan() if scan: *************** *** 340,343 **** --- 350,354 ---- self.scanmine = mine self.lineno = 0 + return 1 def openinput(self, filename): *************** *** 361,364 **** --- 372,377 ---- self.line = self.scanfile.readline() if not self.line: + if self._nextinput(): + return self.getline() raise EOFError self.lineno = self.lineno + 1 *************** *** 389,394 **** if self.comment1.match(line) >= 0: line = self.comment1.group('rest') ! if self.comment2.match(line) >= 0: ! line = self.comment2.group('rest') if self.defsfile and self.sym.match(line) >= 0: self.dosymdef() --- 402,407 ---- if self.comment1.match(line) >= 0: line = self.comment1.group('rest') ! while self.comment2.match(line) >= 0: ! line = self.comment2.group('rest1')+self.comment2.group('rest2') if self.defsfile and self.sym.match(line) >= 0: self.dosymdef() *************** *** 413,416 **** --- 426,433 ---- while self.tail.search(raw) < 0: line = self.getline() + if self.comment1.match(line) >= 0: + line = self.comment1.group('rest') + while self.comment2.match(line) >= 0: + line = self.comment2.group('rest1')+self.comment2.group('rest2') raw = raw + line self.processrawspec(raw) From python-dev@python.org Tue Dec 12 22:21:41 2000 From: python-dev@python.org (Jack Jansen) Date: Tue, 12 Dec 2000 14:21:41 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/bgen/bgen macsupport.py,1.19,1.20 Message-ID: <200012122221.OAA12868@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/bgen/bgen In directory slayer.i.sourceforge.net:/tmp/cvs-serv12844 Modified Files: macsupport.py Log Message: Various new standard types. Index: macsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/macsupport.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** macsupport.py 2000/07/15 22:29:30 1.19 --- macsupport.py 2000/12/12 22:21:39 1.20 *************** *** 13,17 **** Boolean = Type("Boolean", "b") SignedByte = Type("SignedByte", "b") - ScriptCode = Type("ScriptCode", "h") Size = Type("Size", "l") Style = Type("Style", "b") --- 13,16 ---- *************** *** 19,22 **** --- 18,30 ---- CharParameter = Type("CharParameter", "h") TextEncoding = Type("TextEncoding", "l") + ByteCount = Type("ByteCount", "l") + Duration = Type("Duration", "l") + ByteOffset = Type("ByteOffset", "l") + OptionBits = Type("OptionBits", "l") + ItemCount = Type("ItemCount", "l") + PBVersion = Type("PBVersion", "l") + ScriptCode = Type("ScriptCode", "h") + LangCode = Type("LangCode", "h") + RegionCode = Type("RegionCode", "h") UInt8 = Type("UInt8", "b") *************** *** 26,33 **** --- 34,46 ---- UInt32 = Type("UInt32", "l") SInt32 = Type("SInt32", "l") + Float32 = Type("Float32", "f") + + wide = OpaqueByValueType("wide", "PyMac_Buildwide", "PyMac_Getwide") + wide_ptr = OpaqueType("wide", "PyMac_Buildwide", "PyMac_Getwide") # Pascal strings ConstStr255Param = OpaqueArrayType("Str255", "PyMac_BuildStr255", "PyMac_GetStr255") Str255 = OpaqueArrayType("Str255", "PyMac_BuildStr255", "PyMac_GetStr255") + StringPtr = OpaqueByValueType("StringPtr", "PyMac_BuildStr255", "BUG") # File System Specifications *************** *** 40,43 **** --- 53,57 ---- OSType = OSTypeType("OSType") ResType = OSTypeType("ResType") + FourCharCode = OSTypeType("FourCharCode") # Version numbers *************** *** 57,60 **** --- 71,75 ---- DialogRef = DialogPtr ExistingWindowPtr = OpaqueByValueType("WindowPtr", "WinObj_WhichWindow", "BUG") + # XXX This is incorrect: it returns a Window, not a Dialog! ExistingDialogPtr = OpaqueByValueType("DialogPtr", "WinObj_WhichWindow", "BUG") From python-dev@python.org Tue Dec 12 22:37:00 2000 From: python-dev@python.org (Jack Jansen) Date: Tue, 12 Dec 2000 14:37:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python dynload_mac.c,2.8,2.9 Message-ID: <200012122237.OAA14637@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv14484 Modified Files: dynload_mac.c Log Message: Use c2pstr() in stead of Pstring() to convert C-strings to Pascal-strings. Safer, because Pstring converts in-place and the pathname may be reused later for error messages. Index: dynload_mac.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/dynload_mac.c,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -r2.8 -r2.9 *** dynload_mac.c 2000/09/01 23:29:28 2.8 --- dynload_mac.c 2000/12/12 22:36:57 2.9 *************** *** 11,14 **** --- 11,15 ---- #endif #include + #include #include "macdefs.h" #include "macglue.h" *************** *** 57,66 **** err = Path2FSSpec(pathname, &libspec); #else ! (void)FSMakeFSSpec(0, 0, Pstring(pathname), &libspec); err = ResolveAliasFile(&libspec, 1, &isfolder, &didsomething); #endif if ( err ) { ! sprintf(buf, "%.255s: %.200s", ! pathname, PyMac_StrError(err)); PyErr_SetString(PyExc_ImportError, buf); return NULL; --- 58,67 ---- err = Path2FSSpec(pathname, &libspec); #else ! c2pstrcpy((unsigned char *)buf, pathname); ! (void)FSMakeFSSpec(0, 0, (unsigned char *)buf, &libspec); err = ResolveAliasFile(&libspec, 1, &isfolder, &didsomething); #endif if ( err ) { ! sprintf(buf, "%.200s: %.200s", pathname, PyMac_StrError(err)); PyErr_SetString(PyExc_ImportError, buf); return NULL; From python-dev@python.org Tue Dec 12 22:39:06 2000 From: python-dev@python.org (Jack Jansen) Date: Tue, 12 Dec 2000 14:39:06 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib site.py,1.21,1.22 Message-ID: <200012122239.OAA14981@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv14877 Modified Files: site.py Log Message: The ".pth" code knew about the layout of Python trees on unix and windows, but not on the mac. Fixed. Index: site.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/site.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** site.py 2000/12/06 22:20:07 1.21 --- site.py 2000/12/12 22:39:04 1.22 *************** *** 123,126 **** --- 123,128 ---- "site-packages"), makepath(prefix, "lib", "site-python")] + elif os.sep == ':': + sitedirs = [makepath(prefix, "lib", "site-packages")] else: sitedirs = [prefix] From python-dev@python.org Tue Dec 12 22:42:40 2000 From: python-dev@python.org (Jack Jansen) Date: Tue, 12 Dec 2000 14:42:40 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules timemodule.c,2.103,2.104 Message-ID: <200012122242.OAA15381@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv15218 Modified Files: timemodule.c Log Message: The Mac C library (MSL from CodeWarrior 6) and I/O library (GUSI 2.1.3) finally agree on when the epoch is, so the code to convert epochs has been disabled. Index: timemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v retrieving revision 2.103 retrieving revision 2.104 diff -C2 -r2.103 -r2.104 *** timemodule.c 2000/09/01 23:29:27 2.103 --- timemodule.c 2000/12/12 22:42:30 2.104 *************** *** 9,13 **** #include #include ! #ifdef USE_GUSI2 /* GUSI, the I/O library which has the time() function and such uses the ** Mac epoch of 1904. MSL, the C library which has localtime() and so uses --- 9,13 ---- #include #include ! #ifdef USE_GUSI211 /* GUSI, the I/O library which has the time() function and such uses the ** Mac epoch of 1904. MSL, the C library which has localtime() and so uses *************** *** 467,471 **** return NULL; } ! #if defined(macintosh) && defined(USE_GUSI2) tt = tt - GUSI_TO_MSL_EPOCH; #endif --- 467,471 ---- return NULL; } ! #if defined(macintosh) && defined(USE_GUSI211) tt = tt - GUSI_TO_MSL_EPOCH; #endif From python-dev@python.org Tue Dec 12 23:11:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 12 Dec 2000 15:11:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-tk Tkinter.py,1.150,1.151 Message-ID: <200012122311.PAA18727@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory slayer.i.sourceforge.net:/tmp/cvs-serv18670/lib-tk Modified Files: Tkinter.py Log Message: Update the code to better reflect recommended style: Use != instead of <> since <> is documented as "obsolescent". Use "is" and "is not" when comparing with None or type objects. Index: Tkinter.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tkinter.py,v retrieving revision 1.150 retrieving revision 1.151 diff -C2 -r1.150 -r1.151 *** Tkinter.py 2000/10/23 18:31:14 1.150 --- Tkinter.py 2000/12/12 23:11:41 1.151 *************** *** 340,344 **** If no parameter is given self is used.""" ! if window == None: window = self self.tk.call('tkwait', 'window', window._w) --- 340,344 ---- If no parameter is given self is used.""" ! if window is None: window = self self.tk.call('tkwait', 'window', window._w) *************** *** 348,352 **** If no parameter is given self is used.""" ! if window == None: window = self self.tk.call('tkwait', 'visibility', window._w) --- 348,352 ---- If no parameter is given self is used.""" ! if window is None: window = self self.tk.call('tkwait', 'visibility', window._w) From python-dev@python.org Tue Dec 12 23:11:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 12 Dec 2000 15:11:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils cygwinccompiler.py,1.8,1.9 Message-ID: <200012122311.PAA18719@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv18670/distutils Modified Files: cygwinccompiler.py Log Message: Update the code to better reflect recommended style: Use != instead of <> since <> is documented as "obsolescent". Use "is" and "is not" when comparing with None or type objects. Index: cygwinccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/cygwinccompiler.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** cygwinccompiler.py 2000/09/27 02:08:14 1.8 --- cygwinccompiler.py 2000/12/12 23:11:39 1.9 *************** *** 242,246 **** #end: if ((export_symbols is not None) and ! # (target_desc <> self.EXECUTABLE or self.linker_dll == "gcc")): # who wants symbols and a many times larger output file --- 242,246 ---- #end: if ((export_symbols is not None) and ! # (target_desc != self.EXECUTABLE or self.linker_dll == "gcc")): # who wants symbols and a many times larger output file From python-dev@python.org Tue Dec 12 23:11:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 12 Dec 2000 15:11:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-irix5 FL.py,1.7,1.8 cdplayer.py,1.6,1.7 flp.py,1.19,1.20 jpeg.py,1.3,1.4 panel.py,1.5,1.6 panelparser.py,1.2,1.3 readcd.py,1.11,1.12 torgb.py,1.5,1.6 Message-ID: <200012122311.PAA18752@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/plat-irix5 In directory slayer.i.sourceforge.net:/tmp/cvs-serv18670/plat-irix5 Modified Files: FL.py cdplayer.py flp.py jpeg.py panel.py panelparser.py readcd.py torgb.py Log Message: Update the code to better reflect recommended style: Use != instead of <> since <> is documented as "obsolescent". Use "is" and "is not" when comparing with None or type objects. Index: FL.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/FL.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** FL.py 1993/07/06 15:19:33 1.7 --- FL.py 2000/12/12 23:11:41 1.8 *************** *** 8,12 **** ##import fl ##try: ! ## _v20 = (fl.get_rgbmode <> None) ##except: ## _v20 = 0 --- 8,12 ---- ##import fl ##try: ! ## _v20 = (fl.get_rgbmode is not None) ##except: ## _v20 = 0 Index: cdplayer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/cdplayer.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** cdplayer.py 2000/07/16 11:57:19 1.6 --- cdplayer.py 2000/12/12 23:11:42 1.7 *************** *** 78,82 **** if line == '': break ! if line[:l] <> s: new.write(line) new.write(self.id + '.title:\t' + self.title + '\n') --- 78,82 ---- if line == '': break ! if line[:l] != s: new.write(line) new.write(self.id + '.title:\t' + self.title + '\n') Index: flp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/flp.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** flp.py 2000/08/18 14:57:26 1.19 --- flp.py 2000/12/12 23:11:42 1.20 *************** *** 37,41 **** def parse_forms(filename): forms = checkcache(filename) ! if forms != None: return forms fp = _open_formfile(filename) nforms = _parse_fd_header(fp) --- 37,41 ---- def parse_forms(filename): forms = checkcache(filename) ! if forms is not None: return forms fp = _open_formfile(filename) nforms = _parse_fd_header(fp) *************** *** 169,173 **** def _open_formfile2(filename): ! if filename[-3:] <> '.fd': filename = filename + '.fd' if filename[0] == '/': --- 169,173 ---- def _open_formfile2(filename): ! if filename[-3:] != '.fd': filename = filename + '.fd' if filename[0] == '/': *************** *** 185,189 **** except IOError: fp = None ! if fp == None: raise error, 'Cannot find forms file ' + filename return fp, filename --- 185,189 ---- except IOError: fp = None ! if fp is None: raise error, 'Cannot find forms file ' + filename return fp, filename *************** *** 195,199 **** # First read the magic header line datum = _parse_1_line(file) ! if datum <> ('Magic', 12321): raise error, 'Not a forms definition file' # Now skip until we know number of forms --- 195,199 ---- # First read the magic header line datum = _parse_1_line(file) ! if datum != ('Magic', 12321): raise error, 'Not a forms definition file' # Now skip until we know number of forms *************** *** 209,216 **** def _parse_fd_form(file, name): datum = _parse_1_line(file) ! if datum <> FORMLINE: raise error, 'Missing === FORM === line' form = _parse_object(file) ! if form.Name == name or name == None: objs = [] for j in range(form.Numberofobjects): --- 209,216 ---- def _parse_fd_form(file, name): datum = _parse_1_line(file) ! if datum != FORMLINE: raise error, 'Missing === FORM === line' form = _parse_object(file) ! if form.Name == name or name is None: objs = [] for j in range(form.Numberofobjects): *************** *** 317,321 **** file.seek(pos) return obj ! if type(datum) <> type(()) or len(datum) <> 2: raise error, 'Parse error, illegal line in object: '+datum obj.add(datum[0], datum[1]) --- 317,321 ---- file.seek(pos) return obj ! if type(datum) is not type(()) or len(datum) != 2: raise error, 'Parse error, illegal line in object: '+datum obj.add(datum[0], datum[1]) *************** *** 340,344 **** def merge_full_form(inst, form, (fdata, odatalist)): exec 'inst.'+fdata.Name+' = form\n' ! if odatalist[0].Class <> FL.BOX: raise error, 'merge_full_form() expects FL.BOX as first obj' for odata in odatalist[1:]: --- 340,344 ---- def merge_full_form(inst, form, (fdata, odatalist)): exec 'inst.'+fdata.Name+' = form\n' ! if odatalist[0].Class != FL.BOX: raise error, 'merge_full_form() expects FL.BOX as first obj' for odata in odatalist[1:]: Index: jpeg.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/jpeg.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** jpeg.py 2000/08/18 14:57:26 1.3 --- jpeg.py 2000/12/12 23:11:42 1.4 *************** *** 60,64 **** def setoption(name, value): ! if type(value) <> type(0): raise TypeError, 'jpeg.setoption: numeric options only' if name == 'forcegrey': --- 60,64 ---- def setoption(name, value): ! if type(value) is not type(0): raise TypeError, 'jpeg.setoption: numeric options only' if name == 'forcegrey': Index: panel.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/panel.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** panel.py 2000/06/28 14:48:01 1.5 --- panel.py 2000/12/12 23:11:42 1.6 *************** *** 208,212 **** # Sanity check # ! if (not descr) or descr[0] <> 'panel': raise panel_error, 'panel description must start with "panel"' # --- 208,212 ---- # Sanity check # ! if (not descr) or descr[0] != 'panel': raise panel_error, 'panel description must start with "panel"' # Index: panelparser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/panelparser.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** panelparser.py 1992/01/01 19:32:09 1.2 --- panelparser.py 2000/12/12 23:11:42 1.3 *************** *** 72,76 **** # def parse_expr(tokens): ! if (not tokens) or tokens[0] <> '(': raise syntax_error, 'expected "("' tokens = tokens[1:] --- 72,76 ---- # def parse_expr(tokens): ! if (not tokens) or tokens[0] != '(': raise syntax_error, 'expected "("' tokens = tokens[1:] Index: readcd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/readcd.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** readcd.py 2000/08/18 14:57:26 1.11 --- readcd.py 2000/12/12 23:11:42 1.12 *************** *** 94,98 **** raise Error, 'range error' end = self.pmsf2msf(prog, min, sec, frame) ! elif l <> 3: raise Error, 'syntax error' if type(start) == type(0): --- 94,98 ---- raise Error, 'range error' end = self.pmsf2msf(prog, min, sec, frame) ! elif l != 3: raise Error, 'syntax error' if type(start) == type(0): *************** *** 112,116 **** raise Error, 'range error' start = self.pmsf2msf(prog, min, sec, frame) ! elif l <> 3: raise Error, 'syntax error' self.list.append((start, end)) --- 112,116 ---- raise Error, 'range error' start = self.pmsf2msf(prog, min, sec, frame) ! elif l != 3: raise Error, 'syntax error' self.list.append((start, end)) *************** *** 128,135 **** start, end = self.list[self.listindex] if type(end) == type(0): ! if cb_type <> CD.PNUM: self.parser.setcallback(cb_type, func, arg) else: ! if cb_type <> CD.ATIME: self.parser.setcallback(cb_type, func, arg) --- 128,135 ---- start, end = self.list[self.listindex] if type(end) == type(0): ! if cb_type != CD.PNUM: self.parser.setcallback(cb_type, func, arg) else: ! if cb_type != CD.ATIME: self.parser.setcallback(cb_type, func, arg) *************** *** 141,148 **** start, end = self.list[self.listindex] if type(end) == type(0): ! if cb_type <> CD.PNUM: self.parser.removecallback(cb_type) else: ! if cb_type <> CD.ATIME: self.parser.removecallback(cb_type) --- 141,148 ---- start, end = self.list[self.listindex] if type(end) == type(0): ! if cb_type != CD.PNUM: self.parser.removecallback(cb_type) else: ! if cb_type != CD.ATIME: self.parser.removecallback(cb_type) Index: torgb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/torgb.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** torgb.py 2000/08/18 14:57:26 1.5 --- torgb.py 2000/12/12 23:11:42 1.6 *************** *** 61,65 **** finally: for temp in temps[:]: ! if temp <> ret: try: os.unlink(temp) --- 61,65 ---- finally: for temp in temps[:]: ! if temp != ret: try: os.unlink(temp) *************** *** 84,93 **** type(msg[0]) == type(0) and type(msg[1]) == type(''): msg = msg[1] ! if type(msg) <> type(''): msg = `msg` raise error, filename + ': ' + msg if ftype == 'rgb': return fname ! if ftype == None or not table.has_key(ftype): raise error, \ filename + ': unsupported image file type ' + `ftype` --- 84,93 ---- type(msg[0]) == type(0) and type(msg[1]) == type(''): msg = msg[1] ! if type(msg) is not type(''): msg = `msg` raise error, filename + ': ' + msg if ftype == 'rgb': return fname ! if ftype is None or not table.has_key(ftype): raise error, \ filename + ': unsupported image file type ' + `ftype` From python-dev@python.org Tue Dec 12 23:11:45 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 12 Dec 2000 15:11:45 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test regrtest.py,1.27,1.28 test_audioop.py,1.6,1.7 test_b1.py,1.27,1.28 test_b2.py,1.20,1.21 test_binascii.py,1.6,1.7 test_binhex.py,1.6,1.7 test_bsddb.py,1.4,1.5 test_grammar.py,1.20,1.21 test_math.py,1.9,1.10 test_md5.py,1.3,1.4 test_mmap.py,1.11,1.12 test_new.py,1.5,1.6 test_nis.py,1.8,1.9 test_opcodes.py,1.8,1.9 test_operator.py,1.3,1.4 test_pow.py,1.6,1.7 test_pty.py,1.6,1.7 test_pwd.py,1.7,1.8 test_re.py,1.26,1.27 test_rotor.py,1.4,1.5 test_sax.py,1.13,1.14 test_socket.py,1.14,1.15 test_sre.py,1.13,1.14 test_struct.py,1.6,1.7 test_support.py,1.8,1.9 test_time.py,1.5,1.6 test_types.py,1.18,1.19 test_unpack.py,1.4,1.5 Message-ID: <200012122311.PAA18793@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv18670/test Modified Files: regrtest.py test_audioop.py test_b1.py test_b2.py test_binascii.py test_binhex.py test_bsddb.py test_grammar.py test_math.py test_md5.py test_mmap.py test_new.py test_nis.py test_opcodes.py test_operator.py test_pow.py test_pty.py test_pwd.py test_re.py test_rotor.py test_sax.py test_socket.py test_sre.py test_struct.py test_support.py test_time.py test_types.py test_unpack.py Log Message: Update the code to better reflect recommended style: Use != instead of <> since <> is documented as "obsolescent". Use "is" and "is not" when comparing with None or type objects. Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** regrtest.py 2000/10/23 17:22:07 1.27 --- regrtest.py 2000/12/12 23:11:42 1.28 *************** *** 284,288 **** def write(self, data): expected = self.fp.read(len(data)) ! if data <> expected: raise test_support.TestFailed, \ 'Writing: '+`data`+', expected: '+`expected` --- 284,288 ---- def write(self, data): expected = self.fp.read(len(data)) ! if data != expected: raise test_support.TestFailed, \ 'Writing: '+`data`+', expected: '+`expected` Index: test_audioop.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_audioop.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_audioop.py 1998/03/26 19:41:42 1.6 --- test_audioop.py 2000/12/12 23:11:42 1.7 *************** *** 25,31 **** if verbose: print 'max' ! if audioop.max(data[0], 1) <> 2 or \ ! audioop.max(data[1], 2) <> 2 or \ ! audioop.max(data[2], 4) <> 2: return 0 return 1 --- 25,31 ---- if verbose: print 'max' ! if audioop.max(data[0], 1) != 2 or \ ! audioop.max(data[1], 2) != 2 or \ ! audioop.max(data[2], 4) != 2: return 0 return 1 *************** *** 34,40 **** if verbose: print 'minmax' ! if audioop.minmax(data[0], 1) <> (0, 2) or \ ! audioop.minmax(data[1], 2) <> (0, 2) or \ ! audioop.minmax(data[2], 4) <> (0, 2): return 0 return 1 --- 34,40 ---- if verbose: print 'minmax' ! if audioop.minmax(data[0], 1) != (0, 2) or \ ! audioop.minmax(data[1], 2) != (0, 2) or \ ! audioop.minmax(data[2], 4) != (0, 2): return 0 return 1 *************** *** 43,49 **** if verbose: print 'maxpp' ! if audioop.maxpp(data[0], 1) <> 0 or \ ! audioop.maxpp(data[1], 2) <> 0 or \ ! audioop.maxpp(data[2], 4) <> 0: return 0 return 1 --- 43,49 ---- if verbose: print 'maxpp' ! if audioop.maxpp(data[0], 1) != 0 or \ ! audioop.maxpp(data[1], 2) != 0 or \ ! audioop.maxpp(data[2], 4) != 0: return 0 return 1 *************** *** 52,58 **** if verbose: print 'avg' ! if audioop.avg(data[0], 1) <> 1 or \ ! audioop.avg(data[1], 2) <> 1 or \ ! audioop.avg(data[2], 4) <> 1: return 0 return 1 --- 52,58 ---- if verbose: print 'avg' ! if audioop.avg(data[0], 1) != 1 or \ ! audioop.avg(data[1], 2) != 1 or \ ! audioop.avg(data[2], 4) != 1: return 0 return 1 *************** *** 61,74 **** if verbose: print 'avgpp' ! if audioop.avgpp(data[0], 1) <> 0 or \ ! audioop.avgpp(data[1], 2) <> 0 or \ ! audioop.avgpp(data[2], 4) <> 0: return 0 return 1 def testrms(data): ! if audioop.rms(data[0], 1) <> 1 or \ ! audioop.rms(data[1], 2) <> 1 or \ ! audioop.rms(data[2], 4) <> 1: return 0 return 1 --- 61,74 ---- if verbose: print 'avgpp' ! if audioop.avgpp(data[0], 1) != 0 or \ ! audioop.avgpp(data[1], 2) != 0 or \ ! audioop.avgpp(data[2], 4) != 0: return 0 return 1 def testrms(data): ! if audioop.rms(data[0], 1) != 1 or \ ! audioop.rms(data[1], 2) != 1 or \ ! audioop.rms(data[2], 4) != 1: return 0 return 1 *************** *** 77,83 **** if verbose: print 'cross' ! if audioop.cross(data[0], 1) <> 0 or \ ! audioop.cross(data[1], 2) <> 0 or \ ! audioop.cross(data[2], 4) <> 0: return 0 return 1 --- 77,83 ---- if verbose: print 'cross' ! if audioop.cross(data[0], 1) != 0 or \ ! audioop.cross(data[1], 2) != 0 or \ ! audioop.cross(data[2], 4) != 0: return 0 return 1 *************** *** 92,98 **** str = str + chr(ord(s)*2) data2.append(str) ! if audioop.add(data[0], data[0], 1) <> data2[0] or \ ! audioop.add(data[1], data[1], 2) <> data2[1] or \ ! audioop.add(data[2], data[2], 4) <> data2[2]: return 0 return 1 --- 92,98 ---- str = str + chr(ord(s)*2) data2.append(str) ! if audioop.add(data[0], data[0], 1) != data2[0] or \ ! audioop.add(data[1], data[1], 2) != data2[1] or \ ! audioop.add(data[2], data[2], 4) != data2[2]: return 0 return 1 *************** *** 105,111 **** d2 = audioop.bias(data[1], 2, 100) d4 = audioop.bias(data[2], 4, 100) ! if audioop.avg(d1, 1) <> 101 or \ ! audioop.avg(d2, 2) <> 101 or \ ! audioop.avg(d4, 4) <> 101: return 0 return 1 --- 105,111 ---- d2 = audioop.bias(data[1], 2, 100) d4 = audioop.bias(data[2], 4, 100) ! if audioop.avg(d1, 1) != 101 or \ ! audioop.avg(d2, 2) != 101 or \ ! audioop.avg(d4, 4) != 101: return 0 return 1 *************** *** 119,123 **** got = len(d1)/3 wtd = len(d2)/3 ! if len(audioop.lin2lin(d1, got, wtd)) <> len(d2): return 0 return 1 --- 119,123 ---- got = len(d1)/3 wtd = len(d2)/3 ! if len(audioop.lin2lin(d1, got, wtd)) != len(d2): return 0 return 1 *************** *** 125,129 **** def testadpcm2lin(data): # Very cursory test ! if audioop.adpcm2lin('\0\0', 1, None) <> ('\0\0\0\0', (0,0)): return 0 return 1 --- 125,129 ---- def testadpcm2lin(data): # Very cursory test ! if audioop.adpcm2lin('\0\0', 1, None) != ('\0\0\0\0', (0,0)): return 0 return 1 *************** *** 133,137 **** print 'lin2adpcm' # Very cursory test ! if audioop.lin2adpcm('\0\0\0\0', 1, None) <> ('\0\0', (0,0)): return 0 return 1 --- 133,137 ---- print 'lin2adpcm' # Very cursory test ! if audioop.lin2adpcm('\0\0\0\0', 1, None) != ('\0\0', (0,0)): return 0 return 1 *************** *** 140,146 **** if verbose: print 'lin2ulaw' ! if audioop.lin2ulaw(data[0], 1) <> '\377\347\333' or \ ! audioop.lin2ulaw(data[1], 2) <> '\377\377\377' or \ ! audioop.lin2ulaw(data[2], 4) <> '\377\377\377': return 0 return 1 --- 140,146 ---- if verbose: print 'lin2ulaw' ! if audioop.lin2ulaw(data[0], 1) != '\377\347\333' or \ ! audioop.lin2ulaw(data[1], 2) != '\377\377\377' or \ ! audioop.lin2ulaw(data[2], 4) != '\377\377\377': return 0 return 1 *************** *** 151,155 **** # Cursory d = audioop.lin2ulaw(data[0], 1) ! if audioop.ulaw2lin(d, 1) <> data[0]: return 0 return 1 --- 151,155 ---- # Cursory d = audioop.lin2ulaw(data[0], 1) ! if audioop.ulaw2lin(d, 1) != data[0]: return 0 return 1 *************** *** 164,170 **** str = str + chr(ord(s)*2) data2.append(str) ! if audioop.mul(data[0], 1, 2) <> data2[0] or \ ! audioop.mul(data[1],2, 2) <> data2[1] or \ ! audioop.mul(data[2], 4, 2) <> data2[2]: return 0 return 1 --- 164,170 ---- str = str + chr(ord(s)*2) data2.append(str) ! if audioop.mul(data[0], 1, 2) != data2[0] or \ ! audioop.mul(data[1],2, 2) != data2[1] or \ ! audioop.mul(data[2], 4, 2) != data2[2]: return 0 return 1 *************** *** 183,187 **** if verbose: print 'reverse' ! if audioop.reverse(data[0], 1) <> '\2\1\0': return 0 return 1 --- 183,187 ---- if verbose: print 'reverse' ! if audioop.reverse(data[0], 1) != '\2\1\0': return 0 return 1 *************** *** 193,197 **** for d in data[0]: data2 = data2 + d + d ! if audioop.tomono(data2, 1, 0.5, 0.5) <> data[0]: return 0 return 1 --- 193,197 ---- for d in data[0]: data2 = data2 + d + d ! if audioop.tomono(data2, 1, 0.5, 0.5) != data[0]: return 0 return 1 *************** *** 203,207 **** for d in data[0]: data2 = data2 + d + d ! if audioop.tostereo(data[0], 1, 1, 1) <> data2: return 0 return 1 --- 203,207 ---- for d in data[0]: data2 = data2 + d + d ! if audioop.tostereo(data[0], 1, 1, 1) != data2: return 0 return 1 *************** *** 210,214 **** if verbose: print 'findfactor' ! if audioop.findfactor(data[1], data[1]) <> 1.0: return 0 return 1 --- 210,214 ---- if verbose: print 'findfactor' ! if audioop.findfactor(data[1], data[1]) != 1.0: return 0 return 1 *************** *** 217,221 **** if verbose: print 'findfit' ! if audioop.findfit(data[1], data[1]) <> (0, 1.0): return 0 return 1 --- 217,221 ---- if verbose: print 'findfit' ! if audioop.findfit(data[1], data[1]) != (0, 1.0): return 0 return 1 *************** *** 224,228 **** if verbose: print 'findmax' ! if audioop.findmax(data[1], 1) <> 2: return 0 return 1 --- 224,228 ---- if verbose: print 'findmax' ! if audioop.findmax(data[1], 1) != 2: return 0 return 1 *************** *** 232,238 **** print 'getsample' for i in range(3): ! if audioop.getsample(data[0], 1, i) <> i or \ ! audioop.getsample(data[1], 2, i) <> i or \ ! audioop.getsample(data[2], 4, i) <> i: return 0 return 1 --- 232,238 ---- print 'getsample' for i in range(3): ! if audioop.getsample(data[0], 1, i) != i or \ ! audioop.getsample(data[1], 2, i) != i or \ ! audioop.getsample(data[2], 4, i) != i: return 0 return 1 Index: test_b1.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b1.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** test_b1.py 2000/09/19 20:58:53 1.27 --- test_b1.py 2000/12/12 23:11:42 1.28 *************** *** 12,26 **** print 'abs' ! if abs(0) <> 0: raise TestFailed, 'abs(0)' ! if abs(1234) <> 1234: raise TestFailed, 'abs(1234)' ! if abs(-1234) <> 1234: raise TestFailed, 'abs(-1234)' # ! if abs(0.0) <> 0.0: raise TestFailed, 'abs(0.0)' ! if abs(3.14) <> 3.14: raise TestFailed, 'abs(3.14)' ! if abs(-3.14) <> 3.14: raise TestFailed, 'abs(-3.14)' # ! if abs(0L) <> 0L: raise TestFailed, 'abs(0L)' ! if abs(1234L) <> 1234L: raise TestFailed, 'abs(1234L)' ! if abs(-1234L) <> 1234L: raise TestFailed, 'abs(-1234L)' print 'apply' --- 12,26 ---- print 'abs' ! if abs(0) != 0: raise TestFailed, 'abs(0)' ! if abs(1234) != 1234: raise TestFailed, 'abs(1234)' ! if abs(-1234) != 1234: raise TestFailed, 'abs(-1234)' # ! if abs(0.0) != 0.0: raise TestFailed, 'abs(0.0)' ! if abs(3.14) != 3.14: raise TestFailed, 'abs(3.14)' ! if abs(-3.14) != 3.14: raise TestFailed, 'abs(-3.14)' # ! if abs(0L) != 0L: raise TestFailed, 'abs(0L)' ! if abs(1234L) != 1234L: raise TestFailed, 'abs(1234L)' ! if abs(-1234L) != 1234L: raise TestFailed, 'abs(-1234L)' print 'apply' *************** *** 56,67 **** print 'chr' ! if chr(32) <> ' ': raise TestFailed, 'chr(32)' ! if chr(65) <> 'A': raise TestFailed, 'chr(65)' ! if chr(97) <> 'a': raise TestFailed, 'chr(97)' print 'cmp' ! if cmp(-1, 1) <> -1: raise TestFailed, 'cmp(-1, 1)' ! if cmp(1, -1) <> 1: raise TestFailed, 'cmp(1, -1)' ! if cmp(1, 1) <> 0: raise TestFailed, 'cmp(1, 1)' # verify that circular objects are handled a = []; a.append(a) --- 56,67 ---- print 'chr' ! if chr(32) != ' ': raise TestFailed, 'chr(32)' ! if chr(65) != 'A': raise TestFailed, 'chr(65)' ! if chr(97) != 'a': raise TestFailed, 'chr(97)' print 'cmp' ! if cmp(-1, 1) != -1: raise TestFailed, 'cmp(-1, 1)' ! if cmp(1, -1) != 1: raise TestFailed, 'cmp(1, -1)' ! if cmp(1, 1) != 0: raise TestFailed, 'cmp(1, 1)' # verify that circular objects are handled a = []; a.append(a) *************** *** 78,82 **** print 'coerce' if fcmp(coerce(1, 1.1), (1.0, 1.1)): raise TestFailed, 'coerce(1, 1.1)' ! if coerce(1, 1L) <> (1L, 1L): raise TestFailed, 'coerce(1, 1L)' if fcmp(coerce(1L, 1.1), (1.0, 1.1)): raise TestFailed, 'coerce(1L, 1.1)' --- 78,82 ---- print 'coerce' if fcmp(coerce(1, 1.1), (1.0, 1.1)): raise TestFailed, 'coerce(1, 1.1)' ! if coerce(1, 1L) != (1L, 1L): raise TestFailed, 'coerce(1, 1L)' if fcmp(coerce(1L, 1.1), (1.0, 1.1)): raise TestFailed, 'coerce(1L, 1.1)' *************** *** 85,115 **** print 'complex' ! if complex(1,10) <> 1+10j: raise TestFailed, 'complex(1,10)' ! if complex(1,10L) <> 1+10j: raise TestFailed, 'complex(1,10L)' ! if complex(1,10.0) <> 1+10j: raise TestFailed, 'complex(1,10.0)' ! if complex(1L,10) <> 1+10j: raise TestFailed, 'complex(1L,10)' ! if complex(1L,10L) <> 1+10j: raise TestFailed, 'complex(1L,10L)' ! if complex(1L,10.0) <> 1+10j: raise TestFailed, 'complex(1L,10.0)' ! if complex(1.0,10) <> 1+10j: raise TestFailed, 'complex(1.0,10)' ! if complex(1.0,10L) <> 1+10j: raise TestFailed, 'complex(1.0,10L)' ! if complex(1.0,10.0) <> 1+10j: raise TestFailed, 'complex(1.0,10.0)' ! if complex(3.14+0j) <> 3.14+0j: raise TestFailed, 'complex(3.14)' ! if complex(3.14) <> 3.14+0j: raise TestFailed, 'complex(3.14)' ! if complex(314) <> 314.0+0j: raise TestFailed, 'complex(314)' ! if complex(314L) <> 314.0+0j: raise TestFailed, 'complex(314L)' ! if complex(3.14+0j, 0j) <> 3.14+0j: raise TestFailed, 'complex(3.14, 0j)' ! if complex(3.14, 0.0) <> 3.14+0j: raise TestFailed, 'complex(3.14, 0.0)' ! if complex(314, 0) <> 314.0+0j: raise TestFailed, 'complex(314, 0)' ! if complex(314L, 0L) <> 314.0+0j: raise TestFailed, 'complex(314L, 0L)' ! if complex(0j, 3.14j) <> -3.14+0j: raise TestFailed, 'complex(0j, 3.14j)' ! if complex(0.0, 3.14j) <> -3.14+0j: raise TestFailed, 'complex(0.0, 3.14j)' ! if complex(0j, 3.14) <> 3.14j: raise TestFailed, 'complex(0j, 3.14)' ! if complex(0.0, 3.14) <> 3.14j: raise TestFailed, 'complex(0.0, 3.14)' ! if complex(" 3.14+J ") <> 3.14+1j: raise TestFailed, 'complex(" 3.14+J )"' ! if complex(u" 3.14+J ") <> 3.14+1j: raise TestFailed, 'complex(u" 3.14+J )"' class Z: def __complex__(self): return 3.14j z = Z() ! if complex(z) <> 3.14j: raise TestFailed, 'complex(classinstance)' print 'delattr' --- 85,115 ---- print 'complex' ! if complex(1,10) != 1+10j: raise TestFailed, 'complex(1,10)' ! if complex(1,10L) != 1+10j: raise TestFailed, 'complex(1,10L)' ! if complex(1,10.0) != 1+10j: raise TestFailed, 'complex(1,10.0)' ! if complex(1L,10) != 1+10j: raise TestFailed, 'complex(1L,10)' ! if complex(1L,10L) != 1+10j: raise TestFailed, 'complex(1L,10L)' ! if complex(1L,10.0) != 1+10j: raise TestFailed, 'complex(1L,10.0)' ! if complex(1.0,10) != 1+10j: raise TestFailed, 'complex(1.0,10)' ! if complex(1.0,10L) != 1+10j: raise TestFailed, 'complex(1.0,10L)' ! if complex(1.0,10.0) != 1+10j: raise TestFailed, 'complex(1.0,10.0)' ! if complex(3.14+0j) != 3.14+0j: raise TestFailed, 'complex(3.14)' ! if complex(3.14) != 3.14+0j: raise TestFailed, 'complex(3.14)' ! if complex(314) != 314.0+0j: raise TestFailed, 'complex(314)' ! if complex(314L) != 314.0+0j: raise TestFailed, 'complex(314L)' ! if complex(3.14+0j, 0j) != 3.14+0j: raise TestFailed, 'complex(3.14, 0j)' ! if complex(3.14, 0.0) != 3.14+0j: raise TestFailed, 'complex(3.14, 0.0)' ! if complex(314, 0) != 314.0+0j: raise TestFailed, 'complex(314, 0)' ! if complex(314L, 0L) != 314.0+0j: raise TestFailed, 'complex(314L, 0L)' ! if complex(0j, 3.14j) != -3.14+0j: raise TestFailed, 'complex(0j, 3.14j)' ! if complex(0.0, 3.14j) != -3.14+0j: raise TestFailed, 'complex(0.0, 3.14j)' ! if complex(0j, 3.14) != 3.14j: raise TestFailed, 'complex(0j, 3.14)' ! if complex(0.0, 3.14) != 3.14j: raise TestFailed, 'complex(0.0, 3.14)' ! if complex(" 3.14+J ") != 3.14+1j: raise TestFailed, 'complex(" 3.14+J )"' ! if complex(u" 3.14+J ") != 3.14+1j: raise TestFailed, 'complex(u" 3.14+J )"' class Z: def __complex__(self): return 3.14j z = Z() ! if complex(z) != 3.14j: raise TestFailed, 'complex(classinstance)' print 'delattr' *************** *** 125,142 **** print 'divmod' ! if divmod(12, 7) <> (1, 5): raise TestFailed, 'divmod(12, 7)' ! if divmod(-12, 7) <> (-2, 2): raise TestFailed, 'divmod(-12, 7)' ! if divmod(12, -7) <> (-2, -2): raise TestFailed, 'divmod(12, -7)' ! if divmod(-12, -7) <> (1, -5): raise TestFailed, 'divmod(-12, -7)' # ! if divmod(12L, 7L) <> (1L, 5L): raise TestFailed, 'divmod(12L, 7L)' ! if divmod(-12L, 7L) <> (-2L, 2L): raise TestFailed, 'divmod(-12L, 7L)' ! if divmod(12L, -7L) <> (-2L, -2L): raise TestFailed, 'divmod(12L, -7L)' ! if divmod(-12L, -7L) <> (1L, -5L): raise TestFailed, 'divmod(-12L, -7L)' # ! if divmod(12, 7L) <> (1, 5L): raise TestFailed, 'divmod(12, 7L)' ! if divmod(-12, 7L) <> (-2, 2L): raise TestFailed, 'divmod(-12, 7L)' ! if divmod(12L, -7) <> (-2L, -2): raise TestFailed, 'divmod(12L, -7)' ! if divmod(-12L, -7) <> (1L, -5): raise TestFailed, 'divmod(-12L, -7)' # if fcmp(divmod(3.25, 1.0), (3.0, 0.25)): --- 125,142 ---- print 'divmod' ! if divmod(12, 7) != (1, 5): raise TestFailed, 'divmod(12, 7)' ! if divmod(-12, 7) != (-2, 2): raise TestFailed, 'divmod(-12, 7)' ! if divmod(12, -7) != (-2, -2): raise TestFailed, 'divmod(12, -7)' ! if divmod(-12, -7) != (1, -5): raise TestFailed, 'divmod(-12, -7)' # ! if divmod(12L, 7L) != (1L, 5L): raise TestFailed, 'divmod(12L, 7L)' ! if divmod(-12L, 7L) != (-2L, 2L): raise TestFailed, 'divmod(-12L, 7L)' ! if divmod(12L, -7L) != (-2L, -2L): raise TestFailed, 'divmod(12L, -7L)' ! if divmod(-12L, -7L) != (1L, -5L): raise TestFailed, 'divmod(-12L, -7L)' # ! if divmod(12, 7L) != (1, 5L): raise TestFailed, 'divmod(12, 7L)' ! if divmod(-12, 7L) != (-2, 2L): raise TestFailed, 'divmod(-12, 7L)' ! if divmod(12L, -7) != (-2L, -2): raise TestFailed, 'divmod(12L, -7)' ! if divmod(-12L, -7) != (1L, -5): raise TestFailed, 'divmod(-12L, -7)' # if fcmp(divmod(3.25, 1.0), (3.0, 0.25)): *************** *** 150,176 **** print 'eval' ! if eval('1+1') <> 2: raise TestFailed, 'eval(\'1+1\')' ! if eval(' 1+1\n') <> 2: raise TestFailed, 'eval(\' 1+1\\n\')' globals = {'a': 1, 'b': 2} locals = {'b': 200, 'c': 300} ! if eval('a', globals) <> 1: raise TestFailed, "eval(1) == %s" % eval('a', globals) ! if eval('a', globals, locals) <> 1: raise TestFailed, "eval(2)" ! if eval('b', globals, locals) <> 200: raise TestFailed, "eval(3)" ! if eval('c', globals, locals) <> 300: raise TestFailed, "eval(4)" ! if eval(u'1+1') <> 2: raise TestFailed, 'eval(u\'1+1\')' ! if eval(u' 1+1\n') <> 2: raise TestFailed, 'eval(u\' 1+1\\n\')' globals = {'a': 1, 'b': 2} locals = {'b': 200, 'c': 300} ! if eval(u'a', globals) <> 1: raise TestFailed, "eval(1) == %s" % eval(u'a', globals) ! if eval(u'a', globals, locals) <> 1: raise TestFailed, "eval(2)" ! if eval(u'b', globals, locals) <> 200: raise TestFailed, "eval(3)" ! if eval(u'c', globals, locals) <> 300: raise TestFailed, "eval(4)" --- 150,176 ---- print 'eval' ! if eval('1+1') != 2: raise TestFailed, 'eval(\'1+1\')' ! if eval(' 1+1\n') != 2: raise TestFailed, 'eval(\' 1+1\\n\')' globals = {'a': 1, 'b': 2} locals = {'b': 200, 'c': 300} ! if eval('a', globals) != 1: raise TestFailed, "eval(1) == %s" % eval('a', globals) ! if eval('a', globals, locals) != 1: raise TestFailed, "eval(2)" ! if eval('b', globals, locals) != 200: raise TestFailed, "eval(3)" ! if eval('c', globals, locals) != 300: raise TestFailed, "eval(4)" ! if eval(u'1+1') != 2: raise TestFailed, 'eval(u\'1+1\')' ! if eval(u' 1+1\n') != 2: raise TestFailed, 'eval(u\' 1+1\\n\')' globals = {'a': 1, 'b': 2} locals = {'b': 200, 'c': 300} ! if eval(u'a', globals) != 1: raise TestFailed, "eval(1) == %s" % eval(u'a', globals) ! if eval(u'a', globals, locals) != 1: raise TestFailed, "eval(2)" ! if eval(u'b', globals, locals) != 200: raise TestFailed, "eval(3)" ! if eval(u'c', globals, locals) != 300: raise TestFailed, "eval(4)" *************** *** 182,200 **** f.close() execfile(TESTFN) ! if z <> 2: raise TestFailed, "execfile(1)" globals['z'] = 0 execfile(TESTFN, globals) ! if globals['z'] <> 2: raise TestFailed, "execfile(1)" locals['z'] = 0 execfile(TESTFN, globals, locals) ! if locals['z'] <> 2: raise TestFailed, "execfile(1)" unlink(TESTFN) print 'filter' ! if filter(lambda c: 'a' <= c <= 'z', 'Hello World') <> 'elloorld': raise TestFailed, 'filter (filter a string)' ! if filter(None, [1, 'hello', [], [3], '', None, 9, 0]) <> [1, 'hello', [3], 9]: raise TestFailed, 'filter (remove false values)' ! if filter(lambda x: x > 0, [1, -3, 9, 0, 2]) <> [1, 9, 2]: raise TestFailed, 'filter (keep positives)' class Squares: --- 182,200 ---- f.close() execfile(TESTFN) ! if z != 2: raise TestFailed, "execfile(1)" globals['z'] = 0 execfile(TESTFN, globals) ! if globals['z'] != 2: raise TestFailed, "execfile(1)" locals['z'] = 0 execfile(TESTFN, globals, locals) ! if locals['z'] != 2: raise TestFailed, "execfile(1)" unlink(TESTFN) print 'filter' ! if filter(lambda c: 'a' <= c <= 'z', 'Hello World') != 'elloorld': raise TestFailed, 'filter (filter a string)' ! if filter(None, [1, 'hello', [], [3], '', None, 9, 0]) != [1, 'hello', [3], 9]: raise TestFailed, 'filter (remove false values)' ! if filter(lambda x: x > 0, [1, -3, 9, 0, 2]) != [1, 9, 2]: raise TestFailed, 'filter (keep positives)' class Squares: *************** *** 233,242 **** print 'float' ! if float(3.14) <> 3.14: raise TestFailed, 'float(3.14)' ! if float(314) <> 314.0: raise TestFailed, 'float(314)' ! if float(314L) <> 314.0: raise TestFailed, 'float(314L)' ! if float(" 3.14 ") <> 3.14: raise TestFailed, 'float(" 3.14 ")' ! if float(u" 3.14 ") <> 3.14: raise TestFailed, 'float(u" 3.14 ")' ! if float(u" \u0663.\u0661\u0664 ") <> 3.14: raise TestFailed, 'float(u" \u0663.\u0661\u0664 ")' --- 233,242 ---- print 'float' ! if float(3.14) != 3.14: raise TestFailed, 'float(3.14)' ! if float(314) != 314.0: raise TestFailed, 'float(314)' ! if float(314L) != 314.0: raise TestFailed, 'float(314L)' ! if float(" 3.14 ") != 3.14: raise TestFailed, 'float(" 3.14 ")' ! if float(u" 3.14 ") != 3.14: raise TestFailed, 'float(u" 3.14 ")' ! if float(u" \u0663.\u0661\u0664 ") != 3.14: raise TestFailed, 'float(u" \u0663.\u0661\u0664 ")' *************** *** 277,292 **** print 'int' ! if int(314) <> 314: raise TestFailed, 'int(314)' ! if int(3.14) <> 3: raise TestFailed, 'int(3.14)' ! if int(314L) <> 314: raise TestFailed, 'int(314L)' # Check that conversion from float truncates towards zero ! if int(-3.14) <> -3: raise TestFailed, 'int(-3.14)' ! if int(3.9) <> 3: raise TestFailed, 'int(3.9)' ! if int(-3.9) <> -3: raise TestFailed, 'int(-3.9)' ! if int(3.5) <> 3: raise TestFailed, 'int(3.5)' ! if int(-3.5) <> -3: raise TestFailed, 'int(-3.5)' # Different base: ! if int("10",16) <> 16L: raise TestFailed, 'int("10",16)' ! if int(u"10",16) <> 16L: raise TestFailed, 'int(u"10",16)' # Test conversion from strings and various anomalies L = [ --- 277,292 ---- print 'int' ! if int(314) != 314: raise TestFailed, 'int(314)' ! if int(3.14) != 3: raise TestFailed, 'int(3.14)' ! if int(314L) != 314: raise TestFailed, 'int(314L)' # Check that conversion from float truncates towards zero ! if int(-3.14) != -3: raise TestFailed, 'int(-3.14)' ! if int(3.9) != 3: raise TestFailed, 'int(3.9)' ! if int(-3.9) != -3: raise TestFailed, 'int(-3.9)' ! if int(3.5) != 3: raise TestFailed, 'int(3.5)' ! if int(-3.5) != -3: raise TestFailed, 'int(-3.5)' # Different base: ! if int("10",16) != 16L: raise TestFailed, 'int("10",16)' ! if int(u"10",16) != 16L: raise TestFailed, 'int(u"10",16)' # Test conversion from strings and various anomalies L = [ *************** *** 386,411 **** print 'len' ! if len('123') <> 3: raise TestFailed, 'len(\'123\')' ! if len(()) <> 0: raise TestFailed, 'len(())' ! if len((1, 2, 3, 4)) <> 4: raise TestFailed, 'len((1, 2, 3, 4))' ! if len([1, 2, 3, 4]) <> 4: raise TestFailed, 'len([1, 2, 3, 4])' ! if len({}) <> 0: raise TestFailed, 'len({})' ! if len({'a':1, 'b': 2}) <> 2: raise TestFailed, 'len({\'a\':1, \'b\': 2})' print 'long' ! if long(314) <> 314L: raise TestFailed, 'long(314)' ! if long(3.14) <> 3L: raise TestFailed, 'long(3.14)' ! if long(314L) <> 314L: raise TestFailed, 'long(314L)' # Check that conversion from float truncates towards zero ! if long(-3.14) <> -3L: raise TestFailed, 'long(-3.14)' ! if long(3.9) <> 3L: raise TestFailed, 'long(3.9)' ! if long(-3.9) <> -3L: raise TestFailed, 'long(-3.9)' ! if long(3.5) <> 3L: raise TestFailed, 'long(3.5)' ! if long(-3.5) <> -3L: raise TestFailed, 'long(-3.5)' ! if long("-3") <> -3L: raise TestFailed, 'long("-3")' ! if long(u"-3") <> -3L: raise TestFailed, 'long(u"-3")' # Different base: ! if long("10",16) <> 16L: raise TestFailed, 'long("10",16)' ! if long(u"10",16) <> 16L: raise TestFailed, 'long(u"10",16)' # Check conversions from string (same test set as for int(), and then some) LL = [ --- 386,411 ---- print 'len' ! if len('123') != 3: raise TestFailed, 'len(\'123\')' ! if len(()) != 0: raise TestFailed, 'len(())' ! if len((1, 2, 3, 4)) != 4: raise TestFailed, 'len((1, 2, 3, 4))' ! if len([1, 2, 3, 4]) != 4: raise TestFailed, 'len([1, 2, 3, 4])' ! if len({}) != 0: raise TestFailed, 'len({})' ! if len({'a':1, 'b': 2}) != 2: raise TestFailed, 'len({\'a\':1, \'b\': 2})' print 'long' ! if long(314) != 314L: raise TestFailed, 'long(314)' ! if long(3.14) != 3L: raise TestFailed, 'long(3.14)' ! if long(314L) != 314L: raise TestFailed, 'long(314L)' # Check that conversion from float truncates towards zero ! if long(-3.14) != -3L: raise TestFailed, 'long(-3.14)' ! if long(3.9) != 3L: raise TestFailed, 'long(3.9)' ! if long(-3.9) != -3L: raise TestFailed, 'long(-3.9)' ! if long(3.5) != 3L: raise TestFailed, 'long(3.5)' ! if long(-3.5) != -3L: raise TestFailed, 'long(-3.5)' ! if long("-3") != -3L: raise TestFailed, 'long("-3")' ! if long(u"-3") != -3L: raise TestFailed, 'long(u"-3")' # Different base: ! if long("10",16) != 16L: raise TestFailed, 'long("10",16)' ! if long(u"10",16) != 16L: raise TestFailed, 'long(u"10",16)' # Check conversions from string (same test set as for int(), and then some) LL = [ *************** *** 431,442 **** print 'map' ! if map(None, 'hello world') <> ['h','e','l','l','o',' ','w','o','r','l','d']: raise TestFailed, 'map(None, \'hello world\')' ! if map(None, 'abcd', 'efg') <> \ [('a', 'e'), ('b', 'f'), ('c', 'g'), ('d', None)]: raise TestFailed, 'map(None, \'abcd\', \'efg\')' ! if map(None, range(10)) <> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]: raise TestFailed, 'map(None, range(10))' ! if map(lambda x: x*x, range(1,4)) <> [1, 4, 9]: raise TestFailed, 'map(lambda x: x*x, range(1,4))' try: --- 431,442 ---- print 'map' ! if map(None, 'hello world') != ['h','e','l','l','o',' ','w','o','r','l','d']: raise TestFailed, 'map(None, \'hello world\')' ! if map(None, 'abcd', 'efg') != \ [('a', 'e'), ('b', 'f'), ('c', 'g'), ('d', None)]: raise TestFailed, 'map(None, \'abcd\', \'efg\')' ! if map(None, range(10)) != [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]: raise TestFailed, 'map(None, range(10))' ! if map(lambda x: x*x, range(1,4)) != [1, 4, 9]: raise TestFailed, 'map(lambda x: x*x, range(1,4))' try: *************** *** 445,451 **** def sqrt(x): return pow(x, 0.5) ! if map(lambda x: map(sqrt,x), [[16, 4], [81, 9]]) <> [[4.0, 2.0], [9.0, 3.0]]: raise TestFailed, 'map(lambda x: map(sqrt,x), [[16, 4], [81, 9]])' ! if map(lambda x, y: x+y, [1,3,2], [9,1,4]) <> [10, 4, 6]: raise TestFailed, 'map(lambda x,y: x+y, [1,3,2], [9,1,4])' def plus(*v): --- 445,451 ---- def sqrt(x): return pow(x, 0.5) ! if map(lambda x: map(sqrt,x), [[16, 4], [81, 9]]) != [[4.0, 2.0], [9.0, 3.0]]: raise TestFailed, 'map(lambda x: map(sqrt,x), [[16, 4], [81, 9]])' ! if map(lambda x, y: x+y, [1,3,2], [9,1,4]) != [10, 4, 6]: raise TestFailed, 'map(lambda x,y: x+y, [1,3,2], [9,1,4])' def plus(*v): *************** *** 453,461 **** for i in v: accu = accu + i return accu ! if map(plus, [1, 3, 7]) <> [1, 3, 7]: raise TestFailed, 'map(plus, [1, 3, 7])' ! if map(plus, [1, 3, 7], [4, 9, 2]) <> [1+4, 3+9, 7+2]: raise TestFailed, 'map(plus, [1, 3, 7], [4, 9, 2])' ! if map(plus, [1, 3, 7], [4, 9, 2], [1, 1, 0]) <> [1+4+1, 3+9+1, 7+2+0]: raise TestFailed, 'map(plus, [1, 3, 7], [4, 9, 2], [1, 1, 0])' if map(None, Squares(10)) != [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]: --- 453,461 ---- for i in v: accu = accu + i return accu ! if map(plus, [1, 3, 7]) != [1, 3, 7]: raise TestFailed, 'map(plus, [1, 3, 7])' ! if map(plus, [1, 3, 7], [4, 9, 2]) != [1+4, 3+9, 7+2]: raise TestFailed, 'map(plus, [1, 3, 7], [4, 9, 2])' ! if map(plus, [1, 3, 7], [4, 9, 2], [1, 1, 0]) != [1+4+1, 3+9+1, 7+2+0]: raise TestFailed, 'map(plus, [1, 3, 7], [4, 9, 2], [1, 1, 0])' if map(None, Squares(10)) != [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]: *************** *** 469,488 **** print 'max' ! if max('123123') <> '3': raise TestFailed, 'max(\'123123\')' ! if max(1, 2, 3) <> 3: raise TestFailed, 'max(1, 2, 3)' ! if max((1, 2, 3, 1, 2, 3)) <> 3: raise TestFailed, 'max((1, 2, 3, 1, 2, 3))' ! if max([1, 2, 3, 1, 2, 3]) <> 3: raise TestFailed, 'max([1, 2, 3, 1, 2, 3])' # ! if max(1, 2L, 3.0) <> 3.0: raise TestFailed, 'max(1, 2L, 3.0)' ! if max(1L, 2.0, 3) <> 3: raise TestFailed, 'max(1L, 2.0, 3)' ! if max(1.0, 2, 3L) <> 3L: raise TestFailed, 'max(1.0, 2, 3L)' print 'min' ! if min('123123') <> '1': raise TestFailed, 'min(\'123123\')' ! if min(1, 2, 3) <> 1: raise TestFailed, 'min(1, 2, 3)' ! if min((1, 2, 3, 1, 2, 3)) <> 1: raise TestFailed, 'min((1, 2, 3, 1, 2, 3))' ! if min([1, 2, 3, 1, 2, 3]) <> 1: raise TestFailed, 'min([1, 2, 3, 1, 2, 3])' # ! if min(1, 2L, 3.0) <> 1: raise TestFailed, 'min(1, 2L, 3.0)' ! if min(1L, 2.0, 3) <> 1L: raise TestFailed, 'min(1L, 2.0, 3)' ! if min(1.0, 2, 3L) <> 1.0: raise TestFailed, 'min(1.0, 2, 3L)' --- 469,488 ---- print 'max' ! if max('123123') != '3': raise TestFailed, 'max(\'123123\')' ! if max(1, 2, 3) != 3: raise TestFailed, 'max(1, 2, 3)' ! if max((1, 2, 3, 1, 2, 3)) != 3: raise TestFailed, 'max((1, 2, 3, 1, 2, 3))' ! if max([1, 2, 3, 1, 2, 3]) != 3: raise TestFailed, 'max([1, 2, 3, 1, 2, 3])' # ! if max(1, 2L, 3.0) != 3.0: raise TestFailed, 'max(1, 2L, 3.0)' ! if max(1L, 2.0, 3) != 3: raise TestFailed, 'max(1L, 2.0, 3)' ! if max(1.0, 2, 3L) != 3L: raise TestFailed, 'max(1.0, 2, 3L)' print 'min' ! if min('123123') != '1': raise TestFailed, 'min(\'123123\')' ! if min(1, 2, 3) != 1: raise TestFailed, 'min(1, 2, 3)' ! if min((1, 2, 3, 1, 2, 3)) != 1: raise TestFailed, 'min((1, 2, 3, 1, 2, 3))' ! if min([1, 2, 3, 1, 2, 3]) != 1: raise TestFailed, 'min([1, 2, 3, 1, 2, 3])' # ! if min(1, 2L, 3.0) != 1: raise TestFailed, 'min(1, 2L, 3.0)' ! if min(1L, 2.0, 3) != 1L: raise TestFailed, 'min(1L, 2.0, 3)' ! if min(1.0, 2, 3L) != 1.0: raise TestFailed, 'min(1.0, 2, 3L)' Index: test_b2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b2.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** test_b2.py 2000/11/08 19:51:25 1.20 --- test_b2.py 2000/12/12 23:11:42 1.21 *************** *** 26,75 **** fp = open(TESTFN, 'r') try: ! if fp.readline(4) <> '1+1\n': raise TestFailed, 'readline(4) # exact' ! if fp.readline(4) <> '1+1\n': raise TestFailed, 'readline(4) # exact' ! if fp.readline() <> 'The quick brown fox jumps over the lazy dog.\n': raise TestFailed, 'readline() # default' ! if fp.readline(4) <> 'Dear': raise TestFailed, 'readline(4) # short' ! if fp.readline(100) <> ' John\n': raise TestFailed, 'readline(100)' ! if fp.read(300) <> 'XXX'*100: raise TestFailed, 'read(300)' ! if fp.read(1000) <> 'YYY'*100: raise TestFailed, 'read(1000) # truncate' finally: fp.close() print 'ord' ! if ord(' ') <> 32: raise TestFailed, 'ord(\' \')' ! if ord('A') <> 65: raise TestFailed, 'ord(\'A\')' ! if ord('a') <> 97: raise TestFailed, 'ord(\'a\')' print 'pow' ! if pow(0,0) <> 1: raise TestFailed, 'pow(0,0)' ! if pow(0,1) <> 0: raise TestFailed, 'pow(0,1)' ! if pow(1,0) <> 1: raise TestFailed, 'pow(1,0)' ! if pow(1,1) <> 1: raise TestFailed, 'pow(1,1)' # ! if pow(2,0) <> 1: raise TestFailed, 'pow(2,0)' ! if pow(2,10) <> 1024: raise TestFailed, 'pow(2,10)' ! if pow(2,20) <> 1024*1024: raise TestFailed, 'pow(2,20)' ! if pow(2,30) <> 1024*1024*1024: raise TestFailed, 'pow(2,30)' # ! if pow(-2,0) <> 1: raise TestFailed, 'pow(-2,0)' ! if pow(-2,1) <> -2: raise TestFailed, 'pow(-2,1)' ! if pow(-2,2) <> 4: raise TestFailed, 'pow(-2,2)' ! if pow(-2,3) <> -8: raise TestFailed, 'pow(-2,3)' # ! if pow(0L,0) <> 1: raise TestFailed, 'pow(0L,0)' ! if pow(0L,1) <> 0: raise TestFailed, 'pow(0L,1)' ! if pow(1L,0) <> 1: raise TestFailed, 'pow(1L,0)' ! if pow(1L,1) <> 1: raise TestFailed, 'pow(1L,1)' # ! if pow(2L,0) <> 1: raise TestFailed, 'pow(2L,0)' ! if pow(2L,10) <> 1024: raise TestFailed, 'pow(2L,10)' ! if pow(2L,20) <> 1024*1024: raise TestFailed, 'pow(2L,20)' ! if pow(2L,30) <> 1024*1024*1024: raise TestFailed, 'pow(2L,30)' # ! if pow(-2L,0) <> 1: raise TestFailed, 'pow(-2L,0)' ! if pow(-2L,1) <> -2: raise TestFailed, 'pow(-2L,1)' ! if pow(-2L,2) <> 4: raise TestFailed, 'pow(-2L,2)' ! if pow(-2L,3) <> -8: raise TestFailed, 'pow(-2L,3)' # if fcmp(pow(0.,0), 1.): raise TestFailed, 'pow(0.,0)' --- 26,75 ---- fp = open(TESTFN, 'r') try: ! if fp.readline(4) != '1+1\n': raise TestFailed, 'readline(4) # exact' ! if fp.readline(4) != '1+1\n': raise TestFailed, 'readline(4) # exact' ! if fp.readline() != 'The quick brown fox jumps over the lazy dog.\n': raise TestFailed, 'readline() # default' ! if fp.readline(4) != 'Dear': raise TestFailed, 'readline(4) # short' ! if fp.readline(100) != ' John\n': raise TestFailed, 'readline(100)' ! if fp.read(300) != 'XXX'*100: raise TestFailed, 'read(300)' ! if fp.read(1000) != 'YYY'*100: raise TestFailed, 'read(1000) # truncate' finally: fp.close() print 'ord' ! if ord(' ') != 32: raise TestFailed, 'ord(\' \')' ! if ord('A') != 65: raise TestFailed, 'ord(\'A\')' ! if ord('a') != 97: raise TestFailed, 'ord(\'a\')' print 'pow' ! if pow(0,0) != 1: raise TestFailed, 'pow(0,0)' ! if pow(0,1) != 0: raise TestFailed, 'pow(0,1)' ! if pow(1,0) != 1: raise TestFailed, 'pow(1,0)' ! if pow(1,1) != 1: raise TestFailed, 'pow(1,1)' # ! if pow(2,0) != 1: raise TestFailed, 'pow(2,0)' ! if pow(2,10) != 1024: raise TestFailed, 'pow(2,10)' ! if pow(2,20) != 1024*1024: raise TestFailed, 'pow(2,20)' ! if pow(2,30) != 1024*1024*1024: raise TestFailed, 'pow(2,30)' # ! if pow(-2,0) != 1: raise TestFailed, 'pow(-2,0)' ! if pow(-2,1) != -2: raise TestFailed, 'pow(-2,1)' ! if pow(-2,2) != 4: raise TestFailed, 'pow(-2,2)' ! if pow(-2,3) != -8: raise TestFailed, 'pow(-2,3)' # ! if pow(0L,0) != 1: raise TestFailed, 'pow(0L,0)' ! if pow(0L,1) != 0: raise TestFailed, 'pow(0L,1)' ! if pow(1L,0) != 1: raise TestFailed, 'pow(1L,0)' ! if pow(1L,1) != 1: raise TestFailed, 'pow(1L,1)' # ! if pow(2L,0) != 1: raise TestFailed, 'pow(2L,0)' ! if pow(2L,10) != 1024: raise TestFailed, 'pow(2L,10)' ! if pow(2L,20) != 1024*1024: raise TestFailed, 'pow(2L,20)' ! if pow(2L,30) != 1024*1024*1024: raise TestFailed, 'pow(2L,30)' # ! if pow(-2L,0) != 1: raise TestFailed, 'pow(-2L,0)' ! if pow(-2L,1) != -2: raise TestFailed, 'pow(-2L,1)' ! if pow(-2L,2) != 4: raise TestFailed, 'pow(-2L,2)' ! if pow(-2L,3) != -8: raise TestFailed, 'pow(-2L,3)' # if fcmp(pow(0.,0), 1.): raise TestFailed, 'pow(0.,0)' *************** *** 96,105 **** print 'range' ! if range(3) <> [0, 1, 2]: raise TestFailed, 'range(3)' ! if range(1, 5) <> [1, 2, 3, 4]: raise TestFailed, 'range(1, 5)' ! if range(0) <> []: raise TestFailed, 'range(0)' ! if range(-3) <> []: raise TestFailed, 'range(-3)' ! if range(1, 10, 3) <> [1, 4, 7]: raise TestFailed, 'range(1, 10, 3)' ! if range(5, -5, -3) <> [5, 2, -1, -4]: raise TestFailed, 'range(5, -5, -3)' print 'input and raw_input' --- 96,105 ---- print 'range' ! if range(3) != [0, 1, 2]: raise TestFailed, 'range(3)' ! if range(1, 5) != [1, 2, 3, 4]: raise TestFailed, 'range(1, 5)' ! if range(0) != []: raise TestFailed, 'range(0)' ! if range(-3) != []: raise TestFailed, 'range(-3)' ! if range(1, 10, 3) != [1, 4, 7]: raise TestFailed, 'range(1, 10, 3)' ! if range(5, -5, -3) != [5, 2, -1, -4]: raise TestFailed, 'range(5, -5, -3)' print 'input and raw_input' *************** *** 109,117 **** try: sys.stdin = fp ! if input() <> 2: raise TestFailed, 'input()' ! if input('testing\n') <> 2: raise TestFailed, 'input()' ! if raw_input() <> 'The quick brown fox jumps over the lazy dog.': raise TestFailed, 'raw_input()' ! if raw_input('testing\n') <> 'Dear John': raise TestFailed, 'raw_input(\'testing\\n\')' finally: --- 109,117 ---- try: sys.stdin = fp ! if input() != 2: raise TestFailed, 'input()' ! if input('testing\n') != 2: raise TestFailed, 'input()' ! if raw_input() != 'The quick brown fox jumps over the lazy dog.': raise TestFailed, 'raw_input()' ! if raw_input('testing\n') != 'Dear John': raise TestFailed, 'raw_input(\'testing\\n\')' finally: *************** *** 120,131 **** print 'reduce' ! if reduce(lambda x, y: x+y, ['a', 'b', 'c'], '') <> 'abc': raise TestFailed, 'reduce(): implode a string' if reduce(lambda x, y: x+y, ! [['a', 'c'], [], ['d', 'w']], []) <> ['a','c','d','w']: raise TestFailed, 'reduce(): append' ! if reduce(lambda x, y: x*y, range(2,8), 1) <> 5040: raise TestFailed, 'reduce(): compute 7!' ! if reduce(lambda x, y: x*y, range(2,21), 1L) <> 2432902008176640000L: raise TestFailed, 'reduce(): compute 20!, use long' class Squares: --- 120,131 ---- print 'reduce' ! if reduce(lambda x, y: x+y, ['a', 'b', 'c'], '') != 'abc': raise TestFailed, 'reduce(): implode a string' if reduce(lambda x, y: x+y, ! [['a', 'c'], [], ['d', 'w']], []) != ['a','c','d','w']: raise TestFailed, 'reduce(): append' ! if reduce(lambda x, y: x*y, range(2,8), 1) != 5040: raise TestFailed, 'reduce(): compute 7!' ! if reduce(lambda x, y: x*y, range(2,21), 1L) != 2432902008176640000L: raise TestFailed, 'reduce(): compute 20!, use long' class Squares: *************** *** 160,203 **** print 'repr' ! if repr('') <> '\'\'': raise TestFailed, 'repr(\'\')' ! if repr(0) <> '0': raise TestFailed, 'repr(0)' ! if repr(0L) <> '0L': raise TestFailed, 'repr(0L)' ! if repr(()) <> '()': raise TestFailed, 'repr(())' ! if repr([]) <> '[]': raise TestFailed, 'repr([])' ! if repr({}) <> '{}': raise TestFailed, 'repr({})' print 'round' ! if round(0.0) <> 0.0: raise TestFailed, 'round(0.0)' ! if round(1.0) <> 1.0: raise TestFailed, 'round(1.0)' ! if round(10.0) <> 10.0: raise TestFailed, 'round(10.0)' ! if round(1000000000.0) <> 1000000000.0: raise TestFailed, 'round(1000000000.0)' ! if round(1e20) <> 1e20: raise TestFailed, 'round(1e20)' ! if round(-1.0) <> -1.0: raise TestFailed, 'round(-1.0)' ! if round(-10.0) <> -10.0: raise TestFailed, 'round(-10.0)' ! if round(-1000000000.0) <> -1000000000.0: raise TestFailed, 'round(-1000000000.0)' ! if round(-1e20) <> -1e20: raise TestFailed, 'round(-1e20)' ! if round(0.1) <> 0.0: raise TestFailed, 'round(0.0)' ! if round(1.1) <> 1.0: raise TestFailed, 'round(1.0)' ! if round(10.1) <> 10.0: raise TestFailed, 'round(10.0)' ! if round(1000000000.1) <> 1000000000.0: raise TestFailed, 'round(1000000000.0)' ! if round(-1.1) <> -1.0: raise TestFailed, 'round(-1.0)' ! if round(-10.1) <> -10.0: raise TestFailed, 'round(-10.0)' ! if round(-1000000000.1) <> -1000000000.0: raise TestFailed, 'round(-1000000000.0)' ! if round(0.9) <> 1.0: raise TestFailed, 'round(0.9)' ! if round(9.9) <> 10.0: raise TestFailed, 'round(9.9)' ! if round(999999999.9) <> 1000000000.0: raise TestFailed, 'round(999999999.9)' ! if round(-0.9) <> -1.0: raise TestFailed, 'round(-0.9)' ! if round(-9.9) <> -10.0: raise TestFailed, 'round(-9.9)' ! if round(-999999999.9) <> -1000000000.0: raise TestFailed, 'round(-999999999.9)' --- 160,203 ---- print 'repr' ! if repr('') != '\'\'': raise TestFailed, 'repr(\'\')' ! if repr(0) != '0': raise TestFailed, 'repr(0)' ! if repr(0L) != '0L': raise TestFailed, 'repr(0L)' ! if repr(()) != '()': raise TestFailed, 'repr(())' ! if repr([]) != '[]': raise TestFailed, 'repr([])' ! if repr({}) != '{}': raise TestFailed, 'repr({})' print 'round' ! if round(0.0) != 0.0: raise TestFailed, 'round(0.0)' ! if round(1.0) != 1.0: raise TestFailed, 'round(1.0)' ! if round(10.0) != 10.0: raise TestFailed, 'round(10.0)' ! if round(1000000000.0) != 1000000000.0: raise TestFailed, 'round(1000000000.0)' ! if round(1e20) != 1e20: raise TestFailed, 'round(1e20)' ! if round(-1.0) != -1.0: raise TestFailed, 'round(-1.0)' ! if round(-10.0) != -10.0: raise TestFailed, 'round(-10.0)' ! if round(-1000000000.0) != -1000000000.0: raise TestFailed, 'round(-1000000000.0)' ! if round(-1e20) != -1e20: raise TestFailed, 'round(-1e20)' ! if round(0.1) != 0.0: raise TestFailed, 'round(0.0)' ! if round(1.1) != 1.0: raise TestFailed, 'round(1.0)' ! if round(10.1) != 10.0: raise TestFailed, 'round(10.0)' ! if round(1000000000.1) != 1000000000.0: raise TestFailed, 'round(1000000000.0)' ! if round(-1.1) != -1.0: raise TestFailed, 'round(-1.0)' ! if round(-10.1) != -10.0: raise TestFailed, 'round(-10.0)' ! if round(-1000000000.1) != -1000000000.0: raise TestFailed, 'round(-1000000000.0)' ! if round(0.9) != 1.0: raise TestFailed, 'round(0.9)' ! if round(9.9) != 10.0: raise TestFailed, 'round(9.9)' ! if round(999999999.9) != 1000000000.0: raise TestFailed, 'round(999999999.9)' ! if round(-0.9) != -1.0: raise TestFailed, 'round(-0.9)' ! if round(-9.9) != -10.0: raise TestFailed, 'round(-9.9)' ! if round(-999999999.9) != -1000000000.0: raise TestFailed, 'round(-999999999.9)' *************** *** 208,228 **** print 'str' ! if str('') <> '': raise TestFailed, 'str(\'\')' ! if str(0) <> '0': raise TestFailed, 'str(0)' ! if str(0L) <> '0': raise TestFailed, 'str(0L)' ! if str(()) <> '()': raise TestFailed, 'str(())' ! if str([]) <> '[]': raise TestFailed, 'str([])' ! if str({}) <> '{}': raise TestFailed, 'str({})' print 'tuple' ! if tuple(()) <> (): raise TestFailed, 'tuple(())' ! if tuple((0, 1, 2, 3)) <> (0, 1, 2, 3): raise TestFailed, 'tuple((0, 1, 2, 3))' ! if tuple([]) <> (): raise TestFailed, 'tuple([])' ! if tuple([0, 1, 2, 3]) <> (0, 1, 2, 3): raise TestFailed, 'tuple([0, 1, 2, 3])' ! if tuple('') <> (): raise TestFailed, 'tuple('')' ! if tuple('spam') <> ('s', 'p', 'a', 'm'): raise TestFailed, "tuple('spam')" print 'type' ! if type('') <> type('123') or type('') == type(()): raise TestFailed, 'type()' --- 208,228 ---- print 'str' ! if str('') != '': raise TestFailed, 'str(\'\')' ! if str(0) != '0': raise TestFailed, 'str(0)' ! if str(0L) != '0': raise TestFailed, 'str(0L)' ! if str(()) != '()': raise TestFailed, 'str(())' ! if str([]) != '[]': raise TestFailed, 'str([])' ! if str({}) != '{}': raise TestFailed, 'str({})' print 'tuple' ! if tuple(()) != (): raise TestFailed, 'tuple(())' ! if tuple((0, 1, 2, 3)) != (0, 1, 2, 3): raise TestFailed, 'tuple((0, 1, 2, 3))' ! if tuple([]) != (): raise TestFailed, 'tuple([])' ! if tuple([0, 1, 2, 3]) != (0, 1, 2, 3): raise TestFailed, 'tuple([0, 1, 2, 3])' ! if tuple('') != (): raise TestFailed, 'tuple('')' ! if tuple('spam') != ('s', 'p', 'a', 'm'): raise TestFailed, "tuple('spam')" print 'type' ! if type('') != type('123') or type('') == type(()): raise TestFailed, 'type()' *************** *** 233,237 **** a.sort() b.sort() ! if a <> b: raise TestFailed, 'vars()' import sys a = vars(sys).keys() --- 233,237 ---- a.sort() b.sort() ! if a != b: raise TestFailed, 'vars()' import sys a = vars(sys).keys() *************** *** 239,243 **** a.sort() b.sort() ! if a <> b: raise TestFailed, 'vars(sys)' def f0(): if vars() != {}: raise TestFailed, 'vars() in f0()' --- 239,243 ---- a.sort() b.sort() ! if a != b: raise TestFailed, 'vars(sys)' def f0(): if vars() != {}: raise TestFailed, 'vars() in f0()' *************** *** 251,257 **** print 'xrange' ! 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)' # regression tests for SourceForge bug #121695 --- 251,257 ---- print 'xrange' ! 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)' # regression tests for SourceForge bug #121695 *************** *** 274,287 **** b = (4, 5, 6) t = [(1, 4), (2, 5), (3, 6)] ! if zip(a, b) <> t: raise TestFailed, 'zip(a, b) - same size, both tuples' b = [4, 5, 6] ! if zip(a, b) <> t: raise TestFailed, 'zip(a, b) - same size, tuple/list' b = (4, 5, 6, 7) ! if zip(a, b) <> t: raise TestFailed, 'zip(a, b) - b is longer' class I: def __getitem__(self, i): if i < 0 or i > 2: raise IndexError return i + 4 ! if zip(a, I()) <> t: raise TestFailed, 'zip(a, b) - b is instance' exc = 0 try: --- 274,287 ---- b = (4, 5, 6) t = [(1, 4), (2, 5), (3, 6)] ! if zip(a, b) != t: raise TestFailed, 'zip(a, b) - same size, both tuples' b = [4, 5, 6] ! if zip(a, b) != t: raise TestFailed, 'zip(a, b) - same size, tuple/list' b = (4, 5, 6, 7) ! if zip(a, b) != t: raise TestFailed, 'zip(a, b) - b is longer' class I: def __getitem__(self, i): if i < 0 or i > 2: raise IndexError return i + 4 ! if zip(a, I()) != t: raise TestFailed, 'zip(a, b) - b is instance' exc = 0 try: Index: test_binascii.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_binascii.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_binascii.py 2000/08/15 06:08:31 1.6 --- test_binascii.py 2000/12/12 23:11:42 1.7 *************** *** 97,101 **** t = binascii.b2a_hex(s) u = binascii.a2b_hex(t) ! if s <> u: print 'binascii hexlification failed' try: --- 97,101 ---- t = binascii.b2a_hex(s) u = binascii.a2b_hex(t) ! if s != u: print 'binascii hexlification failed' try: Index: test_binhex.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_binhex.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_binhex.py 2000/10/23 17:22:07 1.6 --- test_binhex.py 2000/12/12 23:11:42 1.7 *************** *** 33,38 **** finish = f.readline() ! if start <> finish: ! print 'Error: binhex <> hexbin' elif verbose: print 'binhex == hexbin' --- 33,38 ---- finish = f.readline() ! if start != finish: ! print 'Error: binhex != hexbin' elif verbose: print 'binhex == hexbin' Index: test_bsddb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_bsddb.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** test_bsddb.py 2000/10/23 17:22:07 1.4 --- test_bsddb.py 2000/12/12 23:11:42 1.5 *************** *** 35,40 **** rec = f.next() except KeyError: ! if rec <> f.last(): ! print 'Error, last <> last!' f.previous() break --- 35,40 ---- rec = f.next() except KeyError: ! if rec != f.last(): ! print 'Error, last != last!' f.previous() break Index: test_grammar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_grammar.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** test_grammar.py 2000/10/23 17:22:07 1.20 --- test_grammar.py 2000/12/12 23:11:42 1.21 *************** *** 13,27 **** x = 1 \ + 1 ! if x <> 2: raise TestFailed, 'backslash for line continuation' # Backslash does not means continuation in comments :\ x = 0 ! if x <> 0: raise TestFailed, 'backslash ending comment' print '1.1.2 Numeric literals' print '1.1.2.1 Plain integers' ! if 0xff <> 255: raise TestFailed, 'hex int' ! if 0377 <> 255: raise TestFailed, 'octal int' if 2147483647 != 017777777777: raise TestFailed, 'large positive int' try: --- 13,27 ---- x = 1 \ + 1 ! if x != 2: raise TestFailed, 'backslash for line continuation' # Backslash does not means continuation in comments :\ x = 0 ! if x != 0: raise TestFailed, 'backslash ending comment' print '1.1.2 Numeric literals' print '1.1.2.1 Plain integers' ! if 0xff != 255: raise TestFailed, 'hex int' ! if 0377 != 255: raise TestFailed, 'octal int' if 2147483647 != 017777777777: raise TestFailed, 'large positive int' try: *************** *** 360,379 **** del z exec 'z=1+1\n' ! if z <> 2: raise TestFailed, 'exec \'z=1+1\'\\n' del z exec 'z=1+1' ! if z <> 2: raise TestFailed, 'exec \'z=1+1\'' z = None del z exec u'z=1+1\n' ! if z <> 2: raise TestFailed, 'exec u\'z=1+1\'\\n' del z exec u'z=1+1' ! if z <> 2: raise TestFailed, 'exec u\'z=1+1\'' f() g = {} exec 'z = 1' in g if g.has_key('__builtins__'): del g['__builtins__'] ! if g <> {'z': 1}: raise TestFailed, 'exec \'z = 1\' in g' g = {} l = {} --- 360,379 ---- del z exec 'z=1+1\n' ! if z != 2: raise TestFailed, 'exec \'z=1+1\'\\n' del z exec 'z=1+1' ! if z != 2: raise TestFailed, 'exec \'z=1+1\'' z = None del z exec u'z=1+1\n' ! if z != 2: raise TestFailed, 'exec u\'z=1+1\'\\n' del z exec u'z=1+1' ! if z != 2: raise TestFailed, 'exec u\'z=1+1\'' f() g = {} exec 'z = 1' in g if g.has_key('__builtins__'): del g['__builtins__'] ! if g != {'z': 1}: raise TestFailed, 'exec \'z = 1\' in g' g = {} l = {} *************** *** 381,385 **** if g.has_key('__builtins__'): del g['__builtins__'] if l.has_key('__builtins__'): del l['__builtins__'] ! if (g, l) <> ({'a':1}, {'b':2}): raise TestFailed, 'exec ... in g, l' --- 381,385 ---- if g.has_key('__builtins__'): del g['__builtins__'] if l.has_key('__builtins__'): del l['__builtins__'] ! if (g, l) != ({'a':1}, {'b':2}): raise TestFailed, 'exec ... in g, l' Index: test_math.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_math.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** test_math.py 2000/10/23 17:22:07 1.9 --- test_math.py 2000/12/12 23:11:42 1.10 *************** *** 86,90 **** print 'frexp' def testfrexp(name, (mant, exp), (emant, eexp)): ! if abs(mant-emant) > eps or exp <> eexp: raise TestFailed, '%s returned %s, expected %s'%\ (name, `mant, exp`, `emant,eexp`) --- 86,90 ---- print 'frexp' def testfrexp(name, (mant, exp), (emant, eexp)): ! if abs(mant-emant) > eps or exp != eexp: raise TestFailed, '%s returned %s, expected %s'%\ (name, `mant, exp`, `emant,eexp`) Index: test_md5.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_md5.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_md5.py 2000/10/23 17:22:07 1.3 --- test_md5.py 2000/12/12 23:11:42 1.4 *************** *** 27,30 **** m = md5('testing the hexdigest method') h = m.hexdigest() ! if hexstr(m.digest()) <> h: print 'hexdigest() failed' --- 27,30 ---- m = md5('testing the hexdigest method') h = m.hexdigest() ! if hexstr(m.digest()) != h: print 'hexdigest() failed' Index: test_mmap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mmap.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** test_mmap.py 2000/10/23 17:22:07 1.11 --- test_mmap.py 2000/12/12 23:11:42 1.12 *************** *** 47,51 **** # Test doing a regular expression match in an mmap'ed file match=re.search('[A-Za-z]+', m) ! if match == None: print ' ERROR: regex match on mmap failed!' else: --- 47,51 ---- # Test doing a regular expression match in an mmap'ed file match=re.search('[A-Za-z]+', m) ! if match is None: print ' ERROR: regex match on mmap failed!' else: Index: test_new.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_new.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** test_new.py 1998/03/26 19:42:19 1.5 --- test_new.py 2000/12/12 23:11:42 1.6 *************** *** 34,41 **** print im ! if c.get_yolks() <> 3 and c.get_more_yolks() <> 6: print 'Broken call of hand-crafted class instance' im() ! if c.get_yolks() <> 1 and c.get_more_yolks() <> 4: print 'Broken call of hand-crafted instance method' --- 34,41 ---- print im ! if c.get_yolks() != 3 and c.get_more_yolks() != 6: print 'Broken call of hand-crafted class instance' im() ! if c.get_yolks() != 1 and c.get_more_yolks() != 4: print 'Broken call of hand-crafted instance method' *************** *** 54,58 **** print func func() ! if g['c'] <> 3: print 'Could not create a proper function object' --- 54,58 ---- print func func() ! if g['c'] != 3: print 'Could not create a proper function object' Index: test_nis.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_nis.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** test_nis.py 2000/08/04 13:34:43 1.8 --- test_nis.py 2000/12/12 23:11:42 1.9 *************** *** 22,26 **** if not k: continue ! if nis.match(k, nismap) <> v: print "NIS match failed for key `%s' in map `%s'" % (k, nismap) else: --- 22,26 ---- if not k: continue ! if nis.match(k, nismap) != v: print "NIS match failed for key `%s' in map `%s'" % (k, nismap) else: Index: test_opcodes.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_opcodes.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** test_opcodes.py 2000/10/23 17:22:07 1.8 --- test_opcodes.py 2000/12/12 23:11:42 1.9 *************** *** 20,24 **** finally: pass n = n+i ! if n <> 90: raise TestFailed, 'try inside for' --- 20,24 ---- finally: pass n = n+i ! if n != 90: raise TestFailed, 'try inside for' Index: test_operator.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_operator.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_operator.py 1998/03/26 19:42:25 1.3 --- test_operator.py 2000/12/12 23:11:42 1.4 *************** *** 10,14 **** except: val = sys.exc_type ! if val <> output: print '%s%s = %s: %s expected' % (f.__name__, params, `val`, `output`) --- 10,14 ---- except: val = sys.exc_type ! if val != output: print '%s%s = %s: %s expected' % (f.__name__, params, `val`, `output`) *************** *** 22,31 **** a = [4, 3, 2, 1] test('delitem', a, None, 1) ! if a <> [4, 2, 1]: print 'delitem() failed' a = range(10) test('delslice', a, None, 2, 8) ! if a <> [0, 1, 8, 9]: print 'delslice() failed' --- 22,31 ---- a = [4, 3, 2, 1] test('delitem', a, None, 1) ! if a != [4, 2, 1]: print 'delitem() failed' a = range(10) test('delslice', a, None, 2, 8) ! if a != [0, 1, 8, 9]: print 'delslice() failed' *************** *** 60,69 **** test('setitem', a, None, 0, 2) ! if a <> [2, 1, 2]: print 'setitem() failed' a = range(4) test('setslice', a, None, 1, 3, [2, 1]) ! if a <> [0, 2, 1, 3]: print 'setslice() failed:', a --- 60,69 ---- test('setitem', a, None, 0, 2) ! if a != [2, 1, 2]: print 'setitem() failed' a = range(4) test('setslice', a, None, 1, 3, [2, 1]) ! if a != [0, 2, 1, 3]: print 'setslice() failed:', a Index: test_pow.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pow.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_pow.py 2000/10/23 17:22:07 1.6 --- test_pow.py 2000/12/12 23:11:42 1.7 *************** *** 111,119 **** n = pow(i,j,k) if o != n: print 'Integer mismatch:', i,j,k ! if j >= 0 and k <> 0: o = pow(long(i),j) % k n = pow(long(i),j,k) if o != n: print 'Long mismatch:', i,j,k ! if i >= 0 and k <> 0: o = pow(float(i),j) % k n = pow(float(i),j,k) --- 111,119 ---- n = pow(i,j,k) if o != n: print 'Integer mismatch:', i,j,k ! if j >= 0 and k != 0: o = pow(long(i),j) % k n = pow(long(i),j,k) if o != n: print 'Long mismatch:', i,j,k ! if i >= 0 and k != 0: o = pow(float(i),j) % k n = pow(float(i),j,k) Index: test_pty.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pty.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_pty.py 2000/10/23 17:22:07 1.6 --- test_pty.py 2000/12/12 23:11:42 1.7 *************** *** 82,86 **** elif status / 256 == 3: raise TestFailed, "Child spawned by pty.fork() did not have a tty as stdout" ! elif status / 256 <> 4: raise TestFailed, "pty.fork() failed for unknown reasons:" print os.read(master_fd, 65536) --- 82,86 ---- elif status / 256 == 3: raise TestFailed, "Child spawned by pty.fork() did not have a tty as stdout" ! elif status / 256 != 4: raise TestFailed, "pty.fork() failed for unknown reasons:" print os.read(master_fd, 65536) Index: test_pwd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pwd.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** test_pwd.py 2000/10/23 17:22:07 1.7 --- test_pwd.py 2000/12/12 23:11:42 1.8 *************** *** 13,21 **** print 'pwd.getpwuid()' dbuid = pwd.getpwuid(uid) ! if dbuid[0] <> name: print 'Mismatch in pwd.getpwuid()' print 'pwd.getpwnam()' dbname = pwd.getpwnam(name) ! if dbname[2] <> uid: print 'Mismatch in pwd.getpwnam()' else: --- 13,21 ---- print 'pwd.getpwuid()' dbuid = pwd.getpwuid(uid) ! if dbuid[0] != name: print 'Mismatch in pwd.getpwuid()' print 'pwd.getpwnam()' dbname = pwd.getpwnam(name) ! if dbname[2] != uid: print 'Mismatch in pwd.getpwnam()' else: Index: test_re.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_re.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** test_re.py 2000/10/23 17:22:08 1.26 --- test_re.py 2000/12/12 23:11:42 1.27 *************** *** 16,20 **** assert re.search('x+', 'axx').span(0) == (1, 3) assert re.search('x+', 'axx').span() == (1, 3) ! assert re.search('x', 'aaa') == None except: raise TestFailed, "re.search" --- 16,20 ---- assert re.search('x+', 'axx').span(0) == (1, 3) assert re.search('x+', 'axx').span() == (1, 3) ! assert re.search('x', 'aaa') is None except: raise TestFailed, "re.search" *************** *** 25,29 **** assert re.match('x*', 'xxxa').span(0) == (0, 3) assert re.match('x*', 'xxxa').span() == (0, 3) ! assert re.match('a+', 'xxx') == None except: raise TestFailed, "re.search" --- 25,29 ---- assert re.match('x*', 'xxxa').span(0) == (0, 3) assert re.match('x*', 'xxxa').span() == (0, 3) ! assert re.match('a+', 'xxx') is None except: raise TestFailed, "re.search" *************** *** 217,225 **** for i in range(0, 256): p = p + chr(i) ! assert re.match(re.escape(chr(i)), chr(i)) != None assert re.match(re.escape(chr(i)), chr(i)).span() == (0,1) pat=re.compile( re.escape(p) ) ! assert pat.match(p) != None assert pat.match(p).span() == (0,256) except AssertionError: --- 217,225 ---- for i in range(0, 256): p = p + chr(i) ! assert re.match(re.escape(chr(i)), chr(i)) is not None assert re.match(re.escape(chr(i)), chr(i)).span() == (0,1) pat=re.compile( re.escape(p) ) ! assert pat.match(p) is not None assert pat.match(p).span() == (0,256) except AssertionError: *************** *** 336,340 **** # still succeeds. result = obj.search(unicode(s, "latin-1")) ! if result == None: print '=== Fails on unicode match', t --- 336,340 ---- # still succeeds. result = obj.search(unicode(s, "latin-1")) ! if result is None: print '=== Fails on unicode match', t *************** *** 343,347 **** obj=re.compile(unicode(pattern, "latin-1")) result = obj.search(s) ! if result == None: print '=== Fails on unicode pattern match', t --- 343,347 ---- obj=re.compile(unicode(pattern, "latin-1")) result = obj.search(s) ! if result is None: print '=== Fails on unicode pattern match', t *************** *** 352,359 **** if pattern[:2] != '\\B' and pattern[-2:] != '\\B' \ ! and result != None: obj = re.compile(pattern) result = obj.search(s, result.start(0), result.end(0) + 1) ! if result == None: print '=== Failed on range-limited match', t --- 352,359 ---- if pattern[:2] != '\\B' and pattern[-2:] != '\\B' \ ! and result is not None: obj = re.compile(pattern) result = obj.search(s, result.start(0), result.end(0) + 1) ! if result is None: print '=== Failed on range-limited match', t *************** *** 362,366 **** obj = re.compile(pattern, re.IGNORECASE) result = obj.search(s) ! if result == None: print '=== Fails on case-insensitive match', t --- 362,366 ---- obj = re.compile(pattern, re.IGNORECASE) result = obj.search(s) ! if result is None: print '=== Fails on case-insensitive match', t *************** *** 369,373 **** obj = re.compile(pattern, re.LOCALE) result = obj.search(s) ! if result == None: print '=== Fails on locale-sensitive match', t --- 369,373 ---- obj = re.compile(pattern, re.LOCALE) result = obj.search(s) ! if result is None: print '=== Fails on locale-sensitive match', t *************** *** 376,379 **** obj = re.compile(pattern, re.UNICODE) result = obj.search(s) ! if result == None: print '=== Fails on unicode-sensitive match', t --- 376,379 ---- obj = re.compile(pattern, re.UNICODE) result = obj.search(s) ! if result is None: print '=== Fails on unicode-sensitive match', t Index: test_rotor.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_rotor.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** test_rotor.py 1997/08/18 13:42:28 1.4 --- test_rotor.py 2000/12/12 23:11:42 1.5 *************** *** 14,23 **** A1 = r.decrypt(a) print A1 ! if A1 <> A: print 'decrypt failed' B1 = r.decryptmore(b) print B1 ! if B1 <> B: print 'decryptmore failed' --- 14,23 ---- A1 = r.decrypt(a) print A1 ! if A1 != A: print 'decrypt failed' B1 = r.decryptmore(b) print B1 ! if B1 != B: print 'decryptmore failed' Index: test_sax.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sax.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** test_sax.py 2000/10/24 16:00:22 1.13 --- test_sax.py 2000/12/12 23:11:42 1.14 *************** *** 396,401 **** parser.close() ! return parser.getSystemId() == None and \ ! parser.getPublicId() == None and \ parser.getLineNumber() == 1 --- 396,401 ---- parser.close() ! return parser.getSystemId() is None and \ ! parser.getPublicId() is None and \ parser.getLineNumber() == 1 *************** *** 408,412 **** return parser.getSystemId() == findfile("test.xml") and \ ! parser.getPublicId() == None --- 408,412 ---- return parser.getSystemId() == findfile("test.xml") and \ ! parser.getPublicId() is None *************** *** 485,489 **** not attrs.has_key("attr") and \ attrs.keys() == [] and \ ! attrs.get("attrs") == None and \ attrs.get("attrs", 25) == 25 and \ attrs.items() == [] and \ --- 485,489 ---- not attrs.has_key("attr") and \ attrs.keys() == [] and \ ! attrs.get("attrs") is None and \ attrs.get("attrs", 25) == 25 and \ attrs.items() == [] and \ *************** *** 553,557 **** not attrs.has_key((ns_uri, "attr")) and \ attrs.keys() == [] and \ ! attrs.get((ns_uri, "attr")) == None and \ attrs.get((ns_uri, "attr"), 25) == 25 and \ attrs.items() == [] and \ --- 553,557 ---- not attrs.has_key((ns_uri, "attr")) and \ attrs.keys() == [] and \ ! attrs.get((ns_uri, "attr")) is None and \ attrs.get((ns_uri, "attr"), 25) == 25 and \ attrs.items() == [] and \ Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** test_socket.py 2000/06/29 17:00:54 1.14 --- test_socket.py 2000/12/12 23:11:42 1.15 *************** *** 138,142 **** s.send(msg) data = s.recv(1024) ! if msg <> data: print 'parent/client mismatch' s.close() --- 138,142 ---- s.send(msg) data = s.recv(1024) ! if msg != data: print 'parent/client mismatch' s.close() Index: test_sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sre.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** test_sre.py 2000/10/28 19:30:41 1.13 --- test_sre.py 2000/12/12 23:11:42 1.14 *************** *** 48,57 **** for i in [0, 8, 16, 32, 64, 127, 128, 255]: ! test(r"""sre.match(r"\%03o" % i, chr(i)) != None""", 1) ! test(r"""sre.match(r"\%03o0" % i, chr(i)+"0") != None""", 1) ! test(r"""sre.match(r"\%03o8" % i, chr(i)+"8") != None""", 1) ! test(r"""sre.match(r"\x%02x" % i, chr(i)) != None""", 1) ! test(r"""sre.match(r"\x%02x0" % i, chr(i)+"0") != None""", 1) ! test(r"""sre.match(r"\x%02xz" % i, chr(i)+"z") != None""", 1) test(r"""sre.match("\911", "")""", None, sre.error) --- 48,57 ---- for i in [0, 8, 16, 32, 64, 127, 128, 255]: ! test(r"""sre.match(r"\%03o" % i, chr(i)) is not None""", 1) ! test(r"""sre.match(r"\%03o0" % i, chr(i)+"0") is not None""", 1) ! test(r"""sre.match(r"\%03o8" % i, chr(i)+"8") is not None""", 1) ! test(r"""sre.match(r"\x%02x" % i, chr(i)) is not None""", 1) ! test(r"""sre.match(r"\x%02x0" % i, chr(i)+"0") is not None""", 1) ! test(r"""sre.match(r"\x%02xz" % i, chr(i)+"z") is not None""", 1) test(r"""sre.match("\911", "")""", None, sre.error) *************** *** 198,206 **** for i in range(0, 256): p = p + chr(i) ! test(r"""sre.match(sre.escape(chr(i)), chr(i)) != None""", 1) test(r"""sre.match(sre.escape(chr(i)), chr(i)).span()""", (0,1)) pat = sre.compile(sre.escape(p)) ! test(r"""pat.match(p) != None""", 1) test(r"""pat.match(p).span()""", (0,256)) --- 198,206 ---- for i in range(0, 256): p = p + chr(i) ! test(r"""sre.match(sre.escape(chr(i)), chr(i)) is not None""", 1) test(r"""sre.match(sre.escape(chr(i)), chr(i)).span()""", (0,1)) pat = sre.compile(sre.escape(p)) ! test(r"""pat.match(p) is not None""", 1) test(r"""pat.match(p).span()""", (0,256)) Index: test_struct.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_struct.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_struct.py 2000/10/23 17:22:08 1.6 --- test_struct.py 2000/12/12 23:11:42 1.7 *************** *** 16,20 **** sz = struct.calcsize('i') ! if sz * 3 <> struct.calcsize('iii'): raise TestFailed, 'inconsistent sizes' --- 16,20 ---- sz = struct.calcsize('i') ! if sz * 3 != struct.calcsize('iii'): raise TestFailed, 'inconsistent sizes' *************** *** 23,27 **** sz = struct.calcsize(fmt) sz3 = struct.calcsize(fmt3) ! if sz * 3 <> sz3: raise TestFailed, 'inconsistent sizes (3*%s -> 3*%d = %d, %s -> %d)' % ( `fmt`, sz, 3*sz, `fmt3`, sz3) --- 23,27 ---- sz = struct.calcsize(fmt) sz3 = struct.calcsize(fmt3) ! if sz * 3 != sz3: raise TestFailed, 'inconsistent sizes (3*%s -> 3*%d = %d, %s -> %d)' % ( `fmt`, sz, 3*sz, `fmt3`, sz3) *************** *** 50,55 **** s = struct.pack(format, c, b, h, i, l, f, d) cp, bp, hp, ip, lp, fp, dp = struct.unpack(format, s) ! if (cp <> c or bp <> b or hp <> h or ip <> i or lp <> l or ! int(100 * fp) <> int(100 * f) or int(100 * dp) <> int(100 * d)): # ^^^ calculate only to two decimal places raise TestFailed, "unpack/pack not transitive (%s, %s)" % ( --- 50,55 ---- s = struct.pack(format, c, b, h, i, l, f, d) cp, bp, hp, ip, lp, fp, dp = struct.unpack(format, s) ! if (cp != c or bp != b or hp != h or ip != i or lp != l or ! int(100 * fp) != int(100 * f) or int(100 * dp) != int(100 * d)): # ^^^ calculate only to two decimal places raise TestFailed, "unpack/pack not transitive (%s, %s)" % ( Index: test_support.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_support.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** test_support.py 2000/10/23 17:22:08 1.8 --- test_support.py 2000/12/12 23:11:42 1.9 *************** *** 53,57 **** for i in range(min(len(x), len(y))): outcome = fcmp(x[i], y[i]) ! if outcome <> 0: return outcome return cmp(len(x), len(y)) --- 53,57 ---- for i in range(min(len(x), len(y))): outcome = fcmp(x[i], y[i]) ! if outcome != 0: return outcome return cmp(len(x), len(y)) Index: test_time.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_time.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** test_time.py 1998/03/26 19:42:56 1.5 --- test_time.py 2000/12/12 23:11:42 1.6 *************** *** 5,14 **** t = time.time() time.asctime(time.gmtime(t)) ! if time.ctime(t) <> time.asctime(time.localtime(t)): ! print 'time.ctime(t) <> time.asctime(time.localtime(t))' time.daylight ! if long(time.mktime(time.localtime(t))) <> long(t): ! print 'time.mktime(time.localtime(t)) <> t' time.sleep(1.2) --- 5,14 ---- t = time.time() time.asctime(time.gmtime(t)) ! if time.ctime(t) != time.asctime(time.localtime(t)): ! print 'time.ctime(t) != time.asctime(time.localtime(t))' time.daylight ! if long(time.mktime(time.localtime(t))) != long(t): ! print 'time.mktime(time.localtime(t)) != t' time.sleep(1.2) Index: test_types.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** test_types.py 2000/12/12 22:02:59 1.18 --- test_types.py 2000/12/12 23:11:42 1.19 *************** *** 37,45 **** print '6.3 Comparisons' ! if 0 < 1 <= 1 == 1 >= 1 > 0 <> 1: pass else: raise TestFailed, 'int comparisons failed' ! if 0L < 1L <= 1L == 1L >= 1L > 0L <> 1L: pass else: raise TestFailed, 'long int comparisons failed' ! if 0.0 < 1.0 <= 1.0 == 1.0 >= 1.0 > 0.0 <> 1.0: pass else: raise TestFailed, 'float comparisons failed' if '' < 'a' <= 'a' == 'a' < 'abc' < 'abd' < 'b': pass --- 37,45 ---- print '6.3 Comparisons' ! if 0 < 1 <= 1 == 1 >= 1 > 0 != 1: pass else: raise TestFailed, 'int comparisons failed' ! if 0L < 1L <= 1L == 1L >= 1L > 0L != 1L: pass else: raise TestFailed, 'long int comparisons failed' ! if 0.0 < 1.0 <= 1.0 == 1.0 >= 1.0 > 0.0 != 1.0: pass else: raise TestFailed, 'float comparisons failed' if '' < 'a' <= 'a' == 'a' < 'abc' < 'abd' < 'b': pass *************** *** 51,57 **** print '6.4 Numeric types (mostly conversions)' ! if 0 <> 0L or 0 <> 0.0 or 0L <> 0.0: raise TestFailed, 'mixed comparisons' ! if 1 <> 1L or 1 <> 1.0 or 1L <> 1.0: raise TestFailed, 'mixed comparisons' ! if -1 <> -1L or -1 <> -1.0 or -1L <> -1.0: raise TestFailed, 'int/long/float value not equal' if int(1.9) == 1 == int(1.1) and int(-1.1) == -1 == int(-1.9): pass --- 51,57 ---- print '6.4 Numeric types (mostly conversions)' ! if 0 != 0L or 0 != 0.0 or 0L != 0.0: raise TestFailed, 'mixed comparisons' ! if 1 != 1L or 1 != 1.0 or 1L != 1.0: raise TestFailed, 'mixed comparisons' ! if -1 != -1L or -1 != -1.0 or -1L != -1.0: raise TestFailed, 'int/long/float value not equal' if int(1.9) == 1 == int(1.1) and int(-1.1) == -1 == int(-1.9): pass *************** *** 62,69 **** else: raise TestFailed, 'float() does not work properly' print '6.4.1 32-bit integers' ! if 12 + 24 <> 36: raise TestFailed, 'int op' ! if 12 + (-24) <> -12: raise TestFailed, 'int op' ! if (-12) + 24 <> 12: raise TestFailed, 'int op' ! if (-12) + (-24) <> -36: raise TestFailed, 'int op' if not 12 < 24: raise TestFailed, 'int op' if not -24 < -12: raise TestFailed, 'int op' --- 62,69 ---- else: raise TestFailed, 'float() does not work properly' print '6.4.1 32-bit integers' ! if 12 + 24 != 36: raise TestFailed, 'int op' ! if 12 + (-24) != -12: raise TestFailed, 'int op' ! if (-12) + 24 != 12: raise TestFailed, 'int op' ! if (-12) + (-24) != -36: raise TestFailed, 'int op' if not 12 < 24: raise TestFailed, 'int op' if not -24 < -12: raise TestFailed, 'int op' *************** *** 73,80 **** raise TestFailed, 'int mul commutativity' print '6.4.2 Long integers' ! if 12L + 24L <> 36L: raise TestFailed, 'long op' ! if 12L + (-24L) <> -12L: raise TestFailed, 'long op' ! if (-12L) + 24L <> 12L: raise TestFailed, 'long op' ! if (-12L) + (-24L) <> -36L: raise TestFailed, 'long op' if not 12L < 24L: raise TestFailed, 'long op' if not -24L < -12L: raise TestFailed, 'long op' --- 73,80 ---- raise TestFailed, 'int mul commutativity' print '6.4.2 Long integers' ! if 12L + 24L != 36L: raise TestFailed, 'long op' ! if 12L + (-24L) != -12L: raise TestFailed, 'long op' ! if (-12L) + 24L != 12L: raise TestFailed, 'long op' ! if (-12L) + (-24L) != -36L: raise TestFailed, 'long op' if not 12L < 24L: raise TestFailed, 'long op' if not -24L < -12L: raise TestFailed, 'long op' *************** *** 92,99 **** else:raise TestFailed, 'long op' print '6.4.3 Floating point numbers' ! if 12.0 + 24.0 <> 36.0: raise TestFailed, 'float op' ! if 12.0 + (-24.0) <> -12.0: raise TestFailed, 'float op' ! if (-12.0) + 24.0 <> 12.0: raise TestFailed, 'float op' ! if (-12.0) + (-24.0) <> -36.0: raise TestFailed, 'float op' if not 12.0 < 24.0: raise TestFailed, 'float op' if not -24.0 < -12.0: raise TestFailed, 'float op' --- 92,99 ---- else:raise TestFailed, 'long op' print '6.4.3 Floating point numbers' ! if 12.0 + 24.0 != 36.0: raise TestFailed, 'float op' ! if 12.0 + (-24.0) != -12.0: raise TestFailed, 'float op' ! if (-12.0) + 24.0 != 12.0: raise TestFailed, 'float op' ! if (-12.0) + (-24.0) != -36.0: raise TestFailed, 'float op' if not 12.0 < 24.0: raise TestFailed, 'float op' if not -24.0 < -12.0: raise TestFailed, 'float op' *************** *** 102,112 **** print '6.5.1 Strings' ! if len('') <> 0: raise TestFailed, 'len(\'\')' ! if len('a') <> 1: raise TestFailed, 'len(\'a\')' ! if len('abcdef') <> 6: raise TestFailed, 'len(\'abcdef\')' ! if 'xyz' + 'abcde' <> 'xyzabcde': raise TestFailed, 'string concatenation' ! if 'xyz'*3 <> 'xyzxyzxyz': raise TestFailed, 'string repetition *3' ! if 0*'abcde' <> '': raise TestFailed, 'string repetition 0*' ! if min('abc') <> 'a' or max('abc') <> 'c': raise TestFailed, 'min/max string' if 'a' in 'abc' and 'b' in 'abc' and 'c' in 'abc' and 'd' not in 'abc': pass else: raise TestFailed, 'in/not in string' --- 102,112 ---- print '6.5.1 Strings' ! if len('') != 0: raise TestFailed, 'len(\'\')' ! if len('a') != 1: raise TestFailed, 'len(\'a\')' ! if len('abcdef') != 6: raise TestFailed, 'len(\'abcdef\')' ! if 'xyz' + 'abcde' != 'xyzabcde': raise TestFailed, 'string concatenation' ! if 'xyz'*3 != 'xyzxyzxyz': raise TestFailed, 'string repetition *3' ! if 0*'abcde' != '': raise TestFailed, 'string repetition 0*' ! if min('abc') != 'a' or max('abc') != 'c': raise TestFailed, 'min/max string' if 'a' in 'abc' and 'b' in 'abc' and 'c' in 'abc' and 'd' not in 'abc': pass else: raise TestFailed, 'in/not in string' *************** *** 115,138 **** print '6.5.2 Tuples' ! if len(()) <> 0: raise TestFailed, 'len(())' ! if len((1,)) <> 1: raise TestFailed, 'len((1,))' ! if len((1,2,3,4,5,6)) <> 6: raise TestFailed, 'len((1,2,3,4,5,6))' ! if (1,2)+(3,4) <> (1,2,3,4): raise TestFailed, 'tuple concatenation' ! if (1,2)*3 <> (1,2,1,2,1,2): raise TestFailed, 'tuple repetition *3' ! if 0*(1,2,3) <> (): raise TestFailed, 'tuple repetition 0*' ! if min((1,2)) <> 1 or max((1,2)) <> 2: raise TestFailed, 'min/max tuple' if 0 in (0,1,2) and 1 in (0,1,2) and 2 in (0,1,2) and 3 not in (0,1,2): pass else: raise TestFailed, 'in/not in tuple' print '6.5.3 Lists' ! if len([]) <> 0: raise TestFailed, 'len([])' ! if len([1,]) <> 1: raise TestFailed, 'len([1,])' ! if len([1,2,3,4,5,6]) <> 6: raise TestFailed, 'len([1,2,3,4,5,6])' ! if [1,2]+[3,4] <> [1,2,3,4]: raise TestFailed, 'list concatenation' ! if [1,2]*3 <> [1,2,1,2,1,2]: raise TestFailed, 'list repetition *3' ! if [1,2]*3L <> [1,2,1,2,1,2]: raise TestFailed, 'list repetition *3L' ! if 0*[1,2,3] <> []: raise TestFailed, 'list repetition 0*' ! if 0L*[1,2,3] <> []: raise TestFailed, 'list repetition 0L*' ! if min([1,2]) <> 1 or max([1,2]) <> 2: raise TestFailed, 'min/max list' if 0 in [0,1,2] and 1 in [0,1,2] and 2 in [0,1,2] and 3 not in [0,1,2]: pass else: raise TestFailed, 'in/not in list' --- 115,138 ---- print '6.5.2 Tuples' ! if len(()) != 0: raise TestFailed, 'len(())' ! if len((1,)) != 1: raise TestFailed, 'len((1,))' ! if len((1,2,3,4,5,6)) != 6: raise TestFailed, 'len((1,2,3,4,5,6))' ! if (1,2)+(3,4) != (1,2,3,4): raise TestFailed, 'tuple concatenation' ! if (1,2)*3 != (1,2,1,2,1,2): raise TestFailed, 'tuple repetition *3' ! if 0*(1,2,3) != (): raise TestFailed, 'tuple repetition 0*' ! if min((1,2)) != 1 or max((1,2)) != 2: raise TestFailed, 'min/max tuple' if 0 in (0,1,2) and 1 in (0,1,2) and 2 in (0,1,2) and 3 not in (0,1,2): pass else: raise TestFailed, 'in/not in tuple' print '6.5.3 Lists' ! if len([]) != 0: raise TestFailed, 'len([])' ! if len([1,]) != 1: raise TestFailed, 'len([1,])' ! if len([1,2,3,4,5,6]) != 6: raise TestFailed, 'len([1,2,3,4,5,6])' ! if [1,2]+[3,4] != [1,2,3,4]: raise TestFailed, 'list concatenation' ! if [1,2]*3 != [1,2,1,2,1,2]: raise TestFailed, 'list repetition *3' ! if [1,2]*3L != [1,2,1,2,1,2]: raise TestFailed, 'list repetition *3L' ! if 0*[1,2,3] != []: raise TestFailed, 'list repetition 0*' ! if 0L*[1,2,3] != []: raise TestFailed, 'list repetition 0L*' ! if min([1,2]) != 1 or max([1,2]) != 2: raise TestFailed, 'min/max list' if 0 in [0,1,2] and 1 in [0,1,2] and 2 in [0,1,2] and 3 not in [0,1,2]: pass else: raise TestFailed, 'in/not in list' *************** *** 156,208 **** a[1L] = 2 a[2L] = 3 ! if a <> [1,2,3,3,4]: raise TestFailed, 'list item assignment [0L], [1L], [2L]' a[0] = 5 a[1] = 6 a[2] = 7 ! if a <> [5,6,7,3,4]: raise TestFailed, 'list item assignment [0], [1], [2]' a[-2L] = 88 a[-1L] = 99 ! if a <> [5,6,7,88,99]: raise TestFailed, 'list item assignment [-2L], [-1L]' a[-2] = 8 a[-1] = 9 ! if a <> [5,6,7,8,9]: raise TestFailed, 'list item assignment [-2], [-1]' a[:2] = [0,4] a[-3:] = [] a[1:1] = [1,2,3] ! if a <> [0,1,2,3,4]: raise TestFailed, 'list slice assignment' a[ 1L : 4L] = [7,8,9] ! if a <> [0,7,8,9,4]: raise TestFailed, 'list slice assignment using long ints' del a[1:4] ! if a <> [0,4]: raise TestFailed, 'list slice deletion' del a[0] ! if a <> [4]: raise TestFailed, 'list item deletion [0]' del a[-1] ! if a <> []: raise TestFailed, 'list item deletion [-1]' a=range(0,5) del a[1L:4L] ! if a <> [0,4]: raise TestFailed, 'list slice deletion' del a[0L] ! if a <> [4]: raise TestFailed, 'list item deletion [0]' del a[-1L] ! if a <> []: raise TestFailed, 'list item deletion [-1]' a.append(0) a.append(1) a.append(2) ! if a <> [0,1,2]: raise TestFailed, 'list append' a.insert(0, -2) a.insert(1, -1) a.insert(2,0) ! if a <> [-2,-1,0,0,1,2]: raise TestFailed, 'list insert' ! if a.count(0) <> 2: raise TestFailed, ' list count' ! if a.index(0) <> 2: raise TestFailed, 'list index' a.remove(0) ! if a <> [-2,-1,0,1,2]: raise TestFailed, 'list remove' a.reverse() ! if a <> [2,1,0,-1,-2]: raise TestFailed, 'list reverse' a.sort() ! if a <> [-2,-1,0,1,2]: raise TestFailed, 'list sort' def revcmp(a, b): return cmp(b, a) a.sort(revcmp) ! if a <> [2,1,0,-1,-2]: raise TestFailed, 'list sort with cmp func' # The following dumps core in unpatched Python 1.5: def myComparison(x,y): --- 156,208 ---- a[1L] = 2 a[2L] = 3 ! if a != [1,2,3,3,4]: raise TestFailed, 'list item assignment [0L], [1L], [2L]' a[0] = 5 a[1] = 6 a[2] = 7 ! if a != [5,6,7,3,4]: raise TestFailed, 'list item assignment [0], [1], [2]' a[-2L] = 88 a[-1L] = 99 ! if a != [5,6,7,88,99]: raise TestFailed, 'list item assignment [-2L], [-1L]' a[-2] = 8 a[-1] = 9 ! if a != [5,6,7,8,9]: raise TestFailed, 'list item assignment [-2], [-1]' a[:2] = [0,4] a[-3:] = [] a[1:1] = [1,2,3] ! if a != [0,1,2,3,4]: raise TestFailed, 'list slice assignment' a[ 1L : 4L] = [7,8,9] ! if a != [0,7,8,9,4]: raise TestFailed, 'list slice assignment using long ints' del a[1:4] ! if a != [0,4]: raise TestFailed, 'list slice deletion' del a[0] ! if a != [4]: raise TestFailed, 'list item deletion [0]' del a[-1] ! if a != []: raise TestFailed, 'list item deletion [-1]' a=range(0,5) del a[1L:4L] ! if a != [0,4]: raise TestFailed, 'list slice deletion' del a[0L] ! if a != [4]: raise TestFailed, 'list item deletion [0]' del a[-1L] ! if a != []: raise TestFailed, 'list item deletion [-1]' a.append(0) a.append(1) a.append(2) ! if a != [0,1,2]: raise TestFailed, 'list append' a.insert(0, -2) a.insert(1, -1) a.insert(2,0) ! if a != [-2,-1,0,0,1,2]: raise TestFailed, 'list insert' ! if a.count(0) != 2: raise TestFailed, ' list count' ! if a.index(0) != 2: raise TestFailed, 'list index' a.remove(0) ! if a != [-2,-1,0,1,2]: raise TestFailed, 'list remove' a.reverse() ! if a != [2,1,0,-1,-2]: raise TestFailed, 'list reverse' a.sort() ! if a != [-2,-1,0,1,2]: raise TestFailed, 'list sort' def revcmp(a, b): return cmp(b, a) a.sort(revcmp) ! if a != [2,1,0,-1,-2]: raise TestFailed, 'list sort with cmp func' # The following dumps core in unpatched Python 1.5: def myComparison(x,y): *************** *** 220,239 **** print '6.6 Mappings == Dictionaries' d = {} ! if d.keys() <> []: raise TestFailed, '{}.keys()' ! if d.has_key('a') <> 0: raise TestFailed, '{}.has_key(\'a\')' ! if len(d) <> 0: raise TestFailed, 'len({})' d = {'a': 1, 'b': 2} ! if len(d) <> 2: raise TestFailed, 'len(dict)' k = d.keys() k.sort() ! if k <> ['a', 'b']: raise TestFailed, 'dict keys()' if d.has_key('a') and d.has_key('b') and not d.has_key('c'): pass else: raise TestFailed, 'dict keys()' ! if d['a'] <> 1 or d['b'] <> 2: raise TestFailed, 'dict item' d['c'] = 3 d['a'] = 4 ! if d['c'] <> 3 or d['a'] <> 4: raise TestFailed, 'dict item assignment' del d['b'] ! if d <> {'a': 4, 'c': 3}: raise TestFailed, 'dict item deletion' d = {1:1, 2:2, 3:3} d.clear() --- 220,239 ---- print '6.6 Mappings == Dictionaries' d = {} ! if d.keys() != []: raise TestFailed, '{}.keys()' ! if d.has_key('a') != 0: raise TestFailed, '{}.has_key(\'a\')' ! if len(d) != 0: raise TestFailed, 'len({})' d = {'a': 1, 'b': 2} ! if len(d) != 2: raise TestFailed, 'len(dict)' k = d.keys() k.sort() ! if k != ['a', 'b']: raise TestFailed, 'dict keys()' if d.has_key('a') and d.has_key('b') and not d.has_key('c'): pass else: raise TestFailed, 'dict keys()' ! if d['a'] != 1 or d['b'] != 2: raise TestFailed, 'dict item' d['c'] = 3 d['a'] = 4 ! if d['c'] != 3 or d['a'] != 4: raise TestFailed, 'dict item assignment' del d['b'] ! if d != {'a': 4, 'c': 3}: raise TestFailed, 'dict item deletion' d = {1:1, 2:2, 3:3} d.clear() *************** *** 247,254 **** # dict.get() d = {} ! if d.get('c') != None: raise TestFailed, 'missing {} get, no 2nd arg' if d.get('c', 3) != 3: raise TestFailed, 'missing {} get, w/ 2nd arg' d = {'a' : 1, 'b' : 2} ! if d.get('c') != None: raise TestFailed, 'missing dict get, no 2nd arg' if d.get('c', 3) != 3: raise TestFailed, 'missing dict get, w/ 2nd arg' if d.get('a') != 1: raise TestFailed, 'present dict get, no 2nd arg' --- 247,254 ---- # dict.get() d = {} ! if d.get('c') is not None: raise TestFailed, 'missing {} get, no 2nd arg' if d.get('c', 3) != 3: raise TestFailed, 'missing {} get, w/ 2nd arg' d = {'a' : 1, 'b' : 2} ! if d.get('c') is not None: raise TestFailed, 'missing dict get, no 2nd arg' if d.get('c', 3) != 3: raise TestFailed, 'missing dict get, w/ 2nd arg' if d.get('a') != 1: raise TestFailed, 'present dict get, no 2nd arg' *************** *** 256,268 **** # dict.setdefault() d = {} ! if d.setdefault('key0') <> None: raise TestFailed, 'missing {} setdefault, no 2nd arg' ! if d.setdefault('key0') <> None: raise TestFailed, 'present {} setdefault, no 2nd arg' d.setdefault('key', []).append(3) ! if d['key'][0] <> 3: raise TestFailed, 'missing {} setdefault, w/ 2nd arg' d.setdefault('key', []).append(4) ! if len(d['key']) <> 2: raise TestFailed, 'present {} setdefault, w/ 2nd arg' # dict.popitem() --- 256,268 ---- # dict.setdefault() d = {} ! if d.setdefault('key0') is not None: raise TestFailed, 'missing {} setdefault, no 2nd arg' ! if d.setdefault('key0') is not None: raise TestFailed, 'present {} setdefault, no 2nd arg' d.setdefault('key', []).append(3) ! if d['key'][0] != 3: raise TestFailed, 'missing {} setdefault, w/ 2nd arg' d.setdefault('key', []).append(4) ! if len(d['key']) != 2: raise TestFailed, 'present {} setdefault, w/ 2nd arg' # dict.popitem() Index: test_unpack.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unpack.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** test_unpack.py 2000/10/12 14:45:58 1.4 --- test_unpack.py 2000/12/12 23:11:42 1.5 *************** *** 17,21 **** print 'unpack tuple' a, b, c = t ! if a <> 1 or b <> 2 or c <> 3: raise TestFailed --- 17,21 ---- print 'unpack tuple' a, b, c = t ! if a != 1 or b != 2 or c != 3: raise TestFailed *************** *** 24,28 **** print 'unpack list' a, b, c = l ! if a <> 4 or b <> 5 or c <> 6: raise TestFailed --- 24,28 ---- print 'unpack list' a, b, c = l ! if a != 4 or b != 5 or c != 6: raise TestFailed *************** *** 31,35 **** print 'unpack implied tuple' a, b, c = 7, 8, 9 ! if a <> 7 or b <> 8 or c <> 9: raise TestFailed --- 31,35 ---- print 'unpack implied tuple' a, b, c = 7, 8, 9 ! if a != 7 or b != 8 or c != 9: raise TestFailed *************** *** 38,42 **** print 'unpack string' a, b, c = 'one' ! if a <> 'o' or b <> 'n' or c <> 'e': raise TestFailed --- 38,42 ---- print 'unpack string' a, b, c = 'one' ! if a != 'o' or b != 'n' or c != 'e': raise TestFailed *************** *** 45,49 **** print 'unpack sequence' a, b, c = Seq() ! if a <> 0 or b <> 1 or c <> 2: raise TestFailed --- 45,49 ---- print 'unpack sequence' a, b, c = Seq() ! if a != 0 or b != 1 or c != 2: raise TestFailed *************** *** 54,61 **** sl = [100] a, = st ! if a <> 99: raise TestFailed b, = sl ! if b <> 100: raise TestFailed --- 54,61 ---- sl = [100] a, = st ! if a != 99: raise TestFailed b, = sl ! if b != 100: raise TestFailed From python-dev@python.org Tue Dec 12 23:11:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 12 Dec 2000 15:11:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-old Para.py,1.6,1.7 cmp.py,1.1,1.2 cmpcache.py,1.1,1.2 dircmp.py,1.1,1.2 fmt.py,1.5,1.6 grep.py,1.7,1.8 packmail.py,1.7,1.8 tb.py,1.7,1.8 zmod.py,1.1,1.2 Message-ID: <200012122311.PAA18731@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/lib-old In directory slayer.i.sourceforge.net:/tmp/cvs-serv18670/lib-old Modified Files: Para.py cmp.py cmpcache.py dircmp.py fmt.py grep.py packmail.py tb.py zmod.py Log Message: Update the code to better reflect recommended style: Use != instead of <> since <> is documented as "obsolescent". Use "is" and "is not" when comparing with None or type objects. Index: Para.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/Para.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** Para.py 2000/07/16 12:04:31 1.6 --- Para.py 2000/12/12 23:11:41 1.7 *************** *** 29,33 **** # (font, text, width, space, stretch, ascent, descent) def addword(self, d, font, text, space, stretch): ! if font <> None: d.setfont(font) width = d.textwidth(text) --- 29,33 ---- # (font, text, width, space, stretch, ascent, descent) def addword(self, d, font, text, space, stretch): ! if font is not None: d.setfont(font) width = d.textwidth(text) *************** *** 51,55 **** total = 0 for word in self.words: ! if type(word) <> Int: total = total + word[2] + word[3] return total --- 51,55 ---- total = 0 for word in self.words: ! if type(word) is not Int: total = total + word[2] + word[3] return total *************** *** 64,68 **** for i in range(len(self.words)): word = self.words[i] ! if type(word) == Int: continue (fo, te, wi, sp, st, as, de) = word self.words[i] = (fo, te, wi, sp, 0, as, de) --- 64,68 ---- for i in range(len(self.words)): word = self.words[i] ! if type(word) is Int: continue (fo, te, wi, sp, st, as, de) = word self.words[i] = (fo, te, wi, sp, 0, as, de) *************** *** 100,104 **** while i < n: word = words[i] ! if type(word) == Int: if word > 0 and width >= avail: break --- 100,104 ---- while i < n: word = words[i] ! if type(word) is Int: if word > 0 and width >= avail: break *************** *** 108,112 **** if width + wi > avail and width > 0 and wi > 0: break ! if fo <> None: lastfont = fo if width == 0: --- 108,112 ---- if width + wi > avail and width > 0 and wi > 0: break ! if fo is not None: lastfont = fo if width == 0: *************** *** 120,124 **** descent = max(descent, de) i = i+1 ! while i > j and type(words[i-1]) == Int and \ words[i-1] > 0: i = i-1 width = width - lsp --- 120,124 ---- descent = max(descent, de) i = i+1 ! while i > j and type(words[i-1]) is Int and \ words[i-1] > 0: i = i-1 width = width - lsp *************** *** 153,160 **** for j in range(i, i+wordcount): word = self.words[j] ! if type(word) == Int: ok = anchorfunc(self, tuple, word, \ h, v) ! if ok <> None: return ok continue fo, te, wi, sp, st, as, de = word --- 153,160 ---- for j in range(i, i+wordcount): word = self.words[j] ! if type(word) is Int: ok = anchorfunc(self, tuple, word, \ h, v) ! if ok is not None: return ok continue fo, te, wi, sp, st, as, de = word *************** *** 168,172 **** ok = wordfunc(self, tuple, word, h, v, \ h2, v2, (j==i), (j==i+wordcount-1)) ! if ok <> None: return ok h = h2 v = v2 --- 168,172 ---- ok = wordfunc(self, tuple, word, h, v, \ h2, v2, (j==i), (j==i+wordcount-1)) ! if ok is not None: return ok h = h2 v = v2 *************** *** 178,182 **** # Return the computed bottom of the text. def render(self, d, left, top, right): ! if self.width <> right-left: self.layout(right-left) self.left = left --- 178,182 ---- # Return the computed bottom of the text. def render(self, d, left, top, right): ! if self.width != right-left: self.layout(right-left) self.left = left *************** *** 194,198 **** # def _renderword(self, tuple, word, h, v, h2, v2, isfirst, islast): ! if word[0] <> None: self.d.setfont(word[0]) baseline = v + tuple[5] self.d.text((h, baseline - word[5]), word[1]) --- 194,198 ---- # def _renderword(self, tuple, word, h, v, h2, v2, isfirst, islast): ! if word[0] is not None: self.d.setfont(word[0]) baseline = v + tuple[5] self.d.text((h, baseline - word[5]), word[1]) *************** *** 230,234 **** text = '' for w in self.words: ! if type(w) <> Int: word = w[1] if w[3]: word = word + ' ' --- 230,234 ---- text = '' for w in self.words: ! if type(w) is not Int: word = w[1] if w[3]: word = word + ' ' *************** *** 255,259 **** def _whereisword(self, tuple, word, h1, v1, h2, v2, isfirst, islast): fo, te, wi, sp, st, as, de = word ! if fo <> None: self.lastfont = fo h = h1 if isfirst: h1 = 0 --- 255,259 ---- def _whereisword(self, tuple, word, h1, v1, h2, v2, isfirst, islast): fo, te, wi, sp, st, as, de = word ! if fo is not None: self.lastfont = fo h = h1 if isfirst: h1 = 0 *************** *** 262,266 **** self.charcount = self.charcount + len(te) + (sp > 0) return ! if self.lastfont <> None: self.d.setfont(self.lastfont) cc = 0 --- 262,266 ---- self.charcount = self.charcount + len(te) + (sp > 0) return ! if self.lastfont is not None: self.d.setfont(self.lastfont) cc = 0 *************** *** 296,300 **** finally: self.d = None ! if ok == None: ascent, descent = self.lines[-1][5:7] ok = self.right, self.bottom - ascent - descent, \ --- 296,300 ---- finally: self.d = None ! if ok is None: ascent, descent = self.lines[-1][5:7] ok = self.right, self.bottom - ascent - descent, \ *************** *** 304,308 **** def _screenposword(self, tuple, word, h1, v1, h2, v2, isfirst, islast): fo, te, wi, sp, st, as, de = word ! if fo <> None: self.lastfont = fo cc = len(te) + (sp > 0) if self.pos > cc: --- 304,308 ---- def _screenposword(self, tuple, word, h1, v1, h2, v2, isfirst, islast): fo, te, wi, sp, st, as, de = word ! if fo is not None: self.lastfont = fo cc = len(te) + (sp > 0) if self.pos > cc: *************** *** 325,333 **** # Undoes its own effect when called again with the same arguments def invert(self, d, pos1, pos2): ! if pos1 == None: pos1 = self.left, self.top, self.top, self.top else: pos1 = self.screenpos(d, pos1) ! if pos2 == None: pos2 = self.right, self.bottom,self.bottom,self.bottom else: --- 325,333 ---- # Undoes its own effect when called again with the same arguments def invert(self, d, pos1, pos2): ! if pos1 is None: pos1 = self.left, self.top, self.top, self.top else: pos1 = self.screenpos(d, pos1) ! if pos2 is None: pos2 = self.right, self.bottom,self.bottom,self.bottom else: Index: cmp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/cmp.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** cmp.py 2000/02/03 15:25:32 1.1 --- cmp.py 2000/12/12 23:11:41 1.2 *************** *** 17,21 **** Raise exceptions if either file could not be statted, read, etc.""" s1, s2 = sig(os.stat(f1)), sig(os.stat(f2)) ! if s1[0] <> 8 or s2[0] <> 8: # Either is a not a plain file -- always report as different return 0 --- 17,21 ---- Raise exceptions if either file could not be statted, read, etc.""" s1, s2 = sig(os.stat(f1)), sig(os.stat(f2)) ! if s1[0] != 8 or s2[0] != 8: # Either is a not a plain file -- always report as different return 0 *************** *** 23,27 **** # type, size & mtime match -- report same return 1 ! if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother # types or sizes differ -- report different return 0 --- 23,27 ---- # type, size & mtime match -- report same return 1 ! if s1[:2] != s2[:2]: # Types or sizes differ, don't bother # types or sizes differ -- report different return 0 *************** *** 60,63 **** b1 = fp1.read(bufsize) b2 = fp2.read(bufsize) ! if b1 <> b2: return 0 if not b1: return 1 --- 60,63 ---- b1 = fp1.read(bufsize) b2 = fp2.read(bufsize) ! if b1 != b2: return 0 if not b1: return 1 Index: cmpcache.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/cmpcache.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** cmpcache.py 2000/02/03 15:25:32 1.1 --- cmpcache.py 2000/12/12 23:11:41 1.2 *************** *** 31,35 **** # type, size & mtime match -- report same return 1 ! if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother # types or sizes differ -- report different return 0 --- 31,35 ---- # type, size & mtime match -- report same return 1 ! if s1[:2] != s2[:2]: # Types or sizes differ, don't bother # types or sizes differ -- report different return 0 *************** *** 61,64 **** b1 = fp1.read(bufsize) b2 = fp2.read(bufsize) ! if b1 <> b2: return 0 if not b1: return 1 --- 61,64 ---- b1 = fp1.read(bufsize) b2 = fp2.read(bufsize) ! if b1 != b2: return 0 if not b1: return 1 Index: dircmp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/dircmp.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** dircmp.py 2000/02/03 15:25:32 1.1 --- dircmp.py 2000/12/12 23:11:41 1.2 *************** *** 71,75 **** a_type = S_IFMT(a_stat[ST_MODE]) b_type = S_IFMT(b_stat[ST_MODE]) ! if a_type <> b_type: self.common_funny.append(x) elif S_ISDIR(a_type): --- 71,75 ---- a_type = S_IFMT(a_stat[ST_MODE]) b_type = S_IFMT(b_stat[ST_MODE]) ! if a_type != b_type: self.common_funny.append(x) elif S_ISDIR(a_type): *************** *** 190,194 **** import getopt options, args = getopt.getopt(sys.argv[1:], 'r') ! if len(args) <> 2: raise getopt.error, 'need exactly two args' dd = dircmp().new(args[0], args[1]) dd.run() --- 190,195 ---- import getopt options, args = getopt.getopt(sys.argv[1:], 'r') ! if len(args) != 2: ! raise getopt.error, 'need exactly two args' dd = dircmp().new(args[0], args[1]) dd.run() Index: fmt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/fmt.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** fmt.py 2000/02/27 15:34:29 1.5 --- fmt.py 2000/12/12 23:11:41 1.6 *************** *** 69,73 **** p = self.paralist[i] result = p.whereis(d, h, v) ! if result <> None: return i, result return None --- 69,73 ---- p = self.paralist[i] result = p.whereis(d, h, v) ! if result is not None: return i, result return None *************** *** 76,80 **** i, offset = long1 text = self.paralist[i].extract() ! while offset > 0 and text[offset-1] <> ' ': offset = offset-1 long1 = i, offset # --- 76,80 ---- i, offset = long1 text = self.paralist[i].extract() ! while offset > 0 and text[offset-1] != ' ': offset = offset-1 long1 = i, offset # *************** *** 82,86 **** text = self.paralist[i].extract() n = len(text) ! while offset < n-1 and text[offset] <> ' ': offset = offset+1 long2 = i, offset # --- 82,86 ---- text = self.paralist[i].extract() n = len(text) ! while offset < n-1 and text[offset] != ' ': offset = offset+1 long2 = i, offset # *************** *** 160,164 **** # def setfont(self, font): ! if font == None: return self.font = self.nextfont = font d = self.d --- 160,164 ---- # def setfont(self, font): ! if font is None: return self.font = self.nextfont = font d = self.d *************** *** 194,198 **** self.b.addpara(self.para) self.para = None ! if self.font <> None: self.d.setfont(self.font) self.nospace = 1 --- 194,198 ---- self.b.addpara(self.para) self.para = None ! if self.font is not None: self.d.setfont(self.font) self.nospace = 1 *************** *** 339,344 **** for i in range(len(para.words)): fo, te, wi = para.words[i][:3] ! if fo <> None: curfont = fo ! if curfont <> oldfont: if closechar.has_key(oldfont): c = closechar[oldfont] --- 339,344 ---- for i in range(len(para.words)): fo, te, wi = para.words[i][:3] ! if fo is not None: curfont = fo ! if curfont != oldfont: if closechar.has_key(oldfont): c = closechar[oldfont] *************** *** 431,435 **** pos2 = long2[:3] new = pos1, pos2 ! if new <> self.selection: d = self.window.begindrawing() if self.selection: --- 431,435 ---- pos2 = long2[:3] new = pos1, pos2 ! if new != self.selection: d = self.window.begindrawing() if self.selection: *************** *** 463,467 **** def search(self, prog): import re, string ! if type(prog) == type(''): prog = re.compile(string.lower(prog)) if self.selection: --- 463,467 ---- def search(self, prog): import re, string ! if type(prog) is type(''): prog = re.compile(string.lower(prog)) if self.selection: *************** *** 552,556 **** self.fontcache[key] = handle self.fontkey = fontkey ! if self.fonthandle <> handle: self.fonthandle = handle self.fontinfo = handle.getfontinfo() --- 552,556 ---- self.fontcache[key] = handle self.fontkey = fontkey ! if self.fonthandle != handle: self.fonthandle = handle self.fontinfo = handle.getfontinfo() *************** *** 583,587 **** oldhandle = self.fonthandle GLFontCache.setfont(fontkey) ! if self.fonthandle <> oldhandle: handle.setfont() --- 583,587 ---- oldhandle = self.fonthandle GLFontCache.setfont(fontkey) ! if self.fonthandle != oldhandle: handle.setfont() *************** *** 613,617 **** gl.winset(self.wid) width = gl.getsize()[1] ! if width <> self.width: setdocsize = 1 self.width = width --- 613,617 ---- gl.winset(self.wid) width = gl.getsize()[1] ! if width != self.width: setdocsize = 1 self.width = width Index: grep.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/grep.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** grep.py 1997/10/22 20:44:58 1.7 --- grep.py 2000/12/12 23:11:41 1.8 *************** *** 74,78 **** prefix = ' ' * len(prefix) for c in line: ! if c <> '\t': c = ' ' prefix = prefix + c if start == end: prefix = prefix + '\\' --- 74,78 ---- prefix = ' ' * len(prefix) for c in line: ! if c != '\t': c = ' ' prefix = prefix + c if start == end: prefix = prefix + '\\' Index: packmail.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/packmail.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** packmail.py 1998/04/28 16:03:03 1.7 --- packmail.py 2000/12/12 23:11:41 1.8 *************** *** 26,30 **** line = fp.readline() if not line: break ! if line[-1:] <> '\n': line = line + '\n' outfp.write('X' + line) --- 26,30 ---- line = fp.readline() if not line: break ! if line[-1:] != '\n': line = line + '\n' outfp.write('X' + line) Index: tb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/tb.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** tb.py 1997/09/29 23:21:47 1.7 --- tb.py 2000/12/12 23:11:41 1.8 *************** *** 24,28 **** tb = tblist[ptr] while 1: ! if tb <> tblist[ptr]: tb = tblist[ptr] print `ptr` + ':', --- 24,28 ---- tb = tblist[ptr] while 1: ! if tb != tblist[ptr]: tb = tblist[ptr] print `ptr` + ':', *************** *** 77,85 **** t, v = sys.exc_info()[:2] print '*** Exception:', ! if type(t) == type(''): print t, else: print t.__name__, ! if v <> None: print ':', v, print --- 77,85 ---- t, v = sys.exc_info()[:2] print '*** Exception:', ! if type(t) is type(''): print t, else: print t.__name__, ! if v is not None: print ':', v, print *************** *** 128,149 **** def printobject(v, maxlevel): ! if v == None: print 'None', elif type(v) in (type(0), type(0.0)): print v, ! elif type(v) == type(''): if len(v) > 20: print `v[:17] + '...'`, else: print `v`, ! elif type(v) == type(()): print '(', printlist(v, maxlevel) print ')', ! elif type(v) == type([]): print '[', printlist(v, maxlevel) print ']', ! elif type(v) == type({}): print '{', printdict(v, maxlevel) --- 128,149 ---- def printobject(v, maxlevel): ! if v is None: print 'None', elif type(v) in (type(0), type(0.0)): print v, ! elif type(v) is type(''): if len(v) > 20: print `v[:17] + '...'`, else: print `v`, ! elif type(v) is type(()): print '(', printlist(v, maxlevel) print ')', ! elif type(v) is type([]): print '[', printlist(v, maxlevel) print ']', ! elif type(v) is type({}): print '{', printdict(v, maxlevel) Index: zmod.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/zmod.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** zmod.py 1998/11/02 15:38:51 1.1 --- zmod.py 2000/12/12 23:11:41 1.2 *************** *** 83,87 **** def rj(s, width): ! if type(s) <> type(''): s = `s` n = len(s) if n >= width: return s --- 83,87 ---- def rj(s, width): ! if type(s) is not type(''): s = `s` n = len(s) if n >= width: return s *************** *** 89,93 **** def lj(s, width): ! if type(s) <> type(''): s = `s` n = len(s) if n >= width: return s --- 89,93 ---- def lj(s, width): ! if type(s) is not type(''): s = `s` n = len(s) if n >= width: return s From python-dev@python.org Tue Dec 12 23:11:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 12 Dec 2000 15:11:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-irix6 FL.py,1.1,1.2 cdplayer.py,1.3,1.4 flp.py,1.6,1.7 jpeg.py,1.3,1.4 panel.py,1.2,1.3 panelparser.py,1.1,1.2 readcd.py,1.2,1.3 torgb.py,1.2,1.3 Message-ID: <200012122311.PAA18760@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/plat-irix6 In directory slayer.i.sourceforge.net:/tmp/cvs-serv18670/plat-irix6 Modified Files: FL.py cdplayer.py flp.py jpeg.py panel.py panelparser.py readcd.py torgb.py Log Message: Update the code to better reflect recommended style: Use != instead of <> since <> is documented as "obsolescent". Use "is" and "is not" when comparing with None or type objects. Index: FL.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/FL.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** FL.py 1997/01/15 19:18:42 1.1 --- FL.py 2000/12/12 23:11:42 1.2 *************** *** 8,12 **** ##import fl ##try: ! ## _v20 = (fl.get_rgbmode <> None) ##except: ## _v20 = 0 --- 8,12 ---- ##import fl ##try: ! ## _v20 = (fl.get_rgbmode is not None) ##except: ## _v20 = 0 Index: cdplayer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/cdplayer.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** cdplayer.py 2000/07/16 11:57:20 1.3 --- cdplayer.py 2000/12/12 23:11:42 1.4 *************** *** 78,82 **** if line == '': break ! if line[:l] <> s: new.write(line) new.write(self.id + '.title:\t' + self.title + '\n') --- 78,82 ---- if line == '': break ! if line[:l] != s: new.write(line) new.write(self.id + '.title:\t' + self.title + '\n') Index: flp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/flp.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** flp.py 2000/08/18 14:59:32 1.6 --- flp.py 2000/12/12 23:11:42 1.7 *************** *** 37,41 **** def parse_forms(filename): forms = checkcache(filename) ! if forms != None: return forms fp = _open_formfile(filename) nforms = _parse_fd_header(fp) --- 37,41 ---- def parse_forms(filename): forms = checkcache(filename) ! if forms is not None: return forms fp = _open_formfile(filename) nforms = _parse_fd_header(fp) *************** *** 169,173 **** def _open_formfile2(filename): ! if filename[-3:] <> '.fd': filename = filename + '.fd' if filename[0] == '/': --- 169,173 ---- def _open_formfile2(filename): ! if filename[-3:] != '.fd': filename = filename + '.fd' if filename[0] == '/': *************** *** 185,189 **** except IOError: fp = None ! if fp == None: raise error, 'Cannot find forms file ' + filename return fp, filename --- 185,189 ---- except IOError: fp = None ! if fp is None: raise error, 'Cannot find forms file ' + filename return fp, filename *************** *** 195,199 **** # First read the magic header line datum = _parse_1_line(file) ! if datum <> ('Magic', 12321): raise error, 'Not a forms definition file' # Now skip until we know number of forms --- 195,199 ---- # First read the magic header line datum = _parse_1_line(file) ! if datum != ('Magic', 12321): raise error, 'Not a forms definition file' # Now skip until we know number of forms *************** *** 209,216 **** def _parse_fd_form(file, name): datum = _parse_1_line(file) ! if datum <> FORMLINE: raise error, 'Missing === FORM === line' form = _parse_object(file) ! if form.Name == name or name == None: objs = [] for j in range(form.Numberofobjects): --- 209,216 ---- def _parse_fd_form(file, name): datum = _parse_1_line(file) ! if datum != FORMLINE: raise error, 'Missing === FORM === line' form = _parse_object(file) ! if form.Name == name or name is None: objs = [] for j in range(form.Numberofobjects): *************** *** 317,321 **** file.seek(pos) return obj ! if type(datum) <> type(()) or len(datum) <> 2: raise error, 'Parse error, illegal line in object: '+datum obj.add(datum[0], datum[1]) --- 317,321 ---- file.seek(pos) return obj ! if type(datum) is not type(()) or len(datum) != 2: raise error, 'Parse error, illegal line in object: '+datum obj.add(datum[0], datum[1]) *************** *** 340,344 **** def merge_full_form(inst, form, (fdata, odatalist)): exec 'inst.'+fdata.Name+' = form\n' ! if odatalist[0].Class <> FL.BOX: raise error, 'merge_full_form() expects FL.BOX as first obj' for odata in odatalist[1:]: --- 340,344 ---- def merge_full_form(inst, form, (fdata, odatalist)): exec 'inst.'+fdata.Name+' = form\n' ! if odatalist[0].Class != FL.BOX: raise error, 'merge_full_form() expects FL.BOX as first obj' for odata in odatalist[1:]: Index: jpeg.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/jpeg.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** jpeg.py 2000/08/18 14:59:33 1.3 --- jpeg.py 2000/12/12 23:11:42 1.4 *************** *** 60,64 **** def setoption(name, value): ! if type(value) <> type(0): raise TypeError, 'jpeg.setoption: numeric options only' if name == 'forcegrey': --- 60,64 ---- def setoption(name, value): ! if type(value) is not type(0): raise TypeError, 'jpeg.setoption: numeric options only' if name == 'forcegrey': Index: panel.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/panel.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** panel.py 2000/06/28 14:48:01 1.2 --- panel.py 2000/12/12 23:11:42 1.3 *************** *** 208,212 **** # Sanity check # ! if (not descr) or descr[0] <> 'panel': raise panel_error, 'panel description must start with "panel"' # --- 208,212 ---- # Sanity check # ! if (not descr) or descr[0] != 'panel': raise panel_error, 'panel description must start with "panel"' # Index: panelparser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/panelparser.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** panelparser.py 1997/01/15 19:19:12 1.1 --- panelparser.py 2000/12/12 23:11:42 1.2 *************** *** 72,76 **** # def parse_expr(tokens): ! if (not tokens) or tokens[0] <> '(': raise syntax_error, 'expected "("' tokens = tokens[1:] --- 72,76 ---- # def parse_expr(tokens): ! if (not tokens) or tokens[0] != '(': raise syntax_error, 'expected "("' tokens = tokens[1:] Index: readcd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/readcd.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** readcd.py 2000/08/18 14:59:33 1.2 --- readcd.py 2000/12/12 23:11:42 1.3 *************** *** 94,98 **** raise Error, 'range error' end = self.pmsf2msf(prog, min, sec, frame) ! elif l <> 3: raise Error, 'syntax error' if type(start) == type(0): --- 94,98 ---- raise Error, 'range error' end = self.pmsf2msf(prog, min, sec, frame) ! elif l != 3: raise Error, 'syntax error' if type(start) == type(0): *************** *** 112,116 **** raise Error, 'range error' start = self.pmsf2msf(prog, min, sec, frame) ! elif l <> 3: raise Error, 'syntax error' self.list.append((start, end)) --- 112,116 ---- raise Error, 'range error' start = self.pmsf2msf(prog, min, sec, frame) ! elif l != 3: raise Error, 'syntax error' self.list.append((start, end)) *************** *** 128,135 **** start, end = self.list[self.listindex] if type(end) == type(0): ! if cb_type <> CD.PNUM: self.parser.setcallback(cb_type, func, arg) else: ! if cb_type <> CD.ATIME: self.parser.setcallback(cb_type, func, arg) --- 128,135 ---- start, end = self.list[self.listindex] if type(end) == type(0): ! if cb_type != CD.PNUM: self.parser.setcallback(cb_type, func, arg) else: ! if cb_type != CD.ATIME: self.parser.setcallback(cb_type, func, arg) *************** *** 141,148 **** start, end = self.list[self.listindex] if type(end) == type(0): ! if cb_type <> CD.PNUM: self.parser.removecallback(cb_type) else: ! if cb_type <> CD.ATIME: self.parser.removecallback(cb_type) --- 141,148 ---- start, end = self.list[self.listindex] if type(end) == type(0): ! if cb_type != CD.PNUM: self.parser.removecallback(cb_type) else: ! if cb_type != CD.ATIME: self.parser.removecallback(cb_type) Index: torgb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/torgb.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** torgb.py 2000/08/18 14:59:33 1.2 --- torgb.py 2000/12/12 23:11:42 1.3 *************** *** 61,65 **** finally: for temp in temps[:]: ! if temp <> ret: try: os.unlink(temp) --- 61,65 ---- finally: for temp in temps[:]: ! if temp != ret: try: os.unlink(temp) *************** *** 84,93 **** type(msg[0]) == type(0) and type(msg[1]) == type(''): msg = msg[1] ! if type(msg) <> type(''): msg = `msg` raise error, filename + ': ' + msg if ftype == 'rgb': return fname ! if ftype == None or not table.has_key(ftype): raise error, \ filename + ': unsupported image file type ' + `ftype` --- 84,93 ---- type(msg[0]) == type(0) and type(msg[1]) == type(''): msg = msg[1] ! if type(msg) is not type(''): msg = `msg` raise error, filename + ': ' + msg if ftype == 'rgb': return fname ! if ftype is None or not table.has_key(ftype): raise error, \ filename + ': unsupported image file type ' + `ftype` From python-dev@python.org Tue Dec 12 23:12:26 2000 From: python-dev@python.org (Barry Warsaw) Date: Tue, 12 Dec 2000 15:12:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib StringIO.py,1.12,1.13 Message-ID: <200012122312.PAA18890@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv18874 Modified Files: StringIO.py Log Message: Accept Finn Bock's patch #102208 to hardcode EINVAL to 22 when errno can't be imported. This makes StringIO.py work with Jython. Also, get rid of the string module by converting to string methods. Shorten some lines by using augmented assignment where appropriate. Index: StringIO.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/StringIO.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** StringIO.py 2000/10/12 16:45:37 1.12 --- StringIO.py 2000/12/12 23:12:23 1.13 *************** *** 30,36 **** """ ! import errno ! import string class StringIO: def __init__(self, buf = ''): --- 30,40 ---- """ ! try: ! from errno import EINVAL ! except ImportError: ! EINVAL = 22 + EMPTYSTRING = '' + class StringIO: def __init__(self, buf = ''): *************** *** 53,62 **** raise ValueError, "I/O operation on closed file" if self.buflist: ! self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] if mode == 1: ! pos = pos + self.pos elif mode == 2: ! pos = pos + self.len self.pos = max(0, pos) def tell(self): --- 57,66 ---- raise ValueError, "I/O operation on closed file" if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] if mode == 1: ! pos += self.pos elif mode == 2: ! pos += self.len self.pos = max(0, pos) def tell(self): *************** *** 68,72 **** raise ValueError, "I/O operation on closed file" if self.buflist: ! self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] if n < 0: --- 72,76 ---- raise ValueError, "I/O operation on closed file" if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] if n < 0: *************** *** 81,87 **** raise ValueError, "I/O operation on closed file" if self.buflist: ! self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] ! i = string.find(self.buf, '\n', self.pos) if i < 0: newpos = self.len --- 85,91 ---- raise ValueError, "I/O operation on closed file" if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] ! i = self.buf.find('\n', self.pos) if i < 0: newpos = self.len *************** *** 111,116 **** size = self.pos elif size < 0: ! raise IOError(errno.EINVAL, ! "Negative size not allowed") elif size < self.pos: self.pos = size --- 115,119 ---- size = self.pos elif size < 0: ! raise IOError(EINVAL, "Negative size not allowed") elif size < self.pos: self.pos = size *************** *** 126,130 **** if self.pos < self.len: if self.buflist: ! self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] self.buflist = [self.buf[:self.pos], s, self.buf[newpos:]] --- 129,133 ---- if self.pos < self.len: if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] self.buflist = [self.buf[:self.pos], s, self.buf[newpos:]] *************** *** 137,141 **** self.pos = newpos def writelines(self, list): ! self.write(string.joinfields(list, '')) def flush(self): if self.closed: --- 140,144 ---- self.pos = newpos def writelines(self, list): ! self.write(EMPTYSTRING.join(list)) def flush(self): if self.closed: *************** *** 143,147 **** def getvalue(self): if self.buflist: ! self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] return self.buf --- 146,150 ---- def getvalue(self): if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] return self.buf From python-dev@python.org Tue Dec 12 23:16:57 2000 From: python-dev@python.org (Barry Warsaw) Date: Tue, 12 Dec 2000 15:16:57 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib StringIO.py,1.13,1.14 Message-ID: <200012122316.PAA19453@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv19434 Modified Files: StringIO.py Log Message: Change the file's indentation from tabs to 4 spaces per level. Index: StringIO.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/StringIO.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** StringIO.py 2000/12/12 23:12:23 1.13 --- StringIO.py 2000/12/12 23:16:51 1.14 *************** *** 31,152 **** try: ! from errno import EINVAL except ImportError: ! EINVAL = 22 EMPTYSTRING = '' class StringIO: ! def __init__(self, buf = ''): ! self.buf = buf ! self.len = len(buf) self.buflist = [] ! self.pos = 0 ! self.closed = 0 ! self.softspace = 0 ! def close(self): ! if not self.closed: ! self.closed = 1 ! del self.buf, self.pos ! def isatty(self): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! return 0 ! def seek(self, pos, mode = 0): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) ! self.buflist = [] ! if mode == 1: ! pos += self.pos ! elif mode == 2: ! pos += self.len ! self.pos = max(0, pos) ! def tell(self): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! return self.pos ! def read(self, n = -1): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) ! self.buflist = [] ! if n < 0: ! newpos = self.len ! else: ! newpos = min(self.pos+n, self.len) ! r = self.buf[self.pos:newpos] ! self.pos = newpos ! return r ! def readline(self, length=None): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) ! self.buflist = [] ! i = self.buf.find('\n', self.pos) ! if i < 0: ! newpos = self.len ! else: ! newpos = i+1 ! if length is not None: ! if self.pos + length < newpos: ! newpos = self.pos + length ! r = self.buf[self.pos:newpos] ! self.pos = newpos ! return r ! def readlines(self, sizehint = 0): ! total = 0 ! lines = [] ! line = self.readline() ! while line: ! lines.append(line) ! total += len(line) ! if 0 < sizehint <= total: ! break ! line = self.readline() ! return lines ! def truncate(self, size=None): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if size is None: ! size = self.pos ! elif size < 0: ! raise IOError(EINVAL, "Negative size not allowed") ! elif size < self.pos: ! self.pos = size ! self.buf = self.getvalue()[:size] ! def write(self, s): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if not s: return ! if self.pos > self.len: ! self.buflist.append('\0'*(self.pos - self.len)) ! self.len = self.pos ! newpos = self.pos + len(s) ! if self.pos < self.len: ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) ! self.buflist = [] ! self.buflist = [self.buf[:self.pos], s, self.buf[newpos:]] ! self.buf = '' ! if newpos > self.len: ! self.len = newpos ! else: ! self.buflist.append(s) ! self.len = newpos ! self.pos = newpos ! def writelines(self, list): ! self.write(EMPTYSTRING.join(list)) ! def flush(self): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! def getvalue(self): ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) ! self.buflist = [] ! return self.buf --- 31,164 ---- try: ! from errno import EINVAL except ImportError: ! EINVAL = 22 EMPTYSTRING = '' class StringIO: ! def __init__(self, buf = ''): ! self.buf = buf ! self.len = len(buf) ! self.buflist = [] ! self.pos = 0 ! self.closed = 0 ! self.softspace = 0 ! ! def close(self): ! if not self.closed: ! self.closed = 1 ! del self.buf, self.pos ! ! def isatty(self): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! return 0 ! ! def seek(self, pos, mode = 0): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) ! self.buflist = [] ! if mode == 1: ! pos += self.pos ! elif mode == 2: ! pos += self.len ! self.pos = max(0, pos) ! ! def tell(self): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! return self.pos ! ! def read(self, n = -1): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) ! self.buflist = [] ! if n < 0: ! newpos = self.len ! else: ! newpos = min(self.pos+n, self.len) ! r = self.buf[self.pos:newpos] ! self.pos = newpos ! return r ! ! def readline(self, length=None): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) ! self.buflist = [] ! i = self.buf.find('\n', self.pos) ! if i < 0: ! newpos = self.len ! else: ! newpos = i+1 ! if length is not None: ! if self.pos + length < newpos: ! newpos = self.pos + length ! r = self.buf[self.pos:newpos] ! self.pos = newpos ! return r ! ! def readlines(self, sizehint = 0): ! total = 0 ! lines = [] ! line = self.readline() ! while line: ! lines.append(line) ! total += len(line) ! if 0 < sizehint <= total: ! break ! line = self.readline() ! return lines ! ! def truncate(self, size=None): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if size is None: ! size = self.pos ! elif size < 0: ! raise IOError(EINVAL, "Negative size not allowed") ! elif size < self.pos: ! self.pos = size ! self.buf = self.getvalue()[:size] ! ! def write(self, s): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! if not s: return ! if self.pos > self.len: ! self.buflist.append('\0'*(self.pos - self.len)) ! self.len = self.pos ! newpos = self.pos + len(s) ! if self.pos < self.len: ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] ! self.buflist = [self.buf[:self.pos], s, self.buf[newpos:]] ! self.buf = '' ! if newpos > self.len: ! self.len = newpos ! else: ! self.buflist.append(s) ! self.len = newpos ! self.pos = newpos ! ! def writelines(self, list): ! self.write(EMPTYSTRING.join(list)) ! ! def flush(self): ! if self.closed: ! raise ValueError, "I/O operation on closed file" ! ! def getvalue(self): ! if self.buflist: ! self.buf += EMPTYSTRING.join(self.buflist) ! self.buflist = [] ! return self.buf *************** *** 154,196 **** def test(): ! import sys ! if sys.argv[1:]: ! file = sys.argv[1] ! else: ! file = '/etc/passwd' ! lines = open(file, 'r').readlines() ! text = open(file, 'r').read() ! f = StringIO() ! for line in lines[:-2]: ! f.write(line) ! f.writelines(lines[-2:]) ! if f.getvalue() != text: ! raise RuntimeError, 'write failed' ! length = f.tell() ! print 'File length =', length ! f.seek(len(lines[0])) ! f.write(lines[1]) ! f.seek(0) ! print 'First line =', `f.readline()` ! here = f.tell() ! line = f.readline() ! print 'Second line =', `line` ! f.seek(-len(line), 1) ! line2 = f.read(len(line)) ! if line != line2: ! raise RuntimeError, 'bad result after seek back' ! f.seek(len(line2), 1) ! list = f.readlines() ! line = list[-1] ! f.seek(f.tell() - len(line)) ! line2 = f.read() ! if line != line2: ! raise RuntimeError, 'bad result after seek back from EOF' ! print 'Read', len(list), 'more lines' ! print 'File length =', f.tell() ! if f.tell() != length: ! raise RuntimeError, 'bad length' ! f.close() if __name__ == '__main__': ! test() --- 166,208 ---- def test(): ! import sys ! if sys.argv[1:]: ! file = sys.argv[1] ! else: ! file = '/etc/passwd' ! lines = open(file, 'r').readlines() ! text = open(file, 'r').read() ! f = StringIO() ! for line in lines[:-2]: ! f.write(line) ! f.writelines(lines[-2:]) ! if f.getvalue() != text: ! raise RuntimeError, 'write failed' ! length = f.tell() ! print 'File length =', length ! f.seek(len(lines[0])) ! f.write(lines[1]) ! f.seek(0) ! print 'First line =', `f.readline()` ! here = f.tell() ! line = f.readline() ! print 'Second line =', `line` ! f.seek(-len(line), 1) ! line2 = f.read(len(line)) ! if line != line2: ! raise RuntimeError, 'bad result after seek back' ! f.seek(len(line2), 1) ! list = f.readlines() ! line = list[-1] ! f.seek(f.tell() - len(line)) ! line2 = f.read() ! if line != line2: ! raise RuntimeError, 'bad result after seek back from EOF' ! print 'Read', len(list), 'more lines' ! print 'File length =', f.tell() ! if f.tell() != length: ! raise RuntimeError, 'bad length' ! f.close() if __name__ == '__main__': ! test() From python-dev@python.org Tue Dec 12 23:20:48 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 12 Dec 2000 15:20:48 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib Cookie.py,1.3,1.4 binhex.py,1.15,1.16 calendar.py,1.18,1.19 cmd.py,1.18,1.19 commands.py,1.12,1.13 dircache.py,1.6,1.7 dospath.py,1.19,1.20 filecmp.py,1.7,1.8 ftplib.py,1.45,1.46 imputil.py,1.14,1.15 linecache.py,1.5,1.6 macpath.py,1.26,1.27 macurl2path.py,1.7,1.8 mailbox.py,1.26,1.27 mailcap.py,1.5,1.6 mhlib.py,1.21,1.22 mimetools.py,1.18,1.19 multifile.py,1.11,1.12 netrc.py,1.6,1.7 nntplib.py,1.20,1.21 ntpath.py,1.31,1.32 pdb.py,1.44,1.45 pipes.py,1.5,1.6 posixpath.py,1.37,1.38 quopri.py,1.7,1.8 regsub.py,1.7,1.8 sgmllib.py,1.21,1.22 smtplib.py,1.30,1.31 sndhdr.py,1.3,1.4 statcache.py,1.7,1.8 sunaudio.py,1.5,1.6 toaiff.py,1.7,1.8 tzparse.py,1.7,1.8 uu.py,1.12,1.13 xdrlib.py,1.9,1.10 xmllib.py,1.24,1.25 Message-ID: <200012122320.PAA19916@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv19858 Modified Files: Cookie.py binhex.py calendar.py cmd.py commands.py dircache.py dospath.py filecmp.py ftplib.py imputil.py linecache.py macpath.py macurl2path.py mailbox.py mailcap.py mhlib.py mimetools.py multifile.py netrc.py nntplib.py ntpath.py pdb.py pipes.py posixpath.py quopri.py regsub.py sgmllib.py smtplib.py sndhdr.py statcache.py sunaudio.py toaiff.py tzparse.py uu.py xdrlib.py xmllib.py Log Message: Update the code to better reflect recommended style: Use != instead of <> since <> is documented as "obsolescent". Use "is" and "is not" when comparing with None or type objects. Index: Cookie.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/Cookie.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** Cookie.py 2000/08/24 14:40:35 1.3 --- Cookie.py 2000/12/12 23:20:44 1.4 *************** *** 490,494 **** # Now add any defined attributes ! if attrs == None: attrs = self._reserved_keys for K,V in self.items(): --- 490,494 ---- # Now add any defined attributes ! if attrs is None: attrs = self._reserved_keys for K,V in self.items(): Index: binhex.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/binhex.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** binhex.py 2000/08/17 05:06:49 1.15 --- binhex.py 2000/12/12 23:20:44 1.16 *************** *** 190,194 **** self.ofp = _Rlecoderengine(hqxer) self.crc = 0 ! if finfo == None: finfo = FInfo() self.dlen = dlen --- 190,194 ---- self.ofp = _Rlecoderengine(hqxer) self.crc = 0 ! if finfo is None: finfo = FInfo() self.dlen = dlen *************** *** 229,233 **** def close_data(self): ! if self.dlen <> 0: raise Error, 'Incorrect data size, diff='+`self.rlen` self._writecrc() --- 229,233 ---- def close_data(self): ! if self.dlen != 0: raise Error, 'Incorrect data size, diff='+`self.rlen` self._writecrc() *************** *** 247,251 **** if self.state != _DID_DATA: raise Error, 'Close at the wrong time' ! if self.rlen <> 0: raise Error, \ "Incorrect resource-datasize, diff="+`self.rlen` --- 247,251 ---- if self.state != _DID_DATA: raise Error, 'Close at the wrong time' ! if self.rlen != 0: raise Error, \ "Incorrect resource-datasize, diff="+`self.rlen` Index: calendar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/calendar.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** calendar.py 2000/10/09 12:42:04 1.18 --- calendar.py 2000/12/12 23:20:44 1.19 *************** *** 51,55 **** def isleap(year): """Return 1 for leap years, 0 for non-leap years.""" ! return year % 4 == 0 and (year % 100 <> 0 or year % 400 == 0) def leapdays(y1, y2): --- 51,55 ---- def isleap(year): """Return 1 for leap years, 0 for non-leap years.""" ! return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) def leapdays(y1, y2): Index: cmd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cmd.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** cmd.py 2000/07/11 13:03:55 1.18 --- cmd.py 2000/12/12 23:20:44 1.19 *************** *** 58,62 **** def cmdloop(self, intro=None): self.preloop() ! if intro != None: self.intro = intro if self.intro: --- 58,62 ---- def cmdloop(self, intro=None): self.preloop() ! if intro is not None: self.intro = intro if self.intro: Index: commands.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/commands.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** commands.py 1998/03/26 21:11:54 1.12 --- commands.py 2000/12/12 23:20:44 1.13 *************** *** 52,56 **** text = pipe.read() sts = pipe.close() ! if sts == None: sts = 0 if text[-1:] == '\n': text = text[:-1] return sts, text --- 52,56 ---- text = pipe.read() sts = pipe.close() ! if sts is None: sts = 0 if text[-1:] == '\n': text = text[:-1] return sts, text Index: dircache.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dircache.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** dircache.py 2000/02/04 15:39:29 1.6 --- dircache.py 2000/12/12 23:20:44 1.7 *************** *** 20,24 **** except os.error: return [] ! if mtime <> cached_mtime: try: list = os.listdir(path) --- 20,24 ---- except os.error: return [] ! if mtime != cached_mtime: try: list = os.listdir(path) Index: dospath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dospath.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** dospath.py 2000/09/28 16:25:20 1.19 --- dospath.py 2000/12/12 23:20:44 1.20 *************** *** 109,113 **** for item in m: for i in range(len(prefix)): ! if prefix[:i+1] <> item[:i+1]: prefix = prefix[:i] if i == 0: return '' --- 109,113 ---- for item in m: for i in range(len(prefix)): ! if prefix[:i+1] != item[:i+1]: prefix = prefix[:i] if i == 0: return '' *************** *** 211,215 **** variable expansion.)""" ! if path[:1] <> '~': return path i, n = 1, len(path) --- 211,215 ---- variable expansion.)""" ! if path[:1] != '~': return path i, n = 1, len(path) *************** *** 304,308 **** del comps[i-1:i+1] i = i - 1 ! elif comps[i] == '' and i > 0 and comps[i-1] <> '': del comps[i] elif '.' in comps[i]: --- 304,308 ---- del comps[i-1:i+1] i = i - 1 ! elif comps[i] == '' and i > 0 and comps[i-1] != '': del comps[i] elif '.' in comps[i]: Index: filecmp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/filecmp.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** filecmp.py 2000/12/03 20:48:07 1.7 --- filecmp.py 2000/12/12 23:20:44 1.8 *************** *** 200,204 **** a_type = stat.S_IFMT(a_stat[stat.ST_MODE]) b_type = stat.S_IFMT(b_stat[stat.ST_MODE]) ! if a_type <> b_type: self.common_funny.append(x) elif stat.S_ISDIR(a_type): --- 200,204 ---- a_type = stat.S_IFMT(a_stat[stat.ST_MODE]) b_type = stat.S_IFMT(b_stat[stat.ST_MODE]) ! if a_type != b_type: self.common_funny.append(x) elif stat.S_ISDIR(a_type): *************** *** 318,322 **** import getopt options, args = getopt.getopt(sys.argv[1:], 'r') ! if len(args) <> 2: raise getopt.error, 'need exactly two args' dd = dircmp(args[0], args[1]) if ('-r', '') in options: --- 318,323 ---- import getopt options, args = getopt.getopt(sys.argv[1:], 'r') ! if len(args) != 2: ! raise getopt.error, 'need exactly two args' dd = dircmp(args[0], args[1]) if ('-r', '') in options: Index: ftplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ftplib.py,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -r1.45 -r1.46 *** ftplib.py 2000/09/01 06:09:23 1.45 --- ftplib.py 2000/12/12 23:20:44 1.46 *************** *** 186,190 **** line = line + ('\n' + nextline) if nextline[:3] == code and \ ! nextline[3:4] <> '-': break return line --- 186,190 ---- line = line + ('\n' + nextline) if nextline[:3] == code and \ ! nextline[3:4] != '-': break return line *************** *** 208,212 **** """Expect a response beginning with '2'.""" resp = self.getresp() ! if resp[0] <> '2': raise error_reply, resp return resp --- 208,212 ---- """Expect a response beginning with '2'.""" resp = self.getresp() ! if resp[0] != '2': raise error_reply, resp return resp *************** *** 278,282 **** self.sendcmd("REST %s" % rest) resp = self.sendcmd(cmd) ! if resp[0] <> '1': raise error_reply, resp else: --- 278,282 ---- self.sendcmd("REST %s" % rest) resp = self.sendcmd(cmd) ! if resp[0] != '1': raise error_reply, resp else: *************** *** 285,289 **** self.sendcmd("REST %s" % rest) resp = self.sendcmd(cmd) ! if resp[0] <> '1': raise error_reply, resp conn, sockaddr = sock.accept() --- 285,289 ---- self.sendcmd("REST %s" % rest) resp = self.sendcmd(cmd) ! if resp[0] != '1': raise error_reply, resp conn, sockaddr = sock.accept() *************** *** 319,323 **** if resp[0] == '3': resp = self.sendcmd('PASS ' + passwd) if resp[0] == '3': resp = self.sendcmd('ACCT ' + acct) ! if resp[0] <> '2': raise error_reply, resp return resp --- 319,323 ---- if resp[0] == '3': resp = self.sendcmd('PASS ' + passwd) if resp[0] == '3': resp = self.sendcmd('ACCT ' + acct) ! if resp[0] != '2': raise error_reply, resp return resp *************** *** 385,389 **** buf = fp.readline() if not buf: break ! if buf[-2:] <> CRLF: if buf[-1] in CRLF: buf = buf[:-1] buf = buf + CRLF --- 385,389 ---- buf = fp.readline() if not buf: break ! if buf[-2:] != CRLF: if buf[-1] in CRLF: buf = buf[:-1] buf = buf + CRLF *************** *** 424,428 **** '''Rename a file.''' resp = self.sendcmd('RNFR ' + fromname) ! if resp[0] <> '3': raise error_reply, resp return self.voidcmd('RNTO ' + toname) --- 424,428 ---- '''Rename a file.''' resp = self.sendcmd('RNFR ' + fromname) ! if resp[0] != '3': raise error_reply, resp return self.voidcmd('RNTO ' + toname) *************** *** 509,513 **** Return ('host.addr.as.numbers', port#) tuple.''' ! if resp[:3] <> '227': raise error_reply, resp left = string.find(resp, '(') --- 509,513 ---- Return ('host.addr.as.numbers', port#) tuple.''' ! if resp[:3] != '227': raise error_reply, resp left = string.find(resp, '(') *************** *** 517,521 **** raise error_proto, resp # should contain '(h1,h2,h3,h4,p1,p2)' numbers = string.split(resp[left+1:right], ',') ! if len(numbers) <> 6: raise error_proto, resp host = string.join(numbers[:4], '.') --- 517,521 ---- raise error_proto, resp # should contain '(h1,h2,h3,h4,p1,p2)' numbers = string.split(resp[left+1:right], ',') ! if len(numbers) != 6: raise error_proto, resp host = string.join(numbers[:4], '.') *************** *** 529,535 **** Returns the directoryname in the 257 reply.''' ! if resp[:3] <> '257': raise error_reply, resp ! if resp[3:5] <> ' "': return '' # Not compliant to RFC 959, but UNIX ftpd does this dirname = '' --- 529,535 ---- Returns the directoryname in the 257 reply.''' ! if resp[:3] != '257': raise error_reply, resp ! if resp[3:5] != ' "': return '' # Not compliant to RFC 959, but UNIX ftpd does this dirname = '' *************** *** 540,544 **** i = i+1 if c == '"': ! if i >= n or resp[i] <> '"': break i = i+1 --- 540,544 ---- i = i+1 if c == '"': ! if i >= n or resp[i] != '"': break i = i+1 Index: imputil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imputil.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** imputil.py 2000/07/18 09:09:47 1.14 --- imputil.py 2000/12/12 23:20:44 1.15 *************** *** 435,439 **** if ':' not in a: a = ':' + a ! if a[-1:] <> ':': a = a + ':' return a + b --- 435,439 ---- if ':' not in a: a = ':' + a ! if a[-1:] != ':': a = a + ':' return a + b *************** *** 644,648 **** # need to change sys.* references for rexec environs # need hook for MAL's walk-me-up import strategy, or Tim's absolute strategy ! # watch out for sys.modules[...] == None # flag to force absolute imports? (speeds _determine_import_context and # checking for a relative module) --- 644,648 ---- # need to change sys.* references for rexec environs # need hook for MAL's walk-me-up import strategy, or Tim's absolute strategy ! # watch out for sys.modules[...] is None # flag to force absolute imports? (speeds _determine_import_context and # checking for a relative module) Index: linecache.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/linecache.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** linecache.py 2000/02/04 15:10:33 1.5 --- linecache.py 2000/12/12 23:20:44 1.6 *************** *** 51,55 **** del cache[filename] continue ! if size <> stat[ST_SIZE] or mtime <> stat[ST_MTIME]: del cache[filename] --- 51,55 ---- del cache[filename] continue ! if size != stat[ST_SIZE] or mtime != stat[ST_MTIME]: del cache[filename] Index: macpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/macpath.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** macpath.py 2000/09/28 16:25:20 1.26 --- macpath.py 2000/12/12 23:20:44 1.27 *************** *** 18,22 **** volume name).""" ! return ':' in s and s[0] <> ':' --- 18,22 ---- volume name).""" ! return ':' in s and s[0] != ':' *************** *** 31,35 **** if ':' not in path: path = ':' + path ! if path[-1:] <> ':': path = path + ':' path = path + t --- 31,35 ---- if ':' not in path: path = ':' + path ! if path[-1:] != ':': path = path + ':' path = path + t *************** *** 152,156 **** for item in m: for i in range(len(prefix)): ! if prefix[:i+1] <> item[:i+1]: prefix = prefix[:i] if i == 0: return '' --- 152,156 ---- for item in m: for i in range(len(prefix)): ! if prefix[:i+1] != item[:i+1]: prefix = prefix[:i] if i == 0: return '' Index: macurl2path.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/macurl2path.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** macurl2path.py 2000/02/04 15:39:29 1.7 --- macurl2path.py 2000/12/12 23:20:44 1.8 *************** *** 13,17 **** # tp = urllib.splittype(pathname)[0] ! if tp and tp <> 'file': raise RuntimeError, 'Cannot convert non-local URL to pathname' # Turn starting /// into /, an empty hostname means current host --- 13,17 ---- # tp = urllib.splittype(pathname)[0] ! if tp and tp != 'file': raise RuntimeError, 'Cannot convert non-local URL to pathname' # Turn starting /// into /, an empty hostname means current host *************** *** 30,34 **** del components[i-1:i+1] i = i-1 ! elif components[i] == '' and i > 0 and components[i-1] <> '': del components[i] else: --- 30,34 ---- del components[i-1:i+1] i = i-1 ! elif components[i] == '' and i > 0 and components[i-1] != '': del components[i] else: Index: mailbox.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mailbox.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** mailbox.py 2000/10/23 13:37:01 1.26 --- mailbox.py 2000/12/12 23:20:44 1.27 *************** *** 31,35 **** self._search_end() self.seekp = stop = self.fp.tell() ! if start <> stop: break return rfc822.Message(_Subfile(self.fp, start, stop)) --- 31,35 ---- self._search_end() self.seekp = stop = self.fp.tell() ! if start != stop: break return rfc822.Message(_Subfile(self.fp, start, stop)) Index: mailcap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mailcap.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** mailcap.py 2000/02/04 15:10:33 1.5 --- mailcap.py 2000/12/12 23:20:44 1.6 *************** *** 174,178 **** while i < n: c = field[i]; i = i+1 ! if c <> '%': if c == '\\': c = field[i:i+1]; i = i+1 --- 174,178 ---- while i < n: c = field[i]; i = i+1 ! if c != '%': if c == '\\': c = field[i:i+1]; i = i+1 *************** *** 188,192 **** elif c == '{': start = i ! while i < n and field[i] <> '}': i = i+1 name = field[start:i] --- 188,192 ---- elif c == '{': start = i ! while i < n and field[i] != '}': i = i+1 name = field[start:i] Index: mhlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mhlib.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** mhlib.py 2000/07/16 12:04:30 1.21 --- mhlib.py 2000/12/12 23:20:44 1.22 *************** *** 306,310 **** if not line: break fields = string.splitfields(line, ':') ! if len(fields) <> 2: self.error('bad sequence in %s: %s' % (fullname, string.strip(line))) --- 306,310 ---- if not line: break fields = string.splitfields(line, ':') ! if len(fields) != 2: self.error('bad sequence in %s: %s' % (fullname, string.strip(line))) Index: mimetools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mimetools.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** mimetools.py 2000/09/30 16:52:45 1.18 --- mimetools.py 2000/12/12 23:20:44 1.19 *************** *** 23,27 **** def parsetype(self): str = self.typeheader ! if str == None: str = 'text/plain' if ';' in str: --- 23,27 ---- def parsetype(self): str = self.typeheader ! if str is None: str = 'text/plain' if ';' in str: *************** *** 76,80 **** def getencoding(self): ! if self.encodingheader == None: return '7bit' return string.lower(self.encodingheader) --- 76,80 ---- def getencoding(self): ! if self.encodingheader is None: return '7bit' return string.lower(self.encodingheader) *************** *** 110,114 **** import time import random ! if _prefix == None: import socket import os --- 110,114 ---- import time import random ! if _prefix is None: import socket import os Index: multifile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/multifile.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** multifile.py 2000/08/17 05:06:49 1.11 --- multifile.py 2000/12/12 23:20:44 1.12 *************** *** 156,160 **** def is_data(self, line): ! return line[:2] <> '--' def section_divider(self, str): --- 156,160 ---- def is_data(self, line): ! return line[:2] != '--' def section_divider(self, str): Index: netrc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/netrc.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** netrc.py 2000/07/13 13:25:07 1.6 --- netrc.py 2000/12/12 23:20:44 1.7 *************** *** 18,22 **** # Look for a machine, default, or macdef top-level keyword toplevel = tt = lexer.get_token() ! if tt == '' or tt == None: break elif tt == 'machine': --- 18,22 ---- # Look for a machine, default, or macdef top-level keyword toplevel = tt = lexer.get_token() ! if not tt: break elif tt == 'machine': Index: nntplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/nntplib.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** nntplib.py 2000/07/16 12:04:30 1.20 --- nntplib.py 2000/12/12 23:20:45 1.21 *************** *** 259,263 **** resp = self.shortcmd('GROUP ' + name) ! if resp[:3] <> '211': raise NNTPReplyError(resp) words = string.split(resp) --- 259,263 ---- resp = self.shortcmd('GROUP ' + name) ! if resp[:3] != '211': raise NNTPReplyError(resp) words = string.split(resp) *************** *** 283,287 **** def statparse(self, resp): """Internal: parse the response of a STAT, NEXT or LAST command.""" ! if resp[:2] <> '22': raise NNTPReplyError(resp) words = string.split(resp) --- 283,287 ---- def statparse(self, resp): """Internal: parse the response of a STAT, NEXT or LAST command.""" ! if resp[:2] != '22': raise NNTPReplyError(resp) words = string.split(resp) *************** *** 430,434 **** resp = self.shortcmd("XPATH " + id) ! if resp[:3] <> '223': raise NNTPReplyError(resp) try: --- 430,434 ---- resp = self.shortcmd("XPATH " + id) ! if resp[:3] != '223': raise NNTPReplyError(resp) try: *************** *** 448,452 **** resp = self.shortcmd("DATE") ! if resp[:3] <> '111': raise NNTPReplyError(resp) elem = string.split(resp) --- 448,452 ---- resp = self.shortcmd("DATE") ! if resp[:3] != '111': raise NNTPReplyError(resp) elem = string.split(resp) *************** *** 468,472 **** resp = self.shortcmd('POST') # Raises error_??? if posting is not allowed ! if resp[0] <> '3': raise NNTPReplyError(resp) while 1: --- 468,472 ---- resp = self.shortcmd('POST') # Raises error_??? if posting is not allowed ! if resp[0] != '3': raise NNTPReplyError(resp) while 1: *************** *** 492,496 **** resp = self.shortcmd('IHAVE ' + id) # Raises error_??? if the server already has it ! if resp[0] <> '3': raise NNTPReplyError(resp) while 1: --- 492,496 ---- resp = self.shortcmd('IHAVE ' + id) # Raises error_??? if the server already has it ! if resp[0] != '3': raise NNTPReplyError(resp) while 1: Index: ntpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ntpath.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -r1.31 -r1.32 *** ntpath.py 2000/09/28 16:25:20 1.31 --- ntpath.py 2000/12/12 23:20:45 1.32 *************** *** 161,165 **** for item in m: for i in range(len(prefix)): ! if prefix[:i+1] <> item[:i+1]: prefix = prefix[:i] if i == 0: return '' --- 161,165 ---- for item in m: for i in range(len(prefix)): ! if prefix[:i+1] != item[:i+1]: prefix = prefix[:i] if i == 0: return '' *************** *** 284,288 **** If user or $HOME is unknown, do nothing.""" ! if path[:1] <> '~': return path i, n = 1, len(path) --- 284,288 ---- If user or $HOME is unknown, do nothing.""" ! if path[:1] != '~': return path i, n = 1, len(path) *************** *** 388,392 **** del comps[i-1:i+1] i = i - 1 ! elif comps[i] == '' and i > 0 and comps[i-1] <> '': del comps[i] else: --- 388,392 ---- del comps[i-1:i+1] i = i - 1 ! elif comps[i] == '' and i > 0 and comps[i-1] != '': del comps[i] else: Index: pdb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pdb.py,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -r1.44 -r1.45 *** pdb.py 2000/07/16 12:04:30 1.44 --- pdb.py 2000/12/12 23:20:45 1.45 *************** *** 554,558 **** else: first = self.lineno + 1 ! if last == None: last = first + 10 filename = self.curframe.f_code.co_filename --- 554,558 ---- else: first = self.lineno + 1 ! if last is None: last = first + 10 filename = self.curframe.f_code.co_filename *************** *** 896,900 **** p = Pdb() p.reset() ! while t.tb_next <> None: t = t.tb_next p.interaction(t.tb_frame, t) --- 896,901 ---- p = Pdb() p.reset() ! while t.tb_next is not None: ! t = t.tb_next p.interaction(t.tb_frame, t) Index: pipes.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pipes.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** pipes.py 2000/02/04 15:10:34 1.5 --- pipes.py 2000/12/12 23:20:45 1.6 *************** *** 111,115 **** def append(self, cmd, kind): """t.append(cmd, kind) adds a new step at the end.""" ! if type(cmd) <> type(''): raise TypeError, \ 'Template.append: cmd must be a string' --- 111,115 ---- def append(self, cmd, kind): """t.append(cmd, kind) adds a new step at the end.""" ! if type(cmd) is not type(''): raise TypeError, \ 'Template.append: cmd must be a string' *************** *** 120,124 **** raise ValueError, \ 'Template.append: SOURCE can only be prepended' ! if self.steps <> [] and self.steps[-1][1] == SINK: raise ValueError, \ 'Template.append: already ends with SINK' --- 120,124 ---- raise ValueError, \ 'Template.append: SOURCE can only be prepended' ! if self.steps and self.steps[-1][1] == SINK: raise ValueError, \ 'Template.append: already ends with SINK' *************** *** 133,137 **** def prepend(self, cmd, kind): """t.prepend(cmd, kind) adds a new step at the front.""" ! if type(cmd) <> type(''): raise TypeError, \ 'Template.prepend: cmd must be a string' --- 133,137 ---- def prepend(self, cmd, kind): """t.prepend(cmd, kind) adds a new step at the front.""" ! if type(cmd) is not type(''): raise TypeError, \ 'Template.prepend: cmd must be a string' *************** *** 142,146 **** raise ValueError, \ 'Template.prepend: SINK can only be appended' ! if self.steps <> [] and self.steps[0][1] == SOURCE: raise ValueError, \ 'Template.prepend: already begins with SOURCE' --- 142,146 ---- raise ValueError, \ 'Template.prepend: SINK can only be appended' ! if self.steps and self.steps[0][1] == SOURCE: raise ValueError, \ 'Template.prepend: already begins with SOURCE' *************** *** 166,170 **** """t.open_r(file) and t.open_w(file) implement t.open(file, 'r') and t.open(file, 'w') respectively.""" ! if self.steps == []: return open(file, 'r') if self.steps[-1][1] == SINK: --- 166,170 ---- """t.open_r(file) and t.open_w(file) implement t.open(file, 'r') and t.open(file, 'w') respectively.""" ! if not self.steps: return open(file, 'r') if self.steps[-1][1] == SINK: *************** *** 175,179 **** def open_w(self, file): ! if self.steps == []: return open(file, 'w') if self.steps[0][1] == SOURCE: --- 175,179 ---- def open_w(self, file): ! if not self.steps: return open(file, 'w') if self.steps[0][1] == SOURCE: *************** *** 204,208 **** # Make sure there is at least one step # ! if list == []: list.append(['', 'cat', '--', '']) # --- 204,208 ---- # Make sure there is at least one step # ! if not list: list.append(['', 'cat', '--', '']) # Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -r1.37 -r1.38 *** posixpath.py 2000/09/28 16:22:52 1.37 --- posixpath.py 2000/12/12 23:20:45 1.38 *************** *** 60,64 **** i = p.rfind('/') + 1 head, tail = p[:i], p[i:] ! if head and head <> '/'*len(head): while head[-1] == '/': head = head[:-1] --- 60,64 ---- i = p.rfind('/') + 1 head, tail = p[:i], p[i:] ! if head and head != '/'*len(head): while head[-1] == '/': head = head[:-1] *************** *** 121,125 **** for item in m: for i in range(len(prefix)): ! if prefix[:i+1] <> item[:i+1]: prefix = prefix[:i] if i == 0: return '' --- 121,125 ---- for item in m: for i in range(len(prefix)): ! if prefix[:i+1] != item[:i+1]: prefix = prefix[:i] if i == 0: return '' *************** *** 282,289 **** """Expand ~ and ~user constructions. If user or $HOME is unknown, do nothing.""" ! if path[:1] <> '~': return path i, n = 1, len(path) ! while i < n and path[i] <> '/': i = i + 1 if i == 1: --- 282,289 ---- """Expand ~ and ~user constructions. If user or $HOME is unknown, do nothing.""" ! if path[:1] != '~': return path i, n = 1, len(path) ! while i < n and path[i] != '/': i = i + 1 if i == 1: Index: quopri.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/quopri.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** quopri.py 2000/10/05 17:24:33 1.7 --- quopri.py 2000/12/12 23:20:45 1.8 *************** *** 70,74 **** while i < n: c = line[i] ! if c <> ESCAPE: new = new + c; i = i+1 elif i+1 == n and not partial: --- 70,74 ---- while i < n: c = line[i] ! if c != ESCAPE: new = new + c; i = i+1 elif i+1 == n and not partial: Index: regsub.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/regsub.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** regsub.py 2000/02/04 15:28:40 1.7 --- regsub.py 2000/12/12 23:20:45 1.8 *************** *** 125,129 **** def compile(pat): ! if type(pat) <> type(''): return pat # Assume it is a compiled regex key = (pat, regex.get_syntax()) --- 125,129 ---- def compile(pat): ! if type(pat) != type(''): return pat # Assume it is a compiled regex key = (pat, regex.get_syntax()) *************** *** 154,158 **** while i < len(repl): c = repl[i]; i = i+1 ! if c <> '\\' or i >= len(repl): new = new + c else: --- 154,158 ---- while i < len(repl): c = repl[i]; i = i+1 ! if c != '\\' or i >= len(repl): new = new + c else: *************** *** 183,187 **** if line[-1] == '\n': line = line[:-1] fields = split(line, delpat) ! if len(fields) <> 3: print 'Sorry, not three fields' print 'split:', `fields` --- 183,187 ---- if line[-1] == '\n': line = line[:-1] fields = split(line, delpat) ! if len(fields) != 3: print 'Sorry, not three fields' print 'split:', `fields` Index: sgmllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sgmllib.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** sgmllib.py 2000/06/29 18:50:59 1.21 --- sgmllib.py 2000/12/12 23:20:45 1.22 *************** *** 186,190 **** def parse_comment(self, i): rawdata = self.rawdata ! if rawdata[i:i+4] <> '", "LAST"] stdscr.refresh() for y in range(0, curses.LINES - 1): for x in range(0, curses.COLS): stdscr.addstr("%d" % ((y + x) % 10)) for y in range(0, 1): p1 = mkpanel(curses.COLOR_RED, curses.LINES / 2 - 2, curses.COLS / 8 + 1, 0, 0) p1.set_userptr("p1") p2 = mkpanel(curses.COLOR_GREEN, curses.LINES / 2 + 1, curses.COLS / 7, curses.LINES / 4, curses.COLS / 10) p2.set_userptr("p2") p3 = mkpanel(curses.COLOR_YELLOW, curses.LINES / 4, curses.COLS / 10, curses.LINES / 2, curses.COLS / 9) p3.set_userptr("p3") p4 = mkpanel(curses.COLOR_BLUE, curses.LINES / 2 - 2, curses.COLS / 8, curses.LINES / 2 - 2, curses.COLS / 3) p4.set_userptr("p4") p5 = mkpanel(curses.COLOR_MAGENTA, curses.LINES / 2 - 2, curses.COLS / 8, curses.LINES / 2, curses.COLS / 2 - 2) p5.set_userptr("p5") fill_panel(p1) fill_panel(p2) fill_panel(p3) fill_panel(p4) fill_panel(p5) p4.hide() p5.hide() pflush() saywhat("press any key to continue") wait_a_while() saywhat("h3 s1 s2 s4 s5;press any key to continue") p1.move(0, 0) p3.hide() p1.show() p2.show() p4.show() p5.show() pflush() wait_a_while() saywhat("s1; press any key to continue") p1.show() pflush() wait_a_while() saywhat("s2; press any key to continue") p2.show() pflush() wait_a_while() saywhat("m2; press any key to continue") p2.move(curses.LINES / 3 + 1, curses.COLS / 8) pflush() wait_a_while() saywhat("s3; press any key to continue") p3.show() pflush() wait_a_while() saywhat("m3; press any key to continue") p3.move(curses.LINES / 4 + 1, curses.COLS / 15) pflush() wait_a_while() saywhat("b3; press any key to continue") p3.bottom() pflush() wait_a_while() saywhat("s4; press any key to continue") p4.show() pflush() wait_a_while() saywhat("s5; press any key to continue") p5.show() pflush() wait_a_while() saywhat("t3; press any key to continue") p3.top() pflush() wait_a_while() saywhat("t1; press any key to continue") p1.show() pflush() wait_a_while() saywhat("t2; press any key to continue") p2.show() pflush() wait_a_while() saywhat("t3; press any key to continue") p3.show() pflush() wait_a_while() saywhat("t4; press any key to continue") p4.show() pflush() wait_a_while() for itmp in range(0, 6): w4 = p4.window() w5 = p5.window() saywhat("m4; press any key to continue") w4.move(curses.LINES / 8, 1) w4.addstr(mod[itmp]) p4.move(curses.LINES / 6, itmp * curses.COLS / 8) w5.move(curses.LINES / 6, 1) w5.addstr(mod[itmp]) pflush() wait_a_while() saywhat("m5; press any key to continue") w4.move(curses.LINES / 6, 1) w4.addstr(mod[itmp]) p5.move(curses.LINES / 3 - 1, itmp * 10 + 6) w5.move(curses.LINES / 8, 1) w5.addstr(mod[itmp]) pflush() wait_a_while() saywhat("m4; press any key to continue") p4.move(curses.LINES / 6, (itmp + 1) * curses.COLS / 8) pflush() wait_a_while() saywhat("t5; press any key to continue") p5.top() pflush() wait_a_while() saywhat("t2; press any key to continue") p2.top() pflush() wait_a_while() saywhat("t1; press any key to continue") p1.top() pflush() wait_a_while() saywhat("d2; press any key to continue") del p2 pflush() wait_a_while() saywhat("h3; press any key to continue") p3.hide() pflush() wait_a_while() saywhat("d1; press any key to continue") del p1 pflush() wait_a_while() saywhat("d4; press any key to continue") del p4 pflush() wait_a_while() saywhat("d5; press any key to continue") del p5 pflush() wait_a_while() if nap_msec == 1: break nap_msec = 100 # # one fine day there'll be the menu at this place # curses.wrapper(demo_panels) --- NEW FILE: rain.py --- #!/usr/bin/env python # # $Id: rain.py,v 1.1 2000/12/15 00:41:48 akuchling Exp $ # # somebody should probably check the randrange()s... import curses from random import randrange def next_j(j): if j == 0: j = 4 else: j -= 1 if curses.has_colors(): z = randrange(0, 3) color = curses.color_pair(z) if z: color = color | curses.A_BOLD stdscr.attrset(color) return j def main(win): # we know that the first argument from curses.wrapper() is stdscr. # Initialize it globally for convenience. global stdscr stdscr = win if curses.has_colors(): bg = curses.COLOR_BLACK curses.init_pair(1, curses.COLOR_BLUE, bg) curses.init_pair(2, curses.COLOR_CYAN, bg) curses.nl() curses.noecho() # XXX curs_set() always returns ERR # curses.curs_set(0) stdscr.timeout(0) c = curses.COLS - 4 r = curses.LINES - 4 xpos = [0] * c ypos = [0] * r for j in range(4, -1, -1): xpos[j] = randrange(0, c) + 2 ypos[j] = randrange(0, r) + 2 j = 0 while 1: x = randrange(0, c) + 2 y = randrange(0, r) + 2 stdscr.addch(y, x, ord('.')) stdscr.addch(ypos[j], xpos[j], ord('o')) j = next_j(j) stdscr.addch(ypos[j], xpos[j], ord('O')) j = next_j(j) stdscr.addch( ypos[j] - 1, xpos[j], ord('-')) stdscr.addstr(ypos[j], xpos[j] - 1, "|.|") stdscr.addch( ypos[j] + 1, xpos[j], ord('-')) j = next_j(j) stdscr.addch( ypos[j] - 2, xpos[j], ord('-')) stdscr.addstr(ypos[j] - 1, xpos[j] - 1, "/ \\") stdscr.addstr(ypos[j], xpos[j] - 2, "| O |") stdscr.addstr(ypos[j] + 1, xpos[j] - 1, "\\ /") stdscr.addch( ypos[j] + 2, xpos[j], ord('-')) j = next_j(j) stdscr.addch( ypos[j] - 2, xpos[j], ord(' ')) stdscr.addstr(ypos[j] - 1, xpos[j] - 1, " ") stdscr.addstr(ypos[j], xpos[j] - 2, " ") stdscr.addstr(ypos[j] + 1, xpos[j] - 1, " ") stdscr.addch( ypos[j] + 2, xpos[j], ord(' ')) xpos[j] = x ypos[j] = y ch = stdscr.getch() if ch == ord('q') or ch == ord('Q'): return 0 elif ch == ord('s'): stdscr.nodelay(0) elif ch == ord(' '): stdscr.nodelay(1) curses.napms(50) curses.wrapper(main) --- NEW FILE: tclock.py --- #!/usr/bin/env python # # $Id: tclock.py,v 1.1 2000/12/15 00:41:48 akuchling Exp $ # # From tclock.c, Copyright Howard Jones , September 1994. from math import * import curses, time ASPECT = 2.2 def sign(_x): if _x < 0: return -1 return 1 def A2XY(angle, radius): return int(round(ASPECT * radius * sin(angle))), int(round(radius * cos(angle))) def plot(x, y, col): stdscr.addch(y, x, col) # draw a diagonal line using Bresenham's algorithm def dline(pair, from_x, from_y, x2, y2, ch): if curses.has_colors(): stdscr.attrset(curses.color_pair(pair)) dx = x2 - from_x dy = y2 - from_y ax = abs(dx * 2) ay = abs(dy * 2) sx = sign(dx) sy = sign(dy) x = from_x y = from_y if ax > ay: d = ay - ax / 2 while 1: plot(x, y, ch) if x == x2: return if d >= 0: y += sy d -= ax x += sx d += ay else: d = ax - ay / 2 while 1: plot(x, y, ch) if y == y2: return if d >= 0: x += sx d -= ay y += sy d += ax def main(win): global stdscr stdscr = win lastbeep = -1 my_bg = curses.COLOR_BLACK stdscr.nodelay(1) stdscr.timeout(0) # curses.curs_set(0) if curses.has_colors(): curses.init_pair(1, curses.COLOR_RED, my_bg) curses.init_pair(2, curses.COLOR_MAGENTA, my_bg) curses.init_pair(3, curses.COLOR_GREEN, my_bg) cx = (curses.COLS - 1) / 2 cy = curses.LINES / 2 if cx > cy: ch = cy else: ch = cx mradius = (3 * cy) / 4 hradius = cy / 2 sradius = (2 * cy) / 3 for i in range(0, 12): sangle = (i + 1) * 2.0 * pi / 12.0 sradius = 5 * cy / 6 sdx, sdy = A2XY(sangle, sradius) stdscr.addstr(cy - sdy, cx + sdx, "%d" % (i + 1)) stdscr.addstr(0, 0, "ASCII Clock by Howard Jones , 1994") sradius = 8 while 1: curses.napms(1000) tim = time.time() t = time.localtime(tim) hours = t[3] + t[4] / 60.0 if hours > 12.0: hours -= 12.0 mangle = t[4] * 2 * pi / 60.0 mdx, mdy = A2XY(mangle, mradius) hangle = hours * 2 * pi / 12.0 hdx, hdy = A2XY(hangle, hradius) sangle = t[5] * 2 * pi / 60.0 sdx, sdy = A2XY(sangle, sradius) dline(3, cx, cy, cx + mdx, cy - mdy, ord('#')) stdscr.attrset(curses.A_REVERSE) dline(2, cx, cy, cx + hdx, cy - hdy, ord('.')) stdscr.attroff(curses.A_REVERSE) if curses.has_colors(): stdscr.attrset(curses.color_pair(1)) plot(cx + sdx, cy - sdy, ord('O')) if curses.has_colors(): stdscr.attrset(curses.color_pair(0)) stdscr.addstr(curses.LINES - 2, 0, time.ctime(tim)) stdscr.refresh() if (t[5] % 5) == 0 and t[5] != lastbeep: lastbeep = t[5] curses.beep() ch = stdscr.getch() if ch == ord('q'): return 0 plot(cx + sdx, cy - sdy, ord(' ')) dline(0, cx, cy, cx + hdx, cy - hdy, ord(' ')) dline(0, cx, cy, cx + mdx, cy - mdy, ord(' ')) curses.wrapper(main) Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/curses/README,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** README 2000/12/13 03:50:20 1.1 --- README 2000/12/15 00:41:48 1.2 *************** *** 1,3 **** ! Sample programs that use the curses package: life.py Simple game of Life --- 1,28 ---- ! This is a collection of demos and tests for the curses module. + ncurses demos + ============= + + These demos are converted from the C versions in the ncurses + distribution, and were contributed by Thomas Gellekum + I didn't strive for a `pythonic' style, but bluntly copied the + originals. I won't attempt to `beautify' the program anytime soon, but + I wouldn't mind someone else making an effort in that direction, of + course. + + ncurses.py -- currently only a panels demo + XXX this won't work until panel support is checked in + rain.py -- raindrops keep falling on my desktop + tclock.py -- ASCII clock, by Howard Jones + + Please send bugfixes and new contributions to me or, even better, + submit them to the Python Bug Tracker on SourceForge + (). + + + Other demos + =========== + life.py Simple game of Life + + From python-dev@python.org Fri Dec 15 00:44:04 2000 From: python-dev@python.org (A.M. Kuchling) Date: Thu, 14 Dec 2000 16:44:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.42,2.43 Message-ID: <200012150044.QAA01033@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv993 Modified Files: _cursesmodule.c Log Message: Wrapper for napms() function, contributed by Thomas Gellekum Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.42 retrieving revision 2.43 diff -C2 -r2.42 -r2.43 *** _cursesmodule.c 2000/11/18 17:45:59 2.42 --- _cursesmodule.c 2000/12/15 00:44:02 2.43 *************** *** 44,48 **** mcprint mvaddchnstr mvaddchstr mvchgat mvcur mvinchnstr mvinchstr mvinnstr mmvwaddchnstr mvwaddchstr mvwchgat ! mvwgetnstr mvwinchnstr mvwinchstr mvwinnstr napms newterm overlay overwrite resizeterm restartterm ripoffline scr_dump scr_init scr_restore scr_set scrl set_curterm set_term setterm --- 44,48 ---- mcprint mvaddchnstr mvaddchstr mvchgat mvcur mvinchnstr mvinchstr mvinnstr mmvwaddchnstr mvwaddchstr mvwchgat ! mvwgetnstr mvwinchnstr mvwinchstr mvwinnstr newterm overlay overwrite resizeterm restartterm ripoffline scr_dump scr_init scr_restore scr_set scrl set_curterm set_term setterm *************** *** 56,59 **** --- 56,95 ---- slk_noutrefresh slk_refresh slk_restore slk_set slk_touch + Menu extension (ncurses and probably SYSV): + current_item free_item free_menu item_count item_description + item_index item_init item_name item_opts item_opts_off + item_opts_on item_term item_userptr item_value item_visible + menu_back menu_driver menu_fore menu_format menu_grey + menu_init menu_items menu_mark menu_opts menu_opts_off + menu_opts_on menu_pad menu_pattern menu_request_by_name + menu_request_name menu_spacing menu_sub menu_term menu_userptr + menu_win new_item new_menu pos_menu_cursor post_menu + scale_menu set_current_item set_item_init set_item_opts + set_item_term set_item_userptr set_item_value set_menu_back + set_menu_fore set_menu_format set_menu_grey set_menu_init + set_menu_items set_menu_mark set_menu_opts set_menu_pad + set_menu_pattern set_menu_spacing set_menu_sub set_menu_term + set_menu_userptr set_menu_win set_top_row top_row unpost_menu + + Form extension (ncurses and probably SYSV): + current_field data_ahead data_behind dup_field + dynamic_fieldinfo field_arg field_back field_buffer + field_count field_fore field_index field_info field_init + field_just field_opts field_opts_off field_opts_on field_pad + field_status field_term field_type field_userptr form_driver + form_fields form_init form_opts form_opts_off form_opts_on + form_page form_request_by_name form_request_name form_sub + form_term form_userptr form_win free_field free_form + link_field link_fieldtype move_field new_field new_form + new_page pos_form_cursor post_form scale_form + set_current_field set_field_back set_field_buffer + set_field_fore set_field_init set_field_just set_field_opts + set_field_pad set_field_status set_field_term set_field_type + set_field_userptr set_fieldtype_arg set_fieldtype_choice + set_form_fields set_form_init set_form_opts set_form_page + set_form_sub set_form_term set_form_userptr set_form_win + set_max_field set_new_page unpost_form + + */ *************** *** 1934,1937 **** --- 1970,1985 ---- static PyObject * + PyCurses_Napms(PyObject *self, PyObject *args) + { + int ms; + + PyCursesInitialised + if (!PyArg_Parse(args, "i;ms", &ms)) return NULL; + + return Py_BuildValue("i", napms(ms)); + } + + + static PyObject * PyCurses_NewPad(PyObject *self, PyObject *args) { *************** *** 2333,2336 **** --- 2381,2385 ---- {"mousemask", (PyCFunction)PyCurses_MouseMask}, #endif + {"napms", (PyCFunction)PyCurses_Napms}, {"newpad", (PyCFunction)PyCurses_NewPad}, {"newwin", (PyCFunction)PyCurses_NewWindow}, From python-dev@python.org Fri Dec 15 00:59:34 2000 From: python-dev@python.org (A.M. Kuchling) Date: Thu, 14 Dec 2000 16:59:34 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules bsddbmodule.c,1.25,1.26 Message-ID: <200012150059.QAA02005@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv1941 Modified Files: bsddbmodule.c Log Message: [Patch #102827] Fix for PR#119558, avoiding core dumps by checking for malloc() returning NULL Index: bsddbmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/bsddbmodule.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** bsddbmodule.c 2000/09/01 23:29:26 1.25 --- bsddbmodule.c 2000/12/15 00:59:32 1.26 *************** *** 267,273 **** if (drec.size > sizeof(buf)) data = malloc(drec.size); else data = buf; ! memcpy(data,drec.data,drec.size); } BSDDB_END_SAVE(dp) if (status != 0) { if (status < 0) --- 267,274 ---- if (drec.size > sizeof(buf)) data = malloc(drec.size); else data = buf; ! if (data!=NULL) memcpy(data,drec.data,drec.size); } BSDDB_END_SAVE(dp) + if (data==NULL) return PyErr_NoMemory(); if (status != 0) { if (status < 0) *************** *** 388,394 **** if (krec.size > sizeof(buf)) data = malloc(krec.size); else data = buf; ! memcpy(data,krec.data,krec.size); } BSDDB_END_SAVE(dp) while (status == 0) { item = PyString_FromStringAndSize(data, (int)krec.size); --- 389,396 ---- if (krec.size > sizeof(buf)) data = malloc(krec.size); else data = buf; ! if (data!=NULL) memcpy(data,krec.data,krec.size); } BSDDB_END_SAVE(dp) + if (data==NULL) return PyErr_NoMemory(); while (status == 0) { item = PyString_FromStringAndSize(data, (int)krec.size); *************** *** 409,415 **** if (krec.size > sizeof(buf)) data = malloc(krec.size); else data = buf; ! memcpy(data,krec.data,krec.size); } BSDDB_END_SAVE(dp) } if (status < 0) { --- 411,418 ---- if (krec.size > sizeof(buf)) data = malloc(krec.size); else data = buf; ! if (data!=NULL) memcpy(data,krec.data,krec.size); } BSDDB_END_SAVE(dp) + if (data==NULL) return PyErr_NoMemory(); } if (status < 0) { *************** *** 468,474 **** if (drec.size > sizeof(buf)) data = malloc(drec.size); else data = buf; ! memcpy(data,drec.data,drec.size); } BSDDB_END_SAVE(dp) if (status != 0) { if (status < 0) --- 471,478 ---- if (drec.size > sizeof(buf)) data = malloc(drec.size); else data = buf; ! if (data!=NULL) memcpy(data,drec.data,drec.size); } BSDDB_END_SAVE(dp) + if (data==NULL) return PyErr_NoMemory(); if (status != 0) { if (status < 0) *************** *** 506,516 **** if (krec.size > sizeof(kbuf)) kdata = malloc(krec.size); else kdata = kbuf; ! memcpy(kdata,krec.data,krec.size); if (drec.size > sizeof(dbuf)) ddata = malloc(drec.size); else ddata = dbuf; ! memcpy(ddata,drec.data,drec.size); } BSDDB_END_SAVE(dp) ! if (status != 0) { if (status < 0) PyErr_SetFromErrno(BsddbError); --- 510,525 ---- if (krec.size > sizeof(kbuf)) kdata = malloc(krec.size); else kdata = kbuf; ! if (kdata!=NULL) memcpy(kdata,krec.data,krec.size); if (drec.size > sizeof(dbuf)) ddata = malloc(drec.size); else ddata = dbuf; ! if (ddata!=NULL) memcpy(ddata,drec.data,drec.size); } BSDDB_END_SAVE(dp) ! if (status == 0) { ! if ((kdata==NULL) || (ddata==NULL)) ! return PyErr_NoMemory(); ! } ! else { ! /* (status != 0) */ if (status < 0) PyErr_SetFromErrno(BsddbError); From python-dev@python.org Fri Dec 15 01:03:25 2000 From: python-dev@python.org (A.M. Kuchling) Date: Thu, 14 Dec 2000 17:03:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcurses.tex,1.23,1.24 Message-ID: <200012150103.RAA02258@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv2234 Modified Files: libcurses.tex Log Message: Document napms() Add reference to demo directory Index: libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** libcurses.tex 2000/12/01 15:25:23 1.23 --- libcurses.tex 2000/12/15 01:03:23 1.24 *************** *** 34,37 **** --- 34,38 ---- with Python, by Andrew Kuchling, is available on the Python Web site.} + \seetitle[Demo/curses]{}{Some example programs.} \end{seealso} *************** *** 309,312 **** --- 310,317 ---- event mask. If this function is never called, no mouse events are ever reported. + \end{funcdesc} + + \begin{funcdesc}{napms}{ms} + Sleep for \var{ms} milliseconds. \end{funcdesc} From python-dev@python.org Fri Dec 15 01:16:47 2000 From: python-dev@python.org (A.M. Kuchling) Date: Thu, 14 Dec 2000 17:16:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.85,1.86 Message-ID: <200012150116.RAA03058@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv3041 Modified Files: NEWS Log Message: Fix typo Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -r1.85 -r1.86 *** NEWS 2000/12/12 22:10:31 1.85 --- NEWS 2000/12/15 01:16:43 1.86 *************** *** 475,479 **** it works when argv[0] is a relative path. ! - Added a true tnicode_internal_encode() function and fixed the unicode_internal_decode function() to support Unicode objects directly rather than by generating a copy of the object. --- 475,479 ---- it works when argv[0] is a relative path. ! - Added a true unicode_internal_encode() function and fixed the unicode_internal_decode function() to support Unicode objects directly rather than by generating a copy of the object. From python-dev@python.org Fri Dec 15 05:41:52 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 14 Dec 2000 21:41:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib liboperator.tex,1.18,1.19 Message-ID: <200012150541.VAA12810@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv12800/lib Modified Files: liboperator.tex Log Message: Grant Griffin : Clarify that invert() is a *bitwise* operation. Index: liboperator.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liboperator.tex,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** liboperator.tex 2000/10/22 03:19:30 1.18 --- liboperator.tex 2000/12/15 05:41:49 1.19 *************** *** 59,64 **** \funcline{__inv__}{o} \funcline{__invert__}{o} ! Return the inverse of \var{o}. The names \function{invert()} and ! \function{__invert__()} were added in Python 2.0. \end{funcdesc} --- 59,65 ---- \funcline{__inv__}{o} \funcline{__invert__}{o} ! Return the bitwise inverse of the number \var{o}. The names ! \function{invert()} and \function{__invert__()} were added in Python ! 2.0. \end{funcdesc} From python-dev@python.org Fri Dec 15 13:07:49 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 15 Dec 2000 05:07:49 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.95,2.96 unicodeobject.c,2.67,2.68 Message-ID: <200012151307.FAA10566@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv10322 Modified Files: stringobject.c unicodeobject.c Log Message: [ Patch #102852 ] Make % error a bit more informative by indicates the index at which an unknown %-escape was found Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.95 retrieving revision 2.96 diff -C2 -r2.95 -r2.96 *** stringobject.c 2000/12/06 14:27:49 2.95 --- stringobject.c 2000/12/15 13:07:46 2.96 *************** *** 2940,2945 **** default: PyErr_Format(PyExc_ValueError, ! "unsupported format character '%c' (0x%x)", ! c, c); goto error; } --- 2940,2946 ---- default: PyErr_Format(PyExc_ValueError, ! "unsupported format character '%c' (0x%x) " ! "at index %i", ! c, c, fmt - 1 - PyString_AsString(format)); goto error; } Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.67 retrieving revision 2.68 diff -C2 -r2.67 -r2.68 *** unicodeobject.c 2000/11/30 05:22:44 2.67 --- unicodeobject.c 2000/12/15 13:07:46 2.68 *************** *** 5068,5073 **** default: PyErr_Format(PyExc_ValueError, ! "unsupported format character '%c' (0x%x)", ! c, c); goto onError; } --- 5068,5074 ---- default: PyErr_Format(PyExc_ValueError, ! "unsupported format character '%c' (0x%x) " ! "at index %i", ! c, c, fmt -1 - PyUnicode_AS_UNICODE(uformat)); goto onError; } From python-dev@python.org Fri Dec 15 13:09:09 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 15 Dec 2000 05:09:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_format.py,1.3,1.4 Message-ID: <200012151309.FAA10690@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv10608 Modified Files: test_format.py Log Message: Add test case for error message raised by bad % format character (Oh, look, it adds another little utility function for testing) Index: test_format.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_format.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_format.py 2000/11/30 05:22:41 1.3 --- test_format.py 2000/12/15 13:09:06 1.4 *************** *** 175,176 **** --- 175,201 ---- testboth("%o", 042L, "42") testboth("%o", -042L, "-42") + + # Test exception for unknown format characters + if verbose: + print 'Testing exceptions' + + def test_exc(formatstr, args, exception, excmsg): + try: + testformat(formatstr, args) + except exception, exc: + if str(exc) == excmsg: + if verbose: + print "yes" + else: + if verbose: print 'no' + print 'Unexpected ', exception, ':', repr(str(exc)) + except: + if verbose: print 'no' + print 'Unexpected exception' + raise + + test_exc('abc %a', 1, ValueError, + "unsupported format character 'a' (0x61) at index 5") + test_exc(u'abc %\u3000', 1, ValueError, + "unsupported format character '\000' (0x3000) at index 5") + From python-dev@python.org Fri Dec 15 15:01:40 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 15 Dec 2000 07:01:40 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib urllib.py,1.108,1.109 Message-ID: <200012151501.HAA17427@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv17415 Modified Files: urllib.py Log Message: Get rid of string functions, except maketrans() (which is *not* obsolete!). Fix a bug in ftpwrapper.retrfile() where somehow ftplib.error_perm was assumed to be a string. (The fix applies str().) Also break some long lines and change the output from test() slightly. Index: urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.108 retrieving revision 1.109 diff -C2 -r1.108 -r1.109 *** urllib.py 2000/12/03 18:30:10 1.108 --- urllib.py 2000/12/15 15:01:37 1.109 *************** *** 29,33 **** import types ! __version__ = '1.14' # XXX This version is not always updated :-( MAXFTPCACHE = 10 # Trim the ftp cache beyond this size --- 29,33 ---- import types ! __version__ = '1.15' # XXX This version is not always updated :-( MAXFTPCACHE = 10 # Trim the ftp cache beyond this size *************** *** 156,160 **** if '-' in name: # replace - with _ ! name = string.join(string.split(name, '-'), '_') if not hasattr(self, name): if proxy: --- 156,160 ---- if '-' in name: # replace - with _ ! name = '_'.join(name.split('-')) if not hasattr(self, name): if proxy: *************** *** 250,254 **** url = rest user_passwd = None ! if string.lower(urltype) != 'http': realhost = None else: --- 250,254 ---- url = rest user_passwd = None ! if urltype.lower() != 'http': realhost = None else: *************** *** 262,266 **** if user_passwd: import base64 ! auth = string.strip(base64.encodestring(user_passwd)) else: auth = None --- 262,266 ---- if user_passwd: import base64 ! auth = base64.encodestring(user_passwd).strip() else: auth = None *************** *** 325,329 **** url = rest user_passwd = None ! if string.lower(urltype) != 'https': realhost = None else: --- 325,329 ---- url = rest user_passwd = None ! if urltype.lower() != 'https': realhost = None else: *************** *** 337,341 **** if user_passwd: import base64 ! auth = string.strip(base64.encodestring(user_passwd)) else: auth = None --- 337,341 ---- if user_passwd: import base64 ! auth = base64.encodestring(user_passwd).strip() else: auth = None *************** *** 364,368 **** return self.http_error(url, fp, errcode, errmsg, headers) else: ! return self.http_error(url, fp, errcode, errmsg, headers, data) def open_gopher(self, url): --- 364,369 ---- return self.http_error(url, fp, errcode, errmsg, headers) else: ! return self.http_error(url, fp, errcode, errmsg, headers, ! data) def open_gopher(self, url): *************** *** 431,439 **** path, attrs = splitattr(path) path = unquote(path) ! dirs = string.splitfields(path, '/') dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] if dirs and not dirs[0]: dirs[0] = '/' ! key = user, host, port, string.join(dirs, '/') # XXX thread unsafe! if len(self.ftpcache) > MAXFTPCACHE: --- 432,440 ---- path, attrs = splitattr(path) path = unquote(path) ! dirs = path.split('/') dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] if dirs and not dirs[0]: dirs[0] = '/' ! key = user, host, port, '/'.join(dirs) # XXX thread unsafe! if len(self.ftpcache) > MAXFTPCACHE: *************** *** 452,458 **** for attr in attrs: attr, value = splitvalue(attr) ! if string.lower(attr) == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): ! type = string.upper(value) (fp, retrlen) = self.ftpcache[key].retrfile(file, type) if retrlen is not None and retrlen >= 0: --- 453,459 ---- for attr in attrs: attr, value = splitvalue(attr) ! if attr.lower() == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): ! type = value.upper() (fp, retrlen) = self.ftpcache[key].retrfile(file, type) if retrlen is not None and retrlen >= 0: *************** *** 477,486 **** import StringIO, mimetools, time try: ! [type, data] = string.split(url, ',', 1) except ValueError: raise IOError, ('data error', 'bad data URL') if not type: type = 'text/plain;charset=US-ASCII' ! semi = string.rfind(type, ';') if semi >= 0 and '=' not in type[semi:]: encoding = type[semi+1:] --- 478,487 ---- import StringIO, mimetools, time try: ! [type, data] = url.split(',', 1) except ValueError: raise IOError, ('data error', 'bad data URL') if not type: type = 'text/plain;charset=US-ASCII' ! semi = type.rfind(';') if semi >= 0 and '=' not in type[semi:]: encoding = type[semi+1:] *************** *** 500,504 **** msg.append('') msg.append(data) ! msg = string.join(msg, '\n') f = StringIO.StringIO(msg) headers = mimetools.Message(f, 0) --- 501,505 ---- msg.append('') msg.append(data) ! msg = '\n'.join(msg) f = StringIO.StringIO(msg) headers = mimetools.Message(f, 0) *************** *** 550,554 **** if match: scheme, realm = match.groups() ! if string.lower(scheme) == 'basic': name = 'retry_' + self.type + '_basic_auth' if data is None: --- 551,555 ---- if match: scheme, realm = match.groups() ! if scheme.lower() == 'basic': name = 'retry_' + self.type + '_basic_auth' if data is None: *************** *** 559,563 **** def retry_http_basic_auth(self, url, realm, data=None): host, selector = splithost(url) ! i = string.find(host, '@') + 1 host = host[i:] user, passwd = self.get_user_passwd(host, realm, i) --- 560,564 ---- def retry_http_basic_auth(self, url, realm, data=None): host, selector = splithost(url) ! i = host.find('@') + 1 host = host[i:] user, passwd = self.get_user_passwd(host, realm, i) *************** *** 572,576 **** def retry_https_basic_auth(self, url, realm, data=None): host, selector = splithost(url) ! i = string.find(host, '@') + 1 host = host[i:] user, passwd = self.get_user_passwd(host, realm, i) --- 573,577 ---- def retry_https_basic_auth(self, url, realm, data=None): host, selector = splithost(url) ! i = host.find('@') + 1 host = host[i:] user, passwd = self.get_user_passwd(host, realm, i) *************** *** 581,585 **** def get_user_passwd(self, host, realm, clear_cache = 0): ! key = realm + '@' + string.lower(host) if self.auth_cache.has_key(key): if clear_cache: --- 582,586 ---- def get_user_passwd(self, host, realm, clear_cache = 0): ! key = realm + '@' + host.lower() if self.auth_cache.has_key(key): if clear_cache: *************** *** 690,694 **** conn = self.ftp.ntransfercmd(cmd) except ftplib.error_perm, reason: ! if reason[:3] != '550': raise IOError, ('ftp error', reason), sys.exc_info()[2] if not conn: --- 691,695 ---- conn = self.ftp.ntransfercmd(cmd) except ftplib.error_perm, reason: ! if str(reason)[:3] != '550': raise IOError, ('ftp error', reason), sys.exc_info()[2] if not conn: *************** *** 806,810 **** else: # else replace last component ! i = string.rfind(basepath, '/') if i < 0: # basepath not absolute --- 807,811 ---- else: # else replace last component ! i = basepath.rfind('/') if i < 0: # basepath not absolute *************** *** 821,825 **** while basepath and path[:3] == '../': path = path[3:] ! i = string.rfind(basepath[:-1], '/') if i > 0: basepath = basepath[:i+1] --- 822,826 ---- while basepath and path[:3] == '../': path = path[3:] ! i = basepath[:-1].rfind('/') if i > 0: basepath = basepath[:i+1] *************** *** 861,873 **** url = url.encode("ASCII") except UnicodeError: ! raise UnicodeError("URL "+repr(url)+" contains non-ASCII characters") return url def unwrap(url): """unwrap('') --> 'type://host/path'.""" ! url = string.strip(url) if url[:1] == '<' and url[-1:] == '>': ! url = string.strip(url[1:-1]) ! if url[:4] == 'URL:': url = string.strip(url[4:]) return url --- 862,875 ---- url = url.encode("ASCII") except UnicodeError: ! raise UnicodeError("URL " + repr(url) + ! " contains non-ASCII characters") return url def unwrap(url): """unwrap('') --> 'type://host/path'.""" ! url = url.strip() if url[:1] == '<' and url[-1:] == '>': ! url = url[1:-1].strip() ! if url[:4] == 'URL:': url = url[4:].strip() return url *************** *** 950,956 **** host, port = match.group(1, 2) try: ! if not port: raise string.atoi_error, "no digits" ! nport = string.atoi(port) ! except string.atoi_error: nport = None return host, nport --- 952,958 ---- host, port = match.group(1, 2) try: ! if not port: raise ValueError, "no digits" ! nport = int(port) ! except ValueError: nport = None return host, nport *************** *** 984,988 **** """splitattr('/path;attr1=value1;attr2=value2;...') -> '/path', ['attr1=value1', 'attr2=value2', ...].""" ! words = string.splitfields(url, ';') return words[0], words[1:] --- 986,990 ---- """splitattr('/path;attr1=value1;attr2=value2;...') -> '/path', ['attr1=value1', 'attr2=value2', ...].""" ! words = url.split(';') return words[0], words[1:] *************** *** 1008,1013 **** """unquote('abc%20def') -> 'abc def'.""" mychr = chr ! myatoi = string.atoi ! list = string.split(s, '%') res = [list[0]] myappend = res.append --- 1010,1015 ---- """unquote('abc%20def') -> 'abc def'.""" mychr = chr ! myatoi = int ! list = s.split('%') res = [list[0]] myappend = res.append *************** *** 1022,1026 **** else: myappend('%' + item) ! return string.join(res, "") def unquote_plus(s): --- 1024,1028 ---- else: myappend('%' + item) ! return "".join(res) def unquote_plus(s): *************** *** 1028,1032 **** if '+' in s: # replace '+' with ' ' ! s = string.join(string.split(s, '+'), ' ') return unquote(s) --- 1030,1034 ---- if '+' in s: # replace '+' with ' ' ! s = ' '.join(s.split('+')) return unquote(s) *************** *** 1049,1053 **** if not _fast_safe.has_key(c): res[i] = '%%%02x' % ord(c) ! return string.join(res, '') def quote(s, safe = '/'): --- 1051,1055 ---- if not _fast_safe.has_key(c): res[i] = '%%%02x' % ord(c) ! return ''.join(res) def quote(s, safe = '/'): *************** *** 1080,1092 **** if c not in safe: res[i] = '%%%02x' % ord(c) ! return string.join(res, '') def quote_plus(s, safe = ''): """Quote the query fragment of a URL; replacing ' ' with '+'""" if ' ' in s: ! l = string.split(s, ' ') for i in range(len(l)): l[i] = quote(l[i], safe) ! return string.join(l, '+') else: return quote(s, safe) --- 1082,1094 ---- if c not in safe: res[i] = '%%%02x' % ord(c) ! return ''.join(res) def quote_plus(s, safe = ''): """Quote the query fragment of a URL; replacing ' ' with '+'""" if ' ' in s: ! l = s.split(' ') for i in range(len(l)): l[i] = quote(l[i], safe) ! return '+'.join(l) else: return quote(s, safe) *************** *** 1099,1103 **** v = quote_plus(str(v)) l.append(k + '=' + v) ! return string.join(l, '&') # Proxy handling --- 1101,1105 ---- v = quote_plus(str(v)) l.append(k + '=' + v) ! return '&'.join(l) # Proxy handling *************** *** 1113,1117 **** proxies = {} for name, value in os.environ.items(): ! name = string.lower(name) if value and name[-6:] == '_proxy': proxies[name[:-6]] = value --- 1115,1119 ---- proxies = {} for name, value in os.environ.items(): ! name = name.lower() if value and name[-6:] == '_proxy': proxies[name[:-6]] = value *************** *** 1224,1228 **** def reporthook(blocknum, blocksize, totalsize): # Report during remote transfers ! print "Block number: %d, Block size: %d, Total size: %d" % (blocknum, blocksize, totalsize) # Test program --- 1226,1231 ---- def reporthook(blocknum, blocksize, totalsize): # Report during remote transfers ! print "Block number: %d, Block size: %d, Total size: %d" % ( ! blocknum, blocksize, totalsize) # Test program *************** *** 1243,1247 **** print '-'*10, url, '-'*10 fn, h = urlretrieve(url, None, reporthook) ! print fn, h if h: print '======' --- 1246,1250 ---- print '-'*10, url, '-'*10 fn, h = urlretrieve(url, None, reporthook) ! print fn if h: print '======' *************** *** 1253,1257 **** if '\r' in data: table = string.maketrans("", "") ! data = string.translate(data, table, "\r") print data fn, h = None, None --- 1256,1260 ---- if '\r' in data: table = string.maketrans("", "") ! data = data.translate(table, "\r") print data fn, h = None, None From python-dev@python.org Fri Dec 15 15:09:46 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 15 Dec 2000 07:09:46 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib httplib.py,1.25,1.26 Message-ID: <200012151509.HAA18093@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv18082 Modified Files: httplib.py Log Message: Get rid of string functions. There should really be a little tool to help with this -- it's rather tedious and there are lots of special cases! Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** httplib.py 2000/12/11 20:32:20 1.25 --- httplib.py 2000/12/15 15:09:42 1.26 *************** *** 68,72 **** import socket - import string import mimetools --- 68,71 ---- *************** *** 113,120 **** print "reply:", repr(line) try: ! [version, status, reason] = string.split(line, None, 2) except ValueError: try: ! [version, status] = string.split(line, None, 1) reason = "" except ValueError: --- 112,119 ---- print "reply:", repr(line) try: ! [version, status, reason] = line.split(None, 2) except ValueError: try: ! [version, status] = line.split(None, 1) reason = "" except ValueError: *************** *** 127,131 **** self.status = status = int(status) ! self.reason = string.strip(reason) if version == 'HTTP/1.0': --- 126,130 ---- self.status = status = int(status) ! self.reason = reason.strip() if version == 'HTTP/1.0': *************** *** 153,157 **** tr_enc = self.msg.getheader('transfer-encoding') if tr_enc: ! if string.lower(tr_enc) != 'chunked': raise UnknownTransferEncoding() self.chunked = 1 --- 152,156 ---- tr_enc = self.msg.getheader('transfer-encoding') if tr_enc: ! if tr_enc.lower() != 'chunked': raise UnknownTransferEncoding() self.chunked = 1 *************** *** 163,171 **** conn = self.msg.getheader('connection') if conn: ! conn = string.lower(conn) # a "Connection: close" will always close the connection. if we # don't see that and this is not HTTP/1.1, then the connection will # close unless we see a Keep-Alive header. ! self.will_close = string.find(conn, 'close') != -1 or \ ( self.version != 11 and \ not self.msg.getheader('keep-alive') ) --- 162,170 ---- conn = self.msg.getheader('connection') if conn: ! conn = conn.lower() # a "Connection: close" will always close the connection. if we # don't see that and this is not HTTP/1.1, then the connection will # close unless we see a Keep-Alive header. ! self.will_close = conn.find('close') != -1 or \ ( self.version != 11 and \ not self.msg.getheader('keep-alive') ) *************** *** 225,232 **** if chunk_left is None: line = self.fp.readline() ! i = string.find(line, ';') if i >= 0: line = line[:i] # strip chunk-extensions ! chunk_left = string.atoi(line, 16) if chunk_left == 0: break --- 224,231 ---- if chunk_left is None: line = self.fp.readline() ! i = line.find(';') if i >= 0: line = line[:i] # strip chunk-extensions ! chunk_left = int(line, 16) if chunk_left == 0: break *************** *** 332,336 **** def _set_hostport(self, host, port): if port is None: ! i = string.find(host, ':') if i >= 0: port = int(host[i+1:]) --- 331,335 ---- def _set_hostport(self, host, port): if port is None: ! i = host.find(':') if i >= 0: port = int(host[i+1:]) *************** *** 672,677 **** def putheader(self, header, *values): "The superclass allows only one value argument." ! self._conn.putheader(header, ! string.joinfields(values, '\r\n\t')) def getreply(self): --- 671,675 ---- def putheader(self, header, *values): "The superclass allows only one value argument." ! self._conn.putheader(header, '\r\n\t'.join(values)) def getreply(self): *************** *** 799,803 **** print if headers: ! for header in headers.headers: print string.strip(header) print print h.getfile().read() --- 797,801 ---- print if headers: ! for header in headers.headers: print header.strip() print print h.getfile().read() *************** *** 814,818 **** print if headers: ! for header in headers.headers: print string.strip(header) print print hs.getfile().read() --- 812,816 ---- print if headers: ! for header in headers.headers: print header.strip() print print hs.getfile().read() From python-dev@python.org Fri Dec 15 15:37:52 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 15 Dec 2000 07:37:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib rfc822.py,1.50,1.51 Message-ID: <200012151537.HAA20340@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv20326 Modified Files: rfc822.py Log Message: Get rid of string functions. References to string.whitespace, string.digits are left. Index: rfc822.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/rfc822.py,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -r1.50 -r1.51 *** rfc822.py 2000/11/09 18:05:24 1.50 --- rfc822.py 2000/12/15 15:37:48 1.51 *************** *** 143,147 **** break # Skip unix From name time lines ! if firstline and line[:5] == 'From ': self.unixfrom = self.unixfrom + line continue --- 143,147 ---- break # Skip unix From name time lines ! if firstline and line.startswith('From '): self.unixfrom = self.unixfrom + line continue *************** *** 150,155 **** # It's a continuation line. list.append(line) ! x = (self.dict[headerseen] + "\n " + string.strip(line)) ! self.dict[headerseen] = string.strip(x) continue elif self.iscomment(line): --- 150,155 ---- # It's a continuation line. list.append(line) ! x = (self.dict[headerseen] + "\n " + line.strip()) ! self.dict[headerseen] = x.strip() continue elif self.iscomment(line): *************** *** 163,167 **** # It's a legal header line, save it. list.append(line) ! self.dict[headerseen] = string.strip(line[len(headerseen)+1:]) continue else: --- 163,167 ---- # It's a legal header line, save it. list.append(line) ! self.dict[headerseen] = line[len(headerseen)+1:].strip() continue else: *************** *** 187,193 **** on tagged data in RFC822-like formats with special header formats. """ ! i = string.find(line, ':') if i > 0: ! return string.lower(line[:i]) else: return None --- 187,193 ---- on tagged data in RFC822-like formats with special header formats. """ ! i = line.find(':') if i > 0: ! return line[:i].lower() else: return None *************** *** 224,233 **** important in the header name. """ ! name = string.lower(name) + ':' n = len(name) list = [] hit = 0 for line in self.headers: ! if string.lower(line[:n]) == name: hit = 1 elif line[:1] not in string.whitespace: --- 224,233 ---- important in the header name. """ ! name = name.lower() + ':' n = len(name) list = [] hit = 0 for line in self.headers: ! if line[:n].lower() == name: hit = 1 elif line[:1] not in string.whitespace: *************** *** 244,248 **** lines). """ ! name = string.lower(name) + ':' n = len(name) list = [] --- 244,248 ---- lines). """ ! name = name.lower() + ':' n = len(name) list = [] *************** *** 252,256 **** if line[:1] not in string.whitespace: break ! elif string.lower(line[:n]) == name: hit = 1 if hit: --- 252,256 ---- if line[:1] not in string.whitespace: break ! elif line[:n].lower() == name: hit = 1 if hit: *************** *** 272,276 **** return None list[0] = list[0][len(name) + 1:] ! return string.joinfields(list, '') def getheader(self, name, default=None): --- 272,276 ---- return None list[0] = list[0][len(name) + 1:] ! return ''.join(list) def getheader(self, name, default=None): *************** *** 283,287 **** """ try: ! return self.dict[string.lower(name)] except KeyError: return default --- 283,287 ---- """ try: ! return self.dict[name.lower()] except KeyError: return default *************** *** 302,312 **** if s[0] in string.whitespace: if current: ! current = "%s\n %s" % (current, string.strip(s)) else: ! current = string.strip(s) else: if have_header: result.append(current) ! current = string.strip(s[string.find(s, ":") + 1:]) have_header = 1 if have_header: --- 302,312 ---- if s[0] in string.whitespace: if current: ! current = "%s\n %s" % (current, s.strip()) else: ! current = s.strip() else: if have_header: result.append(current) ! current = s[s.find(":") + 1:].strip() have_header = 1 if have_header: *************** *** 342,350 **** if raw: raw.append(', ') ! i = string.find(h, ':') if i > 0: addr = h[i+1:] raw.append(addr) ! alladdrs = string.join(raw, '') a = AddrlistClass(alladdrs) return a.getaddrlist() --- 342,350 ---- if raw: raw.append(', ') ! i = h.find(':') if i > 0: addr = h[i+1:] raw.append(addr) ! alladdrs = ''.join(raw) a = AddrlistClass(alladdrs) return a.getaddrlist() *************** *** 384,388 **** def __getitem__(self, name): """Get a specific header, as from a dictionary.""" ! return self.dict[string.lower(name)] def __setitem__(self, name, value): --- 384,388 ---- def __getitem__(self, name): """Get a specific header, as from a dictionary.""" ! return self.dict[name.lower()] def __setitem__(self, name, value): *************** *** 394,400 **** """ del self[name] # Won't fail if it doesn't exist ! self.dict[string.lower(name)] = value text = name + ": " + value ! lines = string.split(text, "\n") for line in lines: self.headers.append(line + "\n") --- 394,400 ---- """ del self[name] # Won't fail if it doesn't exist ! self.dict[name.lower()] = value text = name + ": " + value ! lines = text.split("\n") for line in lines: self.headers.append(line + "\n") *************** *** 402,406 **** def __delitem__(self, name): """Delete all occurrences of a specific header, if it is present.""" ! name = string.lower(name) if not self.dict.has_key(name): return --- 402,406 ---- def __delitem__(self, name): """Delete all occurrences of a specific header, if it is present.""" ! name = name.lower() if not self.dict.has_key(name): return *************** *** 412,416 **** for i in range(len(self.headers)): line = self.headers[i] ! if string.lower(line[:n]) == name: hit = 1 elif line[:1] not in string.whitespace: --- 412,416 ---- for i in range(len(self.headers)): line = self.headers[i] ! if line[:n].lower() == name: hit = 1 elif line[:1] not in string.whitespace: *************** *** 424,428 **** def has_key(self, name): """Determine whether a message contains the named header.""" ! return self.dict.has_key(string.lower(name)) def keys(self): --- 424,428 ---- def has_key(self, name): """Determine whether a message contains the named header.""" ! return self.dict.has_key(name.lower()) def keys(self): *************** *** 467,477 **** def quote(str): """Add quotes around a string.""" ! return '"%s"' % string.join( ! string.split( ! string.join( ! string.split(str, '\\'), ! '\\\\'), ! '"'), ! '\\"') --- 467,471 ---- def quote(str): """Add quotes around a string.""" ! return str.replace('\\', '\\\\').replace('"', '\\"') *************** *** 544,548 **** # Bad email address technically, no domain. if plist: ! returnlist = [(string.join(self.commentlist), plist[0])] elif self.field[self.pos] in '.@': --- 538,542 ---- # Bad email address technically, no domain. if plist: ! returnlist = [(' '.join(self.commentlist), plist[0])] elif self.field[self.pos] in '.@': *************** *** 552,556 **** self.commentlist = oldcl addrspec = self.getaddrspec() ! returnlist = [(string.join(self.commentlist), addrspec)] elif self.field[self.pos] == ':': --- 546,550 ---- self.commentlist = oldcl addrspec = self.getaddrspec() ! returnlist = [(' '.join(self.commentlist), addrspec)] elif self.field[self.pos] == ':': *************** *** 572,582 **** if self.commentlist: ! returnlist = [(string.join(plist) + ' (' + \ ! string.join(self.commentlist) + ')', routeaddr)] ! else: returnlist = [(string.join(plist), routeaddr)] else: if plist: ! returnlist = [(string.join(self.commentlist), plist[0])] elif self.field[self.pos] in self.specials: self.pos = self.pos + 1 --- 566,576 ---- if self.commentlist: ! returnlist = [(' '.join(plist) + ' (' + \ ! ' '.join(self.commentlist) + ')', routeaddr)] ! else: returnlist = [(' '.join(plist), routeaddr)] else: if plist: ! returnlist = [(' '.join(self.commentlist), plist[0])] elif self.field[self.pos] in self.specials: self.pos = self.pos + 1 *************** *** 637,646 **** if self.pos >= len(self.field) or self.field[self.pos] != '@': ! return string.join(aslist, '') aslist.append('@') self.pos = self.pos + 1 self.gotonext() ! return string.join(aslist, '') + self.getdomain() def getdomain(self): --- 631,640 ---- if self.pos >= len(self.field) or self.field[self.pos] != '@': ! return ''.join(aslist) aslist.append('@') self.pos = self.pos + 1 self.gotonext() ! return ''.join(aslist) + self.getdomain() def getdomain(self): *************** *** 660,664 **** break else: sdlist.append(self.getatom()) ! return string.join(sdlist, '') def getdelimited(self, beginchar, endchars, allowcomments = 1): --- 654,658 ---- break else: sdlist.append(self.getatom()) ! return ''.join(sdlist) def getdelimited(self, beginchar, endchars, allowcomments = 1): *************** *** 696,700 **** self.pos = self.pos + 1 ! return string.join(slist, '') def getquote(self): --- 690,694 ---- self.pos = self.pos + 1 ! return ''.join(slist) def getquote(self): *************** *** 720,724 **** self.pos = self.pos + 1 ! return string.join(atomlist, '') def getphraselist(self): --- 714,718 ---- self.pos = self.pos + 1 ! return ''.join(atomlist) def getphraselist(self): *************** *** 757,761 **** def __str__(self): ! return string.joinfields(map(dump_address_pair, self.addresslist),", ") def __add__(self, other): --- 751,755 ---- def __str__(self): ! return ", ".join(map(dump_address_pair, self.addresslist)) def __add__(self, other): *************** *** 829,843 **** Accounts for military timezones. """ ! data = string.split(data) ! if data[0][-1] in (',', '.') or string.lower(data[0]) in _daynames: # There's a dayname here. Skip it del data[0] if len(data) == 3: # RFC 850 date, deprecated ! stuff = string.split(data[0], '-') if len(stuff) == 3: data = stuff + data[1:] if len(data) == 4: s = data[3] ! i = string.find(s, '+') if i > 0: data[3:] = [s[:i], s[i+1:]] --- 823,837 ---- Accounts for military timezones. """ ! data = data.split() ! if data[0][-1] in (',', '.') or data[0].lower() in _daynames: # There's a dayname here. Skip it del data[0] if len(data) == 3: # RFC 850 date, deprecated ! stuff = data[0].split('-') if len(stuff) == 3: data = stuff + data[1:] if len(data) == 4: s = data[3] ! i = s.find('+') if i > 0: data[3:] = [s[:i], s[i+1:]] *************** *** 848,854 **** data = data[:5] [dd, mm, yy, tm, tz] = data ! mm = string.lower(mm) if not mm in _monthnames: ! dd, mm = mm, string.lower(dd) if not mm in _monthnames: return None --- 842,848 ---- data = data[:5] [dd, mm, yy, tm, tz] = data ! mm = mm.lower() if not mm in _monthnames: ! dd, mm = mm, dd.lower() if not mm in _monthnames: return None *************** *** 857,861 **** if dd[-1] == ',': dd = dd[:-1] ! i = string.find(yy, ':') if i > 0: yy, tm = tm, yy --- 851,855 ---- if dd[-1] == ',': dd = dd[:-1] ! i = yy.find(':') if i > 0: yy, tm = tm, yy *************** *** 866,870 **** if tm[-1] == ',': tm = tm[:-1] ! tm = string.splitfields(tm, ':') if len(tm) == 2: [thh, tmm] = tm --- 860,864 ---- if tm[-1] == ',': tm = tm[:-1] ! tm = tm.split(':') if len(tm) == 2: [thh, tmm] = tm *************** *** 875,893 **** return None try: ! yy = string.atoi(yy) ! dd = string.atoi(dd) ! thh = string.atoi(thh) ! tmm = string.atoi(tmm) ! tss = string.atoi(tss) ! except string.atoi_error: return None ! tzoffset=None ! tz=string.upper(tz) if _timezones.has_key(tz): ! tzoffset=_timezones[tz] else: try: ! tzoffset=string.atoi(tz) ! except string.atoi_error: pass # Convert a timezone offset into seconds ; -0500 -> -18000 --- 869,887 ---- return None try: ! yy = int(yy) ! dd = int(dd) ! thh = int(thh) ! tmm = int(tmm) ! tss = int(tss) ! except ValueError: return None ! tzoffset = None ! tz = tz.upper() if _timezones.has_key(tz): ! tzoffset = _timezones[tz] else: try: ! tzoffset = int(tz) ! except ValueError: pass # Convert a timezone offset into seconds ; -0500 -> -18000 *************** *** 905,910 **** def parsedate(data): """Convert a time string to a time tuple.""" ! t=parsedate_tz(data) ! if type(t)==type( () ): return t[:9] else: return t --- 899,904 ---- def parsedate(data): """Convert a time string to a time tuple.""" ! t = parsedate_tz(data) ! if type(t) == type( () ): return t[:9] else: return t From python-dev@python.org Fri Dec 15 15:49:14 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 15 Dec 2000 07:49:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib mimetools.py,1.19,1.20 Message-ID: <200012151549.HAA21195@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv21183 Modified Files: mimetools.py Log Message: Get rid of string functions. Index: mimetools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mimetools.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** mimetools.py 2000/12/12 23:20:44 1.19 --- mimetools.py 2000/12/15 15:49:08 1.20 *************** *** 4,8 **** import os import rfc822 - import string import tempfile --- 4,7 ---- *************** *** 26,40 **** str = 'text/plain' if ';' in str: ! i = string.index(str, ';') self.plisttext = str[i:] str = str[:i] else: self.plisttext = '' ! fields = string.splitfields(str, '/') for i in range(len(fields)): ! fields[i] = string.lower(string.strip(fields[i])) ! self.type = string.joinfields(fields, '/') self.maintype = fields[0] ! self.subtype = string.joinfields(fields[1:], '/') def parseplist(self): --- 25,39 ---- str = 'text/plain' if ';' in str: ! i = str.index(';') self.plisttext = str[i:] str = str[:i] else: self.plisttext = '' ! fields = str.split('/') for i in range(len(fields)): ! fields[i] = fields[i].strip().lower() ! self.type = '/'.join(fields) self.maintype = fields[0] ! self.subtype = '/'.join(fields[1:]) def parseplist(self): *************** *** 45,57 **** if ';' in str: # XXX Should parse quotes! ! end = string.index(str, ';') else: end = len(str) f = str[:end] if '=' in f: ! i = string.index(f, '=') ! f = string.lower(string.strip(f[:i])) + \ ! '=' + string.strip(f[i+1:]) ! self.plist.append(string.strip(f)) str = str[end:] --- 44,56 ---- if ';' in str: # XXX Should parse quotes! ! end = str.index(';') else: end = len(str) f = str[:end] if '=' in f: ! i = f.index('=') ! f = f[:i].strip().lower() + \ ! '=' + f[i+1:].strip() ! self.plist.append(f.strip()) str = str[end:] *************** *** 60,64 **** def getparam(self, name): ! name = string.lower(name) + '=' n = len(name) for p in self.plist: --- 59,63 ---- def getparam(self, name): ! name = name.lower() + '=' n = len(name) for p in self.plist: *************** *** 70,76 **** result = [] for p in self.plist: ! i = string.find(p, '=') if i >= 0: ! result.append(string.lower(p[:i])) return result --- 69,75 ---- result = [] for p in self.plist: ! i = p.find('=') if i >= 0: ! result.append(p[:i].lower()) return result *************** *** 78,82 **** if self.encodingheader is None: return '7bit' ! return string.lower(self.encodingheader) def gettype(self): --- 77,81 ---- if self.encodingheader is None: return '7bit' ! return self.encodingheader.lower() def gettype(self): From python-dev@python.org Fri Dec 15 19:07:20 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 15 Dec 2000 11:07:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib librandom.tex,1.14,1.15 Message-ID: <200012151907.LAA01315@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv1307/lib Modified Files: librandom.tex Log Message: Added documentation for random.shuffle(). Index: librandom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/librandom.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** librandom.tex 2000/06/30 15:32:31 1.14 --- librandom.tex 2000/12/15 19:07:17 1.15 *************** *** 89,92 **** --- 89,109 ---- \end{funcdesc} + + This function does not represent a specific distribution, but + implements a standard useful algorithm: + + \begin{funcdesc}{shuffle}{x\optional{, random}} + Shuffle the sequence \var{x} in place. + The optional argument \var{random} is a 0-argument function returning + a random float in [0.0, 1.0); by default, this is the function + \function{random()}. + + Note that for even rather small \code{len(\var{x})}, the total number + of permutations of \var{x} is larger than the period of most random + number generators; this implies that most permutations of a long + sequence can never be generated. + \end{funcdesc} + + \begin{seealso} \seemodule{whrandom}{The standard Python random number generator.} From python-dev@python.org Fri Dec 15 20:08:43 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 15 Dec 2000 12:08:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib threading.py,1.9,1.10 Message-ID: <200012152008.MAA05958@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv5943 Modified Files: threading.py Log Message: Comment out a debugging print statement that triggered a complaint in c.l.py. Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** threading.py 2000/08/18 15:50:54 1.9 --- threading.py 2000/12/15 20:08:39 1.10 *************** *** 518,522 **** return _active[_get_ident()] except KeyError: ! print "currentThread(): no current thread for", _get_ident() return _DummyThread() --- 518,522 ---- return _active[_get_ident()] except KeyError: ! ##print "currentThread(): no current thread for", _get_ident() return _DummyThread() From python-dev@python.org Fri Dec 15 21:08:05 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 15 Dec 2000 13:08:05 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom __init__.py,1.4,1.5 Message-ID: <200012152108.NAA09470@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory slayer.i.sourceforge.net:/tmp/cvs-serv9455 Modified Files: __init__.py Log Message: DOMException.__init__(): Remember to pass self to Exception.__init__(). Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/__init__.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** __init__.py 2000/12/13 16:35:53 1.4 --- __init__.py 2000/12/15 21:07:59 1.5 *************** *** 66,70 **** raise RuntimeError( "DOMException should not be instaniated directly") ! apply(Exception.__init__, args, kw) --- 66,70 ---- raise RuntimeError( "DOMException should not be instaniated directly") ! apply(Exception.__init__, (self,) + args, kw) From python-dev@python.org Tue Dec 19 20:59:07 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 19 Dec 2000 12:59:07 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects fileobject.c,2.94,2.95 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv1678 Modified Files: fileobject.c Log Message: Patch #102868 from cgw: fix memory leak when an EOF is encountered using GNU libc's getline() Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.94 retrieving revision 2.95 diff -C2 -r2.94 -r2.95 *** fileobject.c 2000/11/30 18:27:50 2.94 --- fileobject.c 2000/12/19 20:59:04 2.95 *************** *** 661,664 **** --- 661,667 ---- Py_END_ALLOW_THREADS if (n1 == -1) { + if (buf){ + free(buf); + } clearerr(fp); if (PyErr_CheckSignals()) { From python-dev@python.org Tue Dec 19 22:49:09 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 19 Dec 2000 14:49:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.69,2.70 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv18623 Modified Files: unicodeobject.c Log Message: Patch #102940: use only printable Unicode chars in reporting incorrect % characters; characters outside the printable range are replaced with '?' Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.69 retrieving revision 2.70 diff -C2 -r2.69 -r2.70 *** unicodeobject.c 2000/12/19 02:23:19 2.69 --- unicodeobject.c 2000/12/19 22:49:06 2.70 *************** *** 5070,5074 **** "unsupported format character '%c' (0x%x) " "at index %i", ! c, c, fmt -1 - PyUnicode_AS_UNICODE(uformat)); goto onError; } --- 5070,5075 ---- "unsupported format character '%c' (0x%x) " "at index %i", ! (31<=c && c<=126) ? c : '?', ! c, fmt -1 - PyUnicode_AS_UNICODE(uformat)); goto onError; } From python-dev@python.org Wed Dec 20 00:48:15 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 19 Dec 2000 16:48:15 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils/command install.py,1.54,1.55 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv4764 Modified Files: install.py Log Message: Add forgotten initialization. Fixes bug #120994, "Traceback with DISTUTILS_DEBUG set" Index: install.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/install.py,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -r1.54 -r1.55 *** install.py 2000/10/14 04:06:40 1.54 --- install.py 2000/12/20 00:48:12 1.55 *************** *** 147,150 **** --- 147,151 ---- self.compile = None + self.no_compile = None self.optimize = None From python-dev@python.org Wed Dec 20 00:55:09 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 19 Dec 2000 16:55:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects fileobject.c,2.95,2.96 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv5580 Modified Files: fileobject.c Log Message: Make the indentation consistently use tabs instead of using spaces just in one place. Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.95 retrieving revision 2.96 diff -C2 -r2.95 -r2.96 *** fileobject.c 2000/12/19 20:59:04 2.95 --- fileobject.c 2000/12/20 00:55:07 2.96 *************** *** 661,667 **** Py_END_ALLOW_THREADS if (n1 == -1) { ! if (buf){ ! free(buf); ! } clearerr(fp); if (PyErr_CheckSignals()) { --- 661,667 ---- Py_END_ALLOW_THREADS if (n1 == -1) { ! if (buf){ ! free(buf); ! } clearerr(fp); if (PyErr_CheckSignals()) { From python-dev@python.org Wed Dec 20 00:55:48 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 19 Dec 2000 16:55:48 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_format.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv5603 Modified Files: test_format.py Log Message: Change expected message for ValueError, fixing bug #126400 Index: test_format.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_format.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** test_format.py 2000/12/15 13:09:06 1.4 --- test_format.py 2000/12/20 00:55:46 1.5 *************** *** 198,201 **** "unsupported format character 'a' (0x61) at index 5") test_exc(u'abc %\u3000', 1, ValueError, ! "unsupported format character '\000' (0x3000) at index 5") --- 198,201 ---- "unsupported format character 'a' (0x61) at index 5") test_exc(u'abc %\u3000', 1, ValueError, ! "unsupported format character '?' (0x3000) at index 5") From python-dev@python.org Wed Dec 20 14:36:58 2000 From: python-dev@python.org (A.M. Kuchling) Date: Wed, 20 Dec 2000 06:36:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.183,2.184 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv17873 Modified Files: bltinmodule.c Log Message: Patch #102955, fixing one of the warnings in bug #121479: Simplifies ord()'s logic at the cost of some code duplication, removing a " `ord' might be used uninitialized in this function" warning Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.183 retrieving revision 2.184 diff -C2 -r2.183 -r2.184 *** bltinmodule.c 2000/12/04 15:42:11 2.183 --- bltinmodule.c 2000/12/20 14:36:56 2.184 *************** *** 1,3 **** ! /* Built-in functions */ --- 1,3 ---- ! fo /* Built-in functions */ *************** *** 1513,1522 **** if (PyString_Check(obj)) { size = PyString_GET_SIZE(obj); ! if (size == 1) ord = (long)((unsigned char)*PyString_AS_STRING(obj)); } else if (PyUnicode_Check(obj)) { size = PyUnicode_GET_SIZE(obj); ! if (size == 1) ord = (long)*PyUnicode_AS_UNICODE(obj); } else { PyErr_Format(PyExc_TypeError, --- 1513,1526 ---- if (PyString_Check(obj)) { size = PyString_GET_SIZE(obj); ! if (size == 1) { ord = (long)((unsigned char)*PyString_AS_STRING(obj)); + return PyInt_FromLong(ord); + } } else if (PyUnicode_Check(obj)) { size = PyUnicode_GET_SIZE(obj); ! if (size == 1) { ord = (long)*PyUnicode_AS_UNICODE(obj); + return PyInt_FromLong(ord); + } } else { PyErr_Format(PyExc_TypeError, *************** *** 1525,1530 **** return NULL; } - if (size == 1) - return PyInt_FromLong(ord); PyErr_Format(PyExc_TypeError, --- 1529,1532 ---- From python-dev@python.org Wed Dec 20 14:47:26 2000 From: python-dev@python.org (A.M. Kuchling) Date: Wed, 20 Dec 2000 06:47:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom minidom.py,1.15,1.16 pulldom.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory usw-pr-cvs1:/tmp/cvs-serv20506 Modified Files: minidom.py pulldom.py Log Message: Patch #102492, fixing bug #116677: give minidom.py behaviour that complies with the DOM Level 1 REC, which says that when a node newChild is added to the tree, "if the newChild is already in the tree, it is first removed." pulldom.py is patched to use the public minidom interface instead of setting .parentNode itself. Possibly this reduces pulldom's efficiency; someone else will have to pronounce on that. Index: minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/minidom.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** minidom.py 2000/12/14 18:16:11 1.15 --- minidom.py 2000/12/20 14:47:24 1.16 *************** *** 41,44 **** --- 41,45 ---- def __init__(self): self.childNodes = [] + self.parentNode = None if Node._debug: index = repr(id(self)) + repr(self.__class__) *************** *** 99,102 **** --- 100,105 ---- def insertBefore(self, newChild, refChild): + if newChild.parentNode is not None: + newChild.parentNode.removeChild(newChild) if refChild is None: self.appendChild(newChild) *************** *** 117,120 **** --- 120,125 ---- def appendChild(self, node): + if node.parentNode is not None: + node.parentNode.removeChild(node) if self.childNodes: last = self.lastChild *************** *** 130,133 **** --- 135,140 ---- def replaceChild(self, newChild, oldChild): + if newChild.parentNode is not None: + newChild.parentNode.removeChild(newChild) if newChild is oldChild: return *************** *** 145,148 **** --- 152,161 ---- def removeChild(self, oldChild): self.childNodes.remove(oldChild) + if oldChild.nextSibling is not None: + oldChild.nextSibling.previousSibling = oldChild.previousSibling + if oldChild.previousSibling is not None: + oldChild.previousSibling.nextSibling = oldChild.nextSibling + oldChild.nextSibling = oldChild.previousSibling = None + if self._makeParentNodes: oldChild.parentNode = None *************** *** 607,614 **** --- 620,639 ---- def appendChild(self, node): + if node.parentNode is not None: + node.parentNode.removeChild(node) + if node.nodeType == Node.ELEMENT_NODE \ and self._get_documentElement(): raise TypeError, "two document elements disallowed" return Node.appendChild(self, node) + + def removeChild(self, oldChild): + self.childNodes.remove(oldChild) + oldChild.nextSibling = oldChild.previousSibling = None + oldChild.parentNode = None + if self.documentElement is oldChild: + self.documentElement = None + + return oldChild def _get_documentElement(self): Index: pulldom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/pulldom.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** pulldom.py 2000/12/14 18:00:18 1.12 --- pulldom.py 2000/12/20 14:47:24 1.13 *************** *** 56,60 **** node.setAttributeNode(attr) ! node.parentNode = self.curNode self.curNode = node --- 56,62 ---- node.setAttributeNode(attr) ! ## print self.curNode, self.curNode.childNodes, node, node.parentNode ! self.curNode.appendChild(node) ! # node.parentNode = self.curNode self.curNode = node *************** *** 78,82 **** node.setAttributeNode(attr) ! node.parentNode = self.curNode self.curNode = node --- 80,85 ---- node.setAttributeNode(attr) ! #node.parentNode = self.curNode ! self.curNode.appendChild(node) self.curNode = node *************** *** 94,99 **** def comment(self, s): node = self.document.createComment(s) ! parent = self.curNode ! node.parentNode = parent self.lastEvent[1] = [(COMMENT, node), None] self.lastEvent = self.lastEvent[1] --- 97,103 ---- def comment(self, s): node = self.document.createComment(s) ! self.curNode.appendChild(node) ! # parent = self.curNode ! # node.parentNode = parent self.lastEvent[1] = [(COMMENT, node), None] self.lastEvent = self.lastEvent[1] *************** *** 103,108 **** node = self.document.createProcessingInstruction(target, data) ! parent = self.curNode ! node.parentNode = parent self.lastEvent[1] = [(PROCESSING_INSTRUCTION, node), None] self.lastEvent = self.lastEvent[1] --- 107,113 ---- node = self.document.createProcessingInstruction(target, data) ! self.curNode.appendChild(node) ! # parent = self.curNode ! # node.parentNode = parent self.lastEvent[1] = [(PROCESSING_INSTRUCTION, node), None] self.lastEvent = self.lastEvent[1] *************** *** 111,116 **** def ignorableWhitespace(self, chars): node = self.document.createTextNode(chars) ! parent = self.curNode ! node.parentNode = parent self.lastEvent[1] = [(IGNORABLE_WHITESPACE, node), None] self.lastEvent = self.lastEvent[1] --- 116,122 ---- def ignorableWhitespace(self, chars): node = self.document.createTextNode(chars) ! self.curNode.appendChild(node) ! # parent = self.curNode ! # node.parentNode = parent self.lastEvent[1] = [(IGNORABLE_WHITESPACE, node), None] self.lastEvent = self.lastEvent[1] *************** *** 119,124 **** def characters(self, chars): node = self.document.createTextNode(chars) ! parent = self.curNode ! node.parentNode = parent self.lastEvent[1] = [(CHARACTERS, node), None] self.lastEvent = self.lastEvent[1] --- 125,131 ---- def characters(self, chars): node = self.document.createTextNode(chars) ! self.curNode.appendChild(node) ! # parent = self.curNode ! # node.parentNode = parent self.lastEvent[1] = [(CHARACTERS, node), None] self.lastEvent = self.lastEvent[1] From python-dev@python.org Wed Dec 20 15:07:37 2000 From: python-dev@python.org (A.M. Kuchling) Date: Wed, 20 Dec 2000 07:07:37 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.184,2.185 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv24457 Modified Files: bltinmodule.c Log Message: Whoops! Two stray characters crept in to my last check-in Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.184 retrieving revision 2.185 diff -C2 -r2.184 -r2.185 *** bltinmodule.c 2000/12/20 14:36:56 2.184 --- bltinmodule.c 2000/12/20 15:07:34 2.185 *************** *** 1,3 **** ! fo /* Built-in functions */ --- 1,3 ---- ! /* Built-in functions */ From python-dev@python.org Wed Dec 20 16:43:01 2000 From: python-dev@python.org (Barry Warsaw) Date: Wed, 20 Dec 2000 08:43:01 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0232.txt,1.2,1.3 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv14147 Modified Files: pep-0232.txt Log Message: Another suggested syntax for inlining attributes, by Aaron Digulla. Index: pep-0232.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0232.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** pep-0232.txt 2000/12/14 17:20:46 1.2 --- pep-0232.txt 2000/12/20 16:42:59 1.3 *************** *** 100,105 **** syntactic support for conveniently setting. It may be worthwhile to enhance the language for supporting easy function ! attribute setting. One suggestion that has been raised in ! previous discussions is this syntax: def a { --- 100,104 ---- syntactic support for conveniently setting. It may be worthwhile to enhance the language for supporting easy function ! attribute setting. Here are some suggested syntaxes: def a { *************** *** 110,115 **** # ... ! I.e., that a dictionary literal placed between the function ! name and the argument parentheses be assigned to func_dict. It isn't currently clear if special syntax is necessary or --- 109,118 ---- # ... ! def a(args): ! """The usual docstring.""" ! {'publish' : 1, ! 'unittest': '''...''', ! # etc. ! } It isn't currently clear if special syntax is necessary or From python-dev@python.org Thu Dec 21 16:22:24 2000 From: python-dev@python.org (A.M. Kuchling) Date: Thu, 21 Dec 2000 08:22:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.43,2.44 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv4442 Modified Files: _cursesmodule.c Log Message: Another patch from Thomas Gellekum: add .overlay() and .overwrite() window methods Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.43 retrieving revision 2.44 diff -C2 -r2.43 -r2.44 *** _cursesmodule.c 2000/12/15 00:44:02 2.43 --- _cursesmodule.c 2000/12/21 16:22:22 2.44 *************** *** 40,49 **** unsupported functions: ! addchnstr addchstr chgat color_set copywin define_key del_curterm delscreen dupwin inchnstr inchstr innstr keyok mcprint mvaddchnstr mvaddchstr mvchgat mvcur mvinchnstr mvinchstr mvinnstr mmvwaddchnstr mvwaddchstr mvwchgat mvwgetnstr mvwinchnstr mvwinchstr mvwinnstr newterm ! overlay overwrite resizeterm restartterm ripoffline scr_dump scr_init scr_restore scr_set scrl set_curterm set_term setterm tgetent tgetflag tgetnum tgetstr tgoto timeout tputs --- 40,49 ---- unsupported functions: ! addchnstr addchstr chgat color_set define_key del_curterm delscreen dupwin inchnstr inchstr innstr keyok mcprint mvaddchnstr mvaddchstr mvchgat mvcur mvinchnstr mvinchstr mvinnstr mmvwaddchnstr mvwaddchstr mvwchgat mvwgetnstr mvwinchnstr mvwinchstr mvwinnstr newterm ! resizeterm restartterm ripoffline scr_dump scr_init scr_restore scr_set scrl set_curterm set_term setterm tgetent tgetflag tgetnum tgetstr tgoto timeout tputs *************** *** 1083,1086 **** --- 1083,1162 ---- static PyObject * + PyCursesWindow_Overlay(PyCursesWindowObject *self, PyObject *args) + { + PyCursesWindowObject *temp; + int use_copywin = FALSE; + int sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol; + int rtn; + + switch (ARG_COUNT(args)) { + case 1: + if (!PyArg_ParseTuple(args, "O!;window object", + &PyCursesWindow_Type, &temp)) + return NULL; + break; + case 7: + if (!PyArg_ParseTuple(args, "(O!iiiiii);window object, int, int, int, int, int, int", + &PyCursesWindow_Type, &temp, &sminrow, &smincol, + &dminrow, &dmincol, &dmaxrow, &dmaxcol)) + return NULL; + use_copywin = TRUE; + break; + default: + PyErr_SetString(PyExc_TypeError, + "overlay requires one or seven arguments"); + return NULL; + } + + if (use_copywin == TRUE) { + rtn = copywin(self->win, temp->win, sminrow, smincol, + dminrow, dmincol, dmaxrow, dmaxcol, TRUE); + return PyCursesCheckERR(rtn, "copywin"); + } + else { + rtn = overlay(self->win, temp->win); + return PyCursesCheckERR(rtn, "overlay"); + } + } + + static PyObject * + PyCursesWindow_Overwrite(PyCursesWindowObject *self, PyObject *args) + { + PyCursesWindowObject *temp; + int use_copywin = FALSE; + int sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol; + int rtn; + + switch (ARG_COUNT(args)) { + case 1: + if (!PyArg_ParseTuple(args, "O!;window object", + &PyCursesWindow_Type, &temp)) + return NULL; + break; + case 7: + if (!PyArg_ParseTuple(args, "(O!iiiiii);window object, int, int, int, int, int, int", + &PyCursesWindow_Type, &temp, &sminrow, &smincol, + &dminrow, &dmincol, &dmaxrow, &dmaxcol)) + return NULL; + use_copywin = TRUE; + break; + default: + PyErr_SetString(PyExc_TypeError, + "overwrite requires one or seven arguments"); + return NULL; + } + + if (use_copywin == TRUE) { + rtn = copywin(self->win, temp->win, sminrow, smincol, + dminrow, dmincol, dmaxrow, dmaxcol, FALSE); + return PyCursesCheckERR(rtn, "copywin"); + } + else { + rtn = overwrite(self->win, temp->win); + return PyCursesCheckERR(rtn, "overwrite"); + } + } + + static PyObject * PyCursesWindow_PutWin(PyCursesWindowObject *self, PyObject *args) { *************** *** 1324,1328 **** {"noutrefresh", (PyCFunction)PyCursesWindow_NoOutRefresh}, /* Backward compatibility alias -- remove in Python 2.1 */ ! {"nooutrefresh", (PyCFunction)PyCursesWindow_NoOutRefresh}, {"putwin", (PyCFunction)PyCursesWindow_PutWin}, {"redrawln", (PyCFunction)PyCursesWindow_RedrawLine}, --- 1400,1406 ---- {"noutrefresh", (PyCFunction)PyCursesWindow_NoOutRefresh}, /* Backward compatibility alias -- remove in Python 2.1 */ ! {"nooutrefresh", (PyCFunction)PyCursesWindow_NoOutRefresh}, ! {"overlay", (PyCFunction)PyCursesWindow_Overlay, METH_VARARGS}, ! {"overwrite", (PyCFunction)PyCursesWindow_Overwrite, METH_VARARGS}, {"putwin", (PyCFunction)PyCursesWindow_PutWin}, {"redrawln", (PyCFunction)PyCursesWindow_RedrawLine}, From python-dev@python.org Thu Dec 21 16:25:47 2000 From: python-dev@python.org (A.M. Kuchling) Date: Thu, 21 Dec 2000 08:25:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcurses.tex,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv4799 Modified Files: libcurses.tex Log Message: Document the window.overlay() and .overwrite() methods Index: libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** libcurses.tex 2000/12/15 01:03:23 1.24 --- libcurses.tex 2000/12/21 16:25:44 1.25 *************** *** 861,864 **** --- 861,890 ---- \end{methoddesc} + \begin{methoddesc}{overlay}{destwin\optional{, sminrow, smincol, + dminrow, dmincol, dmaxrow, dmaxcol}} + Overlay the window on top of \var{destwin}. The windows need not be + the same size, only the overlapping region is copied. This copy is + non-destructive, which means that the current background character + does not overwrite the old contents of \var{destwin}. + + To get fine-grained control over the copied region, the second form + of \method{overlay} can be used. \var{sminrow} and \var{smincol} are + the upper-left coordinates of the source window, and the other variables + mark a rectangle in the destination window. + \end{methoddesc} + + \begin{methoddesc}{overwrite}{destwin\optional{, sminrow, smincol, + dminrow, dmincol, dmaxrow, dmaxcol}} + Overwrite the window on top of \var{destwin}. The windows need not be + the same size, in which case only the overlapping region is copied. This copy is + destructive, which means that the current background character + overwrites the old contents of \var{destwin}. + + To get fine-grained control over the copied region, the second form + of \method{overwrite} can be used. \var{sminrow} and \var{smincol} are + the upper-left coordinates of the source window, the other variables + mark a rectangle in the destination window. + \end{methoddesc} + \begin{methoddesc}{putwin}{file} Writes all data associated with the window into the provided file From python-dev@python.org Thu Dec 21 16:26:39 2000 From: python-dev@python.org (A.M. Kuchling) Date: Thu, 21 Dec 2000 08:26:39 -0800 Subject: [Python-checkins] CVS: python/dist/src/Demo/curses xmas.py,NONE,1.1 README,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/curses In directory usw-pr-cvs1:/tmp/cvs-serv4902 Modified Files: README Added Files: xmas.py Log Message: Another demo from Thomas Gellekum (seasonally-themed, too) --- NEW FILE: xmas.py --- # asciixmas # December 1989 Larry Bartz Indianapolis, IN # # $Id: xmas.py,v 1.1 2000/12/21 16:26:37 akuchling Exp $ # # I'm dreaming of an ascii character-based monochrome Christmas, # Just like the one's I used to know! # Via a full duplex communications channel, # At 9600 bits per second, # Even though it's kinda slow. # # I'm dreaming of an ascii character-based monochrome Christmas, # With ev'ry C program I write! # May your screen be merry and bright! # And may all your Christmases be amber or green, # (for reduced eyestrain and improved visibility)! # # # Notes on the Python version: # I used a couple of `try...except curses.error' to get around some functions # returning ERR. The errors come from using wrapping functions to fill # windows to the last character cell. The C version doesn't have this problem, # it simply ignores any return values. # import curses import sys FROMWHO = "Thomas Gellekum " def set_color(win, color): if curses.has_colors(): n = color + 1 curses.init_pair(n, color, my_bg) win.attroff(curses.A_COLOR) win.attron(curses.color_pair(n)) def unset_color(win): if curses.has_colors(): win.attrset(curses.color_pair(0)) def look_out(msecs): curses.napms(msecs) if stdscr.getch() != -1: curses.beep() sys.exit(0) def boxit(): for y in range(0, 20): stdscr.addch(y, 7, ord('|')) for x in range(8, 80): stdscr.addch(19, x, ord('_')) for x in range(0, 80): stdscr.addch(22, x, ord('_')) return def seas(): stdscr.addch(4, 1, ord('S')) stdscr.addch(6, 1, ord('E')) stdscr.addch(8, 1, ord('A')) stdscr.addch(10, 1, ord('S')) stdscr.addch(12, 1, ord('O')) stdscr.addch(14, 1, ord('N')) stdscr.addch(16, 1, ord("'")) stdscr.addch(18, 1, ord('S')) return def greet(): stdscr.addch(3, 5, ord('G')) stdscr.addch(5, 5, ord('R')) stdscr.addch(7, 5, ord('E')) stdscr.addch(9, 5, ord('E')) stdscr.addch(11, 5, ord('T')) stdscr.addch(13, 5, ord('I')) stdscr.addch(15, 5, ord('N')) stdscr.addch(17, 5, ord('G')) stdscr.addch(19, 5, ord('S')) return def fromwho(): stdscr.addstr(21, 13, FROMWHO) return def tree(): set_color(treescrn, curses.COLOR_GREEN) treescrn.addch(1, 11, ord('/')) treescrn.addch(2, 11, ord('/')) treescrn.addch(3, 10, ord('/')) treescrn.addch(4, 9, ord('/')) treescrn.addch(5, 9, ord('/')) treescrn.addch(6, 8, ord('/')) treescrn.addch(7, 7, ord('/')) treescrn.addch(8, 6, ord('/')) treescrn.addch(9, 6, ord('/')) treescrn.addch(10, 5, ord('/')) treescrn.addch(11, 3, ord('/')) treescrn.addch(12, 2, ord('/')) treescrn.addch(1, 13, ord('\\')) treescrn.addch(2, 13, ord('\\')) treescrn.addch(3, 14, ord('\\')) treescrn.addch(4, 15, ord('\\')) treescrn.addch(5, 15, ord('\\')) treescrn.addch(6, 16, ord('\\')) treescrn.addch(7, 17, ord('\\')) treescrn.addch(8, 18, ord('\\')) treescrn.addch(9, 18, ord('\\')) treescrn.addch(10, 19, ord('\\')) treescrn.addch(11, 21, ord('\\')) treescrn.addch(12, 22, ord('\\')) treescrn.addch(4, 10, ord('_')) treescrn.addch(4, 14, ord('_')) treescrn.addch(8, 7, ord('_')) treescrn.addch(8, 17, ord('_')) treescrn.addstr(13, 0, "//////////// \\\\\\\\\\\\\\\\\\\\\\\\") treescrn.addstr(14, 11, "| |") treescrn.addstr(15, 11, "|_|") unset_color(treescrn) treescrn.refresh() w_del_msg.refresh() return def balls(): treescrn.overlay(treescrn2) set_color(treescrn2, curses.COLOR_BLUE) treescrn2.addch(3, 9, ord('@')) treescrn2.addch(3, 15, ord('@')) treescrn2.addch(4, 8, ord('@')) treescrn2.addch(4, 16, ord('@')) treescrn2.addch(5, 7, ord('@')) treescrn2.addch(5, 17, ord('@')) treescrn2.addch(7, 6, ord('@')) treescrn2.addch(7, 18, ord('@')) treescrn2.addch(8, 5, ord('@')) treescrn2.addch(8, 19, ord('@')) treescrn2.addch(10, 4, ord('@')) treescrn2.addch(10, 20, ord('@')) treescrn2.addch(11, 2, ord('@')) treescrn2.addch(11, 22, ord('@')) treescrn2.addch(12, 1, ord('@')) treescrn2.addch(12, 23, ord('@')) unset_color(treescrn2) treescrn2.refresh() w_del_msg.refresh() return def star(): treescrn2.attrset(curses.A_BOLD | curses.A_BLINK) set_color(treescrn2, curses.COLOR_YELLOW) treescrn2.addch(0, 12, ord('*')) treescrn2.standend() unset_color(treescrn2) treescrn2.refresh() w_del_msg.refresh() return def strng1(): treescrn2.attrset(curses.A_BOLD | curses.A_BLINK) set_color(treescrn2, curses.COLOR_WHITE) treescrn2.addch(3, 13, ord('\'')) treescrn2.addch(3, 12, ord(':')) treescrn2.addch(3, 11, ord('.')) treescrn2.attroff(curses.A_BOLD | curses.A_BLINK) unset_color(treescrn2) treescrn2.refresh() w_del_msg.refresh() return def strng2(): treescrn2.attrset(curses.A_BOLD | curses.A_BLINK) set_color(treescrn2, curses.COLOR_WHITE) treescrn2.addch(5, 14, ord('\'')) treescrn2.addch(5, 13, ord(':')) treescrn2.addch(5, 12, ord('.')) treescrn2.addch(5, 11, ord(',')) treescrn2.addch(6, 10, ord('\'')) treescrn2.addch(6, 9, ord(':')) treescrn2.attroff(curses.A_BOLD | curses.A_BLINK) unset_color(treescrn2) treescrn2.refresh() w_del_msg.refresh() return def strng3(): treescrn2.attrset(curses.A_BOLD | curses.A_BLINK) set_color(treescrn2, curses.COLOR_WHITE) treescrn2.addch(7, 16, ord('\'')) treescrn2.addch(7, 15, ord(':')) treescrn2.addch(7, 14, ord('.')) treescrn2.addch(7, 13, ord(',')) treescrn2.addch(8, 12, ord('\'')) treescrn2.addch(8, 11, ord(':')) treescrn2.addch(8, 10, ord('.')) treescrn2.addch(8, 9, ord(',')) treescrn2.attroff(curses.A_BOLD | curses.A_BLINK) unset_color(treescrn2) treescrn2.refresh() w_del_msg.refresh() return def strng4(): treescrn2.attrset(curses.A_BOLD | curses.A_BLINK) set_color(treescrn2, curses.COLOR_WHITE) treescrn2.addch(9, 17, ord('\'')) treescrn2.addch(9, 16, ord(':')) treescrn2.addch(9, 15, ord('.')) treescrn2.addch(9, 14, ord(',')) treescrn2.addch(10, 13, ord('\'')) treescrn2.addch(10, 12, ord(':')) treescrn2.addch(10, 11, ord('.')) treescrn2.addch(10, 10, ord(',')) treescrn2.addch(11, 9, ord('\'')) treescrn2.addch(11, 8, ord(':')) treescrn2.addch(11, 7, ord('.')) treescrn2.addch(11, 6, ord(',')) treescrn2.addch(12, 5, ord('\'')) treescrn2.attroff(curses.A_BOLD | curses.A_BLINK) unset_color(treescrn2) treescrn2.refresh() w_del_msg.refresh() return def strng5(): treescrn2.attrset(curses.A_BOLD | curses.A_BLINK) set_color(treescrn2, curses.COLOR_WHITE) treescrn2.addch(11, 19, ord('\'')) treescrn2.addch(11, 18, ord(':')) treescrn2.addch(11, 17, ord('.')) treescrn2.addch(11, 16, ord(',')) treescrn2.addch(12, 15, ord('\'')) treescrn2.addch(12, 14, ord(':')) treescrn2.addch(12, 13, ord('.')) treescrn2.addch(12, 12, ord(',')) treescrn2.attroff(curses.A_BOLD | curses.A_BLINK) unset_color(treescrn2) # save a fully lit tree treescrn2.overlay(treescrn) treescrn2.refresh() w_del_msg.refresh() return def blinkit(): treescrn8.touchwin() for cycle in range(0, 5): if cycle == 0: treescrn3.overlay(treescrn8) treescrn8.refresh() w_del_msg.refresh() break elif cycle == 1: treescrn4.overlay(treescrn8) treescrn8.refresh() w_del_msg.refresh() break elif cycle == 2: treescrn5.overlay(treescrn8) treescrn8.refresh() w_del_msg.refresh() break elif cycle == 3: treescrn6.overlay(treescrn8) treescrn8.refresh() w_del_msg.refresh() break elif cycle == 4: treescrn7.overlay(treescrn8) treescrn8.refresh() w_del_msg.refresh() break treescrn8.touchwin() # ALL ON treescrn.overlay(treescrn8) treescrn8.refresh() w_del_msg.refresh() return def deer_step(win, y, x): win.mvwin(y, x) win.refresh() w_del_msg.refresh() look_out(5) def reindeer(): y_pos = 0 for x_pos in range(70, 62, -1): if x_pos < 66: y_pos = 1 for looper in range(0, 4): dotdeer0.addch(y_pos, x_pos, ord('.')) dotdeer0.refresh() w_del_msg.refresh() dotdeer0.erase() dotdeer0.refresh() w_del_msg.refresh() look_out(50) y_pos = 2 for x_pos in range(x_pos - 1, 50, -1): for looper in range(0, 4): if x_pos < 56: y_pos = 3 try: stardeer0.addch(y_pos, x_pos, ord('*')) except curses.error: pass stardeer0.refresh() w_del_msg.refresh() stardeer0.erase() stardeer0.refresh() w_del_msg.refresh() else: dotdeer0.addch(y_pos, x_pos, ord('*')) dotdeer0.refresh() w_del_msg.refresh() dotdeer0.erase() dotdeer0.refresh() w_del_msg.refresh() x_pos = 58 for y_pos in range(2, 5): lildeer0.touchwin() lildeer0.refresh() w_del_msg.refresh() for looper in range(0, 4): deer_step(lildeer3, y_pos, x_pos) deer_step(lildeer2, y_pos, x_pos) deer_step(lildeer1, y_pos, x_pos) deer_step(lildeer2, y_pos, x_pos) deer_step(lildeer3, y_pos, x_pos) lildeer0.touchwin() lildeer0.refresh() w_del_msg.refresh() x_pos -= 2 x_pos = 35 for y_pos in range(5, 10): middeer0.touchwin() middeer0.refresh() w_del_msg.refresh() for looper in range(0, 2): deer_step(middeer3, y_pos, x_pos) deer_step(middeer2, y_pos, x_pos) deer_step(middeer1, y_pos, x_pos) deer_step(middeer2, y_pos, x_pos) deer_step(middeer3, y_pos, x_pos) middeer0.touchwin() middeer0.refresh() w_del_msg.refresh() x_pos -= 3 look_out(300) y_pos = 1 for x_pos in range(8, 16): deer_step(bigdeer4, y_pos, x_pos) deer_step(bigdeer3, y_pos, x_pos) deer_step(bigdeer2, y_pos, x_pos) deer_step(bigdeer1, y_pos, x_pos) deer_step(bigdeer2, y_pos, x_pos) deer_step(bigdeer3, y_pos, x_pos) deer_step(bigdeer4, y_pos, x_pos) deer_step(bigdeer0, y_pos, x_pos) x_pos -= 1 for looper in range(0, 6): deer_step(lookdeer4, y_pos, x_pos) deer_step(lookdeer3, y_pos, x_pos) deer_step(lookdeer2, y_pos, x_pos) deer_step(lookdeer1, y_pos, x_pos) deer_step(lookdeer2, y_pos, x_pos) deer_step(lookdeer3, y_pos, x_pos) deer_step(lookdeer4, y_pos, x_pos) deer_step(lookdeer0, y_pos, x_pos) for y_pos in range(y_pos, 10): for looper in range(0, 2): deer_step(bigdeer4, y_pos, x_pos) deer_step(bigdeer3, y_pos, x_pos) deer_step(bigdeer2, y_pos, x_pos) deer_step(bigdeer1, y_pos, x_pos) deer_step(bigdeer2, y_pos, x_pos) deer_step(bigdeer3, y_pos, x_pos) deer_step(bigdeer4, y_pos, x_pos) deer_step(bigdeer0, y_pos, x_pos) y_pos -= 1 deer_step(lookdeer3, y_pos, x_pos) return def main(win): global stdscr stdscr = win global my_bg, y_pos, x_pos global treescrn, treescrn2, treescrn3, treescrn4 global treescrn5, treescrn6, treescrn7, treescrn8 global dotdeer0, stardeer0 global lildeer0, lildeer1, lildeer2, lildeer3 global middeer0, middeer1, middeer2, middeer3 global bigdeer0, bigdeer1, bigdeer2, bigdeer3, bigdeer4 global lookdeer0, lookdeer1, lookdeer2, lookdeer3, lookdeer4 global w_holiday, w_del_msg my_bg = curses.COLOR_BLACK # curses.curs_set(0) treescrn = curses.newwin(16, 27, 3, 53) treescrn2 = curses.newwin(16, 27, 3, 53) treescrn3 = curses.newwin(16, 27, 3, 53) treescrn4 = curses.newwin(16, 27, 3, 53) treescrn5 = curses.newwin(16, 27, 3, 53) treescrn6 = curses.newwin(16, 27, 3, 53) treescrn7 = curses.newwin(16, 27, 3, 53) treescrn8 = curses.newwin(16, 27, 3, 53) dotdeer0 = curses.newwin(3, 71, 0, 8) stardeer0 = curses.newwin(4, 56, 0, 8) lildeer0 = curses.newwin(7, 53, 0, 8) lildeer1 = curses.newwin(2, 4, 0, 0) lildeer2 = curses.newwin(2, 4, 0, 0) lildeer3 = curses.newwin(2, 4, 0, 0) middeer0 = curses.newwin(15, 42, 0, 8) middeer1 = curses.newwin(3, 7, 0, 0) middeer2 = curses.newwin(3, 7, 0, 0) middeer3 = curses.newwin(3, 7, 0, 0) bigdeer0 = curses.newwin(10, 23, 0, 0) bigdeer1 = curses.newwin(10, 23, 0, 0) bigdeer2 = curses.newwin(10, 23, 0, 0) bigdeer3 = curses.newwin(10, 23, 0, 0) bigdeer4 = curses.newwin(10, 23, 0, 0) lookdeer0 = curses.newwin(10, 25, 0, 0) lookdeer1 = curses.newwin(10, 25, 0, 0) lookdeer2 = curses.newwin(10, 25, 0, 0) lookdeer3 = curses.newwin(10, 25, 0, 0) lookdeer4 = curses.newwin(10, 25, 0, 0) w_holiday = curses.newwin(1, 27, 3, 27) w_del_msg = curses.newwin(1, 20, 23, 60) try: w_del_msg.addstr(0, 0, "Hit any key to quit") except curses.error: pass try: w_holiday.addstr(0, 0, "H A P P Y H O L I D A Y S") except curses.error: pass # set up the windows for our various reindeer lildeer1.addch(0, 0, ord('V')) lildeer1.addch(1, 0, ord('@')) lildeer1.addch(1, 1, ord('<')) lildeer1.addch(1, 2, ord('>')) try: lildeer1.addch(1, 3, ord('~')) except curses.error: pass lildeer2.addch(0, 0, ord('V')) lildeer2.addch(1, 0, ord('@')) lildeer2.addch(1, 1, ord('|')) lildeer2.addch(1, 2, ord('|')) try: lildeer2.addch(1, 3, ord('~')) except curses.error: pass lildeer3.addch(0, 0, ord('V')) lildeer3.addch(1, 0, ord('@')) lildeer3.addch(1, 1, ord('>')) lildeer3.addch(1, 2, ord('<')) try: lildeer2.addch(1, 3, ord('~')) # XXX except curses.error: pass middeer1.addch(0, 2, ord('y')) middeer1.addch(0, 3, ord('y')) middeer1.addch(1, 2, ord('0')) middeer1.addch(1, 3, ord('(')) middeer1.addch(1, 4, ord('=')) middeer1.addch(1, 5, ord(')')) middeer1.addch(1, 6, ord('~')) middeer1.addch(2, 3, ord('\\')) middeer1.addch(2, 5, ord('/')) middeer2.addch(0, 2, ord('y')) middeer2.addch(0, 3, ord('y')) middeer2.addch(1, 2, ord('0')) middeer2.addch(1, 3, ord('(')) middeer2.addch(1, 4, ord('=')) middeer2.addch(1, 5, ord(')')) middeer2.addch(1, 6, ord('~')) middeer2.addch(2, 3, ord('|')) middeer2.addch(2, 5, ord('|')) middeer3.addch(0, 2, ord('y')) middeer3.addch(0, 3, ord('y')) middeer3.addch(1, 2, ord('0')) middeer3.addch(1, 3, ord('(')) middeer3.addch(1, 4, ord('=')) middeer3.addch(1, 5, ord(')')) middeer3.addch(1, 6, ord('~')) middeer3.addch(2, 3, ord('/')) middeer3.addch(2, 5, ord('\\')) bigdeer1.addch(0, 17, ord('\\')) bigdeer1.addch(0, 18, ord('/')) bigdeer1.addch(0, 19, ord('\\')) bigdeer1.addch(0, 20, ord('/')) bigdeer1.addch(1, 18, ord('\\')) bigdeer1.addch(1, 20, ord('/')) bigdeer1.addch(2, 19, ord('|')) bigdeer1.addch(2, 20, ord('_')) bigdeer1.addch(3, 18, ord('/')) bigdeer1.addch(3, 19, ord('^')) bigdeer1.addch(3, 20, ord('0')) bigdeer1.addch(3, 21, ord('\\')) bigdeer1.addch(4, 17, ord('/')) bigdeer1.addch(4, 18, ord('/')) bigdeer1.addch(4, 19, ord('\\')) bigdeer1.addch(4, 22, ord('\\')) bigdeer1.addstr(5, 7, "^~~~~~~~~// ~~U") bigdeer1.addstr(6, 7, "( \\_____( /") # )) bigdeer1.addstr(7, 8, "( ) /") bigdeer1.addstr(8, 9, "\\\\ /") bigdeer1.addstr(9, 11, "\\>/>") bigdeer2.addch(0, 17, ord('\\')) bigdeer2.addch(0, 18, ord('/')) bigdeer2.addch(0, 19, ord('\\')) bigdeer2.addch(0, 20, ord('/')) bigdeer2.addch(1, 18, ord('\\')) bigdeer2.addch(1, 20, ord('/')) bigdeer2.addch(2, 19, ord('|')) bigdeer2.addch(2, 20, ord('_')) bigdeer2.addch(3, 18, ord('/')) bigdeer2.addch(3, 19, ord('^')) bigdeer2.addch(3, 20, ord('0')) bigdeer2.addch(3, 21, ord('\\')) bigdeer2.addch(4, 17, ord('/')) bigdeer2.addch(4, 18, ord('/')) bigdeer2.addch(4, 19, ord('\\')) bigdeer2.addch(4, 22, ord('\\')) bigdeer2.addstr(5, 7, "^~~~~~~~~// ~~U") bigdeer2.addstr(6, 7, "(( )____( /") # )) bigdeer2.addstr(7, 7, "( / |") bigdeer2.addstr(8, 8, "\\/ |") bigdeer2.addstr(9, 9, "|> |>") bigdeer3.addch(0, 17, ord('\\')) bigdeer3.addch(0, 18, ord('/')) bigdeer3.addch(0, 19, ord('\\')) bigdeer3.addch(0, 20, ord('/')) bigdeer3.addch(1, 18, ord('\\')) bigdeer3.addch(1, 20, ord('/')) bigdeer3.addch(2, 19, ord('|')) bigdeer3.addch(2, 20, ord('_')) bigdeer3.addch(3, 18, ord('/')) bigdeer3.addch(3, 19, ord('^')) bigdeer3.addch(3, 20, ord('0')) bigdeer3.addch(3, 21, ord('\\')) bigdeer3.addch(4, 17, ord('/')) bigdeer3.addch(4, 18, ord('/')) bigdeer3.addch(4, 19, ord('\\')) bigdeer3.addch(4, 22, ord('\\')) bigdeer3.addstr(5, 7, "^~~~~~~~~// ~~U") bigdeer3.addstr(6, 6, "( ()_____( /") # )) bigdeer3.addstr(7, 6, "/ / /") bigdeer3.addstr(8, 5, "|/ \\") bigdeer3.addstr(9, 5, "/> \\>") bigdeer4.addch(0, 17, ord('\\')) bigdeer4.addch(0, 18, ord('/')) bigdeer4.addch(0, 19, ord('\\')) bigdeer4.addch(0, 20, ord('/')) bigdeer4.addch(1, 18, ord('\\')) bigdeer4.addch(1, 20, ord('/')) bigdeer4.addch(2, 19, ord('|')) bigdeer4.addch(2, 20, ord('_')) bigdeer4.addch(3, 18, ord('/')) bigdeer4.addch(3, 19, ord('^')) bigdeer4.addch(3, 20, ord('0')) bigdeer4.addch(3, 21, ord('\\')) bigdeer4.addch(4, 17, ord('/')) bigdeer4.addch(4, 18, ord('/')) bigdeer4.addch(4, 19, ord('\\')) bigdeer4.addch(4, 22, ord('\\')) bigdeer4.addstr(5, 7, "^~~~~~~~~// ~~U") bigdeer4.addstr(6, 6, "( )______( /") # ) bigdeer4.addstr(7, 5, "(/ \\") # ) bigdeer4.addstr(8, 0, "v___= ----^") lookdeer1.addstr(0, 16, "\\/ \\/") lookdeer1.addstr(1, 17, "\\Y/ \\Y/") lookdeer1.addstr(2, 19, "\\=/") lookdeer1.addstr(3, 17, "^\\o o/^") lookdeer1.addstr(4, 17, "//( )") lookdeer1.addstr(5, 7, "^~~~~~~~~// \\O/") lookdeer1.addstr(6, 7, "( \\_____( /") # )) lookdeer1.addstr(7, 8, "( ) /") lookdeer1.addstr(8, 9, "\\\\ /") lookdeer1.addstr(9, 11, "\\>/>") lookdeer2.addstr(0, 16, "\\/ \\/") lookdeer2.addstr(1, 17, "\\Y/ \\Y/") lookdeer2.addstr(2, 19, "\\=/") lookdeer2.addstr(3, 17, "^\\o o/^") lookdeer2.addstr(4, 17, "//( )") lookdeer2.addstr(5, 7, "^~~~~~~~~// \\O/") lookdeer2.addstr(6, 7, "(( )____( /") # )) lookdeer2.addstr(7, 7, "( / |") lookdeer2.addstr(8, 8, "\\/ |") lookdeer2.addstr(9, 9, "|> |>") lookdeer3.addstr(0, 16, "\\/ \\/") lookdeer3.addstr(1, 17, "\\Y/ \\Y/") lookdeer3.addstr(2, 19, "\\=/") lookdeer3.addstr(3, 17, "^\\o o/^") lookdeer3.addstr(4, 17, "//( )") lookdeer3.addstr(5, 7, "^~~~~~~~~// \\O/") lookdeer3.addstr(6, 6, "( ()_____( /") # )) lookdeer3.addstr(7, 6, "/ / /") lookdeer3.addstr(8, 5, "|/ \\") lookdeer3.addstr(9, 5, "/> \\>") lookdeer4.addstr(0, 16, "\\/ \\/") lookdeer4.addstr(1, 17, "\\Y/ \\Y/") lookdeer4.addstr(2, 19, "\\=/") lookdeer4.addstr(3, 17, "^\\o o/^") lookdeer4.addstr(4, 17, "//( )") lookdeer4.addstr(5, 7, "^~~~~~~~~// \\O/") lookdeer4.addstr(6, 6, "( )______( /") # ) lookdeer4.addstr(7, 5, "(/ \\") # ) lookdeer4.addstr(8, 0, "v___= ----^") ############################################### curses.cbreak() stdscr.nodelay(1) while 1: stdscr.clear() treescrn.erase() w_del_msg.touchwin() treescrn.touchwin() treescrn2.erase() treescrn2.touchwin() treescrn8.erase() treescrn8.touchwin() stdscr.refresh() look_out(150) boxit() stdscr.refresh() look_out(150) seas() stdscr.refresh() greet() stdscr.refresh() look_out(150) fromwho() stdscr.refresh() look_out(150) tree() look_out(150) balls() look_out(150) star() look_out(150) strng1() strng2() strng3() strng4() strng5() # set up the windows for our blinking trees # # treescrn3 treescrn.overlay(treescrn3) # balls treescrn3.addch(4, 18, ord(' ')) treescrn3.addch(7, 6, ord(' ')) treescrn3.addch(8, 19, ord(' ')) treescrn3.addch(11, 22, ord(' ')) # star treescrn3.addch(0, 12, ord('*')) # strng1 treescrn3.addch(3, 11, ord(' ')) # strng2 treescrn3.addch(5, 13, ord(' ')) treescrn3.addch(6, 10, ord(' ')) # strng3 treescrn3.addch(7, 16, ord(' ')) treescrn3.addch(7, 14, ord(' ')) # strng4 treescrn3.addch(10, 13, ord(' ')) treescrn3.addch(10, 10, ord(' ')) treescrn3.addch(11, 8, ord(' ')) # strng5 treescrn3.addch(11, 18, ord(' ')) treescrn3.addch(12, 13, ord(' ')) # treescrn4 treescrn.overlay(treescrn4) # balls treescrn4.addch(3, 9, ord(' ')) treescrn4.addch(4, 16, ord(' ')) treescrn4.addch(7, 6, ord(' ')) treescrn4.addch(8, 19, ord(' ')) treescrn4.addch(11, 2, ord(' ')) treescrn4.addch(12, 23, ord(' ')) # star treescrn4.standout() treescrn4.addch(0, 12, ord('*')) treescrn4.standend() # strng1 treescrn4.addch(3, 13, ord(' ')) # strng2 # strng3 treescrn4.addch(7, 15, ord(' ')) treescrn4.addch(8, 11, ord(' ')) # strng4 treescrn4.addch(9, 16, ord(' ')) treescrn4.addch(10, 12, ord(' ')) treescrn4.addch(11, 8, ord(' ')) # strng5 treescrn4.addch(11, 18, ord(' ')) treescrn4.addch(12, 14, ord(' ')) # treescrn5 treescrn.overlay(treescrn5) # balls treescrn5.addch(3, 15, ord(' ')) treescrn5.addch(10, 20, ord(' ')) treescrn5.addch(12, 1, ord(' ')) # star treescrn5.addch(0, 12, ord(' ')) # strng1 treescrn5.addch(3, 11, ord(' ')) # strng2 treescrn5.addch(5, 12, ord(' ')) # strng3 treescrn5.addch(7, 14, ord(' ')) treescrn5.addch(8, 10, ord(' ')) # strng4 treescrn5.addch(9, 15, ord(' ')) treescrn5.addch(10, 11, ord(' ')) treescrn5.addch(11, 7, ord(' ')) # strng5 treescrn5.addch(11, 17, ord(' ')) treescrn5.addch(12, 13, ord(' ')) # treescrn6 treescrn.overlay(treescrn6) # balls treescrn6.addch(6, 7, ord(' ')) treescrn6.addch(7, 18, ord(' ')) treescrn6.addch(10, 4, ord(' ')) treescrn6.addch(11, 23, ord(' ')) # star treescrn6.standout() treescrn6.addch(0, 12, ord('*')) treescrn6.standend() # strng1 # strng2 treescrn6.addch(5, 11, ord(' ')) # strng3 treescrn6.addch(7, 13, ord(' ')) treescrn6.addch(8, 9, ord(' ')) # strng4 treescrn6.addch(9, 14, ord(' ')) treescrn6.addch(10, 10, ord(' ')) treescrn6.addch(11, 6, ord(' ')) # strng5 treescrn6.addch(11, 16, ord(' ')) treescrn6.addch(12, 12, ord(' ')) # treescrn7 treescrn.overlay(treescrn7) # balls treescrn7.addch(3, 15, ord(' ')) treescrn7.addch(6, 7, ord(' ')) treescrn7.addch(7, 18, ord(' ')) treescrn7.addch(10, 4, ord(' ')) treescrn7.addch(11, 22, ord(' ')) # star treescrn7.addch(0, 12, ord('*')) # strng1 treescrn7.addch(3, 12, ord(' ')) # strng2 treescrn7.addch(5, 13, ord(' ')) treescrn7.addch(6, 9, ord(' ')) # strng3 treescrn7.addch(7, 15, ord(' ')) treescrn7.addch(8, 11, ord(' ')) # strng4 treescrn7.addch(9, 16, ord(' ')) treescrn7.addch(10, 12, ord(' ')) treescrn7.addch(11, 8, ord(' ')) # strng5 treescrn7.addch(11, 18, ord(' ')) treescrn7.addch(12, 14, ord(' ')) look_out(150) reindeer() w_holiday.touchwin() w_holiday.refresh() w_del_msg.refresh() look_out(500) for i in range(0, 20): blinkit() curses.wrapper(main) Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/curses/README,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** README 2000/12/15 00:41:48 1.2 --- README 2000/12/21 16:26:37 1.3 *************** *** 15,18 **** --- 15,19 ---- rain.py -- raindrops keep falling on my desktop tclock.py -- ASCII clock, by Howard Jones + xmas.py -- I'm dreaming of an ASCII christmas Please send bugfixes and new contributions to me or, even better, From python-dev@python.org Fri Dec 22 14:39:12 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 06:39:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.46,2.47 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv6312 Modified Files: _sre.c Log Message: Fix bug 126587: matchobject.groupdict() leaks memory because of a missing DECREF Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.46 retrieving revision 2.47 diff -C2 -r2.46 -r2.47 *** _sre.c 2000/10/28 19:30:40 2.46 --- _sre.c 2000/12/22 14:39:10 2.47 *************** *** 1997,2000 **** --- 1997,2001 ---- /* FIXME: this can fail, right? */ PyDict_SetItem(result, key, item); + Py_DECREF(item); } From python-dev@python.org Fri Dec 22 20:35:22 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 12:35:22 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0222.txt,1.7,1.8 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv2267 Modified Files: pep-0222.txt Log Message: Fill out the proposed interface some more. Remove some items that have been taken care of. Index: pep-0222.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0222.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** pep-0222.txt 2000/12/18 03:01:23 1.7 --- pep-0222.txt 2000/12/22 20:35:20 1.8 *************** *** 7,11 **** Python-Version: 2.1 Created: 18-Aug-2000 ! Post-History: --- 7,11 ---- Python-Version: 2.1 Created: 18-Aug-2000 ! Post-History: 22-Dec-2000 *************** *** 22,26 **** ! Proposed Changes This section lists changes that have been suggested, but about --- 22,26 ---- ! Open Issues This section lists changes that have been suggested, but about *************** *** 29,48 **** be classified as accepted or rejected. - fcgi.py : A new module adding support for the FastCGI protocol. - Robin Dunn's code needs to be ported to Windows, though. - - Better debugging support for CGIs from the Unix command line. - Using Perl's CGI.pm [1], if you run a script from the command - line, you can enter name=value pairs on standard input. - cgimodel [2] provides this already. - - Should the existing cgi.py be deprecated and everything moved into - a 'web' or 'cgi' package? That would allow removing some - backward-compatibility cruft. - - cgi.py: keep_blank_values should be on by default. The 'if - form.has_key()/if form[key].value' nested syntax is unnecessarily - convoluted. - cgi.py: We should not be told to create our own subclass just so we can handle file uploads. As a practical matter, I have yet to --- 29,32 ---- *************** *** 53,76 **** with its __init__ call and associated overhead. - cgi.py: Ideally, the pseudo-dictionary syntax would go away. It - seems to me that the main reason it is there is to accomodate - - form['field'].file syntax. How about the following: - form['field'] = '' #no values for key - form['field'] = 'string' #one value in submission for key - form['field'] = ['string', 'string', ....] #multiple values - form['field'] = {'fileName':'remote/path', - 'binaryValue':'@UIHJBV29489erht...'} #one file - form['field'] = [{'fileName':'remote/path', - 'binaryValue':'@UIHJBV29489erht...'}, - {'fileName':'another/path', - 'binaryValue':'7r7w7@@@@'}] #multiple files - - cgi.py: I'd prefer "input" or "submission" for the suggested - FieldStorage() name. The html page into which the data represented - by FieldStorage() is input is commonly known as a "form", which - means that when someone refers to "the form" you aren't always - sure what they are talking about. - cgi.py: Currently, query data with no `=' are ignored. Even if keep_blank_values is set, queries like `...?value=&...' are --- 37,40 ---- *************** *** 82,88 **** Utility function: build a query string from a list of 2-tuples - Higher-level frameworks: add something like Webware or Zope's - HTTPReqest/HTTPResponse objects. - Dictionary-related utility classes: NoKeyErrors (returns an empty string, never a KeyError), PartialStringSubstitution (returns --- 46,49 ---- *************** *** 96,99 **** --- 57,62 ---- that should be added to the Python standard library. + * fcgi.py : A new module adding support for the FastCGI protocol. + Robin Dunn's code needs to be ported to Windows, though. Major Changes to Existing Modules *************** *** 103,107 **** section therefore carry greater degrees of risk, either in introducing bugs or a backward incompatibility. ! Minor Changes to Existing Modules --- 66,72 ---- section therefore carry greater degrees of risk, either in introducing bugs or a backward incompatibility. ! ! The cgi.py module would be deprecated. (XXX A new module or ! package name hasn't been chosen yet: 'web'? 'cgilib'?) Minor Changes to Existing Modules *************** *** 133,144 **** Proposed Interface ! XXX open issues: naming convention (studlycaps or underline-separated?); ! no interface for file uploads yet; need to look at all the various ! packages to see if there's anything else missing; need to look at ! the cgi.parse*() functions and see if they can be simplified, too. ! XXX file uploads ! ! Parsing functions: carry over most of the parse* functions from cgi.py # The Response class borrows most of its methods from Zope's --- 98,107 ---- Proposed Interface ! XXX open issues: naming convention (studlycaps or ! underline-separated?); need to look at the cgi.parse*() functions ! and see if they can be simplified, too. ! Parsing functions: carry over most of the parse* functions from ! cgi.py # The Response class borrows most of its methods from Zope's *************** *** 169,178 **** def setCookie(self, name, value, ! path = XXX, # What to use as defaults? ! comment = XXX, ! domain = XXX, ! max-age = XXX, ! expires = XXX, ! secure = XXX ): "Set a cookie" --- 132,141 ---- def setCookie(self, name, value, ! path = '/', ! comment = None, ! domain = None, ! max-age = None, ! expires = None, ! secure = 0 ): "Set a cookie" *************** *** 195,199 **** pass ! # XXX methods for specific classes of error:serverError, badRequest, etc.? --- 158,163 ---- pass ! # XXX methods for specific classes of error:serverError, ! # badRequest, etc.? *************** *** 201,213 **** """ ! Attributes: .headers : dictionary containing HTTP headers .cookies : dictionary of cookies ! .form : data from the form .env : environment dictionary """ def __init__(self, environ=os.environ, stdin=sys.stdin, ! keep_blank_values=0, strict_parsing=0): """Initialize the request object, using the provided environment and standard input.""" --- 165,179 ---- """ ! Attributes: ! ! XXX should these be dictionaries, or dictionary-like objects? .headers : dictionary containing HTTP headers .cookies : dictionary of cookies ! .fields : data from the form .env : environment dictionary """ def __init__(self, environ=os.environ, stdin=sys.stdin, ! keep_blank_values=1, strict_parsing=0): """Initialize the request object, using the provided environment and standard input.""" *************** *** 222,231 **** def getField(self, name, default=None): pass ! def getURL(self, n=0, query_string=0): """Return the URL of the current request, chopping off 'n' path components from the right. Eg. if the URL is ! "http://foo.com/bar/baz/qux", n=2 would return "http://foo.com/bar". Does not include the query string (if any) --- 188,205 ---- def getField(self, name, default=None): + "Return field's value as a string (even if it's an uploaded file)" pass ! ! def getUploadedFile(self, name): ! """Returns a file object that can be read to obtain the contents ! of an uploaded file. XXX should this report an error if the ! field isn't actually an uploaded file? Or should it wrap ! a StringIO around simple fields for consistency? ! """ ! def getURL(self, n=0, query_string=0): """Return the URL of the current request, chopping off 'n' path components from the right. Eg. if the URL is ! "http://foo.com/bar/baz/quux", n=2 would return "http://foo.com/bar". Does not include the query string (if any) *************** *** 247,251 **** pass ! # Possibilities? def getBrowser(self): "Returns Mozilla/IE/Lynx/Opera/whatever" --- 221,226 ---- pass ! # Possibilities? I don't know if these are worth doing in the ! # basic objects. def getBrowser(self): "Returns Mozilla/IE/Lynx/Opera/whatever" *************** *** 254,259 **** "Return true if this is an SSLified request" ! ! def wrapper(func, logfile=None): """ Calls the function 'func', passing it the arguments --- 229,235 ---- "Return true if this is an SSLified request" ! ! # Module-level function ! def wrapper(func, logfile=sys.stderr): """ Calls the function 'func', passing it the arguments *************** *** 261,265 **** sent to the file 'logfile'. """ ! pass --- 237,244 ---- sent to the file 'logfile'. """ ! # This wrapper will detect if it's being called from the command-line, ! # and if so, it will run in a debugging mode; name=value pairs ! # can be entered on standard input to set field values. ! # (XXX how to do file uploads in this syntax?) *************** *** 267,277 **** This document has been placed in the public domain. - - - References and Footnotes - - [1] CGI.pm: - - [2] http://www.embl-heidelberg.de/~chenna/pythonpages/ --- 246,249 ---- From python-dev@python.org Fri Dec 22 21:50:03 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 13:50:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Demo/curses ncurses.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/curses In directory usw-pr-cvs1:/tmp/cvs-serv19559 Modified Files: ncurses.py Log Message: Update this demo to use curses.panel Index: ncurses.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/curses/ncurses.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** ncurses.py 2000/12/15 00:41:48 1.1 --- ncurses.py 2000/12/22 21:50:01 1.2 *************** *** 7,10 **** --- 7,11 ---- import curses + from curses import panel def wGetchar(win = None): *************** *** 31,35 **** def mkpanel(color, rows, cols, tly, tlx): win = curses.newwin(rows, cols, tly, tlx) ! pan = win.new_panel() if curses.has_colors(): if color == curses.COLOR_BLUE: --- 32,36 ---- def mkpanel(color, rows, cols, tly, tlx): win = curses.newwin(rows, cols, tly, tlx) ! pan = panel.new_panel(win) if curses.has_colors(): if color == curses.COLOR_BLUE: *************** *** 46,50 **** def pflush(): ! curses.update_panels() curses.doupdate() --- 47,51 ---- def pflush(): ! panel.update_panels() curses.doupdate() From python-dev@python.org Fri Dec 22 21:51:12 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 13:51:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include py_curses.h,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv19666 Added Files: py_curses.h Log Message: Added header file for C API exported by _cursesmodule.c --- NEW FILE: py_curses.h --- #ifndef Py_CURSES_H #define Py_CURSES_H #ifdef HAVE_NCURSES_H #include #else #include #endif #ifdef __cplusplus extern "C" { #endif #define PyCurses_API_pointers 4 /* Type declarations */ typedef struct { PyObject_HEAD WINDOW *win; } PyCursesWindowObject; #define PyCursesWindow_Check(v) ((v)->ob_type == &PyCursesWindow_Type) #ifdef CURSES_MODULE /* This section is used when compiling _cursesmodule.c */ #else /* This section is used in modules that use the _cursesmodule API */ static void **PyCurses_API; #define PyCursesWindow_Type (*(PyTypeObject *) PyCurses_API[0]) #define PyCursesSetupTermCalled {if (! ((int (*)(void))PyCurses_API[1]) () ) return NULL;} #define PyCursesInitialised {if (! ((int (*)(void))PyCurses_API[2]) () ) return NULL;} #define PyCursesInitialisedColor {if (! ((int (*)(void))PyCurses_API[3]) () ) return NULL;} #define import_curses() \ { \ PyObject *module = PyImport_ImportModule("_curses"); \ if (module != NULL) { \ PyObject *module_dict = PyModule_GetDict(module); \ PyObject *c_api_object = PyDict_GetItemString(module_dict, "_C_API"); \ if (PyCObject_Check(c_api_object)) { \ PyCurses_API = (void **)PyCObject_AsVoidPtr(c_api_object); \ } \ } \ } #endif /* general error messages */ static char *catchall_ERR = "curses function returned ERR"; static char *catchall_NULL = "curses function returned NULL"; /* Utility macros */ #define ARG_COUNT(X) \ (((X) == NULL) ? 0 : (PyTuple_Check(X) ? PyTuple_Size(X) : 1)) /* Function Prototype Macros - They are ugly but very, very useful. ;-) X - function name TYPE - parameter Type ERGSTR - format string for construction of the return value PARSESTR - format string for argument parsing */ #define NoArgNoReturnFunction(X) \ static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ { \ PyCursesInitialised \ if (!PyArg_NoArgs(args)) return NULL; \ return PyCursesCheckERR(X(), # X); } #define NoArgOrFlagNoReturnFunction(X) \ static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ { \ int flag = 0; \ PyCursesInitialised \ switch(ARG_COUNT(args)) { \ case 0: \ return PyCursesCheckERR(X(), # X); \ case 1: \ if (!PyArg_Parse(args, "i;True(1) or False(0)", &flag)) return NULL; \ if (flag) return PyCursesCheckERR(X(), # X); \ else return PyCursesCheckERR(no ## X (), # X); \ default: \ PyErr_SetString(PyExc_TypeError, # X " requires 0 or 1 arguments"); \ return NULL; } } #define NoArgReturnIntFunction(X) \ static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ { \ PyCursesInitialised \ if (!PyArg_NoArgs(args)) return NULL; \ return PyInt_FromLong((long) X()); } #define NoArgReturnStringFunction(X) \ static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ { \ PyCursesInitialised \ if (!PyArg_NoArgs(args)) return NULL; \ return PyString_FromString(X()); } #define NoArgTrueFalseFunction(X) \ static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ { \ PyCursesInitialised \ if (!PyArg_NoArgs(args)) return NULL; \ if (X () == FALSE) { \ Py_INCREF(Py_False); \ return Py_False; \ } \ Py_INCREF(Py_True); \ return Py_True; } #define NoArgNoReturnVoidFunction(X) \ static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ { \ PyCursesInitialised \ if (!PyArg_NoArgs(args)) return NULL; \ X(); \ Py_INCREF(Py_None); \ return Py_None; } #ifdef __cplusplus } #endif #endif /* !defined(Py_CURSES_H) */ From python-dev@python.org Fri Dec 22 21:52:30 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 13:52:30 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.44,2.45 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv19738 Modified Files: _cursesmodule.c Log Message: Export C API from this module. Remove several macros and #includes; py_curses.h contains them now. Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.44 retrieving revision 2.45 diff -C2 -r2.44 -r2.45 *** _cursesmodule.c 2000/12/21 16:22:22 2.44 --- _cursesmodule.c 2000/12/22 21:52:27 2.45 *************** *** 96,104 **** /* Release Number */ ! char *PyCursesVersion = "1.6"; /* Includes */ #include "Python.h" #ifdef __osf__ --- 96,106 ---- /* Release Number */ ! char *PyCursesVersion = "2.1"; /* Includes */ #include "Python.h" + #define CURSES_MODULE + #include "py_curses.h" #ifdef __osf__ *************** *** 107,116 **** #endif - #ifdef HAVE_NCURSES_H - #include - #else - #include - #endif - /* These prototypes are in , but including this header #defines many common symbols (such as "lines") which breaks the --- 109,112 ---- *************** *** 131,138 **** static PyObject *PyCursesError; - /* general error messages */ - static char *catchall_ERR = "curses function returned ERR"; - static char *catchall_NULL = "curses function returned NULL"; - /* Tells whether setupterm() has been called to initialise terminfo. */ static int initialised_setupterm = FALSE; --- 127,130 ---- *************** *** 141,156 **** static int initialised = FALSE; ! /* Tells whether start_color() has been called to initialise colorusage. */ static int initialisedcolors = FALSE; /* Utility Macros */ - #define ARG_COUNT(X) \ - (((X) == NULL) ? 0 : (PyTuple_Check(X) ? PyTuple_Size(X) : 1)) - #define PyCursesSetupTermCalled \ if (initialised_setupterm != TRUE) { \ PyErr_SetString(PyCursesError, \ "must call (at least) setupterm() first"); \ ! return NULL; } #define PyCursesInitialised \ --- 133,145 ---- static int initialised = FALSE; ! /* Tells whether start_color() has been called to initialise color usage. */ static int initialisedcolors = FALSE; /* Utility Macros */ #define PyCursesSetupTermCalled \ if (initialised_setupterm != TRUE) { \ PyErr_SetString(PyCursesError, \ "must call (at least) setupterm() first"); \ ! return 0; } #define PyCursesInitialised \ *************** *** 158,162 **** PyErr_SetString(PyCursesError, \ "must call initscr() first"); \ ! return NULL; } #define PyCursesInitialisedColor \ --- 147,151 ---- PyErr_SetString(PyCursesError, \ "must call initscr() first"); \ ! return 0; } #define PyCursesInitialisedColor \ *************** *** 164,168 **** PyErr_SetString(PyCursesError, \ "must call start_color() first"); \ ! return NULL; } /* Utility Functions */ --- 153,157 ---- PyErr_SetString(PyCursesError, \ "must call start_color() first"); \ ! return 0; } /* Utility Functions */ *************** *** 170,174 **** /* * Check the return code from a curses function and return None ! * or raise an exception as appropriate. */ --- 159,164 ---- /* * Check the return code from a curses function and return None ! * or raise an exception as appropriate. These are exported using the ! * CObject API. */ *************** *** 203,223 **** } /***************************************************************************** The Window Object ******************************************************************************/ - - /* Definition of the window object and window type */ ! typedef struct { ! PyObject_HEAD ! WINDOW *win; ! } PyCursesWindowObject; PyTypeObject PyCursesWindow_Type; ! #define PyCursesWindow_Check(v) ((v)->ob_type == &PyCursesWindow_Type) - /* Function Prototype Macros - They are ugly but very, very useful. ;-) - X - function name TYPE - parameter Type --- 193,227 ---- } + /* Function versions of the 3 functions for tested whether curses has been + initialised or not. */ + + static int func_PyCursesSetupTermCalled(void) + { + PyCursesSetupTermCalled; + return 1; + } + + static int func_PyCursesInitialised(void) + { + PyCursesInitialised; + return 1; + } + + static int func_PyCursesInitialisedColor(void) + { + PyCursesInitialisedColor; + return 1; + } + /***************************************************************************** The Window Object ******************************************************************************/ ! /* Definition of the window type */ PyTypeObject PyCursesWindow_Type; ! /* Function prototype macros for Window object X - function name TYPE - parameter Type *************** *** 1459,1531 **** **********************************************************************/ - static PyObject *ModDict; - - /* Function Prototype Macros - They are ugly but very, very useful. ;-) - - X - function name - TYPE - parameter Type - ERGSTR - format string for construction of the return value - PARSESTR - format string for argument parsing - */ - - #define NoArgNoReturnFunction(X) \ - static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ - { \ - PyCursesInitialised \ - if (!PyArg_NoArgs(args)) return NULL; \ - return PyCursesCheckERR(X(), # X); } - - #define NoArgOrFlagNoReturnFunction(X) \ - static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ - { \ - int flag = 0; \ - PyCursesInitialised \ - switch(ARG_COUNT(args)) { \ - case 0: \ - return PyCursesCheckERR(X(), # X); \ - case 1: \ - if (!PyArg_Parse(args, "i;True(1) or False(0)", &flag)) return NULL; \ - if (flag) return PyCursesCheckERR(X(), # X); \ - else return PyCursesCheckERR(no ## X (), # X); \ - default: \ - PyErr_SetString(PyExc_TypeError, # X " requires 0 or 1 arguments"); \ - return NULL; } } - - #define NoArgReturnIntFunction(X) \ - static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ - { \ - PyCursesInitialised \ - if (!PyArg_NoArgs(args)) return NULL; \ - return PyInt_FromLong((long) X()); } - - - #define NoArgReturnStringFunction(X) \ - static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ - { \ - PyCursesInitialised \ - if (!PyArg_NoArgs(args)) return NULL; \ - return PyString_FromString(X()); } - - #define NoArgTrueFalseFunction(X) \ - static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ - { \ - PyCursesInitialised \ - if (!PyArg_NoArgs(args)) return NULL; \ - if (X () == FALSE) { \ - Py_INCREF(Py_False); \ - return Py_False; \ - } \ - Py_INCREF(Py_True); \ - return Py_True; } - - #define NoArgNoReturnVoidFunction(X) \ - static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ - { \ - PyCursesInitialised \ - if (!PyArg_NoArgs(args)) return NULL; \ - X(); \ - Py_INCREF(Py_None); \ - return Py_None; } - NoArgNoReturnFunction(beep) NoArgNoReturnFunction(def_prog_mode) --- 1463,1466 ---- *************** *** 1806,1809 **** --- 1741,1746 ---- } + static PyObject *ModDict; + static PyObject * PyCurses_InitScr(PyObject *self, PyObject *args) *************** *** 2498,2503 **** init_curses(void) { ! PyObject *m, *d, *v; /* Create the module and add the functions */ m = Py_InitModule("_curses", PyCurses_methods); --- 2435,2447 ---- init_curses(void) { ! PyObject *m, *d, *v, *c_api_object; ! static void *PyCurses_API[PyCurses_API_pointers]; + /* Initialize the C API pointer array */ + PyCurses_API[0] = (void *)&PyCursesWindow_Type; + PyCurses_API[1] = (void *)func_PyCursesSetupTermCalled; + PyCurses_API[2] = (void *)func_PyCursesInitialised; + PyCurses_API[3] = (void *)func_PyCursesInitialisedColor; + /* Create the module and add the functions */ m = Py_InitModule("_curses", PyCurses_methods); *************** *** 2505,2509 **** /* Add some symbolic constants to the module */ d = PyModule_GetDict(m); ! ModDict = d; /* For PyCurses_InitScr */ /* For exception curses.error */ --- 2449,2457 ---- /* Add some symbolic constants to the module */ d = PyModule_GetDict(m); ! ModDict = d; /* For PyCurses_InitScr to use later */ ! ! /* Add a CObject for the C API */ ! c_api_object = PyCObject_FromVoidPtr((void *)PyCurses_API, NULL); ! PyDict_SetItemString(d, "_C_API", c_api_object); /* For exception curses.error */ From python-dev@python.org Fri Dec 22 21:54:14 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 13:54:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _curses_panel.c,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv19887 Added Files: _curses_panel.c Log Message: Patch #102813: add a wrapper for the panel library included with ncurses. Original version written by Thomas Gellekum, reshaped into a separate module by AMK. --- NEW FILE: _curses_panel.c --- /* * Interface to the ncurses panel library * * Original version by Thomas Gellekum */ /* Release Number */ static char *PyCursesVersion = "2.1"; /* Includes */ #include "Python.h" #include "py_curses.h" #include static PyObject *PyCursesError; /* Utility Functions */ /* * Check the return code from a curses function and return None * or raise an exception as appropriate. */ static PyObject * PyCursesCheckERR(int code, char *fname) { if (code != ERR) { Py_INCREF(Py_None); return Py_None; } else { if (fname == NULL) { PyErr_SetString(PyCursesError, catchall_ERR); } else { PyErr_Format(PyCursesError, "%s() returned ERR", fname); } return NULL; } } /***************************************************************************** The Panel Object ******************************************************************************/ /* Definition of the panel object and panel type */ typedef struct { PyObject_HEAD PANEL *pan; PyCursesWindowObject *wo; /* for reference counts */ } PyCursesPanelObject; PyTypeObject PyCursesPanel_Type; #define PyCursesPanel_Check(v) ((v)->ob_type == &PyCursesPanel_Type) /* Some helper functions. The problem is that there's always a window associated with a panel. To ensure that Python's GC doesn't pull this window from under our feet we need to keep track of references to the corresponding window object within Python. We can't use dupwin(oldwin) to keep a copy of the curses WINDOW because the contents of oldwin is copied only once; code like win = newwin(...) pan = win.panel() win.addstr(some_string) pan.window().addstr(other_string) will fail. */ /* We keep a linked list of PyCursesPanelObjects, lop. A list should suffice, I don't expect more than a handful or at most a few dozens of panel objects within a typical program. */ typedef struct _list_of_panels { PyCursesPanelObject *po; struct _list_of_panels *next; } list_of_panels; /* list anchor */ static list_of_panels *lop; /* Insert a new panel object into lop */ static int insert_lop(PyCursesPanelObject *po) { list_of_panels *new; if ((new = (list_of_panels *)malloc(sizeof(list_of_panels))) == NULL) { PyErr_NoMemory(); return -1; } new->po = po; new->next = lop; lop = new; return 0; } /* Remove the panel object from lop */ static void remove_lop(PyCursesPanelObject *po) { list_of_panels *temp, *n; temp = lop; if (temp->po == po) { lop = temp->next; free(temp); return; } while (temp->next->po != po) { if (temp->next == NULL) PyErr_SetString(PyExc_RuntimeError, "remove_lop: can't find Panel Object"); temp = temp->next; } n = temp->next->next; free(temp->next); temp->next = n; return; } /* Return the panel object that corresponds to pan */ static PyCursesPanelObject * find_po(PANEL *pan) { list_of_panels *temp; for (temp = lop; temp->po->pan != pan; temp = temp->next) if (temp->next == NULL) return NULL; /* not found!? */ return temp->po; } /* Function Prototype Macros - They are ugly but very, very useful. ;-) X - function name TYPE - parameter Type ERGSTR - format string for construction of the return value PARSESTR - format string for argument parsing */ #define Panel_NoArgNoReturnFunction(X) \ static PyObject *PyCursesPanel_ ## X (PyCursesPanelObject *self, PyObject *args) \ { if (!PyArg_NoArgs(args)) return NULL; \ return PyCursesCheckERR(X(self->pan), # X); } #define Panel_NoArgReturnStringFunction(X) \ static PyObject *PyCursesPanel_ ## X (PyCursesPanelObject *self, PyObject *args) \ { if (!PyArg_NoArgs(args)) return NULL; \ return PyString_FromString(X(self->pan)); } #define Panel_NoArgTrueFalseFunction(X) \ static PyObject * PyCursesPanel_ ## X (PyCursesPanelObject *self, PyObject *args) \ { \ if (!PyArg_NoArgs(args)) return NULL; \ if (X (self->pan) == FALSE) { Py_INCREF(Py_False); return Py_False; } \ else { Py_INCREF(Py_True); return Py_True; } } #define Panel_TwoArgNoReturnFunction(X, TYPE, PARSESTR) \ static PyObject * PyCursesPanel_ ## X (PyCursesPanelObject *self, PyObject *args) \ { \ TYPE arg1, arg2; \ if (!PyArg_Parse(args,PARSESTR, &arg1, &arg2)) return NULL; \ return PyCursesCheckERR(X(self->pan, arg1, arg2), # X); } /* ------------- PANEL routines --------------- */ Panel_NoArgNoReturnFunction(bottom_panel) Panel_NoArgNoReturnFunction(hide_panel) Panel_NoArgNoReturnFunction(show_panel) Panel_NoArgNoReturnFunction(top_panel) Panel_NoArgTrueFalseFunction(panel_hidden) Panel_TwoArgNoReturnFunction(move_panel, int, "(ii);y,x") /* Allocation and deallocation of Panel Objects */ static PyObject * PyCursesPanel_New(PANEL *pan, PyCursesWindowObject *wo) { PyCursesPanelObject *po; po = PyObject_NEW(PyCursesPanelObject, &PyCursesPanel_Type); if (po == NULL) return NULL; po->pan = pan; po->wo = wo; Py_INCREF(wo); if (insert_lop(po) < 0) { PyObject_DEL(po); return NULL; } return (PyObject *)po; } static void PyCursesPanel_Dealloc(PyCursesPanelObject *po) { (void)del_panel(po->pan); Py_DECREF(po->wo); remove_lop(po); PyMem_DEL(po); } /* panel_above(NULL) returns the bottom panel in the stack. To get this behaviour we use curses.panel.bottom_panel(). */ static PyObject * PyCursesPanel_above(PyCursesPanelObject *self, PyObject *args) { PANEL *pan; PyCursesPanelObject *po; if (!PyArg_NoArgs(args)) return NULL; pan = panel_above(self->pan); if (pan == NULL) { /* valid output, it means the calling panel is on top of the stack */ Py_INCREF(Py_None); return Py_None; } po = find_po(pan); if (po == NULL) { PyErr_SetString(PyExc_RuntimeError, "panel_above: can't find Panel Object"); return NULL; } Py_INCREF(po); return (PyObject *)po; } /* panel_below(NULL) returns the top panel in the stack. To get this behaviour we use curses.panel_below(). */ static PyObject * PyCursesPanel_below(PyCursesPanelObject *self, PyObject *args) { PANEL *pan; PyCursesPanelObject *po; if (!PyArg_NoArgs(args)) return NULL; pan = panel_below(self->pan); if (pan == NULL) { /* valid output, it means the calling panel is on the bottom of the stack */ Py_INCREF(Py_None); return Py_None; } po = find_po(pan); if (po == NULL) { PyErr_SetString(PyExc_RuntimeError, "panel_below: can't find Panel Object"); return NULL; } Py_INCREF(po); return (PyObject *)po; } static PyObject * PyCursesPanel_window(PyCursesPanelObject *self, PyObject *args) { if (!PyArg_NoArgs(args)) return NULL; Py_INCREF(self->wo); return (PyObject *)self->wo; } static PyObject * PyCursesPanel_replace_panel(PyCursesPanelObject *self, PyObject *args) { PyCursesPanelObject *po; PyCursesWindowObject *temp; int rtn; if (ARG_COUNT(args) != 1) { PyErr_SetString(PyExc_TypeError, "replace requires one argument"); return NULL; } if (!PyArg_ParseTuple(args, "O!;window object", &PyCursesWindow_Type, &temp)) return NULL; po = find_po(self->pan); if (po == NULL) { PyErr_SetString(PyExc_RuntimeError, "replace_panel: can't find Panel Object"); return NULL; } rtn = replace_panel(self->pan, temp->win); if (rtn == ERR) { PyErr_SetString(PyCursesError, "replace_panel() returned ERR"); return NULL; } Py_DECREF(po->wo); po->wo = temp; Py_INCREF(po->wo); Py_INCREF(Py_None); return Py_None; } static PyObject * PyCursesPanel_set_panel_userptr(PyCursesPanelObject *self, PyObject *args) { PyObject *obj; if (ARG_COUNT(args) != 1) { PyErr_SetString(PyExc_TypeError, "set_userptr requires one argument"); return NULL; } obj = PyTuple_GetItem(args, 0); Py_INCREF(obj); return PyCursesCheckERR(set_panel_userptr(self->pan, obj), "set_panel_userptr"); } static PyObject *PyCursesPanel_userptr (PyCursesPanelObject *self, PyObject *args) { PyObject *obj; PyCursesInitialised; if (!PyArg_NoArgs(args)) return NULL; obj = panel_userptr(self->pan); Py_INCREF(obj); return obj; } /* Module interface */ static PyMethodDef PyCursesPanel_Methods[] = { {"above", (PyCFunction)PyCursesPanel_above}, {"below", (PyCFunction)PyCursesPanel_below}, {"bottom", (PyCFunction)PyCursesPanel_bottom_panel}, {"hidden", (PyCFunction)PyCursesPanel_panel_hidden}, {"hide", (PyCFunction)PyCursesPanel_hide_panel}, {"move", (PyCFunction)PyCursesPanel_move_panel}, {"replace", (PyCFunction)PyCursesPanel_replace_panel}, {"set_userptr", (PyCFunction)PyCursesPanel_set_panel_userptr, METH_VARARGS}, {"show", (PyCFunction)PyCursesPanel_show_panel}, {"top", (PyCFunction)PyCursesPanel_top_panel}, {"userptr", (PyCFunction)PyCursesPanel_userptr}, {"window", (PyCFunction)PyCursesPanel_window}, {NULL, NULL} /* sentinel */ }; static PyObject * PyCursesPanel_GetAttr(PyCursesPanelObject *self, char *name) { return Py_FindMethod(PyCursesPanel_Methods, (PyObject *)self, name); } /* -------------------------------------------------------*/ PyTypeObject PyCursesPanel_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /*ob_size*/ "curses panel", /*tp_name*/ sizeof(PyCursesPanelObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor)PyCursesPanel_Dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc)PyCursesPanel_GetAttr, /*tp_getattr*/ (setattrfunc)0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ }; /* Wrapper for panel_above(NULL). This function returns the bottom panel of the stack, so it's renamed to bottom_panel(). panel.above() *requires* a panel object in the first place which may be undesirable. */ static PyObject * PyCurses_bottom_panel(PyObject *self, PyObject *args) { PANEL *pan; PyCursesPanelObject *po; PyCursesInitialised; if (!PyArg_NoArgs(args)) return NULL; pan = panel_above(NULL); if (pan == NULL) { /* valid output, it means there's no panel at all */ Py_INCREF(Py_None); return Py_None; } po = find_po(pan); if (po == NULL) { PyErr_SetString(PyExc_RuntimeError, "panel_above: can't find Panel Object"); return NULL; } Py_INCREF(po); return (PyObject *)po; } static PyObject * PyCurses_new_panel(PyObject *self, PyObject *args) { PyCursesWindowObject *win; PANEL *pan; if (!PyArg_ParseTuple(args, "O!", &PyCursesWindow_Type, &win)) return NULL; pan = new_panel(win->win); if (pan == NULL) { PyErr_SetString(PyCursesError, catchall_NULL); return NULL; } return (PyObject *)PyCursesPanel_New(pan, win); } /* Wrapper for panel_below(NULL). This function returns the top panel of the stack, so it's renamed to top_panel(). panel.below() *requires* a panel object in the first place which may be undesirable. */ static PyObject * PyCurses_top_panel(PyObject *self, PyObject *args) { PANEL *pan; PyCursesPanelObject *po; PyCursesInitialised; if (!PyArg_NoArgs(args)) return NULL; pan = panel_below(NULL); if (pan == NULL) { /* valid output, it means there's no panel at all */ Py_INCREF(Py_None); return Py_None; } po = find_po(pan); if (po == NULL) { PyErr_SetString(PyExc_RuntimeError, "panel_below: can't find Panel Object"); return NULL; } Py_INCREF(po); return (PyObject *)po; } static PyObject *PyCurses_update_panels(PyObject *self, PyObject *args) { PyCursesInitialised; if (!PyArg_NoArgs(args)) return NULL; update_panels(); Py_INCREF(Py_None); return Py_None; } /* List of functions defined in the module */ static PyMethodDef PyCurses_methods[] = { {"bottom_panel", (PyCFunction)PyCurses_bottom_panel}, {"new_panel", (PyCFunction)PyCurses_new_panel, METH_VARARGS}, {"top_panel", (PyCFunction)PyCurses_top_panel}, {"update_panels", (PyCFunction)PyCurses_update_panels}, {NULL, NULL} /* sentinel */ }; /* Initialization function for the module */ void init_curses_panel(void) { PyObject *m, *d, *v; import_curses(); /* Create the module and add the functions */ m = Py_InitModule("_curses_panel", PyCurses_methods); d = PyModule_GetDict(m); /* For exception _curses_panel.error */ PyCursesError = PyErr_NewException("_curses_panel.error", NULL, NULL); PyDict_SetItemString(d, "error", PyCursesError); /* Make the version available */ v = PyString_FromString(PyCursesVersion); PyDict_SetItemString(d, "version", v); PyDict_SetItemString(d, "__version__", v); Py_DECREF(v); } From python-dev@python.org Fri Dec 22 21:57:35 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 13:57:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.dist,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv20343 Modified Files: Setup.dist Log Message: Add _curses_panel to Setup Index: Setup.dist =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.dist,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** Setup.dist 2000/12/12 21:07:08 1.2 --- Setup.dist 2000/12/22 21:57:33 1.3 *************** *** 322,326 **** #_curses _cursesmodule.c -lcurses -ltermcap ! --- 322,327 ---- #_curses _cursesmodule.c -lcurses -ltermcap ! # Wrapper for the panel library that's part of ncurses and SYSV curses. ! #_curses_panel _curses_panel.c -lpanel -lncurses From python-dev@python.org Fri Dec 22 21:57:44 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 13:57:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcursespanel.tex,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv20359 Added Files: libcursespanel.tex Log Message: Added documentation for the panel wrapper module --- NEW FILE: libcursespanel.tex --- \section{\module{curses.panel} --- A panel stack extension for curses.} \declaremodule{standard}{curses.panel} \sectionauthor{A.M. Kuchling}{amk1@bigfoot.com} \modulesynopsis{A panel stack extension that adds depth to curses windows.} Panels are windows with the added feature of depth, so they can be stacked on top of each other, and only the visible portions of each window will be displayed. Panels can be added, moved up or down in the stack, and removed. \subsection{Functions \label{cursespanel-functions}} The module \module{curses.panel} defines the following functions: \begin{funcdesc}{bottom_panel}{} Returns the bottom panel in the panel stack. \end{funcdesc} \begin{methoddesc}{new_panel}{win} Returns a panel object, associating it with the given window \var{win}. \end{methoddesc} \begin{funcdesc}{top_panel}{} Returns the top panel in the panel stack. \end{funcdesc} \begin{funcdesc}{update_panels}{} Updates the virtual screen after changes in the panel stack. This does not call \function{curses.doupdate()}, so you'll have to do this yourself. \end{funcdesc} \subsection{Panel Objects \label{curses-panel-objects}} Panel objects, as returned by \function{new_panel()} above, are windows with a stacking order. There's always a window associated with a panel which determines the content, while the panel methods are responsible for the window's depth in the panel stack. Panel objects have the following methods: \begin{methoddesc}{above} Returns the panel above the current panel. \end{methoddesc} \begin{methoddesc}{below} Returns the panel below the current panel. \end{methoddesc} \begin{methoddesc}{bottom} Push the panel to the bottom of the stack. \end{methoddesc} \begin{methoddesc}{hidden} Returns true if the panel is hidden (not visible), false otherwise. \end{methoddesc} \begin{methoddesc}{hide} Hide the panel. This does not delete the object, it just makes the window on screen invisible. \end{methoddesc} \begin{methoddesc}{move}{y, x} Move the panel to the screen coordinates \code{(\var{y}, \var{x})}. \end{methoddesc} \begin{methoddesc}{replace}{win} Change the window associated with the panel to the window \var{win}. \end{methoddesc} \begin{methoddesc}{set_userptr}{obj} Set the panel's user pointer to \var{obj}. This is used to associate an arbitrary piece of data with the panel, and can be any Python object. \end{methoddesc} \begin{methoddesc}{show} Display the panel (which might have been hidden). \end{methoddesc} \begin{methoddesc}{top} Push panel to the top of the stack. \end{methoddesc} \begin{methoddesc}{userptr} Returns the user pointer for the panel. This might be any Python object. \end{methoddesc} \begin{methoddesc}{window} Returns the window object associated with the panel. \end{methoddesc} From python-dev@python.org Fri Dec 22 21:58:31 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 13:58:31 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses panel.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/curses In directory usw-pr-cvs1:/tmp/cvs-serv20446 Added Files: panel.py Log Message: Wrapper for _curses_panel module; currently this adds nothing extra beyond what's in _curses_panel --- NEW FILE: panel.py --- """curses.panel Module for using panels with curses. """ __revision__ = "$Id: panel.py,v 1.1 2000/12/22 21:58:29 akuchling Exp $" from _curses_panel import * From python-dev@python.org Fri Dec 22 22:03:17 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 14:03:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _curses_panel.c,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv21050 Modified Files: _curses_panel.c Log Message: Add correction caught by Thomas Gellekum (and sitting in my e-mail) Index: _curses_panel.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_curses_panel.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** _curses_panel.c 2000/12/22 21:54:12 1.1 --- _curses_panel.c 2000/12/22 22:03:15 1.2 *************** *** 334,338 **** {"hide", (PyCFunction)PyCursesPanel_hide_panel}, {"move", (PyCFunction)PyCursesPanel_move_panel}, ! {"replace", (PyCFunction)PyCursesPanel_replace_panel}, {"set_userptr", (PyCFunction)PyCursesPanel_set_panel_userptr, METH_VARARGS}, --- 334,339 ---- {"hide", (PyCFunction)PyCursesPanel_hide_panel}, {"move", (PyCFunction)PyCursesPanel_move_panel}, ! {"replace", (PyCFunction)PyCursesPanel_replace_panel, ! METH_VARARGS}, {"set_userptr", (PyCFunction)PyCursesPanel_set_panel_userptr, METH_VARARGS}, From python-dev@python.org Fri Dec 22 22:06:45 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 22 Dec 2000 14:06:45 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcurses.tex,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv21355 Modified Files: libcurses.tex Log Message: Add 'see also' link to curses.panel Index: libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** libcurses.tex 2000/12/21 17:04:31 1.26 --- libcurses.tex 2000/12/22 22:06:43 1.27 *************** *** 25,28 **** --- 25,30 ---- characters, regardless of your locale settings.} + \seemodule{curses.panel}{A panel stack extension that adds depth to + curses windows.} \seemodule{curses.textpad}{Editable text widget for curses supporting \program{Emacs}-like bindings.} From python-dev@python.org Sat Dec 23 05:46:25 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 22 Dec 2000 21:46:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _curses_panel.c,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv18355/Modules Modified Files: _curses_panel.c Log Message: Shortened / wrapped some long lines. Removed warning on use of panel_userptr() in PyCursesPanel_userptr(). Index: _curses_panel.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_curses_panel.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** _curses_panel.c 2000/12/22 22:03:15 1.2 --- _curses_panel.c 2000/12/23 05:46:23 1.3 *************** *** 142,156 **** #define Panel_NoArgNoReturnFunction(X) \ ! static PyObject *PyCursesPanel_ ## X (PyCursesPanelObject *self, PyObject *args) \ { if (!PyArg_NoArgs(args)) return NULL; \ return PyCursesCheckERR(X(self->pan), # X); } #define Panel_NoArgReturnStringFunction(X) \ ! static PyObject *PyCursesPanel_ ## X (PyCursesPanelObject *self, PyObject *args) \ { if (!PyArg_NoArgs(args)) return NULL; \ return PyString_FromString(X(self->pan)); } #define Panel_NoArgTrueFalseFunction(X) \ ! static PyObject * PyCursesPanel_ ## X (PyCursesPanelObject *self, PyObject *args) \ { \ if (!PyArg_NoArgs(args)) return NULL; \ --- 142,156 ---- #define Panel_NoArgNoReturnFunction(X) \ ! static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self, PyObject *args) \ { if (!PyArg_NoArgs(args)) return NULL; \ return PyCursesCheckERR(X(self->pan), # X); } #define Panel_NoArgReturnStringFunction(X) \ ! static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self, PyObject *args) \ { if (!PyArg_NoArgs(args)) return NULL; \ return PyString_FromString(X(self->pan)); } #define Panel_NoArgTrueFalseFunction(X) \ ! static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self, PyObject *args) \ { \ if (!PyArg_NoArgs(args)) return NULL; \ *************** *** 159,163 **** #define Panel_TwoArgNoReturnFunction(X, TYPE, PARSESTR) \ ! static PyObject * PyCursesPanel_ ## X (PyCursesPanelObject *self, PyObject *args) \ { \ TYPE arg1, arg2; \ --- 159,163 ---- #define Panel_TwoArgNoReturnFunction(X, TYPE, PARSESTR) \ ! static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self, PyObject *args) \ { \ TYPE arg1, arg2; \ *************** *** 310,314 **** obj = PyTuple_GetItem(args, 0); Py_INCREF(obj); ! return PyCursesCheckERR(set_panel_userptr(self->pan, obj), "set_panel_userptr"); } --- 310,315 ---- obj = PyTuple_GetItem(args, 0); Py_INCREF(obj); ! return PyCursesCheckERR(set_panel_userptr(self->pan, obj), ! "set_panel_userptr"); } *************** *** 318,323 **** PyObject *obj; PyCursesInitialised; ! if (!PyArg_NoArgs(args)) return NULL; ! obj = panel_userptr(self->pan); Py_INCREF(obj); return obj; --- 319,325 ---- PyObject *obj; PyCursesInitialised; ! if (!PyArg_NoArgs(args)) ! return NULL; ! obj = (PyObject *) panel_userptr(self->pan); Py_INCREF(obj); return obj; *************** *** 409,413 **** PANEL *pan; ! if (!PyArg_ParseTuple(args, "O!", &PyCursesWindow_Type, &win)) return NULL; pan = new_panel(win->win); if (pan == NULL) { --- 411,416 ---- PANEL *pan; ! if (!PyArg_ParseTuple(args, "O!", &PyCursesWindow_Type, &win)) ! return NULL; pan = new_panel(win->win); if (pan == NULL) { From python-dev@python.org Sat Dec 23 14:11:30 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 23 Dec 2000 06:11:30 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.185,2.186 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv16346 Modified Files: bltinmodule.c Log Message: CHange error messages for ord(), using "string" instead of "string or Unicode" Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.185 retrieving revision 2.186 diff -C2 -r2.185 -r2.186 *** bltinmodule.c 2000/12/20 15:07:34 2.185 --- bltinmodule.c 2000/12/23 14:11:28 2.186 *************** *** 1525,1529 **** } else { PyErr_Format(PyExc_TypeError, ! "ord() expected string or Unicode character, " \ "%.200s found", obj->ob_type->tp_name); return NULL; --- 1525,1529 ---- } else { PyErr_Format(PyExc_TypeError, ! "ord() expected string of length 1, but " \ "%.200s found", obj->ob_type->tp_name); return NULL; *************** *** 1531,1535 **** PyErr_Format(PyExc_TypeError, ! "ord() expected a character, length-%d string found", size); return NULL; --- 1531,1536 ---- PyErr_Format(PyExc_TypeError, ! "ord() expected a character, " ! "but string of length %d found", size); return NULL; From python-dev@python.org Sat Dec 23 14:20:26 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 23 Dec 2000 06:20:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib shlex.py,1.9,1.10 netrc.py,1.7,1.8 multifile.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv18929 Modified Files: shlex.py netrc.py multifile.py Log Message: Remove superfluous semicolons Index: shlex.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/shlex.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** shlex.py 2000/07/09 16:44:26 1.9 --- shlex.py 2000/12/23 14:20:23 1.10 *************** *** 23,27 **** self.quotes = '\'"' self.state = ' ' ! self.pushback = []; self.lineno = 1 self.debug = 0 --- 23,27 ---- self.quotes = '\'"' self.state = ' ' ! self.pushback = [] self.lineno = 1 self.debug = 0 *************** *** 37,41 **** if self.debug >= 1: print "shlex: pushing token " + `tok` ! self.pushback = [tok] + self.pushback; def get_token(self): --- 37,41 ---- if self.debug >= 1: print "shlex: pushing token " + `tok` ! self.pushback = [tok] + self.pushback def get_token(self): *************** *** 84,88 **** tok = '' while 1: ! nextchar = self.instream.read(1); if nextchar == '\n': self.lineno = self.lineno + 1 --- 84,88 ---- tok = '' while 1: ! nextchar = self.instream.read(1) if nextchar == '\n': self.lineno = self.lineno + 1 *************** *** 91,99 **** "I see character:", repr(nextchar) if self.state is None: ! self.token = ''; # past end of file break elif self.state == ' ': if not nextchar: ! self.state = None; # end of file break elif nextchar in self.whitespace: --- 91,99 ---- "I see character:", repr(nextchar) if self.state is None: ! self.token = '' # past end of file break elif self.state == ' ': if not nextchar: ! self.state = None # end of file break elif nextchar in self.whitespace: *************** *** 126,130 **** elif self.state == 'a': if not nextchar: ! self.state = None; # end of file break elif nextchar in self.whitespace: --- 126,130 ---- elif self.state == 'a': if not nextchar: ! self.state = None # end of file break elif nextchar in self.whitespace: Index: netrc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/netrc.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** netrc.py 2000/12/12 23:20:44 1.7 --- netrc.py 2000/12/23 14:20:24 1.8 *************** *** 47,51 **** if tt=='' or tt == 'machine' or tt == 'default' or tt == 'macdef': if toplevel == 'macdef': ! break; elif login and password: self.hosts[entryname] = (login, account, password) --- 47,51 ---- if tt=='' or tt == 'machine' or tt == 'default' or tt == 'macdef': if toplevel == 'macdef': ! break elif login and password: self.hosts[entryname] = (login, account, password) Index: multifile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/multifile.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** multifile.py 2000/12/12 23:20:44 1.12 --- multifile.py 2000/12/23 14:20:24 1.13 *************** *** 87,91 **** else: # Ignore trailing whitespace on marker lines ! k = len(line) - 1; while line[k] in string.whitespace: k = k - 1 --- 87,91 ---- else: # Ignore trailing whitespace on marker lines ! k = len(line) - 1 while line[k] in string.whitespace: k = k - 1 From python-dev@python.org Sat Dec 23 14:50:21 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 23 Dec 2000 06:50:21 -0800 Subject: [Python-checkins] CVS: python/dist/src/Demo/curses tclock.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/curses In directory usw-pr-cvs1:/tmp/cvs-serv28253 Modified Files: tclock.py Log Message: Choose the smallest value of x,y for the clock's radius (instead of just taking the y coordinate), and change radius of second indicator to compensate Remove redundant setting of sradius Index: tclock.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/curses/tclock.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** tclock.py 2000/12/15 00:41:48 1.1 --- tclock.py 2000/12/23 14:50:18 1.2 *************** *** 81,95 **** cx = (curses.COLS - 1) / 2 cy = curses.LINES / 2 ! if cx > cy: ! ch = cy ! else: ! ch = cx ! mradius = (3 * cy) / 4 ! hradius = cy / 2 ! sradius = (2 * cy) / 3 for i in range(0, 12): sangle = (i + 1) * 2.0 * pi / 12.0 - sradius = 5 * cy / 6 sdx, sdy = A2XY(sangle, sradius) --- 81,91 ---- cx = (curses.COLS - 1) / 2 cy = curses.LINES / 2 ! ch = min( cy-1, int(cx / ASPECT) - 1) ! mradius = (3 * ch) / 4 ! hradius = ch / 2 ! sradius = 5 * ch / 6 for i in range(0, 12): sangle = (i + 1) * 2.0 * pi / 12.0 sdx, sdy = A2XY(sangle, sradius) *************** *** 99,103 **** "ASCII Clock by Howard Jones , 1994") ! sradius = 8 while 1: curses.napms(1000) --- 95,100 ---- "ASCII Clock by Howard Jones , 1994") ! sradius = max(sradius-4, 8) ! while 1: curses.napms(1000) From python-dev@python.org Sat Dec 23 22:08:30 2000 From: python-dev@python.org (Fred L. Drake) Date: Sat, 23 Dec 2000 14:08:30 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_regex.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv15551/Lib/test Modified Files: test_regex.py Log Message: The regression test for the regex module should not trip the deprecation warning for that module, so suppress just that one warning. Index: test_regex.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_regex.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** test_regex.py 2000/10/23 17:22:08 1.5 --- test_regex.py 2000/12/23 22:08:27 1.6 *************** *** 1,3 **** --- 1,6 ---- from test_support import verbose + import warnings + warnings.filterwarnings("ignore", "the regex module is deprecated", + DeprecationWarning, "test_regex") import regex from regex_syntax import * From python-dev@python.org Sat Dec 23 22:12:09 2000 From: python-dev@python.org (Fred L. Drake) Date: Sat, 23 Dec 2000 14:12:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_pyexpat.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv18271/test Modified Files: test_pyexpat.py Log Message: The "context" parameter to the ExternalEntityRefParameter exposes internal information from the Expat library that is not part of its public API. Do not print this information as the format of the string may (and will) change as Expat evolves. Add additional tests to make sure the ParserCreate() function raises the right exceptions on illegal parameters. Index: test_pyexpat.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pyexpat.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_pyexpat.py 2000/10/23 17:22:07 1.6 --- test_pyexpat.py 2000/12/23 22:12:07 1.7 *************** *** 51,55 **** def ExternalEntityRefHandler(self, *args): context, base, sysId, pubId = args ! print 'External entity ref:', args return 1 --- 51,55 ---- def ExternalEntityRefHandler(self, *args): context, base, sysId, pubId = args ! print 'External entity ref:', args[1:] return 1 *************** *** 151,152 **** --- 151,183 ---- print '** Column', parser.ErrorColumnNumber print '** Byte', parser.ErrorByteIndex + + + # Tests that make sure we get errors when the namespace_separator value + # is illegal, and that we don't for good values: + print + print "Testing constructor for proper handling of namespace_separator values:" + expat.ParserCreate() + expat.ParserCreate(namespace_separator=None) + expat.ParserCreate(namespace_separator=' ') + print "Legal values tested o.k." + try: + expat.ParserCreate(namespace_separator=42) + except TypeError, e: + print "Caught expected TypeError:" + print e + else: + print "Failed to catch expected TypeError." + try: + expat.ParserCreate(namespace_separator='too long') + except ValueError, e: + print "Caught expected ValueError:" + print e + else: + print "Failed to catch expected ValueError." + try: + expat.ParserCreate(namespace_separator='') # too short + except ValueError, e: + print "Caught expected ValueError:" + print e + else: + print "Failed to catch expected ValueError." From python-dev@python.org Sat Dec 23 22:12:09 2000 From: python-dev@python.org (Fred L. Drake) Date: Sat, 23 Dec 2000 14:12:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_pyexpat,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv18271/test/output Modified Files: test_pyexpat Log Message: The "context" parameter to the ExternalEntityRefParameter exposes internal information from the Expat library that is not part of its public API. Do not print this information as the format of the string may (and will) change as Expat evolves. Add additional tests to make sure the ParserCreate() function raises the right exceptions on illegal parameters. Index: test_pyexpat =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_pyexpat,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_pyexpat 2000/09/21 20:32:13 1.3 --- test_pyexpat 2000/12/23 22:12:07 1.4 *************** *** 31,35 **** End element: 'sub2' ! External entity ref: ('http://www.python.org/namespace=http://www.w3.org/XML/1998/namespace\014external_entity', None, 'entity.file', None) End element: 'root' --- 31,35 ---- End element: 'sub2' ! External entity ref: (None, 'entity.file', None) End element: 'root' *************** *** 61,65 **** End element: u'sub2' ! External entity ref: (u'http://www.python.org/namespace=http://www.w3.org/XML/1998/namespace\014external_entity', None, u'entity.file', None) End element: u'root' --- 61,65 ---- End element: u'sub2' ! External entity ref: (None, u'entity.file', None) End element: u'root' *************** *** 91,95 **** End element: u'sub2' ! External entity ref: (u'http://www.python.org/namespace=http://www.w3.org/XML/1998/namespace\014external_entity', None, u'entity.file', None) End element: u'root' --- 91,104 ---- End element: u'sub2' ! External entity ref: (None, u'entity.file', None) End element: u'root' + + Testing constructor for proper handling of namespace_separator values: + Legal values tested o.k. + Caught expected TypeError: + ParserCreate, argument 2: expected string or None, int found + Caught expected ValueError: + namespace_separator must be one character, omitted, or None + Caught expected ValueError: + namespace_separator must be one character, omitted, or None From python-dev@python.org Sat Dec 23 22:19:07 2000 From: python-dev@python.org (Fred L. Drake) Date: Sat, 23 Dec 2000 14:19:07 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libpyexpat.tex,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv19645 Modified Files: libpyexpat.tex Log Message: Added information on the ExternalEntityParserCreate() method. Index: libpyexpat.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpyexpat.tex,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** libpyexpat.tex 2000/12/07 00:00:21 1.9 --- libpyexpat.tex 2000/12/23 22:19:05 1.10 *************** *** 81,87 **** elem2 \end{verbatim} - \end{funcdesc} \class{xmlparser} objects have the following methods: --- 81,89 ---- elem2 \end{verbatim} \end{funcdesc} + + \subsection{XMLParser Objects \label{xmlparser-objects}} + \class{xmlparser} objects have the following methods: *************** *** 89,93 **** Parses the contents of the string \var{data}, calling the appropriate handler functions to process the parsed data. \var{isfinal} must be ! true on the final call to this method. \var{data} can be the empty string at any time. \end{methoddesc} --- 91,95 ---- Parses the contents of the string \var{data}, calling the appropriate handler functions to process the parsed data. \var{isfinal} must be ! true on the final call to this method. \var{data} can be the empty string at any time. \end{methoddesc} *************** *** 111,114 **** --- 113,124 ---- \method{SetBase()}, or \code{None} if \method{SetBase()} hasn't been called. + \end{methoddesc} + + \begin{methoddesc}[xmlparser]{ExternalEntityParserCreate}{context\optional{, + encoding}} + Create a ``child'' parser which can be used to parse an external + parsed entity referred to by content parsed by the parent parser. The + \var{content} parameter should be the string passed to the + \method{ExternalEntityRefHandler()} handler function, described below. \end{methoddesc} From python-dev@python.org Mon Dec 25 06:19:11 2000 From: python-dev@python.org (Fred L. Drake) Date: Sun, 24 Dec 2000 22:19:11 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libwarnings.tex,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv28673/Doc/lib Modified Files: libwarnings.tex Log Message: Make sure subsections are formatted into HTML pages with reasonable names. Index: libwarnings.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwarnings.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** libwarnings.tex 2000/12/19 06:01:23 1.1 --- libwarnings.tex 2000/12/25 06:19:08 1.2 *************** *** 44,48 **** ! \subsection{Warning Categories} There are a number of built-in exceptions that represent warning --- 44,48 ---- ! \subsection{Warning Categories \label{warning-categories}} There are a number of built-in exceptions that represent warning *************** *** 77,81 **** ! \subsection{The Warnings Filter} The warnings filter controls whether warnings are ignored, displayed, --- 77,81 ---- ! \subsection{The Warnings Filter \label{warning-filter}} The warnings filter controls whether warnings are ignored, displayed, *************** *** 139,143 **** ! \subsection{Available Functions} \begin{funcdesc}{warn}{message\optional{, category\optional{, stacklevel}}} --- 139,143 ---- ! \subsection{Available Functions \label{warning-functions}} \begin{funcdesc}{warn}{message\optional{, category\optional{, stacklevel}}} *************** *** 176,180 **** \begin{funcdesc}{filterwarnings}{action\optional{, ! message\optional{, category\optional{, module\optional{, lineno}}}}} Insert an entry into the list of warnings filters (at the front). This checks the types of the arguments, compiles the message and --- 176,181 ---- \begin{funcdesc}{filterwarnings}{action\optional{, ! message\optional{, category\optional{, ! module\optional{, lineno}}}}} Insert an entry into the list of warnings filters (at the front). This checks the types of the arguments, compiles the message and From python-dev@python.org Tue Dec 26 15:57:05 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 26 Dec 2000 07:57:05 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.45,2.46 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv12097 Modified Files: _cursesmodule.c Log Message: Add the curses constants ERR and OK to the module at TG's suggestion Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.45 retrieving revision 2.46 diff -C2 -r2.45 -r2.46 *** _cursesmodule.c 2000/12/22 21:52:27 2.45 --- _cursesmodule.c 2000/12/26 15:57:01 2.46 *************** *** 2465,2468 **** --- 2465,2471 ---- Py_DECREF(v); + SetDictInt("ERR", ERR); + SetDictInt("OK", OK); + /* Here are some attributes you can add to chars to print */ From python-dev@python.org Tue Dec 26 15:58:29 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 26 Dec 2000 07:58:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcurses.tex,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv12340 Modified Files: libcurses.tex Log Message: Document ERR and OK Index: libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** libcurses.tex 2000/12/22 22:06:43 1.27 --- libcurses.tex 2000/12/26 15:58:27 1.28 *************** *** 1027,1030 **** --- 1027,1041 ---- The \module{curses} module defines the following data members: + \begin{datadesc}{ERR} + Some curses routines that return an integer, such as + \function{getch()}, return ERR upon failure. + \end{datadesc} + + \begin{datadesc}{OK} + Some curses routines that return an integer, such as + \function{napms()}, return OK upon success. + + \end{datadesc} + \begin{datadesc}{version} A string representing the current version of the module. From python-dev@python.org Tue Dec 26 16:08:01 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 26 Dec 2000 08:08:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses ascii.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/curses In directory usw-pr-cvs1:/tmp/cvs-serv14257 Modified Files: ascii.py Log Message: Make isspace(chr(32)) return true Index: ascii.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/curses/ascii.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** ascii.py 2000/07/11 10:38:24 1.3 --- ascii.py 2000/12/26 16:07:59 1.4 *************** *** 62,66 **** def isprint(c): return _ctoi(c) >= 32 and _ctoi(c) <= 126 def ispunct(c): return _ctoi(c) != 32 and not isalnum(c) ! def isspace(c): return _ctoi(c) in (12, 10, 13, 9, 11) def isupper(c): return _ctoi(c) >= 65 and _ctoi(c) <= 90 def isxdigit(c): return isdigit(c) or \ --- 62,66 ---- def isprint(c): return _ctoi(c) >= 32 and _ctoi(c) <= 126 def ispunct(c): return _ctoi(c) != 32 and not isalnum(c) ! def isspace(c): return _ctoi(c) in (9, 10, 11, 12, 13, 32) def isupper(c): return _ctoi(c) >= 65 and _ctoi(c) <= 90 def isxdigit(c): return isdigit(c) or \ From python-dev@python.org Tue Dec 26 16:09:39 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 26 Dec 2000 08:09:39 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libascii.tex,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv16315 Modified Files: libascii.tex Log Message: Remove redundant reference to tab (since it = 'horizontal tab') Index: libascii.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libascii.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** libascii.tex 2000/08/09 14:36:11 1.5 --- libascii.tex 2000/12/26 16:09:37 1.6 *************** *** 105,109 **** \begin{funcdesc}{isspace}{c} ! Checks for \ASCII{} white-space characters; space, tab, line feed, carriage return, form feed, horizontal tab, vertical tab. \end{funcdesc} --- 105,109 ---- \begin{funcdesc}{isspace}{c} ! Checks for \ASCII{} white-space characters; space, line feed, carriage return, form feed, horizontal tab, vertical tab. \end{funcdesc} From python-dev@python.org Tue Dec 26 16:14:35 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 26 Dec 2000 08:14:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libstring.tex,1.41,1.42 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv21730 Modified Files: libstring.tex Log Message: Fix doubled word Index: libstring.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstring.tex,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -r1.41 -r1.42 *** libstring.tex 2000/10/04 13:59:52 1.41 --- libstring.tex 2000/12/26 16:14:32 1.42 *************** *** 11,15 **** expressions. ! The constants defined in this module are are: \begin{datadesc}{digits} --- 11,15 ---- expressions. ! The constants defined in this module are: \begin{datadesc}{digits} From python-dev@python.org Wed Dec 27 08:03:22 2000 From: python-dev@python.org (Tim Peters) Date: Wed, 27 Dec 2000 00:03:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_getopt.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv715/python/dist/src/lib/test Modified Files: test_getopt.py Log Message: Add test case for SF bug https://sourceforge.net/bugs/?func=detailbug&bug_id=126863&group_id=5470 Index: test_getopt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_getopt.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_getopt.py 2000/08/21 22:59:26 1.2 --- test_getopt.py 2000/12/27 08:03:20 1.3 *************** *** 75,78 **** --- 75,87 ---- assert opts == [('--abcd', '1')] assert args == [] + opts, args = getopt.do_longs([], 'abc', ['ab', 'abc', 'abcd'], []) + assert opts == [('--abc', '')] + assert args == [] + # Much like the preceding, except with a non-alpha character ("-") in + # option name that precedes "="; failed in + # http://sourceforge.net/bugs/?func=detailbug&bug_id=126863&group_id=5470 + opts, args = getopt.do_longs([], 'foo=42', ['foo-bar', 'foo=',], []) + assert opts == [('--foo', '42')] + assert args == [] expectException("opts, args = getopt.do_longs([], 'abc=1', ['abc'], [])", GetoptError) From python-dev@python.org Wed Dec 27 08:05:07 2000 From: python-dev@python.org (Tim Peters) Date: Wed, 27 Dec 2000 00:05:07 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib getopt.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv796/python/dist/src/lib Modified Files: getopt.py Log Message: Fix for SF bug https://sourceforge.net/bugs/?func=detailbug&bug_id=126863&group_id=5470 "getopt long option handling broken". Tossed the excruciating logic in long_has_args in favor of something obviously correct. Index: getopt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/getopt.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** getopt.py 2000/02/25 16:34:11 1.11 --- getopt.py 2000/12/27 08:05:05 1.12 *************** *** 67,71 **** longopts = list(longopts) longopts.sort() ! while args and args[0][:1] == '-' and args[0] != '-': if args[0] == '--': args = args[1:] --- 67,71 ---- longopts = list(longopts) longopts.sort() ! while args and args[0].startswith('-') and args[0] != '-': if args[0] == '--': args = args[1:] *************** *** 81,87 **** try: i = opt.index('=') - opt, optarg = opt[:i], opt[i+1:] except ValueError: optarg = None has_arg, opt = long_has_args(opt, longopts) --- 81,88 ---- try: i = opt.index('=') except ValueError: optarg = None + else: + opt, optarg = opt[:i], opt[i+1:] has_arg, opt = long_has_args(opt, longopts) *************** *** 99,115 **** # has_arg? # full option name def long_has_args(opt, longopts): - optlen = len(opt) for i in range(len(longopts)): ! x, y = longopts[i][:optlen], longopts[i][optlen:] ! if opt != x: ! continue ! if y != '' and y != '=' and i+1 < len(longopts): ! if opt == longopts[i+1][:optlen]: ! raise GetoptError('option --%s not a unique prefix' % opt, opt) ! if longopts[i][-1:] in ('=', ): ! return 1, longopts[i][:-1] ! return 0, longopts[i] ! raise GetoptError('option --%s not recognized' % opt, opt) def do_shorts(opts, optstring, shortopts, args): --- 100,132 ---- # has_arg? # full option name + # Assumes longopts has been sorted (ASCII order). def long_has_args(opt, longopts): for i in range(len(longopts)): ! if longopts[i].startswith(opt): ! break ! else: ! raise GetoptError('option --%s not recognized' % opt, opt) ! # opt is a prefix of longopts[i]; find j s.t. opt is a prefix of ! # each possibility in longopts[i:j] ! j = i+1 ! while j < len(longopts) and longopts[j].startswith(opt): ! j += 1 ! possibilities = longopts[i:j] ! # Is there an exact match? ! if opt in possibilities: ! return 0, opt ! elif opt + '=' in possibilities: ! return 1, opt ! # No exact match, so better be unique. ! if len(possibilities) > 1: ! # XXX since possibilities contains all valid continuations, might be ! # nice to work them into the error msg ! raise GetoptError('option --%s not a unique prefix' % opt, opt) ! assert len(possibilities) == 1 ! unique_match = possibilities[0] ! has_arg = unique_match.endswith('=') ! if has_arg: ! unique_match = unique_match[:-1] ! return has_arg, unique_match def do_shorts(opts, optstring, shortopts, args): From python-dev@python.org Wed Dec 27 17:41:49 2000 From: python-dev@python.org (Barry Warsaw) Date: Wed, 27 Dec 2000 09:41:49 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc python-mode.el,3.108,3.109 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv16451 Modified Files: python-mode.el Log Message: (python-font-lock-keywords): Add highlighting of `as' as a keyword, but only in "import foo as bar" statements (including optional preceding `from' clause). Index: python-mode.el =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/python-mode.el,v retrieving revision 3.108 retrieving revision 3.109 diff -C2 -r3.108 -r3.109 *** python-mode.el 2000/10/27 05:00:25 3.108 --- python-mode.el 2000/12/27 17:41:47 3.109 *************** *** 333,336 **** --- 333,338 ---- ;; Yes "except" is in both lists. (cons (concat "\\b\\(" kw2 "\\)[ \n\t(]") 1) + ;; `as' but only in "import foo as bar" + '("[ \t]*\\(\\bfrom\\b.*\\)?\\bimport\\b.*\\b\\(as\\)\\b" . 2) ;; classes '("\\bclass[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)" From python-dev@python.org Wed Dec 27 19:13:00 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 27 Dec 2000 11:13:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib code.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv14677 Modified Files: code.py Log Message: Make Traceback header conform to new traceback ("innermost last" -> "most recent call last"). Index: code.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/code.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** code.py 2000/02/28 15:12:25 1.9 --- code.py 2000/12/27 19:12:58 1.10 *************** *** 142,146 **** list = traceback.format_list(tblist) if list: ! list.insert(0, "Traceback (innermost last):\n") list[len(list):] = traceback.format_exception_only(type, value) finally: --- 142,146 ---- list = traceback.format_list(tblist) if list: ! list.insert(0, "Traceback (most recent call last):\n") list[len(list):] = traceback.format_exception_only(type, value) finally: From python-dev@python.org Wed Dec 27 19:12:42 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 27 Dec 2000 11:12:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib cgi.py,1.56,1.57 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv14652 Modified Files: cgi.py Log Message: Make Traceback header conform to new traceback ("innermost last" -> "most recent call last"). Index: cgi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cgi.py,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -r1.56 -r1.57 *** cgi.py 2000/11/06 18:46:09 1.56 --- cgi.py 2000/12/27 19:12:40 1.57 *************** *** 865,869 **** import traceback print ! print "

Traceback (innermost last):

" list = traceback.format_tb(tb, limit) + \ traceback.format_exception_only(type, value) --- 865,869 ---- import traceback print ! print "

Traceback (most recent call last):

" list = traceback.format_tb(tb, limit) + \ traceback.format_exception_only(type, value) From python-dev@python.org Wed Dec 27 22:26:10 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 27 Dec 2000 14:26:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/idle/Icons minusnode.gif,1.1,1.2 python.gif,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/idle/Icons In directory usw-pr-cvs1:/tmp/cvs-serv15026 Modified Files: minusnode.gif python.gif Log Message: Fixed snake logo and minus image by Daniel Calvelo. Index: minusnode.gif =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/idle/Icons/minusnode.gif,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 Binary files /tmp/cvsjcgx1G and /tmp/cvsunMJTd differ Index: python.gif =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/idle/Icons/python.gif,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 Binary files /tmp/cvs7iQv1I and /tmp/cvsQkGuQh differ From python-dev@python.org Thu Dec 28 00:44:29 2000 From: python-dev@python.org (Tim Peters) Date: Wed, 27 Dec 2000 19:44:29 -0500 Subject: [Python-checkins] CVS: python/dist/src/Misc python-mode.el,3.108,3.109 In-Reply-To: Message-ID: [Barry Warsaw] > Modified Files: > python-mode.el > Log Message: > (python-font-lock-keywords): Add highlighting of `as' as a keyword, > but only in "import foo as bar" statements (including optional > preceding `from' clause). Oh, that's right, try to make IDLE look bad, will you? I've got half a mind to take up the challenge. Unfortunately, I only have half a mind in total, so you may get away with this backstabbing for a while . From python-dev@python.org Thu Dec 28 16:00:36 2000 From: python-dev@python.org (Barry A. Warsaw) Date: Thu, 28 Dec 2000 11:00:36 -0500 Subject: [Python-checkins] CVS: python/dist/src/Misc python-mode.el,3.108,3.109 References: Message-ID: <14923.25508.668453.186209@anthem.concentric.net> >>>>> "TP" == Tim Peters writes: TP> [Barry Warsaw] >> Modified Files: python-mode.el Log Message: >> (python-font-lock-keywords): Add highlighting of `as' as a >> keyword, but only in "import foo as bar" statements (including >> optional preceding `from' clause). TP> Oh, that's right, try to make IDLE look bad, will you? I've TP> got half a mind to take up the challenge. Unfortunately, I TP> only have half a mind in total, so you may get away with this TP> backstabbing for a while . With my current network (un)connectivity, I feel like a nuclear sub which can only surface once a month to receive low frequency orders from some remote antenna farm out in New Brunswick. Just think of me as a rogue commander who tries to do as much damage as possible when he's not joyriding in the draft-wake of giant squids. rehoming-all-remaining-missiles-at-the-Kingdom-of-Timbotia-ly y'rs, -Barry From python-dev@python.org Thu Dec 28 18:40:58 2000 From: python-dev@python.org (Martin v. Löwis) Date: Thu, 28 Dec 2000 10:40:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom minidom.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory usw-pr-cvs1:/tmp/cvs-serv16398 Modified Files: minidom.py Log Message: Merge changes up to 1.10 from PyXML: - implement hasAttribute and hasAttributeNS (1.7) - Node.replaceChild(): Update the sibling nodes to point to newChild. Set the .nextSibling attribute on oldChild instead of adding a .newChild attribute (1.9). Index: minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/minidom.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** minidom.py 2000/12/20 14:47:24 1.16 --- minidom.py 2000/12/28 18:40:56 1.17 *************** *** 146,151 **** newChild.nextSibling = oldChild.nextSibling newChild.previousSibling = oldChild.previousSibling ! oldChild.newChild = None oldChild.previousSibling = None return oldChild --- 146,155 ---- newChild.nextSibling = oldChild.nextSibling newChild.previousSibling = oldChild.previousSibling ! oldChild.nextSibling = None oldChild.previousSibling = None + if newChild.previousSibling: + newChild.previousSibling.nextSibling = newChild + if newChild.nextSibling: + newChild.nextSibling.previousSibling = newChild return oldChild *************** *** 464,467 **** --- 468,477 ---- del self._attrsNS[(node.namespaceURI, node.localName)] + def hasAttribute(self, name): + return self._attrs.has_key(name) + + def hasAttributeNS(self, namespaceURI, localName): + return self._attrsNS.has_key((namespaceURI, localName)) + def getElementsByTagName(self, name): return _getElementsByTagNameHelper(self, name, []) From python-dev@python.org Thu Dec 28 18:43:04 2000 From: python-dev@python.org (Martin v. Löwis) Date: Thu, 28 Dec 2000 10:43:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom pulldom.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory usw-pr-cvs1:/tmp/cvs-serv22869 Modified Files: pulldom.py Log Message: Merge with 1.8 of pulldom.py: Use types.UnicodeType if available, not type(u""). Index: pulldom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/pulldom.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** pulldom.py 2000/12/20 14:47:24 1.13 --- pulldom.py 2000/12/28 18:43:02 1.14 *************** *** 1,5 **** --- 1,11 ---- import xml.sax import xml.sax.handler + import types + try: + _StringTypes = [types.StringType, types.UnicodeType] + except AttributeError: + _StringTypes = [types.StringType] + START_ELEMENT = "START_ELEMENT" END_ELEMENT = "END_ELEMENT" *************** *** 236,240 **** if bufsize is None: bufsize = default_bufsize ! if type(stream_or_string) in [type(""), type(u"")]: stream = open(stream_or_string) else: --- 242,246 ---- if bufsize is None: bufsize = default_bufsize ! if type(stream_or_string) in _StringTypes: stream = open(stream_or_string) else: From python-dev@python.org Fri Dec 29 02:06:47 2000 From: python-dev@python.org (Tim Peters) Date: Thu, 28 Dec 2000 18:06:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_bisect.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv26508/python/dist/src/Lib/test Added Files: test_bisect.py Log Message: Fred, THIS NEEDS DOCS! The function docstrings tell the tale. Christmas present to myself: the bisect module didn't define what happened if the new element was already in the list. It so happens that it inserted the new element "to the right" of all equal elements. Since it wasn't defined, among other bad implications it was a mystery how to use bisect to determine whether an element was already in the list (I've seen code that *assumed* "to the right" without justification). Added new methods bisect_left and insort_left that insert "to the left" instead; made the old names bisect and insort aliases for the new names bisect_right and insort_right; beefed up docstrings to explain what these actually do; and added a std test for the bisect module. --- NEW FILE: test_bisect.py --- from test_support import TestFailed import bisect import sys nerrors = 0 def check_bisect(func, list, elt, expected): global nerrors got = func(list, elt) if got != expected: print >> sys.stderr, \ "expected %s(%s, %s) -> %s, but got %s" % (func.__name__, list, elt, expected, got) nerrors += 1 # XXX optional slice arguments need tests. check_bisect(bisect.bisect_right, [], 1, 0) check_bisect(bisect.bisect_right, [1], 0, 0) check_bisect(bisect.bisect_right, [1], 1, 1) check_bisect(bisect.bisect_right, [1], 2, 1) check_bisect(bisect.bisect_right, [1, 1], 0, 0) check_bisect(bisect.bisect_right, [1, 1], 1, 2) check_bisect(bisect.bisect_right, [1, 1], 2, 2) check_bisect(bisect.bisect_right, [1, 1, 1], 0, 0) check_bisect(bisect.bisect_right, [1, 1, 1], 1, 3) check_bisect(bisect.bisect_right, [1, 1, 1], 2, 3) check_bisect(bisect.bisect_right, [1, 1, 1, 1], 0, 0) check_bisect(bisect.bisect_right, [1, 1, 1, 1], 1, 4) check_bisect(bisect.bisect_right, [1, 1, 1, 1], 2, 4) check_bisect(bisect.bisect_right, [1, 2], 0, 0) check_bisect(bisect.bisect_right, [1, 2], 1, 1) check_bisect(bisect.bisect_right, [1, 2], 1.5, 1) check_bisect(bisect.bisect_right, [1, 2], 2, 2) check_bisect(bisect.bisect_right, [1, 2], 3, 2) check_bisect(bisect.bisect_right, [1, 1, 2, 2], 0, 0) check_bisect(bisect.bisect_right, [1, 1, 2, 2], 1, 2) check_bisect(bisect.bisect_right, [1, 1, 2, 2], 1.5, 2) check_bisect(bisect.bisect_right, [1, 1, 2, 2], 2, 4) check_bisect(bisect.bisect_right, [1, 1, 2, 2], 3, 4) check_bisect(bisect.bisect_right, [1, 2, 3], 0, 0) check_bisect(bisect.bisect_right, [1, 2, 3], 1, 1) check_bisect(bisect.bisect_right, [1, 2, 3], 1.5, 1) check_bisect(bisect.bisect_right, [1, 2, 3], 2, 2) check_bisect(bisect.bisect_right, [1, 2, 3], 2.5, 2) check_bisect(bisect.bisect_right, [1, 2, 3], 3, 3) check_bisect(bisect.bisect_right, [1, 2, 3], 4, 3) check_bisect(bisect.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 0, 0) check_bisect(bisect.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1, 1) check_bisect(bisect.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1.5, 1) check_bisect(bisect.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2, 3) check_bisect(bisect.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2.5, 3) check_bisect(bisect.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3, 6) check_bisect(bisect.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3.5, 6) check_bisect(bisect.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 4, 10) check_bisect(bisect.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 5, 10) check_bisect(bisect.bisect_left, [], 1, 0) check_bisect(bisect.bisect_left, [1], 0, 0) check_bisect(bisect.bisect_left, [1], 1, 0) check_bisect(bisect.bisect_left, [1], 2, 1) check_bisect(bisect.bisect_left, [1, 1], 0, 0) check_bisect(bisect.bisect_left, [1, 1], 1, 0) check_bisect(bisect.bisect_left, [1, 1], 2, 2) check_bisect(bisect.bisect_left, [1, 1, 1], 0, 0) check_bisect(bisect.bisect_left, [1, 1, 1], 1, 0) check_bisect(bisect.bisect_left, [1, 1, 1], 2, 3) check_bisect(bisect.bisect_left, [1, 1, 1, 1], 0, 0) check_bisect(bisect.bisect_left, [1, 1, 1, 1], 1, 0) check_bisect(bisect.bisect_left, [1, 1, 1, 1], 2, 4) check_bisect(bisect.bisect_left, [1, 2], 0, 0) check_bisect(bisect.bisect_left, [1, 2], 1, 0) check_bisect(bisect.bisect_left, [1, 2], 1.5, 1) check_bisect(bisect.bisect_left, [1, 2], 2, 1) check_bisect(bisect.bisect_left, [1, 2], 3, 2) check_bisect(bisect.bisect_left, [1, 1, 2, 2], 0, 0) check_bisect(bisect.bisect_left, [1, 1, 2, 2], 1, 0) check_bisect(bisect.bisect_left, [1, 1, 2, 2], 1.5, 2) check_bisect(bisect.bisect_left, [1, 1, 2, 2], 2, 2) check_bisect(bisect.bisect_left, [1, 1, 2, 2], 3, 4) check_bisect(bisect.bisect_left, [1, 2, 3], 0, 0) check_bisect(bisect.bisect_left, [1, 2, 3], 1, 0) check_bisect(bisect.bisect_left, [1, 2, 3], 1.5, 1) check_bisect(bisect.bisect_left, [1, 2, 3], 2, 1) check_bisect(bisect.bisect_left, [1, 2, 3], 2.5, 2) check_bisect(bisect.bisect_left, [1, 2, 3], 3, 2) check_bisect(bisect.bisect_left, [1, 2, 3], 4, 3) check_bisect(bisect.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 0, 0) check_bisect(bisect.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1, 0) check_bisect(bisect.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1.5, 1) check_bisect(bisect.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2, 1) check_bisect(bisect.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2.5, 3) check_bisect(bisect.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3, 3) check_bisect(bisect.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3.5, 6) check_bisect(bisect.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 4, 6) check_bisect(bisect.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 5, 10) def check_insort(n): global nerrors from random import choice import sys digits = "0123456789" raw = [] insorted = [] for i in range(n): digit = choice(digits) raw.append(digit) if digit in "02468": f = bisect.insort_left else: f = bisect.insort_right f(insorted, digit) sorted = raw[:] sorted.sort() if sorted == insorted: return print >> sys.stderr, "insort test failed: raw %s got %s" % (raw, insorted) nerrors += 1 check_insort(500) if nerrors: raise TestFailed("%d errors in test_bisect" % nerrors) From python-dev@python.org Fri Dec 29 02:06:47 2000 From: python-dev@python.org (Tim Peters) Date: Thu, 28 Dec 2000 18:06:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_bisect,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv26508/python/dist/src/Lib/test/output Added Files: test_bisect Log Message: Fred, THIS NEEDS DOCS! The function docstrings tell the tale. Christmas present to myself: the bisect module didn't define what happened if the new element was already in the list. It so happens that it inserted the new element "to the right" of all equal elements. Since it wasn't defined, among other bad implications it was a mystery how to use bisect to determine whether an element was already in the list (I've seen code that *assumed* "to the right" without justification). Added new methods bisect_left and insort_left that insert "to the left" instead; made the old names bisect and insort aliases for the new names bisect_right and insort_right; beefed up docstrings to explain what these actually do; and added a std test for the bisect module. --- NEW FILE: test_bisect --- test_bisect From python-dev@python.org Fri Dec 29 02:06:47 2000 From: python-dev@python.org (Tim Peters) Date: Thu, 28 Dec 2000 18:06:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib bisect.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv26508/python/dist/src/Lib Modified Files: bisect.py Log Message: Fred, THIS NEEDS DOCS! The function docstrings tell the tale. Christmas present to myself: the bisect module didn't define what happened if the new element was already in the list. It so happens that it inserted the new element "to the right" of all equal elements. Since it wasn't defined, among other bad implications it was a mystery how to use bisect to determine whether an element was already in the list (I've seen code that *assumed* "to the right" without justification). Added new methods bisect_left and insort_left that insert "to the left" instead; made the old names bisect and insort aliases for the new names bisect_right and insort_right; beefed up docstrings to explain what these actually do; and added a std test for the bisect module. Index: bisect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/bisect.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** bisect.py 2000/02/02 15:10:14 1.4 --- bisect.py 2000/12/29 02:06:45 1.5 *************** *** 2,7 **** ! def insort(a, x, lo=0, hi=None): ! """Insert item x in list a, and keep it sorted assuming a is sorted.""" if hi is None: hi = len(a) --- 2,14 ---- ! def insort_right(a, x, lo=0, hi=None): ! """Insert item x in list a, and keep it sorted assuming a is sorted. ! ! If x is already in a, insert it to the right of the rightmost x. ! ! Optional args lo (default 0) and hi (default len(a)) bound the ! slice of a to be searched. ! """ ! if hi is None: hi = len(a) *************** *** 12,18 **** a.insert(lo, x) ! def bisect(a, x, lo=0, hi=None): ! """Find the index where to insert item x in list a, assuming a is sorted.""" if hi is None: hi = len(a) --- 19,35 ---- a.insert(lo, x) + insort = insort_right # backward compatibility + + def bisect_right(a, x, lo=0, hi=None): + """Return the index where to insert item x in list a, assuming a is sorted. ! The return value i is such that all e in a[:i] have e <= x, and all e in ! a[i:] have e > x. So if x already appears in the list, i points just ! beyond the rightmost x already there. ! ! Optional args lo (default 0) and hi (default len(a)) bound the ! slice of a to be searched. ! """ ! if hi is None: hi = len(a) *************** *** 21,23 **** --- 38,79 ---- if x < a[mid]: hi = mid else: lo = mid+1 + return lo + + bisect = bisect_right # backward compatibility + + def insort_left(a, x, lo=0, hi=None): + """Insert item x in list a, and keep it sorted assuming a is sorted. + + If x is already in a, insert it to the left of the leftmost x. + + Optional args lo (default 0) and hi (default len(a)) bound the + slice of a to be searched. + """ + + if hi is None: + hi = len(a) + while lo < hi: + mid = (lo+hi)/2 + if a[mid] < x: lo = mid+1 + else: hi = mid + a.insert(lo, x) + + + def bisect_left(a, x, lo=0, hi=None): + """Return the index where to insert item x in list a, assuming a is sorted. + + The return value i is such that all e in a[:i] have e < x, and all e in + a[i:] have e >= x. So if x already appears in the list, i points just + before the leftmost x already there. + + Optional args lo (default 0) and hi (default len(a)) bound the + slice of a to be searched. + """ + + if hi is None: + hi = len(a) + while lo < hi: + mid = (lo+hi)/2 + if a[mid] < x: lo = mid+1 + else: hi = mid return lo From python-dev@python.org Fri Dec 29 02:06:47 2000 From: python-dev@python.org (Tim Peters) Date: Thu, 28 Dec 2000 18:06:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.86,1.87 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv26508/python/dist/src/Misc Modified Files: NEWS Log Message: Fred, THIS NEEDS DOCS! The function docstrings tell the tale. Christmas present to myself: the bisect module didn't define what happened if the new element was already in the list. It so happens that it inserted the new element "to the right" of all equal elements. Since it wasn't defined, among other bad implications it was a mystery how to use bisect to determine whether an element was already in the list (I've seen code that *assumed* "to the right" without justification). Added new methods bisect_left and insort_left that insert "to the left" instead; made the old names bisect and insort aliases for the new names bisect_right and insort_right; beefed up docstrings to explain what these actually do; and added a std test for the bisect module. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -r1.86 -r1.87 *** NEWS 2000/12/15 01:16:43 1.86 --- NEWS 2000/12/29 02:06:45 1.87 *************** *** 35,38 **** --- 35,50 ---- using popitem() they can usually be made to run in linear time. + + Standard library + + - The bisect module has new functions bisect_left, insort_left, + bisect_right and insort_right. The old names bisect and insort + are now aliases for bisect_right and insort_right. XXX_right + and XXX_left methods differ in what happens when the new element + compares equal to one or more elements already in the list: the + XXX_left methods insert to the left, the XXX_right methods to the + right. + + Windows changes From python-dev@python.org Fri Dec 29 02:17:58 2000 From: python-dev@python.org (Tim Peters) Date: Thu, 28 Dec 2000 18:17:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib getopt.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv28119/python/dist/src/Lib Modified Files: getopt.py Log Message: getopt used to sort the long option names, in an attempt to simplify the logic. That resulted in a bug. My previous getopt checkin repaired the bug but left the sorting. The solution is significantly simpler if we don't bother sorting at all, so this checkin gets rid of the sort and the code that relied on it. Index: getopt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/getopt.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** getopt.py 2000/12/27 08:05:05 1.12 --- getopt.py 2000/12/29 02:17:56 1.13 *************** *** 66,70 **** else: longopts = list(longopts) - longopts.sort() while args and args[0].startswith('-') and args[0] != '-': if args[0] == '--': --- 66,69 ---- *************** *** 100,116 **** # has_arg? # full option name - # Assumes longopts has been sorted (ASCII order). def long_has_args(opt, longopts): ! for i in range(len(longopts)): ! if longopts[i].startswith(opt): ! break ! else: raise GetoptError('option --%s not recognized' % opt, opt) - # opt is a prefix of longopts[i]; find j s.t. opt is a prefix of - # each possibility in longopts[i:j] - j = i+1 - while j < len(longopts) and longopts[j].startswith(opt): - j += 1 - possibilities = longopts[i:j] # Is there an exact match? if opt in possibilities: --- 99,106 ---- # has_arg? # full option name def long_has_args(opt, longopts): ! possibilities = [o for o in longopts if o.startswith(opt)] ! if not possibilities: raise GetoptError('option --%s not recognized' % opt, opt) # Is there an exact match? if opt in possibilities: From python-dev@python.org Sat Dec 30 22:21:25 2000 From: python-dev@python.org (Tim Peters) Date: Sat, 30 Dec 2000 14:21:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test regrtest.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv20342/python/dist/src/lib/test Modified Files: regrtest.py Log Message: Christmas present to myself: changed regrtest in two ways: 1. When running in verbose mode, if any test happens to pass, print a warning that the apparent success may be bogus (stdout isn't compared in verbose mode). Been fooled by that too often. 2. When a test fails because the expected stdout doesn't match the actual stdout, print as much of stdout as did match before the first failing write. Else we get failures of the form "expected 'a', got 'b'" and a glance at the expected output file shows 500 instances of 'a' -- no idea where it failed, and, as in #1, trying to run in verbose mode instead doesn't help because stdout isn't compared then. Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -r1.28 -r1.29 *** regrtest.py 2000/12/12 23:11:42 1.28 --- regrtest.py 2000/12/30 22:21:22 1.29 *************** *** 159,162 **** --- 159,165 ---- print "All", print count(len(good), "test"), "OK." + if verbose: + print "CAUTION: stdout isn't compared in verbose mode: a test" + print "that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:", *************** *** 281,290 **** def __init__(self, filename): self.fp = open(filename, 'r') def write(self, data): expected = self.fp.read(len(data)) ! if data != expected: ! raise test_support.TestFailed, \ ! 'Writing: '+`data`+', expected: '+`expected` def writelines(self, listoflines): --- 284,315 ---- def __init__(self, filename): self.fp = open(filename, 'r') + self.stuffthatmatched = [] def write(self, data): expected = self.fp.read(len(data)) ! if data == expected: ! self.stuffthatmatched.append(expected) ! else: ! # This Compare instance is spoofing stdout, so we need to write ! # to stderr instead. ! from sys import stderr as e ! print >> e, "The actual stdout doesn't match the expected stdout." ! if self.stuffthatmatched: ! print >> e, "This much did match (between asterisk lines):" ! print >> e, "*" * 70 ! good = "".join(self.stuffthatmatched) ! e.write(good) ! if not good.endswith("\n"): ! e.write("\n") ! print >> e, "*" * 70 ! print >> e, "Then ..." ! else: ! print >> e, "The first write to stdout clashed:" ! # Note that the prompts are the same length in next two lines. ! # This is so what we expected and what we got line up. ! print >> e, "We expected (repr):", `expected` ! print >> e, "But instead we got:", `data` ! raise test_support.TestFailed('Writing: ' + `data`+ ! ', expected: ' + `expected`) def writelines(self, listoflines): *************** *** 297,301 **** leftover = self.fp.read() if leftover: ! raise test_support.TestFailed, 'Unread: '+`leftover` self.fp.close() --- 322,327 ---- leftover = self.fp.read() if leftover: ! raise test_support.TestFailed('Tail of expected stdout unseen: ' + ! `leftover`) self.fp.close() From python-dev@python.org Sun Dec 31 03:50:25 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 30 Dec 2000 19:50:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom minidom.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory usw-pr-cvs1:/tmp/cvs-serv29110 Modified Files: minidom.py Log Message: Patch #102485 ] Check for legal children when adding children to a DOM node Index: minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/minidom.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** minidom.py 2000/12/28 18:40:56 1.17 --- minidom.py 2000/12/31 03:50:23 1.18 *************** *** 19,22 **** --- 19,24 ---- del string + from xml.dom import HierarchyRequestErr + # localize the types, and allow support for Unicode values if available: import types *************** *** 38,42 **** _makeParentNodes = 1 debug = None ! def __init__(self): self.childNodes = [] --- 40,45 ---- _makeParentNodes = 1 debug = None ! childNodeTypes = () ! def __init__(self): self.childNodes = [] *************** *** 100,103 **** --- 103,109 ---- def insertBefore(self, newChild, refChild): + if newChild.nodeType not in self.childNodeTypes: + raise HierarchyRequestErr, \ + "%s cannot be child of %s" % (repr(newChild), repr(self) ) if newChild.parentNode is not None: newChild.parentNode.removeChild(newChild) *************** *** 120,123 **** --- 126,132 ---- def appendChild(self, node): + if node.nodeType not in self.childNodeTypes: + raise HierarchyRequestErr, \ + "%s cannot be child of %s" % (repr(node), repr(self) ) if node.parentNode is not None: node.parentNode.removeChild(node) *************** *** 135,138 **** --- 144,150 ---- def replaceChild(self, newChild, oldChild): + if newChild.nodeType not in self.childNodeTypes: + raise HierarchyRequestErr, \ + "%s cannot be child of %s" % (repr(newChild), repr(self) ) if newChild.parentNode is not None: newChild.parentNode.removeChild(newChild) *************** *** 251,255 **** attributes = None ownerElement = None ! def __init__(self, qName, namespaceURI="", localName=None, prefix=None): # skip setattr for performance --- 263,268 ---- attributes = None ownerElement = None ! childNodeTypes = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) ! def __init__(self, qName, namespaceURI="", localName=None, prefix=None): # skip setattr for performance *************** *** 375,379 **** nextSibling = None previousSibling = None ! def __init__(self, tagName, namespaceURI="", prefix="", localName=None): --- 388,395 ---- nextSibling = None previousSibling = None ! childNodeTypes = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, ! Node.COMMENT_NODE, Node.TEXT_NODE, ! Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE) ! def __init__(self, tagName, namespaceURI="", prefix="", localName=None): *************** *** 509,513 **** nodeName = "#comment" attributes = None ! def __init__(self, data): Node.__init__(self) --- 525,530 ---- nodeName = "#comment" attributes = None ! childNodeTypes = () ! def __init__(self, data): Node.__init__(self) *************** *** 520,524 **** nodeType = Node.PROCESSING_INSTRUCTION_NODE attributes = None ! def __init__(self, target, data): Node.__init__(self) --- 537,542 ---- nodeType = Node.PROCESSING_INSTRUCTION_NODE attributes = None ! childNodeTypes = () ! def __init__(self, target, data): Node.__init__(self) *************** *** 533,537 **** nodeName = "#text" attributes = None ! def __init__(self, data): Node.__init__(self) --- 551,556 ---- nodeName = "#text" attributes = None ! childNodeTypes = () ! def __init__(self, data): Node.__init__(self) *************** *** 628,633 **** --- 647,657 ---- implementation = DOMImplementation() + childNodeTypes = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, + Node.COMMENT_NODE, Node.DOCUMENT_TYPE_NODE) def appendChild(self, node): + if node.nodeType not in self.childNodeTypes: + raise HierarchyRequestErr, \ + "%s cannot be child of %s" % (repr(node), repr(self) ) if node.parentNode is not None: node.parentNode.removeChild(node) From python-dev@python.org Sun Dec 31 04:03:29 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 30 Dec 2000 20:03:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_minidom.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv29510 Modified Files: test_minidom.py Log Message: Added test case for legal DOM children Index: test_minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_minidom.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** test_minidom.py 2000/12/15 21:31:59 1.17 --- test_minidom.py 2000/12/31 04:03:27 1.18 *************** *** 77,80 **** --- 77,104 ---- dom.unlink() + def testLegalChildren(): + dom = Document() + elem = dom.createElement('element') + text = dom.createTextNode('text') + + try: dom.appendChild(text) + except HierarchyRequestErr: pass + else: + print "dom.appendChild didn't raise HierarchyRequestErr" + + dom.appendChild(elem) + try: dom.insertBefore(text, elem) + except HierarchyRequestErr: pass + else: + print "dom.appendChild didn't raise HierarchyRequestErr" + + try: dom.replaceChild(text, elem) + except HierarchyRequestErr: pass + else: + print "dom.appendChild didn't raise HierarchyRequestErr" + + elem.appendChild(text) + dom.unlink() + def testNonZero(): dom = parse(tstfile) *************** *** 280,284 **** def testCreateElementNS(): pass ! def testCreatAttributeNS(): pass def testParse(): pass --- 304,308 ---- def testCreateElementNS(): pass ! def testCreateAttributeNS(): pass def testParse(): pass From python-dev@python.org Sun Dec 31 04:03:29 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 30 Dec 2000 20:03:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_minidom,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv29510/output Modified Files: test_minidom Log Message: Added test case for legal DOM children Index: test_minidom =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_minidom,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** test_minidom 2000/12/14 18:20:22 1.11 --- test_minidom 2000/12/31 04:03:27 1.12 *************** *** 77,81 **** Test Succeeded testComment Passed assertion: len(Node.allnodes) == 0 ! Test Succeeded testCreatAttributeNS Passed assertion: len(Node.allnodes) == 0 Test Succeeded testCreateElementNS --- 77,81 ---- Test Succeeded testComment Passed assertion: len(Node.allnodes) == 0 ! Test Succeeded testCreateAttributeNS Passed assertion: len(Node.allnodes) == 0 Test Succeeded testCreateElementNS *************** *** 121,124 **** --- 121,126 ---- Passed testInsertBefore -- node properly placed in tree Test Succeeded testInsertBefore + Passed assertion: len(Node.allnodes) == 0 + Test Succeeded testLegalChildren Passed assertion: len(Node.allnodes) == 0 Passed Test From python-dev@python.org Sun Dec 31 22:53:01 2000 From: python-dev@python.org (Thomas Wouters) Date: Sun, 31 Dec 2000 14:53:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref7.tex,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv27527 Modified Files: ref7.tex Log Message: Change documentation of 'else' clause of 'try/except' to make clear that it doesn't get triggered by 'return', 'break' or 'continue'. If the 'try-inside-continue' patch does not get accepted before next release, the 'or continue' should be removed ;P Closes SF patch #103045 and SF bug #127098. Index: ref7.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref7.tex,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** ref7.tex 2000/07/16 19:05:38 1.20 --- ref7.tex 2000/12/31 22:52:59 1.21 *************** *** 243,249 **** \ttindex{exc_value}\ttindex{exc_traceback}} ! The optional \keyword{else} clause is executed when no exception occurs ! in the \keyword{try} clause. Exceptions in the \keyword{else} clause are ! not handled by the preceding \keyword{except} clauses. \kwindex{else} --- 243,251 ---- \ttindex{exc_value}\ttindex{exc_traceback}} ! The optional \keyword{else} clause is executed when the \keyword{try} clause ! terminates by any means other than an exception or executing a ! \keyword{return}, \keyword{continue} or \keyword{break} statement. ! Exceptions in the \keyword{else} clause are not handled by the preceding ! \keyword{except} clauses. \kwindex{else}