From bwarsaw@users.sourceforge.net Fri Mar 1 00:42:51 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Thu, 28 Feb 2002 16:42:51 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0001.txt,1.28,1.29 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv737 Modified Files: pep-0001.txt Log Message: Last-Modified: is now a required header. Index: pep-0001.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0001.txt,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** pep-0001.txt 12 Nov 2001 14:57:18 -0000 1.28 --- pep-0001.txt 1 Mar 2002 00:42:48 -0000 1.29 *************** *** 186,190 **** Title: Version: ! * Last-Modified: Author: * Discussions-To: --- 186,190 ---- Title: Version: ! Last-Modified: Author: * Discussions-To: From mal@lemburg.com Fri Mar 1 08:28:31 2002 From: mal@lemburg.com (M.-A. Lemburg) Date: Fri, 01 Mar 2002 09:28:31 +0100 Subject: [Python-checkins] CVS: python/nondist/peps pep-0001.txt,1.28,1.29 References: Message-ID: <3C7F3BAF.56514E85@lemburg.com> Barry Warsaw wrote: > > Update of /cvsroot/python/python/nondist/peps > In directory usw-pr-cvs1:/tmp/cvs-serv737 > > Modified Files: > pep-0001.txt > Log Message: > Last-Modified: is now a required header. Isn't this unnecessary duplication ? The CVS history has all this information available, including patches, comments, etc. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/ From loewis@users.sourceforge.net Fri Mar 1 08:31:09 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 01 Mar 2002 00:31:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/PC pyconfig.h,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory usw-pr-cvs1:/tmp/cvs-serv30289/PC Modified Files: pyconfig.h Log Message: Patch #520062: Support IPv6 with VC.NET. Index: pyconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/pyconfig.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pyconfig.h 21 Dec 2001 22:06:12 -0000 1.6 --- pyconfig.h 1 Mar 2002 08:31:07 -0000 1.7 *************** *** 409,413 **** --- 409,417 ---- /* Define to `int' if doesn't define. */ + #if _MSC_VER + 0 >= 1300 + /* VC.NET typedefs socklen_t in ws2tcpip.h. */ + #else #define socklen_t int + #endif /* Define if you have the ANSI C header files. */ From loewis@users.sourceforge.net Fri Mar 1 08:31:09 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 01 Mar 2002 00:31:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules socketmodule.c,1.208,1.209 socketmodule.h,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv30289/Modules Modified Files: socketmodule.c socketmodule.h Log Message: Patch #520062: Support IPv6 with VC.NET. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.208 retrieving revision 1.209 diff -C2 -d -r1.208 -r1.209 *** socketmodule.c 17 Feb 2002 04:13:21 -0000 1.208 --- socketmodule.c 1 Mar 2002 08:31:07 -0000 1.209 *************** *** 410,415 **** --- 410,418 ---- PyObject *v; + #ifdef EAI_SYSTEM + /* EAI_SYSTEM is not available on Windows XP. */ if (error == EAI_SYSTEM) return PySocket_Err(); + #endif #ifdef HAVE_GAI_STRERROR Index: socketmodule.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** socketmodule.h 25 Feb 2002 14:45:40 -0000 1.4 --- socketmodule.h 1 Mar 2002 08:31:07 -0000 1.5 *************** *** 10,14 **** --- 10,24 ---- #else /* MS_WINDOWS */ + #if _MSC_VER >= 1300 + # include + # include + # define HAVE_ADDRINFO + # define HAVE_SOCKADDR_STORAGE + # define HAVE_GETADDRINFO + # define HAVE_GETNAMEINFO + # define ENABLE_IPV6 + #else # include + #endif #endif From mwh@users.sourceforge.net Fri Mar 1 08:58:34 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Fri, 01 Mar 2002 00:58:34 -0800 Subject: [Python-checkins] CVS: python/dist/src setup.py,1.73,1.73.4.1 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv3842 Modified Files: Tag: release22-maint setup.py Log Message: Whitespace normalization. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.73 retrieving revision 1.73.4.1 diff -C2 -d -r1.73 -r1.73.4.1 *** setup.py 17 Dec 2001 17:24:43 -0000 1.73 --- setup.py 1 Mar 2002 08:58:32 -0000 1.73.4.1 *************** *** 65,69 **** self.announce("WARNING: multiple copies of %s found"%module) return os.path.join(list[0], module) ! class PyBuildExt(build_ext): --- 65,69 ---- self.announce("WARNING: multiple copies of %s found"%module) return os.path.join(list[0], module) ! class PyBuildExt(build_ext): *************** *** 87,94 **** srcdir = os.path.normpath(srcdir) moddir = os.path.normpath(moddir) ! moddirlist = [moddir] incdirlist = ['./Include'] ! # Platform-dependent module source and include directories platform = self.get_platform() --- 87,94 ---- srcdir = os.path.normpath(srcdir) moddir = os.path.normpath(moddir) ! moddirlist = [moddir] incdirlist = ['./Include'] ! # Platform-dependent module source and include directories platform = self.get_platform() *************** *** 116,120 **** # Parse Modules/Setup to figure out which modules are turned ! # on in the file. input = text_file.TextFile('Modules/Setup', join_lines=1) remove_modules = [] --- 116,120 ---- # Parse Modules/Setup to figure out which modules are turned ! # on in the file. input = text_file.TextFile('Modules/Setup', join_lines=1) remove_modules = [] *************** *** 125,133 **** remove_modules.append( line[0] ) input.close() ! for ext in self.extensions[:]: if ext.name in remove_modules: self.extensions.remove(ext) ! # When you run "make CC=altcc" or something similar, you really want # those environment variables passed into the setup.py phase. Here's --- 125,133 ---- remove_modules.append( line[0] ) input.close() ! for ext in self.extensions[:]: if ext.name in remove_modules: self.extensions.remove(ext) ! # When you run "make CC=altcc" or something similar, you really want # those environment variables passed into the setup.py phase. Here's *************** *** 158,165 **** # reliably imported into a command-line Python if 'Carbon' in ext.extra_link_args: ! self.announce( ! 'WARNING: skipping import check for Carbon-based "%s"' % ! ext.name) ! return try: __import__(ext.name) --- 158,165 ---- # reliably imported into a command-line Python if 'Carbon' in ext.extra_link_args: ! self.announce( ! 'WARNING: skipping import check for Carbon-based "%s"' % ! ext.name) ! return try: __import__(ext.name) *************** *** 208,221 **** # be assumed that no additional -I,-L directives are needed. lib_dirs = self.compiler.library_dirs + ['/lib', '/usr/lib'] ! inc_dirs = self.compiler.include_dirs + ['/usr/include'] exts = [] platform = self.get_platform() ! # Check for MacOS X, which doesn't need libm.a at all math_libs = ['m'] if platform in ['darwin', 'beos']: math_libs = [] ! # XXX Omitted modules: gl, pure, dl, SGI-specific modules --- 208,221 ---- # be assumed that no additional -I,-L directives are needed. lib_dirs = self.compiler.library_dirs + ['/lib', '/usr/lib'] ! inc_dirs = self.compiler.include_dirs + ['/usr/include'] exts = [] platform = self.get_platform() ! # Check for MacOS X, which doesn't need libm.a at all math_libs = ['m'] if platform in ['darwin', 'beos']: math_libs = [] ! # XXX Omitted modules: gl, pure, dl, SGI-specific modules *************** *** 414,418 **** elif self.compiler.find_library_file(lib_dirs, 'db'): dblib = ['db'] ! db185_incs = find_file('db_185.h', inc_dirs, ['/usr/include/db3', '/usr/include/db2']) --- 414,418 ---- elif self.compiler.find_library_file(lib_dirs, 'db'): dblib = ['db'] ! db185_incs = find_file('db_185.h', inc_dirs, ['/usr/include/db3', '/usr/include/db2']) *************** *** 475,480 **** elif (self.compiler.find_library_file(lib_dirs, 'curses') and platform != 'darwin'): ! # OSX has an old Berkeley curses, not good enough for ! # the _curses module. if (self.compiler.find_library_file(lib_dirs, 'terminfo')): curses_libs = ['curses', 'terminfo'] --- 475,480 ---- elif (self.compiler.find_library_file(lib_dirs, 'curses') and platform != 'darwin'): ! # OSX has an old Berkeley curses, not good enough for ! # the _curses module. if (self.compiler.find_library_file(lib_dirs, 'terminfo')): curses_libs = ['curses', 'terminfo'] *************** *** 576,580 **** # SunOS specific modules exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) ) ! if platform == 'darwin': # Mac OS X specific modules. These are ported over from MacPython --- 576,580 ---- # SunOS specific modules exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) ) ! if platform == 'darwin': # Mac OS X specific modules. These are ported over from MacPython *************** *** 589,639 **** exts.append( Extension('gestalt', ['gestaltmodule.c']) ) exts.append( Extension('MacOS', ['macosmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('icglue', ['icgluemodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('macfs', ['macfsmodule.c', '../Python/getapplbycreator.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_CF', ['cf/_CFmodule.c']) ) exts.append( Extension('_Res', ['res/_Resmodule.c']) ) exts.append( Extension('_Snd', ['snd/_Sndmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) if frameworkdir: exts.append( Extension('Nav', ['Nav.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_AE', ['ae/_AEmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_App', ['app/_Appmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_CarbonEvt', ['carbonevt/_CarbonEvtmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_CG', ['cg/_CGmodule.c'], ! extra_link_args=['-framework', 'ApplicationServices', '-framework', 'Carbon']) ) exts.append( Extension('_Cm', ['cm/_Cmmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Ctl', ['ctl/_Ctlmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Dlg', ['dlg/_Dlgmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Drag', ['drag/_Dragmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Evt', ['evt/_Evtmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Fm', ['fm/_Fmmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Icn', ['icn/_Icnmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_List', ['list/_Listmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Menu', ['menu/_Menumodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Mlte', ['mlte/_Mltemodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Qd', ['qd/_Qdmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Qdoffs', ['qdoffs/_Qdoffsmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Qt', ['qt/_Qtmodule.c'], extra_link_args=['-framework', 'QuickTime', --- 589,639 ---- exts.append( Extension('gestalt', ['gestaltmodule.c']) ) exts.append( Extension('MacOS', ['macosmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('icglue', ['icgluemodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('macfs', ['macfsmodule.c', '../Python/getapplbycreator.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_CF', ['cf/_CFmodule.c']) ) exts.append( Extension('_Res', ['res/_Resmodule.c']) ) exts.append( Extension('_Snd', ['snd/_Sndmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) if frameworkdir: exts.append( Extension('Nav', ['Nav.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_AE', ['ae/_AEmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_App', ['app/_Appmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_CarbonEvt', ['carbonevt/_CarbonEvtmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_CG', ['cg/_CGmodule.c'], ! extra_link_args=['-framework', 'ApplicationServices', '-framework', 'Carbon']) ) exts.append( Extension('_Cm', ['cm/_Cmmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Ctl', ['ctl/_Ctlmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Dlg', ['dlg/_Dlgmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Drag', ['drag/_Dragmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Evt', ['evt/_Evtmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Fm', ['fm/_Fmmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Icn', ['icn/_Icnmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_List', ['list/_Listmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Menu', ['menu/_Menumodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Mlte', ['mlte/_Mltemodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Qd', ['qd/_Qdmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Qdoffs', ['qdoffs/_Qdoffsmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Qt', ['qt/_Qtmodule.c'], extra_link_args=['-framework', 'QuickTime', *************** *** 641,645 **** ## exts.append( Extension('_Scrap', ['scrap/_Scrapmodule.c']) ) exts.append( Extension('_TE', ['te/_TEmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) # As there is no standardized place (yet) to put user-installed # Mac libraries on OSX you should put a symlink to your Waste --- 641,645 ---- ## exts.append( Extension('_Scrap', ['scrap/_Scrapmodule.c']) ) exts.append( Extension('_TE', ['te/_TEmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) # As there is no standardized place (yet) to put user-installed # Mac libraries on OSX you should put a symlink to your Waste *************** *** 650,654 **** ["../waste/Static Libraries"]) if waste_incs != None and waste_libs != None: ! exts.append( Extension('waste', ['waste/wastemodule.c', 'Mac/Wastemods/WEObjectHandlers.c', --- 650,654 ---- ["../waste/Static Libraries"]) if waste_incs != None and waste_libs != None: ! exts.append( Extension('waste', ['waste/wastemodule.c', 'Mac/Wastemods/WEObjectHandlers.c', *************** *** 662,667 **** ) ) exts.append( Extension('_Win', ['win/_Winmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) ! self.extensions.extend(exts) --- 662,667 ---- ) ) exts.append( Extension('_Win', ['win/_Winmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) ! self.extensions.extend(exts) *************** *** 672,676 **** def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. ! # Assume we haven't found any of the libraries or include files # The versions with dots are used on Unix, and the versions without --- 672,676 ---- def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. ! # Assume we haven't found any of the libraries or include files # The versions with dots are used on Unix, and the versions without *************** *** 679,687 **** for version in ['8.4', '84', '8.3', '83', '8.2', '82', '8.1', '81', '8.0', '80']: ! tklib = self.compiler.find_library_file(lib_dirs, ! 'tk' + version ) ! tcllib = self.compiler.find_library_file(lib_dirs, ! 'tcl' + version ) ! if tklib and tcllib: # Exit the loop when we've found the Tcl/Tk libraries break --- 679,687 ---- for version in ['8.4', '84', '8.3', '83', '8.2', '82', '8.1', '81', '8.0', '80']: ! tklib = self.compiler.find_library_file(lib_dirs, ! 'tk' + version ) ! tcllib = self.compiler.find_library_file(lib_dirs, ! 'tcl' + version ) ! if tklib and tcllib: # Exit the loop when we've found the Tcl/Tk libraries break *************** *** 772,776 **** install.initialize_options(self) self.warn_dir=0 ! def main(): # turn off warnings when deprecated modules are imported --- 772,776 ---- install.initialize_options(self) self.warn_dir=0 ! def main(): # turn off warnings when deprecated modules are imported From loewis@users.sourceforge.net Fri Mar 1 10:27:03 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 01 Mar 2002 02:27:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_array.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv25235/Lib/test Modified Files: test_array.py Log Message: Patch 520694: arraymodule.c improvements: - make array.array a type - add Py_UNICODE arrays - support +=, *= Index: test_array.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_array.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** test_array.py 17 Jan 2001 21:51:36 -0000 1.13 --- test_array.py 1 Mar 2002 10:27:01 -0000 1.14 *************** *** 7,18 **** def main(): - testtype('c', 'c') ! for type in (['b', 'h', 'i', 'l', 'f', 'd']): testtype(type, 1) ! unlink(TESTFN) def testoverflow(type, lowerLimit, upperLimit): --- 7,91 ---- def main(): testtype('c', 'c') ! testtype('u', u'\u263a') for type in (['b', 'h', 'i', 'l', 'f', 'd']): testtype(type, 1) ! testunicode() ! testsubclassing() unlink(TESTFN) + def testunicode(): + try: + array.array('b', u'foo') + except TypeError: + pass + else: + raise TestFailed("creating a non-unicode array from " + "a Unicode string should fail") + + x = array.array('u', u'\xa0\xc2\u1234') + x.fromunicode(u' ') + x.fromunicode(u'') + x.fromunicode(u'') + x.fromunicode(u'\x11abc\xff\u1234') + s = x.tounicode() + if s != u'\xa0\xc2\u1234 \x11abc\xff\u1234': + raise TestFailed("fromunicode()/tounicode()") + + s = u'\x00="\'a\\b\x80\xff\u0000\u0001\u1234' + a = array.array('u', s) + if verbose: + print "repr of type 'u' array:", repr(a) + print " expected: array('u', %r)" % s + + def testsubclassing(): + class EditableString(array.array): + def __new__(cls, s, *args, **kwargs): + return array.array.__new__(cls, 'c', s) + + def __init__(self, s, color='blue'): + array.array.__init__(self, 'c', s) + self.color = color + + def strip(self): + self[:] = array.array('c', self.tostring().strip()) + + def __repr__(self): + return 'EditableString(%r)' % self.tostring() + + s = EditableString("\ttest\r\n") + s.strip() + if s.tostring() != 'test': + raise TestFailed, "subclassing array.array failed somewhere" + if s.color != 'blue': + raise TestFailed, "assigning attributes to instance of array subclass" + s.color = 'red' + if s.color != 'red': + raise TestFailed, "assigning attributes to instance of array subclass" + if s.__dict__.keys() != ['color']: + raise TestFailed, "array subclass __dict__" + + class ExaggeratingArray(array.array): + __slots__ = ['offset'] + + def __new__(cls, typecode, data, offset): + return array.array.__new__(cls, typecode, data) + + def __init__(self, typecode, data, offset): + self.offset = offset + + def __getitem__(self, i): + return array.array.__getitem__(self, i) + self.offset + + a = ExaggeratingArray('i', [3, 6, 7, 11], 4) + if a[0] != 7: + raise TestFailed, "array subclass overriding __getitem__" + try: + a.color = 'blue' + except AttributeError: + pass + else: + raise TestFailed, "array subclass __slots__ was ignored" + def testoverflow(type, lowerLimit, upperLimit): *************** *** 55,59 **** def testtype(type, example): - a = array.array(type) a.append(example) --- 128,131 ---- *************** *** 98,101 **** --- 170,200 ---- % a.typecode, `a.tostring()` + # Try out inplace addition and multiplication + a = array.array(type, [example]) + b = a + a += array.array(type, [example]*2) + if a is not b: + raise TestFailed, "array(%s) inplace addition" % `type` + if a != array.array(type, [example] * 3): + raise TestFailed, "array(%s) inplace addition" % `type` + + a *= 5 + if a is not b: + raise TestFailed, "array(%s) inplace multiplication" % `type` + if a != array.array(type, [example] * 15): + raise TestFailed, "array(%s) inplace multiplication" % `type` + + a *= 0 + if a is not b: + raise TestFailed, "array(%s) inplace multiplication by 0" % `type` + if a != array.array(type, []): + raise TestFailed, "array(%s) inplace multiplication by 0" % `type` + + a *= 1000 + if a is not b: + raise TestFailed, "empty array(%s) inplace multiplication" % `type` + if a != array.array(type, []): + raise TestFailed, "empty array(%s) inplace multiplication" % `type` + if type == 'c': a = array.array(type, "abcde") *************** *** 135,138 **** --- 234,275 ---- a.reverse() if a != array.array(type, "dca"): + raise TestFailed, "array(%s) reverse-test" % `type` + elif type == 'u': + a = array.array(type, u"abcde") + a[:-1] = a + if a != array.array(type, u"abcdee"): + raise TestFailed, "array(%s) self-slice-assign (head)" % `type` + a = array.array(type, u"abcde") + a[1:] = a + if a != array.array(type, u"aabcde"): + raise TestFailed, "array(%s) self-slice-assign (tail)" % `type` + a = array.array(type, u"abcde") + a[1:-1] = a + if a != array.array(type, u"aabcdee"): + raise TestFailed, "array(%s) self-slice-assign (cntr)" % `type` + if a.index(u"e") != 5: + raise TestFailed, "array(%s) index-test" % `type` + if a.count(u"a") != 2: + raise TestFailed, "array(%s) count-test" % `type` + a.remove(u"e") + if a != array.array(type, u"aabcde"): + raise TestFailed, "array(%s) remove-test" % `type` + if a.pop(0) != u"a": + raise TestFailed, "array(%s) pop-test" % `type` + if a.pop(1) != u"b": + raise TestFailed, "array(%s) pop-test" % `type` + a.extend(array.array(type, u"xyz")) + if a != array.array(type, u"acdexyz"): + raise TestFailed, "array(%s) extend-test" % `type` + a.pop() + a.pop() + a.pop() + x = a.pop() + if x != u'e': + raise TestFailed, "array(%s) pop-test" % `type` + if a != array.array(type, u"acd"): + raise TestFailed, "array(%s) pop-test" % `type` + a.reverse() + if a != array.array(type, u"dca"): raise TestFailed, "array(%s) reverse-test" % `type` else: From loewis@users.sourceforge.net Fri Mar 1 10:27:03 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 01 Mar 2002 02:27:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules arraymodule.c,2.66,2.67 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv25235/Modules Modified Files: arraymodule.c Log Message: Patch 520694: arraymodule.c improvements: - make array.array a type - add Py_UNICODE arrays - support +=, *= Index: arraymodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v retrieving revision 2.66 retrieving revision 2.67 diff -C2 -d -r2.66 -r2.67 *** arraymodule.c 8 Dec 2001 18:02:55 -0000 2.66 --- arraymodule.c 1 Mar 2002 10:27:01 -0000 2.67 *************** *** 28,32 **** typedef struct arrayobject { ! PyObject_VAR_HEAD char *ob_item; struct arraydescr *ob_descr; --- 28,33 ---- typedef struct arrayobject { ! PyObject_HEAD ! int ob_size; char *ob_item; struct arraydescr *ob_descr; *************** *** 35,39 **** staticforward PyTypeObject Arraytype; ! #define is_arrayobject(op) ((op)->ob_type == &Arraytype) /**************************************************************************** --- 36,41 ---- staticforward PyTypeObject Arraytype; ! #define array_Check(op) PyObject_TypeCheck(op, &Arraytype) ! #define array_CheckExact(op) ((op)->ob_type == &Arraytype) /**************************************************************************** *************** *** 62,66 **** return -1; if (i >= 0) ! ((char *)ap->ob_item)[i] = x; return 0; } --- 64,68 ---- return -1; if (i >= 0) ! ((char *)ap->ob_item)[i] = x; return 0; } *************** *** 114,121 **** return -1; if (i >= 0) ! ((char *)ap->ob_item)[i] = x; return 0; } static PyObject * h_getitem(arrayobject *ap, int i) --- 116,148 ---- return -1; if (i >= 0) ! ((char *)ap->ob_item)[i] = x; return 0; } + #ifdef Py_USING_UNICODE + static PyObject * + u_getitem(arrayobject *ap, int i) + { + return PyUnicode_FromUnicode(&((Py_UNICODE *) ap->ob_item)[i], 1); + } + + static int + u_setitem(arrayobject *ap, int i, PyObject *v) + { + Py_UNICODE *p; + int len; + + if (!PyArg_Parse(v, "u#;array item must be unicode character", &p, &len)) + return -1; + if (len != 1) { + PyErr_SetString(PyExc_TypeError, "array item must be unicode character"); + return -1; + } + if (i >= 0) + ((Py_UNICODE *)ap->ob_item)[i] = p[0]; + return 0; + } + #endif + static PyObject * h_getitem(arrayobject *ap, int i) *************** *** 316,319 **** --- 343,349 ---- {'b', sizeof(char), b_getitem, b_setitem}, {'B', sizeof(char), BB_getitem, BB_setitem}, + #ifdef Py_USING_UNICODE + {'u', sizeof(Py_UNICODE), u_getitem, u_setitem}, + #endif {'h', sizeof(short), h_getitem, h_setitem}, {'H', sizeof(short), HH_getitem, HH_setitem}, *************** *** 332,343 **** static PyObject * ! newarrayobject(int size, struct arraydescr *descr) { arrayobject *op; size_t nbytes; if (size < 0) { PyErr_BadInternalCall(); return NULL; } nbytes = size * descr->itemsize; /* Check for overflow */ --- 362,375 ---- static PyObject * ! newarrayobject(PyTypeObject *type, int size, struct arraydescr *descr) { arrayobject *op; size_t nbytes; + if (size < 0) { PyErr_BadInternalCall(); return NULL; } + nbytes = size * descr->itemsize; /* Check for overflow */ *************** *** 345,352 **** return PyErr_NoMemory(); } ! op = PyObject_NewVar(arrayobject, &Arraytype, size); if (op == NULL) { ! return PyErr_NoMemory(); } if (size <= 0) { op->ob_item = NULL; --- 377,385 ---- return PyErr_NoMemory(); } ! op = (arrayobject *) type->tp_alloc(type, 0); if (op == NULL) { ! return NULL; } + op->ob_size = size; if (size <= 0) { op->ob_item = NULL; *************** *** 367,371 **** { register arrayobject *ap; ! assert(is_arrayobject(op)); ap = (arrayobject *)op; if (i < 0 || i >= ap->ob_size) { --- 400,404 ---- { register arrayobject *ap; ! assert(array_Check(op)); ap = (arrayobject *)op; if (i < 0 || i >= ap->ob_size) { *************** *** 412,416 **** if (op->ob_item != NULL) PyMem_DEL(op->ob_item); ! PyObject_Del(op); } --- 445,449 ---- if (op->ob_item != NULL) PyMem_DEL(op->ob_item); ! op->ob_type->tp_free((PyObject *)op); } *************** *** 424,428 **** PyObject *res; ! if (!is_arrayobject(v) || !is_arrayobject(w)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; --- 457,461 ---- PyObject *res; ! if (!array_Check(v) || !array_Check(w)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; *************** *** 531,535 **** else if (ihigh > a->ob_size) ihigh = a->ob_size; ! np = (arrayobject *) newarrayobject(ihigh - ilow, a->ob_descr); if (np == NULL) return NULL; --- 564,568 ---- else if (ihigh > a->ob_size) ihigh = a->ob_size; ! np = (arrayobject *) newarrayobject(&Arraytype, ihigh - ilow, a->ob_descr); if (np == NULL) return NULL; *************** *** 544,548 **** int size; arrayobject *np; ! if (!is_arrayobject(bb)) { PyErr_Format(PyExc_TypeError, "can only append array (not \"%.200s\") to array", --- 577,581 ---- int size; arrayobject *np; ! if (!array_Check(bb)) { PyErr_Format(PyExc_TypeError, "can only append array (not \"%.200s\") to array", *************** *** 556,560 **** } size = a->ob_size + b->ob_size; ! np = (arrayobject *) newarrayobject(size, a->ob_descr); if (np == NULL) { return NULL; --- 589,593 ---- } size = a->ob_size + b->ob_size; ! np = (arrayobject *) newarrayobject(&Arraytype, size, a->ob_descr); if (np == NULL) { return NULL; *************** *** 578,582 **** n = 0; size = a->ob_size * n; ! np = (arrayobject *) newarrayobject(size, a->ob_descr); if (np == NULL) return NULL; --- 611,615 ---- n = 0; size = a->ob_size * n; ! np = (arrayobject *) newarrayobject(&Arraytype, size, a->ob_descr); if (np == NULL) return NULL; *************** *** 599,603 **** if (v == NULL) n = 0; ! else if (is_arrayobject(v)) { n = b->ob_size; if (a == b) { --- 632,636 ---- if (v == NULL) n = 0; ! else if (array_Check(v)) { n = b->ob_size; if (a == b) { *************** *** 677,684 **** setarrayitem(PyObject *a, int i, PyObject *v) { ! assert(is_arrayobject(a)); return array_ass_item((arrayobject *)a, i, v); } static PyObject * ins(arrayobject *self, int where, PyObject *v) --- 710,792 ---- setarrayitem(PyObject *a, int i, PyObject *v) { ! assert(array_Check(a)); return array_ass_item((arrayobject *)a, i, v); } + static int + array_do_extend(arrayobject *self, PyObject *bb) + { + int size; + + if (!array_Check(bb)) { + PyErr_Format(PyExc_TypeError, + "can only extend array with array (not \"%.200s\")", + bb->ob_type->tp_name); + return -1; + } + #define b ((arrayobject *)bb) + if (self->ob_descr != b->ob_descr) { + PyErr_SetString(PyExc_TypeError, + "can only extend with array of same kind"); + return -1; + } + size = self->ob_size + b->ob_size; + PyMem_RESIZE(self->ob_item, char, size*self->ob_descr->itemsize); + if (self->ob_item == NULL) { + PyObject_Del(self); + PyErr_NoMemory(); + return -1; + } + memcpy(self->ob_item + self->ob_size*self->ob_descr->itemsize, + b->ob_item, b->ob_size*b->ob_descr->itemsize); + self->ob_size = size; + + return 0; + #undef b + } + + static PyObject * + array_inplace_concat(arrayobject *self, PyObject *bb) + { + if (array_do_extend(self, bb) == -1) + return NULL; + Py_INCREF(self); + return (PyObject *)self; + } + + static PyObject * + array_inplace_repeat(arrayobject *self, int n) + { + char *items, *p; + int size, i; + + if (self->ob_size > 0) { + if (n < 0) + n = 0; + items = self->ob_item; + size = self->ob_size * self->ob_descr->itemsize; + if (n == 0) { + PyMem_FREE(items); + self->ob_item = NULL; + self->ob_size = 0; + } + else { + PyMem_Resize(items, char, n * size); + if (items == NULL) + return PyErr_NoMemory(); + p = items; + for (i = 1; i < n; i++) { + p += size; + memcpy(p, items, size); + } + self->ob_item = items; + self->ob_size *= n; + } + } + Py_INCREF(self); + return (PyObject *)self; + } + + static PyObject * ins(arrayobject *self, int where, PyObject *v) *************** *** 808,841 **** array_extend(arrayobject *self, PyObject *args) { - int size; PyObject *bb; if (!PyArg_ParseTuple(args, "O:extend", &bb)) - return NULL; - - if (!is_arrayobject(bb)) { - PyErr_Format(PyExc_TypeError, - "can only extend array with array (not \"%.200s\")", - bb->ob_type->tp_name); return NULL; ! } ! #define b ((arrayobject *)bb) ! if (self->ob_descr != b->ob_descr) { ! PyErr_SetString(PyExc_TypeError, ! "can only extend with array of same kind"); return NULL; ! } ! size = self->ob_size + b->ob_size; ! PyMem_RESIZE(self->ob_item, char, size*self->ob_descr->itemsize); ! if (self->ob_item == NULL) { ! PyObject_Del(self); ! return PyErr_NoMemory(); ! } ! memcpy(self->ob_item + self->ob_size*self->ob_descr->itemsize, ! b->ob_item, b->ob_size*b->ob_descr->itemsize); ! self->ob_size = size; ! Py_INCREF(Py_None); return Py_None; - #undef b } --- 916,927 ---- array_extend(arrayobject *self, PyObject *args) { PyObject *bb; if (!PyArg_ParseTuple(args, "O:extend", &bb)) return NULL; ! if (array_do_extend(self, bb) == -1) return NULL; ! Py_INCREF(Py_None); return Py_None; } *************** *** 1204,1207 **** --- 1290,1381 ---- representation."; + + + #ifdef Py_USING_UNICODE + static PyObject * + array_fromunicode(arrayobject *self, PyObject *args) + { + Py_UNICODE *ustr; + int n; + + if (!PyArg_ParseTuple(args, "u#:fromunicode", &ustr, &n)) + return NULL; + if (self->ob_descr->typecode != 'u') { + PyErr_SetString(PyExc_ValueError, + "fromunicode() may only be called on " + "type 'u' arrays"); + return NULL; + } + if (n > 0) { + Py_UNICODE *item = (Py_UNICODE *) self->ob_item; + PyMem_RESIZE(item, Py_UNICODE, self->ob_size + n); + if (item == NULL) { + PyErr_NoMemory(); + return NULL; + } + self->ob_item = (char *) item; + self->ob_size += n; + memcpy(item + self->ob_size - n, + ustr, n * sizeof(Py_UNICODE)); + } + + Py_INCREF(Py_None); + return Py_None; + } + + static char fromunicode_doc[] = + "fromunicode(ustr)\n\ + \n\ + Extends this array with data from the unicode string ustr.\n\ + The array must be a type 'u' array; otherwise a ValueError\n\ + is raised. Use array.fromstring(ustr.decode(...)) to\n\ + append Unicode data to an array of some other type."; + + + static PyObject * + array_tounicode(arrayobject *self, PyObject *args) + { + if (!PyArg_ParseTuple(args, ":tounicode")) + return NULL; + if (self->ob_descr->typecode != 'u') { + PyErr_SetString(PyExc_ValueError, + "tounicode() may only be called on type 'u' arrays"); + return NULL; + } + return PyUnicode_FromUnicode((Py_UNICODE *) self->ob_item, self->ob_size); + } + + static char tounicode_doc [] = + "tounicode() -> unicode\n\ + \n\ + Convert the array to a unicode string. The array must be\n\ + a type 'u' array; otherwise a ValueError is raised. Use\n\ + array.tostring().decode() to obtain a unicode string from\n\ + an array of some other type."; + + #endif /* Py_USING_UNICODE */ + + + static PyObject * + array_get_typecode(arrayobject *a, void *closure) + { + char tc = a->ob_descr->typecode; + return PyString_FromStringAndSize(&tc, 1); + } + + static PyObject * + array_get_itemsize(arrayobject *a, void *closure) + { + return PyInt_FromLong((long)a->ob_descr->itemsize); + } + + static PyGetSetDef array_getsets [] = { + {"typecode", (getter) array_get_typecode, NULL, + "the typecode character used to create the array"}, + {"itemsize", (getter) array_get_itemsize, NULL, + "the size, in bytes, of one array item"}, + {NULL} + }; + PyMethodDef array_methods[] = { {"append", (PyCFunction)array_append, METH_VARARGS, *************** *** 1221,1224 **** --- 1395,1402 ---- {"fromstring", (PyCFunction)array_fromstring, METH_VARARGS, fromstring_doc}, + #ifdef Py_USING_UNICODE + {"fromunicode", (PyCFunction)array_fromunicode, METH_VARARGS, + fromunicode_doc}, + #endif {"index", (PyCFunction)array_index, METH_VARARGS, index_doc}, *************** *** 1241,1244 **** --- 1419,1426 ---- {"tostring", (PyCFunction)array_tostring, METH_VARARGS, tostring_doc}, + #ifdef Py_USING_UNICODE + {"tounicode", (PyCFunction)array_tounicode, METH_VARARGS, + tounicode_doc}, + #endif {"write", (PyCFunction)array_tofile, METH_VARARGS, tofile_doc}, *************** *** 1246,1276 **** }; - static PyObject * - array_getattr(arrayobject *a, char *name) - { - if (strcmp(name, "typecode") == 0) { - char tc = a->ob_descr->typecode; - return PyString_FromStringAndSize(&tc, 1); - } - if (strcmp(name, "itemsize") == 0) { - return PyInt_FromLong((long)a->ob_descr->itemsize); - } - if (strcmp(name, "__members__") == 0) { - PyObject *list = PyList_New(2); - if (list) { - PyList_SetItem(list, 0, - PyString_FromString("typecode")); - PyList_SetItem(list, 1, - PyString_FromString("itemsize")); - if (PyErr_Occurred()) { - Py_DECREF(list); - list = NULL; - } - } - return list; - } - return Py_FindMethod(array_methods, (PyObject *)a, name); - } - static int array_print(arrayobject *a, FILE *fp, int flags) --- 1428,1431 ---- *************** *** 1309,1326 **** array_repr(arrayobject *a) { ! char buf[256]; PyObject *s, *t, *comma, *v; int i, len; len = a->ob_size; if (len == 0) { ! PyOS_snprintf(buf, sizeof(buf), "array('%c')", ! a->ob_descr->typecode); return PyString_FromString(buf); } ! if (a->ob_descr->typecode == 'c') { PyObject *t_empty = PyTuple_New(0); ! PyOS_snprintf(buf, sizeof(buf), "array('c', "); s = PyString_FromString(buf); ! v = array_tostring(a, t_empty); Py_DECREF(t_empty); t = PyObject_Repr(v); --- 1464,1486 ---- array_repr(arrayobject *a) { ! char buf[256], typecode; PyObject *s, *t, *comma, *v; int i, len; + len = a->ob_size; + typecode = a->ob_descr->typecode; if (len == 0) { ! PyOS_snprintf(buf, sizeof(buf), "array('%c')", typecode); return PyString_FromString(buf); } ! ! if (typecode == 'c' || typecode == 'u') { PyObject *t_empty = PyTuple_New(0); ! PyOS_snprintf(buf, sizeof(buf), "array('%c', ", typecode); s = PyString_FromString(buf); ! if (typecode == 'c') ! v = array_tostring(a, t_empty); ! else ! v = array_tounicode(a, t_empty); Py_DECREF(t_empty); t = PyObject_Repr(v); *************** *** 1330,1334 **** return s; } ! PyOS_snprintf(buf, sizeof(buf), "array('%c', [", a->ob_descr->typecode); s = PyString_FromString(buf); comma = PyString_FromString(", "); --- 1490,1494 ---- return s; } ! PyOS_snprintf(buf, sizeof(buf), "array('%c', [", typecode); s = PyString_FromString(buf); comma = PyString_FromString(", "); *************** *** 1386,1389 **** --- 1546,1552 ---- (intobjargproc)array_ass_item, /*sq_ass_item*/ (intintobjargproc)array_ass_slice, /*sq_ass_slice*/ + NULL, /*sq_contains*/ + (binaryfunc)array_inplace_concat, /*sq_inplace_concat*/ + (intargfunc)array_inplace_repeat /*sq_inplace_repeat*/ }; *************** *** 1395,1413 **** static PyObject * ! a_array(PyObject *self, PyObject *args) { char c; PyObject *initial = NULL; struct arraydescr *descr; ! if (!PyArg_ParseTuple(args, "c:array", &c)) { ! PyErr_Clear(); ! if (!PyArg_ParseTuple(args, "cO:array", &c, &initial)) return NULL; ! if (!PyList_Check(initial) && !PyString_Check(initial)) { PyErr_SetString(PyExc_TypeError, ! "array initializer must be list or string"); return NULL; } } for (descr = descriptors; descr->typecode != '\0'; descr++) { if (descr->typecode == c) { --- 1558,1589 ---- static PyObject * ! array_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { char c; PyObject *initial = NULL; struct arraydescr *descr; ! ! if (kwds != NULL) { ! int i = PyObject_Length(kwds); ! if (i < 0) return NULL; ! else if (i > 0) { PyErr_SetString(PyExc_TypeError, ! "array.array constructor takes " ! "no keyword arguments"); return NULL; } } + + if (!PyArg_ParseTuple(args, "c|O:array", &c, &initial)) + return NULL; + + if (!(initial == NULL || PyList_Check(initial) + || PyString_Check(initial) + || (c == 'u' && PyUnicode_Check(initial)))) { + PyErr_SetString(PyExc_TypeError, + "array initializer must be list or string"); + return NULL; + } for (descr = descriptors; descr->typecode != '\0'; descr++) { if (descr->typecode == c) { *************** *** 1418,1429 **** else len = PyList_Size(initial); ! a = newarrayobject(len, descr); if (a == NULL) return NULL; if (len > 0) { int i; for (i = 0; i < len; i++) { PyObject *v = ! PyList_GetItem(initial, i); if (setarrayitem(a, i, v) != 0) { Py_DECREF(a); --- 1594,1607 ---- else len = PyList_Size(initial); ! ! a = newarrayobject(type, len, descr); if (a == NULL) return NULL; + if (len > 0) { int i; for (i = 0; i < len; i++) { PyObject *v = ! PyList_GetItem(initial, i); if (setarrayitem(a, i, v) != 0) { Py_DECREF(a); *************** *** 1438,1442 **** array_fromstring((arrayobject *)a, t_initial); ! Py_DECREF(t_initial); if (v == NULL) { Py_DECREF(a); --- 1616,1620 ---- array_fromstring((arrayobject *)a, t_initial); ! Py_DECREF(t_initial); if (v == NULL) { Py_DECREF(a); *************** *** 1444,1447 **** --- 1622,1642 ---- } Py_DECREF(v); + #ifdef Py_USING_UNICODE + } else if (initial != NULL && PyUnicode_Check(initial)) { + int n = PyUnicode_GET_DATA_SIZE(initial); + if (n > 0) { + arrayobject *self = (arrayobject *)a; + char *item = self->ob_item; + item = PyMem_Realloc(item, n); + if (item == NULL) { + PyErr_NoMemory(); + Py_DECREF(a); + return NULL; + } + self->ob_item = item; + self->ob_size = n / sizeof(Py_UNICODE); + memcpy(item, PyUnicode_AS_DATA(initial), n); + } + #endif } return a; *************** *** 1449,1470 **** } PyErr_SetString(PyExc_ValueError, ! "bad typecode (must be c, b, B, h, H, i, I, l, L, f or d)"); return NULL; } - static char a_array_doc [] = - "array(typecode [, initializer]) -> array\n\ - \n\ - Return a new array whose items are restricted by typecode, and\n\ - initialized from the optional initializer value, which must be a list\n\ - or a string."; - - static PyMethodDef a_methods[] = { - {"array", a_array, METH_VARARGS, a_array_doc}, - {NULL, NULL} /* sentinel */ - }; static char module_doc [] = ! "This module defines a new object type which can efficiently represent\n\ an array of basic values: characters, integers, floating point\n\ numbers. Arrays are sequence types and behave very much like lists,\n\ --- 1644,1654 ---- } PyErr_SetString(PyExc_ValueError, ! "bad typecode (must be c, b, B, u, h, H, i, I, l, L, f or d)"); return NULL; } static char module_doc [] = ! "This module defines an object type which can efficiently represent\n\ an array of basic values: characters, integers, floating point\n\ numbers. Arrays are sequence types and behave very much like lists,\n\ *************** *** 1477,1480 **** --- 1661,1665 ---- 'b' signed integer 1 \n\ 'B' unsigned integer 1 \n\ + 'u' Unicode character 2 \n\ 'h' signed integer 2 \n\ 'H' unsigned integer 2 \n\ *************** *** 1486,1500 **** 'd' floating point 8 \n\ \n\ ! Functions:\n\ \n\ array(typecode [, initializer]) -- create a new array\n\ - \n\ - Special Objects:\n\ - \n\ - ArrayType -- type object for array objects\n\ "; static char arraytype_doc [] = ! "An array represents basic values and behave very much like lists, except\n\ the type of objects stored in them is constrained.\n\ \n\ --- 1671,1687 ---- 'd' floating point 8 \n\ \n\ ! The constructor is:\n\ \n\ array(typecode [, initializer]) -- create a new array\n\ "; static char arraytype_doc [] = ! "array(typecode [, initializer]) -> array\n\ ! \n\ ! Return a new array whose items are restricted by typecode, and\n\ ! initialized from the optional initializer value, which must be a list\n\ ! or a string.\n\ ! \n\ ! Arrays represent basic values and behave very much like lists, except\n\ the type of objects stored in them is constrained.\n\ \n\ *************** *** 1520,1524 **** write() -- DEPRECATED, use tofile()\n\ \n\ ! Variables:\n\ \n\ typecode -- the typecode character used to create the array\n\ --- 1707,1711 ---- write() -- DEPRECATED, use tofile()\n\ \n\ ! Attributes:\n\ \n\ typecode -- the typecode character used to create the array\n\ *************** *** 1534,1538 **** (destructor)array_dealloc, /* tp_dealloc */ (printfunc)array_print, /* tp_print */ ! (getattrfunc)array_getattr, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ --- 1721,1725 ---- (destructor)array_dealloc, /* tp_dealloc */ (printfunc)array_print, /* tp_print */ ! 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ *************** *** 1544,1557 **** 0, /* tp_call */ 0, /* tp_str */ ! 0, /* tp_getattro */ 0, /* tp_setattro */ &array_as_buffer, /* tp_as_buffer*/ ! Py_TPFLAGS_DEFAULT, /* tp_flags */ arraytype_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ array_richcompare, /* tp_richcompare */ }; DL_EXPORT(void) initarray(void) --- 1731,1765 ---- 0, /* tp_call */ 0, /* tp_str */ ! PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ &array_as_buffer, /* tp_as_buffer*/ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ arraytype_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ array_richcompare, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + array_methods, /* tp_methods */ + 0, /* tp_members */ + array_getsets, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + PyType_GenericAlloc, /* tp_alloc */ + array_new, /* tp_new */ + _PyObject_Del, /* tp_free */ }; + /* No functions in array module. */ + static PyMethodDef a_methods[] = { + {NULL, NULL, 0, NULL} /* Sentinel */ + }; + + DL_EXPORT(void) initarray(void) *************** *** 1559,1566 **** PyObject *m, *d; ! Arraytype.ob_type = &PyType_Type; m = Py_InitModule3("array", a_methods, module_doc); d = PyModule_GetDict(m); PyDict_SetItemString(d, "ArrayType", (PyObject *)&Arraytype); /* No need to check the error here, the caller will do that */ } --- 1767,1775 ---- PyObject *m, *d; ! Arraytype.ob_type = &PyType_Type; m = Py_InitModule3("array", a_methods, module_doc); d = PyModule_GetDict(m); PyDict_SetItemString(d, "ArrayType", (PyObject *)&Arraytype); + PyDict_SetItemString(d, "array", (PyObject *)&Arraytype); /* No need to check the error here, the caller will do that */ } From loewis@users.sourceforge.net Fri Mar 1 10:27:03 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 01 Mar 2002 02:27:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.357,1.358 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv25235/Misc Modified Files: NEWS Log Message: Patch 520694: arraymodule.c improvements: - make array.array a type - add Py_UNICODE arrays - support +=, *= Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.357 retrieving revision 1.358 diff -C2 -d -r1.357 -r1.358 *** NEWS 16 Feb 2002 23:35:41 -0000 1.357 --- NEWS 1 Mar 2002 10:27:01 -0000 1.358 *************** *** 18,21 **** --- 18,26 ---- Extension modules + - array.array is now a type object. A new format character + 'u' indicates Py_UNICODE arrays. For those, .tounicode and + .fromunicode methods are available. Arrays now support __iadd__ + and __imul__. + - dl now builds on every system that has dlfcn.h. Failure in case of sizeof(int)!=sizeof(long)!=sizeof(void*) is delayed until dl.open From loewis@users.sourceforge.net Fri Mar 1 10:27:03 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 01 Mar 2002 02:27:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libarray.tex,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv25235/Doc/lib Modified Files: libarray.tex Log Message: Patch 520694: arraymodule.c improvements: - make array.array a type - add Py_UNICODE arrays - support +=, *= Index: libarray.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libarray.tex,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** libarray.tex 20 Oct 2001 04:24:09 -0000 1.31 --- libarray.tex 1 Mar 2002 10:27:01 -0000 1.32 *************** *** 6,10 **** ! This module defines a new object type which can efficiently represent an array of basic values: characters, integers, floating point numbers. Arrays\index{arrays} are sequence types and behave very much --- 6,10 ---- ! This module defines an object type which can efficiently represent an array of basic values: characters, integers, floating point numbers. Arrays\index{arrays} are sequence types and behave very much *************** *** 18,21 **** --- 18,22 ---- \lineiii{'b'}{signed int}{1} \lineiii{'B'}{unsigned int}{1} + \lineiii{'u'}{Unicode character}{2} \lineiii{'h'}{signed int}{2} \lineiii{'H'}{unsigned int}{2} *************** *** 36,56 **** ! The module defines the following function and type object: \begin{funcdesc}{array}{typecode\optional{, initializer}} ! Return a new array whose items are restricted by \var{typecode}, and ! initialized from the optional \var{initializer} value, which must be a ! list or a string. The list or string is passed to the new array's ! \method{fromlist()} or \method{fromstring()} method (see below) to add ! initial items to the array. \end{funcdesc} \begin{datadesc}{ArrayType} ! Type object corresponding to the objects returned by ! \function{array()}. \end{datadesc} ! Array objects support the following data items and methods: \begin{memberdesc}[array]{typecode} --- 37,59 ---- ! The module defines the following type: \begin{funcdesc}{array}{typecode\optional{, initializer}} ! Return a new array whose items are restricted by \var{typecode}, ! and initialized from the optional \var{initializer} value, which ! must be a list or a string. The list or string is passed to the ! new array's \method{fromlist()}, \method{fromstring()}, or ! \method{fromunicode()} method (see below) to add initial items to ! the array. \end{funcdesc} \begin{datadesc}{ArrayType} ! Obsolete alias for \function{array}. \end{datadesc} ! Array objects support the ordinary sequence operations of ! indexing, slicing, concatenation, and multiplication. The ! following data items and methods are also supported: \begin{memberdesc}[array]{typecode} *************** *** 122,125 **** --- 125,135 ---- \end{methoddesc} + \begin{methoddesc}[array]{fromunicode}{s} + Extends this array with data from the given unicode string. + The array must be a type 'u' array; otherwise a ValueError + is raised. Use \samp{array.fromstring(ustr.decode(enc))} to + append Unicode data to an array of some other type. + \end{methoddesc} + \begin{methoddesc}[array]{index}{x} Return the smallest \var{i} such that \var{i} is the index of *************** *** 135,139 **** Removes the item with the index \var{i} from the array and returns it. The optional argument defaults to \code{-1}, so that by default ! the last item is removed and returned. \end{methoddesc} --- 145,149 ---- Removes the item with the index \var{i} from the array and returns it. The optional argument defaults to \code{-1}, so that by default ! the last item is removed and returned. \end{methoddesc} *************** *** 171,174 **** --- 181,191 ---- \end{methoddesc} + \begin{methoddesc}[array]{tounicode}{} + Convert the array to a unicode string. The array must be + a type 'u' array; otherwise a ValueError is raised. Use + array.tostring().decode(enc) to obtain a unicode string + from an array of some other type. + \end{methoddesc} + \begin{methoddesc}[array]{write}{f} \deprecated {1.5.1} *************** *** 189,192 **** --- 206,210 ---- array('l') array('c', 'hello world') + array('u', u'hello \textbackslash u2641') array('l', [1, 2, 3, 4, 5]) array('d', [1.0, 2.0, 3.14]) From loewis@users.sourceforge.net Fri Mar 1 10:38:46 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 01 Mar 2002 02:38:46 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libgrp.tex,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv28176/Doc/lib Modified Files: libgrp.tex Log Message: Patch #523268, #522027: return enhanced tuples. Index: libgrp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libgrp.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** libgrp.tex 8 Jul 2000 16:59:03 -0000 1.15 --- libgrp.tex 1 Mar 2002 10:38:44 -0000 1.16 *************** *** 10,17 **** It is available on all \UNIX{} versions. ! Group database entries are reported as 4-tuples containing the ! following items from the group database (see \code{}), in order: ! \begin{tableiii}{r|l|l}{textrm}{Index}{Field}{Meaning} \lineiii{0}{gr_name}{the name of the group} \lineiii{1}{gr_passwd}{the (encrypted) group password; often empty} --- 10,18 ---- It is available on all \UNIX{} versions. ! Group database entries are reported as a tuple-like object, whose ! attributes correspond to the members of the \code{group} structure ! (Attribute field below, see \code{}): ! \begin{tableiii}{r|l|l}{textrm}{Index}{Attribute}{Meaning} \lineiii{0}{gr_name}{the name of the group} \lineiii{1}{gr_passwd}{the (encrypted) group password; often empty} From loewis@users.sourceforge.net Fri Mar 1 10:38:47 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 01 Mar 2002 02:38:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules grpmodule.c,2.16,2.17 pwdmodule.c,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv28176/Modules Modified Files: grpmodule.c pwdmodule.c Log Message: Patch #523268, #522027: return enhanced tuples. Index: grpmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/grpmodule.c,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -d -r2.16 -r2.17 *** grpmodule.c 1 Feb 2002 15:46:29 -0000 2.16 --- grpmodule.c 1 Mar 2002 10:38:44 -0000 2.17 *************** *** 3,17 **** #include "Python.h" #include #include static PyObject * mkgrent(struct group *p) { ! PyObject *v, *w; char **member; if ((w = PyList_New(0)) == NULL) { return NULL; } --- 3,47 ---- #include "Python.h" + #include "structseq.h" #include #include + static PyStructSequence_Field struct_group_type_fields[] = { + {"gr_name", "group name"}, + {"gr_passwd", "password"}, + {"gr_gid", "group id"}, + {"gr_mem", "group memebers"}, + {0} + }; + + static char struct_group__doc__[] = + "grp.struct_group: Results from getgr*() routines.\n\n\ + This object may be accessed either as a tuple of\n\ + (gr_name,gr_passwd,gr_gid,gr_mem)\n\ + or via the object attributes as named in the above tuple.\n"; + + static PyStructSequence_Desc struct_group_type_desc = { + "grp.struct_group", + struct_group__doc__, + struct_group_type_fields, + 4, + }; + + + static PyTypeObject StructGrpType; static PyObject * mkgrent(struct group *p) { ! int setIndex = 0; ! PyObject *v = PyStructSequence_New(&StructGrpType), *w; char **member; + + if (v == NULL) + return NULL; + if ((w = PyList_New(0)) == NULL) { + Py_DECREF(v); return NULL; } *************** *** 21,34 **** Py_XDECREF(x); Py_DECREF(w); return NULL; } Py_DECREF(x); } ! v = Py_BuildValue("(sslO)", ! p->gr_name, ! p->gr_passwd, ! (long)p->gr_gid, ! w); ! Py_DECREF(w); return v; } --- 51,73 ---- Py_XDECREF(x); Py_DECREF(w); + Py_DECREF(v); return NULL; } Py_DECREF(x); } ! ! #define SET(i,val) PyStructSequence_SET_ITEM(v, i, val) ! SET(setIndex++, PyString_FromString(p->gr_name)); ! SET(setIndex++, PyString_FromString(p->gr_passwd)); ! SET(setIndex++, PyInt_FromLong((long) p->gr_gid)); ! SET(setIndex++, w); ! #undef SET ! ! if (PyErr_Occurred()) { ! Py_DECREF(v); ! Py_DECREF(w); ! return NULL; ! } ! return v; } *************** *** 121,124 **** initgrp(void) { ! Py_InitModule3("grp", grp_methods, grp__doc__); } --- 160,167 ---- initgrp(void) { ! PyObject *m, *d; ! m = Py_InitModule3("grp", grp_methods, grp__doc__); ! d = PyModule_GetDict(m); ! PyStructSequence_InitType(&StructGrpType, &struct_group_type_desc); ! PyDict_SetItemString(d, "struct_group", (PyObject *) &StructGrpType); } Index: pwdmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pwdmodule.c,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** pwdmodule.c 1 Feb 2002 15:46:29 -0000 1.26 --- pwdmodule.c 1 Mar 2002 10:38:44 -0000 1.27 *************** *** 3,10 **** --- 3,35 ---- #include "Python.h" + #include "structseq.h" #include #include + static PyStructSequence_Field struct_pwd_type_fields[] = { + {"pw_name", "user name"}, + {"pw_passwd", "password"}, + {"pw_uid", "user id"}, + {"pw_gid", "group id"}, + {"pw_gecos", "real name"}, + {"pw_dir", "home directory"}, + {"pw_shell", "shell program"}, + {0} + }; + + static char struct_passwd__doc__[] = + "pwd.struct_passwd: Results from getpw*() routines.\n\n\ + This object may be accessed either as a tuple of\n\ + (pw_name,pw_passwd,pw_uid,pw_gid,pw_gecos,pw_dir,pw_shell)\n\ + or via the object attributes as named in the above tuple.\n"; + + static PyStructSequence_Desc struct_pwd_type_desc = { + "pwd.struct_passwd", + struct_passwd__doc__, + struct_pwd_type_fields, + 7, + }; + static char pwd__doc__ [] = "\ This module provides access to the Unix password database.\n\ *************** *** 18,37 **** static PyObject * mkpwent(struct passwd *p) { ! return Py_BuildValue( ! "(ssllsss)", ! p->pw_name, ! p->pw_passwd, ! (long)p->pw_uid, ! (long)p->pw_gid, ! p->pw_gecos, ! p->pw_dir, ! p->pw_shell); } static char pwd_getpwuid__doc__[] = "\ ! getpwuid(uid) -> entry\n\ Return the password database entry for the given numeric user ID.\n\ See pwd.__doc__ for more on password database entries."; --- 43,80 ---- + static PyTypeObject StructPwdType; + static PyObject * mkpwent(struct passwd *p) { ! int setIndex = 0; ! PyObject *v = PyStructSequence_New(&StructPwdType); ! if (v == NULL) ! return NULL; ! ! #define SETI(i,val) PyStructSequence_SET_ITEM(v, i, PyInt_FromLong((long) val)) ! #define SETS(i,val) PyStructSequence_SET_ITEM(v, i, PyString_FromString(val)) ! ! SETS(setIndex++, p->pw_name); ! SETS(setIndex++, p->pw_passwd); ! SETI(setIndex++, p->pw_uid); ! SETI(setIndex++, p->pw_gid); ! SETS(setIndex++, p->pw_gecos); ! SETS(setIndex++, p->pw_dir); ! SETS(setIndex++, p->pw_shell); ! ! #undef SETS ! #undef SETI ! ! if (PyErr_Occurred()) { ! Py_XDECREF(v); ! return NULL; ! } ! ! return v; } static char pwd_getpwuid__doc__[] = "\ ! getpwuid(uid) -> (pw_name,pw_passwd,pw_uid,pw_gid,pw_gecos,pw_dir,pw_shell)\n\ Return the password database entry for the given numeric user ID.\n\ See pwd.__doc__ for more on password database entries."; *************** *** 52,56 **** static char pwd_getpwnam__doc__[] = "\ ! getpwnam(name) -> entry\n\ Return the password database entry for the given user name.\n\ See pwd.__doc__ for more on password database entries."; --- 95,99 ---- static char pwd_getpwnam__doc__[] = "\ ! getpwnam(name) -> (pw_name,pw_passwd,pw_uid,pw_gid,pw_gecos,pw_dir,pw_shell)\n\ Return the password database entry for the given user name.\n\ See pwd.__doc__ for more on password database entries."; *************** *** 113,117 **** initpwd(void) { ! Py_InitModule4("pwd", pwd_methods, pwd__doc__, (PyObject *)NULL, PYTHON_API_VERSION); } --- 156,164 ---- initpwd(void) { ! PyObject *m, *d; ! m = Py_InitModule4("pwd", pwd_methods, pwd__doc__, (PyObject *)NULL, PYTHON_API_VERSION); + d = PyModule_GetDict(m); + PyStructSequence_InitType(&StructPwdType, &struct_pwd_type_desc); + PyDict_SetItemString(d, "struct_pwent", (PyObject *) &StructPwdType); } From loewis@users.sourceforge.net Fri Mar 1 10:47:39 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 01 Mar 2002 02:47:39 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.358,1.359 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv30618/Misc Modified Files: NEWS Log Message: Patch #523268, #522027: return enhanced tuples. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.358 retrieving revision 1.359 diff -C2 -d -r1.358 -r1.359 *** NEWS 1 Mar 2002 10:27:01 -0000 1.358 --- NEWS 1 Mar 2002 10:47:37 -0000 1.359 *************** *** 18,21 **** --- 18,23 ---- Extension modules + - pwd and grp return enhanced tuples now, with symbolic field names. + - array.array is now a type object. A new format character 'u' indicates Py_UNICODE arrays. For those, .tounicode and From loewis@users.sourceforge.net Fri Mar 1 10:47:39 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 01 Mar 2002 02:47:39 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libpwd.tex,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv30618/Doc/lib Modified Files: libpwd.tex Log Message: Patch #523268, #522027: return enhanced tuples. Index: libpwd.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpwd.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** libpwd.tex 20 Oct 2001 04:24:09 -0000 1.13 --- libpwd.tex 1 Mar 2002 10:47:36 -0000 1.14 *************** *** 9,16 **** database. It is available on all \UNIX{} versions. ! Password database entries are reported as 7-tuples containing the ! following items from the password database (see \code{}), in order: ! \begin{tableiii}{r|l|l}{textrm}{Index}{Field}{Meaning} \lineiii{0}{\code{pw_name}}{Login name} \lineiii{1}{\code{pw_passwd}}{Optional encrypted password} --- 9,17 ---- database. It is available on all \UNIX{} versions. ! Password database entries are reported as a tuple-like object, whose ! attributes correspond to the members of the \code{passwd} structure ! (Attribute field below, see \code{}): ! \begin{tableiii}{r|l|l}{textrm}{Index}{Attribute}{Meaning} \lineiii{0}{\code{pw_name}}{Login name} \lineiii{1}{\code{pw_passwd}}{Optional encrypted password} From barry@zope.com Fri Mar 1 12:52:48 2002 From: barry@zope.com (Barry A. Warsaw) Date: Fri, 1 Mar 2002 07:52:48 -0500 Subject: [Python-checkins] CVS: python/nondist/peps pep-0001.txt,1.28,1.29 References: <3C7F3BAF.56514E85@lemburg.com> Message-ID: <15487.31136.344196.234047@anthem.wooz.org> >>>>> "MAL" == M writes: MAL> Isn't this unnecessary duplication ? The CVS history has all MAL> this information available, including patches, comments, etc. I think it's helpful when viewing the file on the web. -Barry From nnorwitz@users.sourceforge.net Fri Mar 1 13:10:05 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Fri, 01 Mar 2002 05:10:05 -0800 Subject: [Python-checkins] CVS: python/dist/src/Demo/tix tixwidgets.py,1.4,1.4.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/tix In directory usw-pr-cvs1:/tmp/cvs-serv31408 Modified Files: Tag: release22-maint tixwidgets.py Log Message: SF #517447, correct syntax error Index: tixwidgets.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/tixwidgets.py,v retrieving revision 1.4 retrieving revision 1.4.6.1 diff -C2 -d -r1.4 -r1.4.6.1 *** tixwidgets.py 25 Nov 2001 14:50:55 -0000 1.4 --- tixwidgets.py 1 Mar 2002 13:10:02 -0000 1.4.6.1 *************** *** 136,141 **** while self.exit < 0: try: ! while self.exit < 0: ! self.root.tk.dooneevent(TCL_ALL_EVENTS) except SystemExit: #print 'Exit' --- 136,140 ---- while self.exit < 0: try: ! self.root.tk.dooneevent(TCL_ALL_EVENTS) except SystemExit: #print 'Exit' From loewis@users.sourceforge.net Fri Mar 1 13:15:33 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 01 Mar 2002 05:15:33 -0800 Subject: [Python-checkins] CVS: python/dist/src/Demo/pysvr pysvr.c,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/pysvr In directory usw-pr-cvs1:/tmp/cvs-serv32447 Modified Files: pysvr.c Log Message: Patch #524008: Fix portability bug on new POSIX hosts Index: pysvr.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/pysvr/pysvr.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pysvr.c 28 Nov 2001 20:27:42 -0000 1.10 --- pysvr.c 1 Mar 2002 13:15:30 -0000 1.11 *************** *** 366,370 **** char buffer[100]; PyOS_snprintf(buffer, sizeof(buffer), ! "ps -l -p %d Update of /cvsroot/python/python/dist/src/Demo/tix In directory usw-pr-cvs1:/tmp/cvs-serv30904 Modified Files: tixwidgets.py Log Message: SF #517447, correct syntax error Index: tixwidgets.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/tixwidgets.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tixwidgets.py 25 Nov 2001 14:50:55 -0000 1.4 --- tixwidgets.py 1 Mar 2002 13:07:34 -0000 1.5 *************** *** 136,141 **** while self.exit < 0: try: ! while self.exit < 0: ! self.root.tk.dooneevent(TCL_ALL_EVENTS) except SystemExit: #print 'Exit' --- 136,140 ---- while self.exit < 0: try: ! self.root.tk.dooneevent(TCL_ALL_EVENTS) except SystemExit: #print 'Exit' From mwh@users.sourceforge.net Fri Mar 1 14:16:34 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Fri, 01 Mar 2002 06:16:34 -0800 Subject: [Python-checkins] CVS: python/dist/src setup.py,1.82,1.83 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv15478 Modified Files: setup.py Log Message: Changes to what we do to modules that don't import, as discussed on python-dev. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** setup.py 16 Feb 2002 18:23:29 -0000 1.82 --- setup.py 1 Mar 2002 14:16:31 -0000 1.83 *************** *** 177,187 **** if 1: ! self.announce('*** WARNING: removing "%s" since importing it' ' failed: %s' % (ext.name, why)) assert not self.inplace ! fullname = self.get_ext_fullname(ext.name) ! ext_filename = os.path.join(self.build_lib, ! self.get_ext_filename(fullname)) ! os.remove(ext_filename) # XXX -- This relies on a Vile HACK in --- 177,187 ---- if 1: ! self.announce('*** WARNING: renaming "%s" since importing it' ' failed: %s' % (ext.name, why)) assert not self.inplace ! basename, tail = os.path.splitext(ext_filename) ! newname = basename + "_failed" + tail ! if os.path.exists(newname): os.remove(newname) ! os.rename(ext_filename, newname) # XXX -- This relies on a Vile HACK in From mal@lemburg.com Fri Mar 1 18:17:38 2002 From: mal@lemburg.com (M.-A. Lemburg) Date: Fri, 01 Mar 2002 19:17:38 +0100 Subject: [Python-checkins] CVS: python/nondist/peps pep-0001.txt,1.28,1.29 References: <3C7F3BAF.56514E85@lemburg.com> <15487.31136.344196.234047@anthem.wooz.org> Message-ID: <3C7FC5C2.616B707E@lemburg.com> "Barry A. Warsaw" wrote: > > >>>>> "MAL" == M writes: > > MAL> Isn't this unnecessary duplication ? The CVS history has all > MAL> this information available, including patches, comments, etc. > > I think it's helpful when viewing the file on the web. A direct link to the ViewCVS entry on SF would be a lot more helpful, IMHO, since it offers more background information than the simple Last-Modified notice. pep2html.py could easily generate this link (and also the Last-Modified entry; perhaps both ;-): http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/nondist/peps/pep-.txt -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/ From lemburg@users.sourceforge.net Fri Mar 1 19:07:49 2002 From: lemburg@users.sourceforge.net (M.-A. Lemburg) Date: Fri, 01 Mar 2002 11:07:49 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep2html.py,1.31,1.32 pep-0263.txt,1.8,1.9 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv2473 Modified Files: pep2html.py pep-0263.txt Log Message: Added support for Last-Modified header and its (possibly automatic) generation. Index: pep2html.py =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep2html.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** pep2html.py 16 Feb 2002 10:44:32 -0000 1.31 --- pep2html.py 1 Mar 2002 19:07:46 -0000 1.32 *************** *** 32,40 **** import getopt import errno PROGRAM = sys.argv[0] RFCURL = 'http://www.faqs.org/rfcs/rfc%d.html' PEPURL = 'pep-%04d.html' ! --- 32,41 ---- import getopt import errno + import time PROGRAM = sys.argv[0] RFCURL = 'http://www.faqs.org/rfcs/rfc%d.html' PEPURL = 'pep-%04d.html' ! PEPCVSURL = 'http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/nondist/peps/pep-%04d.txt' *************** *** 159,167 **** v = SPACE.join(mailtos) elif k.lower() in ('replaces', 'replaced-by'): ! peps = '' ! for pep in v.split(): ! pep = int(pep) ! peps += '%i ' % (pep, pep) ! v = peps else: v = cgi.escape(v) --- 160,174 ---- v = SPACE.join(mailtos) elif k.lower() in ('replaces', 'replaced-by'): ! otherpeps = '' ! for otherpep in v.split(): ! otherpep = int(otherpep) ! otherpeps += '%i ' % (otherpep, ! otherpep) ! v = otherpeps ! elif k.lower() in ('last-modified',): ! url = PEPCVSURL % int(pep) ! date = v or time.strftime('%d-%b-%Y', ! time.localtime(os.stat(infile)[8])) ! v = '%s ' % (url, cgi.escape(date)) else: v = cgi.escape(v) Index: pep-0263.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0263.txt,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** pep-0263.txt 28 Feb 2002 09:08:39 -0000 1.8 --- pep-0263.txt 1 Mar 2002 19:07:46 -0000 1.9 *************** *** 7,10 **** --- 7,11 ---- Python-Version: 2.3 Created: 06-Jun-2001 + Last-Modified: Post-History: From mal@lemburg.com Fri Mar 1 19:11:21 2002 From: mal@lemburg.com (M.-A. Lemburg) Date: Fri, 01 Mar 2002 20:11:21 +0100 Subject: [Python-checkins] CVS: python/nondist/peps pep-0001.txt,1.28,1.29 References: <3C7F3BAF.56514E85@lemburg.com> <15487.31136.344196.234047@anthem.wooz.org> <3C7FC5C2.616B707E@lemburg.com> Message-ID: <3C7FD259.4D835FA2@lemburg.com> "M.-A. Lemburg" wrote: > > "Barry A. Warsaw" wrote: > > > > >>>>> "MAL" == M writes: > > > > MAL> Isn't this unnecessary duplication ? The CVS history has all > > MAL> this information available, including patches, comments, etc. > > > > I think it's helpful when viewing the file on the web. > > A direct link to the ViewCVS entry on SF would be a lot > more helpful, IMHO, since it offers more background > information than the simple Last-Modified notice. > > pep2html.py could easily generate this link (and > also the Last-Modified entry; perhaps both ;-): > > http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/nondist/peps/pep-.txt I just added support for this to pep2html.py. If the Last-Modified is present, but empty, it is autogenerated. If available, the value is taken as is. In both cases the date links to the CVS entry on SF. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/ From mal@lemburg.com Fri Mar 1 19:15:29 2002 From: mal@lemburg.com (M.-A. Lemburg) Date: Fri, 01 Mar 2002 20:15:29 +0100 Subject: [Python-checkins] CVS: python/nondist/peps pep-0001.txt,1.28,1.29 References: <3C7F3BAF.56514E85@lemburg.com> <15487.31136.344196.234047@anthem.wooz.org> <3C7FC5C2.616B707E@lemburg.com> <3C7FD259.4D835FA2@lemburg.com> Message-ID: <3C7FD351.24B7CCDC@lemburg.com> "M.-A. Lemburg" wrote: > > I just added support for this to pep2html.py. If the Last-Modified > is present, but empty, it is autogenerated. If available, the > value is taken as is. In both cases the date links to the > CVS entry on SF. See http://python.sourceforge.net/peps/pep-0263.html for an example. FYI, I've converted all PEPs on the SF page to the new format. Hope I didn't break anything... -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/ From barry@zope.com Fri Mar 1 19:17:35 2002 From: barry@zope.com (Barry A. Warsaw) Date: Fri, 1 Mar 2002 14:17:35 -0500 Subject: [Python-checkins] CVS: python/nondist/peps pep-0001.txt,1.28,1.29 References: <3C7F3BAF.56514E85@lemburg.com> <15487.31136.344196.234047@anthem.wooz.org> <3C7FC5C2.616B707E@lemburg.com> <3C7FD259.4D835FA2@lemburg.com> <3C7FD351.24B7CCDC@lemburg.com> Message-ID: <15487.54223.483081.28063@anthem.wooz.org> >>>>> "MAL" == M writes: MAL> See http://python.sourceforge.net/peps/pep-0263.html MAL> for an example. MAL> FYI, I've converted all PEPs on the SF page to the new MAL> format. Hope I didn't break anything... As an alternative format, what about adding a link to the CVS history in the title bar, e.g. [History] right after [PEP source]? BTW, thanks! -Barry From guido@python.org Fri Mar 1 19:21:52 2002 From: guido@python.org (Guido van Rossum) Date: Fri, 01 Mar 2002 14:21:52 -0500 Subject: [Python-checkins] CVS: python/nondist/peps pep-0001.txt,1.28,1.29 In-Reply-To: Your message of "Fri, 01 Mar 2002 20:15:29 +0100." <3C7FD351.24B7CCDC@lemburg.com> References: <3C7F3BAF.56514E85@lemburg.com> <15487.31136.344196.234047@anthem.wooz.org> <3C7FC5C2.616B707E@lemburg.com> <3C7FD259.4D835FA2@lemburg.com> <3C7FD351.24B7CCDC@lemburg.com> Message-ID: <200203011921.g21JLv006833@pcp742651pcs.reston01.va.comcast.net> > See http://python.sourceforge.net/peps/pep-0263.html > for an example. Oh, very cool, very subtle! --Guido van Rossum (home page: http://www.python.org/~guido/) From gvanrossum@users.sourceforge.net Fri Mar 1 20:58:37 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 01 Mar 2002 12:58:37 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime - New directory Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv4777/datetime Log Message: Directory /cvsroot/python/python/nondist/sandbox/datetime added to the repository From gvanrossum@users.sourceforge.net Fri Mar 1 21:00:52 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 01 Mar 2002 13:00:52 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,NONE,1.1 test_datetime.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv5784 Added Files: datetime.py test_datetime.py Log Message: datetime prototype in Python --- NEW FILE: datetime.py --- import time as _time class basetime(object): """Abstract date/time type. See http://effbot.org/ideas/time-type.htm """ __slots__ = [] def timetuple(self): raise NotImplementedError def utctimetuple(self): raise NotImplementedError def __cmp__(self, other): raise NotImplementedError def __hash__(self): raise NotImplementedError # XXX deltaobject? class datetime(basetime): """Concrete date/time type -- prototype implemented in Python. See http://www.zope.org/Members/fdrake/DateTimeWiki/FrontPage """ __isdst = None def __init__(self, year, month, day, hour=0, minute=0, second=0, microsecond=0, tzoffset=None): assert 1 <= year <= 9999 assert 1 <= month <= 12 assert 1 <= day <= 31 # XXX calendrical check assert 0 <= hour <= 23 assert 0 <= minute <= 59 assert 0 <= second <= 59 assert 0 <= microsecond <= 999999 if tzoffset is None: if datetime.__isdst is None: datetime.__isdst = _time.localtime()[-1] if datetime.__isdst > 0: tzoffset = -(_time.altzone/60) else: tzoffset = -(_time.timezone/60) assert -1439 <= tzoffset <= 1439 self.__year = year self.__month = month self.__day = day self.__hour = hour self.__minute = minute self.__second = second self.__microsecond = microsecond self.__tzoffset = tzoffset # minutes east of UTC def new(cls, *args, **kwds): return cls(*args, **kwds) new = classmethod(new) def fromtimestamp(cls, t): y, m, d, hh, mm, ss, weekday, jday, dst = _time.localtime(t) us = int((t % 1.0) * 1000000) if dst > 0: tz = - _time.altzone/60 else: tz = - _time.timezone/60 return cls(y, m, d, hh, mm, ss, us, tz) fromtimestamp = classmethod(fromtimestamp) def now(cls): t = _time.time() return cls.fromtimestamp(t) now = classmethod(now) def utcfromtimestamp(cls, t): y, m, d, hh, mm, ss, weekday, jday, dst = _time.gmtime(t) us = int((t % 1.0) * 1000000) return cls(y, m, d, hh, mm, ss, us, 0) utcfromtimestamp = classmethod(utcfromtimestamp) def utcnow(cls): t = _time.time() return cls.utcfromtimestamp(t) utcnow = classmethod(utcnow) # Read-only field accessors year = property(lambda self: self.__year, doc="year (1-9999)") month = property(lambda self: self.__month, doc="month (1-12)") day = property(lambda self: self.__day, doc="day (1-31)") hour = property(lambda self: self.__hour, doc="hour (0-23)") minute = property(lambda self: self.__minute, doc="minute (0-59)") second = property(lambda self: self.__second, doc="second (0-59)") microsecond = property(lambda self: self.__microsecond, doc="microsecond (0-999999)") tzoffset = property(lambda self: self.__tzoffset, doc="time zone offset in minutes east of UTC") def _mktime(self): # Helper to call time.mktime() y, m, d = self.__year, self.__month, self.__day hh, mm, ss = self.__hour, self.__minute, self.__second mm -= self.__tzoffset # tzoffset is negative in the US ss -= _time.timezone # but time.timezone has the opposite sign! return _time.mktime((y, m, d, hh, mm, ss, -1, -1, -1)) def _timestamp(self): # Helper like _mktime() that adds microseconds return self._mktime() + 0.000001 * self.__microsecond def timetuple(self): """Return local time tuple compatible with time.localtime().""" return _time.localtime(self._mktime()) def utctimetuple(self): """Return UTC time tuple compatible with time.gmtime().""" return _time.gmtime(self._mktime()) def __cmp__(self, other): """Three-way comparison.""" if isinstance(other, datetime): if other.__tzoffset == self.__tzoffset: y, m, d = self.__year, self.__month, self.__day hh, mm, ss = self.__hour, self.__minute, self.__second tz = self.__tzoffset y2, m2, d2 = other.__year, other.__month, other.__day hh2, mm2, ss2 = other.__hour, other.__minute, other.__second tz2 = other.__tzoffset return cmp((y, m, d, hh, mm, ss, tz), (y2, m2, d2, hh2, mm2, ss2, tz2)) else: return cmp(self._timestamp(), other._timestamp()) else: return NotImplemented def __hash__(self): """Hash.""" y, m, d = self.__year, self.__month, self.__day hh, mm, ss = self.__hour, self.__minute, self.__second us, tz = self.__microsecond, self.__tzoffset return hash((y, m, d, hh, mm, ss, us, tz)) def ctime(self): return _time.strftime("%c", _time.localtime(self._mktime())) def strftime(self, fmt): return _time.strftime(fmt, _time.localtime(self._mktime())) def utcctime(self): return _time.strftime("%c", _time.gmtime(self._mktime())) def utcstrftime(self, fmt): return _time.strftime(fmt, _time.gmtime(self._mktime())) # __add__, __sub__? def _test(): now = _time.time() print _time.ctime(now) t = datetime.fromtimestamp(now) print t.ctime(), divmod(t.tzoffset, 60), t.hour u = datetime.utcfromtimestamp(now) print u.utcctime(), divmod(u.tzoffset, 60), u.hour assert t == u if __name__ == "__main__": _test() --- NEW FILE: test_datetime.py --- """Test date/time type. See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases """ import sys import unittest from datetime import datetime class TestDateTime(unittest.TestCase): def test_basic_attributes(self): dt = datetime.new(2002, 3, 1, 12, 0, 0) self.assertEqual(dt.year, 2002) self.assertEqual(dt.month, 3) self.assertEqual(dt.day, 1) self.assertEqual(dt.hour, 12) self.assertEqual(dt.minute, 0) self.assertEqual(dt.second, 0) def test_tz_independent_comparing(self): dt1 = datetime.new(2002, 3, 1, 9, 0, 0, tzoffset=-60) dt2 = datetime.new(2002, 3, 1, 10, 0, 0, tzoffset=-60) dt3 = datetime.new(2002, 3, 1, 10, 0, 0, tzoffset=0) self.assertEqual(dt1, dt3) self.assert_(dt2 > dt3) def test_suite(): s1 = unittest.makeSuite(TestDateTime, 'test') return unittest.TestSuite([s1]) def test_main(): r = unittest.TextTestRunner(stream=sys.stdout, verbosity=2) s = test_suite() r.run(s) if __name__ == "__main__": test_main() From gvanrossum@users.sourceforge.net Fri Mar 1 21:30:57 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 01 Mar 2002 13:30:57 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules mpzmodule.c,2.39,2.40 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv15797 Modified Files: mpzmodule.c Log Message: SF patch 517245 by Marc Recht. Support GMP version >= 2. Bugfix candidate. Index: mpzmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mpzmodule.c,v retrieving revision 2.39 retrieving revision 2.40 diff -C2 -d -r2.39 -r2.40 *** mpzmodule.c 17 Jan 2002 23:15:58 -0000 2.39 --- mpzmodule.c 1 Mar 2002 21:30:55 -0000 2.40 *************** *** 63,67 **** #include "gmp.h" ! #if __GNU_MP__ + 0 == 2 #define GMP2 #define BITS_PER_MP_LIMB mp_bits_per_limb --- 63,67 ---- #include "gmp.h" ! #if __GNU_MP__ + 0 >= 2 #define GMP2 #define BITS_PER_MP_LIMB mp_bits_per_limb From gvanrossum@users.sourceforge.net Fri Mar 1 21:31:30 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 01 Mar 2002 13:31:30 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc ACKS,1.161,1.162 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv16005 Modified Files: ACKS Log Message: SF patch 517245 by Marc Recht. Support GMP version >= 2. Bugfix candidate. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.161 retrieving revision 1.162 diff -C2 -d -r1.161 -r1.162 *** ACKS 28 Feb 2002 23:19:52 -0000 1.161 --- ACKS 1 Mar 2002 21:31:27 -0000 1.162 *************** *** 356,359 **** --- 356,360 ---- Eric Raymond Edward K. Ream + Marc Recht John Redford Terry Reedy From tim_one@users.sourceforge.net Fri Mar 1 21:40:31 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 01 Mar 2002 13:40:31 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv17907 Modified Files: datetime.py Log Message: Parameterize min year and max year (in part because the code doesn't match the docs). Arrange for failing asserts to display the offending value. Force integer division where appropriate. Force consistent order of evaluation when mixing unary minus with //. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** datetime.py 1 Mar 2002 21:00:49 -0000 1.1 --- datetime.py 1 Mar 2002 21:40:28 -0000 1.2 *************** *** 1,4 **** --- 1,7 ---- import time as _time + MINYEAR = 1 # XXX The design doc says 0 + MAXYEAR = 9999 # XXX The design doc says 65535 + class basetime(object): """Abstract date/time type. *************** *** 34,52 **** def __init__(self, year, month, day, hour=0, minute=0, second=0, microsecond=0, tzoffset=None): ! assert 1 <= year <= 9999 ! assert 1 <= month <= 12 ! assert 1 <= day <= 31 # XXX calendrical check ! assert 0 <= hour <= 23 ! assert 0 <= minute <= 59 ! assert 0 <= second <= 59 ! assert 0 <= microsecond <= 999999 if tzoffset is None: if datetime.__isdst is None: datetime.__isdst = _time.localtime()[-1] if datetime.__isdst > 0: ! tzoffset = -(_time.altzone/60) else: ! tzoffset = -(_time.timezone/60) ! assert -1439 <= tzoffset <= 1439 self.__year = year self.__month = month --- 37,55 ---- def __init__(self, year, month, day, hour=0, minute=0, second=0, microsecond=0, tzoffset=None): ! assert MINYEAR <= year <= MAXYEAR, year ! assert 1 <= month <= 12, month ! assert 1 <= day <= 31, day # XXX calendrical check ! assert 0 <= hour <= 23, hour ! assert 0 <= minute <= 59, minute ! assert 0 <= second <= 59, second ! assert 0 <= microsecond <= 999999, microsecond if tzoffset is None: if datetime.__isdst is None: datetime.__isdst = _time.localtime()[-1] if datetime.__isdst > 0: ! tzoffset = -(_time.altzone // 60) else: ! tzoffset = -(_time.timezone // 60) ! assert -1439 <= tzoffset <= 1439, tzoffset self.__year = year self.__month = month *************** *** 66,72 **** us = int((t % 1.0) * 1000000) if dst > 0: ! tz = - _time.altzone/60 else: ! tz = - _time.timezone/60 return cls(y, m, d, hh, mm, ss, us, tz) fromtimestamp = classmethod(fromtimestamp) --- 69,75 ---- us = int((t % 1.0) * 1000000) if dst > 0: ! tz = -(_time.altzone // 60) else: ! tz = -(_time.timezone // 60) return cls(y, m, d, hh, mm, ss, us, tz) fromtimestamp = classmethod(fromtimestamp) *************** *** 89,93 **** # Read-only field accessors ! year = property(lambda self: self.__year, doc="year (1-9999)") month = property(lambda self: self.__month, doc="month (1-12)") day = property(lambda self: self.__day, doc="day (1-31)") --- 92,97 ---- # Read-only field accessors ! year = property(lambda self: self.__year, ! doc="year (%d-%d)" % (MINYEAR, MAXYEAR)) month = property(lambda self: self.__month, doc="month (1-12)") day = property(lambda self: self.__day, doc="day (1-31)") From gvanrossum@users.sourceforge.net Fri Mar 1 22:19:43 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 01 Mar 2002 14:19:43 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv28789 Modified Files: datetime.py Log Message: __cmp__ must raise an error when other isn't a datetime, otherwise the default (meaningless) comparison will be used. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** datetime.py 1 Mar 2002 21:40:28 -0000 1.2 --- datetime.py 1 Mar 2002 22:19:41 -0000 1.3 *************** *** 139,143 **** return cmp(self._timestamp(), other._timestamp()) else: ! return NotImplemented def __hash__(self): --- 139,144 ---- return cmp(self._timestamp(), other._timestamp()) else: ! raise TypeError, ("can't compare datetime to %s instance" % ! type(other).__name__) def __hash__(self): From gvanrossum@users.sourceforge.net Fri Mar 1 22:23:55 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 01 Mar 2002 14:23:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects abstract.c,2.94,2.95 object.c,2.162,2.163 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv29045 Modified Files: abstract.c object.c Log Message: SF patch 514641 (Naofumi Honda) - Negative ob_size of LongObjects Due to the bizarre definition of _PyLong_Copy(), creating an instance of a subclass of long with a negative value could cause core dumps later on. Unfortunately it looks like the behavior of _PyLong_Copy() is quite intentional, so the fix is more work than feels comfortable. This fix is almost, but not quite, the code that Naofumi Honda added; in addition, I added a test case. Index: abstract.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v retrieving revision 2.94 retrieving revision 2.95 diff -C2 -d -r2.94 -r2.95 *** abstract.c 5 Jan 2002 10:50:30 -0000 2.94 --- abstract.c 1 Mar 2002 22:23:53 -0000 2.95 *************** *** 934,939 **** return o; } ! if (PyLong_Check(o)) ! return _PyLong_Copy((PyLongObject *)o); if (PyString_Check(o)) /* need to do extra error checking that PyLong_FromString() --- 934,947 ---- return o; } ! if (PyLong_Check(o)) { ! PyObject *res; ! ! res = _PyLong_Copy((PyLongObject *)o); ! if (res != NULL) ! ((PyLongObject *)res)->ob_size = ! ((PyLongObject *)o)->ob_size; ! ! return res; ! } if (PyString_Check(o)) /* need to do extra error checking that PyLong_FromString() Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.162 retrieving revision 2.163 diff -C2 -d -r2.162 -r2.163 *** object.c 4 Dec 2001 15:54:53 -0000 2.162 --- object.c 1 Mar 2002 22:23:53 -0000 2.163 *************** *** 1192,1197 **** return NULL; if (dictoffset < 0) { ! const size_t size = _PyObject_VAR_SIZE(tp, ! ((PyVarObject *)obj)->ob_size); dictoffset += (long)size; assert(dictoffset > 0); --- 1192,1203 ---- return NULL; if (dictoffset < 0) { ! int tsize; ! size_t size; ! ! tsize = ((PyVarObject *)obj)->ob_size; ! if (tsize < 0) ! tsize = -tsize; ! size = _PyObject_VAR_SIZE(tp, tsize); ! dictoffset += (long)size; assert(dictoffset > 0); From gvanrossum@users.sourceforge.net Fri Mar 1 22:24:26 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 01 Mar 2002 14:24:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.114,1.115 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv30224 Modified Files: test_descr.py Log Message: SF patch 514641 (Naofumi Honda) - Negative ob_size of LongObjects Due to the bizarre definition of _PyLong_Copy(), creating an instance of a subclass of long with a negative value could cause core dumps later on. Unfortunately it looks like the behavior of _PyLong_Copy() is quite intentional, so the fix is more work than feels comfortable. This fix is almost, but not quite, the code that Naofumi Honda added; in addition, I added a test case. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.114 retrieving revision 1.115 diff -C2 -d -r1.114 -r1.115 *** test_descr.py 28 Dec 2001 21:39:03 -0000 1.114 --- test_descr.py 1 Mar 2002 22:24:24 -0000 1.115 *************** *** 1749,1752 **** --- 1749,1756 ---- verify((0 + a).__class__ is long) + # Check that negative clones don't segfault + a = longclone(-1) + vereq(a.__dict__, {}) + class precfloat(float): __slots__ = ['prec'] From gvanrossum@users.sourceforge.net Fri Mar 1 22:24:51 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 01 Mar 2002 14:24:51 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc ACKS,1.162,1.163 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv30349 Modified Files: ACKS Log Message: SF patch 514641 (Naofumi Honda) - Negative ob_size of LongObjects Due to the bizarre definition of _PyLong_Copy(), creating an instance of a subclass of long with a negative value could cause core dumps later on. Unfortunately it looks like the behavior of _PyLong_Copy() is quite intentional, so the fix is more work than feels comfortable. This fix is almost, but not quite, the code that Naofumi Honda added; in addition, I added a test case. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.162 retrieving revision 1.163 diff -C2 -d -r1.162 -r1.163 *** ACKS 1 Mar 2002 21:31:27 -0000 1.162 --- ACKS 1 Mar 2002 22:24:49 -0000 1.163 *************** *** 204,207 **** --- 204,208 ---- Gerrit Holl Philip Homburg + Naofumi Honda Jeffrey Honig Rob Hooft From bwarsaw@users.sourceforge.net Fri Mar 1 22:39:16 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Fri, 01 Mar 2002 14:39:16 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib mailbox.py,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv1556 Modified Files: mailbox.py Log Message: Added PortableUnixMailbox to the __all__ variable, and in the __main__ section use this class instead of UnixMailbox as per the comments in the latter's class. Bug fix candidate for 2.2.1. Index: mailbox.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mailbox.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** mailbox.py 13 Sep 2001 01:29:13 -0000 1.33 --- mailbox.py 1 Mar 2002 22:39:14 -0000 1.34 *************** *** 7,11 **** import os ! __all__ = ["UnixMailbox","MmdfMailbox","MHMailbox","Maildir","BabylMailbox"] class _Mailbox: --- 7,12 ---- import os ! __all__ = ["UnixMailbox","MmdfMailbox","MHMailbox","Maildir","BabylMailbox", ! "PortableUnixMailbox"] class _Mailbox: *************** *** 92,95 **** --- 93,97 ---- + # Recommended to use PortableUnixMailbox instead! class UnixMailbox(_Mailbox): def _search_start(self): *************** *** 283,287 **** else: fp = open(mbox, 'r') ! mb = UnixMailbox(fp) msgs = [] --- 285,289 ---- else: fp = open(mbox, 'r') ! mb = PortableUnixMailbox(fp) msgs = [] From tim_one@users.sourceforge.net Fri Mar 1 22:42:30 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 01 Mar 2002 14:42:30 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.3,1.4 test_datetime.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv1524 Modified Files: datetime.py test_datetime.py Log Message: Incorporate a pile of utility functions from Demo/classes/Dates.py, which also assumes the Gregorian calender indefinitely extended. In particular, this gives us _date2num() and _num2date() utilities that establish a bijection between datetime objects and a contiguous range of integers, such that consecutive days are associated with consecutive integers. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** datetime.py 1 Mar 2002 22:19:41 -0000 1.3 --- datetime.py 1 Mar 2002 22:42:28 -0000 1.4 *************** *** 4,7 **** --- 4,75 ---- MAXYEAR = 9999 # XXX The design doc says 65535 + # Utility functions, adapted from Python's Demo/classes/Dates.py, which + # also assumes the current Gregorian calendar indefinitely extended in + # both directions. + + _DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] + + _DAYS_BEFORE_MONTH = [] + dbm = 0 + for dim in _DAYS_IN_MONTH: + _DAYS_BEFORE_MONTH.append(dbm) + dbm = dbm + dim + del dbm, dim + + def _is_leap(year): + "year -> 1 if leap year, else 0." + return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) + + def _days_in_year(year): + "year -> number of days in year (366 if a leap year, else 365)." + return 365 + _is_leap(year) + + def _days_before_year(year): + "year -> number of days before January 1st of year." + return year*365 + (year+3)//4 - (year+99)//100 + (year+399)//400 + + def _days_in_month(month, year): + "month, year -> number of days in that month in that year." + assert 1 <= month <= 12, month + if month == 2 and _is_leap(year): + return 29 + return _DAYS_IN_MONTH[month-1] + + def _days_before_month(month, year): + "month, year -> number of days in year preceeding first day of month." + return _DAYS_BEFORE_MONTH[month-1] + (month > 2 and _is_leap(year)) + + def _date2num(date): + "datetime object -> day ordinal, considering 01-Jan-0000 as day 1." + assert isinstance(date, datetime) + return (_days_before_year(date.year) + + _days_before_month(date.month, date.year) + + date.day) + + _DI400Y = _days_before_year(400) # number of days in 400 years + + def _num2date(n): + "day ordinal -> datetime object." + + n400 = (n-1) // _DI400Y # number of 400-year blocks preceding + year = n400 * 400 + n -= n400 * _DI400Y + + more = n // 365 + dby = _days_before_year(more) + if dby >= n: + more -= 1 + dby -= _days_in_year(more) + year += more + n -= dby + + month = min(n//29 + 1, 12) + dbm = _days_before_month(month, year) + if dbm >= n: + month -= 1 + dbm -= _days_in_month(month, year) + + return datetime(year, month, n-dbm) + class basetime(object): """Abstract date/time type. Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_datetime.py 1 Mar 2002 21:00:49 -0000 1.1 --- test_datetime.py 1 Mar 2002 22:42:28 -0000 1.2 *************** *** 27,30 **** --- 27,39 ---- self.assert_(dt2 > dt3) + def test_ordinal_conversions(self): + import datetime as _datetime + for year in range(_datetime.MINYEAR, _datetime.MAXYEAR + 1): + for month, day in (1, 1), (12, 31), (6, 17): + base = datetime(year, month, day) + ordinal = _datetime._date2num(base) + derived = _datetime._num2date(ordinal) + self.assertEqual(base, derived) + def test_suite(): s1 = unittest.makeSuite(TestDateTime, 'test') From tim_one@users.sourceforge.net Fri Mar 1 22:53:45 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 01 Mar 2002 14:53:45 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv5305 Modified Files: datetime.py Log Message: Cut the number of rounding errors in datetime._timestamp(). Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** datetime.py 1 Mar 2002 22:42:28 -0000 1.4 --- datetime.py 1 Mar 2002 22:53:43 -0000 1.5 *************** *** 182,186 **** def _timestamp(self): # Helper like _mktime() that adds microseconds ! return self._mktime() + 0.000001 * self.__microsecond def timetuple(self): --- 182,186 ---- def _timestamp(self): # Helper like _mktime() that adds microseconds ! return self._mktime() + self.__microsecond / 1e6 def timetuple(self): From tim.one@comcast.net Fri Mar 1 23:18:34 2002 From: tim.one@comcast.net (Tim Peters) Date: Fri, 01 Mar 2002 18:18:34 -0500 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.114,1.115 In-Reply-To: Message-ID: [Guido] > Due to the bizarre definition of _PyLong_Copy(), creating an instance > of a subclass of long with a negative value could cause core dumps > later on. Unfortunately it looks like the behavior of _PyLong_Copy() > is quite intentional, so the fix is more work than feels comfortable. What specifically is bizarre? Looks to me like _PyLong_Copy() is plain wrong, and I probably wrote it . result->ob_size = i; should be result->ob_size = src->ob_size; if I'm guessing what bizarre means to you. Is that what you mean, or something else? The bizarreness *begins* with that _longobject fakes a PyObject_VAR_HEAD header by hand, then abuses the ob_size member to store the sign bit of the long as well as the number of bytes. So I expect there was more than one bug here (and that _PyLong_Copy() is one of them). From tim_one@users.sourceforge.net Fri Mar 1 23:53:49 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 01 Mar 2002 15:53:49 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.5,1.6 test_datetime.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv20152 Modified Files: datetime.py test_datetime.py Log Message: Change constructor to raise ValueError on out-of-range arguments instead of assert-failing. Change day range test to use the correct largest day number for the given month and year. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** datetime.py 1 Mar 2002 22:53:43 -0000 1.5 --- datetime.py 1 Mar 2002 23:53:47 -0000 1.6 *************** *** 105,115 **** def __init__(self, year, month, day, hour=0, minute=0, second=0, microsecond=0, tzoffset=None): ! assert MINYEAR <= year <= MAXYEAR, year ! assert 1 <= month <= 12, month ! assert 1 <= day <= 31, day # XXX calendrical check ! assert 0 <= hour <= 23, hour ! assert 0 <= minute <= 59, minute ! assert 0 <= second <= 59, second ! assert 0 <= microsecond <= 999999, microsecond if tzoffset is None: if datetime.__isdst is None: --- 105,124 ---- def __init__(self, year, month, day, hour=0, minute=0, second=0, microsecond=0, tzoffset=None): ! if not MINYEAR <= year <= MAXYEAR: ! raise ValueError('year must be in %d..%d' % (MINYEAR, MAXYEAR), ! year) ! if not 1 <= month <= 12: ! raise ValueError('month must be in 1..12', month) ! dim = _days_in_month(month, year) ! if not 1 <= day <= dim: ! raise ValueError('day must be in 1..%d' % dim, day) ! if not 0 <= hour <= 23: ! raise ValueError('hour must be in 0..23', hour) ! if not 0 <= minute <= 59: ! raise ValueError('minute must be in 0..59', minute) ! if not 0 <= second <= 59: ! raise ValueError('second must be in 0..59', second) ! if not 0 <= microsecond <= 999999: ! raise ValueError('second must be in 0..999999', microsecond) if tzoffset is None: if datetime.__isdst is None: *************** *** 119,123 **** else: tzoffset = -(_time.timezone // 60) ! assert -1439 <= tzoffset <= 1439, tzoffset self.__year = year self.__month = month --- 128,133 ---- else: tzoffset = -(_time.timezone // 60) ! if not -1439 <= tzoffset <= 1439: ! raise ValueError('tzoffset must be in -1439..1439', tzoffset) self.__year = year self.__month = month Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_datetime.py 1 Mar 2002 22:42:28 -0000 1.2 --- test_datetime.py 1 Mar 2002 23:53:47 -0000 1.3 *************** *** 36,39 **** --- 36,78 ---- self.assertEqual(base, derived) + def test_bad_constructor_arguments(self): + from datetime import MINYEAR, MAXYEAR + # bad years + datetime(MINYEAR, 1, 1) # no exception + datetime(MAXYEAR, 1, 1) # no exception + self.assertRaises(ValueError, datetime, MINYEAR-1, 1, 1) + self.assertRaises(ValueError, datetime, MAXYEAR+1, 1, 1) + # bad months + datetime(2000, 1, 1) # no exception + datetime(2000, 12, 1) # no exception + self.assertRaises(ValueError, datetime, 2000, 0, 1) + self.assertRaises(ValueError, datetime, 2000, 13, 1) + # bad days + datetime(2000, 2, 29) # no exception + datetime(2004, 2, 29) # no exception + datetime(2400, 2, 29) # no exception + self.assertRaises(ValueError, datetime, 2000, 2, 30) + self.assertRaises(ValueError, datetime, 2001, 2, 29) + self.assertRaises(ValueError, datetime, 2100, 2, 29) + self.assertRaises(ValueError, datetime, 1900, 2, 29) + self.assertRaises(ValueError, datetime, 1900, 2, 29) + self.assertRaises(ValueError, datetime, 2000, 1, 0) + self.assertRaises(ValueError, datetime, 2000, 1, 32) + # bad hours + datetime(2000, 1, 31, 0) # no exception + datetime(2000, 1, 31, 23) # no exception + self.assertRaises(ValueError, datetime, 2000, 1, 31, -1) + self.assertRaises(ValueError, datetime, 2000, 1, 31, 24) + # bad minutes + datetime(2000, 1, 31, 23, 0) # no exception + datetime(2000, 1, 31, 23, 59) # no exception + self.assertRaises(ValueError, datetime, 2000, 1, 31, 23, -1) + self.assertRaises(ValueError, datetime, 2000, 1, 31, 23, 60) + # bad seconds + datetime(2000, 1, 31, 23, 59, 0) # no exception + datetime(2000, 1, 31, 23, 59, 59) # no exception + self.assertRaises(ValueError, datetime, 2000, 1, 31, 23, 59, -1) + self.assertRaises(ValueError, datetime, 2000, 1, 31, 23, 59, 60) + def test_suite(): s1 = unittest.makeSuite(TestDateTime, 'test') From tim_one@users.sourceforge.net Fri Mar 1 23:55:57 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 01 Mar 2002 15:55:57 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.6,1.7 test_datetime.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv21041 Modified Files: datetime.py test_datetime.py Log Message: Typo repair. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** datetime.py 1 Mar 2002 23:53:47 -0000 1.6 --- datetime.py 1 Mar 2002 23:55:55 -0000 1.7 *************** *** 120,124 **** raise ValueError('second must be in 0..59', second) if not 0 <= microsecond <= 999999: ! raise ValueError('second must be in 0..999999', microsecond) if tzoffset is None: if datetime.__isdst is None: --- 120,124 ---- raise ValueError('second must be in 0..59', second) if not 0 <= microsecond <= 999999: ! raise ValueError('microsecond must be in 0..999999', microsecond) if tzoffset is None: if datetime.__isdst is None: Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_datetime.py 1 Mar 2002 23:53:47 -0000 1.3 --- test_datetime.py 1 Mar 2002 23:55:55 -0000 1.4 *************** *** 56,60 **** self.assertRaises(ValueError, datetime, 2100, 2, 29) self.assertRaises(ValueError, datetime, 1900, 2, 29) - self.assertRaises(ValueError, datetime, 1900, 2, 29) self.assertRaises(ValueError, datetime, 2000, 1, 0) self.assertRaises(ValueError, datetime, 2000, 1, 32) --- 56,59 ---- From tim_one@users.sourceforge.net Sat Mar 2 00:09:57 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 01 Mar 2002 16:09:57 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv23990 Modified Files: datetime.py Log Message: Added XXX comment noting a nasty bug in datetime.__hash__(). Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** datetime.py 1 Mar 2002 23:55:55 -0000 1.7 --- datetime.py 2 Mar 2002 00:09:55 -0000 1.8 *************** *** 222,225 **** --- 222,228 ---- def __hash__(self): """Hash.""" + # XXX Bug: objects that compare equal must have equal hashcodes, + # XXX and two datetimes can be equal even if their fields aren't + # XXX (due to tzoffset). Do we have to hash the timestamp instead? y, m, d = self.__year, self.__month, self.__day hh, mm, ss = self.__hour, self.__minute, self.__second From tim_one@users.sourceforge.net Sat Mar 2 01:03:10 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 01 Mar 2002 17:03:10 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.8,1.9 test_datetime.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv2483 Modified Files: datetime.py test_datetime.py Log Message: Repair __hash__ so that equal values have equal hashcodes. This is done by normalizing (year, month, day, hour, minute) to UTC (and a new method computes that), then leaving tzoffset out of the hash computation. May not be cheap enough; normalizing to UTC *can* propagate all the way to the year (and a new test verifies that it can). Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** datetime.py 2 Mar 2002 00:09:55 -0000 1.8 --- datetime.py 2 Mar 2002 01:03:08 -0000 1.9 *************** *** 220,232 **** type(other).__name__) def __hash__(self): """Hash.""" ! # XXX Bug: objects that compare equal must have equal hashcodes, ! # XXX and two datetimes can be equal even if their fields aren't ! # XXX (due to tzoffset). Do we have to hash the timestamp instead? ! y, m, d = self.__year, self.__month, self.__day ! hh, mm, ss = self.__hour, self.__minute, self.__second ! us, tz = self.__microsecond, self.__tzoffset ! return hash((y, m, d, hh, mm, ss, us, tz)) def ctime(self): --- 220,265 ---- type(other).__name__) + def _utc_ymdHM(self): + "Return (year, month, day, hour, minute) in UTC equivalent." + y, m, d = self.__year, self.__month, self.__day + H, M = self.__hour, self.__minute + if self.__tzoffset: + M -= self.__tzoffset + if not 0 <= M <= 59: + carry, M = divmod(M, 60) + H += carry + if not 0 <= H <= 23: + carry, H = divmod(H, 24) + # tzoffset is less than a day, so carry is no more than 1. + if carry > 0: + assert carry == 1 + d += 1 + if d > _days_in_month(m, y): + d = 1 + m += 1 + if m > 12: + m = 1 + y += 1 + else: + assert carry == -1 + d -= 1 + if d == 0: + m -= 1 + if m > 0: + d = _days_in_month(m, y) + else: + d = 31 + m = 12 + y -= 1 + return y, m, d, H, M + def __hash__(self): """Hash.""" ! # Caution: objects that compare equal must have equal hashcodes, ! # and two datetimes can be equal even if their fields aren't ! # (due to tzoffset). So we have to compute a UTC-normalized hash. ! # XXX _utc_ymdHM can be expensive; dream up a quicker correct way. ! y, m, d, H, M = self._utc_ymdHM() ! return hash((y, m, d, H, M, self.__second, self.__microsecond)) def ctime(self): Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_datetime.py 1 Mar 2002 23:55:55 -0000 1.4 --- test_datetime.py 2 Mar 2002 01:03:08 -0000 1.5 *************** *** 74,77 **** --- 74,88 ---- self.assertRaises(ValueError, datetime, 2000, 1, 31, 23, 59, 60) + def test_hash_equality(self): + d = datetime(2000, 12, 31, 23, 30, 17, tzoffset=-35) + # same thing in UTC. + e = datetime(2001, 1, 1, 0, 5, 17, tzoffset=0) + self.assertEqual(hash(d), hash(e)) + + d = datetime(2001, 1, 1, 0, 5, 17, tzoffset=35) + # same thing in UTC. + e = datetime(2000, 12, 31, 23, 30, 17, tzoffset=0) + self.assertEqual(hash(d), hash(e)) + def test_suite(): s1 = unittest.makeSuite(TestDateTime, 'test') From tim_one@users.sourceforge.net Sat Mar 2 01:10:37 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 01 Mar 2002 17:10:37 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv5096 Modified Files: test_datetime.py Log Message: test_hash_equality(): assert that the objects are equal, as well as their hashes. Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_datetime.py 2 Mar 2002 01:03:08 -0000 1.5 --- test_datetime.py 2 Mar 2002 01:10:35 -0000 1.6 *************** *** 78,81 **** --- 78,82 ---- # same thing in UTC. e = datetime(2001, 1, 1, 0, 5, 17, tzoffset=0) + self.assertEqual(d, e) self.assertEqual(hash(d), hash(e)) *************** *** 83,86 **** --- 84,88 ---- # same thing in UTC. e = datetime(2000, 12, 31, 23, 30, 17, tzoffset=0) + self.assertEqual(d, e) self.assertEqual(hash(d), hash(e)) From tim_one@users.sourceforge.net Sat Mar 2 04:14:23 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 01 Mar 2002 20:14:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects abstract.c,2.95,2.96 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv9137 Modified Files: abstract.c Log Message: Revert the last odd change to PyNumber_Long: the problem it was trying to fix was almost certainly a bug in _PyLong_Copy (which I'll fix next). Index: abstract.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v retrieving revision 2.95 retrieving revision 2.96 diff -C2 -d -r2.95 -r2.96 *** abstract.c 1 Mar 2002 22:23:53 -0000 2.95 --- abstract.c 2 Mar 2002 04:14:21 -0000 2.96 *************** *** 934,947 **** return o; } ! if (PyLong_Check(o)) { ! PyObject *res; ! ! res = _PyLong_Copy((PyLongObject *)o); ! if (res != NULL) ! ((PyLongObject *)res)->ob_size = ! ((PyLongObject *)o)->ob_size; ! ! return res; ! } if (PyString_Check(o)) /* need to do extra error checking that PyLong_FromString() --- 934,939 ---- return o; } ! if (PyLong_Check(o)) ! return _PyLong_Copy((PyLongObject *)o); if (PyString_Check(o)) /* need to do extra error checking that PyLong_FromString() From tim_one@users.sourceforge.net Sat Mar 2 04:18:06 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 01 Mar 2002 20:18:06 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.115,1.116 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv9574/python/Lib/test Modified Files: test_descr.py Log Message: _PyLong_Copy(): was creating a copy of the absolute value, but should copy the sign too. Added a test to test_descr to ensure that it does. Bugfix candidate. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.115 retrieving revision 1.116 diff -C2 -d -r1.115 -r1.116 *** test_descr.py 1 Mar 2002 22:24:24 -0000 1.115 --- test_descr.py 2 Mar 2002 04:18:04 -0000 1.116 *************** *** 1752,1755 **** --- 1752,1756 ---- a = longclone(-1) vereq(a.__dict__, {}) + vereq(long(a), -1) # verify PyNumber_Long() copies the sign bit class precfloat(float): From tim_one@users.sourceforge.net Sat Mar 2 04:18:07 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 01 Mar 2002 20:18:07 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects longobject.c,1.113,1.114 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv9574/python/Objects Modified Files: longobject.c Log Message: _PyLong_Copy(): was creating a copy of the absolute value, but should copy the sign too. Added a test to test_descr to ensure that it does. Bugfix candidate. Index: longobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/longobject.c,v retrieving revision 1.113 retrieving revision 1.114 diff -C2 -d -r1.113 -r1.114 *** longobject.c 16 Feb 2002 23:39:10 -0000 1.113 --- longobject.c 2 Mar 2002 04:18:04 -0000 1.114 *************** *** 64,68 **** result = _PyLong_New(i); if (result != NULL) { ! result->ob_size = i; while (--i >= 0) result->ob_digit[i] = src->ob_digit[i]; --- 64,68 ---- result = _PyLong_New(i); if (result != NULL) { ! result->ob_size = src->ob_size; while (--i >= 0) result->ob_digit[i] = src->ob_digit[i]; From tim_one@users.sourceforge.net Sat Mar 2 04:33:11 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 01 Mar 2002 20:33:11 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include longintrepr.h,2.12,2.13 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv12140/python/Include Modified Files: longintrepr.h Log Message: For clarity, change _longobject to build directly from PyObject_VAR_HEAD instead of faking it by hand. It *is* a var object, and nothing but hysterical raisins to pretend it's an oddball. Index: longintrepr.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/longintrepr.h,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -d -r2.12 -r2.13 *** longintrepr.h 10 Sep 2001 20:52:47 -0000 2.12 --- longintrepr.h 2 Mar 2002 04:33:09 -0000 2.13 *************** *** 37,45 **** 0 <= ob_digit[i] <= MASK. The allocation function takes care of allocating extra memory ! so that ob_digit[0] ... ob_digit[abs(ob_size)-1] are actually available. */ struct _longobject { ! PyObject_HEAD ! int ob_size; digit ob_digit[1]; }; --- 37,48 ---- 0 <= ob_digit[i] <= MASK. The allocation function takes care of allocating extra memory ! so that ob_digit[0] ... ob_digit[abs(ob_size)-1] are actually available. ! ! CAUTION: Generic code manipulating subtypes of PyVarObject has to ! aware that longs abuse ob_size's sign bit. ! */ struct _longobject { ! PyObject_VAR_HEAD digit ob_digit[1]; }; From tim_one@users.sourceforge.net Sat Mar 2 08:43:21 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 02 Mar 2002 00:43:21 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects object.c,2.163,2.164 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv18886/python/Objects Modified Files: object.c Log Message: Whether platform malloc(0) returns NULL has nothing to do with whether platform realloc(p, 0) returns NULL, so MALLOC_ZERO_RETURNS_NULL can be correctly undefined yet realloc(p, 0) can return NULL anyway. Prevent realloc(p, 0) doing free(p) and returning NULL via a different hack. Would probably be better to get rid of MALLOC_ZERO_RETURNS_NULL entirely. Bugfix candidate. Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.163 retrieving revision 2.164 diff -C2 -d -r2.163 -r2.164 *** object.c 1 Mar 2002 22:23:53 -0000 2.163 --- object.c 2 Mar 2002 08:43:19 -0000 2.164 *************** *** 1895,1903 **** PyMem_Realloc(void *p, size_t nbytes) { ! #if _PyMem_EXTRA > 0 ! if (nbytes == 0) ! nbytes = _PyMem_EXTRA; ! #endif ! return PyMem_REALLOC(p, nbytes); } --- 1895,1900 ---- PyMem_Realloc(void *p, size_t nbytes) { ! /* See comment near MALLOC_ZERO_RETURNS_NULL in pyport.h. */ ! return PyMem_REALLOC(p, nbytes ? nbytes : 1); } From tim_one@users.sourceforge.net Sat Mar 2 08:43:21 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 02 Mar 2002 00:43:21 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include pymem.h,2.4,2.5 pyport.h,2.43,2.44 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv18886/python/Include Modified Files: pymem.h pyport.h Log Message: Whether platform malloc(0) returns NULL has nothing to do with whether platform realloc(p, 0) returns NULL, so MALLOC_ZERO_RETURNS_NULL can be correctly undefined yet realloc(p, 0) can return NULL anyway. Prevent realloc(p, 0) doing free(p) and returning NULL via a different hack. Would probably be better to get rid of MALLOC_ZERO_RETURNS_NULL entirely. Bugfix candidate. Index: pymem.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pymem.h,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -d -r2.4 -r2.5 *** pymem.h 26 Jul 2001 21:34:59 -0000 2.4 --- pymem.h 2 Mar 2002 08:43:19 -0000 2.5 *************** *** 112,122 **** #define PyMem_NEW(type, n) \ ( (type *) PyMem_MALLOC(_PyMem_EXTRA + (n) * sizeof(type)) ) ! #define PyMem_RESIZE(p, type, n) \ ! if ((p) == NULL) \ ! (p) = (type *)(PyMem_MALLOC( \ ! _PyMem_EXTRA + (n) * sizeof(type))); \ ! else \ ! (p) = (type *)(PyMem_REALLOC((p), \ ! _PyMem_EXTRA + (n) * sizeof(type))) #define PyMem_DEL(p) PyMem_FREE(p) --- 112,127 ---- #define PyMem_NEW(type, n) \ ( (type *) PyMem_MALLOC(_PyMem_EXTRA + (n) * sizeof(type)) ) ! ! /* See comment near MALLOC_ZERO_RETURNS_NULL in pyport.h. */ ! #define PyMem_RESIZE(p, type, n) \ ! do { \ ! size_t _sum = (n) * sizeof(type); \ ! if (!_sum) \ ! _sum = 1; \ ! (p) = (type *)((p) ? \ ! PyMem_REALLOC(p, _sum) : \ ! PyMem_MALLOC(_sum)); \ ! } while (0) ! #define PyMem_DEL(p) PyMem_FREE(p) Index: pyport.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pyport.h,v retrieving revision 2.43 retrieving revision 2.44 diff -C2 -d -r2.43 -r2.44 *** pyport.h 26 Feb 2002 11:20:01 -0000 2.43 --- pyport.h 2 Mar 2002 08:43:19 -0000 2.44 *************** *** 367,372 **** #ifdef MALLOC_ZERO_RETURNS_NULL ! /* XXX Always allocate one extra byte, since some malloc's return NULL ! XXX for malloc(0) or realloc(p, 0). */ #define _PyMem_EXTRA 1 #else --- 367,380 ---- #ifdef MALLOC_ZERO_RETURNS_NULL ! /* Allocate an extra byte if the platform malloc(0) returns NULL. ! Caution: this bears no relation to whether realloc(p, 0) returns NULL ! when p != NULL. Even on platforms where malloc(0) does not return NULL, ! realloc(p, 0) may act like free(p) and return NULL. Examples include ! Windows, and Python's own obmalloc.c (as of 2-Mar-2002). For whatever ! reason, our docs promise that PyMem_Realloc(p, 0) won't act like ! free(p) or return NULL, so realloc() calls may have to be hacked ! too, but MALLOC_ZERO_RETURNS_NULL's state is irrelevant to realloc (it ! needs a different hack). ! */ #define _PyMem_EXTRA 1 #else From jvr@users.sourceforge.net Sat Mar 2 10:20:46 2002 From: jvr@users.sourceforge.net (Just van Rossum) Date: Sat, 02 Mar 2002 02:20:46 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/cg CGStubLib,1.1,1.2 CGStubLib.exp,1.1,1.2 _CGmodule.c,1.3,1.4 cgsupport.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cg In directory usw-pr-cvs1:/tmp/cvs-serv2641 Modified Files: CGStubLib CGStubLib.exp _CGmodule.c cgsupport.py Log Message: Added support for SyncCGContextOriginWithPort(). Index: CGStubLib =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/CGStubLib,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvsoGvkHU and /tmp/cvsyUg6gF differ Index: CGStubLib.exp =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/CGStubLib.exp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CGStubLib.exp 13 Dec 2001 13:17:20 -0000 1.1 --- CGStubLib.exp 2 Mar 2002 10:20:44 -0000 1.2 *************** *** 57,58 **** --- 57,59 ---- CGContextRelease CreateCGContextForPort + SyncCGContextOriginWithPort Index: _CGmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/_CGmodule.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** _CGmodule.c 18 Dec 2001 15:38:24 -0000 1.3 --- _CGmodule.c 2 Mar 2002 10:20:44 -0000 1.4 *************** *** 1116,1119 **** --- 1116,1133 ---- } + static PyObject *CGContextRefObj_SyncCGContextOriginWithPort(CGContextRefObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + CGrafPtr port; + if (!PyArg_ParseTuple(_args, "O&", + GrafObj_Convert, &port)) + return NULL; + SyncCGContextOriginWithPort(_self->ob_itself, + port); + Py_INCREF(Py_None); + _res = Py_None; + return _res; + } + static PyMethodDef CGContextRefObj_methods[] = { {"CGContextSaveGState", (PyCFunction)CGContextRefObj_CGContextSaveGState, 1, *************** *** 1229,1232 **** --- 1243,1248 ---- {"CGContextSetShouldAntialias", (PyCFunction)CGContextRefObj_CGContextSetShouldAntialias, 1, "(int shouldAntialias) -> None"}, + {"SyncCGContextOriginWithPort", (PyCFunction)CGContextRefObj_SyncCGContextOriginWithPort, 1, + "(CGrafPtr port) -> None"}, {NULL, NULL, 0} }; Index: cgsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/cgsupport.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cgsupport.py 13 Dec 2001 13:40:04 -0000 1.2 --- cgsupport.py 2 Mar 2002 10:20:44 -0000 1.3 *************** *** 18,21 **** --- 18,22 ---- from macsupport import * + CGrafPtr = OpaqueByValueType("CGrafPtr", "GrafObj") # Create the type objects *************** *** 275,278 **** --- 276,286 ---- # ADD _methods initializer here execfile(INPUTFILE) + + # manual method, lives in Quickdraw.h + f = Method(void, 'SyncCGContextOriginWithPort', + (CGContextRef, 'ctx', InMode), + (CGrafPtr, 'port', InMode), + ) + CGContextRef_methods.append(f) CreateCGContextForPort_body = """\ From gvanrossum@users.sourceforge.net Sat Mar 2 13:59:34 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sat, 02 Mar 2002 05:59:34 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv14179 Modified Files: datetime.py Log Message: Add XXX comment about duplication with calendar.py. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** datetime.py 2 Mar 2002 01:03:08 -0000 1.9 --- datetime.py 2 Mar 2002 13:59:32 -0000 1.10 *************** *** 7,10 **** --- 7,11 ---- # also assumes the current Gregorian calendar indefinitely extended in # both directions. + # XXX Why not borrow from calendar.py? _DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] From guido@python.org Sat Mar 2 17:31:56 2002 From: guido@python.org (Guido van Rossum) Date: Sat, 02 Mar 2002 12:31:56 -0500 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.114,1.115 In-Reply-To: Your message of "Fri, 01 Mar 2002 18:18:34 EST." References: Message-ID: <200203021731.g22HVu715656@pcp742651pcs.reston01.va.comcast.net> > [Guido] > > Due to the bizarre definition of _PyLong_Copy(), creating an instance > > of a subclass of long with a negative value could cause core dumps > > later on. Unfortunately it looks like the behavior of _PyLong_Copy() > > is quite intentional, so the fix is more work than feels comfortable. > > What specifically is bizarre? Looks to me like _PyLong_Copy() is plain > wrong, and I probably wrote it . > > result->ob_size = i; > > should be > > result->ob_size = src->ob_size; > > if I'm guessing what bizarre means to you. > > Is that what you mean, or something else? I had misread the code and thought that long_pos() was depending on this property. But it isn't -- I somehow confused long_pos and long_abs. So thanks for fixing this. > The bizarreness *begins* with that _longobject fakes a > PyObject_VAR_HEAD header by hand, then abuses the ob_size member to > store the sign bit of the long as well as the number of bytes. So I > expect there was more than one bug here (and that _PyLong_Copy() is > one of them). I have half a feeling that the header was explicitly not using VAR_HEAD because it isn't quite a standard variable size object. But since PyLong_Type sets tp_itemsize, it really should be defined a variable size object. I wonder if there could be places where the assumption ob_size >= 0 is made. (I checked _PyObject_GetDictPtr() and it correctly checks for tsize < 0.) --Guido van Rossum (home page: http://www.python.org/~guido/) From tim.one@comcast.net Sat Mar 2 18:36:40 2002 From: tim.one@comcast.net (Tim Peters) Date: Sat, 02 Mar 2002 13:36:40 -0500 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.9,1.10 In-Reply-To: Message-ID: [Guido] > + # XXX Why not borrow from calendar.py? Primarily because it relies on platform mktime() and localtime(), which can't be counted on outside of 1970-2038. The Dates.py code is self-contained, and works for all years. Replace calendar's use of mktime() with something that works everywhere for all years, and you'd end up reinventing Dates.py. If we're going to recode this in C some day, it's vital to prototype algorithms that don't rely on inadequate C datetime functions. From tim.one@comcast.net Sat Mar 2 19:15:20 2002 From: tim.one@comcast.net (Tim Peters) Date: Sat, 02 Mar 2002 14:15:20 -0500 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.114,1.115 In-Reply-To: <200203021731.g22HVu715656@pcp742651pcs.reston01.va.comcast.net> Message-ID: [Guido, on _PyLong_Copy()] > I had misread the code and thought that long_pos() was depending on > this property. But it isn't -- I somehow confused long_pos and > long_abs. Ah, understandable. I'm glad we were looking at the same thing. > So thanks for fixing this. My pleasure. [on whether longs should use PyObject_VAR_HEAD] > I have half a feeling that the header was explicitly not using > VAR_HEAD because it isn't quite a standard variable size object. But > since PyLong_Type sets tp_itemsize, it really should be defined a > variable size object. In 2.2, pointers to long subtype instances can get cast to PyVarObject*, so I changed the decl to use VAR_HEAD, and added a caution there about the sign bit. > I wonder if there could be places where the assumption ob_size >= 0 is > made. (I checked _PyObject_GetDictPtr() and it correctly checks for > tsize < 0.) That's the only place I found that I believe can cast a pointer to a long subtype instance to a PyVarObject*. There are several hundred instances of ob_size in the codebase, though, so I wouldn't call this proof . From guido@python.org Sat Mar 2 20:42:48 2002 From: guido@python.org (Guido van Rossum) Date: Sat, 02 Mar 2002 15:42:48 -0500 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.9,1.10 In-Reply-To: Your message of "Sat, 02 Mar 2002 13:36:40 EST." References: Message-ID: <200203022042.g22Kgmv15937@pcp742651pcs.reston01.va.comcast.net> > [Guido] > > + # XXX Why not borrow from calendar.py? > > Primarily because it relies on platform mktime() and localtime(), > which can't be counted on outside of 1970-2038. The Dates.py code > is self-contained, and works for all years. Replace calendar's use > of mktime() with something that works everywhere for all years, and > you'd end up reinventing Dates.py. If we're going to recode this in > C some day, it's vital to prototype algorithms that don't rely on > inadequate C datetime functions. You're right, I missed that calendar.weekday() calls mktime() and localtime(). We're definitely going to recode this in C! --Guido van Rossum (home page: http://www.python.org/~guido/) From tim_one@users.sourceforge.net Sat Mar 2 20:42:49 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 02 Mar 2002 12:42:49 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.10,1.11 test_datetime.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv13899 Modified Files: datetime.py test_datetime.py Log Message: Fiddle to compute day ordinals consistent with the "proleptic Gregorian" calendar at the heart of Dershowitz and Reingold's "Calendrical Calculations" book. They're the experts, and they call 1 Jan 1 "day 1" (the Dates.py code called 1 Jan 0 "day 1" -- same calendar, different origin). Their book gives algorithms for converting between proleptic Gregorian ordinals and many other calendar systems, so supplying these ordinals should make life much easier for people with other needs. Note that we're going to need *some* form of ordinal conversion regardless, in order to get around C limitations on timestamps and mktime(). Bummer: while putting the origin at year 1 simplifies _days_before_year(), it makes the details in _num2date significantly harder to understand; it's a net loss in clarity. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** datetime.py 2 Mar 2002 13:59:32 -0000 1.10 --- datetime.py 2 Mar 2002 20:42:47 -0000 1.11 *************** *** 6,11 **** # Utility functions, adapted from Python's Demo/classes/Dates.py, which # also assumes the current Gregorian calendar indefinitely extended in ! # both directions. ! # XXX Why not borrow from calendar.py? _DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] --- 6,16 ---- # Utility functions, adapted from Python's Demo/classes/Dates.py, which # also assumes the current Gregorian calendar indefinitely extended in ! # both directions. Difference: Dates.py calls January 1 of year 0 day ! # number 1. The code here calls January 1 of year 1 day number 1. This is ! # to match the definition of the "proleptic Gregorian" calendar in Dershowitz ! # and Reingold's "Calendrical Calculations", where it's the base calendar ! # for all computations. See the book for algorithms for converting between ! # day ordinals in the proleptic Gregorian calendar and many other calendar ! # systems. _DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] *************** *** 28,32 **** def _days_before_year(year): "year -> number of days before January 1st of year." ! return year*365 + (year+3)//4 - (year+99)//100 + (year+399)//400 def _days_in_month(month, year): --- 33,38 ---- def _days_before_year(year): "year -> number of days before January 1st of year." ! y = year - 1 ! return y*365 + y//4 - y//100 + y//400 def _days_in_month(month, year): *************** *** 48,52 **** date.day) ! _DI400Y = _days_before_year(400) # number of days in 400 years def _num2date(n): --- 54,58 ---- date.day) ! _DI400Y = _days_before_year(401) # number of days in 400 years def _num2date(n): *************** *** 54,66 **** n400 = (n-1) // _DI400Y # number of 400-year blocks preceding ! year = n400 * 400 n -= n400 * _DI400Y more = n // 365 ! dby = _days_before_year(more) if dby >= n: - more -= 1 dby -= _days_in_year(more) year += more n -= dby --- 60,73 ---- n400 = (n-1) // _DI400Y # number of 400-year blocks preceding ! year = n400 * 400 + 1 n -= n400 * _DI400Y more = n // 365 ! dby = _days_before_year(more + 1) if dby >= n: dby -= _days_in_year(more) + more -= 1 year += more + assert n > dby n -= dby *************** *** 70,74 **** month -= 1 dbm -= _days_in_month(month, year) ! return datetime(year, month, n-dbm) --- 77,81 ---- month -= 1 dbm -= _days_in_month(month, year) ! assert n > dbm return datetime(year, month, n-dbm) Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_datetime.py 2 Mar 2002 01:10:35 -0000 1.6 --- test_datetime.py 2 Mar 2002 20:42:47 -0000 1.7 *************** *** 28,38 **** def test_ordinal_conversions(self): ! import datetime as _datetime ! for year in range(_datetime.MINYEAR, _datetime.MAXYEAR + 1): ! for month, day in (1, 1), (12, 31), (6, 17): ! base = datetime(year, month, day) ! ordinal = _datetime._date2num(base) ! derived = _datetime._num2date(ordinal) ! self.assertEqual(base, derived) def test_bad_constructor_arguments(self): --- 28,53 ---- def test_ordinal_conversions(self): ! from datetime import _date2num, _num2date, MINYEAR, MAXYEAR ! ! # Verify 1 Jan 1 has ordinal 1. ! one = datetime.new(1, 1, 1) ! self.assertEqual(_date2num(one), 1) ! self.assertEqual(_num2date(1), one) ! ! # The first example in "Calendrical Calculations". ! d = datetime.new(1945, 11, 12) ! self.assertEqual(_date2num(d), 710347) ! self.assertEqual(_num2date(710347), d) ! ! for year in range(MINYEAR, MAXYEAR + 1): ! base = datetime(year, 1, 1) ! ordinal = _date2num(base) ! derived = _num2date(ordinal) ! self.assertEqual(base, derived) ! if year > MINYEAR: ! # Verify that moving back a day gets to the end of year-1. ! lastyear = datetime(year-1, 12, 31) ! derived = _num2date(ordinal - 1) ! self.assertEqual(lastyear, derived) def test_bad_constructor_arguments(self): From gvanrossum@users.sourceforge.net Sat Mar 2 21:09:52 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sat, 02 Mar 2002 13:09:52 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.11,1.12 test_datetime.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv23789 Modified Files: datetime.py test_datetime.py Log Message: Add timedelta class, with unit tests. This doesn't yet interoperate with the datetime class, but will be on the next iteration. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** datetime.py 2 Mar 2002 20:42:47 -0000 1.11 --- datetime.py 2 Mar 2002 21:09:50 -0000 1.12 *************** *** 101,105 **** ! # XXX deltaobject? class datetime(basetime): --- 101,207 ---- ! class timedelta(object): ! """Represent the difference between two datetime objects. ! ! Supported operators: ! ! - add, subtract timedelta ! - unary plus, minus, abs ! - compare to timedelta ! - multiply, divide by int/long ! ! In addition, datetime supports subtraction of two datetime objects ! returning a timedelta, and addition or subtraction of a datetime ! and a timedelta giving a datetime. ! ! Representation: (days, seconds, microseconds). Why? Because I ! felt like it. ! """ ! ! def __init__(self, days=0, seconds=0, microseconds=0): ! s, us = divmod(microseconds, 1000000) ! assert us >= 0 ! d, s = divmod(s + seconds, 24*3600) ! assert s >= 0 ! d += days ! # d may be < 0 ! self.__days = d ! self.__seconds = s ! self.__microseconds = us ! ! def __repr__(self): ! if self.__microseconds: ! return "timedelta(%d, %d, %d)" % (self.__days, ! self.__seconds, ! self.__microseconds) ! if self.__seconds: ! return "timedelta(%d, %d)" % (self.__days, self.__seconds) ! return "timedelta(%d)" % self.__days ! ! days = property(lambda self: self.__days, doc="days") ! seconds = property(lambda self: self.__seconds, doc="seconds") ! microseconds = property(lambda self: self.__microseconds, ! doc="microseconds") ! ! def __add__(self, other): ! if isinstance(other, timedelta): ! return timedelta(self.__days + other.__days, ! self.__seconds + other.__seconds, ! self.__microseconds + other.__microseconds) ! return NotImplemented ! ! __radd__ = __add__ ! ! def __sub__(self, other): ! if isinstance(other, timedelta): ! return self + -other ! return NotImplemented ! ! def __rsub__(self, other): ! if isinstance(other, timedelta): ! return -self + other ! return NotImplemented ! ! def __neg__(self): ! return timedelta(-self.__days, -self.__seconds, -self.__microseconds) ! ! def __pos__(self): ! return self ! ! def __abs__(self): ! if self.__days < 0: ! return -self ! else: ! return self ! ! def __mul__(self, other): ! if isinstance(other, (int, long)): ! return timedelta(self.__days * other, ! self.__seconds * other, ! self.__microseconds * other) ! return NotImplemented ! ! __rmul__ = __mul__ ! ! def __div__(self, other): ! if isinstance(other, (int, long)): ! return timedelta(self.__days // other, ! self.__seconds // other, ! self.__microseconds // other) ! return NotImplemented ! ! __floordiv__ = __div__ ! ! def __cmp__(self, other): ! if not isinstance(other, timedelta): ! raise TypeError, ("can't compare timedelta to %s instance" % ! type(other).__name__) ! diff = self - other ! if diff.__days < 0: ! return -1 ! if diff.__days == 0 == diff.__seconds == diff.__microseconds: ! return 0 ! return 1 ! class datetime(basetime): Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_datetime.py 2 Mar 2002 20:42:47 -0000 1.7 --- test_datetime.py 2 Mar 2002 21:09:50 -0000 1.8 *************** *** 7,11 **** import unittest ! from datetime import datetime class TestDateTime(unittest.TestCase): --- 7,11 ---- import unittest ! from datetime import datetime, timedelta class TestDateTime(unittest.TestCase): *************** *** 101,104 **** --- 101,135 ---- self.assertEqual(d, e) self.assertEqual(hash(d), hash(e)) + + def test_timedelta(self): + a = timedelta(7) # One week + b = timedelta(0, 60) # One minute + c = timedelta(0, 0, 1000) # One millisecond + self.assertEqual(a+b+c, timedelta(7, 60, 1000)) + self.assertEqual(a-b, timedelta(6, 24*3600 - 60)) + self.assertEqual(-a, timedelta(-7)) + self.assertEqual(+a, timedelta(7)) + self.assertEqual(-b, timedelta(-1, 24*3600 - 60)) + self.assertEqual(-c, timedelta(-1, 24*3600 - 1, 999000)) + self.assertEqual(abs(a), a) + self.assertEqual(abs(-a), a) + self.assertEqual(timedelta(6, 24*3600), a) + self.assertEqual(timedelta(0, 0, 60*1000000), b) + self.assertEqual(a*10, timedelta(70)) + self.assertEqual(a*10, 10*a) + self.assertEqual(a*10L, 10*a) + self.assertEqual(b*10, timedelta(0, 600)) + self.assertEqual(10*b, timedelta(0, 600)) + self.assertEqual(b*10L, timedelta(0, 600)) + self.assertEqual(c*10, timedelta(0, 0, 10000)) + self.assertEqual(10*c, timedelta(0, 0, 10000)) + self.assertEqual(c*10L, timedelta(0, 0, 10000)) + self.assertEqual(a*-1, -a) + self.assertEqual(b*-2, -b-b) + self.assertEqual(c*-2, -c+-c) + self.assertEqual(b*(60*24), (b*60)*24) + self.assertEqual(b*(60*24), (60*b)*24) + self.assertEqual(c*1000, timedelta(0, 1)) + self.assertEqual(1000*c, timedelta(0, 1)) def test_suite(): From gvanrossum@users.sourceforge.net Sat Mar 2 22:33:49 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sat, 02 Mar 2002 14:33:49 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.12,1.13 test_datetime.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv12052 Modified Files: datetime.py test_datetime.py Log Message: - Add computations on datetime instances (__add__, __radd__ and __sub__) - Fix docstring of _date2num() - Add XXX comment about how we derive the default tzoffset - Add __repr__ and __str__ to class datetime - In _test(), run the tests from test_datetime Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** datetime.py 2 Mar 2002 21:09:50 -0000 1.12 --- datetime.py 2 Mar 2002 22:33:46 -0000 1.13 *************** *** 48,52 **** def _date2num(date): ! "datetime object -> day ordinal, considering 01-Jan-0000 as day 1." assert isinstance(date, datetime) return (_days_before_year(date.year) + --- 48,52 ---- def _date2num(date): ! "datetime object -> day ordinal, considering 01-Jan-0001 as day 1." assert isinstance(date, datetime) return (_days_before_year(date.year) + *************** *** 232,235 **** --- 232,237 ---- raise ValueError('microsecond must be in 0..999999', microsecond) if tzoffset is None: + # XXX This decides whether local time is DST or not once, + # and never changes its mind, regardless how long we run if datetime.__isdst is None: datetime.__isdst = _time.localtime()[-1] *************** *** 279,282 **** --- 281,302 ---- utcnow = classmethod(utcnow) + def __repr__(self): + L = [self.__year, self.__month, self.__day, # These are never zero + self.__hour, self.__minute, self.__second, self.__microsecond] + while L[-1] == 0: + del L[-1] + s = ", ".join(map(str, L)) + return "datetime(%s, tzoffset=%d)" % (s, self.__tzoffset) + + def __str__(self): + if self.__tzoffset == 0: + return self.ctime() + " UTC" + if self.__tzoffset > 0: + h, m = divmod(self.__tzoffset, 60) + else: + h, m = divmod(-self.__tzoffset, 60) + h = -h + return self.ctime() + " %+03d:%02d" % (h, m) + # Read-only field accessors year = property(lambda self: self.__year, *************** *** 385,398 **** return _time.strftime(fmt, _time.gmtime(self._mktime())) ! # __add__, __sub__? def _test(): ! now = _time.time() ! print _time.ctime(now) ! t = datetime.fromtimestamp(now) ! print t.ctime(), divmod(t.tzoffset, 60), t.hour ! u = datetime.utcfromtimestamp(now) ! print u.utcctime(), divmod(u.tzoffset, 60), u.hour ! assert t == u if __name__ == "__main__": --- 405,449 ---- return _time.strftime(fmt, _time.gmtime(self._mktime())) ! # Computations ! ! def __add__(self, other): ! if isinstance(other, timedelta): ! hh, mm, ss, us = (self.__hour, ! self.__minute, ! self.__second + other.seconds, ! self.__microsecond + other.microseconds) ! carry_ss, us = divmod(us, 1000000) ! carry_mm, ss = divmod(ss+carry_ss, 60) ! carry_hh, mm = divmod(mm+carry_mm, 60) ! days, hh = divmod(hh+carry_hh, 24) ! result = _num2date(days + other.days + _date2num(self)) ! result.__hour = hh ! result.__minute = mm ! result.__second = ss ! result.__microsecond = us ! result.__tzoffset = self.__tzoffset ! return result ! return NotImplemented ! ! __radd__ = __add__ ! ! def __sub__(self, other): ! if isinstance(other, timedelta): ! return self + -other ! if isinstance(other, datetime): ! days1 = _date2num(self) ! days2 = _date2num(other) ! secs1 = (self.__second + 60 * (self.__minute - self.__tzoffset) + ! self.__hour * 3600) ! secs2 = (other.__second + 60 * (other.__minute - other.__tzoffset) + ! other.__hour * 3600) ! return timedelta(days1 - days2, secs1 - secs2, ! self.__microsecond - other.__microsecond) ! return NotImplemented ! def _test(): ! import test_datetime ! test_datetime.test_main() if __name__ == "__main__": Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test_datetime.py 2 Mar 2002 21:09:50 -0000 1.8 --- test_datetime.py 2 Mar 2002 22:33:46 -0000 1.9 *************** *** 40,43 **** --- 40,44 ---- self.assertEqual(_num2date(710347), d) + # XXX To speed up this loop, use range(MINYEAR, MAXYEAR + 1, 11) for year in range(MINYEAR, MAXYEAR + 1): base = datetime(year, 1, 1) *************** *** 132,135 **** --- 133,184 ---- self.assertEqual(c*1000, timedelta(0, 1)) self.assertEqual(1000*c, timedelta(0, 1)) + + def test_computations(self): + a = datetime(2002, 1, 31) + b = datetime(1956, 1, 31) + diff = a-b + self.assertEqual(diff.days, 46*365 + len(range(1956, 2002, 4))) + self.assertEqual(diff.seconds, 0) + self.assertEqual(diff.microseconds, 0) + a = datetime(2002, 3, 2, 17, 6) + millisec = timedelta(0, 0, 1000) + hour = timedelta(0, 3600) + day = timedelta(1) + week = timedelta(7) + self.assertEqual(a + hour, datetime(2002, 3, 2, 18, 6)) + self.assertEqual(a + 10*hour, datetime(2002, 3, 3, 3, 6)) + self.assertEqual(a - hour, datetime(2002, 3, 2, 16, 6)) + self.assertEqual(a - hour, a + -hour) + self.assertEqual(a - 20*hour, datetime(2002, 3, 1, 21, 6)) + self.assertEqual(a + day, datetime(2002, 3, 3, 17, 6)) + self.assertEqual(a - day, datetime(2002, 3, 1, 17, 6)) + self.assertEqual(a + week, datetime(2002, 3, 9, 17, 6)) + self.assertEqual(a - week, datetime(2002, 2, 23, 17, 6)) + self.assertEqual(a + 52*week, datetime(2003, 3, 1, 17, 6)) + self.assertEqual(a - 52*week, datetime(2001, 3, 3, 17, 6)) + self.assertEqual((a + week) - a, week) + self.assertEqual((a + day) - a, day) + self.assertEqual((a + hour) - a, hour) + self.assertEqual((a + millisec) - a, millisec) + self.assertEqual((a - week) - a, -week) + self.assertEqual((a - day) - a, -day) + self.assertEqual((a - hour) - a, -hour) + self.assertEqual((a - millisec) - a, -millisec) + self.assertEqual(a - (a + week), -week) + self.assertEqual(a - (a + day), -day) + self.assertEqual(a - (a + hour), -hour) + self.assertEqual(a - (a + millisec), -millisec) + self.assertEqual(a - (a - week), week) + self.assertEqual(a - (a - day), day) + self.assertEqual(a - (a - hour), hour) + self.assertEqual(a - (a - millisec), millisec) + self.assertEqual(a + (week + day + hour + millisec), + datetime(2002, 3, 10, 18, 6, 0, 1000)) + self.assertEqual(a + (week + day + hour + millisec), + (((a + week) + day) + hour) + millisec) + self.assertEqual(a - (week + day + hour + millisec), + datetime(2002, 2, 22, 16, 5, 59, 999000)) + self.assertEqual(a - (week + day + hour + millisec), + (((a - week) - day) - hour) - millisec) def test_suite(): From gvanrossum@users.sourceforge.net Sat Mar 2 22:57:56 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sat, 02 Mar 2002 14:57:56 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv19164 Modified Files: datetime.py Log Message: - Add docstrings to all public methods. - Add module docstring. - Augment datetime class docstring. - Reformat mis-indented __sub__. - Add a few comments for groups of methods. - Change the _utc_ymdHM() docstring to a comment. - Change triple quotes around 1-line docstrings to regular quotes. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** datetime.py 2 Mar 2002 22:33:46 -0000 1.13 --- datetime.py 2 Mar 2002 22:57:54 -0000 1.14 *************** *** 1,2 **** --- 1,9 ---- + """Concrete date/time type -- prototype implemented in Python. + + See http://www.zope.org/Members/fdrake/DateTimeWiki/FrontPage + + See also http://dir.yahoo.com/Reference/calendars/ + """ + import time as _time *************** *** 206,212 **** class datetime(basetime): ! """Concrete date/time type -- prototype implemented in Python. ! See http://www.zope.org/Members/fdrake/DateTimeWiki/FrontPage """ --- 213,238 ---- class datetime(basetime): ! """Concrete date/time type. ! Constructors: ! ! __init__() == new() ! now(), utcnow() ! fromtimestamp(), utcfromtimestamp() ! ! Operators: ! ! __repr__, __str__ ! __cmp__, __hash__ ! __add__, __radd__, __sub__ (add/radd only with timedelta other arg) ! ! Methods: ! ! timetuple(), utctimetuple() ! ctime(), utcctime() ! strftime(), utcstrftime() ! ! Properties (readonly): ! year, month, day, hour, minute, second, microsecond, tzoffset """ *************** *** 215,218 **** --- 241,253 ---- def __init__(self, year, month, day, hour=0, minute=0, second=0, microsecond=0, tzoffset=None): + """Constructor. + + Arguments: + + year, month, day (required, base 1) + hour, minute, second, microsecond (default to zero) + tzoffset (minutes east of UTC; defaults to local time) + + """ if not MINYEAR <= year <= MAXYEAR: raise ValueError('year must be in %d..%d' % (MINYEAR, MAXYEAR), *************** *** 251,259 **** --- 286,298 ---- self.__tzoffset = tzoffset # minutes east of UTC + # Additional constructors + def new(cls, *args, **kwds): + "Constructor. Same arguments as __init__." return cls(*args, **kwds) new = classmethod(new) def fromtimestamp(cls, t): + "Construct a datetime from a POSIX timestamp (like time.time())." y, m, d, hh, mm, ss, weekday, jday, dst = _time.localtime(t) us = int((t % 1.0) * 1000000) *************** *** 266,269 **** --- 305,309 ---- def now(cls): + "Construct a datetime from time.time()." t = _time.time() return cls.fromtimestamp(t) *************** *** 271,274 **** --- 311,315 ---- def utcfromtimestamp(cls, t): + "Construct a UTC datetime from a POSIX timestamp (like time.time())." y, m, d, hh, mm, ss, weekday, jday, dst = _time.gmtime(t) us = int((t % 1.0) * 1000000) *************** *** 277,285 **** --- 318,330 ---- def utcnow(cls): + "Construct a UTC datetime from time.time()." t = _time.time() return cls.utcfromtimestamp(t) utcnow = classmethod(utcnow) + # Conversions to string + def __repr__(self): + "Convert to formal string, for repr()." L = [self.__year, self.__month, self.__day, # These are never zero self.__hour, self.__minute, self.__second, self.__microsecond] *************** *** 290,293 **** --- 335,339 ---- def __str__(self): + "Convert to pretty string, for str()." if self.__tzoffset == 0: return self.ctime() + " UTC" *************** *** 312,315 **** --- 358,363 ---- doc="time zone offset in minutes east of UTC") + # Standard conversions, __cmp__, __hash__ (and helpers) + def _mktime(self): # Helper to call time.mktime() *************** *** 325,337 **** def timetuple(self): ! """Return local time tuple compatible with time.localtime().""" return _time.localtime(self._mktime()) def utctimetuple(self): ! """Return UTC time tuple compatible with time.gmtime().""" return _time.gmtime(self._mktime()) def __cmp__(self, other): ! """Three-way comparison.""" if isinstance(other, datetime): if other.__tzoffset == self.__tzoffset: --- 373,385 ---- def timetuple(self): ! "Return local time tuple compatible with time.localtime()." return _time.localtime(self._mktime()) def utctimetuple(self): ! "Return UTC time tuple compatible with time.gmtime()." return _time.gmtime(self._mktime()) def __cmp__(self, other): ! "Three-way comparison." if isinstance(other, datetime): if other.__tzoffset == self.__tzoffset: *************** *** 351,355 **** def _utc_ymdHM(self): ! "Return (year, month, day, hour, minute) in UTC equivalent." y, m, d = self.__year, self.__month, self.__day H, M = self.__hour, self.__minute --- 399,403 ---- def _utc_ymdHM(self): ! # Helper to return (year, month, day, hour, minute) in UTC equivalent y, m, d = self.__year, self.__month, self.__day H, M = self.__hour, self.__minute *************** *** 385,389 **** def __hash__(self): ! """Hash.""" # Caution: objects that compare equal must have equal hashcodes, # and two datetimes can be equal even if their fields aren't --- 433,437 ---- def __hash__(self): ! "Hash." # Caution: objects that compare equal must have equal hashcodes, # and two datetimes can be equal even if their fields aren't *************** *** 393,406 **** --- 441,460 ---- return hash((y, m, d, H, M, self.__second, self.__microsecond)) + # Formatting methods + def ctime(self): + "Format a la ctime() in local time." return _time.strftime("%c", _time.localtime(self._mktime())) def strftime(self, fmt): + "Format using strftime() in local time." return _time.strftime(fmt, _time.localtime(self._mktime())) def utcctime(self): + "Format a la ctime() in UTC." return _time.strftime("%c", _time.gmtime(self._mktime())) def utcstrftime(self, fmt): + "Format using strftime() in UTC." return _time.strftime(fmt, _time.gmtime(self._mktime())) *************** *** 408,411 **** --- 462,466 ---- def __add__(self, other): + "Add a datetime to a timedelta." if isinstance(other, timedelta): hh, mm, ss, us = (self.__hour, *************** *** 429,444 **** def __sub__(self, other): ! if isinstance(other, timedelta): ! return self + -other ! if isinstance(other, datetime): ! days1 = _date2num(self) ! days2 = _date2num(other) ! secs1 = (self.__second + 60 * (self.__minute - self.__tzoffset) + ! self.__hour * 3600) ! secs2 = (other.__second + 60 * (other.__minute - other.__tzoffset) + ! other.__hour * 3600) ! return timedelta(days1 - days2, secs1 - secs2, ! self.__microsecond - other.__microsecond) ! return NotImplemented --- 484,502 ---- def __sub__(self, other): ! "Subtract two datetimes, or a datetime and a timedelta." ! if isinstance(other, timedelta): ! return self + -other ! if isinstance(other, datetime): ! days1 = _date2num(self) ! days2 = _date2num(other) ! secs1 = (self.__second + ! (self.__minute - self.__tzoffset) * 60 + ! self.__hour * 3600) ! secs2 = (other.__second + ! (other.__minute - other.__tzoffset) * 60 + ! other.__hour * 3600) ! return timedelta(days1 - days2, secs1 - secs2, ! self.__microsecond - other.__microsecond) ! return NotImplemented From gvanrossum@users.sourceforge.net Sat Mar 2 23:33:40 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sat, 02 Mar 2002 15:33:40 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.14,1.15 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv27887 Modified Files: datetime.py Log Message: Add __str__ to timedelta that returns something like "7 days, 1 hour, 1 minute, 18 seconds, 321623 microseconds" Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** datetime.py 2 Mar 2002 22:57:54 -0000 1.14 --- datetime.py 2 Mar 2002 23:33:38 -0000 1.15 *************** *** 146,149 **** --- 146,168 ---- return "timedelta(%d)" % self.__days + def __str__(self): + def plural(n): + return n, n != 1 and "s" or "" + L = [] + if self.__days: + L.append("%d day%s" % plural(self.__days)) + if self.__seconds: + mm, ss = divmod(self.__seconds, 60) + hh, mm = divmod(mm, 60) + if hh: + L.append("%d hour%s" % plural(hh)) + if mm: + L.append("%d minute%s" % plural(mm)) + if ss: + L.append("%d second%s" % plural(ss)) + if self.__microseconds: + L.append("%d microsecond%s" % plural(self.__microseconds)) + return ", ".join(L) + days = property(lambda self: self.__days, doc="days") seconds = property(lambda self: self.__seconds, doc="seconds") From tim_one@users.sourceforge.net Sun Mar 3 02:10:26 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 02 Mar 2002 18:10:26 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.15,1.16 test_datetime.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv23159 Modified Files: datetime.py test_datetime.py Log Message: Broke dependence of _num2date and _date2num on datetime objects, and renamed to _ord2ymd and _ymd2ord. Proper testing of these functions requires exercising negative ordinals and years, and using datetime objects blocked that. Added a datetime.fromordinal() constructor, and a toordinal() method. "Something like that" is needed for people who want to build other calendar systems on top of this basic one. Changed test_ordinal_conversions() to do exhaustive testing on both sides of the origin, and every 7th year across the datetime range. This is less testing than it was doing before, but the test runs much faster now than can be accounted for by that alone. I suspect it's avoiding object hair that makes the difference (the test uses _ord2ymd and _ymd2ord directly now, never constructing a datetime object). Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** datetime.py 2 Mar 2002 23:33:38 -0000 1.15 --- datetime.py 3 Mar 2002 02:10:24 -0000 1.16 *************** *** 52,68 **** def _days_before_month(month, year): "month, year -> number of days in year preceeding first day of month." return _DAYS_BEFORE_MONTH[month-1] + (month > 2 and _is_leap(year)) ! def _date2num(date): ! "datetime object -> day ordinal, considering 01-Jan-0001 as day 1." ! assert isinstance(date, datetime) ! return (_days_before_year(date.year) + ! _days_before_month(date.month, date.year) + ! date.day) _DI400Y = _days_before_year(401) # number of days in 400 years ! def _num2date(n): ! "day ordinal -> datetime object." n400 = (n-1) // _DI400Y # number of 400-year blocks preceding --- 52,74 ---- def _days_before_month(month, year): "month, year -> number of days in year preceeding first day of month." + if not 1 <= month <= 12: + raise ValueError('month must be in 1..12', month) return _DAYS_BEFORE_MONTH[month-1] + (month > 2 and _is_leap(year)) ! def _ymd2ord(year, month, day): ! "year, month, day -> ordinal, considering 01-Jan-0001 as day 1." ! if not 1 <= month <= 12: ! raise ValueError('month must be in 1..12', month) ! dim = _days_in_month(month, year) ! if not 1 <= day <= dim: ! raise ValueError('day must be in 1..%d' % dim, day) ! return (_days_before_year(year) + ! _days_before_month(month, year) + ! day) _DI400Y = _days_before_year(401) # number of days in 400 years ! def _ord2ymd(n): ! "ordinal -> (year, month, day), considering 01-Jan-0001 as day 1." n400 = (n-1) // _DI400Y # number of 400-year blocks preceding *************** *** 85,89 **** dbm -= _days_in_month(month, year) assert n > dbm ! return datetime(year, month, n-dbm) class basetime(object): --- 91,95 ---- dbm -= _days_in_month(month, year) assert n > dbm ! return year, month, n-dbm class basetime(object): *************** *** 239,242 **** --- 245,249 ---- now(), utcnow() fromtimestamp(), utcfromtimestamp() + fromordinal() Operators: *************** *** 251,254 **** --- 258,262 ---- ctime(), utcctime() strftime(), utcstrftime() + toordinal() Properties (readonly): *************** *** 342,345 **** --- 350,363 ---- utcnow = classmethod(utcnow) + def fromordinal(cls, n): + """Contruct a datetime from a proleptic Gregorian ordinal. + + January 1 of year 1 is day 1. Only the year, month and day are + non-zero in the result. + """ + y, m, d = _ord2ymd(n) + return cls(y, m, d) + fromordinal = classmethod(fromordinal) + # Conversions to string *************** *** 399,402 **** --- 417,428 ---- return _time.gmtime(self._mktime()) + def toordinal(self): + """Return proleptic Gregorian ordinal for the year, month and day. + + January 1 of year 1 is day 1. Only the year, month and day values + contribute to the result. + """ + return _ymd2ord(self.year, self.month, self.day) + def __cmp__(self, other): "Three-way comparison." *************** *** 491,495 **** carry_hh, mm = divmod(mm+carry_mm, 60) days, hh = divmod(hh+carry_hh, 24) ! result = _num2date(days + other.days + _date2num(self)) result.__hour = hh result.__minute = mm --- 517,521 ---- carry_hh, mm = divmod(mm+carry_mm, 60) days, hh = divmod(hh+carry_hh, 24) ! result = datetime.fromordinal(days + other.days + self.toordinal()) result.__hour = hh result.__minute = mm *************** *** 507,512 **** return self + -other if isinstance(other, datetime): ! days1 = _date2num(self) ! days2 = _date2num(other) secs1 = (self.__second + (self.__minute - self.__tzoffset) * 60 + --- 533,538 ---- return self + -other if isinstance(other, datetime): ! days1 = self.toordinal() ! days2 = other.toordinal() secs1 = (self.__second + (self.__minute - self.__tzoffset) * 60 + Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** test_datetime.py 2 Mar 2002 22:33:46 -0000 1.9 --- test_datetime.py 3 Mar 2002 02:10:24 -0000 1.10 *************** *** 28,54 **** def test_ordinal_conversions(self): ! from datetime import _date2num, _num2date, MINYEAR, MAXYEAR ! ! # Verify 1 Jan 1 has ordinal 1. ! one = datetime.new(1, 1, 1) ! self.assertEqual(_date2num(one), 1) ! self.assertEqual(_num2date(1), one) ! # The first example in "Calendrical Calculations". ! d = datetime.new(1945, 11, 12) ! self.assertEqual(_date2num(d), 710347) ! self.assertEqual(_num2date(710347), d) ! # XXX To speed up this loop, use range(MINYEAR, MAXYEAR + 1, 11) ! for year in range(MINYEAR, MAXYEAR + 1): ! base = datetime(year, 1, 1) ! ordinal = _date2num(base) ! derived = _num2date(ordinal) ! self.assertEqual(base, derived) ! if year > MINYEAR: ! # Verify that moving back a day gets to the end of year-1. ! lastyear = datetime(year-1, 12, 31) ! derived = _num2date(ordinal - 1) ! self.assertEqual(lastyear, derived) def test_bad_constructor_arguments(self): --- 28,52 ---- def test_ordinal_conversions(self): ! from datetime import _ymd2ord, _ord2ymd, MINYEAR, MAXYEAR ! # Check some fixed values. ! for y, m, d, n in [(1, 1, 1, 1), # calendar origin ! (0, 12, 31, 0), ! (0, 12, 30, -1), ! # first example from "Calendrical Calculations" ! (1945, 11, 12, 710347)]: ! self.assertEqual(n, _ymd2ord(y, m, d)) ! self.assertEqual((y, m, d), _ord2ymd(n)) ! # Check first and last days of year exhaustively across 2000 years ! # centered at the origin, and spottily over the whole range of ! # years datetime objects support. ! for year in range(-1001, 1002) + range(MINYEAR, MAXYEAR+1, 7): ! # Verify (year, 1, 1) -> ordinal -> y, m, d is identity. ! n = _ymd2ord(year, 1, 1) ! self.assertEqual((year, 1, 1), _ord2ymd(n)) ! # Verify that moving back a day gets to the end of year-1. ! self.assertEqual((year-1, 12, 31), _ord2ymd(n-1)) ! self.assertEqual(_ymd2ord(year-1, 12, 31), n-1) def test_bad_constructor_arguments(self): From tim_one@users.sourceforge.net Sun Mar 3 02:15:36 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 02 Mar 2002 18:15:36 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv25139 Modified Files: test_datetime.py Log Message: Added test_roundtrip(), to verify datetime->string->datetime identity, and to verify that a datetime object can be reconstructed exactly from its pieces. Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** test_datetime.py 3 Mar 2002 02:10:24 -0000 1.10 --- test_datetime.py 3 Mar 2002 02:15:34 -0000 1.11 *************** *** 20,23 **** --- 20,37 ---- self.assertEqual(dt.second, 0) + def test_roundtrip(self): + for dt in (datetime.new(1, 2, 3, 4, 5, 6, 7, 8), + datetime.now()): + # Verify dt -> string -> datetime identity. + s = repr(dt) + dt2 = eval(s) + self.assertEqual(dt, dt2) + + # Verify identity via reconstructing from pieces. + dt2 = datetime.new(dt.year, dt.month, dt.day, + dt.hour, dt.minute, dt.second, + dt.microsecond, dt.tzoffset) + self.assertEqual(dt, dt2) + def test_tz_independent_comparing(self): dt1 = datetime.new(2002, 3, 1, 9, 0, 0, tzoffset=-60) From gvanrossum@users.sourceforge.net Sun Mar 3 02:50:54 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sat, 02 Mar 2002 18:50:54 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.16,1.17 test_datetime.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv31633 Modified Files: datetime.py test_datetime.py Log Message: Add weekday() and iso_calendar() methods. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** datetime.py 3 Mar 2002 02:10:24 -0000 1.16 --- datetime.py 3 Mar 2002 02:50:52 -0000 1.17 *************** *** 545,548 **** --- 545,594 ---- return NotImplemented + # Day-of-the-week and week-of-the-year, according to ISO + + def weekday(self): + "Return day of the week, where Monday == 0 (according to ISO)." + # The constant 6 was obtained experimentally :-) + return (_ymd2ord(self.__year, self.__month, self.__day) + 6) % 7 + + def isocalendar(self): + """Return a 3-tuple containing ISO year, week number, and weekday. + + The first ISO week of the year is the (Mon-Sun) week + containing the year's first Thursday; everything rest derives + from that. + + Note that the first week is 1, but Monday is 0. + + ISO calendar algorithm taken from + http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm + """ + year = self.__year + week1monday = _isoweek1monday(year) + today = _ymd2ord(self.__year, self.__month, self.__day) + # Internally, week has origin 0 + week, day = divmod(today - week1monday, 7) + if week < 0: + year -= 1 + week1monday = _isoweek1monday(year) + week, day = divmod(today - week1monday, 7) + elif week >= 52: + if today >= _isoweek1monday(year+1): + year += 1 + week = 0 + return year, week+1, day + + + def _isoweek1monday(year): + # Helper to calculate the day number of the Monday starting week 1 + # XXX This could be done more efficiently + THURSDAY = 3 + firstday = _ymd2ord(year, 1, 1) + firstweekday = (firstday + 6) % 7 # See weekday() above + week1monday = firstday - firstweekday + if firstweekday > THURSDAY: + week1monday += 7 + return week1monday + def _test(): Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** test_datetime.py 3 Mar 2002 02:15:34 -0000 1.11 --- test_datetime.py 3 Mar 2002 02:50:52 -0000 1.12 *************** *** 194,197 **** --- 194,261 ---- (((a - week) - day) - hour) - millisec) + def test_weekday(self): + for i in range(7): + # March 4, 2002 is a Monday + self.assertEqual(datetime(2002, 3, 4+i).weekday(), i) + # January 2, 1956 is a Monday + self.assertEqual(datetime(1956, 1, 2+i).weekday(), i) + + def test_isocalendar(self): + # Check examples from + # http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm + for i in range(7): + d = datetime(2003, 12, 22+i) + self.assertEqual(d.isocalendar(), (2003, 52, i)) + d = datetime(2003, 12, 29) + timedelta(i) + self.assertEqual(d.isocalendar(), (2004, 1, i)) + d = datetime(2004, 1, 5+i) + self.assertEqual(d.isocalendar(), (2004, 2, i)) + d = datetime(2009, 12, 21+i) + self.assertEqual(d.isocalendar(), (2009, 52, i)) + d = datetime(2009, 12, 28) + timedelta(i) + self.assertEqual(d.isocalendar(), (2009, 53, i)) + d = datetime(2010, 1, 4+i) + self.assertEqual(d.isocalendar(), (2010, 1, i)) + + def test_iso_long_years(self): + # Calculate long ISO years and compare to table from + # http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm + ISO_LONG_YEARS_TABLE = """ + 4 32 60 88 + 9 37 65 93 + 15 43 71 99 + 20 48 76 + 26 54 82 + + 105 133 161 189 + 111 139 167 195 + 116 144 172 + 122 150 178 + 128 156 184 + + 201 229 257 285 + 207 235 263 291 + 212 240 268 296 + 218 246 274 + 224 252 280 + + 303 331 359 387 + 308 336 364 392 + 314 342 370 398 + 320 348 376 + 325 353 381 + """ + iso_long_years = map(int, ISO_LONG_YEARS_TABLE.split()) + iso_long_years.sort() + L = [] + for i in range(400): + d = datetime(2000+i, 12, 31) + d1 = datetime(1600+i, 12, 31) + self.assertEqual(d.isocalendar()[1:], d1.isocalendar()[1:]) + if d.isocalendar()[1] == 53: + L.append(i) + self.assertEqual(L, iso_long_years) + + def test_suite(): s1 = unittest.makeSuite(TestDateTime, 'test') From aimacintyre@users.sourceforge.net Sun Mar 3 02:59:18 2002 From: aimacintyre@users.sourceforge.net (Andrew I MacIntyre) Date: Sat, 02 Mar 2002 18:59:18 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _hotshot.c,1.14,1.15 dbmmodule.c,2.28,2.29 fcntlmodule.c,2.33,2.34 main.c,1.63,1.64 pwdmodule.c,1.27,1.28 readline.c,2.43,2.44 selectmodule.c,2.60,2.61 signalmodule.c,2.62,2.63 termios.c,2.33,2.34 timemodule.c,2.122,2.123 unicodedata.c,2.14,2.15 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv430 Modified Files: _hotshot.c dbmmodule.c fcntlmodule.c main.c pwdmodule.c readline.c selectmodule.c signalmodule.c termios.c timemodule.c unicodedata.c Log Message: OS/2 EMX port changes (Modules part of patch #450267): Modules/ _hotshot.c dbmmodule.c fcntlmodule.c main.c pwdmodule.c readline.c selectmodule.c signalmodule.c termios.c timemodule.c unicodedata.c Index: _hotshot.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_hotshot.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** _hotshot.c 12 Feb 2002 04:02:33 -0000 1.14 --- _hotshot.c 3 Mar 2002 02:59:15 -0000 1.15 *************** *** 27,31 **** #error "This module requires gettimeofday() on non-Windows platforms!" #endif ! #ifdef macintosh #include #else --- 27,31 ---- #error "This module requires gettimeofday() on non-Windows platforms!" #endif ! #if defined(macintosh) || (defined(PYOS_OS2) && defined(PYCC_GCC)) #include #else *************** *** 52,55 **** --- 52,59 ---- #endif + #if defined(PYOS_OS2) && defined(PYCC_GCC) + #define PATH_MAX 260 + #endif + #ifndef PATH_MAX # ifdef MAX_PATH *************** *** 988,992 **** #endif } ! #if defined(MS_WIN32) || defined(macintosh) rusage_diff = -1; #else --- 992,996 ---- #endif } ! #if defined(MS_WIN32) || defined(macintosh) || defined(PYOS_OS2) rusage_diff = -1; #else Index: dbmmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/dbmmodule.c,v retrieving revision 2.28 retrieving revision 2.29 diff -C2 -d -r2.28 -r2.29 *** dbmmodule.c 8 Dec 2001 18:02:56 -0000 2.28 --- dbmmodule.c 3 Mar 2002 02:59:15 -0000 2.29 *************** *** 14,18 **** --- 14,22 ---- #if defined(HAVE_NDBM_H) #include + #if defined(PYOS_OS2) && !defined(PYCC_GCC) static char *which_dbm = "ndbm"; + #else + static char *which_dbm = "GNU gdbm"; /* EMX port of GDBM */ + #endif #elif defined(HAVE_DB1_NDBM_H) #include Index: fcntlmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/fcntlmodule.c,v retrieving revision 2.33 retrieving revision 2.34 diff -C2 -d -r2.33 -r2.34 *** fcntlmodule.c 12 Jan 2002 11:05:06 -0000 2.33 --- fcntlmodule.c 3 Mar 2002 02:59:15 -0000 2.34 *************** *** 223,226 **** --- 223,231 ---- return NULL; + #if defined(PYOS_OS2) && defined(PYCC_GCC) + PyErr_SetString(PyExc_NotImplementedError, + "lockf not supported on OS/2 (EMX)"); + return NULL; + #else #ifndef LOCK_SH #define LOCK_SH 1 /* shared lock */ *************** *** 228,232 **** #define LOCK_NB 4 /* don't block when locking */ #define LOCK_UN 8 /* unlock */ ! #endif { struct flock l; --- 233,237 ---- #define LOCK_NB 4 /* don't block when locking */ #define LOCK_UN 8 /* unlock */ ! #endif /* LOCK_SH */ { struct flock l; *************** *** 276,279 **** --- 281,285 ---- Py_INCREF(Py_None); return Py_None; + #endif /* defined(PYOS_OS2) && defined(PYCC_GCC) */ } Index: main.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/main.c,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** main.c 11 Feb 2002 18:46:47 -0000 1.63 --- main.c 3 Mar 2002 02:59:16 -0000 1.64 *************** *** 9,16 **** #endif ! #if defined(PYOS_OS2) || defined(MS_WINDOWS) #define PYTHONHOMEHELP "\\lib" #else #define PYTHONHOMEHELP "/pythonX.X" #endif --- 9,20 ---- #endif ! #if (defined(PYOS_OS2) && !defined(PYCC_GCC)) || defined(MS_WINDOWS) #define PYTHONHOMEHELP "\\lib" #else + #if defined(PYOS_OS2) && defined(PYCC_GCC) + #define PYTHONHOMEHELP "/Lib" + #else #define PYTHONHOMEHELP "/pythonX.X" + #endif #endif Index: pwdmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pwdmodule.c,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** pwdmodule.c 1 Mar 2002 10:38:44 -0000 1.27 --- pwdmodule.c 3 Mar 2002 02:59:16 -0000 1.28 *************** *** 129,134 **** --- 129,138 ---- if ((d = PyList_New(0)) == NULL) return NULL; + #if defined(PYOS_OS2) && defined(PYCC_GCC) + if ((p = getpwuid(0)) != NULL) { + #else setpwent(); while ((p = getpwent()) != NULL) { + #endif PyObject *v = mkpwent(p); if (v == NULL || PyList_Append(d, v) != 0) { Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.43 retrieving revision 2.44 diff -C2 -d -r2.43 -r2.44 *** readline.c 13 Feb 2002 11:58:25 -0000 2.43 --- readline.c 3 Mar 2002 02:59:16 -0000 2.44 *************** *** 508,511 **** --- 508,515 ---- { rl_readline_name = "python"; + #if defined(PYOS_OS2) && defined(PYCC_GCC) + /* Allow $if term= in .inputrc to work */ + rl_terminal_name = getenv("TERM"); + #endif /* Force rebind of TAB to insert-tab */ rl_bind_key('\t', rl_insert); Index: selectmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/selectmodule.c,v retrieving revision 2.60 retrieving revision 2.61 diff -C2 -d -r2.60 -r2.61 *** selectmodule.c 12 Jan 2002 11:05:08 -0000 2.60 --- selectmodule.c 3 Mar 2002 02:59:16 -0000 2.61 *************** *** 34,38 **** #endif ! #if defined(PYOS_OS2) #include #include --- 34,38 ---- #endif ! #if defined(PYOS_OS2) && !defined(PYCC_GCC) #include #include Index: signalmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/signalmodule.c,v retrieving revision 2.62 retrieving revision 2.63 diff -C2 -d -r2.62 -r2.63 *** signalmodule.c 12 Jan 2002 11:43:25 -0000 2.62 --- signalmodule.c 3 Mar 2002 02:59:16 -0000 2.63 *************** *** 17,21 **** #endif ! #if defined(PYOS_OS2) #define NSIG 12 #include --- 17,21 ---- #endif ! #if defined(PYOS_OS2) && !defined(PYCC_GCC) #define NSIG 12 #include Index: termios.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/termios.c,v retrieving revision 2.33 retrieving revision 2.34 diff -C2 -d -r2.33 -r2.34 *** termios.c 14 Feb 2002 07:08:31 -0000 2.33 --- termios.c 3 Mar 2002 02:59:16 -0000 2.34 *************** *** 385,389 **** --- 385,391 ---- {"OLCUC", OLCUC}, #endif + #ifdef ONLCR {"ONLCR", ONLCR}, + #endif #ifdef OCRNL {"OCRNL", OCRNL}, *************** *** 553,557 **** --- 555,561 ---- {"VLNEXT", VLNEXT}, #endif + #ifdef VEOL2 {"VEOL2", VEOL2}, + #endif Index: timemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v retrieving revision 2.122 retrieving revision 2.123 diff -C2 -d -r2.122 -r2.123 *** timemodule.c 13 Feb 2002 05:14:18 -0000 2.122 --- timemodule.c 3 Mar 2002 02:59:16 -0000 2.123 *************** *** 55,58 **** --- 55,64 ---- #endif /* MS_WIN32 && !MS_WIN64 */ + #if defined(PYOS_OS2) + #define INCL_DOS + #define INCL_ERRORS + #include + #endif + #if defined(PYCC_VACPP) #include *************** *** 753,757 **** { /* XXX Should test for MS_WIN32 first! */ ! #if defined(HAVE_SELECT) && !defined(__BEOS__) struct timeval t; double frac; --- 759,763 ---- { /* XXX Should test for MS_WIN32 first! */ ! #if defined(HAVE_SELECT) && !defined(__BEOS__) && !defined(__EMX__) struct timeval t; double frac; Index: unicodedata.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/unicodedata.c,v retrieving revision 2.14 retrieving revision 2.15 diff -C2 -d -r2.14 -r2.15 *** unicodedata.c 30 Nov 2001 07:23:05 -0000 2.14 --- unicodedata.c 3 Mar 2002 02:59:16 -0000 2.15 *************** *** 278,282 **** static int ! _getname(Py_UCS4 code, char* buffer, int buflen) { int offset; --- 278,282 ---- static int ! _Py_getname(Py_UCS4 code, char* buffer, int buflen) { int offset; *************** *** 335,339 **** int i; char buffer[NAME_MAXLEN]; ! if (!_getname(code, buffer, sizeof(buffer))) return 0; for (i = 0; i < namelen; i++) { --- 335,339 ---- int i; char buffer[NAME_MAXLEN]; ! if (!_Py_getname(code, buffer, sizeof(buffer))) return 0; for (i = 0; i < namelen; i++) { *************** *** 385,389 **** { sizeof(_PyUnicode_Name_CAPI), ! _getname, _getcode }; --- 385,389 ---- { sizeof(_PyUnicode_Name_CAPI), ! _Py_getname, _getcode }; *************** *** 408,412 **** } ! if (!_getname((Py_UCS4) *PyUnicode_AS_UNICODE(v), name, sizeof(name))) { if (defobj == NULL) { --- 408,412 ---- } ! if (!_Py_getname((Py_UCS4) *PyUnicode_AS_UNICODE(v), name, sizeof(name))) { if (defobj == NULL) { From aimacintyre@users.sourceforge.net Sun Mar 3 03:03:54 2002 From: aimacintyre@users.sourceforge.net (Andrew I MacIntyre) Date: Sat, 02 Mar 2002 19:03:54 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules socketmodule.c,1.209,1.210 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv1397 Modified Files: socketmodule.c Log Message: OS/2 EMX port changes (Modules part of patch #450267): Modules/ socketmodule.c EMX handles sockets like Posix, rather than use native APIs Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.209 retrieving revision 1.210 diff -C2 -d -r1.209 -r1.210 *** socketmodule.c 1 Mar 2002 08:31:07 -0000 1.209 --- socketmodule.c 3 Mar 2002 03:03:52 -0000 1.210 *************** *** 228,232 **** #endif ! #if defined(PYOS_OS2) #define SOCKETCLOSE soclose #define NO_DUP /* Sockets are Not Actual File Handles under OS/2 */ --- 228,232 ---- #endif ! #if defined(PYOS_OS2) && !defined(PYCC_GCC) #define SOCKETCLOSE soclose #define NO_DUP /* Sockets are Not Actual File Handles under OS/2 */ *************** *** 353,357 **** #endif ! #if defined(PYOS_OS2) if (sock_errno() != NO_ERROR) { APIRET rc; --- 353,357 ---- #endif ! #if defined(PYOS_OS2) && !defined(PYCC_GCC) if (sock_errno() != NO_ERROR) { APIRET rc; *************** *** 932,936 **** #ifndef RISCOS #ifndef MS_WINDOWS ! #ifdef PYOS_OS2 block = !block; ioctl(s->sock_fd, FIONBIO, (caddr_t)&block, sizeof(block)); --- 932,936 ---- #ifndef RISCOS #ifndef MS_WINDOWS ! #if defined(PYOS_OS2) && !defined(PYCC_GCC) block = !block; ioctl(s->sock_fd, FIONBIO, (caddr_t)&block, sizeof(block)); *************** *** 1442,1446 **** n = recvfrom(s->sock_fd, PyString_AS_STRING(buf), len, flags, #ifndef MS_WINDOWS ! #if defined(PYOS_OS2) (struct sockaddr *)addrbuf, &addrlen #else --- 1442,1446 ---- n = recvfrom(s->sock_fd, PyString_AS_STRING(buf), len, flags, #ifndef MS_WINDOWS ! #if defined(PYOS_OS2) && !defined(PYCC_GCC) (struct sockaddr *)addrbuf, &addrlen #else *************** *** 2634,2637 **** --- 2634,2638 ---- OS2init(void) { + #if !defined(PYCC_GCC) char reason[64]; int rc = sock_init(); *************** *** 2647,2650 **** --- 2648,2655 ---- return 0; /* Indicate Failure */ + #else + /* no need to initialise sockets with GCC/EMX */ + return 1; + #endif } *************** *** 2696,2703 **** return; #else ! #if defined(__TOS_OS2__) if (!OS2init()) return; ! #endif /* __TOS_OS2__ */ #endif /* MS_WINDOWS */ #endif /* RISCOS */ --- 2701,2708 ---- return; #else ! #if defined(PYOS_OS2) if (!OS2init()) return; ! #endif /* PYOS_OS2 */ #endif /* MS_WINDOWS */ #endif /* RISCOS */ From aimacintyre@users.sourceforge.net Sun Mar 3 03:07:10 2002 From: aimacintyre@users.sourceforge.net (Andrew I MacIntyre) Date: Sat, 02 Mar 2002 19:07:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.222,2.223 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv1868 Modified Files: posixmodule.c Log Message: OS/2 EMX port changes (Modules part of patch #450267): Modules/ posixmodule.c - use SEP,ALTSEP #defines instead of hard coded path separator chars - use EMX specific variants of chdir2(),getcwd() that support drive letters - OS/2+EMX spawnv(),spawnve() support - EMX specific popen[234]() derived from Win32 popen[234]() code Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.222 retrieving revision 2.223 diff -C2 -d -r2.222 -r2.223 *** posixmodule.c 16 Feb 2002 23:33:23 -0000 2.222 --- posixmodule.c 3 Mar 2002 03:07:07 -0000 2.223 *************** *** 2,11 **** /* POSIX module implementation */ ! /* This file is also used for Windows NT and MS-Win. In that case the module ! actually calls itself 'nt', not 'posix', and a few functions are ! either unimplemented or implemented differently. The source assumes that for Windows NT, the macro 'MS_WIN32' is defined independent of the compiler used. Different compilers define their own feature ! test macro, e.g. '__BORLANDC__' or '_MSC_VER'. */ /* See also ../Dos/dosmodule.c */ --- 2,14 ---- /* POSIX module implementation */ ! /* This file is also used for Windows NT/MS-Win and OS/2. In that case the ! module actually calls itself 'nt' or 'os2', not 'posix', and a few ! functions are either unimplemented or implemented differently. The source assumes that for Windows NT, the macro 'MS_WIN32' is defined independent of the compiler used. Different compilers define their own feature ! test macro, e.g. '__BORLANDC__' or '_MSC_VER'. For OS/2, the compiler ! independent macro PYOS_OS2 should be defined. On OS/2 the default ! compiler is assumed to be IBM's VisualAge C++ (VACPP). PYCC_GCC is used ! as the compiler specific macro for the EMX port of gcc to OS/2. */ /* See also ../Dos/dosmodule.c */ *************** *** 26,29 **** --- 29,39 ---- #define INCL_NOPMAPI #include + #if defined(PYCC_GCC) + #include + #include + #include + #include + #include "osdefs.h" + #endif #endif *************** *** 82,85 **** --- 92,98 ---- #else /* 16-bit Windows */ #endif /* !MS_WIN32 */ + #else + #if defined(PYOS_OS2) && defined(PYCC_GCC) + /* Everything needed is defined in PC/os2emx/pyconfig.h */ #else /* all other compilers */ /* Unix functions that the configure script doesn't check for */ *************** *** 102,105 **** --- 115,119 ---- #define HAVE_WAIT 1 #define HAVE_TTYNAME 1 + #endif /* PYOS_OS2 && PYCC_GCC */ #endif /* _MSC_VER */ #endif /* __BORLANDC__ */ *************** *** 802,806 **** --- 816,824 ---- posix_chdir(PyObject *self, PyObject *args) { + #if defined(PYOS_OS2) && defined(PYCC_GCC) + return posix_1str(args, "et:chdir", _chdir2); + #else return posix_1str(args, "et:chdir", chdir); + #endif } *************** *** 913,917 **** --- 931,939 ---- return NULL; Py_BEGIN_ALLOW_THREADS + #if defined(PYOS_OS2) && defined(PYCC_GCC) + res = _getcwd2(buf, sizeof buf); + #else res = getcwd(buf, sizeof buf); + #endif Py_END_ALLOW_THREADS if (res == NULL) *************** *** 964,968 **** return NULL; ch = namebuf[len-1]; ! if (ch != '/' && ch != '\\' && ch != ':') namebuf[len++] = '/'; strcpy(namebuf + len, "*.*"); --- 986,990 ---- return NULL; ch = namebuf[len-1]; ! if (ch != SEP && ch != ALTSEP && ch != ':') namebuf[len++] = '/'; strcpy(namebuf + len, "*.*"); *************** *** 1023,1030 **** strcpy(namebuf, name); for (pt = namebuf; *pt; pt++) ! if (*pt == '/') ! *pt = '\\'; ! if (namebuf[len-1] != '\\') ! namebuf[len++] = '\\'; strcpy(namebuf + len, "*.*"); --- 1045,1052 ---- strcpy(namebuf, name); for (pt = namebuf; *pt; pt++) ! if (*pt == ALTSEP) ! *pt = SEP; ! if (namebuf[len-1] != SEP) ! namebuf[len++] = SEP; strcpy(namebuf + len, "*.*"); *************** *** 1087,1094 **** strcpy(namebuf, name); for (pt = namebuf; *pt; pt++) ! if (*pt == '/') ! *pt = '\\'; ! if (namebuf[len-1] != '\\') ! namebuf[len++] = '\\'; strcpy(namebuf + len, "*.*"); --- 1109,1116 ---- strcpy(namebuf, name); for (pt = namebuf; *pt; pt++) ! if (*pt == ALTSEP) ! *pt = SEP; ! if (namebuf[len-1] != SEP) ! namebuf[len++] = SEP; strcpy(namebuf + len, "*.*"); *************** *** 1111,1115 **** do { if (ep.achName[0] == '.' ! && (ep.achName[1] == '\0' || ep.achName[1] == '.' && ep.achName[2] == '\0')) continue; /* Skip Over "." and ".." Names */ --- 1133,1137 ---- do { if (ep.achName[0] == '.' ! && (ep.achName[1] == '\0' || (ep.achName[1] == '.' && ep.achName[2] == '\0'))) continue; /* Skip Over "." and ".." Names */ *************** *** 1705,1708 **** --- 1727,1735 ---- argvlist[argc] = NULL; + #if defined(PYOS_OS2) && defined(PYCC_GCC) + Py_BEGIN_ALLOW_THREADS + spawnval = spawnv(mode, path, argvlist); + Py_END_ALLOW_THREADS + #else if (mode == _OLD_P_OVERLAY) mode = _P_OVERLAY; *************** *** 1711,1714 **** --- 1738,1742 ---- spawnval = _spawnv(mode, path, argvlist); Py_END_ALLOW_THREADS + #endif PyMem_DEL(argvlist); *************** *** 1821,1824 **** --- 1849,1857 ---- envlist[envc] = 0; + #if defined(PYOS_OS2) && defined(PYCC_GCC) + Py_BEGIN_ALLOW_THREADS + spawnval = spawnve(mode, path, argvlist, envlist); + Py_END_ALLOW_THREADS + #else if (mode == _OLD_P_OVERLAY) mode = _P_OVERLAY; *************** *** 1827,1830 **** --- 1860,1864 ---- spawnval = _spawnve(mode, path, argvlist, envlist); Py_END_ALLOW_THREADS + #endif if (spawnval == -1) *************** *** 2178,2182 **** if (!PyArg_ParseTuple(args, "ii:kill", &pid, &sig)) return NULL; ! #if defined(PYOS_OS2) if (sig == XCPT_SIGNAL_INTR || sig == XCPT_SIGNAL_BREAK) { APIRET rc; --- 2212,2216 ---- if (!PyArg_ParseTuple(args, "ii:kill", &pid, &sig)) return NULL; ! #if defined(PYOS_OS2) && !defined(PYCC_GCC) if (sig == XCPT_SIGNAL_INTR || sig == XCPT_SIGNAL_BREAK) { APIRET rc; *************** *** 2248,2251 **** --- 2282,2286 ---- #if defined(PYOS_OS2) + #if defined(PYCC_VACPP) static int async_system(const char *command) *************** *** 2355,2358 **** --- 2390,3014 ---- } + #elif defined(PYCC_GCC) + + /* standard posix version of popen() support */ + static PyObject * + posix_popen(PyObject *self, PyObject *args) + { + char *name; + char *mode = "r"; + int bufsize = -1; + FILE *fp; + PyObject *f; + if (!PyArg_ParseTuple(args, "s|si:popen", &name, &mode, &bufsize)) + return NULL; + Py_BEGIN_ALLOW_THREADS + fp = popen(name, mode); + Py_END_ALLOW_THREADS + if (fp == NULL) + return posix_error(); + f = PyFile_FromFile(fp, name, mode, pclose); + if (f != NULL) + PyFile_SetBufSize(f, bufsize); + return f; + } + + /* fork() under OS/2 has lots'o'warts + * EMX supports pipe() and spawn*() so we can synthesize popen[234]() + * most of this code is a ripoff of the win32 code, but using the + * capabilities of EMX's C library routines + */ + + /* These tell _PyPopen() whether to return 1, 2, or 3 file objects. */ + #define POPEN_1 1 + #define POPEN_2 2 + #define POPEN_3 3 + #define POPEN_4 4 + + static PyObject *_PyPopen(char *, int, int, int); + static int _PyPclose(FILE *file); + + /* + * Internal dictionary mapping popen* file pointers to process handles, + * for use when retrieving the process exit code. See _PyPclose() below + * for more information on this dictionary's use. + */ + static PyObject *_PyPopenProcs = NULL; + + /* os2emx version of popen2() + * + * The result of this function is a pipe (file) connected to the + * process's stdin, and a pipe connected to the process's stdout. + */ + + static PyObject * + os2emx_popen2(PyObject *self, PyObject *args) + { + PyObject *f; + int tm=0; + + char *cmdstring; + char *mode = "t"; + int bufsize = -1; + if (!PyArg_ParseTuple(args, "s|si:popen2", &cmdstring, &mode, &bufsize)) + return NULL; + + if (*mode == 't') + tm = O_TEXT; + else if (*mode != 'b') { + PyErr_SetString(PyExc_ValueError, "mode must be 't' or 'b'"); + return NULL; + } else + tm = O_BINARY; + + f = _PyPopen(cmdstring, tm, POPEN_2, bufsize); + + return f; + } + + /* + * Variation on os2emx.popen2 + * + * The result of this function is 3 pipes - the process's stdin, + * stdout and stderr + */ + + static PyObject * + os2emx_popen3(PyObject *self, PyObject *args) + { + PyObject *f; + int tm = 0; + + char *cmdstring; + char *mode = "t"; + int bufsize = -1; + if (!PyArg_ParseTuple(args, "s|si:popen3", &cmdstring, &mode, &bufsize)) + return NULL; + + if (*mode == 't') + tm = O_TEXT; + else if (*mode != 'b') { + PyErr_SetString(PyExc_ValueError, "mode must be 't' or 'b'"); + return NULL; + } else + tm = O_BINARY; + + f = _PyPopen(cmdstring, tm, POPEN_3, bufsize); + + return f; + } + + /* + * Variation on os2emx.popen2 + * + * The result of this function is 2 pipes - the processes stdin, + * and stdout+stderr combined as a single pipe. + */ + + static PyObject * + os2emx_popen4(PyObject *self, PyObject *args) + { + PyObject *f; + int tm = 0; + + char *cmdstring; + char *mode = "t"; + int bufsize = -1; + if (!PyArg_ParseTuple(args, "s|si:popen4", &cmdstring, &mode, &bufsize)) + return NULL; + + if (*mode == 't') + tm = O_TEXT; + else if (*mode != 'b') { + PyErr_SetString(PyExc_ValueError, "mode must be 't' or 'b'"); + return NULL; + } else + tm = O_BINARY; + + f = _PyPopen(cmdstring, tm, POPEN_4, bufsize); + + return f; + } + + /* a couple of structures for convenient handling of multiple + * file handles and pipes + */ + struct file_ref + { + int handle; + int flags; + }; + + struct pipe_ref + { + int rd; + int wr; + }; + + /* The following code is derived from the win32 code */ + + static PyObject * + _PyPopen(char *cmdstring, int mode, int n, int bufsize) + { + struct file_ref stdio[3]; + struct pipe_ref p_fd[3]; + FILE *p_s[3]; + int file_count, i, pipe_err, pipe_pid; + char *shell, *sh_name, *opt, *rd_mode, *wr_mode; + PyObject *f, *p_f[3]; + + /* file modes for subsequent fdopen's on pipe handles */ + if (mode == O_TEXT) + { + rd_mode = "rt"; + wr_mode = "wt"; + } + else + { + rd_mode = "rb"; + wr_mode = "wb"; + } + + /* prepare shell references */ + if ((shell = getenv("EMXSHELL")) == NULL) + if ((shell = getenv("COMSPEC")) == NULL) + { + errno = ENOENT; + return posix_error(); + } + + sh_name = _getname(shell); + if (stricmp(sh_name, "cmd.exe") == 0 || stricmp(sh_name, "4os2.exe") == 0) + opt = "/c"; + else + opt = "-c"; + + /* save current stdio fds + their flags, and set not inheritable */ + i = pipe_err = 0; + while (pipe_err >= 0 && i < 3) + { + pipe_err = stdio[i].handle = dup(i); + stdio[i].flags = fcntl(i, F_GETFD, 0); + fcntl(stdio[i].handle, F_SETFD, stdio[i].flags | FD_CLOEXEC); + i++; + } + if (pipe_err < 0) + { + /* didn't get them all saved - clean up and bail out */ + int saved_err = errno; + while (i-- > 0) + { + close(stdio[i].handle); + } + errno = saved_err; + return posix_error(); + } + + /* create pipe ends */ + file_count = 2; + if (n == POPEN_3) + file_count = 3; + i = pipe_err = 0; + while ((pipe_err == 0) && (i < file_count)) + pipe_err = pipe((int *)&p_fd[i++]); + if (pipe_err < 0) + { + /* didn't get them all made - clean up and bail out */ + while (i-- > 0) + { + close(p_fd[i].wr); + close(p_fd[i].rd); + } + errno = EPIPE; + return posix_error(); + } + + /* change the actual standard IO streams over temporarily, + * making the retained pipe ends non-inheritable + */ + pipe_err = 0; + + /* - stdin */ + if (dup2(p_fd[0].rd, 0) == 0) + { + close(p_fd[0].rd); + i = fcntl(p_fd[0].wr, F_GETFD, 0); + fcntl(p_fd[0].wr, F_SETFD, i | FD_CLOEXEC); + if ((p_s[0] = fdopen(p_fd[0].wr, wr_mode)) == NULL) + { + close(p_fd[0].wr); + pipe_err = -1; + } + } + else + { + pipe_err = -1; + } + + /* - stdout */ + if (pipe_err == 0) + { + if (dup2(p_fd[1].wr, 1) == 1) + { + close(p_fd[1].wr); + i = fcntl(p_fd[1].rd, F_GETFD, 0); + fcntl(p_fd[1].rd, F_SETFD, i | FD_CLOEXEC); + if ((p_s[1] = fdopen(p_fd[1].rd, rd_mode)) == NULL) + { + close(p_fd[1].rd); + pipe_err = -1; + } + } + else + { + pipe_err = -1; + } + } + + /* - stderr, as required */ + if (pipe_err == 0) + switch (n) + { + case POPEN_3: + { + if (dup2(p_fd[2].wr, 2) == 2) + { + close(p_fd[2].wr); + i = fcntl(p_fd[2].rd, F_GETFD, 0); + fcntl(p_fd[2].rd, F_SETFD, i | FD_CLOEXEC); + if ((p_s[2] = fdopen(p_fd[2].rd, rd_mode)) == NULL) + { + close(p_fd[2].rd); + pipe_err = -1; + } + } + else + { + pipe_err = -1; + } + break; + } + + case POPEN_4: + { + if (dup2(1, 2) != 2) + { + pipe_err = -1; + } + break; + } + } + + /* spawn the child process */ + if (pipe_err == 0) + { + pipe_pid = spawnlp(P_NOWAIT, shell, shell, opt, cmdstring, (char *)0); + if (pipe_pid == -1) + { + pipe_err = -1; + } + else + { + /* save the PID into the FILE structure + * NOTE: this implementation doesn't actually + * take advantage of this, but do it for + * completeness - AIM Apr01 + */ + for (i = 0; i < file_count; i++) + p_s[i]->_pid = pipe_pid; + } + } + + /* reset standard IO to normal */ + for (i = 0; i < 3; i++) + { + dup2(stdio[i].handle, i); + fcntl(i, F_SETFD, stdio[i].flags); + close(stdio[i].handle); + } + + /* if any remnant problems, clean up and bail out */ + if (pipe_err < 0) + { + for (i = 0; i < 3; i++) + { + close(p_fd[i].rd); + close(p_fd[i].wr); + } + errno = EPIPE; + return posix_error_with_filename(cmdstring); + } + + /* build tuple of file objects to return */ + if ((p_f[0] = PyFile_FromFile(p_s[0], cmdstring, wr_mode, _PyPclose)) != NULL) + PyFile_SetBufSize(p_f[0], bufsize); + if ((p_f[1] = PyFile_FromFile(p_s[1], cmdstring, rd_mode, _PyPclose)) != NULL) + PyFile_SetBufSize(p_f[1], bufsize); + if (n == POPEN_3) + { + if ((p_f[2] = PyFile_FromFile(p_s[2], cmdstring, rd_mode, _PyPclose)) != NULL) + PyFile_SetBufSize(p_f[0], bufsize); + f = Py_BuildValue("OOO", p_f[0], p_f[1], p_f[2]); + } + else + f = Py_BuildValue("OO", p_f[0], p_f[1]); + + /* + * Insert the files we've created into the process dictionary + * all referencing the list with the process handle and the + * initial number of files (see description below in _PyPclose). + * Since if _PyPclose later tried to wait on a process when all + * handles weren't closed, it could create a deadlock with the + * child, we spend some energy here to try to ensure that we + * either insert all file handles into the dictionary or none + * at all. It's a little clumsy with the various popen modes + * and variable number of files involved. + */ + if (!_PyPopenProcs) + { + _PyPopenProcs = PyDict_New(); + } + + if (_PyPopenProcs) + { + PyObject *procObj, *pidObj, *intObj, *fileObj[3]; + int ins_rc[3]; + + fileObj[0] = fileObj[1] = fileObj[2] = NULL; + ins_rc[0] = ins_rc[1] = ins_rc[2] = 0; + + procObj = PyList_New(2); + pidObj = PyInt_FromLong((long) pipe_pid); + intObj = PyInt_FromLong((long) file_count); + + if (procObj && pidObj && intObj) + { + PyList_SetItem(procObj, 0, pidObj); + PyList_SetItem(procObj, 1, intObj); + + fileObj[0] = PyLong_FromVoidPtr(p_s[0]); + if (fileObj[0]) + { + ins_rc[0] = PyDict_SetItem(_PyPopenProcs, + fileObj[0], + procObj); + } + fileObj[1] = PyLong_FromVoidPtr(p_s[1]); + if (fileObj[1]) + { + ins_rc[1] = PyDict_SetItem(_PyPopenProcs, + fileObj[1], + procObj); + } + if (file_count >= 3) + { + fileObj[2] = PyLong_FromVoidPtr(p_s[2]); + if (fileObj[2]) + { + ins_rc[2] = PyDict_SetItem(_PyPopenProcs, + fileObj[2], + procObj); + } + } + + if (ins_rc[0] < 0 || !fileObj[0] || + ins_rc[1] < 0 || (file_count > 1 && !fileObj[1]) || + ins_rc[2] < 0 || (file_count > 2 && !fileObj[2])) + { + /* Something failed - remove any dictionary + * entries that did make it. + */ + if (!ins_rc[0] && fileObj[0]) + { + PyDict_DelItem(_PyPopenProcs, + fileObj[0]); + } + if (!ins_rc[1] && fileObj[1]) + { + PyDict_DelItem(_PyPopenProcs, + fileObj[1]); + } + if (!ins_rc[2] && fileObj[2]) + { + PyDict_DelItem(_PyPopenProcs, + fileObj[2]); + } + } + } + + /* + * Clean up our localized references for the dictionary keys + * and value since PyDict_SetItem will Py_INCREF any copies + * that got placed in the dictionary. + */ + Py_XDECREF(procObj); + Py_XDECREF(fileObj[0]); + Py_XDECREF(fileObj[1]); + Py_XDECREF(fileObj[2]); + } + + /* Child is launched. */ + return f; + } + + /* + * Wrapper for fclose() to use for popen* files, so we can retrieve the + * exit code for the child process and return as a result of the close. + * + * This function uses the _PyPopenProcs dictionary in order to map the + * input file pointer to information about the process that was + * originally created by the popen* call that created the file pointer. + * The dictionary uses the file pointer as a key (with one entry + * inserted for each file returned by the original popen* call) and a + * single list object as the value for all files from a single call. + * The list object contains the Win32 process handle at [0], and a file + * count at [1], which is initialized to the total number of file + * handles using that list. + * + * This function closes whichever handle it is passed, and decrements + * the file count in the dictionary for the process handle pointed to + * by this file. On the last close (when the file count reaches zero), + * this function will wait for the child process and then return its + * exit code as the result of the close() operation. This permits the + * files to be closed in any order - it is always the close() of the + * final handle that will return the exit code. + */ + + /* RED_FLAG 31-Aug-2000 Tim + * This is always called (today!) between a pair of + * Py_BEGIN_ALLOW_THREADS/ Py_END_ALLOW_THREADS + * macros. So the thread running this has no valid thread state, as + * far as Python is concerned. However, this calls some Python API + * functions that cannot be called safely without a valid thread + * state, in particular PyDict_GetItem. + * As a temporary hack (although it may last for years ...), we + * *rely* on not having a valid thread state in this function, in + * order to create our own "from scratch". + * This will deadlock if _PyPclose is ever called by a thread + * holding the global lock. + * (The OS/2 EMX thread support appears to cover the case where the + * lock is already held - AIM Apr01) + */ + + static int _PyPclose(FILE *file) + { + int result; + int exit_code; + int pipe_pid; + PyObject *procObj, *pidObj, *intObj, *fileObj; + int file_count; + #ifdef WITH_THREAD + PyInterpreterState* pInterpreterState; + PyThreadState* pThreadState; + #endif + + /* Close the file handle first, to ensure it can't block the + * child from exiting if it's the last handle. + */ + result = fclose(file); + + #ifdef WITH_THREAD + /* Bootstrap a valid thread state into existence. */ + pInterpreterState = PyInterpreterState_New(); + if (!pInterpreterState) { + /* Well, we're hosed now! We don't have a thread + * state, so can't call a nice error routine, or raise + * an exception. Just die. + */ + Py_FatalError("unable to allocate interpreter state " + "when closing popen object."); + return -1; /* unreachable */ + } + pThreadState = PyThreadState_New(pInterpreterState); + if (!pThreadState) { + Py_FatalError("unable to allocate thread state " + "when closing popen object."); + return -1; /* unreachable */ + } + /* Grab the global lock. Note that this will deadlock if the + * current thread already has the lock! (see RED_FLAG comments + * before this function) + */ + PyEval_RestoreThread(pThreadState); + #endif + + if (_PyPopenProcs) + { + if ((fileObj = PyLong_FromVoidPtr(file)) != NULL && + (procObj = PyDict_GetItem(_PyPopenProcs, + fileObj)) != NULL && + (pidObj = PyList_GetItem(procObj,0)) != NULL && + (intObj = PyList_GetItem(procObj,1)) != NULL) + { + pipe_pid = (int) PyInt_AsLong(pidObj); + file_count = (int) PyInt_AsLong(intObj); + + if (file_count > 1) + { + /* Still other files referencing process */ + file_count--; + PyList_SetItem(procObj,1, + PyInt_FromLong((long) file_count)); + } + else + { + /* Last file for this process */ + if (result != EOF && + waitpid(pipe_pid, &exit_code, 0) == pipe_pid) + { + /* extract exit status */ + if (WIFEXITED(exit_code)) + { + result = WEXITSTATUS(exit_code); + } + else + { + errno = EPIPE; + result = -1; + } + } + else + { + /* Indicate failure - this will cause the file object + * to raise an I/O error and translate the last + * error code from errno. We do have a problem with + * last errors that overlap the normal errno table, + * but that's a consistent problem with the file object. + */ + result = -1; + } + } + + /* Remove this file pointer from dictionary */ + PyDict_DelItem(_PyPopenProcs, fileObj); + + if (PyDict_Size(_PyPopenProcs) == 0) + { + Py_DECREF(_PyPopenProcs); + _PyPopenProcs = NULL; + } + + } /* if object retrieval ok */ + + Py_XDECREF(fileObj); + } /* if _PyPopenProcs */ + + #ifdef WITH_THREAD + /* Tear down the thread & interpreter states. + * Note that interpreter state clear & delete functions automatically + * call the thread clear & delete functions, and indeed insist on + * doing that themselves. The lock must be held during the clear, but + * need not be held during the delete. + */ + PyInterpreterState_Clear(pInterpreterState); + PyEval_ReleaseThread(pThreadState); + PyInterpreterState_Delete(pInterpreterState); + #endif + + return result; + } + + #endif /* PYCC_??? */ + #elif defined(MS_WIN32) *************** *** 2585,2589 **** GetModuleFileName(NULL, modulepath, sizeof(modulepath)); for (i = x = 0; modulepath[i]; i++) ! if (modulepath[i] == '\\') x = i+1; modulepath[x] = '\0'; --- 3241,3245 ---- GetModuleFileName(NULL, modulepath, sizeof(modulepath)); for (i = x = 0; modulepath[i]; i++) ! if (modulepath[i] == SEP) x = i+1; modulepath[x] = '\0'; *************** *** 3149,3154 **** return f; } - #endif #endif /* HAVE_POPEN */ --- 3805,3810 ---- return f; } + #endif /* PYOS_??? */ #endif /* HAVE_POPEN */ *************** *** 5605,5608 **** --- 6261,6270 ---- {"popen4", win32_popen4, METH_VARARGS}, {"startfile", win32_startfile, METH_VARARGS, win32_startfile__doc__}, + #else + #if defined(PYOS_OS2) && defined(PYCC_GCC) + {"popen2", os2emx_popen2, METH_VARARGS}, + {"popen3", os2emx_popen3, METH_VARARGS}, + {"popen4", os2emx_popen4, METH_VARARGS}, + #endif #endif #endif /* HAVE_POPEN */ *************** *** 5920,5923 **** --- 6582,6607 ---- #ifdef HAVE_SPAWNV + #if defined(PYOS_OS2) && defined(PYCC_GCC) + if (ins(d, "P_WAIT", (long)P_WAIT)) return -1; + if (ins(d, "P_NOWAIT", (long)P_NOWAIT)) return -1; + if (ins(d, "P_OVERLAY", (long)P_OVERLAY)) return -1; + if (ins(d, "P_DEBUG", (long)P_DEBUG)) return -1; + if (ins(d, "P_SESSION", (long)P_SESSION)) return -1; + if (ins(d, "P_DETACH", (long)P_DETACH)) return -1; + if (ins(d, "P_PM", (long)P_PM)) return -1; + if (ins(d, "P_DEFAULT", (long)P_DEFAULT)) return -1; + if (ins(d, "P_MINIMIZE", (long)P_MINIMIZE)) return -1; + if (ins(d, "P_MAXIMIZE", (long)P_MAXIMIZE)) return -1; + if (ins(d, "P_FULLSCREEN", (long)P_FULLSCREEN)) return -1; + if (ins(d, "P_WINDOWED", (long)P_WINDOWED)) return -1; + if (ins(d, "P_FOREGROUND", (long)P_FOREGROUND)) return -1; + if (ins(d, "P_BACKGROUND", (long)P_BACKGROUND)) return -1; + if (ins(d, "P_NOCLOSE", (long)P_NOCLOSE)) return -1; + if (ins(d, "P_NOSESSION", (long)P_NOSESSION)) return -1; + if (ins(d, "P_QUOTE", (long)P_QUOTE)) return -1; + if (ins(d, "P_TILDE", (long)P_TILDE)) return -1; + if (ins(d, "P_UNRELATED", (long)P_UNRELATED)) return -1; + if (ins(d, "P_DEBUGDESC", (long)P_DEBUGDESC)) return -1; + #else if (ins(d, "P_WAIT", (long)_P_WAIT)) return -1; if (ins(d, "P_NOWAIT", (long)_P_NOWAIT)) return -1; *************** *** 5925,5928 **** --- 6609,6613 ---- if (ins(d, "P_NOWAITO", (long)_P_NOWAITO)) return -1; if (ins(d, "P_DETACH", (long)_P_DETACH)) return -1; + #endif #endif From aimacintyre@users.sourceforge.net Sun Mar 3 03:12:33 2002 From: aimacintyre@users.sourceforge.net (Andrew I MacIntyre) Date: Sat, 02 Mar 2002 19:12:33 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib pydoc.py,1.56,1.57 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv2835 Modified Files: pydoc.py Log Message: OS/2 more program behaves like Win32 more (see patch #514490, by Stefan Schwarzer) Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** pydoc.py 31 Oct 2001 04:20:26 -0000 1.56 --- pydoc.py 3 Mar 2002 03:12:30 -0000 1.57 *************** *** 1185,1189 **** else: return lambda text: pipepager(text, os.environ['PAGER']) ! if sys.platform == 'win32': return lambda text: tempfilepager(plain(text), 'more <') if hasattr(os, 'system') and os.system('less 2>/dev/null') == 0: --- 1185,1189 ---- else: return lambda text: pipepager(text, os.environ['PAGER']) ! if sys.platform == 'win32' or sys.platform.startswith('os2'): return lambda text: tempfilepager(plain(text), 'more <') if hasattr(os, 'system') and os.system('less 2>/dev/null') == 0: From gvanrossum@users.sourceforge.net Sun Mar 3 03:21:47 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sat, 02 Mar 2002 19:21:47 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv4386 Modified Files: datetime.py Log Message: Add some XXX comments about brokenness relating to ctime(). Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** datetime.py 3 Mar 2002 02:50:52 -0000 1.17 --- datetime.py 3 Mar 2002 03:21:45 -0000 1.18 *************** *** 380,383 **** --- 380,384 ---- h, m = divmod(-self.__tzoffset, 60) h = -h + # XXX This is broken! ctime() renormalizes to local time. :-( return self.ctime() + " %+03d:%02d" % (h, m) *************** *** 487,490 **** --- 488,500 ---- # Formatting methods + + # XXX These shouldn't depend on time.localtime(), because that + # clips the usable dates to [1970 .. 2038). At least ctime() is + # easily done without using strftime() -- that's better too because + # strftime("%c", ...) is locale specific. + + # XXX An additional question is whether ctime() should renormalize + # to local time, or display the time as entered (which may be + # confusing since it doesn't show the timezone). def ctime(self): From tim.one@comcast.net Sun Mar 3 03:35:39 2002 From: tim.one@comcast.net (Tim Peters) Date: Sat, 02 Mar 2002 22:35:39 -0500 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.16,1.17 test_datetime.py,1.11,1.12 In-Reply-To: Message-ID: > def weekday(self): > "Return day of the week, where Monday == 0 (according to ISO)." > # The constant 6 was obtained experimentally :-) > return (_ymd2ord(self.__year, self.__month, self.__day) + 6) % 7 I'm not sure why we're mucking with the ISO calendar too, but if we want to then I believe this function is incorrect. According to ISO 8601 http://www.pvv.org/~nsaa/8601v2000.pdf section 4.3.2.2 says ISO day ordinals are from 1 (Monday) through 7 (Sunday). "Day 1" in the proleptic Gregorian system is a Monday, so return self.toordinal() % 7 or 7 implements the ISO rule. > def isocalendar(self): > """Return a 3-tuple containing ISO year, week number, > and weekday. Why <0.7 wink>? From tim_one@users.sourceforge.net Sun Mar 3 03:58:14 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 02 Mar 2002 19:58:14 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.18,1.19 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv10966 Modified Files: datetime.py Log Message: toordinal(): Made more efficient by referencing fields directly instead of going thru the properties. weekday(): Recorded disagreement in a XXX block. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** datetime.py 3 Mar 2002 03:21:45 -0000 1.18 --- datetime.py 3 Mar 2002 03:58:12 -0000 1.19 *************** *** 424,428 **** contribute to the result. """ ! return _ymd2ord(self.year, self.month, self.day) def __cmp__(self, other): --- 424,428 ---- contribute to the result. """ ! return _ymd2ord(self.__year, self.__month, self.__day) def __cmp__(self, other): *************** *** 560,563 **** --- 560,567 ---- "Return day of the week, where Monday == 0 (according to ISO)." # The constant 6 was obtained experimentally :-) + # XXX I (tim) believe this is incorrect: ISO defines day ordinals + # XXX as ranging from 1 (Monday) through 7 (Sunday). The next line + # XXX (commented out) implements that: + # return self.toordinal() % 7 or 7 return (_ymd2ord(self.__year, self.__month, self.__day) + 6) % 7 From tim_one@users.sourceforge.net Sun Mar 3 03:59:39 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 02 Mar 2002 19:59:39 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.19,1.20 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv11462 Modified Files: datetime.py Log Message: Simplified a comment. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** datetime.py 3 Mar 2002 03:58:12 -0000 1.19 --- datetime.py 3 Mar 2002 03:59:37 -0000 1.20 *************** *** 18,23 **** # and Reingold's "Calendrical Calculations", where it's the base calendar # for all computations. See the book for algorithms for converting between ! # day ordinals in the proleptic Gregorian calendar and many other calendar ! # systems. _DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] --- 18,22 ---- # and Reingold's "Calendrical Calculations", where it's the base calendar # for all computations. See the book for algorithms for converting between ! # proleptic Gregorian ordinals and many other calendar systems. _DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] From tim_one@users.sourceforge.net Sun Mar 3 04:03:24 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 02 Mar 2002 20:03:24 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.20,1.21 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv12420 Modified Files: datetime.py Log Message: Bug alert for timedelta.__div__. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** datetime.py 3 Mar 2002 03:59:37 -0000 1.20 --- datetime.py 3 Mar 2002 04:03:22 -0000 1.21 *************** *** 217,220 **** --- 217,222 ---- def __div__(self, other): if isinstance(other, (int, long)): + # XXX If, e.g., this is a delta of 1 day, dividing by 2 and + # XXX getting back 0 is pretty surprising. return timedelta(self.__days // other, self.__seconds // other, From tim_one@users.sourceforge.net Sun Mar 3 06:11:56 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 02 Mar 2002 22:11:56 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.21,1.22 test_datetime.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv5735 Modified Files: datetime.py test_datetime.py Log Message: Get a start on a struct tm kinda-workalike that does principled, x-platform normalization; doesn't have year 1970-2038 restrictions; and can construct Unixish timestamps (floating seconds since 1970) for years before 1970 too. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** datetime.py 3 Mar 2002 04:03:22 -0000 1.21 --- datetime.py 3 Mar 2002 06:11:54 -0000 1.22 *************** *** 92,95 **** --- 92,151 ---- return year, month, n-dbm + # This is a start at a struct tm workalike. Goals: + # + # + Works the same way across platforms. + # + Handles all the fields datetime needs handled, without 1970-2038 glitches. + # + # Note: I suspect it's best if this flavor of tm does *not* try to + # second-guess timezones or DST. Instead fold whatever adjustments you want + # into the minutes argument (and the constructor will normalize). + + _ORD1970 = _ymd2ord(1970, 1, 1) # base ordinal for UNIX epoch + + class tmxxx: + + ordinal = None + + def __init__(self, year, month, day, hour=0, minute=0, second=0, + microsecond=0): + # Normalize all the inputs, and store the normalized values. + carry, microsecond = divmod(microsecond, 1000000) + second += carry + carry, second = divmod(second, 60) + minute += carry + carry, minute = divmod(minute, 60) + hour += carry + carry, hour = divmod(hour, 24) + day += carry + # That was easy. Now it gets muddy: the proper range for day + # can't be determined without knowing the correct month and year, + # but if day is, e.g., plus or minus a million, the current month + # and year values make no sense (and may also be out of bounds + # themselves). + # Saying 12 months == 1 year should be non-controversial. + carry, month = divmod(month-1, 12) + year += carry + month += 1 + assert 1 <= month <= 12 + # Now only day can be out of bounds. If it is, what to do is arguable, + # but at least the method here is principled and explainable. + if not 1 <= day <= _days_in_month(month, year): + # Note that the "if" test is for efficiency, not correctness: + # there's simply no need to do this dance if day is already in + # range, and it's an expensive dance. + self.ordinal = _ymd2ord(year, month, 1) + (day - 1) + year, month, day = _ord2ymd(self.ordinal) + self.year, self.month, self.day = year, month, day + self.hour, self.minute, self.second = hour, minute, second + self.microsecond = microsecond + + def time(self): + "Return Unixish timestamp, as a float." + if self.ordinal is None: + self.ordinal = _ymd2ord(self.year, self.month, self.day) + days = self.ordinal - _ORD1970 # convert to UNIX epoch + seconds = ((days * 24. + self.hour)*60. + self.minute)*60. + return seconds + self.second + self.microsecond / 1e6 + class basetime(object): """Abstract date/time type. Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_datetime.py 3 Mar 2002 02:50:52 -0000 1.12 --- test_datetime.py 3 Mar 2002 06:11:54 -0000 1.13 *************** *** 222,247 **** # http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm ISO_LONG_YEARS_TABLE = """ ! 4 32 60 88 ! 9 37 65 93 ! 15 43 71 99 ! 20 48 76 26 54 82 ! 105 133 161 189 ! 111 139 167 195 ! 116 144 172 ! 122 150 178 128 156 184 ! 201 229 257 285 ! 207 235 263 291 ! 212 240 268 296 ! 218 246 274 224 252 280 ! 303 331 359 387 ! 308 336 364 392 ! 314 342 370 398 ! 320 348 376 325 353 381 """ --- 222,247 ---- # http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm ISO_LONG_YEARS_TABLE = """ ! 4 32 60 88 ! 9 37 65 93 ! 15 43 71 99 ! 20 48 76 26 54 82 ! 105 133 161 189 ! 111 139 167 195 ! 116 144 172 ! 122 150 178 128 156 184 ! 201 229 257 285 ! 207 235 263 291 ! 212 240 268 296 ! 218 246 274 224 252 280 ! 303 331 359 387 ! 308 336 364 392 ! 314 342 370 398 ! 320 348 376 325 353 381 """ *************** *** 257,260 **** --- 257,273 ---- self.assertEqual(L, iso_long_years) + def test_tmxxx(self): + from datetime import tmxxx + for timestamp in 123456789.0, 987654321.0: + dt = datetime.utcfromtimestamp(timestamp) + # Mange the fields, but in such a way that normalization should + # restore them to dt's values. + tm = tmxxx(dt.year - 1, dt.month + 12, dt.day + 100, + dt.hour - 24*100, dt.minute - 3, dt.second + 12, + (3*60 - 12) * 1000000) + dt2 = datetime.new(tm.year, tm.month, tm.day, tm.hour, tm.minute, + tm.second, tm.microsecond, tzoffset=0) + self.assertEqual(dt, dt2) + self.assertEqual(timestamp, tm.time()) def test_suite(): From nnorwitz@users.sourceforge.net Sun Mar 3 15:11:19 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 03 Mar 2002 07:11:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python sysmodule.c,2.100,2.101 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv6411/Python Modified Files: sysmodule.c Log Message: SF #506611, fix sys.setprofile(), sys.settrace() core dumps when no arguments are passed Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.100 retrieving revision 2.101 diff -C2 -d -r2.100 -r2.101 *** sysmodule.c 29 Jan 2002 00:53:41 -0000 2.100 --- sysmodule.c 3 Mar 2002 15:11:17 -0000 2.101 *************** *** 565,572 **** setdlopenflags_doc}, #endif ! {"setprofile", sys_setprofile, METH_OLDARGS, setprofile_doc}, {"setrecursionlimit", sys_setrecursionlimit, METH_VARARGS, setrecursionlimit_doc}, ! {"settrace", sys_settrace, METH_OLDARGS, settrace_doc}, {NULL, NULL} /* sentinel */ }; --- 565,572 ---- setdlopenflags_doc}, #endif ! {"setprofile", sys_setprofile, METH_O, setprofile_doc}, {"setrecursionlimit", sys_setrecursionlimit, METH_VARARGS, setrecursionlimit_doc}, ! {"settrace", sys_settrace, METH_O, settrace_doc}, {NULL, NULL} /* sentinel */ }; From nnorwitz@users.sourceforge.net Sun Mar 3 15:11:20 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 03 Mar 2002 07:11:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_profilehooks.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv6411/Lib/test Modified Files: test_profilehooks.py Log Message: SF #506611, fix sys.setprofile(), sys.settrace() core dumps when no arguments are passed Index: test_profilehooks.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_profilehooks.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_profilehooks.py 4 Oct 2001 14:49:46 -0000 1.6 --- test_profilehooks.py 3 Mar 2002 15:11:17 -0000 1.7 *************** *** 1,4 **** --- 1,6 ---- from __future__ import generators + from test_support import TestFailed + import pprint import sys *************** *** 330,333 **** --- 332,339 ---- def capture_events(callable, p=None): + try: sys.setprofile() + except TypeError: pass + else: raise TestFailed, 'sys.setprofile() did not raise TypeError' + if p is None: p = HookWatcher() From nnorwitz@users.sourceforge.net Sun Mar 3 15:13:00 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 03 Mar 2002 07:13:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_scope.py,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv7127/Lib/test Modified Files: test_scope.py Log Message: SF #506611, fix sys.setprofile(), sys.settrace() core dumps when no arguments are passed Index: test_scope.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_scope.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** test_scope.py 15 Dec 2001 18:04:10 -0000 1.24 --- test_scope.py 3 Mar 2002 15:12:58 -0000 1.25 *************** *** 472,475 **** --- 472,479 ---- sys.settrace(None) + try: sys.settrace() + except TypeError: pass + else: raise TestFailed, 'sys.settrace() did not raise TypeError' + print "20. eval and exec with free variables" From nnorwitz@users.sourceforge.net Sun Mar 3 15:17:09 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 03 Mar 2002 07:17:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_profilehooks.py,1.6,1.6.10.1 test_scope.py,1.24,1.24.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv8134/Lib/test Modified Files: Tag: release22-maint test_profilehooks.py test_scope.py Log Message: SF #506611, fix sys.setprofile(), sys.settrace() core dumps when no arguments are passed Index: test_profilehooks.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_profilehooks.py,v retrieving revision 1.6 retrieving revision 1.6.10.1 diff -C2 -d -r1.6 -r1.6.10.1 *** test_profilehooks.py 4 Oct 2001 14:49:46 -0000 1.6 --- test_profilehooks.py 3 Mar 2002 15:17:07 -0000 1.6.10.1 *************** *** 1,4 **** --- 1,6 ---- from __future__ import generators + from test_support import TestFailed + import pprint import sys *************** *** 330,333 **** --- 332,339 ---- def capture_events(callable, p=None): + try: sys.setprofile() + except TypeError: pass + else: raise TestFailed, 'sys.setprofile() did not raise TypeError' + if p is None: p = HookWatcher() Index: test_scope.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_scope.py,v retrieving revision 1.24 retrieving revision 1.24.4.1 diff -C2 -d -r1.24 -r1.24.4.1 *** test_scope.py 15 Dec 2001 18:04:10 -0000 1.24 --- test_scope.py 3 Mar 2002 15:17:07 -0000 1.24.4.1 *************** *** 472,475 **** --- 472,479 ---- sys.settrace(None) + try: sys.settrace() + except TypeError: pass + else: raise TestFailed, 'sys.settrace() did not raise TypeError' + print "20. eval and exec with free variables" From nnorwitz@users.sourceforge.net Sun Mar 3 15:17:09 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 03 Mar 2002 07:17:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python sysmodule.c,2.98.6.2,2.98.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv8134/Python Modified Files: Tag: release22-maint sysmodule.c Log Message: SF #506611, fix sys.setprofile(), sys.settrace() core dumps when no arguments are passed Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.98.6.2 retrieving revision 2.98.6.3 diff -C2 -d -r2.98.6.2 -r2.98.6.3 *** sysmodule.c 6 Feb 2002 17:06:03 -0000 2.98.6.2 --- sysmodule.c 3 Mar 2002 15:17:07 -0000 2.98.6.3 *************** *** 565,572 **** setdlopenflags_doc}, #endif ! {"setprofile", sys_setprofile, METH_OLDARGS, setprofile_doc}, {"setrecursionlimit", sys_setrecursionlimit, METH_VARARGS, setrecursionlimit_doc}, ! {"settrace", sys_settrace, METH_OLDARGS, settrace_doc}, {NULL, NULL} /* sentinel */ }; --- 565,572 ---- setdlopenflags_doc}, #endif ! {"setprofile", sys_setprofile, METH_O, setprofile_doc}, {"setrecursionlimit", sys_setrecursionlimit, METH_VARARGS, setrecursionlimit_doc}, ! {"settrace", sys_settrace, METH_O, settrace_doc}, {NULL, NULL} /* sentinel */ }; From gvanrossum@users.sourceforge.net Sun Mar 3 19:58:43 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sun, 03 Mar 2002 11:58:43 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.22,1.23 test_datetime.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv24418 Modified Files: datetime.py test_datetime.py Log Message: - Add isoweekday(), which has Monday-Sunday == 1-7. - Fix timedelta.__div__, and add testcases for it. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** datetime.py 3 Mar 2002 06:11:54 -0000 1.22 --- datetime.py 3 Mar 2002 19:58:41 -0000 1.23 *************** *** 273,281 **** def __div__(self, other): if isinstance(other, (int, long)): ! # XXX If, e.g., this is a delta of 1 day, dividing by 2 and ! # XXX getting back 0 is pretty surprising. ! return timedelta(self.__days // other, ! self.__seconds // other, ! self.__microseconds // other) return NotImplemented --- 273,279 ---- def __div__(self, other): if isinstance(other, (int, long)): ! usec = ((self.__days * (24*3600L) + self.__seconds) * 1000000 + ! self.__microseconds) ! return timedelta(0, 0, usec // other) return NotImplemented *************** *** 615,625 **** def weekday(self): ! "Return day of the week, where Monday == 0 (according to ISO)." ! # The constant 6 was obtained experimentally :-) ! # XXX I (tim) believe this is incorrect: ISO defines day ordinals ! # XXX as ranging from 1 (Monday) through 7 (Sunday). The next line ! # XXX (commented out) implements that: ! # return self.toordinal() % 7 or 7 ! return (_ymd2ord(self.__year, self.__month, self.__day) + 6) % 7 def isocalendar(self): --- 613,623 ---- def weekday(self): ! "Return day of the week, where Monday == 0 ... Sunday == 6." ! return (self.toordinal() + 6) % 7 ! ! def isoweekday(self): ! "Return day of the week, where Monday == 1 ... Sunday == 7." ! # 1-Jan-0001 is a Monday ! return self.toordinal() % 7 or 7 def isocalendar(self): Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** test_datetime.py 3 Mar 2002 06:11:54 -0000 1.13 --- test_datetime.py 3 Mar 2002 19:58:41 -0000 1.14 *************** *** 145,148 **** --- 145,153 ---- self.assertEqual(c*1000, timedelta(0, 1)) self.assertEqual(1000*c, timedelta(0, 1)) + self.assertEqual(a//7, timedelta(1)) + self.assertEqual(b//10, timedelta(0, 6)) + self.assertEqual(c//1000, timedelta(0, 0, 1)) + self.assertEqual(a//10, timedelta(0, 7*24*360)) + self.assertEqual(a//3600000, timedelta(0, 0, 7*24*1000)) def test_computations(self): *************** *** 198,203 **** --- 203,210 ---- # March 4, 2002 is a Monday self.assertEqual(datetime(2002, 3, 4+i).weekday(), i) + self.assertEqual(datetime(2002, 3, 4+i).isoweekday(), i+1) # January 2, 1956 is a Monday self.assertEqual(datetime(1956, 1, 2+i).weekday(), i) + self.assertEqual(datetime(1956, 1, 2+i).isoweekday(), i+1) def test_isocalendar(self): From gvanrossum@users.sourceforge.net Sun Mar 3 20:24:09 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sun, 03 Mar 2002 12:24:09 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.23,1.24 test_datetime.py,1.14,1.15 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv2478 Modified Files: datetime.py test_datetime.py Log Message: As suggested by Neal Norwitz, support add/sub int/long/float to datetime and timedelta, interpreting as seconds. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** datetime.py 3 Mar 2002 19:58:41 -0000 1.23 --- datetime.py 3 Mar 2002 20:24:06 -0000 1.24 *************** *** 236,239 **** --- 236,249 ---- self.__seconds + other.__seconds, self.__microseconds + other.__microseconds) + if isinstance(other, (int, long)): + return timedelta(self.__days, + self.__seconds + other, + self.__microseconds) + if isinstance(other, float): + ss, us = divmod(other*1e6, 1e6) + d, ss = divmod(ss, 24*3600) + return timedelta(self.__days + int(d), + self.__seconds + int(ss), + self.__microseconds + int(round(us))) return NotImplemented *************** *** 241,245 **** def __sub__(self, other): ! if isinstance(other, timedelta): return self + -other return NotImplemented --- 251,255 ---- def __sub__(self, other): ! if isinstance(other, (timedelta, int, long, float)): return self + -other return NotImplemented *************** *** 306,310 **** __repr__, __str__ __cmp__, __hash__ ! __add__, __radd__, __sub__ (add/radd only with timedelta other arg) Methods: --- 316,320 ---- __repr__, __str__ __cmp__, __hash__ ! __add__, __radd__, __sub__ (add/radd only with timedelta or numeric arg) Methods: *************** *** 572,576 **** def __add__(self, other): ! "Add a datetime to a timedelta." if isinstance(other, timedelta): hh, mm, ss, us = (self.__hour, --- 582,589 ---- def __add__(self, other): ! """Add a datetime to a timedelta. ! ! An int/long/float argument is also allowed, interpreted as seconds. ! """ if isinstance(other, timedelta): hh, mm, ss, us = (self.__hour, *************** *** 589,592 **** --- 602,611 ---- result.__tzoffset = self.__tzoffset return result + elif isinstance(other, (int, long)): + return self + timedelta(0, other) + elif isinstance(other, float): + ss, us = divmod(other*1e6, 1e6) + d, ss = divmod(ss, 24*3600) + return self + timedelta(int(d), int(ss), int(round(us))) return NotImplemented *************** *** 594,599 **** def __sub__(self, other): ! "Subtract two datetimes, or a datetime and a timedelta." ! if isinstance(other, timedelta): return self + -other if isinstance(other, datetime): --- 613,621 ---- def __sub__(self, other): ! """Subtract two datetimes, or a datetime and a timedelta. ! ! An int/long/float argument is also allowed, interpreted as seconds. ! """ ! if isinstance(other, (timedelta, int, long, float)): return self + -other if isinstance(other, datetime): Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** test_datetime.py 3 Mar 2002 19:58:41 -0000 1.14 --- test_datetime.py 3 Mar 2002 20:24:06 -0000 1.15 *************** *** 150,153 **** --- 150,166 ---- self.assertEqual(a//10, timedelta(0, 7*24*360)) self.assertEqual(a//3600000, timedelta(0, 0, 7*24*1000)) + # Add/sub ints, longs, floats + self.assertEqual(a + 7*24*3600, timedelta(14)) + self.assertEqual(a - 24*3600, timedelta(6)) + self.assertEqual(a + 100, timedelta(7, 100)) + self.assertEqual(a - 100, timedelta(6, 24*3600-100)) + self.assertEqual(a + 7*24*3600L, timedelta(14)) + self.assertEqual(a - 24*3600L, timedelta(6)) + self.assertEqual(a + 100L, timedelta(7, 100)) + self.assertEqual(a - 100L, timedelta(6, 24*3600-100)) + self.assertEqual(c + 0.001, timedelta(0, 0, 2000)) + self.assertEqual(c - 0.0001, timedelta(0, 0, 900)) + self.assertEqual(b + 1.1, timedelta(0, 61, 100000)) + self.assertEqual(b - 1.1, timedelta(0, 58, 900000)) def test_computations(self): *************** *** 198,201 **** --- 211,221 ---- self.assertEqual(a - (week + day + hour + millisec), (((a - week) - day) - hour) - millisec) + # Add/sub ints, longs, floats + self.assertEqual(a + 12, a + timedelta(0, 12)) + self.assertEqual(a - 12, a - timedelta(0, 12)) + self.assertEqual(a + 12L, a + timedelta(0, 12)) + self.assertEqual(a - 12L, a - timedelta(0, 12)) + self.assertEqual(a + 0.001, a + timedelta(0, 0, 1000)) + self.assertEqual(a - 0.001, a - timedelta(0, 0, 1000)) def test_weekday(self): From gvanrossum@users.sourceforge.net Sun Mar 3 20:43:52 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sun, 03 Mar 2002 12:43:52 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.24,1.25 test_datetime.py,1.15,1.16 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv7507 Modified Files: datetime.py test_datetime.py Log Message: Add proper tests for __radd__, __rsub__ of timedelta; fix bug thus found. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** datetime.py 3 Mar 2002 20:24:06 -0000 1.24 --- datetime.py 3 Mar 2002 20:43:49 -0000 1.25 *************** *** 256,260 **** def __rsub__(self, other): ! if isinstance(other, timedelta): return -self + other return NotImplemented --- 256,260 ---- def __rsub__(self, other): ! if isinstance(other, (timedelta, int, long, float)): return -self + other return NotImplemented Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** test_datetime.py 3 Mar 2002 20:24:06 -0000 1.15 --- test_datetime.py 3 Mar 2002 20:43:49 -0000 1.16 *************** *** 155,166 **** --- 155,174 ---- self.assertEqual(a + 100, timedelta(7, 100)) self.assertEqual(a - 100, timedelta(6, 24*3600-100)) + self.assertEqual(100 + a, a + 100) + self.assertEqual(100 - a, 100 + -a) self.assertEqual(a + 7*24*3600L, timedelta(14)) self.assertEqual(a - 24*3600L, timedelta(6)) self.assertEqual(a + 100L, timedelta(7, 100)) self.assertEqual(a - 100L, timedelta(6, 24*3600-100)) + self.assertEqual(100L + a, a + 100L) + self.assertEqual(100L - a, 100L + -a) self.assertEqual(c + 0.001, timedelta(0, 0, 2000)) self.assertEqual(c - 0.0001, timedelta(0, 0, 900)) self.assertEqual(b + 1.1, timedelta(0, 61, 100000)) self.assertEqual(b - 1.1, timedelta(0, 58, 900000)) + self.assertEqual(a + 1e6 + 1e-6, timedelta(7, 1000000, 1)) + self.assertEqual(a - 1e6 - 1e-6, timedelta(7, -1000000, -1)) + self.assertEqual(1.1 + a, a + 1.1) + self.assertEqual(1.1 - a, 1.1 + -a) def test_computations(self): *************** *** 214,221 **** --- 222,232 ---- self.assertEqual(a + 12, a + timedelta(0, 12)) self.assertEqual(a - 12, a - timedelta(0, 12)) + self.assertEqual(100 + a, a + 100) self.assertEqual(a + 12L, a + timedelta(0, 12)) self.assertEqual(a - 12L, a - timedelta(0, 12)) + self.assertEqual(100L + a, a + 100L) self.assertEqual(a + 0.001, a + timedelta(0, 0, 1000)) self.assertEqual(a - 0.001, a - timedelta(0, 0, 1000)) + self.assertEqual(0.1 + a, a + 0.1) def test_weekday(self): From gvanrossum@users.sourceforge.net Sun Mar 3 20:45:14 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sun, 03 Mar 2002 12:45:14 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv7860 Modified Files: test_datetime.py Log Message: Make one float test tougher. Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** test_datetime.py 3 Mar 2002 20:43:49 -0000 1.16 --- test_datetime.py 3 Mar 2002 20:45:12 -0000 1.17 *************** *** 167,172 **** self.assertEqual(b + 1.1, timedelta(0, 61, 100000)) self.assertEqual(b - 1.1, timedelta(0, 58, 900000)) ! self.assertEqual(a + 1e6 + 1e-6, timedelta(7, 1000000, 1)) ! self.assertEqual(a - 1e6 - 1e-6, timedelta(7, -1000000, -1)) self.assertEqual(1.1 + a, a + 1.1) self.assertEqual(1.1 - a, 1.1 + -a) --- 167,172 ---- self.assertEqual(b + 1.1, timedelta(0, 61, 100000)) self.assertEqual(b - 1.1, timedelta(0, 58, 900000)) ! self.assertEqual(a + (1e6 + 1e-6), timedelta(7, 1000000, 1)) ! self.assertEqual(a - (1e6 + 1e-6), timedelta(7, -1000000, -1)) self.assertEqual(1.1 + a, a + 1.1) self.assertEqual(1.1 - a, 1.1 + -a) From gvanrossum@users.sourceforge.net Sun Mar 3 20:52:31 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sun, 03 Mar 2002 12:52:31 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.25,1.26 test_datetime.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv9873 Modified Files: datetime.py test_datetime.py Log Message: Of course, isocalendar() should return 1-7 for the weekday too. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** datetime.py 3 Mar 2002 20:43:49 -0000 1.25 --- datetime.py 3 Mar 2002 20:52:29 -0000 1.26 *************** *** 650,654 **** from that. ! Note that the first week is 1, but Monday is 0. ISO calendar algorithm taken from --- 650,654 ---- from that. ! The first week is 1; Monday is 1 ... Sunday is 7. ISO calendar algorithm taken from *************** *** 668,672 **** year += 1 week = 0 ! return year, week+1, day --- 668,672 ---- year += 1 week = 0 ! return year, week+1, day+1 Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** test_datetime.py 3 Mar 2002 20:45:12 -0000 1.17 --- test_datetime.py 3 Mar 2002 20:52:29 -0000 1.18 *************** *** 244,258 **** for i in range(7): d = datetime(2003, 12, 22+i) ! self.assertEqual(d.isocalendar(), (2003, 52, i)) d = datetime(2003, 12, 29) + timedelta(i) ! self.assertEqual(d.isocalendar(), (2004, 1, i)) d = datetime(2004, 1, 5+i) ! self.assertEqual(d.isocalendar(), (2004, 2, i)) d = datetime(2009, 12, 21+i) ! self.assertEqual(d.isocalendar(), (2009, 52, i)) d = datetime(2009, 12, 28) + timedelta(i) ! self.assertEqual(d.isocalendar(), (2009, 53, i)) d = datetime(2010, 1, 4+i) ! self.assertEqual(d.isocalendar(), (2010, 1, i)) def test_iso_long_years(self): --- 244,258 ---- for i in range(7): d = datetime(2003, 12, 22+i) ! self.assertEqual(d.isocalendar(), (2003, 52, i+1)) d = datetime(2003, 12, 29) + timedelta(i) ! self.assertEqual(d.isocalendar(), (2004, 1, i+1)) d = datetime(2004, 1, 5+i) ! self.assertEqual(d.isocalendar(), (2004, 2, i+1)) d = datetime(2009, 12, 21+i) ! self.assertEqual(d.isocalendar(), (2009, 52, i+1)) d = datetime(2009, 12, 28) + timedelta(i) ! self.assertEqual(d.isocalendar(), (2009, 53, i+1)) d = datetime(2010, 1, 4+i) ! self.assertEqual(d.isocalendar(), (2010, 1, i+1)) def test_iso_long_years(self): From gvanrossum@users.sourceforge.net Sun Mar 3 21:24:35 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sun, 03 Mar 2002 13:24:35 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.26,1.27 test_datetime.py,1.18,1.19 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv20056 Modified Files: datetime.py test_datetime.py Log Message: - Add isoformat() and utcisoformat(), returning ISO style timestamps. - Use isoformat(' ') in __str__. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** datetime.py 3 Mar 2002 20:52:29 -0000 1.26 --- datetime.py 3 Mar 2002 21:24:33 -0000 1.27 *************** *** 324,327 **** --- 324,329 ---- strftime(), utcstrftime() toordinal() + weekday(), isoweekday(), isocalendar() + isoformat(), utcisoformat() Properties (readonly): *************** *** 438,450 **** def __str__(self): "Convert to pretty string, for str()." ! if self.__tzoffset == 0: ! return self.ctime() + " UTC" ! if self.__tzoffset > 0: ! h, m = divmod(self.__tzoffset, 60) ! else: ! h, m = divmod(-self.__tzoffset, 60) ! h = -h ! # XXX This is broken! ctime() renormalizes to local time. :-( ! return self.ctime() + " %+03d:%02d" % (h, m) # Read-only field accessors --- 440,444 ---- def __str__(self): "Convert to pretty string, for str()." ! return self.isoformat(sep=' ') # Read-only field accessors *************** *** 669,672 **** --- 663,701 ---- week = 0 return year, week+1, day+1 + + def isoformat(self, sep='T'): + """Return the time formatted according to ISO. + + This is 'YYYY-MM-DD HH:MM:SS.mmmmmm-xx:yy' + where -xx:yy is the timezone offset. + + Optional argument sep specifies the separator between date and + time, default 'T'. + + This method does not convert to local time. + """ + if self.__tzoffset >= 0: + h, m = divmod(self.__tzoffset, 60) + else: + h, m = divmod(-self.__tzoffset, 60) + h = -h + return "%04d-%02d-%02d%c%02d:%02d:%02d.%06d%+03d:%02d" % ( + self.__year, self.__month, self.__day, + sep, + self.__hour, self.__minute, self.__second, + self.__microsecond, + h, m) + + def utcisoformat(self, sep='T'): + """Return the time as UTC formatted according to ISO. + + This is 'YYYY-MM-DD HH:MM:SS.mmmmmmZ'. + + Optional argument sep specifies the separator between date and + time, default 'T'. + """ + y, m, d, hh, mm = self._utc_ymdHM() + return "%04d-%02d-%02d%c%02d:%02d:%02d.%06dZ" % ( + y, m, d, sep, hh, mm, self.__second, self.__microsecond) Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** test_datetime.py 3 Mar 2002 20:52:29 -0000 1.18 --- test_datetime.py 3 Mar 2002 21:24:33 -0000 1.19 *************** *** 295,298 **** --- 295,305 ---- self.assertEqual(L, iso_long_years) + def test_isoformat(self): + t = datetime(2, 3, 2, 4, 5, 1, 123, tzoffset=-120) + self.assertEqual(t.isoformat(), "0002-03-02T04:05:01.000123-02:00") + self.assertEqual(t.isoformat(' '), "0002-03-02 04:05:01.000123-02:00") + self.assertEqual(t.utcisoformat(), "0002-03-02T06:05:01.000123Z") + self.assertEqual(t.utcisoformat(' '), "0002-03-02 06:05:01.000123Z") + def test_tmxxx(self): from datetime import tmxxx From loewis@users.sourceforge.net Sun Mar 3 21:30:29 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Sun, 03 Mar 2002 13:30:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.359,1.360 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv20927/Misc Modified Files: NEWS Log Message: Patch #50002: Display line information for bad \x escapes: - recognize "SyntaxError"s by the print_file_and_line attribute. - add the syntaxerror attributes to all exceptions in compile.c. Fixes #221791 Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.359 retrieving revision 1.360 diff -C2 -d -r1.359 -r1.360 *** NEWS 1 Mar 2002 10:47:37 -0000 1.359 --- NEWS 3 Mar 2002 21:30:27 -0000 1.360 *************** *** 7,10 **** --- 7,13 ---- Core and builtins + - PyErr_Display will provide file and line information for all exceptions + that have an attribute print_file_and_line, not just SyntaxErrors. + - The UTF-8 codec will now encode and decode Unicode surrogates correctly and without raising exceptions for unpaired ones. From loewis@users.sourceforge.net Sun Mar 3 21:30:29 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Sun, 03 Mar 2002 13:30:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python compile.c,2.238,2.239 errors.c,2.66,2.67 exceptions.c,1.28,1.29 pythonrun.c,2.154,2.155 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv20927/Python Modified Files: compile.c errors.c exceptions.c pythonrun.c Log Message: Patch #50002: Display line information for bad \x escapes: - recognize "SyntaxError"s by the print_file_and_line attribute. - add the syntaxerror attributes to all exceptions in compile.c. Fixes #221791 Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.238 retrieving revision 2.239 diff -C2 -d -r2.238 -r2.239 *** compile.c 29 Jan 2002 00:56:37 -0000 2.238 --- compile.c 3 Mar 2002 21:30:27 -0000 2.239 *************** *** 466,477 **** line = Py_None; } ! t = Py_BuildValue("(ziOO)", c->c_filename, c->c_lineno, ! Py_None, line); ! if (t == NULL) ! goto exit; ! w = Py_BuildValue("(OO)", v, t); ! if (w == NULL) ! goto exit; ! PyErr_SetObject(exc, w); exit: Py_XDECREF(t); --- 466,484 ---- line = Py_None; } ! if (exc == PyExc_SyntaxError) { ! t = Py_BuildValue("(ziOO)", c->c_filename, c->c_lineno, ! Py_None, line); ! if (t == NULL) ! goto exit; ! w = Py_BuildValue("(OO)", v, t); ! if (w == NULL) ! goto exit; ! PyErr_SetObject(exc, w); ! } else { ! /* Make sure additional exceptions are printed with ! file and line, also. */ ! PyErr_SetObject(exc, v); ! PyErr_SyntaxLocation(c->c_filename, c->c_lineno); ! } exit: Py_XDECREF(t); *************** *** 1154,1158 **** len = strlen(s); if (len > INT_MAX) { ! PyErr_SetString(PyExc_OverflowError, "string to parse is too long"); return NULL; } --- 1161,1166 ---- len = strlen(s); if (len > INT_MAX) { ! com_error(com, PyExc_OverflowError, ! "string to parse is too long"); return NULL; } *************** *** 1172,1180 **** if (unicode || Py_UnicodeFlag) { if (rawmode) ! return PyUnicode_DecodeRawUnicodeEscape( ! s, len, NULL); else ! return PyUnicode_DecodeUnicodeEscape( s, len, NULL); } #endif --- 1180,1192 ---- if (unicode || Py_UnicodeFlag) { if (rawmode) ! v = PyUnicode_DecodeRawUnicodeEscape( ! s, len, NULL); else ! v = PyUnicode_DecodeUnicodeEscape( s, len, NULL); + if (v == NULL) + PyErr_SyntaxLocation(com->c_filename, com->c_lineno); + return v; + } #endif *************** *** 1239,1245 **** break; } - PyErr_SetString(PyExc_ValueError, - "invalid \\x escape"); Py_DECREF(v); return NULL; default: --- 1251,1257 ---- break; } Py_DECREF(v); + com_error(com, PyExc_ValueError, + "invalid \\x escape"); return NULL; default: Index: errors.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/errors.c,v retrieving revision 2.66 retrieving revision 2.67 diff -C2 -d -r2.66 -r2.67 *** errors.c 2 Oct 2001 21:32:07 -0000 2.66 --- errors.c 3 Mar 2002 21:30:27 -0000 2.67 *************** *** 562,566 **** ! /* XXX There's a comment missing here */ void --- 562,568 ---- ! /* Set file and line information for the current exception. ! If the exception is not a SyntaxError, also sets additional attributes ! to make printing of exceptions believe it is a syntax error. */ void *************** *** 595,598 **** --- 597,620 ---- PyObject_SetAttrString(v, "text", tmp); Py_DECREF(tmp); + } + } + if (PyObject_SetAttrString(v, "offset", Py_None)) { + PyErr_Clear(); + } + if (exc != PyExc_SyntaxError) { + if (!PyObject_HasAttrString(v, "msg")) { + tmp = PyObject_Str(v); + if (tmp) { + if (PyObject_SetAttrString(v, "msg", tmp)) + PyErr_Clear(); + Py_DECREF(tmp); + } else { + PyErr_Clear(); + } + } + if (!PyObject_HasAttrString(v, "print_file_and_line")) { + if (PyObject_SetAttrString(v, "print_file_and_line", + Py_None)) + PyErr_Clear(); } } Index: exceptions.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/exceptions.c,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** exceptions.c 28 Nov 2001 20:24:33 -0000 1.28 --- exceptions.c 3 Mar 2002 21:30:27 -0000 1.29 *************** *** 671,675 **** PyObject_SetAttrString(klass, "lineno", Py_None) || PyObject_SetAttrString(klass, "offset", Py_None) || ! PyObject_SetAttrString(klass, "text", Py_None)) { retval = -1; --- 671,676 ---- PyObject_SetAttrString(klass, "lineno", Py_None) || PyObject_SetAttrString(klass, "offset", Py_None) || ! PyObject_SetAttrString(klass, "text", Py_None) || ! PyObject_SetAttrString(klass, "print_file_and_line", Py_None)) { retval = -1; Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.154 retrieving revision 2.155 diff -C2 -d -r2.154 -r2.155 *** pythonrun.c 12 Jan 2002 11:05:11 -0000 2.154 --- pythonrun.c 3 Mar 2002 21:30:27 -0000 2.155 *************** *** 921,925 **** err = PyTraceBack_Print(tb, f); if (err == 0 && ! PyErr_GivenExceptionMatches(exception, PyExc_SyntaxError)) { PyObject *message; --- 921,925 ---- err = PyTraceBack_Print(tb, f); if (err == 0 && ! PyObject_HasAttrString(v, "print_file_and_line")) { PyObject *message; From loewis@users.sourceforge.net Sun Mar 3 21:32:03 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Sun, 03 Mar 2002 13:32:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python compile.c,2.234.4.2,2.234.4.3 errors.c,2.66,2.66.10.1 exceptions.c,1.28,1.28.6.1 pythonrun.c,2.153.6.1,2.153.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv22284/Python Modified Files: Tag: release22-maint compile.c errors.c exceptions.c pythonrun.c Log Message: Patch #50002: Display line information for bad \x escapes: - recognize "SyntaxError"s by the print_file_and_line attribute. - add the syntaxerror attributes to all exceptions in compile.c. Fixes #221791 Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.234.4.2 retrieving revision 2.234.4.3 diff -C2 -d -r2.234.4.2 -r2.234.4.3 *** compile.c 6 Feb 2002 17:06:02 -0000 2.234.4.2 --- compile.c 3 Mar 2002 21:32:00 -0000 2.234.4.3 *************** *** 466,477 **** line = Py_None; } ! t = Py_BuildValue("(ziOO)", c->c_filename, c->c_lineno, ! Py_None, line); ! if (t == NULL) ! goto exit; ! w = Py_BuildValue("(OO)", v, t); ! if (w == NULL) ! goto exit; ! PyErr_SetObject(exc, w); exit: Py_XDECREF(t); --- 466,484 ---- line = Py_None; } ! if (exc == PyExc_SyntaxError) { ! t = Py_BuildValue("(ziOO)", c->c_filename, c->c_lineno, ! Py_None, line); ! if (t == NULL) ! goto exit; ! w = Py_BuildValue("(OO)", v, t); ! if (w == NULL) ! goto exit; ! PyErr_SetObject(exc, w); ! } else { ! /* Make sure additional exceptions are printed with ! file and line, also. */ ! PyErr_SetObject(exc, v); ! PyErr_SyntaxLocation(c->c_filename, c->c_lineno); ! } exit: Py_XDECREF(t); *************** *** 1154,1158 **** len = strlen(s); if (len > INT_MAX) { ! PyErr_SetString(PyExc_OverflowError, "string to parse is too long"); return NULL; } --- 1161,1166 ---- len = strlen(s); if (len > INT_MAX) { ! com_error(com, PyExc_OverflowError, ! "string to parse is too long"); return NULL; } *************** *** 1172,1180 **** if (unicode || Py_UnicodeFlag) { if (rawmode) ! return PyUnicode_DecodeRawUnicodeEscape( ! s, len, NULL); else ! return PyUnicode_DecodeUnicodeEscape( s, len, NULL); } #endif --- 1180,1192 ---- if (unicode || Py_UnicodeFlag) { if (rawmode) ! v = PyUnicode_DecodeRawUnicodeEscape( ! s, len, NULL); else ! v = PyUnicode_DecodeUnicodeEscape( s, len, NULL); + if (v == NULL) + PyErr_SyntaxLocation(com->c_filename, com->c_lineno); + return v; + } #endif *************** *** 1239,1245 **** break; } - PyErr_SetString(PyExc_ValueError, - "invalid \\x escape"); Py_DECREF(v); return NULL; default: --- 1251,1257 ---- break; } Py_DECREF(v); + com_error(com, PyExc_ValueError, + "invalid \\x escape"); return NULL; default: Index: errors.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/errors.c,v retrieving revision 2.66 retrieving revision 2.66.10.1 diff -C2 -d -r2.66 -r2.66.10.1 *** errors.c 2 Oct 2001 21:32:07 -0000 2.66 --- errors.c 3 Mar 2002 21:32:01 -0000 2.66.10.1 *************** *** 562,566 **** ! /* XXX There's a comment missing here */ void --- 562,568 ---- ! /* Set file and line information for the current exception. ! If the exception is not a SyntaxError, also sets additional attributes ! to make printing of exceptions believe it is a syntax error. */ void *************** *** 595,598 **** --- 597,620 ---- PyObject_SetAttrString(v, "text", tmp); Py_DECREF(tmp); + } + } + if (PyObject_SetAttrString(v, "offset", Py_None)) { + PyErr_Clear(); + } + if (exc != PyExc_SyntaxError) { + if (!PyObject_HasAttrString(v, "msg")) { + tmp = PyObject_Str(v); + if (tmp) { + if (PyObject_SetAttrString(v, "msg", tmp)) + PyErr_Clear(); + Py_DECREF(tmp); + } else { + PyErr_Clear(); + } + } + if (!PyObject_HasAttrString(v, "print_file_and_line")) { + if (PyObject_SetAttrString(v, "print_file_and_line", + Py_None)) + PyErr_Clear(); } } Index: exceptions.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/exceptions.c,v retrieving revision 1.28 retrieving revision 1.28.6.1 diff -C2 -d -r1.28 -r1.28.6.1 *** exceptions.c 28 Nov 2001 20:24:33 -0000 1.28 --- exceptions.c 3 Mar 2002 21:32:01 -0000 1.28.6.1 *************** *** 671,675 **** PyObject_SetAttrString(klass, "lineno", Py_None) || PyObject_SetAttrString(klass, "offset", Py_None) || ! PyObject_SetAttrString(klass, "text", Py_None)) { retval = -1; --- 671,676 ---- PyObject_SetAttrString(klass, "lineno", Py_None) || PyObject_SetAttrString(klass, "offset", Py_None) || ! PyObject_SetAttrString(klass, "text", Py_None) || ! PyObject_SetAttrString(klass, "print_file_and_line", Py_None)) { retval = -1; Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.153.6.1 retrieving revision 2.153.6.2 diff -C2 -d -r2.153.6.1 -r2.153.6.2 *** pythonrun.c 12 Jan 2002 11:13:24 -0000 2.153.6.1 --- pythonrun.c 3 Mar 2002 21:32:01 -0000 2.153.6.2 *************** *** 921,925 **** err = PyTraceBack_Print(tb, f); if (err == 0 && ! PyErr_GivenExceptionMatches(exception, PyExc_SyntaxError)) { PyObject *message; --- 921,925 ---- err = PyTraceBack_Print(tb, f); if (err == 0 && ! PyObject_HasAttrString(v, "print_file_and_line")) { PyObject *message; From loewis@users.sourceforge.net Sun Mar 3 21:32:03 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Sun, 03 Mar 2002 13:32:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.337.2.4.2.1,1.337.2.4.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv22284/Misc Modified Files: Tag: release22-maint NEWS Log Message: Patch #50002: Display line information for bad \x escapes: - recognize "SyntaxError"s by the print_file_and_line attribute. - add the syntaxerror attributes to all exceptions in compile.c. Fixes #221791 Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.337.2.4.2.1 retrieving revision 1.337.2.4.2.2 diff -C2 -d -r1.337.2.4.2.1 -r1.337.2.4.2.2 *** NEWS 10 Jan 2002 13:51:05 -0000 1.337.2.4.2.1 --- NEWS 3 Mar 2002 21:32:00 -0000 1.337.2.4.2.2 *************** *** 3,6 **** --- 3,12 ---- =============================== + Core and builtins + + - PyErr_Display will provide file and line information for all exceptions + that have an attribute print_file_and_line, not just SyntaxErrors. This + fixes the bug that no proper line number is given for bad \x escapes. + Library From bwarsaw@users.sourceforge.net Sun Mar 3 22:46:48 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Sun, 03 Mar 2002 14:46:48 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/email Generator.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv14468 Modified Files: Generator.py Log Message: Removed two unused imports. Closes patch #525225. 2.2.1 candidate (but not terribly important). Index: Generator.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Generator.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Generator.py 19 Oct 2001 04:06:39 -0000 1.6 --- Generator.py 3 Mar 2002 22:46:46 -0000 1.7 *************** *** 12,19 **** from cStringIO import StringIO - # Intrapackage imports - import Message - import Errors - EMPTYSTRING = '' SEMISPACE = '; ' --- 12,15 ---- From gvanrossum@users.sourceforge.net Sun Mar 3 23:16:23 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sun, 03 Mar 2002 15:16:23 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.27,1.28 test_datetime.py,1.19,1.20 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv22462 Modified Files: datetime.py test_datetime.py Log Message: Attempt to fix ctime() to avoid dependence on time.localtime(). XXX This probably breaks when the time module's epoch isn't 1/1/1970! - Add global arrays _MONTHNAMES and _DAYNAMES - Augment class tmxxx: - Note in time() docstring that it assumes UTC - Add ctime() method - Add _localtzoffset() function which attempts to calculate the tzoffset for a given local time. It asks localtime() if possible, but if that fails just assumes time.timezone. - Use _localtzoffset() to calculate the default tzoffset; correct, but even slower than before - Change _mktime() to use tmxxx() instead of the time module - Change _utc_ymdHM() to use tmxxx() instead of repeating the work - Change ctime() and utcctime() to do the right thing, using tmxxx (mostly; there's some stuff with renormalizing for the local time zone that I've probably gotten wrong) - Fix a comment or two Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** datetime.py 3 Mar 2002 21:24:33 -0000 1.27 --- datetime.py 3 Mar 2002 23:16:21 -0000 1.28 *************** *** 92,95 **** --- 92,100 ---- return year, month, n-dbm + # Month and day names. For localized versions, see the calendar module. + _MONTHNAMES = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] + _DAYNAMES = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] + # This is a start at a struct tm workalike. Goals: # *************** *** 141,145 **** def time(self): ! "Return Unixish timestamp, as a float." if self.ordinal is None: self.ordinal = _ymd2ord(self.year, self.month, self.day) --- 146,150 ---- def time(self): ! "Return Unixish timestamp, as a float (assuming UTC)." if self.ordinal is None: self.ordinal = _ymd2ord(self.year, self.month, self.day) *************** *** 148,151 **** --- 153,183 ---- return seconds + self.second + self.microsecond / 1e6 + def ctime(self): + "Return ctime() style string." + if self.ordinal is None: + self.ordinal = _ymd2ord(self.year, self.month, self.day) + weekday = self.ordinal % 7 or 7 + return "%s %s %2d %02d:%02d:%02d %04d" % ( + _DAYNAMES[weekday - 1], + _MONTHNAMES[self.month - 1], + self.day, + self.hour, self.minute, self.second, + self.year) + + + def _localtzoffset(year, month, day, hour, minute): + "Return tzoffset for local time corresponding to given date/time." + try: + t = _time.mktime((year, month, day, hour, minute, 0, -1, -1, -1)) + tm = _time.localtime(t) + if tm.tm_isdst > 0: + return - (_time.altzone // 60) + else: + return - (_time.timezone // 60) + except (ValueError, OverflowError): + # XXX Dates out of range for mktime() never see DST + return - (_time.timezone // 60) + + class basetime(object): """Abstract date/time type. *************** *** 331,336 **** """ - __isdst = None - def __init__(self, year, month, day, hour=0, minute=0, second=0, microsecond=0, tzoffset=None): --- 363,366 ---- *************** *** 361,372 **** raise ValueError('microsecond must be in 0..999999', microsecond) if tzoffset is None: ! # XXX This decides whether local time is DST or not once, ! # and never changes its mind, regardless how long we run ! if datetime.__isdst is None: ! datetime.__isdst = _time.localtime()[-1] ! if datetime.__isdst > 0: ! tzoffset = -(_time.altzone // 60) ! else: ! tzoffset = -(_time.timezone // 60) if not -1439 <= tzoffset <= 1439: raise ValueError('tzoffset must be in -1439..1439', tzoffset) --- 391,396 ---- raise ValueError('microsecond must be in 0..999999', microsecond) if tzoffset is None: ! # XXX Correct, but expensive ! tzoffset = _localtzoffset(year, month, day, hour, minute) if not -1439 <= tzoffset <= 1439: raise ValueError('tzoffset must be in -1439..1439', tzoffset) *************** *** 457,467 **** # Standard conversions, __cmp__, __hash__ (and helpers) def _mktime(self): ! # Helper to call time.mktime() ! y, m, d = self.__year, self.__month, self.__day ! hh, mm, ss = self.__hour, self.__minute, self.__second ! mm -= self.__tzoffset # tzoffset is negative in the US ! ss -= _time.timezone # but time.timezone has the opposite sign! ! return _time.mktime((y, m, d, hh, mm, ss, -1, -1, -1)) def _timestamp(self): --- 481,491 ---- # Standard conversions, __cmp__, __hash__ (and helpers) + # XXX These should be done without reference to the time module + def _mktime(self): ! # Helper to return a POSIX-ish timestamp ! t = tmxxx(self.__year, self.__month, self.__day, ! self.__hour, self.__minute - self.__tzoffset, self.__second) ! return t.time() + self.__microsecond / 1e6 def _timestamp(self): *************** *** 505,539 **** def _utc_ymdHM(self): # Helper to return (year, month, day, hour, minute) in UTC equivalent ! y, m, d = self.__year, self.__month, self.__day ! H, M = self.__hour, self.__minute ! if self.__tzoffset: ! M -= self.__tzoffset ! if not 0 <= M <= 59: ! carry, M = divmod(M, 60) ! H += carry ! if not 0 <= H <= 23: ! carry, H = divmod(H, 24) ! # tzoffset is less than a day, so carry is no more than 1. ! if carry > 0: ! assert carry == 1 ! d += 1 ! if d > _days_in_month(m, y): ! d = 1 ! m += 1 ! if m > 12: ! m = 1 ! y += 1 ! else: ! assert carry == -1 ! d -= 1 ! if d == 0: ! m -= 1 ! if m > 0: ! d = _days_in_month(m, y) ! else: ! d = 31 ! m = 12 ! y -= 1 ! return y, m, d, H, M def __hash__(self): --- 529,535 ---- def _utc_ymdHM(self): # Helper to return (year, month, day, hour, minute) in UTC equivalent ! t = tmxxx(self.__year, self.__month, self.__day, ! self.__hour, self.__minute - self.__tzoffset) ! return t.year, t.month, t.day, t.hour, t.minute def __hash__(self): *************** *** 559,563 **** def ctime(self): "Format a la ctime() in local time." ! return _time.strftime("%c", _time.localtime(self._mktime())) def strftime(self, fmt): --- 555,568 ---- def ctime(self): "Format a la ctime() in local time." ! tzoffset = _localtzoffset(self.__year, self.__month, self.__day, 0, 0) ! t = tmxxx(self.__year, self.__month, self.__day, self.__hour, ! self.__minute - self.__tzoffset + tzoffset, self.__second) ! tzoffset1 = _localtzoffset(t.year, t.month, t.day, t.hour, t.minute) ! if tzoffset1 != tzoffset: ! t = tmxxx(t.year, t.month, t.day, t.hour, ! t.minute - tzoffset + tzoffset1, self.__second) ! tzoffset2 = _localtzoffset(t.year, t.month, t.day, t.hour, t.minute) ! assert tzoffset2 == tzoffset1 # XXX Hah! ! return t.ctime() def strftime(self, fmt): *************** *** 567,571 **** def utcctime(self): "Format a la ctime() in UTC." ! return _time.strftime("%c", _time.gmtime(self._mktime())) def utcstrftime(self, fmt): --- 572,578 ---- def utcctime(self): "Format a la ctime() in UTC." ! t = tmxxx(self.__year, self.__month, self.__day, ! self.__hour, self.__minute - self.__tzoffset, self.__second) ! return t.ctime() def utcstrftime(self, fmt): *************** *** 652,656 **** week1monday = _isoweek1monday(year) today = _ymd2ord(self.__year, self.__month, self.__day) ! # Internally, week has origin 0 week, day = divmod(today - week1monday, 7) if week < 0: --- 659,663 ---- week1monday = _isoweek1monday(year) today = _ymd2ord(self.__year, self.__month, self.__day) ! # Internally, week and day have origin 0 week, day = divmod(today - week1monday, 7) if week < 0: Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** test_datetime.py 3 Mar 2002 21:24:33 -0000 1.19 --- test_datetime.py 3 Mar 2002 23:16:21 -0000 1.20 *************** *** 316,319 **** --- 316,334 ---- self.assertEqual(timestamp, tm.time()) + def test_ctime(self): + t = datetime(2002, 3, 2, 18, 3, 5, 123) + self.assertEqual(t.ctime(), "Sat Mar 2 18:03:05 2002") + # XXX Can only test utcctime() in known timezone :-( + # XXX What about the southern hemisphere, where this is DST? + import time + if time.timezone == 5*3600: + self.assertEqual(t.utcctime(), "Sat Mar 2 23:03:05 2002") + elif time.timezone == 0: + self.assertEqual(t.utcctime(), "Sat Mar 2 18:03:05 2002") + elif time.timezone == 3600: + self.assertEqual(t.utcctime(), "Sat Mar 2 17:03:05 2002") + else: + self.fail("Can't test utcctime()") + def test_suite(): s1 = unittest.makeSuite(TestDateTime, 'test') From tim_one@users.sourceforge.net Sun Mar 3 23:17:04 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 03 Mar 2002 15:17:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.223,2.224 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv23112/python/Modules Modified Files: posixmodule.c Log Message: Python no longer compiled on Windows, due to #include file confusion over SEP, ALTSEP and MAXPATHLEN. Patched up posixmodule.c for MSVC, but unsure what the story is now on other non-Unixish platforms -- the preprocessor maze has no exit . Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.223 retrieving revision 2.224 diff -C2 -d -r2.223 -r2.224 *** posixmodule.c 3 Mar 2002 03:07:07 -0000 2.223 --- posixmodule.c 3 Mar 2002 23:17:02 -0000 2.224 *************** *** 194,201 **** #endif /* HAVE_SYS_UTSNAME_H */ - #ifndef MAXPATHLEN - #define MAXPATHLEN 1024 - #endif /* MAXPATHLEN */ - #ifdef HAVE_DIRENT_H #include --- 194,197 ---- *************** *** 224,227 **** --- 220,224 ---- #include #include + #include "osdefs.h" #define WINDOWS_LEAN_AND_MEAN #include *************** *** 238,241 **** --- 235,242 ---- #include #endif /* OS2 */ + + #ifndef MAXPATHLEN + #define MAXPATHLEN 1024 + #endif /* MAXPATHLEN */ #ifdef UNION_WAIT From tim_one@users.sourceforge.net Mon Mar 4 00:14:56 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 03 Mar 2002 16:14:56 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv10857 Modified Files: datetime.py Log Message: _ord2ymd(): Deal with the switch to year-one based computation more gracefully, and add extensive explanation. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** datetime.py 3 Mar 2002 23:16:21 -0000 1.28 --- datetime.py 4 Mar 2002 00:14:54 -0000 1.29 *************** *** 71,94 **** "ordinal -> (year, month, day), considering 01-Jan-0001 as day 1." ! n400 = (n-1) // _DI400Y # number of 400-year blocks preceding ! year = n400 * 400 + 1 ! n -= n400 * _DI400Y ! more = n // 365 ! dby = _days_before_year(more + 1) ! if dby >= n: ! dby -= _days_in_year(more) ! more -= 1 ! year += more ! assert n > dby ! n -= dby month = min(n//29 + 1, 12) ! dbm = _days_before_month(month, year) ! if dbm >= n: month -= 1 ! dbm -= _days_in_month(month, year) ! assert n > dbm ! return year, month, n-dbm # Month and day names. For localized versions, see the calendar module. --- 71,126 ---- "ordinal -> (year, month, day), considering 01-Jan-0001 as day 1." ! # n is a 1-based index, starting at 1-Jan-1. The pattern of leap years ! # repeats exactly every 400 years. The basic strategy is to find the ! # closest 400-year boundary at or before n, then work with the offset ! # from that boundary to n. Life is much clearer if we subtract 1 from ! # n first -- then the values of n at 400-year boundaries are exactly ! # those divisible by _DI400Y: ! # ! # D M Y n n-1 ! # -- --- ---- ---------- ---------------- ! # 31 Dec -400 -_DI400Y -_DI400Y -1 ! # 1 Jan -399 -_DI400Y +1 -_DI400Y 400-year boundary ! # ... ! # 30 Dec 000 -1 -2 ! # 31 Dec 000 0 -1 ! # 1 Jan 001 1 0 400-year boundary ! # 2 Jan 001 2 1 ! # 3 Jan 001 3 2 ! # ... ! # 31 Dec 400 _DI400Y _DI400Y -1 ! # 1 Jan 401 _DI400Y +1 _DI400Y 400-year boundary ! n -= 1 ! n400, n = divmod(n, _DI400Y) ! year = n400 * 400 + 1 # ..., -399, 1, 401, ... ! # Now n is the (non-negative) offset, in days, from January 1 of year, to ! # the desired date. First compute how many whole years precede the ! # desired date. Dividing by 365 gives an upper bound quickly, and it's ! # easy to show that it's either exact or one too large (note that this ! # relies on that n < _DI400Y; if we did this before factoring out a close ! # 400-year boundary, there's no bound on how far off n//365 could be). ! whole_years_preceding = n // 365 ! exact_days = _days_before_year(whole_years_preceding + 1) ! if exact_days > n: # estimate is too large ! exact_days -= _days_in_year(whole_years_preceding) ! whole_years_preceding -= 1 ! assert 0 <= exact_days <= n ! year += whole_years_preceding ! n -= exact_days + # Now the year is correct, and n is the offset from January 1. We find + # the month via another estimate that's either exact or one too large. month = min(n//29 + 1, 12) ! exact_days = _days_before_month(month, year) ! if exact_days > n: # estimate is too large month -= 1 ! exact_days -= _days_in_month(month, year) ! assert 0 <= exact_days <= n ! n -= exact_days ! ! # Now the year and month are correct, and n is the offset from the ! # start of that month: we're done! ! return year, month, n+1 # Month and day names. For localized versions, see the calendar module. From tim_one@users.sourceforge.net Mon Mar 4 00:53:03 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 03 Mar 2002 16:53:03 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.29,1.30 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv22303 Modified Files: datetime.py Log Message: tmxxx.__init__(): Optimize for common cases. This got more important when __hash__ started using tmxxx. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** datetime.py 4 Mar 2002 00:14:54 -0000 1.29 --- datetime.py 4 Mar 2002 00:53:01 -0000 1.30 *************** *** 147,158 **** microsecond=0): # Normalize all the inputs, and store the normalized values. ! carry, microsecond = divmod(microsecond, 1000000) ! second += carry ! carry, second = divmod(second, 60) ! minute += carry ! carry, minute = divmod(minute, 60) ! hour += carry ! carry, hour = divmod(hour, 24) ! day += carry # That was easy. Now it gets muddy: the proper range for day # can't be determined without knowing the correct month and year, --- 147,163 ---- microsecond=0): # Normalize all the inputs, and store the normalized values. ! if not 0 <= microsecond <= 999999: ! carry, microsecond = divmod(microsecond, 1000000) ! second += carry ! if not 0 <= second <= 59: ! carry, second = divmod(second, 60) ! minute += carry ! if not 0 <= minute <= 59: ! carry, minute = divmod(minute, 60) ! hour += carry ! if not 0 <= hour <= 23: ! carry, hour = divmod(hour, 24) ! day += carry ! # That was easy. Now it gets muddy: the proper range for day # can't be determined without knowing the correct month and year, *************** *** 161,176 **** # themselves). # Saying 12 months == 1 year should be non-controversial. ! carry, month = divmod(month-1, 12) ! year += carry ! month += 1 ! assert 1 <= month <= 12 ! # Now only day can be out of bounds. If it is, what to do is arguable, ! # but at least the method here is principled and explainable. ! if not 1 <= day <= _days_in_month(month, year): ! # Note that the "if" test is for efficiency, not correctness: ! # there's simply no need to do this dance if day is already in ! # range, and it's an expensive dance. ! self.ordinal = _ymd2ord(year, month, 1) + (day - 1) ! year, month, day = _ord2ymd(self.ordinal) self.year, self.month, self.day = year, month, day self.hour, self.minute, self.second = hour, minute, second --- 166,200 ---- # themselves). # Saying 12 months == 1 year should be non-controversial. ! if not 1 <= month <= 12: ! carry, month = divmod(month-1, 12) ! year += carry ! month += 1 ! assert 1 <= month <= 12 ! ! # Now only day can be out of bounds (year may also be out of bounds ! # for a datetime object, but we don't care about that here). ! # If day is out of bounds, what to do is arguable, but at least the ! # method here is principled and explainable. ! dim = _days_in_month(month, year) ! if not 1 <= day <= dim: ! # Move day-1 days from the first of the month. First try to ! # get off cheap if we're only one day out of range (adjustments ! # for timezone alone can't be worse than that). ! if day == 0: # move back a day ! month -= 1 ! if month > 0: ! day = _days_in_month(month, year) ! else: ! year, month, day = year-1, 12, 31 ! elif day == dim + 1: # move forward a day ! month += 1 ! day = 1 ! if month > 12: ! month = 1 ! year += 1 ! else: ! self.ordinal = _ymd2ord(year, month, 1) + (day - 1) ! year, month, day = _ord2ymd(self.ordinal) ! self.year, self.month, self.day = year, month, day self.hour, self.minute, self.second = hour, minute, second From tim_one@users.sourceforge.net Mon Mar 4 01:03:16 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 03 Mar 2002 17:03:16 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.30,1.31 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv25440 Modified Files: datetime.py Log Message: Give tmxxx a toordinal() method, and use it (squash code duplication). Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** datetime.py 4 Mar 2002 00:53:01 -0000 1.30 --- datetime.py 4 Mar 2002 01:03:14 -0000 1.31 *************** *** 201,209 **** self.microsecond = microsecond ! def time(self): ! "Return Unixish timestamp, as a float (assuming UTC)." if self.ordinal is None: self.ordinal = _ymd2ord(self.year, self.month, self.day) ! days = self.ordinal - _ORD1970 # convert to UNIX epoch seconds = ((days * 24. + self.hour)*60. + self.minute)*60. return seconds + self.second + self.microsecond / 1e6 --- 201,217 ---- self.microsecond = microsecond ! def toordinal(self): ! """Return proleptic Gregorian ordinal for the year, month and day. ! ! January 1 of year 1 is day 1. Only the year, month and day values ! contribute to the result. ! """ if self.ordinal is None: self.ordinal = _ymd2ord(self.year, self.month, self.day) ! return self.ordinal ! ! def time(self): ! "Return Unixish timestamp, as a float (assuming UTC)." ! days = self.toordinal() - _ORD1970 # convert to UNIX epoch seconds = ((days * 24. + self.hour)*60. + self.minute)*60. return seconds + self.second + self.microsecond / 1e6 *************** *** 211,217 **** def ctime(self): "Return ctime() style string." ! if self.ordinal is None: ! self.ordinal = _ymd2ord(self.year, self.month, self.day) ! weekday = self.ordinal % 7 or 7 return "%s %s %2d %02d:%02d:%02d %04d" % ( _DAYNAMES[weekday - 1], --- 219,223 ---- def ctime(self): "Return ctime() style string." ! weekday = self.toordinal() % 7 or 7 return "%s %s %2d %02d:%02d:%02d %04d" % ( _DAYNAMES[weekday - 1], From tim_one@users.sourceforge.net Mon Mar 4 01:15:01 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 03 Mar 2002 17:15:01 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.20,1.21 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv28300 Modified Files: test_datetime.py Log Message: test_ordinal_conversions(): Exhaustively test ordinal<->date for every day in a leap year, and in a non leap year. Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** test_datetime.py 3 Mar 2002 23:16:21 -0000 1.20 --- test_datetime.py 4 Mar 2002 01:14:59 -0000 1.21 *************** *** 64,67 **** --- 64,79 ---- self.assertEqual(_ymd2ord(year-1, 12, 31), n-1) + # Test every day in a leap-year and a non-leap year. + dim = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] + for year, isleap in (2000, 1), (2002, 0): + n = _ymd2ord(year, 1, 1) + for month, maxday in zip(range(1, 13), dim): + if month == 2 and isleap: + maxday += 1 + for day in range(1, maxday+1): + self.assertEqual((year, month, day), _ord2ymd(n)) + self.assertEqual(n, _ymd2ord(year, month, day)) + n += 1 + def test_bad_constructor_arguments(self): from datetime import MINYEAR, MAXYEAR From tim_one@users.sourceforge.net Mon Mar 4 01:18:14 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 03 Mar 2002 17:18:14 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv29431 Modified Files: test_datetime.py Log Message: test_basic_attributes(): Verify that microsecond defaulted to 0. Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** test_datetime.py 4 Mar 2002 01:14:59 -0000 1.21 --- test_datetime.py 4 Mar 2002 01:18:12 -0000 1.22 *************** *** 19,22 **** --- 19,23 ---- self.assertEqual(dt.minute, 0) self.assertEqual(dt.second, 0) + self.assertEqual(dt.microsecond, 0) def test_roundtrip(self): From tim_one@users.sourceforge.net Mon Mar 4 01:24:52 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 03 Mar 2002 17:24:52 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.22,1.23 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv31092 Modified Files: test_datetime.py Log Message: test_bad_constructor_arguments(): add tests for bad microsecond and tzoffset arguments. Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** test_datetime.py 4 Mar 2002 01:18:12 -0000 1.22 --- test_datetime.py 4 Mar 2002 01:24:50 -0000 1.23 *************** *** 114,117 **** --- 114,128 ---- self.assertRaises(ValueError, datetime, 2000, 1, 31, 23, 59, -1) self.assertRaises(ValueError, datetime, 2000, 1, 31, 23, 59, 60) + # bad microseconds + datetime(2000, 1, 31, 23, 59, 59, 0) # no exception + datetime(2000, 1, 31, 23, 59, 59, 999999) # no exception + self.assertRaises(ValueError, datetime, 2000, 1, 31, 23, 59, 59, -1) + self.assertRaises(ValueError, datetime, 2000, 1, 31, 23, 59, 59, + 1000000) + # bad tzoffet + datetime(2, 1, 1, 0, 0, 0, 0, -1439) # no exception + datetime(2, 1, 1, 0, 0, 0, 0, 1439) # no exception + self.assertRaises(ValueError, datetime, 2, 1, 1, 0, 0, 0, 0, -1440) + self.assertRaises(ValueError, datetime, 2, 1, 1, 0, 0, 0, 0, 1440) def test_hash_equality(self): From tim_one@users.sourceforge.net Mon Mar 4 01:39:55 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 03 Mar 2002 17:39:55 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.31,1.32 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv1894 Modified Files: datetime.py Log Message: Removed datetime._timestamp(): it called datetime._mktime(), then added in microseconds. But datetime._mktime() already adds in microseconds, so _timestamp() was just a buggy synonyn. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** datetime.py 4 Mar 2002 01:03:14 -0000 1.31 --- datetime.py 4 Mar 2002 01:39:53 -0000 1.32 *************** *** 551,558 **** return t.time() + self.__microsecond / 1e6 - def _timestamp(self): - # Helper like _mktime() that adds microseconds - return self._mktime() + self.__microsecond / 1e6 - def timetuple(self): "Return local time tuple compatible with time.localtime()." --- 551,554 ---- *************** *** 584,588 **** (y2, m2, d2, hh2, mm2, ss2, tz2)) else: ! return cmp(self._timestamp(), other._timestamp()) else: raise TypeError, ("can't compare datetime to %s instance" % --- 580,584 ---- (y2, m2, d2, hh2, mm2, ss2, tz2)) else: ! return cmp(self._mktime(), other._mktime()) else: raise TypeError, ("can't compare datetime to %s instance" % From tim_one@users.sourceforge.net Mon Mar 4 01:42:05 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 03 Mar 2002 17:42:05 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.32,1.33 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv3729 Modified Files: datetime.py Log Message: datetime._mktime(): defer entirely to tmxxx.time(). The latter already knows how to-- and is --adding in microseconds. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** datetime.py 4 Mar 2002 01:39:53 -0000 1.32 --- datetime.py 4 Mar 2002 01:42:03 -0000 1.33 *************** *** 548,553 **** # Helper to return a POSIX-ish timestamp t = tmxxx(self.__year, self.__month, self.__day, ! self.__hour, self.__minute - self.__tzoffset, self.__second) ! return t.time() + self.__microsecond / 1e6 def timetuple(self): --- 548,554 ---- # Helper to return a POSIX-ish timestamp t = tmxxx(self.__year, self.__month, self.__day, ! self.__hour, self.__minute - self.__tzoffset, self.__second, ! self.__microsecond) ! return t.time() def timetuple(self): From tim_one@users.sourceforge.net Mon Mar 4 02:23:28 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 03 Mar 2002 18:23:28 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.33,1.34 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv13979 Modified Files: datetime.py Log Message: timedelta.__add__(): Improve floating-point accuracy. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** datetime.py 4 Mar 2002 01:42:03 -0000 1.33 --- datetime.py 4 Mar 2002 02:23:26 -0000 1.34 *************** *** 7,10 **** --- 7,11 ---- import time as _time + import math as _math MINYEAR = 1 # XXX The design doc says 0 *************** *** 335,343 **** self.__microseconds) if isinstance(other, float): ! ss, us = divmod(other*1e6, 1e6) ! d, ss = divmod(ss, 24*3600) ! return timedelta(self.__days + int(d), ! self.__seconds + int(ss), ! self.__microseconds + int(round(us))) return NotImplemented --- 336,349 ---- self.__microseconds) if isinstance(other, float): ! sign = 1 ! if other < 0: ! sign, other = -1, -other ! frac, whole = _math.modf(other) ! us = int(frac * 1e6 + 0.5) ! assert 0 <= us <= 1000000 # if 1e6, constructor will normalize ! days, seconds = divmod(whole, 24*3600) ! return timedelta(self.__days + sign * int(days), ! self.__seconds + sign * int(seconds), ! self.__microseconds + sign * us) return NotImplemented From tim_one@users.sourceforge.net Mon Mar 4 02:25:30 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 03 Mar 2002 18:25:30 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.34,1.35 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv15437 Modified Files: datetime.py Log Message: timedelta docstring: document that int/long/float seconds work w/ + and -. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** datetime.py 4 Mar 2002 02:23:26 -0000 1.34 --- datetime.py 4 Mar 2002 02:25:28 -0000 1.35 *************** *** 270,273 **** --- 270,274 ---- - add, subtract timedelta + - add, subtract int/long/float seconds - unary plus, minus, abs - compare to timedelta From tim_one@users.sourceforge.net Mon Mar 4 02:43:58 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 03 Mar 2002 18:43:58 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.35,1.36 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv18830 Modified Files: datetime.py Log Message: datetime.__add__(): When adding a float, let the careful fp code in timedelta.__add__ handle it instead. Since floating-point code is always wrong <0.5 wink>, duplication of fp code should be avoided at almost any cost. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** datetime.py 4 Mar 2002 02:25:28 -0000 1.35 --- datetime.py 4 Mar 2002 02:43:56 -0000 1.36 *************** *** 672,678 **** return self + timedelta(0, other) elif isinstance(other, float): ! ss, us = divmod(other*1e6, 1e6) ! d, ss = divmod(ss, 24*3600) ! return self + timedelta(int(d), int(ss), int(round(us))) return NotImplemented --- 672,676 ---- return self + timedelta(0, other) elif isinstance(other, float): ! return self + (timedelta(0) + other) return NotImplemented From tim_one@users.sourceforge.net Mon Mar 4 03:01:17 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 03 Mar 2002 19:01:17 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.36,1.37 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv23783 Modified Files: datetime.py Log Message: datetime.__add__(): when adding a timedelta, let tmxxx handle the normalization (Guido remarked on the Wiki that this is what he wanted normalization for -- finally got around to it ). Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** datetime.py 4 Mar 2002 02:43:56 -0000 1.36 --- datetime.py 4 Mar 2002 03:01:14 -0000 1.37 *************** *** 654,671 **** """ if isinstance(other, timedelta): ! hh, mm, ss, us = (self.__hour, ! self.__minute, ! self.__second + other.seconds, ! self.__microsecond + other.microseconds) ! carry_ss, us = divmod(us, 1000000) ! carry_mm, ss = divmod(ss+carry_ss, 60) ! carry_hh, mm = divmod(mm+carry_mm, 60) ! days, hh = divmod(hh+carry_hh, 24) ! result = datetime.fromordinal(days + other.days + self.toordinal()) ! result.__hour = hh ! result.__minute = mm ! result.__second = ss ! result.__microsecond = us ! result.__tzoffset = self.__tzoffset return result elif isinstance(other, (int, long)): --- 654,667 ---- """ if isinstance(other, timedelta): ! t = tmxxx(self.__year, ! self.__month, ! self.__day + other.days, ! self.__hour, ! self.__minute, ! self.__second + other.seconds, ! self.__microsecond + other.microseconds) ! result = datetime.new(t.year, t.month, t.day, ! t.hour, t.minute, t.second, ! t.microsecond, self.__tzoffset) return result elif isinstance(other, (int, long)): From tim_one@users.sourceforge.net Mon Mar 4 06:10:17 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 03 Mar 2002 22:10:17 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.37,1.38 test_datetime.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv26196 Modified Files: datetime.py test_datetime.py Log Message: Fixed two bugs in datetime.__cmp__: 1. Shallow. When the tzoffsets matched, it forgot to compare microseconds. 2. Not so shallow. When the tzoffsets didn't match, it reverted to comparing timestamps, but an IEEE double doesn't have enough precision to avoid mapping distinct datetimes onto the same timestamp. It takes about 38 bits to distinguish the individual seconds across 10000 years, leaving only about 53-38 = 15 bits to distinguish the microseconds. As a result, non-equal datetimes could compare equal, especially for years near MAXYEAR. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** datetime.py 4 Mar 2002 03:01:14 -0000 1.37 --- datetime.py 4 Mar 2002 06:10:15 -0000 1.38 *************** *** 578,592 **** "Three-way comparison." if isinstance(other, datetime): ! if other.__tzoffset == self.__tzoffset: y, m, d = self.__year, self.__month, self.__day ! hh, mm, ss = self.__hour, self.__minute, self.__second ! tz = self.__tzoffset y2, m2, d2 = other.__year, other.__month, other.__day ! hh2, mm2, ss2 = other.__hour, other.__minute, other.__second ! tz2 = other.__tzoffset ! return cmp((y, m, d, hh, mm, ss, tz), ! (y2, m2, d2, hh2, mm2, ss2, tz2)) else: ! return cmp(self._mktime(), other._mktime()) else: raise TypeError, ("can't compare datetime to %s instance" % --- 578,593 ---- "Three-way comparison." if isinstance(other, datetime): ! if self.__tzoffset == other.__tzoffset: y, m, d = self.__year, self.__month, self.__day ! H, M = self.__hour, self.__minute y2, m2, d2 = other.__year, other.__month, other.__day ! H2, M2 = other.__hour, other.__minute else: ! y, m, d, H, M = self._utc_ymdHM() ! y2, m2, d2, H2, M2 = other._utc_ymdHM() ! return cmp((y, m, d, H, M, ! self.__second, self.__microsecond), ! (y2, m2, d2, H2, M2, ! other.__second, other.__microsecond)) else: raise TypeError, ("can't compare datetime to %s instance" % Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** test_datetime.py 4 Mar 2002 01:24:50 -0000 1.23 --- test_datetime.py 4 Mar 2002 06:10:15 -0000 1.24 *************** *** 7,11 **** import unittest ! from datetime import datetime, timedelta class TestDateTime(unittest.TestCase): --- 7,11 ---- import unittest ! from datetime import datetime, timedelta, MINYEAR, MAXYEAR class TestDateTime(unittest.TestCase): *************** *** 42,47 **** self.assert_(dt2 > dt3) def test_ordinal_conversions(self): ! from datetime import _ymd2ord, _ord2ymd, MINYEAR, MAXYEAR # Check some fixed values. --- 42,66 ---- self.assert_(dt2 > dt3) + # Make sure comparison doesn't forget microseconds, and isn't done + # via comparing a float timestamp (an IEEE double doesn't have enough + # precision to span microsecond resolution across years 1 thru 9999, + # so comparing via timestamp necessarily calls some distinct values + # equal). + dt1 = datetime.new(MAXYEAR, 12, 31, 23, 59, 59, 999998, 0) + us = timedelta(microseconds=1) + dt2 = dt1 + us + self.assertEqual(dt2 - dt1, us) + self.assert_(dt1 < dt2) + + # Again, but mix timezones. + dt1 = datetime.new(MAXYEAR, 12, 31, 22, 59, 59, 999998, -60) + dt2 = datetime.new(MAXYEAR, 12, 31, 23, 59, 59, 999998, 0) + self.assert_(dt1 == dt2) + dt2 += us + self.assertEqual(dt2 - dt1, us) + self.assert_(dt1 < dt2) + def test_ordinal_conversions(self): ! from datetime import _ymd2ord, _ord2ymd # Check some fixed values. *************** *** 78,82 **** def test_bad_constructor_arguments(self): - from datetime import MINYEAR, MAXYEAR # bad years datetime(MINYEAR, 1, 1) # no exception --- 97,100 ---- From mal@lemburg.com Mon Mar 4 09:13:29 2002 From: mal@lemburg.com (M.-A. Lemburg) Date: Mon, 04 Mar 2002 10:13:29 +0100 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.37,1.38 test_datetime.py,1.23,1.24 References: Message-ID: <3C833AB9.788CFE20@lemburg.com> Tim Peters wrote: > > Update of /cvsroot/python/python/nondist/sandbox/datetime > > 2. Not so shallow. When the tzoffsets didn't match, it reverted to > comparing timestamps, but an IEEE double doesn't have enough > precision to avoid mapping distinct datetimes onto the same timestamp. > It takes about 38 bits to distinguish the individual seconds across > 10000 years, leaving only about 53-38 = 15 bits to distinguish the > microseconds. As a result, non-equal datetimes could compare equal, > especially for years near MAXYEAR. Funny, how you guys run into the same problems I had at the time ;-) -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/ From loewis@users.sourceforge.net Mon Mar 4 09:38:55 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Mon, 04 Mar 2002 01:38:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules arraymodule.c,2.67,2.68 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv26372 Modified Files: arraymodule.c Log Message: Remove tp_print. Index: arraymodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v retrieving revision 2.67 retrieving revision 2.68 diff -C2 -d -r2.67 -r2.68 *** arraymodule.c 1 Mar 2002 10:27:01 -0000 2.67 --- arraymodule.c 4 Mar 2002 09:38:52 -0000 2.68 *************** *** 1428,1464 **** }; - static int - array_print(arrayobject *a, FILE *fp, int flags) - { - int ok = 0; - int i, len; - PyObject *v; - len = a->ob_size; - if (len == 0) { - fprintf(fp, "array('%c')", a->ob_descr->typecode); - return ok; - } - if (a->ob_descr->typecode == 'c') { - PyObject *t_empty = PyTuple_New(0); - fprintf(fp, "array('c', "); - v = array_tostring(a, t_empty); - Py_DECREF(t_empty); - ok = PyObject_Print(v, fp, 0); - Py_XDECREF(v); - fprintf(fp, ")"); - return ok; - } - fprintf(fp, "array('%c', [", a->ob_descr->typecode); - for (i = 0; i < len && ok == 0; i++) { - if (i > 0) - fprintf(fp, ", "); - v = (a->ob_descr->getitem)(a, i); - ok = PyObject_Print(v, fp, 0); - Py_XDECREF(v); - } - fprintf(fp, "])"); - return ok; - } - static PyObject * array_repr(arrayobject *a) --- 1428,1431 ---- *************** *** 1720,1724 **** 0, (destructor)array_dealloc, /* tp_dealloc */ ! (printfunc)array_print, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ --- 1687,1691 ---- 0, (destructor)array_dealloc, /* tp_dealloc */ ! 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ From mal@lemburg.com Mon Mar 4 09:54:31 2002 From: mal@lemburg.com (M.-A. Lemburg) Date: Mon, 04 Mar 2002 10:54:31 +0100 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.28,1.29 References: Message-ID: <3C834457.ECC484F2@lemburg.com> Tim Peters wrote: > > Index: datetime.py > =================================================================== > RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v > retrieving revision 1.28 > retrieving revision 1.29 > diff -C2 -d -r1.28 -r1.29 > *** datetime.py 3 Mar 2002 23:16:21 -0000 1.28 > --- datetime.py 4 Mar 2002 00:14:54 -0000 1.29 > *************** > *** 71,94 **** > "ordinal -> (year, month, day), considering 01-Jan-0001 as day 1." > > ! n400 = (n-1) // _DI400Y # number of 400-year blocks preceding > ! year = n400 * 400 + 1 > ! n -= n400 * _DI400Y > > ! more = n // 365 > ! dby = _days_before_year(more + 1) > ! if dby >= n: > ! dby -= _days_in_year(more) > ! more -= 1 > ! year += more > ! assert n > dby > ! n -= dby > > month = min(n//29 + 1, 12) > ! dbm = _days_before_month(month, year) > ! if dbm >= n: > month -= 1 > ! dbm -= _days_in_month(month, year) > ! assert n > dbm > ! return year, month, n-dbm > > # Month and day names. For localized versions, see the calendar module. > --- 71,126 ---- > "ordinal -> (year, month, day), considering 01-Jan-0001 as day 1." > > ! # n is a 1-based index, starting at 1-Jan-1. The pattern of leap years > ! # repeats exactly every 400 years. The basic strategy is to find the > ! # closest 400-year boundary at or before n, then work with the offset > ! # from that boundary to n. Life is much clearer if we subtract 1 from > ! # n first -- then the values of n at 400-year boundaries are exactly > ! # those divisible by _DI400Y: > ! # > ! # D M Y n n-1 > ! # -- --- ---- ---------- ---------------- > ! # 31 Dec -400 -_DI400Y -_DI400Y -1 > ! # 1 Jan -399 -_DI400Y +1 -_DI400Y 400-year boundary > ! # ... > ! # 30 Dec 000 -1 -2 > ! # 31 Dec 000 0 -1 > ! # 1 Jan 001 1 0 400-year boundary > ! # 2 Jan 001 2 1 > ! # 3 Jan 001 3 2 > ! # ... > ! # 31 Dec 400 _DI400Y _DI400Y -1 > ! # 1 Jan 401 _DI400Y +1 _DI400Y 400-year boundary > ! n -= 1 > ! n400, n = divmod(n, _DI400Y) > ! year = n400 * 400 + 1 # ..., -399, 1, 401, ... > > ! # Now n is the (non-negative) offset, in days, from January 1 of year, to > ! # the desired date. First compute how many whole years precede the > ! # desired date. Dividing by 365 gives an upper bound quickly, and it's > ! # easy to show that it's either exact or one too large (note that this > ! # relies on that n < _DI400Y; if we did this before factoring out a close > ! # 400-year boundary, there's no bound on how far off n//365 could be). > ! whole_years_preceding = n // 365 > ! exact_days = _days_before_year(whole_years_preceding + 1) > ! if exact_days > n: # estimate is too large > ! exact_days -= _days_in_year(whole_years_preceding) > ! whole_years_preceding -= 1 > ! assert 0 <= exact_days <= n > ! year += whole_years_preceding > ! n -= exact_days > > + # Now the year is correct, and n is the offset from January 1. We find > + # the month via another estimate that's either exact or one too large. > month = min(n//29 + 1, 12) > ! exact_days = _days_before_month(month, year) > ! if exact_days > n: # estimate is too large > month -= 1 > ! exact_days -= _days_in_month(month, year) > ! assert 0 <= exact_days <= n > ! n -= exact_days > ! > ! # Now the year and month are correct, and n is the offset from the > ! # start of that month: we're done! > ! return year, month, n+1 Looks a lot like what I do in mxDateTime.c :-) -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/ From tim_one@users.sourceforge.net Mon Mar 4 10:17:43 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 04 Mar 2002 02:17:43 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.38,1.39 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv2933 Modified Files: datetime.py Log Message: _ord2ymd(): Speedups, especially with an eye toward C reimplementation. This no longer makes any external calls. The computation of the year is now a mirror of that in "Calendrical Calculations", but the latter's computation of month and day is woefully inefficient. Curiously, they didn't seem to realize that leap-year determination comes almost for free from the intermediates left behind from computing the year number. Also added dummy None initial entries to the arrays indexed by month ordinal, to avoid the "-1" adjustment when subscripting. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** datetime.py 4 Mar 2002 06:10:15 -0000 1.38 --- datetime.py 4 Mar 2002 10:17:41 -0000 1.39 *************** *** 21,31 **** # proleptic Gregorian ordinals and many other calendar systems. ! _DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] ! _DAYS_BEFORE_MONTH = [] dbm = 0 ! for dim in _DAYS_IN_MONTH: _DAYS_BEFORE_MONTH.append(dbm) ! dbm = dbm + dim del dbm, dim --- 21,31 ---- # proleptic Gregorian ordinals and many other calendar systems. ! _DAYS_IN_MONTH = [None, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] ! _DAYS_BEFORE_MONTH = [None] dbm = 0 ! for dim in _DAYS_IN_MONTH[1:]: _DAYS_BEFORE_MONTH.append(dbm) ! dbm += dim del dbm, dim *************** *** 48,52 **** if month == 2 and _is_leap(year): return 29 ! return _DAYS_IN_MONTH[month-1] def _days_before_month(month, year): --- 48,52 ---- if month == 2 and _is_leap(year): return 29 ! return _DAYS_IN_MONTH[month] def _days_before_month(month, year): *************** *** 54,58 **** if not 1 <= month <= 12: raise ValueError('month must be in 1..12', month) ! return _DAYS_BEFORE_MONTH[month-1] + (month > 2 and _is_leap(year)) def _ymd2ord(year, month, day): --- 54,58 ---- if not 1 <= month <= 12: raise ValueError('month must be in 1..12', month) ! return _DAYS_BEFORE_MONTH[month] + (month > 2 and _is_leap(year)) def _ymd2ord(year, month, day): *************** *** 68,71 **** --- 68,85 ---- _DI400Y = _days_before_year(401) # number of days in 400 years + _DI100Y = _days_before_year(101) # " " " " 100 " + _DI4Y = _days_before_year(5) # " " " " 4 " + + # A 4-year cycle has an extra leap day over what we'd get from pasting + # together 4 single years. + assert _DI4Y == 4 * 365 + 1 + + # Similarly, a 400-year cycle has an extra leap day over what we'd get from + # pasting together 4 100-year cycles. + assert _DI400Y == 4 * _DI100Y + 1 + + # OTOH, a 100-year cycle has one fewer leap day than we'd get from + # pasting together 25 4-year cycles. + assert _DI100Y == 25 * _DI4Y - 1 def _ord2ymd(n): *************** *** 97,123 **** # Now n is the (non-negative) offset, in days, from January 1 of year, to ! # the desired date. First compute how many whole years precede the ! # desired date. Dividing by 365 gives an upper bound quickly, and it's ! # easy to show that it's either exact or one too large (note that this ! # relies on that n < _DI400Y; if we did this before factoring out a close ! # 400-year boundary, there's no bound on how far off n//365 could be). ! whole_years_preceding = n // 365 ! exact_days = _days_before_year(whole_years_preceding + 1) ! if exact_days > n: # estimate is too large ! exact_days -= _days_in_year(whole_years_preceding) ! whole_years_preceding -= 1 ! assert 0 <= exact_days <= n ! year += whole_years_preceding ! n -= exact_days # Now the year is correct, and n is the offset from January 1. We find ! # the month via another estimate that's either exact or one too large. month = min(n//29 + 1, 12) ! exact_days = _days_before_month(month, year) ! if exact_days > n: # estimate is too large month -= 1 ! exact_days -= _days_in_month(month, year) ! assert 0 <= exact_days <= n ! n -= exact_days # Now the year and month are correct, and n is the offset from the --- 111,143 ---- # Now n is the (non-negative) offset, in days, from January 1 of year, to ! # the desired date. Now compute how many 100-year cycles precede n. ! # Note that it's possible for n100 to equal 4! In that case 4 full ! # 100-year cycles precede the desired day, which implies the desired ! # day is December 31 at the end of a 400-year cycle. ! n100, n = divmod(n, _DI100Y) ! ! # Now compute how many 4-year cycles precede it. ! n4, n = divmod(n, _DI4Y) ! ! # And now how many single years. Again n1 can be 4, and again meaning ! # that the desired day is December 31 at the end of the 4-year cycle. ! n1, n = divmod(n, 365) ! ! year += n100 * 100 + n4 * 4 + n1 ! if n1 == 4 or n100 == 4: ! assert n == 0 ! return year-1, 12, 31 # Now the year is correct, and n is the offset from January 1. We find ! # the month via an estimate that's either exact or one too large. ! leapyear = n1 == 3 and (n4 != 24 or n100 == 3) ! assert leapyear == _is_leap(year) month = min(n//29 + 1, 12) ! preceding = _DAYS_BEFORE_MONTH[month] + (month > 2 and leapyear) ! if preceding > n: # estimate is too large month -= 1 ! preceding -= _DAYS_IN_MONTH[month] + (month == 2 and leapyear) ! assert 0 <= preceding <= n ! n -= preceding # Now the year and month are correct, and n is the offset from the From jvr@users.sourceforge.net Mon Mar 4 10:31:35 2002 From: jvr@users.sourceforge.net (Just van Rossum) Date: Mon, 04 Mar 2002 02:31:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/cg CGStubLib,1.2,1.3 CGStubLib.exp,1.2,1.3 _CGmodule.c,1.4,1.5 cgsupport.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cg In directory usw-pr-cvs1:/tmp/cvs-serv7812 Modified Files: CGStubLib CGStubLib.exp _CGmodule.c cgsupport.py Log Message: Added ClipCGContextToRegion() from Quickdraw.h. Index: CGStubLib =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/CGStubLib,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 Binary files /tmp/cvsIKKY4o and /tmp/cvs6JauSD differ Index: CGStubLib.exp =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/CGStubLib.exp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CGStubLib.exp 2 Mar 2002 10:20:44 -0000 1.2 --- CGStubLib.exp 4 Mar 2002 10:31:32 -0000 1.3 *************** *** 58,59 **** --- 58,60 ---- CreateCGContextForPort SyncCGContextOriginWithPort + ClipCGContextToRegion Index: _CGmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/_CGmodule.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** _CGmodule.c 2 Mar 2002 10:20:44 -0000 1.4 --- _CGmodule.c 4 Mar 2002 10:31:32 -0000 1.5 *************** *** 1130,1133 **** --- 1130,1150 ---- } + static PyObject *CGContextRefObj_ClipCGContextToRegion(CGContextRefObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + Rect portRect; + RgnHandle region; + if (!PyArg_ParseTuple(_args, "O&O&", + PyMac_GetRect, &portRect, + ResObj_Convert, ®ion)) + return NULL; + ClipCGContextToRegion(_self->ob_itself, + &portRect, + region); + Py_INCREF(Py_None); + _res = Py_None; + return _res; + } + static PyMethodDef CGContextRefObj_methods[] = { {"CGContextSaveGState", (PyCFunction)CGContextRefObj_CGContextSaveGState, 1, *************** *** 1245,1248 **** --- 1262,1267 ---- {"SyncCGContextOriginWithPort", (PyCFunction)CGContextRefObj_SyncCGContextOriginWithPort, 1, "(CGrafPtr port) -> None"}, + {"ClipCGContextToRegion", (PyCFunction)CGContextRefObj_ClipCGContextToRegion, 1, + "(Rect portRect, RgnHandle region) -> None"}, {NULL, NULL, 0} }; Index: cgsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/cgsupport.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** cgsupport.py 2 Mar 2002 10:20:44 -0000 1.3 --- cgsupport.py 4 Mar 2002 10:31:32 -0000 1.4 *************** *** 19,22 **** --- 19,23 ---- CGrafPtr = OpaqueByValueType("CGrafPtr", "GrafObj") + RgnHandle = OpaqueByValueType("RgnHandle", "ResObj") # Create the type objects *************** *** 283,286 **** --- 284,296 ---- ) CGContextRef_methods.append(f) + + # manual method, lives in Quickdraw.h + f = Method(void, 'ClipCGContextToRegion', + (CGContextRef, 'ctx', InMode), + (Rect, 'portRect', InMode), + (RgnHandle, 'region', InMode), + ) + CGContextRef_methods.append(f) + CreateCGContextForPort_body = """\ From tim.one@comcast.net Mon Mar 4 10:36:51 2002 From: tim.one@comcast.net (Tim Peters) Date: Mon, 04 Mar 2002 05:36:51 -0500 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.28,1.29 In-Reply-To: <3C834457.ECC484F2@lemburg.com> Message-ID: [M.-A. Lemburg] > Looks a lot like what I do in mxDateTime.c :-) The key difference is that the Dates.py Gregorian algorithms were loop-free, no matter how large or small the year, even if the year requires a million bits to express (although not even Guido may live long enough to verify that in person ). From mal@lemburg.com Mon Mar 4 11:07:46 2002 From: mal@lemburg.com (M.-A. Lemburg) Date: Mon, 04 Mar 2002 12:07:46 +0100 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetimedatetime.py,1.28,1.29 References: Message-ID: <3C835582.23FE9B1A@lemburg.com> Tim Peters wrote: > > [M.-A. Lemburg] > > Looks a lot like what I do in mxDateTime.c :-) > > The key difference is that the Dates.py Gregorian algorithms were loop-free, > no matter how large or small the year, even if the year requires a million > bits to express (although not even Guido may live long enough to verify that > in person ). Oh, the mxDateTime algorithm is loop-free in a sense as well: the correction does at most 3 iterations, the month finder at most 12 iterations. I'll have a look at yours, though. Perhaps I can make the algorithms a bit faster ;-) (oh, I like competition). -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/ From bwarsaw@users.sourceforge.net Mon Mar 4 13:20:04 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Mon, 04 Mar 2002 05:20:04 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0279.txt,1.4,1.5 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv16151 Modified Files: pep-0279.txt Log Message: Latest update from Raymond D. Hettinger. Spell checking applied. Made code samples self-consistent, and also consistent with Python style guide w.r.t. spaces around function arguments. Index: pep-0279.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0279.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pep-0279.txt 7 Feb 2002 12:08:12 -0000 1.4 --- pep-0279.txt 4 Mar 2002 13:20:02 -0000 1.5 *************** *** 3,7 **** Version: $Revision$ Last-Modified: $Date$ ! Author: othello@javanet.com (Raymond D. Hettinger) Status: Draft Type: Standards Track --- 3,7 ---- Version: $Revision$ Last-Modified: $Date$ ! Author: python@rcn.com (Raymond D. Hettinger) Status: Draft Type: Standards Track *************** *** 14,19 **** This PEP introduces four orthogonal (not mutually exclusive) ideas ! for enhancing the generators as introduced in Python version 2.2 ! [1]. The goal is to increase the convenience, utility, and power of generators. --- 14,19 ---- This PEP introduces four orthogonal (not mutually exclusive) ideas ! for enhancing the generators introduced in Python version 2.2 [1]. ! The goal is to increase the convenience, utility, and power of generators. *************** *** 33,37 **** establishing a common iterable interface for mappings, sequences, and file objects. In the case of mappings and file objects, lazy ! evaluation was made available. The next steps in the evolution of generators are: --- 33,37 ---- establishing a common iterable interface for mappings, sequences, and file objects. In the case of mappings and file objects, lazy ! evaluation became the norm. The next steps in the evolution of generators are: *************** *** 53,57 **** 4. Add a generator method to enable exceptions to be passed to a generator. Currently, there is no clean method for triggering ! exceptions from outside the generator. All of the suggestions are designed to take advantage of the --- 53,58 ---- 4. Add a generator method to enable exceptions to be passed to a generator. Currently, there is no clean method for triggering ! exceptions from outside the generator. Also, generator exception ! passing helps mitigate the try/finally prohibition for generators. All of the suggestions are designed to take advantage of the *************** *** 61,73 **** generators become final and are not imported from __future__. ! SourceForge contains a working, pure Python simulation of every ! feature proposed in this PEP [8]. SourceForge also has a separate ! file with a simulation test suite and working source code for the ! examples listed used in this PEP [9]. Specification for new built-ins: ! def xfilter( pred, gen ): ''' xfilter(...) --- 62,83 ---- generators become final and are not imported from __future__. ! ! ! Reference Implementation ! ! There is not currently a CPython implementation; however, a simulation ! module written in pure Python is available on SourceForge [8]. The ! simulation covers every feature proposed in this PEP and is meant ! to allow direct experimentation with the proposals. ! ! There is also a module [9] with working source code for all of the ! examples used in this PEP. It serves as a test suite for the simulator ! and it documents how each of the new features works in practice. ! Specification for new built-ins: ! def xfilter(pred, gen): ''' xfilter(...) *************** *** 87,91 **** yield i ! def xmap( fun, *collections ): ''' xmap(...) --- 97,101 ---- yield i ! def xmap(fun, *collections): ### Code from Python Cookbook [6] ''' xmap(...) *************** *** 97,109 **** corresponding item of each collection, substituting None for missing values when not all collections have the same length. ! If the function is None, return a list of the items of the ! collection (or a list of tuples if more than one collection). ''' gens = map(iter, collections) values_left = [1] def values(): ! # Emulate map behaviour, i.e. shorter ! # sequences are padded with None when ! # they run out of values. values_left[0] = 0 for i in range(len(gens)): --- 107,118 ---- corresponding item of each collection, substituting None for missing values when not all collections have the same length. ! If the function is None, return an iterator of the items of the ! collection (or an iterator of tuples if more than one collection). ''' gens = map(iter, collections) values_left = [1] def values(): ! # Emulate map behavior by padding sequences with None ! # when they run out of values. values_left[0] = 0 for i in range(len(gens)): *************** *** 124,128 **** yield fun(*args) ! def xzip( *collections ): ### Code from Python Cookbook [6] ''' xzip(...) --- 133,137 ---- yield fun(*args) ! def xzip(*collections): ''' xzip(...) *************** *** 136,142 **** gens = map(iter, collections) while 1: ! yield tuple( [g.next() for g in gens] ) ! def indexed( collection, cnt=0, limit=None ): 'Generates an indexed series: (0,seqn[0]), (1,seqn[1]) ...' gen = iter(collection) --- 145,151 ---- gens = map(iter, collections) while 1: ! yield tuple([g.next() for g in gens]) ! def indexed(collection, cnt=0, limit=None): 'Generates an indexed series: (0,seqn[0]), (1,seqn[1]) ...' gen = iter(collection) *************** *** 145,148 **** --- 154,158 ---- cnt += 1 + Note A: PEP 212 Loop Counter Iteration [2] discussed several proposals for achieving indexing. Some of the proposals only work *************** *** 150,161 **** xrange, sequence, or iterable object. Also, those proposals were presented and evaluated in the world prior to Python 2.2 which did ! not include generators. - Note B: An alternate, simplified definition of indexed was proposed: ! def indexed( collection, cnt=0, limit=sys.maxint ): ! 'Generates an indexed series: (0,seqn[0]), (1,seqn[1]) ...' ! return xzip( xrange(cnt,limit), collection ) Specification for Generator Comprehensions: --- 160,199 ---- xrange, sequence, or iterable object. Also, those proposals were presented and evaluated in the world prior to Python 2.2 which did ! not include generators. As a result, the generator-less version in ! PEP 212 had the disadvantage of consuming memory with a giant list ! of tuples. The generator version presented here is fast and light, ! works with all iterables, and allows users to abandon the sequence ! in mid-stream. ! Note B: An alternate, simplified definition of indexed is: + def indexed(collection, cnt=0, limit=sys.maxint): + 'Generates an indexed series: (0,seqn[0]), (1,seqn[1]) ...' + return xzip( xrange(cnt,limit), collection ) + + + Note C: As it stands, the Python code for xmap is slow. The actual + implementation of the functions should be written in C for speed. + The pure Python code listed above is meant only to specify how the + functions would behave, in particular that they should as closely as + possible emulate their non-lazy counterparts. + + + Note D: Almost all of the PEP reviewers welcomed these functions but were + divided as to whether they should be built-ins or in a separate module. + The main argument for a separate module was to slow the rate of language + inflation. The main argument for built-ins was that these functions are + destined to be part of a core programming style, applicable to any object + with an iterable interface. Just as zip() solves the problem of looping + over multiple sequences, the indexed() function solves the loop counter + problem. Likewise, the x-functions solve the problem of applying + functional constructs without forcing the evaluation of an entire sequence. + + If only one built-in were allowed, then indexed() is the most important + general purpose tool, solving the broadest class of problems while + improving program brevity, clarity and reliability. + + Specification for Generator Comprehensions: *************** *** 165,179 **** g = [yield (len(line),line) for line in file if len(line)>5] This would be implemented as if it had been written: ! class __Temp: ! def __iter__(self): ! for line in file: ! if len(line) > 5: ! yield (len(line), line) ! g = __Temp() ! Note A: There is some debate about whether the enclosing brackets should be part of the syntax for generator comprehensions. On the plus side, it neatly parallels list comprehensions and would be --- 203,218 ---- g = [yield (len(line),line) for line in file if len(line)>5] + print g.next() This would be implemented as if it had been written: ! def __temp(self): ! for line in file: ! if len(line) > 5: ! yield (len(line), line) ! g = __temp() ! print g.next() ! Note A: There is some discussion about whether the enclosing brackets should be part of the syntax for generator comprehensions. On the plus side, it neatly parallels list comprehensions and would be *************** *** 186,204 **** minus side, the brackets may falsely suggest that the whole expression returns a list. Most of the feedback received to date ! indicates that brackets do not make a false suggestion and are ! in fact helpful. ! ! Note B: An iterable instance is returned by the above code. The ! purpose is to allow the object to be re-started and looped-over ! multiple times. This accurately mimics the behavior of list ! comprehensions. As a result, the following code (provided by Oren ! Tirosh) works equally well with or without 'yield': ! ! letters = [yield chr(i) for i in xrange(ord('a'),ord('z')+1)] ! digits = [yield str(i) for i in xrange(10)] ! letdig = [yield l+d for l in letters for d in digits] ! Note C: List comprehensions expose their looping variable and ! leave the variable in the enclosing scope. The code, [str(i) for i in range(8)] leaves 'i' set to 7 in the scope where the comprehension appears. This behavior is by design and reflects an --- 225,232 ---- minus side, the brackets may falsely suggest that the whole expression returns a list. Most of the feedback received to date ! indicates that brackets are helpful and not misleading. ! Note B: List comprehensions expose their looping variable and ! leave that variable in the enclosing scope. The code, [str(i) for i in range(8)] leaves 'i' set to 7 in the scope where the comprehension appears. This behavior is by design and reflects an *************** *** 216,222 **** is not in a defined state on the line immediately following the list comprehension. It does not come into existence until ! iteration starts. Since several generators may be running at ! once, there are potentially multiple, unequal instances of 'i' at ! any one time. --- 244,249 ---- is not in a defined state on the line immediately following the list comprehension. It does not come into existence until ! iteration starts (possibly never). ! *************** *** 230,234 **** print x ! 2. Let the .next() method take a value to pass to generator as in: g = mygen() --- 257,261 ---- print x ! 2. Let the .next() method take a value to pass to the generator as in: g = mygen() *************** *** 237,245 **** g.next(2) # '2' is bound to 'x' in mygen(), then printed ! The control flow is unchanged by this proposal. The only change ! is that a value can be sent into the generator. By analogy, ! consider the quality improvement from GOSUB (which had no argument ! passing mechanism) to modern procedure calls (which can pass in ! arguments and return values). Most of the underlying machinery is already in place, only the --- 264,272 ---- g.next(2) # '2' is bound to 'x' in mygen(), then printed ! The control flow of 'yield' and 'next' is unchanged by this proposal. ! The only change is that a value can be sent into the generator. ! By analogy, consider the quality improvement from GOSUB (which had ! no argument passing mechanism) to modern procedure calls (which can ! pass in arguments and return values). Most of the underlying machinery is already in place, only the *************** *** 264,273 **** threading module with its attendant mutexes, semaphores, and data queues. A class-based approach competes well when there are no ! complex execution states or variable states. When the complexity ! increases, generators with parameter passing are much simpler because they automatically save state (unlike classes which must ! explicitly save the variable and execution state in instance ! variables). Example of a Complex Consumer --- 291,302 ---- threading module with its attendant mutexes, semaphores, and data queues. A class-based approach competes well when there are no ! complex execution states or variable states. However, when the ! complexity increases, generators with parameter passing are much simpler because they automatically save state (unlike classes which must ! explicitly save the variable and execution state in instance variables). + Note A: This proposal changes 'yield' from a statement to an + expression with binding and precedence similar to lambda. + Example of a Complex Consumer *************** *** 285,289 **** cum = [] if appendOrOverwrite == 'w+': ! cum.extend( packages[packagename] ) try: while 1: --- 314,318 ---- cum = [] if appendOrOverwrite == 'w+': ! cum.extend(packages[packagename]) try: while 1: *************** *** 292,300 **** except FlushStream: packages[packagename] = cum ostream = filelike('mydest','w') # Analogous to file.open(name,flag) ostream.next() # Advance to the first yield ostream.next(firstdat) # Analogous to file.write(dat) ostream.next(seconddat) ! ostream.throw( FlushStream ) # This feature proposed below --- 321,330 ---- except FlushStream: packages[packagename] = cum + ostream = filelike('mydest','w') # Analogous to file.open(name,flag) ostream.next() # Advance to the first yield ostream.next(firstdat) # Analogous to file.write(dat) ostream.next(seconddat) ! ostream.throw(FlushStream) # This feature proposed below *************** *** 302,309 **** Loop over the picture files in a directory, shrink them ! one-at-a-time to thumbnail size using PIL [7], and send them to a lazy consumer. That consumer is responsible for creating a large ! blank image, accepting thumbnails one-at-a-time and placing them ! in a 5x3 grid format onto the blank image. Whenever the grid is full, it writes-out the large image as an index print. A FlushStream exception indicates that no more thumbnails are --- 332,339 ---- Loop over the picture files in a directory, shrink them ! one at a time to thumbnail size using PIL [7], and send them to a lazy consumer. That consumer is responsible for creating a large ! blank image, accepting thumbnails one at a time and placing them ! in a 5 by 3 grid format onto the blank image. Whenever the grid is full, it writes-out the large image as an index print. A FlushStream exception indicates that no more thumbnails are *************** *** 312,327 **** ! Example of a Producer and Consumer Used Together in a Pipelike Fashion ! 'Analogy to: source | upper | sink' sink = sinkgen() sink.next() for word in source(): ! sink.next( word.upper() ) Specification for Generator Exception Passing: ! Add a .throw(exception) method to the resulting generator as in: def mygen(): --- 342,358 ---- ! Example of a Producer and Consumer Used Together in a Pipe-like Fashion ! 'Analogy to Linux style pipes: source | upper | sink' sink = sinkgen() sink.next() for word in source(): ! sink.next(word.upper()) ! Specification for Generator Exception Passing: ! Add a .throw(exception) method to the generator interface: def mygen(): *************** *** 337,346 **** g.throw(FlushStream) ! There is no existing work around for triggering an exception inside a generator. This is a true deficiency. It is the only ! case in Python where active code cannot be excepted to or through. Even if the .next(arg) proposal is not adopted, we should add the .throw() method. Note A: The name of the throw method was selected for several reasons. Raise is a keyword and so cannot be used as a method --- 368,383 ---- g.throw(FlushStream) ! There is no existing work-around for triggering an exception inside a generator. This is a true deficiency. It is the only ! case in Python where active code cannot be excepted to or through. Even if the .next(arg) proposal is not adopted, we should add the .throw() method. + Generator exception passing also helps address an intrinsic limitation + on generators, the prohibition against their using try/finally to + trigger clean-up code [1]. Without .throw(), the current work-around + forces the resolution or clean-up code to be moved outside the generator. + + Note A: The name of the throw method was selected for several reasons. Raise is a keyword and so cannot be used as a method *************** *** 351,360 **** already associated with exceptions in other languages. ! Note B: The throw syntax should exactly match raise's syntax including: ! raise string g.throw(string) ! raise string, data g.throw(string,data) ! raise class, instance g.throw(class,instance) ! raise instance g.throw(instance) ! raise g.throw() --- 388,461 ---- already associated with exceptions in other languages. ! Alternative method names were considered: resolve(), signal(), ! genraise(), raiseinto(), and flush(). None of these seem to fit ! as well as throw(). ! ! ! Note B: The throw syntax should exactly match raise's syntax: ! ! throw([expression, [expression, [expression]]]) ! ! Accordingly, it should be implemented to handle all of the following: ! ! raise string g.throw(string) ! raise string, data g.throw(string,data) ! raise class, instance g.throw(class,instance) ! raise instance g.throw(instance) ! raise g.throw() ! ! ! Discussion of Restartability: ! ! Inside for-loops, generators are not substitutable for lists unless they ! are accessed only once. A second access only works for restartable ! objects like lists, dicts, objects defined with __getitem__, and ! xrange objects. Generators are not the only objects which are not ! restartable. Other examples of non-restartable sequences include file ! objects, xreadlines objects, and the result of iter(callable,sentinel). ! ! Since the proposed built-in functions return generators, they are also ! non-restartable. As a result, 'xmap' is not substitutable for 'map' in ! the following example: ! ! alphabet = map(chr, xrange(ord('a'), ord('z')+1)) ! twoletterwords = [a+b for a in alphabet for b in alphabet] ! ! Since generator comprehensions also return generators, they are not ! restartable. Consequently, they are not substitutable for list ! comprehensions in the following example: ! ! digits = [str(i) for i in xrange(10)] ! alphadig = [a+d for a in 'abcdefg' for d in digits] ! ! To achieve substitutabity, generator comprehensions and x-functions ! can be implemented in a way that supports restarts. PEP 234 [4] ! explicitly states that restarts are to be supported through repeated ! calls to iter(). With that guidance, it is easy to add restartability ! to generator comprehensions using a simple wrapper class around the ! generator function and modifying the implementation above to return: ! ! g = Restartable(__temp) # instead of g = __temp() ! ! Restartable is a simple (12 line) class which calls the generator function ! to create a new, re-wound generator whenever iter() requests a restart. ! Calls to .next() are simply forwarded to the generator. The Python source ! code for the Restartable class can found in the PEP 279 simulator [8]. ! An actual implementation in C can achieve re-startability directly and ! would not need the slow class wrapper used in the pure Python simulation. ! ! The XLazy library [10] shows how restarts can be implemented for xmap, ! xfilter, and xzip. ! ! The upside of adding restart capability is that more list comprehensions ! can be made lazy and save memory by adding 'yield'. Likewise, ! more expressions that use map, filter, and zip can be made lazy just by ! adding 'x'. ! ! A possible downside is that x-functions have no control over whether their ! inputs are themselves restartable. With non-restartable inputs like ! generators or files, an x-function restart will not produce a meaningful ! result. ! *************** *** 370,390 **** http://python.sourceforge.net/peps/pep-0202.html ! [4] There have been several discussion on comp.lang.python which helped ! tease out these proposals: ! ! Indexed Function ! http://groups.google.com/groups?hl=en&th=33f778d92dd5720a ! ! Xmap, Xfilter, Xzip and Two-way Generator Communication ! http://groups.google.com/groups?hl=en&th=b5e576b02894bb04&rnum=1 ! ! Two-way Generator Communication -- Revised Version ! http://groups.google.com/groups?hl=en&th=cb1d86e68850c592&rnum=1 ! ! Generator Comprehensions ! http://groups.google.com/groups?hl=en&th=215e6e5a7bfd526&rnum=2 ! ! Discussion Draft of this PEP ! http://groups.google.com/groups?hl=en&th=df8b5e7709957eb7 [5] Dr. David Mertz's draft column for Charming Python. --- 471,476 ---- http://python.sourceforge.net/peps/pep-0202.html ! [4] PEP 234 Iterators ! http://python.sourceforge.net/peps/pep-0234.html [5] Dr. David Mertz's draft column for Charming Python. *************** *** 404,407 **** --- 490,496 ---- http://sourceforge.net/tracker/download.php?group_id=5470&atid=305470&file_id=17412&aid=513756 + [10] Oren Tirosh's XLazy library with re-startable x-functions is at: + http://www.tothink.com/python/dataflow/ + Copyright From fdrake@users.sourceforge.net Mon Mar 4 14:36:18 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 04 Mar 2002 06:36:18 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime .cvsignore,NONE,1.1 Makefile,NONE,1.1 datetime.c,NONE,1.1 setup.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv7708 Added Files: .cvsignore Makefile datetime.c setup.py Log Message: Tell CVS to ignore the build/ directory created by distutils. --- NEW FILE: .cvsignore --- build --- NEW FILE: Makefile --- PYTHON=python2.2 default: check all: _datetime.so _datetime.so: datetime.c $(PYTHON) setup.py build_ext -i check: _datetime.so $(PYTHON) test_datetime.py test: check --- NEW FILE: datetime.c --- /* C implementation for the date/time type documented at * */ #include "Python.h" #include "modsupport.h" static PyMethodDef functions[] = { {NULL, NULL, 0, NULL} }; void init_datetime(void) { PyObject *m = Py_InitModule3("_datetime", functions, "Fast implementation of the datetime type."); PyModule_AddIntConstant(m, "MINYEAR", 1); PyModule_AddIntConstant(m, "MAXYEAR", 9999); } --- NEW FILE: setup.py --- from distutils.core import setup, Extension setup(name="datetime", version = "0.1", ext_modules=[Extension("_datetime", ["datetime.c"])]) From gvanrossum@users.sourceforge.net Mon Mar 4 15:34:31 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Mon, 04 Mar 2002 07:34:31 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.39,1.40 test_datetime.py,1.24,1.25 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv32033 Modified Files: datetime.py test_datetime.py Log Message: Disallow adding or sutracting plain numbers; there's no agreement whether the number should be interpreted as days or seconds. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** datetime.py 4 Mar 2002 10:17:41 -0000 1.39 --- datetime.py 4 Mar 2002 15:34:29 -0000 1.40 *************** *** 352,381 **** self.__seconds + other.__seconds, self.__microseconds + other.__microseconds) ! if isinstance(other, (int, long)): ! return timedelta(self.__days, ! self.__seconds + other, ! self.__microseconds) ! if isinstance(other, float): ! sign = 1 ! if other < 0: ! sign, other = -1, -other ! frac, whole = _math.modf(other) ! us = int(frac * 1e6 + 0.5) ! assert 0 <= us <= 1000000 # if 1e6, constructor will normalize ! days, seconds = divmod(whole, 24*3600) ! return timedelta(self.__days + sign * int(days), ! self.__seconds + sign * int(seconds), ! self.__microseconds + sign * us) ! return NotImplemented __radd__ = __add__ def __sub__(self, other): ! if isinstance(other, (timedelta, int, long, float)): return self + -other return NotImplemented def __rsub__(self, other): ! if isinstance(other, (timedelta, int, long, float)): return -self + other return NotImplemented --- 352,367 ---- self.__seconds + other.__seconds, self.__microseconds + other.__microseconds) ! raise TypeError ! # XXX Should be 'return NotImplemented', but there's a bug in 2.2... __radd__ = __add__ def __sub__(self, other): ! if isinstance(other, timedelta): return self + -other return NotImplemented def __rsub__(self, other): ! if isinstance(other, timedelta): return -self + other return NotImplemented *************** *** 437,441 **** __repr__, __str__ __cmp__, __hash__ ! __add__, __radd__, __sub__ (add/radd only with timedelta or numeric arg) Methods: --- 423,427 ---- __repr__, __str__ __cmp__, __hash__ ! __add__, __radd__, __sub__ (add/radd only with timedelta arg) Methods: *************** *** 670,677 **** def __add__(self, other): ! """Add a datetime to a timedelta. ! ! An int/long/float argument is also allowed, interpreted as seconds. ! """ if isinstance(other, timedelta): t = tmxxx(self.__year, --- 656,660 ---- def __add__(self, other): ! "Add a datetime to a timedelta." if isinstance(other, timedelta): t = tmxxx(self.__year, *************** *** 686,694 **** t.microsecond, self.__tzoffset) return result ! elif isinstance(other, (int, long)): ! return self + timedelta(0, other) ! elif isinstance(other, float): ! return self + (timedelta(0) + other) ! return NotImplemented __radd__ = __add__ --- 669,674 ---- t.microsecond, self.__tzoffset) return result ! raise TypeError ! # XXX Should be 'return NotImplemented', but there's a bug in 2.2... __radd__ = __add__ *************** *** 699,703 **** An int/long/float argument is also allowed, interpreted as seconds. """ ! if isinstance(other, (timedelta, int, long, float)): return self + -other if isinstance(other, datetime): --- 679,683 ---- An int/long/float argument is also allowed, interpreted as seconds. """ ! if isinstance(other, timedelta): return self + -other if isinstance(other, datetime): Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** test_datetime.py 4 Mar 2002 06:10:15 -0000 1.24 --- test_datetime.py 4 Mar 2002 15:34:29 -0000 1.25 *************** *** 192,216 **** self.assertEqual(a//10, timedelta(0, 7*24*360)) self.assertEqual(a//3600000, timedelta(0, 0, 7*24*1000)) ! # Add/sub ints, longs, floats ! self.assertEqual(a + 7*24*3600, timedelta(14)) ! self.assertEqual(a - 24*3600, timedelta(6)) ! self.assertEqual(a + 100, timedelta(7, 100)) ! self.assertEqual(a - 100, timedelta(6, 24*3600-100)) ! self.assertEqual(100 + a, a + 100) ! self.assertEqual(100 - a, 100 + -a) ! self.assertEqual(a + 7*24*3600L, timedelta(14)) ! self.assertEqual(a - 24*3600L, timedelta(6)) ! self.assertEqual(a + 100L, timedelta(7, 100)) ! self.assertEqual(a - 100L, timedelta(6, 24*3600-100)) ! self.assertEqual(100L + a, a + 100L) ! self.assertEqual(100L - a, 100L + -a) ! self.assertEqual(c + 0.001, timedelta(0, 0, 2000)) ! self.assertEqual(c - 0.0001, timedelta(0, 0, 900)) ! self.assertEqual(b + 1.1, timedelta(0, 61, 100000)) ! self.assertEqual(b - 1.1, timedelta(0, 58, 900000)) ! self.assertEqual(a + (1e6 + 1e-6), timedelta(7, 1000000, 1)) ! self.assertEqual(a - (1e6 + 1e-6), timedelta(7, -1000000, -1)) ! self.assertEqual(1.1 + a, a + 1.1) ! self.assertEqual(1.1 - a, 1.1 + -a) def test_computations(self): --- 192,201 ---- self.assertEqual(a//10, timedelta(0, 7*24*360)) self.assertEqual(a//3600000, timedelta(0, 0, 7*24*1000)) ! # Add/sub ints, longs, floats should be illegal ! for i in 1, 1L, 1.0: ! self.assertRaises(TypeError, lambda: a+i) ! self.assertRaises(TypeError, lambda: a-i) ! self.assertRaises(TypeError, lambda: i+a) ! self.assertRaises(TypeError, lambda: i-a) def test_computations(self): *************** *** 261,274 **** self.assertEqual(a - (week + day + hour + millisec), (((a - week) - day) - hour) - millisec) ! # Add/sub ints, longs, floats ! self.assertEqual(a + 12, a + timedelta(0, 12)) ! self.assertEqual(a - 12, a - timedelta(0, 12)) ! self.assertEqual(100 + a, a + 100) ! self.assertEqual(a + 12L, a + timedelta(0, 12)) ! self.assertEqual(a - 12L, a - timedelta(0, 12)) ! self.assertEqual(100L + a, a + 100L) ! self.assertEqual(a + 0.001, a + timedelta(0, 0, 1000)) ! self.assertEqual(a - 0.001, a - timedelta(0, 0, 1000)) ! self.assertEqual(0.1 + a, a + 0.1) def test_weekday(self): --- 246,255 ---- self.assertEqual(a - (week + day + hour + millisec), (((a - week) - day) - hour) - millisec) ! # Add/sub ints, longs, floats should be illegal ! for i in 1, 1L, 1.0: ! self.assertRaises(TypeError, lambda: a+i) ! self.assertRaises(TypeError, lambda: a-i) ! self.assertRaises(TypeError, lambda: i+a) ! self.assertRaises(TypeError, lambda: i-a) def test_weekday(self): From tim_one@users.sourceforge.net Mon Mar 4 18:32:10 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 04 Mar 2002 10:32:10 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.25,1.26 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv25314 Modified Files: test_datetime.py Log Message: test_tz_independent_comparing(): Change assert_(x==y) to assertEqual(). Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** test_datetime.py 4 Mar 2002 15:34:29 -0000 1.25 --- test_datetime.py 4 Mar 2002 18:32:07 -0000 1.26 *************** *** 56,60 **** dt1 = datetime.new(MAXYEAR, 12, 31, 22, 59, 59, 999998, -60) dt2 = datetime.new(MAXYEAR, 12, 31, 23, 59, 59, 999998, 0) ! self.assert_(dt1 == dt2) dt2 += us self.assertEqual(dt2 - dt1, us) --- 56,60 ---- dt1 = datetime.new(MAXYEAR, 12, 31, 22, 59, 59, 999998, -60) dt2 = datetime.new(MAXYEAR, 12, 31, 23, 59, 59, 999998, 0) ! self.assertEqual(dt1, dt2) dt2 += us self.assertEqual(dt2 - dt1, us) From tim_one@users.sourceforge.net Mon Mar 4 18:49:10 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 04 Mar 2002 10:49:10 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.40,1.41 test_datetime.py,1.26,1.27 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv29066 Modified Files: datetime.py test_datetime.py Log Message: datetime.__add__: raise OverflowError if result out of range, meaning specifcally that the result year is out of range. New test test_overflow. Note: tmxxx intentionally ignores year out of range, and should ignore it. Else, e.g., timezone adjustments done for internal datetime purposes of hashing or comparing could raise bogus OverflowErrors at the boundaries: some legit datetime objects can't be converted to legit UTC datetimes. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** datetime.py 4 Mar 2002 15:34:29 -0000 1.40 --- datetime.py 4 Mar 2002 18:49:07 -0000 1.41 *************** *** 655,658 **** --- 655,663 ---- # Computations + def _checkOverflow(self, year): + if not MINYEAR <= year <= MAXYEAR: + raise OverflowError("datetime +/-: result year %d not in %d..%d" % + (year, MINYEAR, MAXYEAR)) + def __add__(self, other): "Add a datetime to a timedelta." *************** *** 665,668 **** --- 670,674 ---- self.__second + other.seconds, self.__microsecond + other.microseconds) + self._checkOverflow(t.year) result = datetime.new(t.year, t.month, t.day, t.hour, t.minute, t.second, Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** test_datetime.py 4 Mar 2002 18:32:07 -0000 1.26 --- test_datetime.py 4 Mar 2002 18:49:07 -0000 1.27 *************** *** 253,256 **** --- 253,271 ---- self.assertRaises(TypeError, lambda: i-a) + def test_overflow(self): + us = timedelta(microseconds=1) + mus = - us + + dt = datetime.new(MINYEAR, 1, 1, microsecond=1) + dt -= us # no problem + self.assertRaises(OverflowError, dt.__sub__, us) + self.assertRaises(OverflowError, dt.__add__, mus) + + dt = datetime.new(MAXYEAR, 12, 31, 23, 59, 59, 999998) + dt += us # no problem + self.assertRaises(OverflowError, dt.__add__, us) + self.assertRaises(OverflowError, dt.__sub__, mus) + + def test_weekday(self): for i in range(7): From tim_one@users.sourceforge.net Mon Mar 4 18:52:59 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 04 Mar 2002 10:52:59 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.27,1.28 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv32541 Modified Files: test_datetime.py Log Message: I don't believe it: I checked in a file with trailing whitespace . Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** test_datetime.py 4 Mar 2002 18:49:07 -0000 1.27 --- test_datetime.py 4 Mar 2002 18:52:57 -0000 1.28 *************** *** 267,271 **** self.assertRaises(OverflowError, dt.__sub__, mus) - def test_weekday(self): for i in range(7): --- 267,270 ---- From gvanrossum@users.sourceforge.net Mon Mar 4 18:56:12 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Mon, 04 Mar 2002 10:56:12 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.41,1.42 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv1528 Modified Files: datetime.py Log Message: Changes to timedelta() constructor: - allow floats - add keyword arguments milliseconds, minutes, hours, and weeks Also remove an outdated item from a comment Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** datetime.py 4 Mar 2002 18:49:07 -0000 1.41 --- datetime.py 4 Mar 2002 18:56:10 -0000 1.42 *************** *** 290,297 **** - add, subtract timedelta - - add, subtract int/long/float seconds - unary plus, minus, abs - compare to timedelta ! - multiply, divide by int/long In addition, datetime supports subtraction of two datetime objects --- 290,296 ---- - add, subtract timedelta - unary plus, minus, abs - compare to timedelta ! - multiply, divide by int/long/float In addition, datetime supports subtraction of two datetime objects *************** *** 303,307 **** """ ! def __init__(self, days=0, seconds=0, microseconds=0): s, us = divmod(microseconds, 1000000) assert us >= 0 --- 302,323 ---- """ ! def __init__(self, days=0, seconds=0, microseconds=0, ! # XXX The following should only be used as keyword args: ! milliseconds=0, minutes=0, hours=0, weeks=0): ! # Normalize everything to days, seconds, microseconds ! days += weeks*7 ! seconds += minutes*60 + hours*3600 ! microseconds += milliseconds*1000 ! # Deal with floats ! # XXX Tim may rewrite this for accuracy :-) ! if isinstance(days, float): ! days, fraction = divmod(days, 1.0) ! if fraction: ! seconds += fraction*(24*3600) ! if isinstance(seconds, float): ! seconds, fraction = divmod(seconds, 1.0) ! if fraction: ! microseconds += fraction*1e6 ! # Propagate carry from us to s, from s to d s, us = divmod(microseconds, 1000000) assert us >= 0 *************** *** 310,320 **** d += days # d may be < 0 ! self.__days = d ! self.__seconds = s ! self.__microseconds = us def __repr__(self): if self.__microseconds: ! return "timedelta(%d, %d, %d)" % (self.__days, self.__seconds, self.__microseconds) --- 326,336 ---- d += days # d may be < 0 ! self.__days = int(d) ! self.__seconds = int(s) ! self.__microseconds = int(round(us)) def __repr__(self): if self.__microseconds: ! return "timedelta(days=%d, %d, %d)" % (self.__days, self.__seconds, self.__microseconds) From gvanrossum@users.sourceforge.net Mon Mar 4 19:09:15 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Mon, 04 Mar 2002 11:09:15 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv5667 Modified Files: test_datetime.py Log Message: Add tests for: - keyword args to timedelta constructor - float args to timedelta constructor Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** test_datetime.py 4 Mar 2002 18:52:57 -0000 1.28 --- test_datetime.py 4 Mar 2002 19:09:12 -0000 1.29 *************** *** 198,201 **** --- 198,220 ---- self.assertRaises(TypeError, lambda: i+a) self.assertRaises(TypeError, lambda: i-a) + # Check keyword args to constructor + eq = self.assertEqual + td = timedelta + eq(td(1), td(days=1)) + eq(td(0, 1), td(seconds=1)) + eq(td(0, 0, 1), td(microseconds=1)) + eq(td(weeks=1), td(days=7)) + eq(td(days=1), td(hours=24)) + eq(td(hours=1), td(minutes=60)) + eq(td(minutes=1), td(seconds=60)) + eq(td(seconds=1), td(milliseconds=1000)) + eq(td(milliseconds=1), td(microseconds=1000)) + # Check float args to constructor + eq(td(weeks=1.0/7), td(days=1)) + eq(td(days=1.0/24), td(hours=1)) + eq(td(hours=1.0/60), td(minutes=1)) + eq(td(minutes=1.0/60), td(seconds=1)) + eq(td(seconds=0.001), td(milliseconds=1)) + eq(td(milliseconds=0.001), td(microseconds=1)) def test_computations(self): From gvanrossum@users.sourceforge.net Mon Mar 4 19:39:40 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Mon, 04 Mar 2002 11:39:40 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.42,1.43 test_datetime.py,1.29,1.30 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv16311 Modified Files: datetime.py test_datetime.py Log Message: Add min, max and resolution to datetime class. This was proposed by s.keim in the Wiki. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** datetime.py 4 Mar 2002 18:56:10 -0000 1.42 --- datetime.py 4 Mar 2002 19:39:38 -0000 1.43 *************** *** 790,793 **** --- 790,798 ---- + datetime.min = datetime(1, 1, 1, tzoffset=0) + datetime.max = datetime(9999, 12, 31, 23, 59, 59, 999999, tzoffset=0) + datetime.resolution = timedelta(microseconds=1) + + def _isoweek1monday(year): # Helper to calculate the day number of the Monday starting week 1 Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** test_datetime.py 4 Mar 2002 19:09:12 -0000 1.29 --- test_datetime.py 4 Mar 2002 19:39:38 -0000 1.30 *************** *** 387,390 **** --- 387,396 ---- self.fail("Can't test utcctime()") + def test_resolution_info(self): + self.assert_(isinstance(datetime.min, datetime)) + self.assert_(isinstance(datetime.max, datetime)) + self.assert_(isinstance(datetime.resolution, timedelta)) + self.assert_(datetime.max > datetime.min) + def test_suite(): s1 = unittest.makeSuite(TestDateTime, 'test') From tim_one@users.sourceforge.net Mon Mar 4 19:51:35 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 04 Mar 2002 11:51:35 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.43,1.44 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv19454 Modified Files: datetime.py Log Message: timedelta.__init__(): Extensive rework for fp accuracy, and to ease the overflow-checking burdens when recoded in C. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** datetime.py 4 Mar 2002 19:39:38 -0000 1.43 --- datetime.py 4 Mar 2002 19:51:32 -0000 1.44 *************** *** 305,332 **** # XXX The following should only be used as keyword args: milliseconds=0, minutes=0, hours=0, weeks=0): ! # Normalize everything to days, seconds, microseconds ! days += weeks*7 ! seconds += minutes*60 + hours*3600 ! microseconds += milliseconds*1000 ! # Deal with floats ! # XXX Tim may rewrite this for accuracy :-) ! if isinstance(days, float): ! days, fraction = divmod(days, 1.0) ! if fraction: ! seconds += fraction*(24*3600) ! if isinstance(seconds, float): ! seconds, fraction = divmod(seconds, 1.0) ! if fraction: ! microseconds += fraction*1e6 # Propagate carry from us to s, from s to d s, us = divmod(microseconds, 1000000) ! assert us >= 0 d, s = divmod(s + seconds, 24*3600) ! assert s >= 0 d += days # d may be < 0 self.__days = int(d) self.__seconds = int(s) ! self.__microseconds = int(round(us)) def __repr__(self): --- 305,336 ---- # XXX The following should only be used as keyword args: milliseconds=0, minutes=0, hours=0, weeks=0): ! # Normalize everything to days, seconds, microseconds. ! # Convert everything to float first, else overflow-checking in C ! # is going to be a nightmare. ! days += weeks*7. ! seconds += minutes*60. + hours*3600. ! microseconds += milliseconds*1000. ! # Get rid of all fractions. ! dayfrac, days = _math.modf(days) ! daysecondsfrac, daysecondswhole = _math.modf(dayfrac * (24.*3600.)) ! secondsfrac, seconds = _math.modf(seconds) ! seconds += daysecondswhole ! secondsfrac += daysecondsfrac ! microseconds += secondsfrac*1e6 ! microseconds = round(microseconds) ! assert _math.modf(days)[0] == 0.0 ! assert _math.modf(seconds)[0] == 0.0 ! assert _math.modf(microseconds)[0] == 0.0 # Propagate carry from us to s, from s to d s, us = divmod(microseconds, 1000000) ! assert us == int(us) and 0 <= us < 1000000 d, s = divmod(s + seconds, 24*3600) ! assert s == int(s) and 0 <= s < 24*3600 d += days + assert d == long(d) # d may be < 0 self.__days = int(d) self.__seconds = int(s) ! self.__microseconds = int(us) def __repr__(self): From tim.one@comcast.net Mon Mar 4 20:09:00 2002 From: tim.one@comcast.net (Tim Peters) Date: Mon, 04 Mar 2002 15:09:00 -0500 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetimedatetime.py,1.28,1.29 In-Reply-To: <3C835582.23FE9B1A@lemburg.com> Message-ID: [MAL] > Oh, the mxDateTime algorithm is loop-free in a sense as well: > the correction does at most 3 iterations, the month finder > at most 12 iterations. "iterations" sounds like "loops" to me, and so do the "while() {}" blocks in the code . > I'll have a look at yours, though. Perhaps I can make the > algorithms a bit faster ;-) (oh, I like competition). Speed here is much more important for us, because we store dates in broken-down form -- we may need to do ordinal->date on every add and subtract. By the time this gets recoded in C, I expect most divmods() will get converted to floating-point multiplies by provably-good-enough reciprocal approximations. From gvanrossum@users.sourceforge.net Mon Mar 4 20:21:20 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Mon, 04 Mar 2002 12:21:20 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.30,1.31 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv30550 Modified Files: test_datetime.py Log Message: Changed all occurrences of datetime.new(args) to datetime(args). Why were we using datetime.new(args) to create instances? datetime(args) works just as well, and is more familiar -- after all, datetime (as imported here) is the class, not the module. Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** test_datetime.py 4 Mar 2002 19:39:38 -0000 1.30 --- test_datetime.py 4 Mar 2002 20:21:18 -0000 1.31 *************** *** 12,16 **** def test_basic_attributes(self): ! dt = datetime.new(2002, 3, 1, 12, 0, 0) self.assertEqual(dt.year, 2002) self.assertEqual(dt.month, 3) --- 12,16 ---- def test_basic_attributes(self): ! dt = datetime(2002, 3, 1, 12, 0, 0) self.assertEqual(dt.year, 2002) self.assertEqual(dt.month, 3) *************** *** 22,26 **** def test_roundtrip(self): ! for dt in (datetime.new(1, 2, 3, 4, 5, 6, 7, 8), datetime.now()): # Verify dt -> string -> datetime identity. --- 22,26 ---- def test_roundtrip(self): ! for dt in (datetime(1, 2, 3, 4, 5, 6, 7, 8), datetime.now()): # Verify dt -> string -> datetime identity. *************** *** 30,42 **** # Verify identity via reconstructing from pieces. ! dt2 = datetime.new(dt.year, dt.month, dt.day, ! dt.hour, dt.minute, dt.second, ! dt.microsecond, dt.tzoffset) self.assertEqual(dt, dt2) def test_tz_independent_comparing(self): ! dt1 = datetime.new(2002, 3, 1, 9, 0, 0, tzoffset=-60) ! dt2 = datetime.new(2002, 3, 1, 10, 0, 0, tzoffset=-60) ! dt3 = datetime.new(2002, 3, 1, 10, 0, 0, tzoffset=0) self.assertEqual(dt1, dt3) self.assert_(dt2 > dt3) --- 30,42 ---- # Verify identity via reconstructing from pieces. ! dt2 = datetime(dt.year, dt.month, dt.day, ! dt.hour, dt.minute, dt.second, ! dt.microsecond, dt.tzoffset) self.assertEqual(dt, dt2) def test_tz_independent_comparing(self): ! dt1 = datetime(2002, 3, 1, 9, 0, 0, tzoffset=-60) ! dt2 = datetime(2002, 3, 1, 10, 0, 0, tzoffset=-60) ! dt3 = datetime(2002, 3, 1, 10, 0, 0, tzoffset=0) self.assertEqual(dt1, dt3) self.assert_(dt2 > dt3) *************** *** 47,51 **** # so comparing via timestamp necessarily calls some distinct values # equal). ! dt1 = datetime.new(MAXYEAR, 12, 31, 23, 59, 59, 999998, 0) us = timedelta(microseconds=1) dt2 = dt1 + us --- 47,51 ---- # so comparing via timestamp necessarily calls some distinct values # equal). ! dt1 = datetime(MAXYEAR, 12, 31, 23, 59, 59, 999998, 0) us = timedelta(microseconds=1) dt2 = dt1 + us *************** *** 54,59 **** # Again, but mix timezones. ! dt1 = datetime.new(MAXYEAR, 12, 31, 22, 59, 59, 999998, -60) ! dt2 = datetime.new(MAXYEAR, 12, 31, 23, 59, 59, 999998, 0) self.assertEqual(dt1, dt2) dt2 += us --- 54,59 ---- # Again, but mix timezones. ! dt1 = datetime(MAXYEAR, 12, 31, 22, 59, 59, 999998, -60) ! dt2 = datetime(MAXYEAR, 12, 31, 23, 59, 59, 999998, 0) self.assertEqual(dt1, dt2) dt2 += us *************** *** 276,285 **** mus = - us ! dt = datetime.new(MINYEAR, 1, 1, microsecond=1) dt -= us # no problem self.assertRaises(OverflowError, dt.__sub__, us) self.assertRaises(OverflowError, dt.__add__, mus) ! dt = datetime.new(MAXYEAR, 12, 31, 23, 59, 59, 999998) dt += us # no problem self.assertRaises(OverflowError, dt.__add__, us) --- 276,285 ---- mus = - us ! dt = datetime(MINYEAR, 1, 1, microsecond=1) dt -= us # no problem self.assertRaises(OverflowError, dt.__sub__, us) self.assertRaises(OverflowError, dt.__add__, mus) ! dt = datetime(MAXYEAR, 12, 31, 23, 59, 59, 999998) dt += us # no problem self.assertRaises(OverflowError, dt.__add__, us) *************** *** 367,372 **** dt.hour - 24*100, dt.minute - 3, dt.second + 12, (3*60 - 12) * 1000000) ! dt2 = datetime.new(tm.year, tm.month, tm.day, tm.hour, tm.minute, ! tm.second, tm.microsecond, tzoffset=0) self.assertEqual(dt, dt2) self.assertEqual(timestamp, tm.time()) --- 367,372 ---- dt.hour - 24*100, dt.minute - 3, dt.second + 12, (3*60 - 12) * 1000000) ! dt2 = datetime(tm.year, tm.month, tm.day, tm.hour, tm.minute, ! tm.second, tm.microsecond, tzoffset=0) self.assertEqual(dt, dt2) self.assertEqual(timestamp, tm.time()) From gvanrossum@users.sourceforge.net Mon Mar 4 20:24:14 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Mon, 04 Mar 2002 12:24:14 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.44,1.45 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv31666 Modified Files: datetime.py Log Message: Get rid of datetime.new() as an alias for datetime(). YAGNI. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** datetime.py 4 Mar 2002 19:51:32 -0000 1.44 --- datetime.py 4 Mar 2002 20:24:12 -0000 1.45 *************** *** 434,438 **** Constructors: ! __init__() == new() now(), utcnow() fromtimestamp(), utcfromtimestamp() --- 434,438 ---- Constructors: ! __init__() now(), utcnow() fromtimestamp(), utcfromtimestamp() *************** *** 501,509 **** # Additional constructors - def new(cls, *args, **kwds): - "Constructor. Same arguments as __init__." - return cls(*args, **kwds) - new = classmethod(new) - def fromtimestamp(cls, t): "Construct a datetime from a POSIX timestamp (like time.time())." --- 501,504 ---- *************** *** 691,697 **** self.__microsecond + other.microseconds) self._checkOverflow(t.year) ! result = datetime.new(t.year, t.month, t.day, ! t.hour, t.minute, t.second, ! t.microsecond, self.__tzoffset) return result raise TypeError --- 686,692 ---- self.__microsecond + other.microseconds) self._checkOverflow(t.year) ! result = datetime(t.year, t.month, t.day, ! t.hour, t.minute, t.second, ! t.microsecond, self.__tzoffset) return result raise TypeError From gvanrossum@users.sourceforge.net Mon Mar 4 20:26:56 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Mon, 04 Mar 2002 12:26:56 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.31,1.32 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv32605 Modified Files: test_datetime.py Log Message: Add a test that fails for the current constructor of timedelta(), because a double doesn't have enough resolution (or is that precision) to express 10000 years in microseconds. Tim will fix it. Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** test_datetime.py 4 Mar 2002 20:21:18 -0000 1.31 --- test_datetime.py 4 Mar 2002 20:26:54 -0000 1.32 *************** *** 393,396 **** --- 393,402 ---- self.assert_(datetime.max > datetime.min) + def test_extreme_timedelta(self): + big = datetime.max - datetime.min + n = (big.days*24*3600 + big.seconds)*1000000 + big.microseconds + justasbig = timedelta(0, 0, n) + self.assertEqual(big, justasbig) + def test_suite(): s1 = unittest.makeSuite(TestDateTime, 'test') From tim.one@comcast.net Mon Mar 4 20:29:43 2002 From: tim.one@comcast.net (Tim Peters) Date: Mon, 04 Mar 2002 15:29:43 -0500 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.30,1.31 In-Reply-To: Message-ID: [Guido] > Why were we using datetime.new(args) to create instances? I have no idea: I did it because the rest of the test file did, and I confess I even went back and changed some of my plain "datetime(...)"s into "datetime.new(...)"s! I figure we figured this was really a Smalltalk class . From guido@python.org Mon Mar 4 20:35:13 2002 From: guido@python.org (Guido van Rossum) Date: Mon, 04 Mar 2002 15:35:13 -0500 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.30,1.31 In-Reply-To: Your message of "Mon, 04 Mar 2002 15:29:43 EST." References: Message-ID: <200203042035.g24KZDH29021@pcp742651pcs.reston01.va.comcast.net> > [Guido] > > Why were we using datetime.new(args) to create instances? > > I have no idea: I did it because the rest of the test file did, and > I confess I even went back and changed some of my plain > "datetime(...)"s into "datetime.new(...)"s! I figure we figured > this was really a Smalltalk class . Fred seems to have started it by accident. His first testcase called datetime.new(...) as the constructor, but that was because in his mind 'datetime' was the module, not the class. I'll fix the TestCases page in the Wiki to avoid more confusion. --Guido van Rossum (home page: http://www.python.org/~guido/) From fdrake@users.sourceforge.net Mon Mar 4 20:41:26 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 04 Mar 2002 12:41:26 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.h,NONE,1.1 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv5607 Added Files: datetime.h Log Message: Preliminary header for the C implementation of the date/time type. --- NEW FILE: datetime.h --- /* datetime.h */ #ifndef DATETIME_H #define DATETIME_H #define _PyDateTime_DATA_SIZE 12 typedef struct { PyObject_HEAD; unsigned char data[_PyDateTime_DATA_SIZE]; } PyDateTime_Object; extern DL_IMPORT(PyTypeObject) PyDateTime_Type; #define PyDateTime_GET_YEAR(o) (((PyDateTime_Object*)o)->data[0] << 8 \ | ((PyDateTime_Object*)o)->data[1]) #define PyDateTime_GET_MONTH(o) (((PyDateTime_Object*)o)->data[2]) #define PyDateTime_GET_DAY(o) (((PyDateTime_Object*)o)->data[3]) #define PyDateTime_GET_HOUR(o) (((PyDateTime_Object*)o)->data[4]) #define PyDateTime_GET_MINUTE(o) (((PyDateTime_Object*)o)->data[5]) #define PyDateTime_GET_SECOND(o) (((PyDateTime_Object*)o)->data[6]) #define PyDateTime_GET_MICROSECOND(o) (((PyDateTime_Object*)o)->data[7] << 16 \ | ((PyDateTime_Object*)o)->data[8] << 8\ | ((PyDateTime_Object*)o)->data[9]) #define PyDateTime_GET_TZOFFSET(o) ((signed int) \ (((PyDateTime_Object*)o)->data[10] << 8\ | ((PyDateTime_Object*)o)->data[11])) #endif From fdrake@users.sourceforge.net Mon Mar 4 20:43:18 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 04 Mar 2002 12:43:18 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.c,1.1,1.2 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv6488 Modified Files: datetime.c Log Message: Added constructor & basic attributes (+ required type object). Several slots have handlers that are dummied in. Index: datetime.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** datetime.c 4 Mar 2002 14:36:16 -0000 1.1 --- datetime.c 4 Mar 2002 20:43:16 -0000 1.2 *************** *** 1,4 **** /* C implementation for the date/time type documented at ! * */ --- 1,4 ---- /* C implementation for the date/time type documented at ! * http://www.zope.org/Members/fdrake/DateTimeWiki/FrontPage */ *************** *** 6,9 **** --- 6,271 ---- #include "modsupport.h" + #include "datetime.h" + + #define MINYEAR 1 + #define MAXYEAR 9999 + + /* Rename the long macros in datetime.h to more reasonable short names. */ + #define GET_YEAR(o) PyDateTime_GET_YEAR(o) + #define GET_MONTH(o) PyDateTime_GET_MONTH(o) + #define GET_DAY(o) PyDateTime_GET_DAY(o) + #define GET_HOUR(o) PyDateTime_GET_HOUR(o) + #define GET_MINUTE(o) PyDateTime_GET_MINUTE(o) + #define GET_SECOND(o) PyDateTime_GET_SECOND(o) + #define GET_MICROSECOND(o) PyDateTime_GET_MICROSECOND(o) + #define GET_TZOFFSET(o) PyDateTime_GET_TZOFFSET(o) + + /* Set accessors. */ + #define SET_YEAR(o, v) (((o)->data[0] = ((v) & 0xff00) >> 8), \ + ((o)->data[1] = ((v) & 0x00ff))) + #define SET_MONTH(o, v) (PyDateTime_GET_MONTH(o) = (v)) + #define SET_DAY(o, v) (PyDateTime_GET_DAY(o) = (v)) + #define SET_HOUR(o, v) (PyDateTime_GET_HOUR(o) = (v)) + #define SET_MINUTE(o, v) (PyDateTime_GET_MINUTE(o) = (v)) + #define SET_SECOND(o, v) (PyDateTime_GET_SECOND(o) = (v)) + #define SET_MICROSECOND(o, v) (((o)->data[7] = ((v) & 0xff0000) >> 16), \ + ((o)->data[8] = ((v) & 0x00ff00) >> 0), \ + ((o)->data[9] = ((v) & 0x00ff00))) + #define SET_TZOFFSET(o, v) (((o)->data[10] = ((v) & 0xff00) >> 8), \ + ((o)->data[11] = ((v) & 0x00ff))) + + static PyObject * + datetime_compare(PyDateTime_Object *self, PyObject *other) + { + PyErr_SetString(PyExc_NotImplementedError, + "not yet implemented"); + return NULL; + } + + static PyObject * + datetime_repr(PyDateTime_Object *self) + { + return PyString_FromString(""); + } + + static PyObject * + datetime_str(PyDateTime_Object *self) + { + return datetime_repr(self); + } + + static int + datetime_hash(PyDateTime_Object *self) + { + return -2; + } + + static int + is_leap(int year) + { + return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); + } + + static int + days_in_month(int year, int month) + { + static int _days_in_month[] = { + 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 + }; + + assert(month >= 1); + assert(month <= 12); + if (month == 2 && is_leap(year)) + return 29; + else + return _days_in_month[month]; + } + + static PyObject * + datetime_new(PyTypeObject *type, PyObject *args, PyObject *kw) + { + PyDateTime_Object *self = NULL; + long int year, month, day, hour = 0, minute = 0, second = 0, usecond = 0; + long int tzoffset; + PyObject *tzoffset_object = Py_None; + + static char * keywords[] = { + "year", "month", "day", "hour", "minute", "second", "microsecond", + "tzoffset", NULL + }; + + if (PyArg_ParseTupleAndKeywords(args, kw, "lll|llllO", keywords, + &year, &month, &day, &hour, &minute, + &second, &usecond, &tzoffset_object)) { + if (year < MINYEAR || year > MAXYEAR) { + PyErr_SetString(PyExc_ValueError, "year is out of range"); + return NULL; + } + if (month < 1 || month > 12) { + PyErr_SetString(PyExc_ValueError, "month must be in 1..12"); + return NULL; + } + if (day < 1 || day > days_in_month(year, month)) { + PyErr_SetString(PyExc_ValueError, "day is out of range for month"); + return NULL; + } + if (hour < 0 || hour > 23) { + PyErr_SetString(PyExc_ValueError, "hour must be in 0..23"); + return NULL; + } + if (minute < 0 || minute > 59) { + PyErr_SetString(PyExc_ValueError, "minute must be in 0..59"); + return NULL; + } + if (second < 0 || second > 59) { + PyErr_SetString(PyExc_ValueError, "second must be in 0..59"); + return NULL; + } + if (usecond < 0 || usecond > 999999) { + PyErr_SetString(PyExc_ValueError, + "microsecond must be in 0..999999"); + return NULL; + } + if (tzoffset_object == Py_None) { + /* tzoffset == None not yet implemented */ + tzoffset = 0; + } + else { + tzoffset_object = PyNumber_Int(tzoffset_object); + if (tzoffset_object == NULL) + return NULL; + tzoffset = PyInt_AS_LONG(tzoffset_object); + Py_DECREF(tzoffset_object); + if (tzoffset < -1439 || tzoffset > 1439) { + PyErr_SetString(PyExc_ValueError, + "tzoffset must be in -1439..1439"); + return NULL; + } + tzoffset_object = NULL; + } + self = PyObject_New(PyDateTime_Object, &PyDateTime_Type); + if (self != NULL) { + SET_YEAR(self, year); + SET_MONTH(self, month); + SET_DAY(self, day); + SET_HOUR(self, hour); + SET_MINUTE(self, minute); + SET_SECOND(self, second); + SET_MICROSECOND(self, usecond); + SET_TZOFFSET(self, tzoffset); + } + } + return (PyObject *) self; + } + + + static PyObject * + datetime_year(PyDateTime_Object *self, void *unused) + { + return (PyInt_FromLong(GET_YEAR(self))); + } + + static PyObject * + datetime_month(PyDateTime_Object *self, void *unused) + { + return (PyInt_FromLong(GET_MONTH(self))); + } + + static PyObject * + datetime_day(PyDateTime_Object *self, void *unused) + { + return (PyInt_FromLong(GET_DAY(self))); + } + + static PyObject * + datetime_hour(PyDateTime_Object *self, void *unused) + { + return (PyInt_FromLong(GET_HOUR(self))); + } + + static PyObject * + datetime_minute(PyDateTime_Object *self, void *unused) + { + return (PyInt_FromLong(GET_MINUTE(self))); + } + + static PyObject * + datetime_second(PyDateTime_Object *self, void *unused) + { + return (PyInt_FromLong(GET_SECOND(self))); + } + + static PyObject * + datetime_microsecond(PyDateTime_Object *self, void *unused) + { + return (PyInt_FromLong(GET_MICROSECOND(self))); + } + + static PyObject * + datetime_tzoffset(PyDateTime_Object *self, void *unused) + { + return (PyInt_FromLong(GET_TZOFFSET(self))); + } + + static PyGetSetDef datetime_getset[] = { + {"year",(getter)datetime_year}, + {"month", (getter)datetime_month}, + {"day", (getter)datetime_day}, + {"hour", (getter)datetime_hour}, + {"minute", (getter)datetime_minute}, + {"second", (getter)datetime_second}, + {"microsecond", (getter)datetime_microsecond}, + {"tzoffset", (getter)datetime_tzoffset}, + {NULL} + }; + + static char datetime_doc[] = + "Basic date/time type."; + + + PyTypeObject PyDateTime_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /* ob_size */ + "datetime.datetime", /* tp_name */ + sizeof(PyDateTime_Object), /* tp_basicsize */ + 0, /* tp_itemsize */ + _PyObject_Del, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + (cmpfunc)datetime_compare, /* tp_compare */ + (reprfunc)datetime_repr, /* tp_repr */ + 0, /* tp_as_number */ + /*&datetime_as_number, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)datetime_hash, /* tp_hash */ + 0, /* tp_call */ + (reprfunc)datetime_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + datetime_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + datetime_getset, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + datetime_new, /* tp_new */ + _PyObject_Del, /* tp_free */ + }; *************** *** 17,23 **** init_datetime(void) { ! PyObject *m = Py_InitModule3("_datetime", functions, ! "Fast implementation of the datetime type."); PyModule_AddIntConstant(m, "MINYEAR", 1); PyModule_AddIntConstant(m, "MAXYEAR", 9999); } --- 279,292 ---- init_datetime(void) { ! PyObject *m; ! ! if (PyType_Ready(&PyDateTime_Type) < 0) ! return; ! ! m = Py_InitModule3("_datetime", functions, ! "Fast implementation of the datetime type."); PyModule_AddIntConstant(m, "MINYEAR", 1); PyModule_AddIntConstant(m, "MAXYEAR", 9999); + Py_INCREF(&PyDateTime_Type); + PyModule_AddObject(m, "datetime", (PyObject *) &PyDateTime_Type); } From fdrake@users.sourceforge.net Mon Mar 4 20:44:21 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 04 Mar 2002 12:44:21 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_cdatetime.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv6906 Added Files: test_cdatetime.py Log Message: Tests that the C implementation passes. This will eventually be stubbed to use test_datetime or be removed. --- NEW FILE: test_cdatetime.py --- """Test date/time type. See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases """ import sys import unittest from _datetime import datetime, MINYEAR, MAXYEAR class TestDateTime(unittest.TestCase): def test_basic_attributes(self): dt = datetime(2002, 3, 1, 12, 0, 0) self.assertEqual(dt.year, 2002) self.assertEqual(dt.month, 3) self.assertEqual(dt.day, 1) self.assertEqual(dt.hour, 12) self.assertEqual(dt.minute, 0) self.assertEqual(dt.second, 0) self.assertEqual(dt.microsecond, 0) def test_suite(): s1 = unittest.makeSuite(TestDateTime, 'test') return unittest.TestSuite([s1]) def test_main(): r = unittest.TextTestRunner(stream=sys.stdout, verbosity=2) s = test_suite() r.run(s) if __name__ == "__main__": test_main() From fdrake@users.sourceforge.net Mon Mar 4 20:44:51 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 04 Mar 2002 12:44:51 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime Makefile,1.1,1.2 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv7118 Modified Files: Makefile Log Message: Run the tests for the C date/time as well. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/Makefile,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile 4 Mar 2002 14:36:16 -0000 1.1 --- Makefile 4 Mar 2002 20:44:49 -0000 1.2 *************** *** 9,12 **** --- 9,13 ---- check: _datetime.so $(PYTHON) test_datetime.py + $(PYTHON) test_cdatetime.py test: check From fdrake@acm.org Mon Mar 4 21:08:14 2002 From: fdrake@acm.org (Fred L. Drake, Jr.) Date: Mon, 4 Mar 2002 16:08:14 -0500 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.30,1.31 In-Reply-To: <200203042035.g24KZDH29021@pcp742651pcs.reston01.va.comcast.net> References: <200203042035.g24KZDH29021@pcp742651pcs.reston01.va.comcast.net> Message-ID: <15491.57918.40857.545634@grendel.zope.com> Guido van Rossum writes: > Fred seems to have started it by accident. His first testcase called > datetime.new(...) as the constructor, but that was because in his mind > 'datetime' was the module, not the class. I'll fix the TestCases page At the time, none of the code existed, and it seemed a reasonable name for it. Not being a Smalltalk programmer, I never guessed that datetime.new() would be interpreted as a classmethod on a class. ;-) -Fred -- Fred L. Drake, Jr. PythonLabs at Zope Corporation From fdrake@users.sourceforge.net Mon Mar 4 21:20:56 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 04 Mar 2002 13:20:56 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.c,1.2,1.3 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv20985 Modified Files: datetime.c Log Message: Use indentation more consistently. Index: datetime.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** datetime.c 4 Mar 2002 20:43:16 -0000 1.2 --- datetime.c 4 Mar 2002 21:20:54 -0000 1.3 *************** *** 225,270 **** PyTypeObject PyDateTime_Type = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, /* ob_size */ ! "datetime.datetime", /* tp_name */ ! sizeof(PyDateTime_Object), /* tp_basicsize */ ! 0, /* tp_itemsize */ ! _PyObject_Del, /* tp_dealloc */ ! 0, /* tp_print */ ! 0, /* tp_getattr */ ! 0, /* tp_setattr */ ! (cmpfunc)datetime_compare, /* tp_compare */ ! (reprfunc)datetime_repr, /* tp_repr */ ! 0, /* tp_as_number */ ! /*&datetime_as_number, /* tp_as_number */ ! 0, /* tp_as_sequence */ ! 0, /* tp_as_mapping */ ! (hashfunc)datetime_hash, /* tp_hash */ ! 0, /* tp_call */ ! (reprfunc)datetime_str, /* tp_str */ ! PyObject_GenericGetAttr, /* tp_getattro */ ! 0, /* tp_setattro */ ! 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES | ! Py_TPFLAGS_BASETYPE, /* tp_flags */ ! datetime_doc, /* tp_doc */ ! 0, /* tp_traverse */ ! 0, /* tp_clear */ ! 0, /* tp_richcompare */ ! 0, /* tp_weaklistoffset */ ! 0, /* tp_iter */ ! 0, /* tp_iternext */ ! 0, /* tp_methods */ ! 0, /* tp_members */ ! datetime_getset, /* tp_getset */ ! 0, /* tp_base */ ! 0, /* tp_dict */ ! 0, /* tp_descr_get */ ! 0, /* tp_descr_set */ ! 0, /* tp_dictoffset */ ! 0, /* tp_init */ ! 0, /* tp_alloc */ ! datetime_new, /* tp_new */ ! _PyObject_Del, /* tp_free */ }; --- 225,269 ---- PyTypeObject PyDateTime_Type = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, /* ob_size */ ! "datetime.datetime", /* tp_name */ ! sizeof(PyDateTime_Object), /* tp_basicsize */ ! 0, /* tp_itemsize */ ! _PyObject_Del, /* tp_dealloc */ ! 0, /* tp_print */ ! 0, /* tp_getattr */ ! 0, /* tp_setattr */ ! (cmpfunc)datetime_compare, /* tp_compare */ ! (reprfunc)datetime_repr, /* tp_repr */ ! 0, /* tp_as_number */ ! 0, /* tp_as_sequence */ ! 0, /* tp_as_mapping */ ! (hashfunc)datetime_hash, /* tp_hash */ ! 0, /* tp_call */ ! (reprfunc)datetime_str, /* tp_str */ ! PyObject_GenericGetAttr, /* tp_getattro */ ! 0, /* tp_setattro */ ! 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES | ! Py_TPFLAGS_BASETYPE, /* tp_flags */ ! datetime_doc, /* tp_doc */ ! 0, /* tp_traverse */ ! 0, /* tp_clear */ ! 0, /* tp_richcompare */ ! 0, /* tp_weaklistoffset */ ! 0, /* tp_iter */ ! 0, /* tp_iternext */ ! 0, /* tp_methods */ ! 0, /* tp_members */ ! datetime_getset, /* tp_getset */ ! 0, /* tp_base */ ! 0, /* tp_dict */ ! 0, /* tp_descr_get */ ! 0, /* tp_descr_set */ ! 0, /* tp_dictoffset */ ! 0, /* tp_init */ ! 0, /* tp_alloc */ ! datetime_new, /* tp_new */ ! _PyObject_Del, /* tp_free */ }; From tim_one@users.sourceforge.net Mon Mar 4 22:52:09 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 04 Mar 2002 14:52:09 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.45,1.46 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv23648 Modified Files: datetime.py Log Message: timedelta.__init__(): Massive rewrite to deal correctly with both the huge dynamic range of floats and the unbounded precision of longs, while also isolating the subcomputations that can be reliably done with 32-bit ints (and asserting that those won't overflow when redone in C -- but assuming Python ints are 32 bits, for sanity's sake). Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** datetime.py 4 Mar 2002 20:24:12 -0000 1.45 --- datetime.py 4 Mar 2002 22:52:07 -0000 1.46 *************** *** 305,336 **** # XXX The following should only be used as keyword args: milliseconds=0, minutes=0, hours=0, weeks=0): # Normalize everything to days, seconds, microseconds. ! # Convert everything to float first, else overflow-checking in C ! # is going to be a nightmare. ! days += weeks*7. ! seconds += minutes*60. + hours*3600. ! microseconds += milliseconds*1000. ! # Get rid of all fractions. ! dayfrac, days = _math.modf(days) ! daysecondsfrac, daysecondswhole = _math.modf(dayfrac * (24.*3600.)) ! secondsfrac, seconds = _math.modf(seconds) ! seconds += daysecondswhole secondsfrac += daysecondsfrac ! microseconds += secondsfrac*1e6 ! microseconds = round(microseconds) ! assert _math.modf(days)[0] == 0.0 ! assert _math.modf(seconds)[0] == 0.0 ! assert _math.modf(microseconds)[0] == 0.0 ! # Propagate carry from us to s, from s to d ! s, us = divmod(microseconds, 1000000) ! assert us == int(us) and 0 <= us < 1000000 ! d, s = divmod(s + seconds, 24*3600) ! assert s == int(s) and 0 <= s < 24*3600 d += days ! assert d == long(d) ! # d may be < 0 ! self.__days = int(d) ! self.__seconds = int(s) ! self.__microseconds = int(us) def __repr__(self): --- 305,406 ---- # XXX The following should only be used as keyword args: milliseconds=0, minutes=0, hours=0, weeks=0): + # Doing this efficiently and accurately in C is going to be difficult + # and error-prone, due to ubiquitous overflow possibilities, and that + # C double doesn't have enough bits of precision to represent + # microseconds over 10K years faithfully. The code here tries to make + # explicit where go-fast assumptions can be relied on, in order to + # guide the C implementation; it's way more convoluted than speed- + # ignoring auto-overflow-to-long idiomatic Python could be. + + # XXX Check that all inputs are ints, longs or floats. + + # Final values, all integer. + # s and us fit in 32-bit signed ints; d isn't bounded. + d = s = us = 0 + # Normalize everything to days, seconds, microseconds. ! days += weeks*7 ! seconds += minutes*60 + hours*3600 ! microseconds += milliseconds*1000 ! ! # Get rid of all fractions, and normalize s and us. ! # Take a deep breath . ! if isinstance(days, float): ! dayfrac, days = _math.modf(days) ! daysecondsfrac, daysecondswhole = _math.modf(dayfrac * (24.*3600.)) ! assert daysecondswhole == int(daysecondswhole) # can't overflow ! daysecondswhole = int(daysecondswhole) ! assert days == long(days) ! d = long(days) ! else: ! daysecondsfrac, daysecondswhole = 0.0, 0 ! d = days ! assert isinstance(daysecondsfrac, float) ! assert isinstance(daysecondswhole, int) ! assert 0 <= daysecondswhole < 24*3600 ! assert isinstance(d, (int, long)) ! # days isn't referenced again before redefinition ! ! if isinstance(seconds, float): ! secondsfrac, seconds = _math.modf(seconds) ! assert seconds == long(seconds) ! seconds = long(seconds) ! else: ! secondsfrac = 0.0 ! assert isinstance(secondsfrac, float) ! assert isinstance(seconds, (int, long)) ! days, seconds = divmod(seconds, 24*3600) ! d += days ! s = int(seconds) # can't overflow ! s += daysecondswhole # can't overflow ! assert isinstance(s, int) ! assert 0 <= s < 2*24*3600 ! # seconds isn't referenced again before redefinition ! secondsfrac += daysecondsfrac ! assert -2.0 <= secondsfrac <= 2.0 ! usdouble = secondsfrac * 1e6 ! assert -2.1e6 < usdouble < 2.1e6 # exact value not critical ! # secondsfrac & daysecondsfrac aren't referenced again ! ! if isinstance(microseconds, float): ! microseconds += usdouble ! microseconds = round(microseconds) ! seconds, microseconds = divmod(microseconds, 1e6) ! assert microseconds == int(microseconds) ! assert seconds == long(seconds) ! days, seconds = divmod(seconds, 24.*3600.) ! assert days == long(days) ! assert seconds == int(seconds) ! d += long(days) ! s += int(seconds) # can't overflow ! assert isinstance(s, int) ! else: ! seconds, microseconds = divmod(microseconds, 1000000) ! days, seconds = divmod(seconds, 24*3600) ! d += days ! s += int(seconds) # can't overflow ! assert isinstance(s, int) ! microseconds = float(microseconds) ! microseconds += usdouble ! microseconds = round(microseconds) ! ! # Just a little bit of carrying possible for microseconds and seconds. ! assert isinstance(microseconds, float) ! assert 0 <= microseconds <= 3.1e6 ! assert int(microseconds) == microseconds ! us = int(microseconds) ! seconds, us = divmod(us, 1000000) ! s += seconds # cant't overflow ! assert isinstance(s, int) ! days, s = divmod(s, 24*3600) d += days ! ! assert isinstance(d, (int, long)) ! assert isinstance(s, int) and 0 <= s < 24*3600 ! assert isinstance(us, int) and 0 <= us < 1000000 ! self.__days = d ! self.__seconds = s ! self.__microseconds = us def __repr__(self): From montanaro@users.sourceforge.net Mon Mar 4 23:08:30 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Mon, 04 Mar 2002 15:08:30 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libre.tex,1.75,1.76 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv30742 Modified Files: libre.tex Log Message: add simple example of avoiding backtracking Index: libre.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** libre.tex 25 Feb 2002 18:56:45 -0000 1.75 --- libre.tex 4 Mar 2002 23:08:28 -0000 1.76 *************** *** 803,810 **** \subsection{Examples} - %\begin{list}{}{\leftmargin 0.7in \labelwidth 0.65in} - - %\item[Simulating scanf] - \leftline{\strong{Simulating \cfunction{scanf()}}} --- 803,806 ---- *************** *** 852,857 **** \begin{verbatim} ! ([^\s]+) - (\d+) errors, (\d+) warnings \end{verbatim} ! %\end{list} --- 848,873 ---- \begin{verbatim} ! (\S+) - (\d+) errors, (\d+) warnings \end{verbatim} ! \leftline{\strong{Avoiding backtracking}} ! ! If you create regular expressions that require the engine to perform a lot ! of backtracking, you may encounter a RuntimeError exception with the message ! \code{maximum recursion limit exceeded}. For example, ! ! \begin{verbatim} ! >>> s = "<" + "that's a very big string!"*1000 + ">" ! >>> re.match('<.*?>', s) ! Traceback (most recent call last): ! File "", line 1, in ? ! File "/usr/local/lib/python2.3/sre.py", line 132, in match ! return _compile(pattern, flags).match(string) ! RuntimeError: maximum recursion limit exceeded ! \end{verbatim} ! ! You can often restructure your regular expression to avoid backtracking. ! The above regular expression can be recast as \regexp{\textless ! [\textasciicircum \textgreater]*\textgreater}. As a further ! benefit, such regular expressions will run faster than their backtracking ! equivalents. From gvanrossum@users.sourceforge.net Tue Mar 5 03:23:23 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Mon, 04 Mar 2002 19:23:23 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.46,1.47 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv18346 Modified Files: datetime.py Log Message: Small stuff: - Make _MONTHNAMES and _DAYNAMES 1-indexed arrays by inserting a None (matching _DAYS_IN_MONTH etc.) - Change timedelta.__repr__ to return self.__class__.__name__ (but not the full module name) - Change various operations to use self.__class__ rather than timedelta or datetime, to support subclasses - In datetime, add a class variable timedelta_class which is used for the return type of __sub__, so a subclass can override the class to be used for deltas There are no tests for these behaviors yet. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** datetime.py 4 Mar 2002 22:52:07 -0000 1.46 --- datetime.py 5 Mar 2002 03:23:21 -0000 1.47 *************** *** 146,152 **** # Month and day names. For localized versions, see the calendar module. ! _MONTHNAMES = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", ! "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] ! _DAYNAMES = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] # This is a start at a struct tm workalike. Goals: --- 146,152 ---- # Month and day names. For localized versions, see the calendar module. ! _MONTHNAMES = [None, "Jan", "Feb", "Mar", "Apr", "May", "Jun", ! "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] ! _DAYNAMES = [None, "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] # This is a start at a struct tm workalike. Goals: *************** *** 242,247 **** weekday = self.toordinal() % 7 or 7 return "%s %s %2d %02d:%02d:%02d %04d" % ( ! _DAYNAMES[weekday - 1], ! _MONTHNAMES[self.month - 1], self.day, self.hour, self.minute, self.second, --- 242,247 ---- weekday = self.toordinal() % 7 or 7 return "%s %s %2d %02d:%02d:%02d %04d" % ( ! _DAYNAMES[weekday], ! _MONTHNAMES[self.month], self.day, self.hour, self.minute, self.second, *************** *** 406,415 **** def __repr__(self): if self.__microseconds: ! return "timedelta(days=%d, %d, %d)" % (self.__days, ! self.__seconds, ! self.__microseconds) if self.__seconds: ! return "timedelta(%d, %d)" % (self.__days, self.__seconds) ! return "timedelta(%d)" % self.__days def __str__(self): --- 406,418 ---- def __repr__(self): if self.__microseconds: ! return "%s(days=%d, %d, %d)" % (self.__class__.__name__, ! self.__days, ! self.__seconds, ! self.__microseconds) if self.__seconds: ! return "%s(%d, %d)" % (self.__class__.__name__, ! self.__days, ! self.__seconds) ! return "%s(%d)" % (self.__class__.__name__, self.__days) def __str__(self): *************** *** 439,445 **** def __add__(self, other): if isinstance(other, timedelta): ! return timedelta(self.__days + other.__days, ! self.__seconds + other.__seconds, ! self.__microseconds + other.__microseconds) raise TypeError # XXX Should be 'return NotImplemented', but there's a bug in 2.2... --- 442,448 ---- def __add__(self, other): if isinstance(other, timedelta): ! return self.__class__(self.__days + other.__days, ! self.__seconds + other.__seconds, ! self.__microseconds + other.__microseconds) raise TypeError # XXX Should be 'return NotImplemented', but there's a bug in 2.2... *************** *** 458,462 **** def __neg__(self): ! return timedelta(-self.__days, -self.__seconds, -self.__microseconds) def __pos__(self): --- 461,467 ---- def __neg__(self): ! return self.__class__(-self.__days, ! -self.__seconds, ! -self.__microseconds) def __pos__(self): *************** *** 471,477 **** def __mul__(self, other): if isinstance(other, (int, long)): ! return timedelta(self.__days * other, ! self.__seconds * other, ! self.__microseconds * other) return NotImplemented --- 476,482 ---- def __mul__(self, other): if isinstance(other, (int, long)): ! return self.__class__(self.__days * other, ! self.__seconds * other, ! self.__microseconds * other) return NotImplemented *************** *** 482,486 **** usec = ((self.__days * (24*3600L) + self.__seconds) * 1000000 + self.__microseconds) ! return timedelta(0, 0, usec // other) return NotImplemented --- 487,491 ---- usec = ((self.__days * (24*3600L) + self.__seconds) * 1000000 + self.__microseconds) ! return self.__class__(0, 0, usec // other) return NotImplemented *************** *** 756,762 **** self.__microsecond + other.microseconds) self._checkOverflow(t.year) ! result = datetime(t.year, t.month, t.day, ! t.hour, t.minute, t.second, ! t.microsecond, self.__tzoffset) return result raise TypeError --- 761,767 ---- self.__microsecond + other.microseconds) self._checkOverflow(t.year) ! result = self.__class__(t.year, t.month, t.day, ! t.hour, t.minute, t.second, ! t.microsecond, self.__tzoffset) return result raise TypeError *************** *** 765,768 **** --- 770,775 ---- __radd__ = __add__ + timedelta_class = timedelta # Allows a subclass to override + def __sub__(self, other): """Subtract two datetimes, or a datetime and a timedelta. *************** *** 781,786 **** (other.__minute - other.__tzoffset) * 60 + other.__hour * 3600) ! return timedelta(days1 - days2, secs1 - secs2, ! self.__microsecond - other.__microsecond) return NotImplemented --- 788,795 ---- (other.__minute - other.__tzoffset) * 60 + other.__hour * 3600) ! return self.timedelta_class( ! days1 - days2, ! secs1 - secs2, ! self.__microsecond - other.__microsecond) return NotImplemented From tim_one@users.sourceforge.net Tue Mar 5 03:55:37 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 04 Mar 2002 19:55:37 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.h,1.1,1.2 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv25638 Modified Files: datetime.h Log Message: PyObject_HEAD already contains a semicolon, and MSVC can't tolerate putting another semicolon after it. Getting rid of the semicolon clears up oodles of bogus errors. Still doesn't compile on Windows, though: datetime.c(226) : warning C4273: 'PyDateTime_Type' : inconsistent dll linkage. dllexport assumed. datetime.c(227) : error C2099: initializer is not a constant plus lots of warnings, some of which look serious. Index: datetime.h =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** datetime.h 4 Mar 2002 20:41:24 -0000 1.1 --- datetime.h 5 Mar 2002 03:55:35 -0000 1.2 *************** *** 9,13 **** typedef struct { ! PyObject_HEAD; unsigned char data[_PyDateTime_DATA_SIZE]; } PyDateTime_Object; --- 9,13 ---- typedef struct { ! PyObject_HEAD unsigned char data[_PyDateTime_DATA_SIZE]; } PyDateTime_Object; From fdrake@users.sourceforge.net Tue Mar 5 04:02:41 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 04 Mar 2002 20:02:41 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libre.tex,1.76,1.77 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv28790/lib Modified Files: libre.tex Log Message: Remove extra indenatation from sample interpreter session. Remove whitespace from the middle of an inline RE example; it was OK for the typeset formats, but LaTeX2HTML is more touchy about this. Index: libre.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** libre.tex 4 Mar 2002 23:08:28 -0000 1.76 --- libre.tex 5 Mar 2002 04:02:39 -0000 1.77 *************** *** 858,873 **** \begin{verbatim} ! >>> s = "<" + "that's a very big string!"*1000 + ">" ! >>> re.match('<.*?>', s) ! Traceback (most recent call last): ! File "", line 1, in ? ! File "/usr/local/lib/python2.3/sre.py", line 132, in match ! return _compile(pattern, flags).match(string) ! RuntimeError: maximum recursion limit exceeded \end{verbatim} You can often restructure your regular expression to avoid backtracking. ! The above regular expression can be recast as \regexp{\textless ! [\textasciicircum \textgreater]*\textgreater}. As a further ! benefit, such regular expressions will run faster than their backtracking ! equivalents. --- 858,873 ---- \begin{verbatim} ! >>> s = "<" + "that's a very big string!"*1000 + ">" ! >>> re.match('<.*?>', s) ! Traceback (most recent call last): ! File "", line 1, in ? ! File "/usr/local/lib/python2.3/sre.py", line 132, in match ! return _compile(pattern, flags).match(string) ! RuntimeError: maximum recursion limit exceeded \end{verbatim} You can often restructure your regular expression to avoid backtracking. ! The above regular expression can be recast as ! \regexp{\textless[\textasciicircum \textgreater]*\textgreater}. As a ! further benefit, such regular expressions will run faster than their ! backtracking equivalents. From fdrake@users.sourceforge.net Tue Mar 5 04:04:08 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 04 Mar 2002 20:04:08 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/perl python.perl,1.116,1.117 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/perl In directory usw-pr-cvs1:/tmp/cvs-serv29139/perl Modified Files: python.perl Log Message: Add implementations for \textgreater and \textless, defined in (relatively) recent versions of LaTeX2e but not support in LaTeX2HTML. Index: python.perl =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/perl/python.perl,v retrieving revision 1.116 retrieving revision 1.117 diff -C2 -d -r1.116 -r1.117 *** python.perl 14 Dec 2001 22:50:05 -0000 1.116 --- python.perl 5 Mar 2002 04:04:06 -0000 1.117 *************** *** 89,92 **** --- 89,94 ---- sub do_cmd_textasciicircum{ '^' . @_[0]; } sub do_cmd_textbar{ '|' . @_[0]; } + sub do_cmd_textgreater{ '>' . @_[0]; } + sub do_cmd_textless{ '<' . @_[0]; } sub do_cmd_infinity{ '∞' . @_[0]; } sub do_cmd_plusminus{ '±' . @_[0]; } From tim_one@users.sourceforge.net Tue Mar 5 04:15:56 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 04 Mar 2002 20:15:56 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.47,1.48 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv31117 Modified Files: datetime.py Log Message: timedelta.__init__(): Small simplification to handling of seconds; repaired some incorrect asserts not triggered by the tests. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** datetime.py 5 Mar 2002 03:23:21 -0000 1.47 --- datetime.py 5 Mar 2002 04:15:53 -0000 1.48 *************** *** 330,343 **** daysecondsfrac, daysecondswhole = _math.modf(dayfrac * (24.*3600.)) assert daysecondswhole == int(daysecondswhole) # can't overflow ! daysecondswhole = int(daysecondswhole) assert days == long(days) d = long(days) else: ! daysecondsfrac, daysecondswhole = 0.0, 0 d = days assert isinstance(daysecondsfrac, float) - assert isinstance(daysecondswhole, int) - assert 0 <= daysecondswhole < 24*3600 assert isinstance(d, (int, long)) # days isn't referenced again before redefinition --- 330,342 ---- daysecondsfrac, daysecondswhole = _math.modf(dayfrac * (24.*3600.)) assert daysecondswhole == int(daysecondswhole) # can't overflow ! s = int(daysecondswhole) assert days == long(days) d = long(days) else: ! daysecondsfrac = 0.0 d = days assert isinstance(daysecondsfrac, float) assert isinstance(d, (int, long)) + assert abs(s) <= 24 * 3600 # days isn't referenced again before redefinition *************** *** 352,359 **** days, seconds = divmod(seconds, 24*3600) d += days ! s = int(seconds) # can't overflow ! s += daysecondswhole # can't overflow assert isinstance(s, int) ! assert 0 <= s < 2*24*3600 # seconds isn't referenced again before redefinition --- 351,357 ---- days, seconds = divmod(seconds, 24*3600) d += days ! s += int(seconds) # can't overflow assert isinstance(s, int) ! assert abs(s) <= 2 * 24 * 3600 # seconds isn't referenced again before redefinition *************** *** 376,379 **** --- 374,378 ---- s += int(seconds) # can't overflow assert isinstance(s, int) + assert abs(s) <= 3 * 24 * 3600 else: seconds, microseconds = divmod(microseconds, 1000000) *************** *** 382,392 **** s += int(seconds) # can't overflow assert isinstance(s, int) microseconds = float(microseconds) microseconds += usdouble microseconds = round(microseconds) # Just a little bit of carrying possible for microseconds and seconds. assert isinstance(microseconds, float) - assert 0 <= microseconds <= 3.1e6 assert int(microseconds) == microseconds us = int(microseconds) --- 381,393 ---- s += int(seconds) # can't overflow assert isinstance(s, int) + assert abs(s) <= 3 * 24 * 3600 microseconds = float(microseconds) microseconds += usdouble microseconds = round(microseconds) + assert abs(s) <= 3 * 24 * 3600 + assert abs(microseconds) <= 3.1e6 # Just a little bit of carrying possible for microseconds and seconds. assert isinstance(microseconds, float) assert int(microseconds) == microseconds us = int(microseconds) From tim_one@users.sourceforge.net Tue Mar 5 04:19:06 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 04 Mar 2002 20:19:06 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.32,1.33 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv31542 Modified Files: test_datetime.py Log Message: test_hash_equality(): Use the datetime objects constructed for hash- equality tests as dict keys, and make sure equal keys "work" in context. Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** test_datetime.py 4 Mar 2002 20:26:54 -0000 1.32 --- test_datetime.py 5 Mar 2002 04:19:03 -0000 1.33 *************** *** 151,154 **** --- 151,160 ---- self.assertEqual(hash(d), hash(e)) + dic = {d: 1} + dic[e] = 2 + self.assertEqual(len(dic), 1) + self.assertEqual(dic[d], 2) + self.assertEqual(dic[e], 2) + d = datetime(2001, 1, 1, 0, 5, 17, tzoffset=35) # same thing in UTC. *************** *** 156,159 **** --- 162,171 ---- self.assertEqual(d, e) self.assertEqual(hash(d), hash(e)) + + dic = {d: 1} + dic[e] = 2 + self.assertEqual(len(dic), 1) + self.assertEqual(dic[d], 2) + self.assertEqual(dic[e], 2) def test_timedelta(self): From fdrake@users.sourceforge.net Tue Mar 5 06:44:51 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 04 Mar 2002 22:44:51 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime Makefile,1.2,1.3 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv24440 Modified Files: Makefile Log Message: Add dependency on the header file. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile 4 Mar 2002 20:44:49 -0000 1.2 --- Makefile 5 Mar 2002 06:44:49 -0000 1.3 *************** *** 4,8 **** all: _datetime.so ! _datetime.so: datetime.c $(PYTHON) setup.py build_ext -i --- 4,8 ---- all: _datetime.so ! _datetime.so: datetime.c datetime.h $(PYTHON) setup.py build_ext -i From tim_one@users.sourceforge.net Tue Mar 5 07:59:14 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 04 Mar 2002 23:59:14 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.33,1.34 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv7224 Modified Files: test_datetime.py Log Message: test_overflow(): use datetime.{min, max, resolution} instead of hardcoded constants. Plus assorted minor fiddling. Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** test_datetime.py 5 Mar 2002 04:19:03 -0000 1.33 --- test_datetime.py 5 Mar 2002 07:59:12 -0000 1.34 *************** *** 285,300 **** def test_overflow(self): ! us = timedelta(microseconds=1) ! mus = - us ! dt = datetime(MINYEAR, 1, 1, microsecond=1) ! dt -= us # no problem ! self.assertRaises(OverflowError, dt.__sub__, us) ! self.assertRaises(OverflowError, dt.__add__, mus) ! dt = datetime(MAXYEAR, 12, 31, 23, 59, 59, 999998) ! dt += us # no problem ! self.assertRaises(OverflowError, dt.__add__, us) ! self.assertRaises(OverflowError, dt.__sub__, mus) def test_weekday(self): --- 285,299 ---- def test_overflow(self): ! tiny = datetime.resolution ! dt = datetime.min + tiny ! dt -= tiny # no problem ! self.assertRaises(OverflowError, dt.__sub__, tiny) ! self.assertRaises(OverflowError, dt.__add__, -tiny) ! dt = datetime.max - tiny ! dt += tiny # no problem ! self.assertRaises(OverflowError, dt.__add__, tiny) ! self.assertRaises(OverflowError, dt.__sub__, -tiny) def test_weekday(self): *************** *** 374,378 **** for timestamp in 123456789.0, 987654321.0: dt = datetime.utcfromtimestamp(timestamp) ! # Mange the fields, but in such a way that normalization should # restore them to dt's values. tm = tmxxx(dt.year - 1, dt.month + 12, dt.day + 100, --- 373,377 ---- for timestamp in 123456789.0, 987654321.0: dt = datetime.utcfromtimestamp(timestamp) ! # Manglee the fields, but in such a way that normalization should # restore them to dt's values. tm = tmxxx(dt.year - 1, dt.month + 12, dt.day + 100, *************** *** 407,413 **** --- 406,416 ---- def test_extreme_timedelta(self): big = datetime.max - datetime.min + # 3652058 days, 23 hours, 59 minutes, 59 seconds, 999999 microseconds n = (big.days*24*3600 + big.seconds)*1000000 + big.microseconds + # n = 315537897599999999 justasbig = timedelta(0, 0, n) self.assertEqual(big, justasbig) + self.assertEqual(datetime.min + big, datetime.max) + self.assertEqual(datetime.max - big, datetime.min) def test_suite(): From tim_one@users.sourceforge.net Tue Mar 5 08:00:43 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Tue, 05 Mar 2002 00:00:43 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.34,1.35 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv7779 Modified Files: test_datetime.py Log Message: Finished a new comment. Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** test_datetime.py 5 Mar 2002 07:59:12 -0000 1.34 --- test_datetime.py 5 Mar 2002 08:00:41 -0000 1.35 *************** *** 408,412 **** # 3652058 days, 23 hours, 59 minutes, 59 seconds, 999999 microseconds n = (big.days*24*3600 + big.seconds)*1000000 + big.microseconds ! # n = 315537897599999999 justasbig = timedelta(0, 0, n) self.assertEqual(big, justasbig) --- 408,412 ---- # 3652058 days, 23 hours, 59 minutes, 59 seconds, 999999 microseconds n = (big.days*24*3600 + big.seconds)*1000000 + big.microseconds ! # n = 315537897599999999 ~= 2**58.13 justasbig = timedelta(0, 0, n) self.assertEqual(big, justasbig) From tim_one@users.sourceforge.net Tue Mar 5 08:30:33 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Tue, 05 Mar 2002 00:30:33 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.48,1.49 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv14634 Modified Files: datetime.py Log Message: _ord2ymd(): Cheaper way to estimate the month, with an addition and a shift, replacing an addition, a division, and a min(). Amazingly, in both leap and non-leap years, this needs to take the "if" (correction) branch exactly as many times as the more expensive method (across all possible values for n). Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** datetime.py 5 Mar 2002 04:15:53 -0000 1.48 --- datetime.py 5 Mar 2002 08:30:31 -0000 1.49 *************** *** 133,137 **** leapyear = n1 == 3 and (n4 != 24 or n100 == 3) assert leapyear == _is_leap(year) ! month = min(n//29 + 1, 12) preceding = _DAYS_BEFORE_MONTH[month] + (month > 2 and leapyear) if preceding > n: # estimate is too large --- 133,137 ---- leapyear = n1 == 3 and (n4 != 24 or n100 == 3) assert leapyear == _is_leap(year) ! month = (n + 50) >> 5 preceding = _DAYS_BEFORE_MONTH[month] + (month > 2 and leapyear) if preceding > n: # estimate is too large From tim_one@users.sourceforge.net Tue Mar 5 08:39:15 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Tue, 05 Mar 2002 00:39:15 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.49,1.50 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv18115 Modified Files: datetime.py Log Message: _ord2ymd(): Strengthened a crucial assertion. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** datetime.py 5 Mar 2002 08:30:31 -0000 1.49 --- datetime.py 5 Mar 2002 08:39:13 -0000 1.50 *************** *** 138,143 **** month -= 1 preceding -= _DAYS_IN_MONTH[month] + (month == 2 and leapyear) - assert 0 <= preceding <= n n -= preceding # Now the year and month are correct, and n is the offset from the --- 138,143 ---- month -= 1 preceding -= _DAYS_IN_MONTH[month] + (month == 2 and leapyear) n -= preceding + assert 0 <= n < _days_in_month(month, year) # Now the year and month are correct, and n is the offset from the From tim_one@users.sourceforge.net Tue Mar 5 08:53:35 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Tue, 05 Mar 2002 00:53:35 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.35,1.36 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv21491 Modified Files: test_datetime.py Log Message: Typo in comment. Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** test_datetime.py 5 Mar 2002 08:00:41 -0000 1.35 --- test_datetime.py 5 Mar 2002 08:53:33 -0000 1.36 *************** *** 373,377 **** for timestamp in 123456789.0, 987654321.0: dt = datetime.utcfromtimestamp(timestamp) ! # Manglee the fields, but in such a way that normalization should # restore them to dt's values. tm = tmxxx(dt.year - 1, dt.month + 12, dt.day + 100, --- 373,377 ---- for timestamp in 123456789.0, 987654321.0: dt = datetime.utcfromtimestamp(timestamp) ! # Mangles the fields, but in such a way that normalization should # restore them to dt's values. tm = tmxxx(dt.year - 1, dt.month + 12, dt.day + 100, From tim_one@users.sourceforge.net Tue Mar 5 09:12:46 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Tue, 05 Mar 2002 01:12:46 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.50,1.51 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv25482 Modified Files: datetime.py Log Message: _localtzoffset(): If the given date is out of platform mktime()'s range, feed mktime() the same values except for a year that is in its range, and with the same leap-year-ness as the given year. In effect, this imposes a "proleptic" DST determination for years outside the platform range. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** datetime.py 5 Mar 2002 08:39:13 -0000 1.50 --- datetime.py 5 Mar 2002 09:12:44 -0000 1.51 *************** *** 259,265 **** return - (_time.timezone // 60) except (ValueError, OverflowError): ! # XXX Dates out of range for mktime() never see DST ! return - (_time.timezone // 60) ! class basetime(object): --- 259,266 ---- return - (_time.timezone // 60) except (ValueError, OverflowError): ! # Dates out of range for mktime() never see DST. ! # As a reasonable guess, though, we can try a year in mktime()'s range ! # with the same leap-year-ness as the given year. ! return _localtzoffset(2003 + _is_leap(year), month, day, hour, minute) class basetime(object): From mal@lemburg.com Tue Mar 5 09:42:37 2002 From: mal@lemburg.com (M.-A. Lemburg) Date: Tue, 05 Mar 2002 10:42:37 +0100 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.50,1.51 References: Message-ID: <3C84930D.2E0B0E97@lemburg.com> Tim Peters wrote: > > Update of /cvsroot/python/python/nondist/sandbox/datetime > In directory usw-pr-cvs1:/tmp/cvs-serv25482 > > Modified Files: > datetime.py > Log Message: > _localtzoffset(): If the given date is out of platform mktime()'s range, > feed mktime() the same values except for a year that is in its range, and > with the same leap-year-ness as the given year. In effect, this imposes > a "proleptic" DST determination for years outside the platform range. This fails badly. DST rules change every year and historic DST switch times as well as future ones are not necessarily reliable. Have a look at the TZ package at ftp://elsie.nci.nih.gov/pub/ for some fun with DST. They update those files many times a year. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/ From tim@zope.com Tue Mar 5 10:16:16 2002 From: tim@zope.com (Tim Peters) Date: Tue, 5 Mar 2002 05:16:16 -0500 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.50,1.51 In-Reply-To: <3C84930D.2E0B0E97@lemburg.com> Message-ID: >> _localtzoffset(): If the given date is out of platform >> mktime()'s range, feed mktime() the same values except for a year >> that is in its range, and with the same leap-year-ness as the given >> year. In effect, this imposes a "proleptic" DST determination for >> years outside the platform range. [M.-A. Lemburg] > This fails badly. Oh, fiddlesticks. By construction, the platform C library knows nothing whatsoever about DST in such cases. We're not trying to do substantially better than it can, we're just trying to return an explainable result that's better than random. ECMAScript goes on to substitute a year that also begins with the same weekday, and I'm happy to do that too, but not more than that. The implementation of ECMAScript should not try to determine whether the exact time was subject to daylight saving time, but just whether daylight saving time would have been in effect if the current daylight saving time algorithm had been used at the time. > DST rules change every year and historic DST switch times as well as > future ones are not necessarily reliable. Of course. Ignoring reality in favor of something uniform is what "proleptic" means in this context, in the same way that the "proleptic Gregorian" calendar ignores messy date realities (about real-life discontinuous year numbering, varying dates of adoption across a gazillion principalities, leap seconds changing the lengths of days, and so on). > Have a look at the TZ package at ftp://elsie.nci.nih.gov/pub/ > for some fun with DST. They update those files many times a > year. Actually, we figured we'd leave the 12MB-of-compressed-DST-tables market to eGenix . From mal@lemburg.com Tue Mar 5 10:42:16 2002 From: mal@lemburg.com (M.-A. Lemburg) Date: Tue, 05 Mar 2002 11:42:16 +0100 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.50,1.51 References: Message-ID: <3C84A108.497B534D@lemburg.com> Tim Peters wrote: > > >> _localtzoffset(): If the given date is out of platform > >> mktime()'s range, feed mktime() the same values except for a year > >> that is in its range, and with the same leap-year-ness as the given > >> year. In effect, this imposes a "proleptic" DST determination for > >> years outside the platform range. > > [M.-A. Lemburg] > > This fails badly. > > Oh, fiddlesticks. By construction, the platform C library knows nothing > whatsoever about DST in such cases. We're not trying to do substantially > better than it can, we're just trying to return an explainable result that's > better than random. ECMAScript goes on to substitute a year that also > begins with the same weekday, and I'm happy to do that too, but not more > than that. > > The implementation of ECMAScript should not try to determine > whether the exact time was subject to daylight saving time, but just > whether daylight saving time would have been in effect if the current > daylight saving time algorithm had been used at the time. My point was to not fiddle with the date at all: raise an exception and that's it. > > DST rules change every year and historic DST switch times as well as > > future ones are not necessarily reliable. > > Of course. Ignoring reality in favor of something uniform is what > "proleptic" means in this context, in the same way that the "proleptic > Gregorian" calendar ignores messy date realities (about real-life > discontinuous year numbering, varying dates of adoption across a gazillion > principalities, leap seconds changing the lengths of days, and so on). > > > Have a look at the TZ package at ftp://elsie.nci.nih.gov/pub/ > > for some fun with DST. They update those files many times a > > year. > > Actually, we figured we'd leave the 12MB-of-compressed-DST-tables market to > eGenix . Gee, thanks :-) I'll rather leave that market to the C lib vendors. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/ From mwh@users.sourceforge.net Tue Mar 5 13:28:00 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 05 Mar 2002 05:28:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects structseq.c,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv27068/Objects Modified Files: structseq.c Log Message: A fix & test for [ 496873 ] structseqs unpicklable by adding a __reduce__ method to structseqs. Will also commit this to the 2.2.1 branch momentarily. Index: structseq.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/structseq.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** structseq.c 28 Nov 2001 20:56:44 -0000 1.3 --- structseq.c 5 Mar 2002 13:27:57 -0000 1.4 *************** *** 189,192 **** --- 189,213 ---- } + static PyObject * + structseq_reduce(PyStructSequence* self) + { + PyObject* tup; + long n_fields; + int i; + + n_fields = REAL_SIZE(self); + tup = PyTuple_New(n_fields); + if (!tup) { + return NULL; + } + + for (i = 0; i < n_fields; i++) { + Py_INCREF(self->ob_item[i]); + PyTuple_SET_ITEM(tup, i, self->ob_item[i]); + } + + return Py_BuildValue("(O(O))", self->ob_type, tup); + } + static PySequenceMethods structseq_as_sequence = { (inquiry)structseq_length, *************** *** 200,203 **** --- 221,230 ---- }; + static PyMethodDef structseq_methods[] = { + {"__reduce__", (PyCFunction)structseq_reduce, + METH_NOARGS, NULL}, + {NULL, NULL} + }; + static PyTypeObject _struct_sequence_template = { PyObject_HEAD_INIT(&PyType_Type) *************** *** 229,233 **** 0, /* tp_iter */ 0, /* tp_iternext */ ! 0, /* tp_methods */ NULL, /* tp_members */ 0, /* tp_getset */ --- 256,260 ---- 0, /* tp_iter */ 0, /* tp_iternext */ ! structseq_methods, /* tp_methods */ NULL, /* tp_members */ 0, /* tp_getset */ *************** *** 283,285 **** --- 310,314 ---- PyDict_SetItemString(dict, real_length_key, PyInt_FromLong((long) n_members)); + PyDict_SetItemString(dict, "__safe_for_unpickling__", + PyInt_FromLong(1)); } From mwh@users.sourceforge.net Tue Mar 5 13:28:00 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 05 Mar 2002 05:28:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test pickletester.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv27068/Lib/test Modified Files: pickletester.py Log Message: A fix & test for [ 496873 ] structseqs unpicklable by adding a __reduce__ method to structseqs. Will also commit this to the 2.2.1 branch momentarily. Index: pickletester.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/pickletester.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** pickletester.py 19 Dec 2001 16:58:54 -0000 1.12 --- pickletester.py 5 Mar 2002 13:27:58 -0000 1.13 *************** *** 249,252 **** --- 249,259 ---- self.assertEqual(a.__class__, b.__class__) + def test_structseq(self): + import time + t = time.localtime() + s = self.dumps(t) + u = self.loads(s) + self.assertEqual(t, u) + class AbstractPickleModuleTests(unittest.TestCase): From mwh@users.sourceforge.net Tue Mar 5 13:52:31 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 05 Mar 2002 05:52:31 -0800 Subject: [Python-checkins] CVS: python/dist/src Makefile.pre.in,1.73.4.1,1.73.4.2 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv16469 Modified Files: Tag: release22-maint Makefile.pre.in Log Message: backport gvanrossum's checkin of revision 1.76 of Makefile.pre.in SF patch #524005 by Paul Eggert. Use posixly correct sort args. Bugfix candidate. Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.73.4.1 retrieving revision 1.73.4.2 diff -C2 -d -r1.73.4.1 -r1.73.4.2 *** Makefile.pre.in 28 Jan 2002 15:07:45 -0000 1.73.4.1 --- Makefile.pre.in 5 Mar 2002 13:52:29 -0000 1.73.4.2 *************** *** 828,832 **** for i in $(SRCDIRS); do ctags -w -t -a $$i/*.[ch]; \ done; \ ! sort tags -o tags # Create a tags file for GNU Emacs --- 828,832 ---- for i in $(SRCDIRS); do ctags -w -t -a $$i/*.[ch]; \ done; \ ! sort -o tags tags # Create a tags file for GNU Emacs From mwh@users.sourceforge.net Tue Mar 5 13:56:26 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 05 Mar 2002 05:56:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python thread_nt.h,2.20,2.20.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv19738 Modified Files: Tag: release22-maint thread_nt.h Log Message: backport tim_one's checkin of revision 2.22 of thread_nt.h SF patch 522961: Leak in Python/thread_nt.h, from Gerald S. Williams. A file-static "threads" dict mapped thread IDs to Windows handles, but was never referenced, and entries never got removed. This gets rid of the YAGNI-dict entirely. Bugfix candidate. Index: thread_nt.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_nt.h,v retrieving revision 2.20 retrieving revision 2.20.10.1 diff -C2 -d -r2.20 -r2.20.10.1 *** thread_nt.h 16 Oct 2001 21:50:04 -0000 2.20 --- thread_nt.h 5 Mar 2002 13:56:23 -0000 2.20.10.1 *************** *** 2,10 **** /* This code implemented by Dag.Gruneau@elsa.preseco.comm.se */ /* Fast NonRecursiveMutex support by Yakov Markovitch, markovitch@iso.ru */ #include #include #include - #include typedef struct NRMUTEX { --- 2,10 ---- /* This code implemented by Dag.Gruneau@elsa.preseco.comm.se */ /* Fast NonRecursiveMutex support by Yakov Markovitch, markovitch@iso.ru */ + /* Eliminated some memory leaks, gsw@agere.com */ #include #include #include typedef struct NRMUTEX { *************** *** 14,20 **** } NRMUTEX, *PNRMUTEX ; - /* dictionary to correlate thread ids with the handle needed to terminate them*/ - static PyObject *threads = NULL; - typedef PVOID WINAPI interlocked_cmp_xchg_t(PVOID *dest, PVOID exc, PVOID comperand) ; --- 14,17 ---- *************** *** 140,153 **** /* - * Change all headers to pure ANSI as no one will use K&R style on an - * NT - */ - - /* * Initialization of the C package, should not be needed. */ static void PyThread__init_thread(void) { - threads = PyDict_New(); } --- 137,144 ---- *************** *** 183,187 **** callobj *obj; int id; - PyObject *key, *val; dprintf(("%ld: PyThread_start_new_thread called\n", PyThread_get_thread_ident())); --- 174,177 ---- *************** *** 204,210 **** WaitForSingleObject(obj->done, 5000); /* maybe INFINITE instead of 5000? */ CloseHandle((HANDLE)obj->done); - key = PyLong_FromLong(obj->id); - val = PyLong_FromLong((long)rv); - PyDict_SetItem(threads, key, val); id = obj->id; free(obj); --- 194,197 ---- From mwh@users.sourceforge.net Tue Mar 5 13:58:16 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 05 Mar 2002 05:58:16 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc ACKS,1.149.4.2,1.149.4.3 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv21380 Modified Files: Tag: release22-maint ACKS Log Message: backport gvanrossum's checkin of revision 1.161 of ACKS SF patch 518765 (Derek Harland): Bug in copy.py when used through rexec. When using a restricted environment, imports of copy will fail with an AttributeError when trying to access types.CodeType. Bugfix candidate (all the way back to 1.5.3, but at least 2.1.3 and 2.2.1). Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.149.4.2 retrieving revision 1.149.4.3 diff -C2 -d -r1.149.4.2 -r1.149.4.3 *** ACKS 28 Feb 2002 10:13:04 -0000 1.149.4.2 --- ACKS 5 Mar 2002 13:58:13 -0000 1.149.4.3 *************** *** 175,178 **** --- 175,179 ---- Barry Hantman Lynda Hardman + Derek Harland Jason Harper Gerhard Häring From mwh@users.sourceforge.net Tue Mar 5 13:58:45 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 05 Mar 2002 05:58:45 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib copy.py,1.22.10.1,1.22.10.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv21762 Modified Files: Tag: release22-maint copy.py Log Message: backport gvanrossum's checkin of revision 1.24 of copy.py SF patch 518765 (Derek Harland): Bug in copy.py when used through rexec. When using a restricted environment, imports of copy will fail with an AttributeError when trying to access types.CodeType. Bugfix candidate (all the way back to 1.5.3, but at least 2.1.3 and 2.2.1). Index: copy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/copy.py,v retrieving revision 1.22.10.1 retrieving revision 1.22.10.2 diff -C2 -d -r1.22.10.1 -r1.22.10.2 *** copy.py 4 Jan 2002 12:28:43 -0000 1.22.10.1 --- copy.py 5 Mar 2002 13:58:42 -0000 1.22.10.2 *************** *** 198,202 **** except AttributeError: pass ! d[types.CodeType] = _deepcopy_atomic d[types.TypeType] = _deepcopy_atomic d[types.XRangeType] = _deepcopy_atomic --- 198,205 ---- except AttributeError: pass ! try: ! d[types.CodeType] = _deepcopy_atomic ! except AttributeError: ! pass d[types.TypeType] = _deepcopy_atomic d[types.XRangeType] = _deepcopy_atomic From mwh@users.sourceforge.net Tue Mar 5 14:01:31 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 05 Mar 2002 06:01:31 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test pickletester.py,1.12,1.12.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv24336 Modified Files: Tag: release22-maint pickletester.py Log Message: backport my checkin of revision 1.13 of pickletester.py A fix & test for [ 496873 ] structseqs unpicklable by adding a __reduce__ method to structseqs. Will also commit this to the 2.2.1 branch momentarily. Index: pickletester.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/pickletester.py,v retrieving revision 1.12 retrieving revision 1.12.4.1 diff -C2 -d -r1.12 -r1.12.4.1 *** pickletester.py 19 Dec 2001 16:58:54 -0000 1.12 --- pickletester.py 5 Mar 2002 14:01:28 -0000 1.12.4.1 *************** *** 249,252 **** --- 249,259 ---- self.assertEqual(a.__class__, b.__class__) + def test_structseq(self): + import time + t = time.localtime() + s = self.dumps(t) + u = self.loads(s) + self.assertEqual(t, u) + class AbstractPickleModuleTests(unittest.TestCase): From mwh@users.sourceforge.net Tue Mar 5 14:00:56 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 05 Mar 2002 06:00:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects structseq.c,1.3,1.3.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv23684 Modified Files: Tag: release22-maint structseq.c Log Message: backport my checkin of revision 1.4 of structseq.c A fix & test for [ 496873 ] structseqs unpicklable by adding a __reduce__ method to structseqs. Will also commit this to the 2.2.1 branch momentarily. Index: structseq.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/structseq.c,v retrieving revision 1.3 retrieving revision 1.3.6.1 diff -C2 -d -r1.3 -r1.3.6.1 *** structseq.c 28 Nov 2001 20:56:44 -0000 1.3 --- structseq.c 5 Mar 2002 14:00:52 -0000 1.3.6.1 *************** *** 189,192 **** --- 189,213 ---- } + static PyObject * + structseq_reduce(PyStructSequence* self) + { + PyObject* tup; + long n_fields; + int i; + + n_fields = REAL_SIZE(self); + tup = PyTuple_New(n_fields); + if (!tup) { + return NULL; + } + + for (i = 0; i < n_fields; i++) { + Py_INCREF(self->ob_item[i]); + PyTuple_SET_ITEM(tup, i, self->ob_item[i]); + } + + return Py_BuildValue("(O(O))", self->ob_type, tup); + } + static PySequenceMethods structseq_as_sequence = { (inquiry)structseq_length, *************** *** 200,203 **** --- 221,230 ---- }; + static PyMethodDef structseq_methods[] = { + {"__reduce__", (PyCFunction)structseq_reduce, + METH_NOARGS, NULL}, + {NULL, NULL} + }; + static PyTypeObject _struct_sequence_template = { PyObject_HEAD_INIT(&PyType_Type) *************** *** 229,233 **** 0, /* tp_iter */ 0, /* tp_iternext */ ! 0, /* tp_methods */ NULL, /* tp_members */ 0, /* tp_getset */ --- 256,260 ---- 0, /* tp_iter */ 0, /* tp_iternext */ ! structseq_methods, /* tp_methods */ NULL, /* tp_members */ 0, /* tp_getset */ *************** *** 283,285 **** --- 310,314 ---- PyDict_SetItemString(dict, real_length_key, PyInt_FromLong((long) n_members)); + PyDict_SetItemString(dict, "__safe_for_unpickling__", + PyInt_FromLong(1)); } From mwh@users.sourceforge.net Tue Mar 5 14:00:19 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 05 Mar 2002 06:00:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib mailbox.py,1.33,1.33.12.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv22981 Modified Files: Tag: release22-maint mailbox.py Log Message: backport bwarsaw's checkin of revision 1.34 of mailbox.py Added PortableUnixMailbox to the __all__ variable, and in the __main__ section use this class instead of UnixMailbox as per the comments in the latter's class. Bug fix candidate for 2.2.1. Index: mailbox.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mailbox.py,v retrieving revision 1.33 retrieving revision 1.33.12.1 diff -C2 -d -r1.33 -r1.33.12.1 *** mailbox.py 13 Sep 2001 01:29:13 -0000 1.33 --- mailbox.py 5 Mar 2002 14:00:16 -0000 1.33.12.1 *************** *** 7,11 **** import os ! __all__ = ["UnixMailbox","MmdfMailbox","MHMailbox","Maildir","BabylMailbox"] class _Mailbox: --- 7,12 ---- import os ! __all__ = ["UnixMailbox","MmdfMailbox","MHMailbox","Maildir","BabylMailbox", ! "PortableUnixMailbox"] class _Mailbox: *************** *** 92,95 **** --- 93,97 ---- + # Recommended to use PortableUnixMailbox instead! class UnixMailbox(_Mailbox): def _search_start(self): *************** *** 283,287 **** else: fp = open(mbox, 'r') ! mb = UnixMailbox(fp) msgs = [] --- 285,289 ---- else: fp = open(mbox, 'r') ! mb = PortableUnixMailbox(fp) msgs = [] From gvanrossum@users.sourceforge.net Tue Mar 5 14:14:50 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Tue, 05 Mar 2002 06:14:50 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.51,1.52 test_datetime.py,1.36,1.37 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv32276 Modified Files: datetime.py test_datetime.py Log Message: A somewhat yucky but I think necessary change: introduce a separate date class. This implements all the date shuffling; the datetime class then subclasses this and adds more precision and tzoffset fiddling. It's yucky because there's a fair amount of code duplication, alas -- this can probably be reduced by thinking more about which interfaces are needed. It's also necessary because the more I think about it, the more we need a succession of types: - date -- for calendrical computations - xxxx -- for date+time computations without timezone awareness - yyyy -- local-timezone-and-DST-aware date+time computations - zzzz -- UTC date+time computations - datetime -- generalized timezone-and-DST-aware date+time computations I'll try to clean this up some more after my shower. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** datetime.py 5 Mar 2002 09:12:44 -0000 1.51 --- datetime.py 5 Mar 2002 14:14:48 -0000 1.52 *************** *** 1,3 **** ! """Concrete date/time type -- prototype implemented in Python. See http://www.zope.org/Members/fdrake/DateTimeWiki/FrontPage --- 1,3 ---- ! """Concrete date/time and related types -- prototype implemented in Python. See http://www.zope.org/Members/fdrake/DateTimeWiki/FrontPage *************** *** 506,511 **** ! class datetime(basetime): ! """Concrete date/time type. Constructors: --- 506,751 ---- ! class date(basetime): ! """Concrete date type. ! ! Constructors: ! ! __init__() ! today() ! fromordinal() ! ! Operators: ! ! __repr__, __str__ ! __cmp__, __hash__ ! __add__, __radd__, __sub__ (add/radd only with timedelta arg) ! ! Methods: ! ! timetuple(), utctimetuple() ! toordinal() ! weekday(), isoweekday(), isocalendar() ! isoformat() ! ! Properties (readonly): ! year, month, day ! """ ! ! def __init__(self, year, month, day): ! """Constructor. ! ! Arguments: ! ! year, month, day (required, base 1) ! """ ! if not MINYEAR <= year <= MAXYEAR: ! raise ValueError('year must be in %d..%d' % (MINYEAR, MAXYEAR), ! year) ! if not 1 <= month <= 12: ! raise ValueError('month must be in 1..12', month) ! dim = _days_in_month(month, year) ! if not 1 <= day <= dim: ! raise ValueError('day must be in 1..%d' % dim, day) ! self.__year = year ! self.__month = month ! self.__day = day ! ! # Additional constructors ! ! def fromtimestamp(cls, t): ! "Construct a date from a POSIX timestamp (like time.time())." ! y, m, d, hh, mm, ss, weekday, jday, dst = _time.localtime(t) ! us = int((t % 1.0) * 1000000) ! if dst > 0: ! tz = -(_time.altzone // 60) ! else: ! tz = -(_time.timezone // 60) ! return cls(y, m, d) ! fromtimestamp = classmethod(fromtimestamp) ! ! def today(cls): ! "Construct a date from time.time()." ! t = _time.time() ! return cls.fromtimestamp(t) ! today = classmethod(today) ! ! def fromordinal(cls, n): ! """Contruct a date from a proleptic Gregorian ordinal. ! ! January 1 of year 1 is day 1. Only the year, month and day are ! non-zero in the result. ! """ ! y, m, d = _ord2ymd(n) ! return cls(y, m, d) ! fromordinal = classmethod(fromordinal) ! ! # Conversions to string ! ! def __repr__(self): ! "Convert to formal string, for repr()." ! return "%s(%d, %d, %d)" % (self.__class__.__name__, ! self.__year, ! self.__month, ! self.__day) ! ! def __str__(self): ! "Convert to pretty string, for str()." ! return self.isoformat() ! ! # Read-only field accessors ! year = property(lambda self: self.__year, ! doc="year (%d-%d)" % (MINYEAR, MAXYEAR)) ! month = property(lambda self: self.__month, doc="month (1-12)") ! day = property(lambda self: self.__day, doc="day (1-31)") ! ! # Standard conversions, __cmp__, __hash__ (and helpers) ! ! # XXX These should be done without reference to the time module ! ! def _mktime(self): ! # Helper to return a POSIX-ish timestamp ! t = tmxxx(self.__year, self.__month, self.__day) ! return t.time() ! ! def timetuple(self): ! "Return local time tuple compatible with time.localtime()." ! return _time.localtime(self._mktime()) ! ! def toordinal(self): ! """Return proleptic Gregorian ordinal for the year, month and day. ! ! January 1 of year 1 is day 1. Only the year, month and day values ! contribute to the result. ! """ ! return _ymd2ord(self.__year, self.__month, self.__day) ! ! def __cmp__(self, other): ! "Three-way comparison." ! if isinstance(other, date): ! y, m, d = self.__year, self.__month, self.__day ! y2, m2, d2 = other.__year, other.__month, other.__day ! return cmp((y, m, d), (y2, m2, d2)) ! else: ! raise TypeError, ("can't compare date to %s instance" % ! type(other).__name__) ! ! def __hash__(self): ! "Hash." ! # Caution: objects that compare equal must have equal hashcodes, ! # and two dates can be equal even if their fields aren't ! # (due to tzoffset). So we have to compute a UTC-normalized hash. ! return hash((self.__year, self.__month, self.__day)) ! ! # Formatting methods ! ! # XXX These shouldn't depend on time.localtime(), because that ! # clips the usable dates to [1970 .. 2038). At least ctime() is ! # easily done without using strftime() -- that's better too because ! # strftime("%c", ...) is locale specific. ! ! # XXX An additional question is whether ctime() should renormalize ! # to local time, or display the time as entered (which may be ! # confusing since it doesn't show the timezone). ! ! def ctime(self): ! "Format a la ctime() in local time." ! t = tmxxx(self.__year, self.__month, self.__day) ! return t.ctime() ! ! def strftime(self, fmt): ! "Format using strftime() in local time." ! return _time.strftime(fmt, _time.localtime(self._mktime())) ! ! # Computations ! ! def _checkOverflow(self, year): ! if not MINYEAR <= year <= MAXYEAR: ! raise OverflowError("date +/-: result year %d not in %d..%d" % ! (year, MINYEAR, MAXYEAR)) ! ! def __add__(self, other): ! "Add a date to a timedelta." ! if isinstance(other, timedelta): ! t = tmxxx(self.__year, ! self.__month, ! self.__day + other.days) ! self._checkOverflow(t.year) ! result = self.__class__(t.year, t.month, t.day) ! return result ! raise TypeError ! # XXX Should be 'return NotImplemented', but there's a bug in 2.2... ! ! __radd__ = __add__ ! ! timedelta_class = timedelta # Allows a subclass to override ! ! def __sub__(self, other): ! """Subtract two dates, or a date and a timedelta. ! ! An int/long/float argument is also allowed, interpreted as seconds. ! """ ! if isinstance(other, timedelta): ! return self + -other ! if isinstance(other, date): ! days1 = self.toordinal() ! days2 = other.toordinal() ! return self.timedelta_class(days1 - days2) ! return NotImplemented ! ! # Day-of-the-week and week-of-the-year, according to ISO ! ! def weekday(self): ! "Return day of the week, where Monday == 0 ... Sunday == 6." ! return (self.toordinal() + 6) % 7 ! ! def isoweekday(self): ! "Return day of the week, where Monday == 1 ... Sunday == 7." ! # 1-Jan-0001 is a Monday ! return self.toordinal() % 7 or 7 ! ! def isocalendar(self): ! """Return a 3-tuple containing ISO year, week number, and weekday. ! ! The first ISO week of the year is the (Mon-Sun) week ! containing the year's first Thursday; everything rest derives ! from that. ! ! The first week is 1; Monday is 1 ... Sunday is 7. ! ! ISO calendar algorithm taken from ! http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm ! """ ! year = self.__year ! week1monday = _isoweek1monday(year) ! today = _ymd2ord(self.__year, self.__month, self.__day) ! # Internally, week and day have origin 0 ! week, day = divmod(today - week1monday, 7) ! if week < 0: ! year -= 1 ! week1monday = _isoweek1monday(year) ! week, day = divmod(today - week1monday, 7) ! elif week >= 52: ! if today >= _isoweek1monday(year+1): ! year += 1 ! week = 0 ! return year, week+1, day+1 ! ! def isoformat(self): ! """Return the time formatted according to ISO. ! ! This is 'YYYY-MM-DD'. ! ! Optional argument sep specifies the separator between date and ! time, default 'T'. ! """ ! return "%04d-%02d-%02d" % (self.__year, self.__month, self.__day) ! ! date.min = date(1, 1, 1) ! date.max = date(9999, 12, 31) ! date.resolution = timedelta(days=1) ! ! ! class datetime(date): ! """Concrete date/time type, inheriting from date. Constructors: *************** *** 546,557 **** """ ! if not MINYEAR <= year <= MAXYEAR: ! raise ValueError('year must be in %d..%d' % (MINYEAR, MAXYEAR), ! year) ! if not 1 <= month <= 12: ! raise ValueError('month must be in 1..12', month) ! dim = _days_in_month(month, year) ! if not 1 <= day <= dim: ! raise ValueError('day must be in 1..%d' % dim, day) if not 0 <= hour <= 23: raise ValueError('hour must be in 0..23', hour) --- 786,790 ---- """ ! super(datetime, self).__init__(year, month, day) if not 0 <= hour <= 23: raise ValueError('hour must be in 0..23', hour) *************** *** 567,570 **** --- 800,804 ---- if not -1439 <= tzoffset <= 1439: raise ValueError('tzoffset must be in -1439..1439', tzoffset) + # XXX This duplicates __year, __month, __day for convenience :-( self.__year = year self.__month = month *************** *** 608,621 **** utcnow = classmethod(utcnow) - def fromordinal(cls, n): - """Contruct a datetime from a proleptic Gregorian ordinal. - - January 1 of year 1 is day 1. Only the year, month and day are - non-zero in the result. - """ - y, m, d = _ord2ymd(n) - return cls(y, m, d) - fromordinal = classmethod(fromordinal) - # Conversions to string --- 842,845 ---- *************** *** 627,631 **** del L[-1] s = ", ".join(map(str, L)) ! return "datetime(%s, tzoffset=%d)" % (s, self.__tzoffset) def __str__(self): --- 851,857 ---- del L[-1] s = ", ".join(map(str, L)) ! return "%s(%s, tzoffset=%d)" % (self.__class__.__name__, ! s, ! self.__tzoffset) def __str__(self): *************** *** 634,641 **** # Read-only field accessors - year = property(lambda self: self.__year, - doc="year (%d-%d)" % (MINYEAR, MAXYEAR)) - month = property(lambda self: self.__month, doc="month (1-12)") - day = property(lambda self: self.__day, doc="day (1-31)") hour = property(lambda self: self.__hour, doc="hour (0-23)") minute = property(lambda self: self.__minute, doc="minute (0-59)") --- 860,863 ---- *************** *** 657,676 **** return t.time() - def timetuple(self): - "Return local time tuple compatible with time.localtime()." - return _time.localtime(self._mktime()) - def utctimetuple(self): "Return UTC time tuple compatible with time.gmtime()." return _time.gmtime(self._mktime()) - def toordinal(self): - """Return proleptic Gregorian ordinal for the year, month and day. - - January 1 of year 1 is day 1. Only the year, month and day values - contribute to the result. - """ - return _ymd2ord(self.__year, self.__month, self.__day) - def __cmp__(self, other): "Three-way comparison." --- 879,886 ---- *************** *** 727,738 **** t = tmxxx(t.year, t.month, t.day, t.hour, t.minute - tzoffset + tzoffset1, self.__second) ! tzoffset2 = _localtzoffset(t.year, t.month, t.day, t.hour, t.minute) assert tzoffset2 == tzoffset1 # XXX Hah! return t.ctime() - def strftime(self, fmt): - "Format using strftime() in local time." - return _time.strftime(fmt, _time.localtime(self._mktime())) - def utcctime(self): "Format a la ctime() in UTC." --- 937,945 ---- t = tmxxx(t.year, t.month, t.day, t.hour, t.minute - tzoffset + tzoffset1, self.__second) ! tzoffset2 = _localtzoffset(t.year, t.month, t.day, ! t.hour, t.minute) assert tzoffset2 == tzoffset1 # XXX Hah! return t.ctime() def utcctime(self): "Format a la ctime() in UTC." *************** *** 747,755 **** # Computations - def _checkOverflow(self, year): - if not MINYEAR <= year <= MAXYEAR: - raise OverflowError("datetime +/-: result year %d not in %d..%d" % - (year, MINYEAR, MAXYEAR)) - def __add__(self, other): "Add a datetime to a timedelta." --- 954,957 ---- *************** *** 772,777 **** __radd__ = __add__ - timedelta_class = timedelta # Allows a subclass to override - def __sub__(self, other): """Subtract two datetimes, or a datetime and a timedelta. --- 974,977 ---- *************** *** 796,836 **** return NotImplemented ! # Day-of-the-week and week-of-the-year, according to ISO ! ! def weekday(self): ! "Return day of the week, where Monday == 0 ... Sunday == 6." ! return (self.toordinal() + 6) % 7 ! ! def isoweekday(self): ! "Return day of the week, where Monday == 1 ... Sunday == 7." ! # 1-Jan-0001 is a Monday ! return self.toordinal() % 7 or 7 ! ! def isocalendar(self): ! """Return a 3-tuple containing ISO year, week number, and weekday. ! ! The first ISO week of the year is the (Mon-Sun) week ! containing the year's first Thursday; everything rest derives ! from that. ! ! The first week is 1; Monday is 1 ... Sunday is 7. ! ! ISO calendar algorithm taken from ! http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm ! """ ! year = self.__year ! week1monday = _isoweek1monday(year) ! today = _ymd2ord(self.__year, self.__month, self.__day) ! # Internally, week and day have origin 0 ! week, day = divmod(today - week1monday, 7) ! if week < 0: ! year -= 1 ! week1monday = _isoweek1monday(year) ! week, day = divmod(today - week1monday, 7) ! elif week >= 52: ! if today >= _isoweek1monday(year+1): ! year += 1 ! week = 0 ! return year, week+1, day+1 def isoformat(self, sep='T'): --- 996,1000 ---- return NotImplemented ! # ISO formats including time and tzoffset def isoformat(self, sep='T'): Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** test_datetime.py 5 Mar 2002 08:53:33 -0000 1.36 --- test_datetime.py 5 Mar 2002 14:14:48 -0000 1.37 *************** *** 7,28 **** import unittest ! from datetime import datetime, timedelta, MINYEAR, MAXYEAR ! class TestDateTime(unittest.TestCase): def test_basic_attributes(self): ! dt = datetime(2002, 3, 1, 12, 0, 0) self.assertEqual(dt.year, 2002) self.assertEqual(dt.month, 3) self.assertEqual(dt.day, 1) - self.assertEqual(dt.hour, 12) - self.assertEqual(dt.minute, 0) - self.assertEqual(dt.second, 0) - self.assertEqual(dt.microsecond, 0) def test_roundtrip(self): ! for dt in (datetime(1, 2, 3, 4, 5, 6, 7, 8), ! datetime.now()): ! # Verify dt -> string -> datetime identity. s = repr(dt) dt2 = eval(s) --- 7,91 ---- import unittest ! from datetime import date, datetime, timedelta, MINYEAR, MAXYEAR ! ! class TestTimeDelta(unittest.TestCase): ! ! def test_timedelta(self): ! a = timedelta(7) # One week ! b = timedelta(0, 60) # One minute ! c = timedelta(0, 0, 1000) # One millisecond ! self.assertEqual(a+b+c, timedelta(7, 60, 1000)) ! self.assertEqual(a-b, timedelta(6, 24*3600 - 60)) ! self.assertEqual(-a, timedelta(-7)) ! self.assertEqual(+a, timedelta(7)) ! self.assertEqual(-b, timedelta(-1, 24*3600 - 60)) ! self.assertEqual(-c, timedelta(-1, 24*3600 - 1, 999000)) ! self.assertEqual(abs(a), a) ! self.assertEqual(abs(-a), a) ! self.assertEqual(timedelta(6, 24*3600), a) ! self.assertEqual(timedelta(0, 0, 60*1000000), b) ! self.assertEqual(a*10, timedelta(70)) ! self.assertEqual(a*10, 10*a) ! self.assertEqual(a*10L, 10*a) ! self.assertEqual(b*10, timedelta(0, 600)) ! self.assertEqual(10*b, timedelta(0, 600)) ! self.assertEqual(b*10L, timedelta(0, 600)) ! self.assertEqual(c*10, timedelta(0, 0, 10000)) ! self.assertEqual(10*c, timedelta(0, 0, 10000)) ! self.assertEqual(c*10L, timedelta(0, 0, 10000)) ! self.assertEqual(a*-1, -a) ! self.assertEqual(b*-2, -b-b) ! self.assertEqual(c*-2, -c+-c) ! self.assertEqual(b*(60*24), (b*60)*24) ! self.assertEqual(b*(60*24), (60*b)*24) ! self.assertEqual(c*1000, timedelta(0, 1)) ! self.assertEqual(1000*c, timedelta(0, 1)) ! self.assertEqual(a//7, timedelta(1)) ! self.assertEqual(b//10, timedelta(0, 6)) ! self.assertEqual(c//1000, timedelta(0, 0, 1)) ! self.assertEqual(a//10, timedelta(0, 7*24*360)) ! self.assertEqual(a//3600000, timedelta(0, 0, 7*24*1000)) ! # Add/sub ints, longs, floats should be illegal ! for i in 1, 1L, 1.0: ! self.assertRaises(TypeError, lambda: a+i) ! self.assertRaises(TypeError, lambda: a-i) ! self.assertRaises(TypeError, lambda: i+a) ! self.assertRaises(TypeError, lambda: i-a) ! # Check keyword args to constructor ! eq = self.assertEqual ! td = timedelta ! eq(td(1), td(days=1)) ! eq(td(0, 1), td(seconds=1)) ! eq(td(0, 0, 1), td(microseconds=1)) ! eq(td(weeks=1), td(days=7)) ! eq(td(days=1), td(hours=24)) ! eq(td(hours=1), td(minutes=60)) ! eq(td(minutes=1), td(seconds=60)) ! eq(td(seconds=1), td(milliseconds=1000)) ! eq(td(milliseconds=1), td(microseconds=1000)) ! # Check float args to constructor ! eq(td(weeks=1.0/7), td(days=1)) ! eq(td(days=1.0/24), td(hours=1)) ! eq(td(hours=1.0/60), td(minutes=1)) ! eq(td(minutes=1.0/60), td(seconds=1)) ! eq(td(seconds=0.001), td(milliseconds=1)) ! eq(td(milliseconds=0.001), td(microseconds=1)) ! ! ! class TestDate(unittest.TestCase): ! ! theclass = date def test_basic_attributes(self): ! dt = self.theclass(2002, 3, 1) self.assertEqual(dt.year, 2002) self.assertEqual(dt.month, 3) self.assertEqual(dt.day, 1) def test_roundtrip(self): ! for dt in (self.theclass(1, 2, 3), ! self.theclass.today()): ! # Verify dt -> string -> date identity. s = repr(dt) dt2 = eval(s) *************** *** 30,64 **** # Verify identity via reconstructing from pieces. ! dt2 = datetime(dt.year, dt.month, dt.day, ! dt.hour, dt.minute, dt.second, ! dt.microsecond, dt.tzoffset) self.assertEqual(dt, dt2) - def test_tz_independent_comparing(self): - dt1 = datetime(2002, 3, 1, 9, 0, 0, tzoffset=-60) - dt2 = datetime(2002, 3, 1, 10, 0, 0, tzoffset=-60) - dt3 = datetime(2002, 3, 1, 10, 0, 0, tzoffset=0) - self.assertEqual(dt1, dt3) - self.assert_(dt2 > dt3) - - # Make sure comparison doesn't forget microseconds, and isn't done - # via comparing a float timestamp (an IEEE double doesn't have enough - # precision to span microsecond resolution across years 1 thru 9999, - # so comparing via timestamp necessarily calls some distinct values - # equal). - dt1 = datetime(MAXYEAR, 12, 31, 23, 59, 59, 999998, 0) - us = timedelta(microseconds=1) - dt2 = dt1 + us - self.assertEqual(dt2 - dt1, us) - self.assert_(dt1 < dt2) - - # Again, but mix timezones. - dt1 = datetime(MAXYEAR, 12, 31, 22, 59, 59, 999998, -60) - dt2 = datetime(MAXYEAR, 12, 31, 23, 59, 59, 999998, 0) - self.assertEqual(dt1, dt2) - dt2 += us - self.assertEqual(dt2 - dt1, us) - self.assert_(dt1 < dt2) - def test_ordinal_conversions(self): from datetime import _ymd2ord, _ord2ymd --- 93,99 ---- # Verify identity via reconstructing from pieces. ! dt2 = self.theclass(dt.year, dt.month, dt.day) self.assertEqual(dt, dt2) def test_ordinal_conversions(self): from datetime import _ymd2ord, _ord2ymd *************** *** 98,151 **** def test_bad_constructor_arguments(self): # bad years ! datetime(MINYEAR, 1, 1) # no exception ! datetime(MAXYEAR, 1, 1) # no exception ! self.assertRaises(ValueError, datetime, MINYEAR-1, 1, 1) ! self.assertRaises(ValueError, datetime, MAXYEAR+1, 1, 1) # bad months ! datetime(2000, 1, 1) # no exception ! datetime(2000, 12, 1) # no exception ! self.assertRaises(ValueError, datetime, 2000, 0, 1) ! self.assertRaises(ValueError, datetime, 2000, 13, 1) # bad days ! datetime(2000, 2, 29) # no exception ! datetime(2004, 2, 29) # no exception ! datetime(2400, 2, 29) # no exception ! self.assertRaises(ValueError, datetime, 2000, 2, 30) ! self.assertRaises(ValueError, datetime, 2001, 2, 29) ! self.assertRaises(ValueError, datetime, 2100, 2, 29) ! self.assertRaises(ValueError, datetime, 1900, 2, 29) ! self.assertRaises(ValueError, datetime, 2000, 1, 0) ! self.assertRaises(ValueError, datetime, 2000, 1, 32) ! # bad hours ! datetime(2000, 1, 31, 0) # no exception ! datetime(2000, 1, 31, 23) # no exception ! self.assertRaises(ValueError, datetime, 2000, 1, 31, -1) ! self.assertRaises(ValueError, datetime, 2000, 1, 31, 24) ! # bad minutes ! datetime(2000, 1, 31, 23, 0) # no exception ! datetime(2000, 1, 31, 23, 59) # no exception ! self.assertRaises(ValueError, datetime, 2000, 1, 31, 23, -1) ! self.assertRaises(ValueError, datetime, 2000, 1, 31, 23, 60) ! # bad seconds ! datetime(2000, 1, 31, 23, 59, 0) # no exception ! datetime(2000, 1, 31, 23, 59, 59) # no exception ! self.assertRaises(ValueError, datetime, 2000, 1, 31, 23, 59, -1) ! self.assertRaises(ValueError, datetime, 2000, 1, 31, 23, 59, 60) ! # bad microseconds ! datetime(2000, 1, 31, 23, 59, 59, 0) # no exception ! datetime(2000, 1, 31, 23, 59, 59, 999999) # no exception ! self.assertRaises(ValueError, datetime, 2000, 1, 31, 23, 59, 59, -1) ! self.assertRaises(ValueError, datetime, 2000, 1, 31, 23, 59, 59, ! 1000000) ! # bad tzoffet ! datetime(2, 1, 1, 0, 0, 0, 0, -1439) # no exception ! datetime(2, 1, 1, 0, 0, 0, 0, 1439) # no exception ! self.assertRaises(ValueError, datetime, 2, 1, 1, 0, 0, 0, 0, -1440) ! self.assertRaises(ValueError, datetime, 2, 1, 1, 0, 0, 0, 0, 1440) def test_hash_equality(self): ! d = datetime(2000, 12, 31, 23, 30, 17, tzoffset=-35) ! # same thing in UTC. ! e = datetime(2001, 1, 1, 0, 5, 17, tzoffset=0) self.assertEqual(d, e) self.assertEqual(hash(d), hash(e)) --- 133,160 ---- def test_bad_constructor_arguments(self): # bad years ! self.theclass(MINYEAR, 1, 1) # no exception ! self.theclass(MAXYEAR, 1, 1) # no exception ! self.assertRaises(ValueError, self.theclass, MINYEAR-1, 1, 1) ! self.assertRaises(ValueError, self.theclass, MAXYEAR+1, 1, 1) # bad months ! self.theclass(2000, 1, 1) # no exception ! self.theclass(2000, 12, 1) # no exception ! self.assertRaises(ValueError, self.theclass, 2000, 0, 1) ! self.assertRaises(ValueError, self.theclass, 2000, 13, 1) # bad days ! self.theclass(2000, 2, 29) # no exception ! self.theclass(2004, 2, 29) # no exception ! self.theclass(2400, 2, 29) # no exception ! self.assertRaises(ValueError, self.theclass, 2000, 2, 30) ! self.assertRaises(ValueError, self.theclass, 2001, 2, 29) ! self.assertRaises(ValueError, self.theclass, 2100, 2, 29) ! self.assertRaises(ValueError, self.theclass, 1900, 2, 29) ! self.assertRaises(ValueError, self.theclass, 2000, 1, 0) ! self.assertRaises(ValueError, self.theclass, 2000, 1, 32) def test_hash_equality(self): ! d = self.theclass(2000, 12, 31) ! # same thing ! e = self.theclass(2000, 12, 31) self.assertEqual(d, e) self.assertEqual(hash(d), hash(e)) *************** *** 157,163 **** self.assertEqual(dic[e], 2) ! d = datetime(2001, 1, 1, 0, 5, 17, tzoffset=35) ! # same thing in UTC. ! e = datetime(2000, 12, 31, 23, 30, 17, tzoffset=0) self.assertEqual(d, e) self.assertEqual(hash(d), hash(e)) --- 166,172 ---- self.assertEqual(dic[e], 2) ! d = self.theclass(2001, 1, 1) ! # same thing ! e = self.theclass(2001, 1, 1) self.assertEqual(d, e) self.assertEqual(hash(d), hash(e)) *************** *** 169,280 **** self.assertEqual(dic[e], 2) - def test_timedelta(self): - a = timedelta(7) # One week - b = timedelta(0, 60) # One minute - c = timedelta(0, 0, 1000) # One millisecond - self.assertEqual(a+b+c, timedelta(7, 60, 1000)) - self.assertEqual(a-b, timedelta(6, 24*3600 - 60)) - self.assertEqual(-a, timedelta(-7)) - self.assertEqual(+a, timedelta(7)) - self.assertEqual(-b, timedelta(-1, 24*3600 - 60)) - self.assertEqual(-c, timedelta(-1, 24*3600 - 1, 999000)) - self.assertEqual(abs(a), a) - self.assertEqual(abs(-a), a) - self.assertEqual(timedelta(6, 24*3600), a) - self.assertEqual(timedelta(0, 0, 60*1000000), b) - self.assertEqual(a*10, timedelta(70)) - self.assertEqual(a*10, 10*a) - self.assertEqual(a*10L, 10*a) - self.assertEqual(b*10, timedelta(0, 600)) - self.assertEqual(10*b, timedelta(0, 600)) - self.assertEqual(b*10L, timedelta(0, 600)) - self.assertEqual(c*10, timedelta(0, 0, 10000)) - self.assertEqual(10*c, timedelta(0, 0, 10000)) - self.assertEqual(c*10L, timedelta(0, 0, 10000)) - self.assertEqual(a*-1, -a) - self.assertEqual(b*-2, -b-b) - self.assertEqual(c*-2, -c+-c) - self.assertEqual(b*(60*24), (b*60)*24) - self.assertEqual(b*(60*24), (60*b)*24) - self.assertEqual(c*1000, timedelta(0, 1)) - self.assertEqual(1000*c, timedelta(0, 1)) - self.assertEqual(a//7, timedelta(1)) - self.assertEqual(b//10, timedelta(0, 6)) - self.assertEqual(c//1000, timedelta(0, 0, 1)) - self.assertEqual(a//10, timedelta(0, 7*24*360)) - self.assertEqual(a//3600000, timedelta(0, 0, 7*24*1000)) - # Add/sub ints, longs, floats should be illegal - for i in 1, 1L, 1.0: - self.assertRaises(TypeError, lambda: a+i) - self.assertRaises(TypeError, lambda: a-i) - self.assertRaises(TypeError, lambda: i+a) - self.assertRaises(TypeError, lambda: i-a) - # Check keyword args to constructor - eq = self.assertEqual - td = timedelta - eq(td(1), td(days=1)) - eq(td(0, 1), td(seconds=1)) - eq(td(0, 0, 1), td(microseconds=1)) - eq(td(weeks=1), td(days=7)) - eq(td(days=1), td(hours=24)) - eq(td(hours=1), td(minutes=60)) - eq(td(minutes=1), td(seconds=60)) - eq(td(seconds=1), td(milliseconds=1000)) - eq(td(milliseconds=1), td(microseconds=1000)) - # Check float args to constructor - eq(td(weeks=1.0/7), td(days=1)) - eq(td(days=1.0/24), td(hours=1)) - eq(td(hours=1.0/60), td(minutes=1)) - eq(td(minutes=1.0/60), td(seconds=1)) - eq(td(seconds=0.001), td(milliseconds=1)) - eq(td(milliseconds=0.001), td(microseconds=1)) - def test_computations(self): ! a = datetime(2002, 1, 31) ! b = datetime(1956, 1, 31) diff = a-b self.assertEqual(diff.days, 46*365 + len(range(1956, 2002, 4))) self.assertEqual(diff.seconds, 0) self.assertEqual(diff.microseconds, 0) - a = datetime(2002, 3, 2, 17, 6) - millisec = timedelta(0, 0, 1000) - hour = timedelta(0, 3600) day = timedelta(1) week = timedelta(7) ! self.assertEqual(a + hour, datetime(2002, 3, 2, 18, 6)) ! self.assertEqual(a + 10*hour, datetime(2002, 3, 3, 3, 6)) ! self.assertEqual(a - hour, datetime(2002, 3, 2, 16, 6)) ! self.assertEqual(a - hour, a + -hour) ! self.assertEqual(a - 20*hour, datetime(2002, 3, 1, 21, 6)) ! self.assertEqual(a + day, datetime(2002, 3, 3, 17, 6)) ! self.assertEqual(a - day, datetime(2002, 3, 1, 17, 6)) ! self.assertEqual(a + week, datetime(2002, 3, 9, 17, 6)) ! self.assertEqual(a - week, datetime(2002, 2, 23, 17, 6)) ! self.assertEqual(a + 52*week, datetime(2003, 3, 1, 17, 6)) ! self.assertEqual(a - 52*week, datetime(2001, 3, 3, 17, 6)) self.assertEqual((a + week) - a, week) self.assertEqual((a + day) - a, day) - self.assertEqual((a + hour) - a, hour) - self.assertEqual((a + millisec) - a, millisec) self.assertEqual((a - week) - a, -week) self.assertEqual((a - day) - a, -day) - self.assertEqual((a - hour) - a, -hour) - self.assertEqual((a - millisec) - a, -millisec) self.assertEqual(a - (a + week), -week) self.assertEqual(a - (a + day), -day) - self.assertEqual(a - (a + hour), -hour) - self.assertEqual(a - (a + millisec), -millisec) self.assertEqual(a - (a - week), week) self.assertEqual(a - (a - day), day) - self.assertEqual(a - (a - hour), hour) - self.assertEqual(a - (a - millisec), millisec) - self.assertEqual(a + (week + day + hour + millisec), - datetime(2002, 3, 10, 18, 6, 0, 1000)) - self.assertEqual(a + (week + day + hour + millisec), - (((a + week) + day) + hour) + millisec) - self.assertEqual(a - (week + day + hour + millisec), - datetime(2002, 2, 22, 16, 5, 59, 999000)) - self.assertEqual(a - (week + day + hour + millisec), - (((a - week) - day) - hour) - millisec) # Add/sub ints, longs, floats should be illegal for i in 1, 1L, 1.0: --- 178,205 ---- self.assertEqual(dic[e], 2) def test_computations(self): ! a = self.theclass(2002, 1, 31) ! b = self.theclass(1956, 1, 31) diff = a-b self.assertEqual(diff.days, 46*365 + len(range(1956, 2002, 4))) self.assertEqual(diff.seconds, 0) self.assertEqual(diff.microseconds, 0) day = timedelta(1) week = timedelta(7) ! a = self.theclass(2002, 3, 2) ! self.assertEqual(a + day, self.theclass(2002, 3, 3)) ! self.assertEqual(a - day, self.theclass(2002, 3, 1)) ! self.assertEqual(a + week, self.theclass(2002, 3, 9)) ! self.assertEqual(a - week, self.theclass(2002, 2, 23)) ! self.assertEqual(a + 52*week, self.theclass(2003, 3, 1)) ! self.assertEqual(a - 52*week, self.theclass(2001, 3, 3)) self.assertEqual((a + week) - a, week) self.assertEqual((a + day) - a, day) self.assertEqual((a - week) - a, -week) self.assertEqual((a - day) - a, -day) self.assertEqual(a - (a + week), -week) self.assertEqual(a - (a + day), -day) self.assertEqual(a - (a - week), week) self.assertEqual(a - (a - day), day) # Add/sub ints, longs, floats should be illegal for i in 1, 1L, 1.0: *************** *** 285,296 **** def test_overflow(self): ! tiny = datetime.resolution ! dt = datetime.min + tiny dt -= tiny # no problem self.assertRaises(OverflowError, dt.__sub__, tiny) self.assertRaises(OverflowError, dt.__add__, -tiny) ! dt = datetime.max - tiny dt += tiny # no problem self.assertRaises(OverflowError, dt.__add__, tiny) --- 210,221 ---- def test_overflow(self): ! tiny = self.theclass.resolution ! dt = self.theclass.min + tiny dt -= tiny # no problem self.assertRaises(OverflowError, dt.__sub__, tiny) self.assertRaises(OverflowError, dt.__add__, -tiny) ! dt = self.theclass.max - tiny dt += tiny # no problem self.assertRaises(OverflowError, dt.__add__, tiny) *************** *** 300,308 **** for i in range(7): # March 4, 2002 is a Monday ! self.assertEqual(datetime(2002, 3, 4+i).weekday(), i) ! self.assertEqual(datetime(2002, 3, 4+i).isoweekday(), i+1) # January 2, 1956 is a Monday ! self.assertEqual(datetime(1956, 1, 2+i).weekday(), i) ! self.assertEqual(datetime(1956, 1, 2+i).isoweekday(), i+1) def test_isocalendar(self): --- 225,233 ---- for i in range(7): # March 4, 2002 is a Monday ! self.assertEqual(self.theclass(2002, 3, 4+i).weekday(), i) ! self.assertEqual(self.theclass(2002, 3, 4+i).isoweekday(), i+1) # January 2, 1956 is a Monday ! self.assertEqual(self.theclass(1956, 1, 2+i).weekday(), i) ! self.assertEqual(self.theclass(1956, 1, 2+i).isoweekday(), i+1) def test_isocalendar(self): *************** *** 310,324 **** # http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm for i in range(7): ! d = datetime(2003, 12, 22+i) self.assertEqual(d.isocalendar(), (2003, 52, i+1)) ! d = datetime(2003, 12, 29) + timedelta(i) self.assertEqual(d.isocalendar(), (2004, 1, i+1)) ! d = datetime(2004, 1, 5+i) self.assertEqual(d.isocalendar(), (2004, 2, i+1)) ! d = datetime(2009, 12, 21+i) self.assertEqual(d.isocalendar(), (2009, 52, i+1)) ! d = datetime(2009, 12, 28) + timedelta(i) self.assertEqual(d.isocalendar(), (2009, 53, i+1)) ! d = datetime(2010, 1, 4+i) self.assertEqual(d.isocalendar(), (2010, 1, i+1)) --- 235,249 ---- # http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm for i in range(7): ! d = self.theclass(2003, 12, 22+i) self.assertEqual(d.isocalendar(), (2003, 52, i+1)) ! d = self.theclass(2003, 12, 29) + timedelta(i) self.assertEqual(d.isocalendar(), (2004, 1, i+1)) ! d = self.theclass(2004, 1, 5+i) self.assertEqual(d.isocalendar(), (2004, 2, i+1)) ! d = self.theclass(2009, 12, 21+i) self.assertEqual(d.isocalendar(), (2009, 52, i+1)) ! d = self.theclass(2009, 12, 28) + timedelta(i) self.assertEqual(d.isocalendar(), (2009, 53, i+1)) ! d = self.theclass(2010, 1, 4+i) self.assertEqual(d.isocalendar(), (2010, 1, i+1)) *************** *** 355,360 **** L = [] for i in range(400): ! d = datetime(2000+i, 12, 31) ! d1 = datetime(1600+i, 12, 31) self.assertEqual(d.isocalendar()[1:], d1.isocalendar()[1:]) if d.isocalendar()[1] == 53: --- 280,285 ---- L = [] for i in range(400): ! d = self.theclass(2000+i, 12, 31) ! d1 = self.theclass(1600+i, 12, 31) self.assertEqual(d.isocalendar()[1:], d1.isocalendar()[1:]) if d.isocalendar()[1] == 53: *************** *** 363,367 **** def test_isoformat(self): ! t = datetime(2, 3, 2, 4, 5, 1, 123, tzoffset=-120) self.assertEqual(t.isoformat(), "0002-03-02T04:05:01.000123-02:00") self.assertEqual(t.isoformat(' '), "0002-03-02 04:05:01.000123-02:00") --- 288,502 ---- def test_isoformat(self): ! t = self.theclass(2, 3, 2) ! self.assertEqual(t.isoformat(), "0002-03-02") ! ! def test_ctime(self): ! t = self.theclass(2002, 3, 2) ! self.assertEqual(t.ctime(), "Sat Mar 2 00:00:00 2002") ! ! def test_resolution_info(self): ! self.assert_(isinstance(self.theclass.min, self.theclass)) ! self.assert_(isinstance(self.theclass.max, self.theclass)) ! self.assert_(isinstance(self.theclass.resolution, timedelta)) ! self.assert_(self.theclass.max > self.theclass.min) ! ! def test_extreme_timedelta(self): ! big = self.theclass.max - self.theclass.min ! # 3652058 days, 23 hours, 59 minutes, 59 seconds, 999999 microseconds ! n = (big.days*24*3600 + big.seconds)*1000000 + big.microseconds ! # n = 315537897599999999 ~= 2**58.13 ! justasbig = timedelta(0, 0, n) ! self.assertEqual(big, justasbig) ! self.assertEqual(self.theclass.min + big, self.theclass.max) ! self.assertEqual(self.theclass.max - big, self.theclass.min) ! ! ! class TestDateTime(TestDate): ! ! theclass = datetime ! ! def test_basic_attributes(self): ! dt = self.theclass(2002, 3, 1, 12, 0, 0) ! self.assertEqual(dt.year, 2002) ! self.assertEqual(dt.month, 3) ! self.assertEqual(dt.day, 1) ! self.assertEqual(dt.hour, 12) ! self.assertEqual(dt.minute, 0) ! self.assertEqual(dt.second, 0) ! self.assertEqual(dt.microsecond, 0) ! ! def test_roundtrip(self): ! for dt in (self.theclass(1, 2, 3, 4, 5, 6, 7, 8), ! self.theclass.now()): ! # Verify dt -> string -> datetime identity. ! s = repr(dt) ! dt2 = eval(s) ! self.assertEqual(dt, dt2) ! ! # Verify identity via reconstructing from pieces. ! dt2 = self.theclass(dt.year, dt.month, dt.day, ! dt.hour, dt.minute, dt.second, ! dt.microsecond, dt.tzoffset) ! self.assertEqual(dt, dt2) ! ! def test_tz_independent_comparing(self): ! dt1 = self.theclass(2002, 3, 1, 9, 0, 0, tzoffset=-60) ! dt2 = self.theclass(2002, 3, 1, 10, 0, 0, tzoffset=-60) ! dt3 = self.theclass(2002, 3, 1, 10, 0, 0, tzoffset=0) ! self.assertEqual(dt1, dt3) ! self.assert_(dt2 > dt3) ! ! # Make sure comparison doesn't forget microseconds, and isn't done ! # via comparing a float timestamp (an IEEE double doesn't have enough ! # precision to span microsecond resolution across years 1 thru 9999, ! # so comparing via timestamp necessarily calls some distinct values ! # equal). ! dt1 = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999998, 0) ! us = timedelta(microseconds=1) ! dt2 = dt1 + us ! self.assertEqual(dt2 - dt1, us) ! self.assert_(dt1 < dt2) ! ! # Again, but mix timezones. ! dt1 = self.theclass(MAXYEAR, 12, 31, 22, 59, 59, 999998, -60) ! dt2 = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999998, 0) ! self.assertEqual(dt1, dt2) ! dt2 += us ! self.assertEqual(dt2 - dt1, us) ! self.assert_(dt1 < dt2) ! ! def test_bad_constructor_arguments(self): ! # bad years ! self.theclass(MINYEAR, 1, 1) # no exception ! self.theclass(MAXYEAR, 1, 1) # no exception ! self.assertRaises(ValueError, self.theclass, MINYEAR-1, 1, 1) ! self.assertRaises(ValueError, self.theclass, MAXYEAR+1, 1, 1) ! # bad months ! self.theclass(2000, 1, 1) # no exception ! self.theclass(2000, 12, 1) # no exception ! self.assertRaises(ValueError, self.theclass, 2000, 0, 1) ! self.assertRaises(ValueError, self.theclass, 2000, 13, 1) ! # bad days ! self.theclass(2000, 2, 29) # no exception ! self.theclass(2004, 2, 29) # no exception ! self.theclass(2400, 2, 29) # no exception ! self.assertRaises(ValueError, self.theclass, 2000, 2, 30) ! self.assertRaises(ValueError, self.theclass, 2001, 2, 29) ! self.assertRaises(ValueError, self.theclass, 2100, 2, 29) ! self.assertRaises(ValueError, self.theclass, 1900, 2, 29) ! self.assertRaises(ValueError, self.theclass, 2000, 1, 0) ! self.assertRaises(ValueError, self.theclass, 2000, 1, 32) ! # bad hours ! self.theclass(2000, 1, 31, 0) # no exception ! self.theclass(2000, 1, 31, 23) # no exception ! self.assertRaises(ValueError, self.theclass, 2000, 1, 31, -1) ! self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 24) ! # bad minutes ! self.theclass(2000, 1, 31, 23, 0) # no exception ! self.theclass(2000, 1, 31, 23, 59) # no exception ! self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, -1) ! self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, 60) ! # bad seconds ! self.theclass(2000, 1, 31, 23, 59, 0) # no exception ! self.theclass(2000, 1, 31, 23, 59, 59) # no exception ! self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, 59, -1) ! self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, 59, 60) ! # bad microseconds ! self.theclass(2000, 1, 31, 23, 59, 59, 0) # no exception ! self.theclass(2000, 1, 31, 23, 59, 59, 999999) # no exception ! self.assertRaises(ValueError, self.theclass, ! 2000, 1, 31, 23, 59, 59, -1) ! self.assertRaises(ValueError, self.theclass, ! 2000, 1, 31, 23, 59, 59, ! 1000000) ! # bad tzoffet ! self.theclass(2, 1, 1, 0, 0, 0, 0, -1439) # no exception ! self.theclass(2, 1, 1, 0, 0, 0, 0, 1439) # no exception ! self.assertRaises(ValueError, self.theclass, ! 2, 1, 1, 0, 0, 0, 0, -1440) ! self.assertRaises(ValueError, self.theclass, ! 2, 1, 1, 0, 0, 0, 0, 1440) ! ! def test_hash_equality(self): ! d = self.theclass(2000, 12, 31, 23, 30, 17, tzoffset=-35) ! # same thing in UTC. ! e = self.theclass(2001, 1, 1, 0, 5, 17, tzoffset=0) ! self.assertEqual(d, e) ! self.assertEqual(hash(d), hash(e)) ! ! dic = {d: 1} ! dic[e] = 2 ! self.assertEqual(len(dic), 1) ! self.assertEqual(dic[d], 2) ! self.assertEqual(dic[e], 2) ! ! d = self.theclass(2001, 1, 1, 0, 5, 17, tzoffset=35) ! # same thing in UTC. ! e = self.theclass(2000, 12, 31, 23, 30, 17, tzoffset=0) ! self.assertEqual(d, e) ! self.assertEqual(hash(d), hash(e)) ! ! dic = {d: 1} ! dic[e] = 2 ! self.assertEqual(len(dic), 1) ! self.assertEqual(dic[d], 2) ! self.assertEqual(dic[e], 2) ! ! def test_computations(self): ! a = self.theclass(2002, 1, 31) ! b = self.theclass(1956, 1, 31) ! diff = a-b ! self.assertEqual(diff.days, 46*365 + len(range(1956, 2002, 4))) ! self.assertEqual(diff.seconds, 0) ! self.assertEqual(diff.microseconds, 0) ! a = self.theclass(2002, 3, 2, 17, 6) ! millisec = timedelta(0, 0, 1000) ! hour = timedelta(0, 3600) ! day = timedelta(1) ! week = timedelta(7) ! self.assertEqual(a + hour, self.theclass(2002, 3, 2, 18, 6)) ! self.assertEqual(a + 10*hour, self.theclass(2002, 3, 3, 3, 6)) ! self.assertEqual(a - hour, self.theclass(2002, 3, 2, 16, 6)) ! self.assertEqual(a - hour, a + -hour) ! self.assertEqual(a - 20*hour, self.theclass(2002, 3, 1, 21, 6)) ! self.assertEqual(a + day, self.theclass(2002, 3, 3, 17, 6)) ! self.assertEqual(a - day, self.theclass(2002, 3, 1, 17, 6)) ! self.assertEqual(a + week, self.theclass(2002, 3, 9, 17, 6)) ! self.assertEqual(a - week, self.theclass(2002, 2, 23, 17, 6)) ! self.assertEqual(a + 52*week, self.theclass(2003, 3, 1, 17, 6)) ! self.assertEqual(a - 52*week, self.theclass(2001, 3, 3, 17, 6)) ! self.assertEqual((a + week) - a, week) ! self.assertEqual((a + day) - a, day) ! self.assertEqual((a + hour) - a, hour) ! self.assertEqual((a + millisec) - a, millisec) ! self.assertEqual((a - week) - a, -week) ! self.assertEqual((a - day) - a, -day) ! self.assertEqual((a - hour) - a, -hour) ! self.assertEqual((a - millisec) - a, -millisec) ! self.assertEqual(a - (a + week), -week) ! self.assertEqual(a - (a + day), -day) ! self.assertEqual(a - (a + hour), -hour) ! self.assertEqual(a - (a + millisec), -millisec) ! self.assertEqual(a - (a - week), week) ! self.assertEqual(a - (a - day), day) ! self.assertEqual(a - (a - hour), hour) ! self.assertEqual(a - (a - millisec), millisec) ! self.assertEqual(a + (week + day + hour + millisec), ! self.theclass(2002, 3, 10, 18, 6, 0, 1000)) ! self.assertEqual(a + (week + day + hour + millisec), ! (((a + week) + day) + hour) + millisec) ! self.assertEqual(a - (week + day + hour + millisec), ! self.theclass(2002, 2, 22, 16, 5, 59, 999000)) ! self.assertEqual(a - (week + day + hour + millisec), ! (((a - week) - day) - hour) - millisec) ! # Add/sub ints, longs, floats should be illegal ! for i in 1, 1L, 1.0: ! self.assertRaises(TypeError, lambda: a+i) ! self.assertRaises(TypeError, lambda: a-i) ! self.assertRaises(TypeError, lambda: i+a) ! self.assertRaises(TypeError, lambda: i-a) ! ! def test_isoformat(self): ! t = self.theclass(2, 3, 2, 4, 5, 1, 123, tzoffset=-120) self.assertEqual(t.isoformat(), "0002-03-02T04:05:01.000123-02:00") self.assertEqual(t.isoformat(' '), "0002-03-02 04:05:01.000123-02:00") *************** *** 372,376 **** from datetime import tmxxx for timestamp in 123456789.0, 987654321.0: ! dt = datetime.utcfromtimestamp(timestamp) # Mangles the fields, but in such a way that normalization should # restore them to dt's values. --- 507,511 ---- from datetime import tmxxx for timestamp in 123456789.0, 987654321.0: ! dt = self.theclass.utcfromtimestamp(timestamp) # Mangles the fields, but in such a way that normalization should # restore them to dt's values. *************** *** 378,388 **** dt.hour - 24*100, dt.minute - 3, dt.second + 12, (3*60 - 12) * 1000000) ! dt2 = datetime(tm.year, tm.month, tm.day, tm.hour, tm.minute, ! tm.second, tm.microsecond, tzoffset=0) self.assertEqual(dt, dt2) self.assertEqual(timestamp, tm.time()) def test_ctime(self): ! t = datetime(2002, 3, 2, 18, 3, 5, 123) self.assertEqual(t.ctime(), "Sat Mar 2 18:03:05 2002") # XXX Can only test utcctime() in known timezone :-( --- 513,523 ---- dt.hour - 24*100, dt.minute - 3, dt.second + 12, (3*60 - 12) * 1000000) ! dt2 = self.theclass(tm.year, tm.month, tm.day, tm.hour, tm.minute, ! tm.second, tm.microsecond, tzoffset=0) self.assertEqual(dt, dt2) self.assertEqual(timestamp, tm.time()) def test_ctime(self): ! t = self.theclass(2002, 3, 2, 18, 3, 5, 123) self.assertEqual(t.ctime(), "Sat Mar 2 18:03:05 2002") # XXX Can only test utcctime() in known timezone :-( *************** *** 398,420 **** self.fail("Can't test utcctime()") - def test_resolution_info(self): - self.assert_(isinstance(datetime.min, datetime)) - self.assert_(isinstance(datetime.max, datetime)) - self.assert_(isinstance(datetime.resolution, timedelta)) - self.assert_(datetime.max > datetime.min) - - def test_extreme_timedelta(self): - big = datetime.max - datetime.min - # 3652058 days, 23 hours, 59 minutes, 59 seconds, 999999 microseconds - n = (big.days*24*3600 + big.seconds)*1000000 + big.microseconds - # n = 315537897599999999 ~= 2**58.13 - justasbig = timedelta(0, 0, n) - self.assertEqual(big, justasbig) - self.assertEqual(datetime.min + big, datetime.max) - self.assertEqual(datetime.max - big, datetime.min) def test_suite(): ! s1 = unittest.makeSuite(TestDateTime, 'test') ! return unittest.TestSuite([s1]) def test_main(): --- 533,542 ---- self.fail("Can't test utcctime()") def test_suite(): ! s1 = unittest.makeSuite(TestTimeDelta, 'test') ! s2 = unittest.makeSuite(TestDate, 'test') ! s3 = unittest.makeSuite(TestDateTime, 'test') ! return unittest.TestSuite([s1, s2, s3]) def test_main(): From mwh@users.sourceforge.net Tue Mar 5 14:20:34 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 05 Mar 2002 06:20:34 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules mpzmodule.c,2.38,2.38.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv8376 Modified Files: Tag: release22-maint mpzmodule.c Log Message: backport gvanrossum's checkin of revision 2.40 of mpzmodule.c SF patch 517245 by Marc Recht. Support GMP version >= 2. Bugfix candidate. Index: mpzmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mpzmodule.c,v retrieving revision 2.38 retrieving revision 2.38.6.1 diff -C2 -d -r2.38 -r2.38.6.1 *** mpzmodule.c 8 Dec 2001 18:02:57 -0000 2.38 --- mpzmodule.c 5 Mar 2002 14:20:32 -0000 2.38.6.1 *************** *** 63,67 **** #include "gmp.h" ! #if __GNU_MP__ + 0 == 2 #define GMP2 #define BITS_PER_MP_LIMB mp_bits_per_limb --- 63,67 ---- #include "gmp.h" ! #if __GNU_MP__ + 0 >= 2 #define GMP2 #define BITS_PER_MP_LIMB mp_bits_per_limb From mwh@users.sourceforge.net Tue Mar 5 14:20:53 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 05 Mar 2002 06:20:53 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc ACKS,1.149.4.3,1.149.4.4 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv8676 Modified Files: Tag: release22-maint ACKS Log Message: backport gvanrossum's checkin of revision 1.162 of ACKS SF patch 517245 by Marc Recht. Support GMP version >= 2. Bugfix candidate. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.149.4.3 retrieving revision 1.149.4.4 diff -C2 -d -r1.149.4.3 -r1.149.4.4 *** ACKS 5 Mar 2002 13:58:13 -0000 1.149.4.3 --- ACKS 5 Mar 2002 14:20:51 -0000 1.149.4.4 *************** *** 349,352 **** --- 349,353 ---- Eric Raymond Edward K. Ream + Marc Recht John Redford Terry Reedy From mwh@users.sourceforge.net Tue Mar 5 14:23:58 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 05 Mar 2002 06:23:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects object.c,2.162,2.162.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv11399 Modified Files: Tag: release22-maint object.c Log Message: backport tim_one's checkin of revision 2.164 of object.c Whether platform malloc(0) returns NULL has nothing to do with whether platform realloc(p, 0) returns NULL, so MALLOC_ZERO_RETURNS_NULL can be correctly undefined yet realloc(p, 0) can return NULL anyway. Prevent realloc(p, 0) doing free(p) and returning NULL via a different hack. Would probably be better to get rid of MALLOC_ZERO_RETURNS_NULL entirely. Bugfix candidate. Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.162 retrieving revision 2.162.6.1 diff -C2 -d -r2.162 -r2.162.6.1 *** object.c 4 Dec 2001 15:54:53 -0000 2.162 --- object.c 5 Mar 2002 14:23:56 -0000 2.162.6.1 *************** *** 1889,1897 **** PyMem_Realloc(void *p, size_t nbytes) { ! #if _PyMem_EXTRA > 0 ! if (nbytes == 0) ! nbytes = _PyMem_EXTRA; ! #endif ! return PyMem_REALLOC(p, nbytes); } --- 1889,1894 ---- PyMem_Realloc(void *p, size_t nbytes) { ! /* See comment near MALLOC_ZERO_RETURNS_NULL in pyport.h. */ ! return PyMem_REALLOC(p, nbytes ? nbytes : 1); } From mwh@users.sourceforge.net Tue Mar 5 14:24:47 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 05 Mar 2002 06:24:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include pymem.h,2.4,2.4.16.1 pyport.h,2.40,2.40.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv12181 Modified Files: Tag: release22-maint pymem.h pyport.h Log Message: backport tim_one's checkin of revision 2.5 of pymem.h revision 2.44 of pyport.h Whether platform malloc(0) returns NULL has nothing to do with whether platform realloc(p, 0) returns NULL, so MALLOC_ZERO_RETURNS_NULL can be correctly undefined yet realloc(p, 0) can return NULL anyway. Prevent realloc(p, 0) doing free(p) and returning NULL via a different hack. Would probably be better to get rid of MALLOC_ZERO_RETURNS_NULL entirely. Bugfix candidate. Index: pymem.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pymem.h,v retrieving revision 2.4 retrieving revision 2.4.16.1 diff -C2 -d -r2.4 -r2.4.16.1 *** pymem.h 26 Jul 2001 21:34:59 -0000 2.4 --- pymem.h 5 Mar 2002 14:24:45 -0000 2.4.16.1 *************** *** 112,122 **** #define PyMem_NEW(type, n) \ ( (type *) PyMem_MALLOC(_PyMem_EXTRA + (n) * sizeof(type)) ) ! #define PyMem_RESIZE(p, type, n) \ ! if ((p) == NULL) \ ! (p) = (type *)(PyMem_MALLOC( \ ! _PyMem_EXTRA + (n) * sizeof(type))); \ ! else \ ! (p) = (type *)(PyMem_REALLOC((p), \ ! _PyMem_EXTRA + (n) * sizeof(type))) #define PyMem_DEL(p) PyMem_FREE(p) --- 112,127 ---- #define PyMem_NEW(type, n) \ ( (type *) PyMem_MALLOC(_PyMem_EXTRA + (n) * sizeof(type)) ) ! ! /* See comment near MALLOC_ZERO_RETURNS_NULL in pyport.h. */ ! #define PyMem_RESIZE(p, type, n) \ ! do { \ ! size_t _sum = (n) * sizeof(type); \ ! if (!_sum) \ ! _sum = 1; \ ! (p) = (type *)((p) ? \ ! PyMem_REALLOC(p, _sum) : \ ! PyMem_MALLOC(_sum)); \ ! } while (0) ! #define PyMem_DEL(p) PyMem_FREE(p) Index: pyport.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pyport.h,v retrieving revision 2.40 retrieving revision 2.40.8.1 diff -C2 -d -r2.40 -r2.40.8.1 *** pyport.h 27 Oct 2001 21:16:16 -0000 2.40 --- pyport.h 5 Mar 2002 14:24:45 -0000 2.40.8.1 *************** *** 365,370 **** #ifdef MALLOC_ZERO_RETURNS_NULL ! /* XXX Always allocate one extra byte, since some malloc's return NULL ! XXX for malloc(0) or realloc(p, 0). */ #define _PyMem_EXTRA 1 #else --- 365,378 ---- #ifdef MALLOC_ZERO_RETURNS_NULL ! /* Allocate an extra byte if the platform malloc(0) returns NULL. ! Caution: this bears no relation to whether realloc(p, 0) returns NULL ! when p != NULL. Even on platforms where malloc(0) does not return NULL, ! realloc(p, 0) may act like free(p) and return NULL. Examples include ! Windows, and Python's own obmalloc.c (as of 2-Mar-2002). For whatever ! reason, our docs promise that PyMem_Realloc(p, 0) won't act like ! free(p) or return NULL, so realloc() calls may have to be hacked ! too, but MALLOC_ZERO_RETURNS_NULL's state is irrelevant to realloc (it ! needs a different hack). ! */ #define _PyMem_EXTRA 1 #else From mwh@users.sourceforge.net Tue Mar 5 15:37:21 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 05 Mar 2002 07:37:21 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.113.4.1,1.113.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv15359 Modified Files: Tag: release22-maint test_descr.py Log Message: backport gvanrossum's checkin of revision 1.115 of test_descr.py SF patch 514641 (Naofumi Honda) - Negative ob_size of LongObjects Due to the bizarre definition of _PyLong_Copy(), creating an instance of a subclass of long with a negative value could cause core dumps later on. Unfortunately it looks like the behavior of _PyLong_Copy() is quite intentional, so the fix is more work than feels comfortable. This fix is almost, but not quite, the code that Naofumi Honda added; in addition, I added a test case. I haven't quite worked out how to port the fix yet, but the test cases can go straight over. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.113.4.1 retrieving revision 1.113.4.2 diff -C2 -d -r1.113.4.1 -r1.113.4.2 *** test_descr.py 4 Jan 2002 12:28:43 -0000 1.113.4.1 --- test_descr.py 5 Mar 2002 15:37:18 -0000 1.113.4.2 *************** *** 1749,1752 **** --- 1749,1756 ---- verify((0 + a).__class__ is long) + # Check that negative clones don't segfault + a = longclone(-1) + vereq(a.__dict__, {}) + class precfloat(float): __slots__ = ['prec'] From mwh@users.sourceforge.net Tue Mar 5 15:37:48 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 05 Mar 2002 07:37:48 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc ACKS,1.149.4.4,1.149.4.5 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv15502 Modified Files: Tag: release22-maint ACKS Log Message: backport gvanrossum's checkin of revision 1.163 of ACKS Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.149.4.4 retrieving revision 1.149.4.5 diff -C2 -d -r1.149.4.4 -r1.149.4.5 *** ACKS 5 Mar 2002 14:20:51 -0000 1.149.4.4 --- ACKS 5 Mar 2002 15:37:46 -0000 1.149.4.5 *************** *** 202,205 **** --- 202,206 ---- Gerrit Holl Philip Homburg + Naofumi Honda Jeffrey Honig Rob Hooft From mwh@users.sourceforge.net Tue Mar 5 15:38:45 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 05 Mar 2002 07:38:45 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.113.4.2,1.113.4.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv15943 Modified Files: Tag: release22-maint test_descr.py Log Message: backport tim_one's checkin of revision 1.116 of test_descr.py _PyLong_Copy(): was creating a copy of the absolute value, but should copy the sign too. Added a test to test_descr to ensure that it does. Bugfix candidate. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.113.4.2 retrieving revision 1.113.4.3 diff -C2 -d -r1.113.4.2 -r1.113.4.3 *** test_descr.py 5 Mar 2002 15:37:18 -0000 1.113.4.2 --- test_descr.py 5 Mar 2002 15:38:43 -0000 1.113.4.3 *************** *** 1752,1755 **** --- 1752,1756 ---- a = longclone(-1) vereq(a.__dict__, {}) + vereq(long(a), -1) # verify PyNumber_Long() copies the sign bit class precfloat(float): From mwh@users.sourceforge.net Tue Mar 5 15:41:42 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 05 Mar 2002 07:41:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects object.c,2.162.6.1,2.162.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv16797 Modified Files: Tag: release22-maint object.c Log Message: Backport the bits of Guido's fix for SF patch 514641 (Naofumi Honda) - Negative ob_size of LongObjects that Tim didn't later back out. Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.162.6.1 retrieving revision 2.162.6.2 diff -C2 -d -r2.162.6.1 -r2.162.6.2 *** object.c 5 Mar 2002 14:23:56 -0000 2.162.6.1 --- object.c 5 Mar 2002 15:41:40 -0000 2.162.6.2 *************** *** 1192,1197 **** return NULL; if (dictoffset < 0) { ! const size_t size = _PyObject_VAR_SIZE(tp, ! ((PyVarObject *)obj)->ob_size); dictoffset += (long)size; assert(dictoffset > 0); --- 1192,1203 ---- return NULL; if (dictoffset < 0) { ! int tsize; ! size_t size; ! ! tsize = ((PyVarObject *)obj)->ob_size; ! if (tsize < 0) ! tsize = -tsize; ! size = _PyObject_VAR_SIZE(tp, tsize); ! dictoffset += (long)size; assert(dictoffset > 0); From mwh@users.sourceforge.net Tue Mar 5 15:42:50 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 05 Mar 2002 07:42:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects longobject.c,1.112.8.1,1.112.8.2 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv17502 Modified Files: Tag: release22-maint longobject.c Log Message: backport tim_one's checkin of revision 1.114 of longobject.c _PyLong_Copy(): was creating a copy of the absolute value, but should copy the sign too. Added a test to test_descr to ensure that it does. Bugfix candidate. Index: longobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/longobject.c,v retrieving revision 1.112.8.1 retrieving revision 1.112.8.2 diff -C2 -d -r1.112.8.1 -r1.112.8.2 *** longobject.c 16 Feb 2002 23:41:39 -0000 1.112.8.1 --- longobject.c 5 Mar 2002 15:42:48 -0000 1.112.8.2 *************** *** 64,68 **** result = _PyLong_New(i); if (result != NULL) { ! result->ob_size = i; while (--i >= 0) result->ob_digit[i] = src->ob_digit[i]; --- 64,68 ---- result = _PyLong_New(i); if (result != NULL) { ! result->ob_size = src->ob_size; while (--i >= 0) result->ob_digit[i] = src->ob_digit[i]; From loewis@users.sourceforge.net Tue Mar 5 15:46:40 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Tue, 05 Mar 2002 07:46:40 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib codecs.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv18567 Modified Files: codecs.py Log Message: Set default value for readlines.sizehint to None. Change needed for 2.2.1 as well. Index: codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codecs.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** codecs.py 19 Sep 2001 11:24:48 -0000 1.23 --- codecs.py 5 Mar 2002 15:46:38 -0000 1.24 *************** *** 253,257 **** ! def readlines(self, sizehint=0): """ Read all lines available on the input stream --- 253,257 ---- ! def readlines(self, sizehint=None): """ Read all lines available on the input stream From mwh@users.sourceforge.net Tue Mar 5 15:55:27 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 05 Mar 2002 07:55:27 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib codecs.py,1.23,1.23.12.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv22140 Modified Files: Tag: release22-maint codecs.py Log Message: backport loewis' checkin of revision 1.24 of codecs.py Set default value for readlines.sizehint to None. Change needed for 2.2.1 as well. Index: codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codecs.py,v retrieving revision 1.23 retrieving revision 1.23.12.1 diff -C2 -d -r1.23 -r1.23.12.1 *** codecs.py 19 Sep 2001 11:24:48 -0000 1.23 --- codecs.py 5 Mar 2002 15:55:25 -0000 1.23.12.1 *************** *** 253,257 **** ! def readlines(self, sizehint=0): """ Read all lines available on the input stream --- 253,257 ---- ! def readlines(self, sizehint=None): """ Read all lines available on the input stream From andymac@bullseye.apana.org.au Tue Mar 5 10:17:33 2002 From: andymac@bullseye.apana.org.au (Andrew MacIntyre) Date: Tue, 5 Mar 2002 21:17:33 +1100 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.223,2.224 In-Reply-To: Message-ID: On Sun, 3 Mar 2002, Tim Peters wrote: > Update of /cvsroot/python/python/dist/src/Modules > In directory usw-pr-cvs1:/tmp/cvs-serv23112/python/Modules > > Modified Files: > posixmodule.c > Log Message: > Python no longer compiled on Windows, due to #include file confusion > over SEP, ALTSEP and MAXPATHLEN. > Patched up posixmodule.c for MSVC, but unsure what the story is now on > other non-Unixish platforms -- the preprocessor maze has no exit . I presume this was as a result of my large commit :-( Sorry. It has occurred to me that posixmodule.c is nearly a candidate for the approach applied to threads and dynamic loading.... -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andymac@bullseye.apana.org.au | Snail: PO Box 370 andymac@pcug.org.au | Belconnen ACT 2616 Web: http://www.andymac.org/ | Australia From tim_one@users.sourceforge.net Tue Mar 5 19:11:45 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Tue, 05 Mar 2002 11:11:45 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.52,1.53 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv24539 Modified Files: datetime.py Log Message: Hmm. Either some fiddling to timedelta.__init__ got lost via another checkin, or I forgot to check it in to begin with. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** datetime.py 5 Mar 2002 14:14:48 -0000 1.52 --- datetime.py 5 Mar 2002 19:11:43 -0000 1.53 *************** *** 338,341 **** --- 338,342 ---- d = days assert isinstance(daysecondsfrac, float) + assert abs(daysecondsfrac) <= 1.0 assert isinstance(d, (int, long)) assert abs(s) <= 24 * 3600 *************** *** 346,352 **** assert seconds == long(seconds) seconds = long(seconds) else: ! secondsfrac = 0.0 assert isinstance(secondsfrac, float) assert isinstance(seconds, (int, long)) days, seconds = divmod(seconds, 24*3600) --- 347,358 ---- assert seconds == long(seconds) seconds = long(seconds) + secondsfrac += daysecondsfrac + assert abs(secondsfrac) <= 2.0 else: ! secondsfrac = daysecondsfrac ! # daysecondsfrac isn't referenced again assert isinstance(secondsfrac, float) + assert abs(secondsfrac) <= 2.0 + assert isinstance(seconds, (int, long)) days, seconds = divmod(seconds, 24*3600) *************** *** 357,365 **** # seconds isn't referenced again before redefinition - secondsfrac += daysecondsfrac - assert -2.0 <= secondsfrac <= 2.0 usdouble = secondsfrac * 1e6 ! assert -2.1e6 < usdouble < 2.1e6 # exact value not critical ! # secondsfrac & daysecondsfrac aren't referenced again if isinstance(microseconds, float): --- 363,369 ---- # seconds isn't referenced again before redefinition usdouble = secondsfrac * 1e6 ! assert abs(usdouble) < 2.1e6 # exact value not critical ! # secondsfrac isn't referenced again if isinstance(microseconds, float): *************** *** 387,391 **** microseconds = round(microseconds) assert abs(s) <= 3 * 24 * 3600 ! assert abs(microseconds) <= 3.1e6 # Just a little bit of carrying possible for microseconds and seconds. --- 391,395 ---- microseconds = round(microseconds) assert abs(s) <= 3 * 24 * 3600 ! assert abs(microseconds) < 3.1e6 # Just a little bit of carrying possible for microseconds and seconds. From jackjansen@users.sourceforge.net Tue Mar 5 22:43:52 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 05 Mar 2002 14:43:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Build _CG.carbon.mcp,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Build In directory usw-pr-cvs1:/tmp/cvs-serv27624/Python/Mac/Build Modified Files: _CG.carbon.mcp Log Message: CGStubLib wasn't weak-linked, fixed. 221 candidate. Index: _CG.carbon.mcp =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Build/_CG.carbon.mcp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 Binary files /tmp/cvsjhXD1M and /tmp/cvsmTDt2r differ From tim.one@comcast.net Tue Mar 5 22:52:55 2002 From: tim.one@comcast.net (Tim Peters) Date: Tue, 05 Mar 2002 17:52:55 -0500 Subject: [Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.223,2.224 In-Reply-To: Message-ID: [Tim] > Modified Files: > posixmodule.c > Log Message: > Python no longer compiled on Windows, due to #include file confusion > over SEP, ALTSEP and MAXPATHLEN. > ... [Andrew MacIntyre] > I presume this was as a result of my large commit :-( Sorry. Probably, but don't worry about it. Historically, the Windows build breaks about once per week, and it's my stated policy that I'd much rather fix it after the fact then pee away time applying patches in advance. One reason for that is, if I wait until after the build is broken, it's much easier to shame the committer into making fixes an urgent priority . > It has occurred to me that posixmodule.c is nearly a candidate for the > approach applied to threads and dynamic loading.... I don't expect it would really help, for much the same reason thread_pthread.h alone has a mass of inscructable #ifdefs at its start, yet keeps breaking on pthreads platforms anyway: outside the 300-line preprocessor maze at the start of posixmodule.c, most of the #ifdef hair in the remaining 6400 lines has to do with untangling Unix variations. From gvanrossum@users.sourceforge.net Wed Mar 6 01:25:18 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Tue, 05 Mar 2002 17:25:18 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.53,1.54 test_datetime.py,1.37,1.38 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv5073 Modified Files: datetime.py test_datetime.py Log Message: Eradicate all references to time zone offset. This implements naive time'' as I described on python-dev. Some cleanup remains to be done... Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** datetime.py 5 Mar 2002 19:11:43 -0000 1.53 --- datetime.py 6 Mar 2002 01:25:13 -0000 1.54 *************** *** 249,267 **** - def _localtzoffset(year, month, day, hour, minute): - "Return tzoffset for local time corresponding to given date/time." - try: - t = _time.mktime((year, month, day, hour, minute, 0, -1, -1, -1)) - tm = _time.localtime(t) - if tm.tm_isdst > 0: - return - (_time.altzone // 60) - else: - return - (_time.timezone // 60) - except (ValueError, OverflowError): - # Dates out of range for mktime() never see DST. - # As a reasonable guess, though, we can try a year in mktime()'s range - # with the same leap-year-ness as the given year. - return _localtzoffset(2003 + _is_leap(year), month, day, hour, minute) - class basetime(object): """Abstract date/time type. --- 249,252 ---- *************** *** 423,443 **** def __str__(self): ! def plural(n): ! return n, n != 1 and "s" or "" ! L = [] if self.__days: ! L.append("%d day%s" % plural(self.__days)) ! if self.__seconds: ! mm, ss = divmod(self.__seconds, 60) ! hh, mm = divmod(mm, 60) ! if hh: ! L.append("%d hour%s" % plural(hh)) ! if mm: ! L.append("%d minute%s" % plural(mm)) ! if ss: ! L.append("%d second%s" % plural(ss)) if self.__microseconds: ! L.append("%d microsecond%s" % plural(self.__microseconds)) ! return ", ".join(L) days = property(lambda self: self.__days, doc="days") --- 408,421 ---- def __str__(self): ! mm, ss = divmod(self.__seconds, 60) ! hh, mm = divmod(mm, 60) ! s = "%d:%02d:%02d" % (hh, mm, ss) if self.__days: ! def plural(n): ! return n, n != 1 and "s" or "" ! s = ("%d day%s, " % plural(self.__days)) + s if self.__microseconds: ! s = s + ".%06d" % self.__microseconds ! return s days = property(lambda self: self.__days, doc="days") *************** *** 560,568 **** "Construct a date from a POSIX timestamp (like time.time())." y, m, d, hh, mm, ss, weekday, jday, dst = _time.localtime(t) - us = int((t % 1.0) * 1000000) - if dst > 0: - tz = -(_time.altzone // 60) - else: - tz = -(_time.timezone // 60) return cls(y, m, d) fromtimestamp = classmethod(fromtimestamp) --- 538,541 ---- *************** *** 636,642 **** def __hash__(self): "Hash." - # Caution: objects that compare equal must have equal hashcodes, - # and two dates can be equal even if their fields aren't - # (due to tzoffset). So we have to compute a UTC-normalized hash. return hash((self.__year, self.__month, self.__day)) --- 609,612 ---- *************** *** 648,662 **** # strftime("%c", ...) is locale specific. - # XXX An additional question is whether ctime() should renormalize - # to local time, or display the time as entered (which may be - # confusing since it doesn't show the timezone). - def ctime(self): ! "Format a la ctime() in local time." ! t = tmxxx(self.__year, self.__month, self.__day) ! return t.ctime() def strftime(self, fmt): ! "Format using strftime() in local time." return _time.strftime(fmt, _time.localtime(self._mktime())) --- 618,627 ---- # strftime("%c", ...) is locale specific. def ctime(self): ! "Format a la ctime()." ! return tmxxx(self.__year, self.__month, self.__day).ctime() def strftime(self, fmt): ! "Format using strftime()." return _time.strftime(fmt, _time.localtime(self._mktime())) *************** *** 776,784 **** Properties (readonly): ! year, month, day, hour, minute, second, microsecond, tzoffset """ def __init__(self, year, month, day, hour=0, minute=0, second=0, ! microsecond=0, tzoffset=None): """Constructor. --- 741,749 ---- Properties (readonly): ! year, month, day, hour, minute, second, microsecond """ def __init__(self, year, month, day, hour=0, minute=0, second=0, ! microsecond=0): """Constructor. *************** *** 787,792 **** year, month, day (required, base 1) hour, minute, second, microsecond (default to zero) - tzoffset (minutes east of UTC; defaults to local time) - """ super(datetime, self).__init__(year, month, day) --- 752,755 ---- *************** *** 799,807 **** if not 0 <= microsecond <= 999999: raise ValueError('microsecond must be in 0..999999', microsecond) - if tzoffset is None: - # XXX Correct, but expensive - tzoffset = _localtzoffset(year, month, day, hour, minute) - if not -1439 <= tzoffset <= 1439: - raise ValueError('tzoffset must be in -1439..1439', tzoffset) # XXX This duplicates __year, __month, __day for convenience :-( self.__year = year --- 762,765 ---- *************** *** 812,816 **** self.__second = second self.__microsecond = microsecond - self.__tzoffset = tzoffset # minutes east of UTC # Additional constructors --- 770,773 ---- *************** *** 820,828 **** y, m, d, hh, mm, ss, weekday, jday, dst = _time.localtime(t) us = int((t % 1.0) * 1000000) ! if dst > 0: ! tz = -(_time.altzone // 60) ! else: ! tz = -(_time.timezone // 60) ! return cls(y, m, d, hh, mm, ss, us, tz) fromtimestamp = classmethod(fromtimestamp) --- 777,781 ---- y, m, d, hh, mm, ss, weekday, jday, dst = _time.localtime(t) us = int((t % 1.0) * 1000000) ! return cls(y, m, d, hh, mm, ss, us) fromtimestamp = classmethod(fromtimestamp) *************** *** 837,841 **** y, m, d, hh, mm, ss, weekday, jday, dst = _time.gmtime(t) us = int((t % 1.0) * 1000000) ! return cls(y, m, d, hh, mm, ss, us, 0) utcfromtimestamp = classmethod(utcfromtimestamp) --- 790,794 ---- y, m, d, hh, mm, ss, weekday, jday, dst = _time.gmtime(t) us = int((t % 1.0) * 1000000) ! return cls(y, m, d, hh, mm, ss, us) utcfromtimestamp = classmethod(utcfromtimestamp) *************** *** 855,861 **** del L[-1] s = ", ".join(map(str, L)) ! return "%s(%s, tzoffset=%d)" % (self.__class__.__name__, ! s, ! self.__tzoffset) def __str__(self): --- 808,812 ---- del L[-1] s = ", ".join(map(str, L)) ! return "%s(%s)" % (self.__class__.__name__, s) def __str__(self): *************** *** 869,874 **** microsecond = property(lambda self: self.__microsecond, doc="microsecond (0-999999)") - tzoffset = property(lambda self: self.__tzoffset, - doc="time zone offset in minutes east of UTC") # Standard conversions, __cmp__, __hash__ (and helpers) --- 820,823 ---- *************** *** 879,883 **** # Helper to return a POSIX-ish timestamp t = tmxxx(self.__year, self.__month, self.__day, ! self.__hour, self.__minute - self.__tzoffset, self.__second, self.__microsecond) return t.time() --- 828,832 ---- # Helper to return a POSIX-ish timestamp t = tmxxx(self.__year, self.__month, self.__day, ! self.__hour, self.__minute, self.__second, self.__microsecond) return t.time() *************** *** 890,923 **** "Three-way comparison." if isinstance(other, datetime): ! if self.__tzoffset == other.__tzoffset: ! y, m, d = self.__year, self.__month, self.__day ! H, M = self.__hour, self.__minute ! y2, m2, d2 = other.__year, other.__month, other.__day ! H2, M2 = other.__hour, other.__minute ! else: ! y, m, d, H, M = self._utc_ymdHM() ! y2, m2, d2, H2, M2 = other._utc_ymdHM() ! return cmp((y, m, d, H, M, ! self.__second, self.__microsecond), ! (y2, m2, d2, H2, M2, ! other.__second, other.__microsecond)) ! else: ! raise TypeError, ("can't compare datetime to %s instance" % ! type(other).__name__) ! ! def _utc_ymdHM(self): ! # Helper to return (year, month, day, hour, minute) in UTC equivalent ! t = tmxxx(self.__year, self.__month, self.__day, ! self.__hour, self.__minute - self.__tzoffset) ! return t.year, t.month, t.day, t.hour, t.minute def __hash__(self): "Hash." ! # Caution: objects that compare equal must have equal hashcodes, ! # and two datetimes can be equal even if their fields aren't ! # (due to tzoffset). So we have to compute a UTC-normalized hash. ! # XXX _utc_ymdHM can be expensive; dream up a quicker correct way. ! y, m, d, H, M = self._utc_ymdHM() ! return hash((y, m, d, H, M, self.__second, self.__microsecond)) # Formatting methods --- 839,856 ---- "Three-way comparison." if isinstance(other, datetime): ! return cmp((self.__year, self.__month, self.__day, ! self.__hour, self.__minute, self.__second, ! self.__microsecond), ! (other.__year, other.__month, other.__day, ! other.__hour, other.__minute, other.__second, ! other.__microsecond)) ! raise TypeError, ("can't compare datetime to %s instance" % ! type(other).__name__) def __hash__(self): "Hash." ! return hash((self.__year, self.__month, self.__day, ! self.__hour, self.__minute, self.__second, ! self.__microsecond)) # Formatting methods *************** *** 933,959 **** def ctime(self): ! "Format a la ctime() in local time." ! tzoffset = _localtzoffset(self.__year, self.__month, self.__day, 0, 0) t = tmxxx(self.__year, self.__month, self.__day, self.__hour, ! self.__minute - self.__tzoffset + tzoffset, self.__second) ! tzoffset1 = _localtzoffset(t.year, t.month, t.day, t.hour, t.minute) ! if tzoffset1 != tzoffset: ! t = tmxxx(t.year, t.month, t.day, t.hour, ! t.minute - tzoffset + tzoffset1, self.__second) ! tzoffset2 = _localtzoffset(t.year, t.month, t.day, ! t.hour, t.minute) ! assert tzoffset2 == tzoffset1 # XXX Hah! ! return t.ctime() ! ! def utcctime(self): ! "Format a la ctime() in UTC." ! t = tmxxx(self.__year, self.__month, self.__day, ! self.__hour, self.__minute - self.__tzoffset, self.__second) return t.ctime() - def utcstrftime(self, fmt): - "Format using strftime() in UTC." - return _time.strftime(fmt, _time.gmtime(self._mktime())) - # Computations --- 866,874 ---- def ctime(self): ! "Format a la ctime()." t = tmxxx(self.__year, self.__month, self.__day, self.__hour, ! self.__minute, self.__second) return t.ctime() # Computations *************** *** 971,975 **** result = self.__class__(t.year, t.month, t.day, t.hour, t.minute, t.second, ! t.microsecond, self.__tzoffset) return result raise TypeError --- 886,890 ---- result = self.__class__(t.year, t.month, t.day, t.hour, t.minute, t.second, ! t.microsecond) return result raise TypeError *************** *** 988,996 **** days1 = self.toordinal() days2 = other.toordinal() ! secs1 = (self.__second + ! (self.__minute - self.__tzoffset) * 60 + ! self.__hour * 3600) secs2 = (other.__second + ! (other.__minute - other.__tzoffset) * 60 + other.__hour * 3600) return self.timedelta_class( --- 903,909 ---- days1 = self.toordinal() days2 = other.toordinal() ! secs1 = (self.__second + self.__minute * 60 + self.__hour * 3600) secs2 = (other.__second + ! (other.__minute) * 60 + other.__hour * 3600) return self.timedelta_class( *************** *** 1000,1004 **** return NotImplemented ! # ISO formats including time and tzoffset def isoformat(self, sep='T'): --- 913,917 ---- return NotImplemented ! # ISO formats including time def isoformat(self, sep='T'): *************** *** 1010,1043 **** Optional argument sep specifies the separator between date and time, default 'T'. - - This method does not convert to local time. """ ! if self.__tzoffset >= 0: ! h, m = divmod(self.__tzoffset, 60) ! else: ! h, m = divmod(-self.__tzoffset, 60) ! h = -h ! return "%04d-%02d-%02d%c%02d:%02d:%02d.%06d%+03d:%02d" % ( self.__year, self.__month, self.__day, sep, self.__hour, self.__minute, self.__second, ! self.__microsecond, ! h, m) ! ! def utcisoformat(self, sep='T'): ! """Return the time as UTC formatted according to ISO. ! ! This is 'YYYY-MM-DD HH:MM:SS.mmmmmmZ'. ! ! Optional argument sep specifies the separator between date and ! time, default 'T'. ! """ ! y, m, d, hh, mm = self._utc_ymdHM() ! return "%04d-%02d-%02d%c%02d:%02d:%02d.%06dZ" % ( ! y, m, d, sep, hh, mm, self.__second, self.__microsecond) ! datetime.min = datetime(1, 1, 1, tzoffset=0) ! datetime.max = datetime(9999, 12, 31, 23, 59, 59, 999999, tzoffset=0) datetime.resolution = timedelta(microseconds=1) --- 923,936 ---- Optional argument sep specifies the separator between date and time, default 'T'. """ ! return "%04d-%02d-%02d%c%02d:%02d:%02d.%06d" % ( self.__year, self.__month, self.__day, sep, self.__hour, self.__minute, self.__second, ! self.__microsecond) ! datetime.min = datetime(1, 1, 1) ! datetime.max = datetime(9999, 12, 31, 23, 59, 59, 999999) datetime.resolution = timedelta(microseconds=1) Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** test_datetime.py 5 Mar 2002 14:14:48 -0000 1.37 --- test_datetime.py 6 Mar 2002 01:25:15 -0000 1.38 *************** *** 327,331 **** def test_roundtrip(self): ! for dt in (self.theclass(1, 2, 3, 4, 5, 6, 7, 8), self.theclass.now()): # Verify dt -> string -> datetime identity. --- 327,331 ---- def test_roundtrip(self): ! for dt in (self.theclass(1, 2, 3, 4, 5, 6, 7), self.theclass.now()): # Verify dt -> string -> datetime identity. *************** *** 337,347 **** dt2 = self.theclass(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, ! dt.microsecond, dt.tzoffset) self.assertEqual(dt, dt2) def test_tz_independent_comparing(self): ! dt1 = self.theclass(2002, 3, 1, 9, 0, 0, tzoffset=-60) ! dt2 = self.theclass(2002, 3, 1, 10, 0, 0, tzoffset=-60) ! dt3 = self.theclass(2002, 3, 1, 10, 0, 0, tzoffset=0) self.assertEqual(dt1, dt3) self.assert_(dt2 > dt3) --- 337,347 ---- dt2 = self.theclass(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, ! dt.microsecond) self.assertEqual(dt, dt2) def test_tz_independent_comparing(self): ! dt1 = self.theclass(2002, 3, 1, 9, 0, 0) ! dt2 = self.theclass(2002, 3, 1, 10, 0, 0) ! dt3 = self.theclass(2002, 3, 1, 9, 0, 0) self.assertEqual(dt1, dt3) self.assert_(dt2 > dt3) *************** *** 352,356 **** # so comparing via timestamp necessarily calls some distinct values # equal). ! dt1 = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999998, 0) us = timedelta(microseconds=1) dt2 = dt1 + us --- 352,356 ---- # so comparing via timestamp necessarily calls some distinct values # equal). ! dt1 = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999998) us = timedelta(microseconds=1) dt2 = dt1 + us *************** *** 358,369 **** self.assert_(dt1 < dt2) - # Again, but mix timezones. - dt1 = self.theclass(MAXYEAR, 12, 31, 22, 59, 59, 999998, -60) - dt2 = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999998, 0) - self.assertEqual(dt1, dt2) - dt2 += us - self.assertEqual(dt2 - dt1, us) - self.assert_(dt1 < dt2) - def test_bad_constructor_arguments(self): # bad years --- 358,361 ---- *************** *** 410,425 **** 2000, 1, 31, 23, 59, 59, 1000000) - # bad tzoffet - self.theclass(2, 1, 1, 0, 0, 0, 0, -1439) # no exception - self.theclass(2, 1, 1, 0, 0, 0, 0, 1439) # no exception - self.assertRaises(ValueError, self.theclass, - 2, 1, 1, 0, 0, 0, 0, -1440) - self.assertRaises(ValueError, self.theclass, - 2, 1, 1, 0, 0, 0, 0, 1440) def test_hash_equality(self): ! d = self.theclass(2000, 12, 31, 23, 30, 17, tzoffset=-35) ! # same thing in UTC. ! e = self.theclass(2001, 1, 1, 0, 5, 17, tzoffset=0) self.assertEqual(d, e) self.assertEqual(hash(d), hash(e)) --- 402,409 ---- 2000, 1, 31, 23, 59, 59, 1000000) def test_hash_equality(self): ! d = self.theclass(2000, 12, 31, 23, 30, 17) ! e = self.theclass(2000, 12, 31, 23, 30, 17) self.assertEqual(d, e) self.assertEqual(hash(d), hash(e)) *************** *** 431,437 **** self.assertEqual(dic[e], 2) ! d = self.theclass(2001, 1, 1, 0, 5, 17, tzoffset=35) ! # same thing in UTC. ! e = self.theclass(2000, 12, 31, 23, 30, 17, tzoffset=0) self.assertEqual(d, e) self.assertEqual(hash(d), hash(e)) --- 415,420 ---- self.assertEqual(dic[e], 2) ! d = self.theclass(2001, 1, 1, 0, 5, 17) ! e = self.theclass(2001, 1, 1, 0, 5, 17) self.assertEqual(d, e) self.assertEqual(hash(d), hash(e)) *************** *** 498,506 **** def test_isoformat(self): ! t = self.theclass(2, 3, 2, 4, 5, 1, 123, tzoffset=-120) ! self.assertEqual(t.isoformat(), "0002-03-02T04:05:01.000123-02:00") ! self.assertEqual(t.isoformat(' '), "0002-03-02 04:05:01.000123-02:00") ! self.assertEqual(t.utcisoformat(), "0002-03-02T06:05:01.000123Z") ! self.assertEqual(t.utcisoformat(' '), "0002-03-02 06:05:01.000123Z") def test_tmxxx(self): --- 481,488 ---- def test_isoformat(self): ! t = self.theclass(2, 3, 2, 4, 5, 1, 123) ! self.assertEqual(t.isoformat(), "0002-03-02T04:05:01.000123") ! self.assertEqual(t.isoformat('T'), "0002-03-02T04:05:01.000123") ! self.assertEqual(t.isoformat(' '), "0002-03-02 04:05:01.000123") def test_tmxxx(self): *************** *** 514,518 **** (3*60 - 12) * 1000000) dt2 = self.theclass(tm.year, tm.month, tm.day, tm.hour, tm.minute, ! tm.second, tm.microsecond, tzoffset=0) self.assertEqual(dt, dt2) self.assertEqual(timestamp, tm.time()) --- 496,500 ---- (3*60 - 12) * 1000000) dt2 = self.theclass(tm.year, tm.month, tm.day, tm.hour, tm.minute, ! tm.second, tm.microsecond) self.assertEqual(dt, dt2) self.assertEqual(timestamp, tm.time()) *************** *** 521,535 **** t = self.theclass(2002, 3, 2, 18, 3, 5, 123) self.assertEqual(t.ctime(), "Sat Mar 2 18:03:05 2002") - # XXX Can only test utcctime() in known timezone :-( - # XXX What about the southern hemisphere, where this is DST? - import time - if time.timezone == 5*3600: - self.assertEqual(t.utcctime(), "Sat Mar 2 23:03:05 2002") - elif time.timezone == 0: - self.assertEqual(t.utcctime(), "Sat Mar 2 18:03:05 2002") - elif time.timezone == 3600: - self.assertEqual(t.utcctime(), "Sat Mar 2 17:03:05 2002") - else: - self.fail("Can't test utcctime()") --- 503,506 ---- From fdrake@users.sourceforge.net Wed Mar 6 02:29:33 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 05 Mar 2002 18:29:33 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libfuncs.tex,1.101,1.102 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv16956/lib Modified Files: libfuncs.tex Log Message: Added missing version annotation for dict(). Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.101 retrieving revision 1.102 diff -C2 -d -r1.101 -r1.102 *** libfuncs.tex 23 Feb 2002 04:40:15 -0000 1.101 --- libfuncs.tex 6 Mar 2002 02:29:30 -0000 1.102 *************** *** 202,205 **** --- 202,207 ---- \item \code{dict([(i-1, i) for i in (2, 3)])} \end{itemize} + + \versionadded{2.2} \end{funcdesc} From fdrake@users.sourceforge.net Wed Mar 6 02:29:52 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 05 Mar 2002 18:29:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libfuncs.tex,1.100.4.1,1.100.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv17016/lib Modified Files: Tag: release22-maint libfuncs.tex Log Message: Added missing version annotation for dict(). Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.100.4.1 retrieving revision 1.100.4.2 diff -C2 -d -r1.100.4.1 -r1.100.4.2 *** libfuncs.tex 23 Feb 2002 08:31:37 -0000 1.100.4.1 --- libfuncs.tex 6 Mar 2002 02:29:50 -0000 1.100.4.2 *************** *** 202,205 **** --- 202,207 ---- \item \code{dict([(i-1, i) for i in (2, 3)])} \end{itemize} + + \versionadded{2.2} \end{funcdesc} From fdrake@users.sourceforge.net Wed Mar 6 04:06:01 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 05 Mar 2002 20:06:01 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.c,1.3,1.4 datetime.h,1.2,1.3 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv2001 Modified Files: datetime.c datetime.h Log Message: Make the corresponding changes to remove tzoffset support from the datetime type. Guido made the changes to the Python implementation earlier. Index: datetime.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** datetime.c 4 Mar 2002 21:20:54 -0000 1.3 --- datetime.c 6 Mar 2002 04:05:59 -0000 1.4 *************** *** 19,23 **** #define GET_SECOND(o) PyDateTime_GET_SECOND(o) #define GET_MICROSECOND(o) PyDateTime_GET_MICROSECOND(o) - #define GET_TZOFFSET(o) PyDateTime_GET_TZOFFSET(o) /* Set accessors. */ --- 19,22 ---- *************** *** 32,37 **** ((o)->data[8] = ((v) & 0x00ff00) >> 0), \ ((o)->data[9] = ((v) & 0x00ff00))) - #define SET_TZOFFSET(o, v) (((o)->data[10] = ((v) & 0xff00) >> 8), \ - ((o)->data[11] = ((v) & 0x00ff))) static PyObject * --- 31,34 ---- *************** *** 87,101 **** PyDateTime_Object *self = NULL; long int year, month, day, hour = 0, minute = 0, second = 0, usecond = 0; - long int tzoffset; - PyObject *tzoffset_object = Py_None; static char * keywords[] = { ! "year", "month", "day", "hour", "minute", "second", "microsecond", ! "tzoffset", NULL }; ! if (PyArg_ParseTupleAndKeywords(args, kw, "lll|llllO", keywords, &year, &month, &day, &hour, &minute, ! &second, &usecond, &tzoffset_object)) { if (year < MINYEAR || year > MAXYEAR) { PyErr_SetString(PyExc_ValueError, "year is out of range"); --- 84,95 ---- PyDateTime_Object *self = NULL; long int year, month, day, hour = 0, minute = 0, second = 0, usecond = 0; static char * keywords[] = { ! "year", "month", "day", "hour", "minute", "second", "microsecond", NULL }; ! if (PyArg_ParseTupleAndKeywords(args, kw, "lll|llll", keywords, &year, &month, &day, &hour, &minute, ! &second, &usecond)) { if (year < MINYEAR || year > MAXYEAR) { PyErr_SetString(PyExc_ValueError, "year is out of range"); *************** *** 127,147 **** return NULL; } - if (tzoffset_object == Py_None) { - /* tzoffset == None not yet implemented */ - tzoffset = 0; - } - else { - tzoffset_object = PyNumber_Int(tzoffset_object); - if (tzoffset_object == NULL) - return NULL; - tzoffset = PyInt_AS_LONG(tzoffset_object); - Py_DECREF(tzoffset_object); - if (tzoffset < -1439 || tzoffset > 1439) { - PyErr_SetString(PyExc_ValueError, - "tzoffset must be in -1439..1439"); - return NULL; - } - tzoffset_object = NULL; - } self = PyObject_New(PyDateTime_Object, &PyDateTime_Type); if (self != NULL) { --- 121,124 ---- *************** *** 153,157 **** SET_SECOND(self, second); SET_MICROSECOND(self, usecond); - SET_TZOFFSET(self, tzoffset); } } --- 130,133 ---- *************** *** 202,211 **** } - static PyObject * - datetime_tzoffset(PyDateTime_Object *self, void *unused) - { - return (PyInt_FromLong(GET_TZOFFSET(self))); - } - static PyGetSetDef datetime_getset[] = { {"year",(getter)datetime_year}, --- 178,181 ---- *************** *** 216,220 **** {"second", (getter)datetime_second}, {"microsecond", (getter)datetime_microsecond}, - {"tzoffset", (getter)datetime_tzoffset}, {NULL} }; --- 186,189 ---- Index: datetime.h =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** datetime.h 5 Mar 2002 03:55:35 -0000 1.2 --- datetime.h 6 Mar 2002 04:05:59 -0000 1.3 *************** *** 5,9 **** #define DATETIME_H ! #define _PyDateTime_DATA_SIZE 12 typedef struct --- 5,9 ---- #define DATETIME_H ! #define _PyDateTime_DATA_SIZE 10 typedef struct *************** *** 27,33 **** | ((PyDateTime_Object*)o)->data[8] << 8\ | ((PyDateTime_Object*)o)->data[9]) - #define PyDateTime_GET_TZOFFSET(o) ((signed int) \ - (((PyDateTime_Object*)o)->data[10] << 8\ - | ((PyDateTime_Object*)o)->data[11])) #endif --- 27,30 ---- From fdrake@users.sourceforge.net Wed Mar 6 04:10:39 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 05 Mar 2002 20:10:39 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.54,1.55 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv2888 Modified Files: datetime.py Log Message: Fix up a docstring. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** datetime.py 6 Mar 2002 01:25:13 -0000 1.54 --- datetime.py 6 Mar 2002 04:10:37 -0000 1.55 *************** *** 701,710 **** def isoformat(self): ! """Return the time formatted according to ISO. This is 'YYYY-MM-DD'. - - Optional argument sep specifies the separator between date and - time, default 'T'. """ return "%04d-%02d-%02d" % (self.__year, self.__month, self.__day) --- 701,707 ---- def isoformat(self): ! """Return the date formatted according to ISO. This is 'YYYY-MM-DD'. """ return "%04d-%02d-%02d" % (self.__year, self.__month, self.__day) From fdrake@users.sourceforge.net Wed Mar 6 04:30:53 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 05 Mar 2002 20:30:53 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.c,1.4,1.5 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv5658 Modified Files: datetime.c Log Message: Fix SET_MICROSECOND() macro to actually store the value correctly. Add support for isoformat(), isoweekday(), weekday(). Added class attributes min, max. Moved instance creation to a separate function from the tp_new handler; this makes it easier to create instances using alternate constructors, or just in C code. Index: datetime.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** datetime.c 6 Mar 2002 04:05:59 -0000 1.4 --- datetime.c 6 Mar 2002 04:30:51 -0000 1.5 *************** *** 29,34 **** #define SET_SECOND(o, v) (PyDateTime_GET_SECOND(o) = (v)) #define SET_MICROSECOND(o, v) (((o)->data[7] = ((v) & 0xff0000) >> 16), \ ! ((o)->data[8] = ((v) & 0x00ff00) >> 0), \ ! ((o)->data[9] = ((v) & 0x00ff00))) static PyObject * --- 29,103 ---- #define SET_SECOND(o, v) (PyDateTime_GET_SECOND(o) = (v)) #define SET_MICROSECOND(o, v) (((o)->data[7] = ((v) & 0xff0000) >> 16), \ ! ((o)->data[8] = ((v) & 0x00ff00) >> 8), \ ! ((o)->data[9] = ((v) & 0x0000ff))) ! ! /* ! * General calendrical helper functions ! */ ! ! static int ! is_leap(int year) ! { ! return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); ! } ! ! static int ! days_in_month(int year, int month) ! { ! static int _days_in_month[] = { ! 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ! }; ! ! assert(month >= 1); ! assert(month <= 12); ! if (month == 2 && is_leap(year)) ! return 29; ! else ! return _days_in_month[month]; ! } ! ! static long ! days_before_year(int year) ! { ! int y = year - 1; ! return y*365 + y/4 - y/100 + y/400; ! } ! ! /* Each entry at index 1..12 gives the number of days before each ! * month on non-leap years. ! */ ! static int _days_before_month[] = { ! 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 ! }; ! ! static int ! days_before_month(int year, int month) ! { ! int days; ! ! assert(month >= 1); ! assert(month <= 12); ! days = _days_before_month[month]; ! if (month > 2 && is_leap(year)) ! ++days; ! return days; ! } ! ! static long ! ymd_to_ord(int year, int month, int day) ! { ! return days_before_year(year) + days_before_month(year, month) + day; ! } ! ! static int ! weekday(int year, int month, int day) ! { ! return (ymd_to_ord(year, month, day) + 6) % 7; ! } ! ! ! /* ! * PyDateTime_Object implementation ! */ static PyObject * *************** *** 58,80 **** } ! static int ! is_leap(int year) ! { ! return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); ! } ! ! static int ! days_in_month(int year, int month) { ! static int _days_in_month[] = { ! 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ! }; ! assert(month >= 1); ! assert(month <= 12); ! if (month == 2 && is_leap(year)) ! return 29; ! else ! return _days_in_month[month]; } --- 127,148 ---- } ! /* Create a datetime instance with no range checking. */ ! static PyObject * ! new_datetime(int year, int month, int day, int hour, int minute, ! int second, int usecond) { ! PyDateTime_Object *self; ! self = PyObject_New(PyDateTime_Object, &PyDateTime_Type); ! if (self != NULL) { ! SET_YEAR(self, year); ! SET_MONTH(self, month); ! SET_DAY(self, day); ! SET_HOUR(self, hour); ! SET_MINUTE(self, minute); ! SET_SECOND(self, second); ! SET_MICROSECOND(self, usecond); ! } ! return (PyObject *) self; } *************** *** 82,89 **** datetime_new(PyTypeObject *type, PyObject *args, PyObject *kw) { ! PyDateTime_Object *self = NULL; long int year, month, day, hour = 0, minute = 0, second = 0, usecond = 0; ! static char * keywords[] = { "year", "month", "day", "hour", "minute", "second", "microsecond", NULL }; --- 150,157 ---- datetime_new(PyTypeObject *type, PyObject *args, PyObject *kw) { ! PyObject *self = NULL; long int year, month, day, hour = 0, minute = 0, second = 0, usecond = 0; ! static char *keywords[] = { "year", "month", "day", "hour", "minute", "second", "microsecond", NULL }; *************** *** 121,136 **** return NULL; } ! self = PyObject_New(PyDateTime_Object, &PyDateTime_Type); ! if (self != NULL) { ! SET_YEAR(self, year); ! SET_MONTH(self, month); ! SET_DAY(self, day); ! SET_HOUR(self, hour); ! SET_MINUTE(self, minute); ! SET_SECOND(self, second); ! SET_MICROSECOND(self, usecond); ! } } ! return (PyObject *) self; } --- 189,195 ---- return NULL; } ! self = new_datetime(year, month, day, hour, minute, second, usecond); } ! return self; } *************** *** 189,192 **** --- 248,300 ---- }; + static PyObject * + datetime_isoformat(PyDateTime_Object *self, PyObject *args, PyObject *kw) + { + char buffer[128]; + char sep = 'T'; + + static char *keywords[] = {"sep", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kw, "|c:isoformat", keywords, &sep)) + return NULL; + + PyOS_snprintf(buffer, sizeof(buffer), + "%04d-%02d-%02d%c%02d:%02d:%02d.%06d", + GET_YEAR(self), GET_MONTH(self), GET_DAY(self), + sep, + GET_HOUR(self), GET_MINUTE(self), GET_SECOND(self), + GET_MICROSECOND(self)); + return PyString_FromString(buffer); + } + + static PyObject * + datetime_isoweekday(PyDateTime_Object *self) + { + int dow = weekday(GET_YEAR(self), GET_MONTH(self), GET_DAY(self)); + + return PyInt_FromLong(dow + 1); + } + + static PyObject * + datetime_weekday(PyDateTime_Object *self) + { + int dow = weekday(GET_YEAR(self), GET_MONTH(self), GET_DAY(self)); + + return PyInt_FromLong(dow); + } + + static PyMethodDef datetime_methods[] = { + {"isoformat", (PyCFunction)datetime_isoformat, METH_VARARGS|METH_KEYWORDS, + "Return the day of the week represented by the datetime.\n" + "Monday == 1 ... Sunday == 7"}, + {"isoweekday", (PyCFunction)datetime_isoweekday, METH_NOARGS, + "Return the day of the week represented by the datetime.\n" + "Monday == 1 ... Sunday == 7"}, + {"weekday", (PyCFunction)datetime_weekday, METH_NOARGS, + "Return the day of the week represented by the datetime.\n" + "Monday == 0 ... Sunday == 6"}, + {NULL} + }; + static char datetime_doc[] = "Basic date/time type."; *************** *** 223,227 **** 0, /* tp_iter */ 0, /* tp_iternext */ ! 0, /* tp_methods */ 0, /* tp_members */ datetime_getset, /* tp_getset */ --- 331,335 ---- 0, /* tp_iter */ 0, /* tp_iternext */ ! datetime_methods, /* tp_methods */ 0, /* tp_members */ datetime_getset, /* tp_getset */ *************** *** 242,246 **** {NULL, NULL, 0, NULL} }; ! void --- 350,354 ---- {NULL, NULL, 0, NULL} }; ! void *************** *** 248,254 **** --- 356,373 ---- { PyObject *m; + PyObject *d, *dt; if (PyType_Ready(&PyDateTime_Type) < 0) return; + + d = PyDateTime_Type.tp_dict; + dt = new_datetime(1, 1, 1, 0, 0, 0, 0); + if (dt == NULL || PyDict_SetItemString(d, "min", dt) < 0) + return; + Py_DECREF(dt); + dt = new_datetime(MAXYEAR, 12, 31, 23, 59, 59, 999999); + if (dt == NULL || PyDict_SetItemString(d, "max", dt) < 0) + return; + Py_DECREF(dt); m = Py_InitModule3("_datetime", functions, From fdrake@users.sourceforge.net Wed Mar 6 04:36:29 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 05 Mar 2002 20:36:29 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_cdatetime.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv6342 Modified Files: test_cdatetime.py Log Message: Add test that retrieves the basic attributes from the datetime instance which actually checks that the bit-shifting accessors do the right thing. Add the test of the isoformat() method now that we have it. Index: test_cdatetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_cdatetime.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_cdatetime.py 4 Mar 2002 20:44:19 -0000 1.1 --- test_cdatetime.py 6 Mar 2002 04:36:26 -0000 1.2 *************** *** 11,16 **** class TestDateTime(unittest.TestCase): def test_basic_attributes(self): ! dt = datetime(2002, 3, 1, 12, 0, 0) self.assertEqual(dt.year, 2002) self.assertEqual(dt.month, 3) --- 11,18 ---- class TestDateTime(unittest.TestCase): + theclass = datetime + def test_basic_attributes(self): ! dt = self.theclass(2002, 3, 1, 12, 0) self.assertEqual(dt.year, 2002) self.assertEqual(dt.month, 3) *************** *** 20,23 **** --- 22,44 ---- self.assertEqual(dt.second, 0) self.assertEqual(dt.microsecond, 0) + + def test_basic_attributes_nonzero(self): + # Make sure all attributes are non-zero so bugs in + # bit-shifting access show up. + dt = self.theclass(2002, 3, 1, 12, 59, 59, 8000) + self.assertEqual(dt.year, 2002) + self.assertEqual(dt.month, 3) + self.assertEqual(dt.day, 1) + self.assertEqual(dt.hour, 12) + self.assertEqual(dt.minute, 59) + self.assertEqual(dt.second, 59) + self.assertEqual(dt.microsecond, 8000) + + def test_isoformat(self): + t = self.theclass(2, 3, 2, 4, 5, 1, 123) + self.assertEqual(t.isoformat(), "0002-03-02T04:05:01.000123") + self.assertEqual(t.isoformat('T'), "0002-03-02T04:05:01.000123") + self.assertEqual(t.isoformat(' '), "0002-03-02 04:05:01.000123") + def test_suite(): From fdrake@users.sourceforge.net Wed Mar 6 04:37:32 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 05 Mar 2002 20:37:32 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.38,1.39 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv6487 Modified Files: test_datetime.py Log Message: Add the test for the bit-shifting accessors here as well, just to be sure we run all the tests the C implementation needs are also supported by the Python implementation. Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** test_datetime.py 6 Mar 2002 01:25:15 -0000 1.38 --- test_datetime.py 6 Mar 2002 04:37:30 -0000 1.39 *************** *** 326,329 **** --- 326,341 ---- self.assertEqual(dt.microsecond, 0) + def test_basic_attributes_nonzero(self): + # Make sure all attributes are non-zero so bugs in + # bit-shifting access show up. + dt = self.theclass(2002, 3, 1, 12, 59, 59, 8000) + self.assertEqual(dt.year, 2002) + self.assertEqual(dt.month, 3) + self.assertEqual(dt.day, 1) + self.assertEqual(dt.hour, 12) + self.assertEqual(dt.minute, 59) + self.assertEqual(dt.second, 59) + self.assertEqual(dt.microsecond, 8000) + def test_roundtrip(self): for dt in (self.theclass(1, 2, 3, 4, 5, 6, 7), From fdrake@users.sourceforge.net Wed Mar 6 05:53:36 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 05 Mar 2002 21:53:36 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.c,1.5,1.6 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv15873 Modified Files: datetime.c Log Message: Added implementation of isocalendar(). Index: datetime.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** datetime.c 6 Mar 2002 04:30:51 -0000 1.5 --- datetime.c 6 Mar 2002 05:53:34 -0000 1.6 *************** *** 96,99 **** --- 96,113 ---- } + static int + iso_week1_monday(int year) + { + int first_day = ymd_to_ord(year, 1, 1); + int first_weekday = (first_day + 6) % 7; + int week1_monday = first_day - first_weekday; + + #define THURSDAY 3 + if (first_weekday > THURSDAY) + week1_monday += 7; + #undef THURSDAY + return week1_monday; + } + /* *************** *** 249,252 **** --- 263,290 ---- static PyObject * + datetime_isocalendar(PyDateTime_Object *self) + { + int year = GET_YEAR(self); + int week1_monday = iso_week1_monday(year); + long today = ymd_to_ord(year, GET_MONTH(self), GET_DAY(self)); + int week = (today - week1_monday) / 7; + int day = (today - week1_monday) % 7; + + if (week < 0) { + --year; + week1_monday = iso_week1_monday(year); + week = (today - week1_monday) / 7; + day = (today - week1_monday) % 7; + } + else if (week >= 52 && + today >= iso_week1_monday(year + 1)) { + ++year; + week = 0; + } + return Py_BuildValue("iii", year, week + 1, day + 1); + } + + + static PyObject * datetime_isoformat(PyDateTime_Object *self, PyObject *args, PyObject *kw) { *************** *** 285,295 **** static PyMethodDef datetime_methods[] = { ! {"isoformat", (PyCFunction)datetime_isoformat, METH_VARARGS|METH_KEYWORDS, "Return the day of the week represented by the datetime.\n" "Monday == 1 ... Sunday == 7"}, ! {"isoweekday", (PyCFunction)datetime_isoweekday, METH_NOARGS, "Return the day of the week represented by the datetime.\n" "Monday == 1 ... Sunday == 7"}, ! {"weekday", (PyCFunction)datetime_weekday, METH_NOARGS, "Return the day of the week represented by the datetime.\n" "Monday == 0 ... Sunday == 6"}, --- 323,337 ---- static PyMethodDef datetime_methods[] = { ! {"isocalendar", (PyCFunction)datetime_isocalendar, METH_NOARGS, ! "Return a 3-tuple containing ISO year, week number, and weekday.\n\n" ! "The first ISO week of the year is the (Mon-Sun) week containing the\n" ! "year's first Thursday; everything rest derives from that."}, ! {"isoformat", (PyCFunction)datetime_isoformat, METH_VARARGS|METH_KEYWORDS, "Return the day of the week represented by the datetime.\n" "Monday == 1 ... Sunday == 7"}, ! {"isoweekday", (PyCFunction)datetime_isoweekday, METH_NOARGS, "Return the day of the week represented by the datetime.\n" "Monday == 1 ... Sunday == 7"}, ! {"weekday", (PyCFunction)datetime_weekday, METH_NOARGS, "Return the day of the week represented by the datetime.\n" "Monday == 0 ... Sunday == 6"}, From fdrake@users.sourceforge.net Wed Mar 6 05:55:02 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 05 Mar 2002 21:55:02 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_cdatetime.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv15991 Modified Files: test_cdatetime.py Log Message: Add the tests for isocalendar(), isoformat(), isoweekday(), and weekday(), but comment out the parts that use a timedelta object since that doesnt Index: test_cdatetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_cdatetime.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_cdatetime.py 6 Mar 2002 04:36:26 -0000 1.2 --- test_cdatetime.py 6 Mar 2002 05:55:00 -0000 1.3 *************** *** 35,38 **** --- 35,94 ---- self.assertEqual(dt.microsecond, 8000) + def test_isocalendar(self): + # Check examples from + # http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm + for i in range(7): + d = self.theclass(2003, 12, 22+i) + self.assertEqual(d.isocalendar(), (2003, 52, i+1)) + ## d = self.theclass(2003, 12, 29) + timedelta(i) + ## self.assertEqual(d.isocalendar(), (2004, 1, i+1)) + d = self.theclass(2004, 1, 5+i) + self.assertEqual(d.isocalendar(), (2004, 2, i+1)) + d = self.theclass(2009, 12, 21+i) + self.assertEqual(d.isocalendar(), (2009, 52, i+1)) + ## d = self.theclass(2009, 12, 28) + timedelta(i) + ## self.assertEqual(d.isocalendar(), (2009, 53, i+1)) + d = self.theclass(2010, 1, 4+i) + self.assertEqual(d.isocalendar(), (2010, 1, i+1)) + + def test_iso_long_years(self): + # Calculate long ISO years and compare to table from + # http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm + ISO_LONG_YEARS_TABLE = """ + 4 32 60 88 + 9 37 65 93 + 15 43 71 99 + 20 48 76 + 26 54 82 + + 105 133 161 189 + 111 139 167 195 + 116 144 172 + 122 150 178 + 128 156 184 + + 201 229 257 285 + 207 235 263 291 + 212 240 268 296 + 218 246 274 + 224 252 280 + + 303 331 359 387 + 308 336 364 392 + 314 342 370 398 + 320 348 376 + 325 353 381 + """ + iso_long_years = map(int, ISO_LONG_YEARS_TABLE.split()) + iso_long_years.sort() + L = [] + for i in range(400): + d = self.theclass(2000+i, 12, 31) + d1 = self.theclass(1600+i, 12, 31) + self.assertEqual(d.isocalendar()[1:], d1.isocalendar()[1:]) + if d.isocalendar()[1] == 53: + L.append(i) + self.assertEqual(L, iso_long_years) + def test_isoformat(self): t = self.theclass(2, 3, 2, 4, 5, 1, 123) *************** *** 40,43 **** --- 96,108 ---- self.assertEqual(t.isoformat('T'), "0002-03-02T04:05:01.000123") self.assertEqual(t.isoformat(' '), "0002-03-02 04:05:01.000123") + + def test_weekday(self): + for i in range(7): + # March 4, 2002 is a Monday + self.assertEqual(self.theclass(2002, 3, 4+i).weekday(), i) + self.assertEqual(self.theclass(2002, 3, 4+i).isoweekday(), i+1) + # January 2, 1956 is a Monday + self.assertEqual(self.theclass(1956, 1, 2+i).weekday(), i) + self.assertEqual(self.theclass(1956, 1, 2+i).isoweekday(), i+1) From fdrake@acm.org Wed Mar 6 05:59:08 2002 From: fdrake@acm.org (Fred Drake) Date: Wed, 06 Mar 2002 00:59:08 -0500 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_cdatetime.py,1.2,1.3 In-Reply-To: Message-ID: On Tue, 05 Mar 2002 21:55:02 -0800 "Fred L. Drake" wrote: > but comment out the parts that use a timedelta object > since that doesnt Ooops! That was supposed to be "... doesn't exist yet in the C implementation." -Fred -- Fred L. Drake, Jr. PythonLabs at Zope Corporation From bwarsaw@users.sourceforge.net Wed Mar 6 13:16:10 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Wed, 06 Mar 2002 05:16:10 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0284.txt,NONE,1.1 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv28216 Added Files: pep-0284.txt Log Message: PEP 284, Integer for-loops, Eppstein & Ewing --- NEW FILE: pep-0284.txt --- PEP: 284 Title: Integer for-loops Version: $Revision: 1.1 $ Last-Modified: $Date: 2002/03/06 13:16:08 $ Author: eppstein@ics.uci.edu (David Eppstein), greg@cosc.canterbury.ac.nz (Greg Ewing) Status: Draft Type: Standards Track Created: 1-Mar-2002 Python-Version: 2.3 Post-History: Abstract This PEP proposes to simplify iteration over intervals of integers, by extending the range of expressions allowed after a "for" keyword to allow three-way comparisons such as for lower <= var < upper: in place of the current for item in list: syntax. The resulting loop or list iteration will loop over all values of var that make the comparison true, starting from the left endpoint of the given interval. Rationale One of the most common uses of for-loops in Python is to iterate over an interval of integers. Python provides functions range() and xrange() to generate lists and iterators for such intervals, which work best for the most frequent case: half-open intervals increasing from zero. However, the range() syntax is more awkward for open or closed intervals, and lacks symmetry when reversing the order of iteration. In addition, the call to an unfamiliar function makes it difficult for newcomers to Python to understand code that uses range() or xrange(). The perceived lack of a natural, intuitive integer iteration syntax has led to heated debate on python-list, and spawned at least four PEPs before this one. PEP 204 [1] (rejected) proposed to re-use Python's slice syntax for integer ranges, leading to a terser syntax but not solving the readability problem of multi-argument range(). PEP 212 [2] (deferred) proposed several syntaxes for directly converting a list to a sequence of integer indices, in place of the current idiom range(len(list)) for such conversion, and PEP 281 [3] proposes to simplify the same idiom by allowing it to be written as range(list). PEP 276 [4] proposes to allow automatic conversion of integers to iterators, simplifying the most common half-open case but not addressing the complexities of other types of interval. Additional alternatives have been discussed on python-list. The solution described here is to allow a three-way comparison after a "for" keyword, both in the context of a for-loop and of a list comprehension: for lower <= var < upper: This would cause iteration over an interval of consecutive integers, beginning at the left bound in the comparison and ending at the right bound. The exact comparison operations used would determine whether the interval is open or closed at either end and whether the integers are considered in ascending or descending order. This syntax closely matches standard mathematical notation, so is likely to be more familiar to Python novices than the current range() syntax. Open and closed interval endpoints are equally easy to express, and the reversal of an integer interval can be formed simply by swapping the two endpoints and reversing the comparisons. In addition, the semantics of such a loop would closely resemble one way of interpreting the existing Python for-loops: for item in list iterates over exactly those values of item that cause the expression item in list to be true. Similarly, the new format for lower <= var < upper: would iterate over exactly those integer values of var that cause the expression lower <= var < upper to be true. Specification We propose to extend the syntax of a for statement, currently for_stmt: "for" target_list "in" expression_list ":" suite ["else" ":" suite] as described below: for_stmt: "for" for_test ":" suite ["else" ":" suite] for_test: target_list "in" expression_list | or_expr less_comp or_expr less_comp or_expr | or_expr greater_comp identifier greater_comp or_expr less_comp: "<" | "<=" greater_comp: ">" | ">=" Similarly, we propose to extend the syntax of list comprehensions, currently list_for: "for" expression_list "in" testlist [list_iter] by replacing it with: list_for: "for" for_test [list_iter] In all cases the expression formed by for_test would be subject to the same precedence rules as comparisons in expressions. The two comp_operators in a for_test must be required to be both of similar types, unlike chained comparisons in expressions which do not have such a restriction. We refer to the two or_expr's occurring on the left and right sides of the for-loop syntax as the bounds of the loop, and the middle or_expr as the variable of the loop. When a for-loop using the new syntax is executed, the expressions for both bounds will be evaluated, and an iterator object created that iterates through all integers between the two bounds according to the comparison operations used. The iterator will begin with an integer equal or near to the left bound, and then step through the remaining integers with a step size of +1 or -1 if the comparison operation is in the set described by less_comp or greater_comp respectively. The execution will then proceed as if the expression had been for variable in iterator where "variable" refers to the variable of the loop and "iterator" refers to the iterator created for the given integer interval. The values taken by the loop variable in an integer for-loop may be either plain integers or long integers, according to the magnitude of the bounds. Both bounds of an integer for-loop must evaluate to a real numeric type (integer, long, or float). Any other value will cause the for-loop statement to raise a TypeError exception. Issues The following issues were raised in discussion of this and related proposals on the Python list. - Should the right bound be evaluated once, or every time through the loop? Clearly, it only makes sense to evaluate the left bound once. For reasons of consistency and efficiency, we have chosen the same convention for the right bound. - Although the new syntax considerably simplifies integer for-loops, list comprehensions using the new syntax are not as simple. We feel that this is appropriate since for-loops are more frequent than comprehensions. - The proposal does not allow access to integer iterator objects such as would be created by xrange. True, but we see this as a shortcoming in the general list-comprehension syntax, beyond the scope of this proposal. In addition, xrange() will still be available. - The proposal does not allow increments other than 1 and -1. More general arithmetic progressions would need to be created by range() or xrange(), or by a list comprehension syntax such as [2*x for 0 <= x <= 100] - The position of the loop variable in the middle of a three-way comparison is not as apparent as the variable in the present for item in list syntax, leading to a possible loss of readability. We feel that this loss is outweighed by the increase in readability from a natural integer iteration syntax. - To some extent, this PEP addresses the same issues as PEP 276 [4]. We feel that the two PEPs are not in conflict since PEP 276 is primarily concerned with half-open ranges starting in 0 (the easy case of range()) while this PEP is primarily concerned with simplifying all other cases. However, if this PEP is approved, its new simpler syntax for integer loops could to some extent reduce the motivation for PEP 276. - It is not clear whether it makes sense to allow floating point bounds for an integer loop: if a float represents an inexact value, how can it be used to determine an exact sequence of integers? On the other hand, disallowing float bounds would make it difficult to use floor() and ceiling() in integer for-loops, as it is difficult to use them now with range(). We have erred on the side of flexibility, but this may lead to some implementation difficulties in determining the smallest and largest integer values that would cause a given comparison to be true. - Should types other than int, long, and float be allowed as bounds? Another choice would be to convert all bounds to integers by int(), and allow as bounds anything that can be so converted instead of just floats. However, this would change the semantics: 0.3 <= x is not the same as int(0.3) <= x, and it would be confusing for a loop with 0.3 as lower bound to start at zero. Also, in general int(f) can be very far from f. Implementation An implementation is not available at this time. Implementation is not expected to pose any great difficulties: the new syntax could, if necessary, be recognized by parsing a general expression after each "for" keyword and testing whether the top level operation of the expression is "in" or a three-way comparison. The Python compiler would convert any instance of the new syntax into a loop over the items in a special iterator object. References [1] PEP 204, Range Literals http://www.python.org/peps/pep-0204.html [2] PEP 212, Loop Counter Iteration http://www.python.org/peps/pep-0212.html [3] PEP 281, Loop Counter Iteration with range and xrange http://www.python.org/peps/pep-0281.html [4] PEP 276, Simple Iterator for ints http://www.python.org/peps/pep-0276.html Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil fill-column: 70 End: From bwarsaw@users.sourceforge.net Wed Mar 6 13:16:25 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Wed, 06 Mar 2002 05:16:25 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.159,1.160 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv28282 Modified Files: pep-0000.txt Log Message: Added PEP 284, Integer for-loops, Eppstein & Ewing Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.159 retrieving revision 1.160 diff -C2 -d -r1.159 -r1.160 *** pep-0000.txt 27 Feb 2002 23:02:11 -0000 1.159 --- pep-0000.txt 6 Mar 2002 13:16:22 -0000 1.160 *************** *** 250,253 **** --- 250,254 ---- S 282 A Logging System Mick I 283 Python 2.3 Release Schedule Hylton + S 284 Integer for-loops Eppstein, Ewing SR 666 Reject Foolish Indentation Creighton *************** *** 276,285 **** Drake, Fred fdrake@acm.org Dubois, Paul F. paul@pfdubois.com Evans, Clark C. cce@clarkevans.com Giacometti, Frédéric B. fred@arakne.com Goodger, David dgoodger@bigfoot.com Griffin, Grant g2@iowegian.com Hetland, Magnus Lie magnus@hetland.org ! Hettinger, Raymond D. othello@javanet.com Hodgson, Neil neilh@scintilla.org Hudson, Michael mwh@python.net --- 277,288 ---- Drake, Fred fdrake@acm.org Dubois, Paul F. paul@pfdubois.com + Eppstein, David eppstein@ics.uci.edu Evans, Clark C. cce@clarkevans.com + Ewing, Greg greg@cosc.canterbury.ac.nz Giacometti, Frédéric B. fred@arakne.com Goodger, David dgoodger@bigfoot.com Griffin, Grant g2@iowegian.com Hetland, Magnus Lie magnus@hetland.org ! Hettinger, Raymond D. python@rcn.com Hodgson, Neil neilh@scintilla.org Hudson, Michael mwh@python.net From mwh@users.sourceforge.net Wed Mar 6 17:18:17 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Wed, 06 Mar 2002 09:18:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_structseq.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv26183 Modified Files: test_structseq.py Log Message: Test for [ 526039 ] devious code can crash structseqs Bugfix candidate. Index: test_structseq.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_structseq.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_structseq.py 31 Oct 2001 03:46:14 -0000 1.2 --- test_structseq.py 6 Mar 2002 17:18:15 -0000 1.3 *************** *** 14,16 **** --- 14,28 ---- vereq(t[i:j], astuple[i:j]) + # Devious code could crash structseqs' contructors + class C: + def __getitem__(self, i): + raise IndexError + def __len__(self): + return 9 + + try: + repr(time.struct_time(C())) + except: + pass + # XXX more needed From mwh@python.net Wed Mar 6 17:22:30 2002 From: mwh@python.net (Michael Hudson) Date: 06 Mar 2002 17:22:30 +0000 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_structseq.py,1.2,1.3 In-Reply-To: Michael Hudson's message of "Wed, 06 Mar 2002 09:18:17 -0800" References: Message-ID: <2m1yex1ui1.fsf@starship.python.net> Michael Hudson writes: > Update of /cvsroot/python/python/dist/src/Lib/test > In directory usw-pr-cvs1:/tmp/cvs-serv26183 > > Modified Files: > test_structseq.py > Log Message: > Test for > > [ 526039 ] devious code can crash structseqs > > Bugfix candidate. Hmm, I made some checkins before this one: to Lib/os.py, Objects/structseq.c and Lib/test/pickletester.py. I wonder where they went? Cheers, M. -- Every now and then, Google doesn't throw up what I need so I start checking Altavista, Yahoo, etc. In almost every single case, I am brutally reminded why I use Google in the first place. -- John Riddoch, asr From mwh@users.sourceforge.net Wed Mar 6 17:11:20 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Wed, 06 Mar 2002 09:11:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib os.py,1.51,1.52 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv22847 Modified Files: os.py Log Message: Special support for pickling os.stat and os.stat_vfs results portably (the types come from different modules on different platforms). Added tests for pickling these types. May be a bugfix candidate. Index: os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/os.py,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** os.py 24 Feb 2002 05:32:32 -0000 1.51 --- os.py 6 Mar 2002 17:11:17 -0000 1.52 *************** *** 603,604 **** --- 603,624 ---- return stdin, stdout __all__.append("popen4") + + import copy_reg as _copy_reg + + def _make_stat_result(tup, dict): + return stat_result(tup, dict) + + def _pickle_stat_result(sr): + (type, args) = sr.__reduce__() + return (_make_stat_result, args) + + _copy_reg.pickle(stat_result, _pickle_stat_result,_make_stat_result) + + def _make_statvfs_result(tup, dict): + return statvfs_result(tup, dict) + + def _pickle_statvfs_result(sr): + (type, args) = sr.__reduce__() + return (_make_statvfs_result, args) + + _copy_reg.pickle(statvfs_result, _pickle_statvfs_result,_make_statvfs_result) From mwh@users.sourceforge.net Wed Mar 6 17:11:20 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Wed, 06 Mar 2002 09:11:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test pickletester.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv22847/test Modified Files: pickletester.py Log Message: Special support for pickling os.stat and os.stat_vfs results portably (the types come from different modules on different platforms). Added tests for pickling these types. May be a bugfix candidate. Index: pickletester.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/pickletester.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** pickletester.py 5 Mar 2002 13:27:58 -0000 1.13 --- pickletester.py 6 Mar 2002 17:11:18 -0000 1.14 *************** *** 255,258 **** --- 255,269 ---- u = self.loads(s) self.assertEqual(t, u) + import os + if hasattr(os, "stat"): + t = os.stat(os.curdir) + s = self.dumps(t) + u = self.loads(s) + self.assertEqual(t, u) + if hasattr(os, "statvfs"): + t = os.statvfs(os.curdir) + s = self.dumps(t) + u = self.loads(s) + self.assertEqual(t, u) class AbstractPickleModuleTests(unittest.TestCase): From mwh@users.sourceforge.net Wed Mar 6 17:07:51 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Wed, 06 Mar 2002 09:07:51 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects structseq.c,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv20601 Modified Files: structseq.c Log Message: Apply (my) patch: [ 526072 ] pickling os.stat results round II structseq's constructors can now take "invisible" fields in a dict. Gave the constructors better error messages. their __reduce__ method puts these fields in a dict. (this is all in aid of getting os.stat_result's to pickle portably) Also fixes [ 526039 ] devious code can crash structseqs Thought needed about how much of this counts as a bugfix. Certainly #526039 needs to be fixed. Index: structseq.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/structseq.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** structseq.c 5 Mar 2002 13:27:57 -0000 1.4 --- structseq.c 6 Mar 2002 17:07:49 -0000 1.5 *************** *** 85,121 **** { PyObject *arg = NULL; PyStructSequence *res = NULL; ! int len, required_len, i; ! static char *kwlist[] = {"sequence", 0}; ! static char msgbuf[128]; ! if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:structseq", ! kwlist, &arg)) return NULL; ! if (!PySequence_Check(arg)) { ! PyErr_SetString(PyExc_TypeError, ! "constructor requires a sequence"); return NULL; } ! len = PySequence_Length(arg); ! required_len = REAL_SIZE_TP(type); ! if (len != required_len) { ! PyOS_snprintf( ! msgbuf, sizeof(msgbuf), ! "constructor takes exactly %d arguments (%d given)", ! required_len, ! len); ! PyErr_SetString(PyExc_TypeError, msgbuf); return NULL; } res = (PyStructSequence*) PyStructSequence_New(type); for (i = 0; i < len; ++i) { ! /* INCREF???? XXXX */ ! res->ob_item[i] = PySequence_GetItem(arg, i); } return (PyObject*) res; } --- 85,161 ---- { PyObject *arg = NULL; + PyObject *dict = NULL; + PyObject *ob; PyStructSequence *res = NULL; ! int len, min_len, max_len, i; ! static char *kwlist[] = {"sequence", "dict", 0}; ! if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:structseq", ! kwlist, &arg, &dict)) return NULL; ! arg = PySequence_Fast(arg, "constructor requires a sequence"); ! ! if (!arg) { return NULL; } ! if (dict && !PyDict_Check(dict)) { ! PyErr_Format(PyExc_TypeError, ! "%.500s() takes a dict as second arg, if any", ! type->tp_name); ! Py_DECREF(arg); return NULL; } + len = PySequence_Fast_GET_SIZE(arg); + min_len = VISIBLE_SIZE_TP(type); + max_len = REAL_SIZE_TP(type); + + if (min_len != max_len) { + if (len < min_len) { + PyErr_Format(PyExc_TypeError, + "%.500s() takes an at least %d-sequence (%d-sequence given)", + type->tp_name, min_len, len); + Py_DECREF(arg); + return NULL; + } + + if (len > max_len) { + PyErr_Format(PyExc_TypeError, + "%.500s() takes an at most %d-sequence (%d-sequence given)", + type->tp_name, max_len, len); + Py_DECREF(arg); + return NULL; + } + } + else { + if (len != min_len) { + PyErr_Format(PyExc_TypeError, + "%.500s() takes a %d-sequence (%d-sequence given)", + type->tp_name, min_len, len); + Py_DECREF(arg); + return NULL; + } + } + res = (PyStructSequence*) PyStructSequence_New(type); for (i = 0; i < len; ++i) { ! PyObject *v = PySequence_Fast_GET_ITEM(arg, i); ! Py_INCREF(v); ! res->ob_item[i] = v; ! } ! for (; i < max_len; ++i) { ! if (dict && (ob = PyDict_GetItemString( ! dict, type->tp_members[i].name))) { ! } ! else { ! ob = Py_None; ! } ! Py_INCREF(ob); ! res->ob_item[i] = ob; } + Py_DECREF(arg); return (PyObject*) res; } *************** *** 193,211 **** { PyObject* tup; ! long n_fields; int i; n_fields = REAL_SIZE(self); ! tup = PyTuple_New(n_fields); if (!tup) { return NULL; } ! for (i = 0; i < n_fields; i++) { Py_INCREF(self->ob_item[i]); PyTuple_SET_ITEM(tup, i, self->ob_item[i]); } ! return Py_BuildValue("(O(O))", self->ob_type, tup); } --- 233,264 ---- { PyObject* tup; ! PyObject* dict; ! long n_fields, n_visible_fields; int i; n_fields = REAL_SIZE(self); ! n_visible_fields = VISIBLE_SIZE(self); ! tup = PyTuple_New(n_visible_fields); if (!tup) { return NULL; } ! dict = PyDict_New(); ! if (!dict) { ! Py_DECREF(tup); ! return NULL; ! } ! ! for (i = 0; i < n_visible_fields; i++) { Py_INCREF(self->ob_item[i]); PyTuple_SET_ITEM(tup, i, self->ob_item[i]); } ! for (; i < n_fields; i++) { ! PyDict_SetItemString(dict, self->ob_type->tp_members[i].name, ! self->ob_item[i]); ! } ! ! return Py_BuildValue("(O(OO))", self->ob_type, tup, dict); } From neal@metaslash.com Wed Mar 6 17:34:28 2002 From: neal@metaslash.com (Neal Norwitz) Date: Wed, 06 Mar 2002 12:34:28 -0500 Subject: [Python-checkins] CVS: python/dist/src/Lib os.py,1.51,1.52 References: Message-ID: <3C865324.C0D3B332@metaslash.com> Michael: I'm curious why you did import copy_reg as _copy_reg. Is it because you don't want clutter when doing 'from os import *'? Would it be better to do: import copy_reg # use copy_reg del copy_reg ? Neal -- Michael Hudson wrote: > > Update of /cvsroot/python/python/dist/src/Lib > In directory usw-pr-cvs1:/tmp/cvs-serv22847 > > Modified Files: > os.py > Log Message: > Special support for pickling os.stat and os.stat_vfs results portably > (the types come from different modules on different platforms). > > Added tests for pickling these types. > > May be a bugfix candidate. > > Index: os.py > =================================================================== > RCS file: /cvsroot/python/python/dist/src/Lib/os.py,v > retrieving revision 1.51 > retrieving revision 1.52 > diff -C2 -d -r1.51 -r1.52 > *** os.py 24 Feb 2002 05:32:32 -0000 1.51 > --- os.py 6 Mar 2002 17:11:17 -0000 1.52 > *************** > *** 603,604 **** > --- 603,624 ---- > return stdin, stdout > __all__.append("popen4") > + > + import copy_reg as _copy_reg > + > + def _make_stat_result(tup, dict): > + return stat_result(tup, dict) > + > + def _pickle_stat_result(sr): > + (type, args) = sr.__reduce__() > + return (_make_stat_result, args) > + > + _copy_reg.pickle(stat_result, _pickle_stat_result,_make_stat_result) > + > + def _make_statvfs_result(tup, dict): > + return statvfs_result(tup, dict) > + > + def _pickle_statvfs_result(sr): > + (type, args) = sr.__reduce__() > + return (_make_statvfs_result, args) > + > + _copy_reg.pickle(statvfs_result, _pickle_statvfs_result,_make_statvfs_result) From bwarsaw@users.sourceforge.net Wed Mar 6 20:48:24 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Wed, 06 Mar 2002 12:48:24 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.160,1.161 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv31219 Modified Files: pep-0000.txt Log Message: Added PEP 284 to the "Open PEPs" category (although Guido will likely reorganize this soon ;). Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.160 retrieving revision 1.161 diff -C2 -d -r1.160 -r1.161 *** pep-0000.txt 6 Mar 2002 13:16:22 -0000 1.160 --- pep-0000.txt 6 Mar 2002 20:48:22 -0000 1.161 *************** *** 86,89 **** --- 86,90 ---- S 281 Loop Counter Iteration with range and xrange Hetland S 282 A Logging System Mick + S 284 Integer for-loops Eppstein, Ewing Finished PEPs (done, implemented in CVS) From bwarsaw@users.sourceforge.net Wed Mar 6 20:53:49 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Wed, 06 Mar 2002 12:53:49 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0284.txt,1.1,1.2 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv455 Modified Files: pep-0284.txt Log Message: An update from David Eppstein. Index: pep-0284.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0284.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pep-0284.txt 6 Mar 2002 13:16:08 -0000 1.1 --- pep-0284.txt 6 Mar 2002 20:53:47 -0000 1.2 *************** *** 115,119 **** for_test: target_list "in" expression_list | or_expr less_comp or_expr less_comp or_expr | ! or_expr greater_comp identifier greater_comp or_expr less_comp: "<" | "<=" greater_comp: ">" | ">=" --- 115,119 ---- for_test: target_list "in" expression_list | or_expr less_comp or_expr less_comp or_expr | ! or_expr greater_comp or_expr greater_comp or_expr less_comp: "<" | "<=" greater_comp: ">" | ">=" From jhylton@users.sourceforge.net Wed Mar 6 20:56:48 2002 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Wed, 06 Mar 2002 12:56:48 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0283.txt,1.2,1.3 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv1333 Modified Files: pep-0283.txt Log Message: Put "PEP" in front of PEP numbers. Index: pep-0283.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0283.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pep-0283.txt 27 Feb 2002 23:06:43 -0000 1.2 --- pep-0283.txt 6 Mar 2002 20:56:46 -0000 1.3 *************** *** 43,52 **** PEP isn't on this list, it's because I'm not a confident channeler. ! 266 Optimizing Global Variable/Attribute Access Montanaro ! 267 Optimized Access to Module Namespaces Hylton ! 269 Pgen Module for Python Riehl ! 273 Import Modules from Zip Archives Ahlstrom ! 280 Optimizing access to globals van Rossum ! 282 A Logging System Mick Copyright --- 43,52 ---- PEP isn't on this list, it's because I'm not a confident channeler. ! PEP 266 Optimizing Global Variable/Attribute Access Montanaro ! PEP 267 Optimized Access to Module Namespaces Hylton ! PEP 269 Pgen Module for Python Riehl ! PEP 273 Import Modules from Zip Archives Ahlstrom ! PEP 280 Optimizing access to globals van Rossum ! PEP 282 A Logging System Mick Copyright From jackjansen@users.sourceforge.net Wed Mar 6 21:57:49 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Wed, 06 Mar 2002 13:57:49 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Build _CG.carbon.mcp,1.2,1.2.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Build In directory usw-pr-cvs1:/tmp/cvs-serv22676/Python 2.2/Mac/Build Modified Files: Tag: release22-maint _CG.carbon.mcp Log Message: Backport of 1.3: CGStubLib wasn't weak-linked, fixed. Index: _CG.carbon.mcp =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Build/_CG.carbon.mcp,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 Binary files /tmp/cvsGwoSjw and /tmp/cvs2f9JhS differ From jackjansen@users.sourceforge.net Wed Mar 6 21:59:39 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Wed, 06 Mar 2002 13:59:39 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/cg cgsupport.py,1.2,1.2.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cg In directory usw-pr-cvs1:/tmp/cvs-serv23586/Python 2.2/Mac/Modules/cg Modified Files: Tag: release22-maint cgsupport.py Log Message: Backport of 1.4 and 1.5: Added support for SyncCGContextOriginWithPort Added ClipCGContextToRegion Index: cgsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/cgsupport.py,v retrieving revision 1.2 retrieving revision 1.2.6.1 diff -C2 -d -r1.2 -r1.2.6.1 *** cgsupport.py 13 Dec 2001 13:40:04 -0000 1.2 --- cgsupport.py 6 Mar 2002 21:59:37 -0000 1.2.6.1 *************** *** 18,21 **** --- 18,23 ---- from macsupport import * + CGrafPtr = OpaqueByValueType("CGrafPtr", "GrafObj") + RgnHandle = OpaqueByValueType("RgnHandle", "ResObj") # Create the type objects *************** *** 275,278 **** --- 277,296 ---- # ADD _methods initializer here execfile(INPUTFILE) + + # manual method, lives in Quickdraw.h + f = Method(void, 'SyncCGContextOriginWithPort', + (CGContextRef, 'ctx', InMode), + (CGrafPtr, 'port', InMode), + ) + CGContextRef_methods.append(f) + + # manual method, lives in Quickdraw.h + f = Method(void, 'ClipCGContextToRegion', + (CGContextRef, 'ctx', InMode), + (Rect, 'portRect', InMode), + (RgnHandle, 'region', InMode), + ) + CGContextRef_methods.append(f) + CreateCGContextForPort_body = """\ From jackjansen@users.sourceforge.net Wed Mar 6 21:59:47 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Wed, 06 Mar 2002 13:59:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/cg _CGmodule.c,1.3,1.3.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cg In directory usw-pr-cvs1:/tmp/cvs-serv23624/Python 2.2/Mac/Modules/cg Modified Files: Tag: release22-maint _CGmodule.c Log Message: Backport of 1.4 and 1.5: Added support for SyncCGContextOriginWithPort Added ClipCGContextToRegion Index: _CGmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/_CGmodule.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -C2 -d -r1.3 -r1.3.4.1 *** _CGmodule.c 18 Dec 2001 15:38:24 -0000 1.3 --- _CGmodule.c 6 Mar 2002 21:59:45 -0000 1.3.4.1 *************** *** 1116,1119 **** --- 1116,1150 ---- } + static PyObject *CGContextRefObj_SyncCGContextOriginWithPort(CGContextRefObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + CGrafPtr port; + if (!PyArg_ParseTuple(_args, "O&", + GrafObj_Convert, &port)) + return NULL; + SyncCGContextOriginWithPort(_self->ob_itself, + port); + Py_INCREF(Py_None); + _res = Py_None; + return _res; + } + + static PyObject *CGContextRefObj_ClipCGContextToRegion(CGContextRefObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + Rect portRect; + RgnHandle region; + if (!PyArg_ParseTuple(_args, "O&O&", + PyMac_GetRect, &portRect, + ResObj_Convert, ®ion)) + return NULL; + ClipCGContextToRegion(_self->ob_itself, + &portRect, + region); + Py_INCREF(Py_None); + _res = Py_None; + return _res; + } + static PyMethodDef CGContextRefObj_methods[] = { {"CGContextSaveGState", (PyCFunction)CGContextRefObj_CGContextSaveGState, 1, *************** *** 1229,1232 **** --- 1260,1267 ---- {"CGContextSetShouldAntialias", (PyCFunction)CGContextRefObj_CGContextSetShouldAntialias, 1, "(int shouldAntialias) -> None"}, + {"SyncCGContextOriginWithPort", (PyCFunction)CGContextRefObj_SyncCGContextOriginWithPort, 1, + "(CGrafPtr port) -> None"}, + {"ClipCGContextToRegion", (PyCFunction)CGContextRefObj_ClipCGContextToRegion, 1, + "(Rect portRect, RgnHandle region) -> None"}, {NULL, NULL, 0} }; From jackjansen@users.sourceforge.net Wed Mar 6 21:59:52 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Wed, 06 Mar 2002 13:59:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/cg CGStubLib,1.1,1.1.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cg In directory usw-pr-cvs1:/tmp/cvs-serv23661/Python 2.2/Mac/Modules/cg Modified Files: Tag: release22-maint CGStubLib Log Message: Backport of 1.4 and 1.5: Added support for SyncCGContextOriginWithPort Added ClipCGContextToRegion Index: CGStubLib =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/CGStubLib,v retrieving revision 1.1 retrieving revision 1.1.6.1 diff -C2 -d -r1.1 -r1.1.6.1 Binary files /tmp/cvsaeMwET and /tmp/cvsuiVkdD differ From jackjansen@users.sourceforge.net Wed Mar 6 21:59:56 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Wed, 06 Mar 2002 13:59:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/cg CGStubLib.exp,1.1,1.1.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cg In directory usw-pr-cvs1:/tmp/cvs-serv23696/Python 2.2/Mac/Modules/cg Modified Files: Tag: release22-maint CGStubLib.exp Log Message: Backport of 1.4 and 1.5: Added support for SyncCGContextOriginWithPort Added ClipCGContextToRegion Index: CGStubLib.exp =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/CGStubLib.exp,v retrieving revision 1.1 retrieving revision 1.1.6.1 diff -C2 -d -r1.1 -r1.1.6.1 *** CGStubLib.exp 13 Dec 2001 13:17:20 -0000 1.1 --- CGStubLib.exp 6 Mar 2002 21:59:54 -0000 1.1.6.1 *************** *** 57,58 **** --- 57,60 ---- CGContextRelease CreateCGContextForPort + SyncCGContextOriginWithPort + ClipCGContextToRegion From jackjansen@users.sourceforge.net Wed Mar 6 22:00:31 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Wed, 06 Mar 2002 14:00:31 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac ReadMe,1.38.4.2,1.38.4.2.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac In directory usw-pr-cvs1:/tmp/cvs-serv23958/Python 2.2/Mac Modified Files: Tag: release22-maint ReadMe Log Message: First stab at files for 2.2.1. Index: ReadMe =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/ReadMe,v retrieving revision 1.38.4.2 retrieving revision 1.38.4.2.2.1 diff -C2 -d -r1.38.4.2 -r1.38.4.2.2.1 *** ReadMe 26 Dec 2001 22:56:44 -0000 1.38.4.2 --- ReadMe 6 Mar 2002 22:00:29 -0000 1.38.4.2.2.1 *************** *** 1,3 **** ! How to install Python 2.2 on your Macintosh --------------------------------------------- --- 1,3 ---- ! How to install Python 2.2.1 on your Macintosh --------------------------------------------- *************** *** 36,96 **** If you want 68k support you will have get MacPython 1.5.2. - Toolbox module reorganization and more - -------------------------------------- - - You can safely skip this section if this is your first encounter with MacPython. - - This release has a new organization of the mac-specific modules, and in - general brings the MacPython folder structure more in line with - unix-Python. This is not only a good idea, it will also immensely - facilitate moving MacPython functionality to an OSX Python that is based - on Mach-O and the unix-Python distribution. But don't worry: MacPython - is definitely not dead yet, and the hope is that the transition will be - as seamless as possible. - - First a change that should not cause too much concern: :Mac:Plugins has - gone, and most of the dynamically loaded modules have moved to - :Lib:lib-dynload. - - Second, and more important: the toolbox modules, such as Res and - Resource, have moved to a Carbon package. So, in stead of "import Res" - you should now say "from Carbon import Res" and in stead of "from Res - import *" you should use "from Carbon.Res import *". For the lifetime of - MacPython 2.2 there is a folder :Mac:Lib:lib-compat on sys.path that - contains modules with the old names which imports the new names after - issuing a warning. - - Note that although the package is called Carbon the modules work fine under - classic PPC, and they are normal classic modules. Also note that some - modules you may think of as toolbox modules (such as Waste) really are not, - and they are not in the Carbon package. - - Also, all toolbox modules have been updated to Universal Headers 3.4, and - are (for classic PPC) weak-linked against InterfaceLib so that they should - work on all systems back to MacOS 8.1. Calling an unimplemented function will - raise an exception, not crash your interpreter. - - Another change related to the OSX growth path is that there is a new module - macresource that you can use to easily open a resource file accompanying your - script. Use "macresource.need("DLOG", MY_DIALOG_ID, "name.rsrc") and if the - given resource is not available (it _is_ available if your script has been - turned into an applet) the given resource file will be opened. This method will - eventually also contain the magic needed to open the resource file on - OSX MachO Python. - - Another feature to help with the OSX transition is that if you open a - textfile for reading MacPython will now accept either unix linefeeds - (LF, '\n') or Macintosh linefeeds (CR, '\r') and present both of them - as '\n'. This is done on a low level, so it works for files opened by - scripts as well as for your scripts and modules itself. This can be - turned off with a preference/startup option. - - But: - - this works only for input, and there's no way to find out what the original - linefeed convention of the file was. - - Windows \r\n linefeeds are not supported and get turned into \n\n. - - in 2.3 this feature will be replaced by a more general, platform independent - way of handling files with foreign newline conventions. - What to install --------------- --- 36,39 ---- *************** *** 171,175 **** Up to three items are installed in the system folder: the interpreter shared libraries PythonCore and PythonCoreCarbon live in the Extensions ! folder and the "Python 2.2 Preferences" file in the Python subfolder in the Preferences folder. All the rest of Python lives in the folder you installed in. --- 114,118 ---- Up to three items are installed in the system folder: the interpreter shared libraries PythonCore and PythonCoreCarbon live in the Extensions ! folder and the "Python 2.2.1 Preferences" file in the Python subfolder in the Preferences folder. All the rest of Python lives in the folder you installed in. *************** *** 219,225 **** are lost and you have to set them again. ! After you are satisfied that 2.2 works as expected you can trash anything in the system folder that has "python" in the name and not ! "2.2". The ConfigurePython... applets will try to detect incompatible --- 162,168 ---- are lost and you have to set them again. ! After you are satisfied that 2.2.1 works as expected you can trash anything in the system folder that has "python" in the name and not ! "2.2.1". The ConfigurePython... applets will try to detect incompatible From jackjansen@users.sourceforge.net Wed Mar 6 22:00:37 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Wed, 06 Mar 2002 14:00:37 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac Relnotes,1.28.4.2,1.28.4.2.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac In directory usw-pr-cvs1:/tmp/cvs-serv24034/Python 2.2/Mac Modified Files: Tag: release22-maint Relnotes Log Message: First stab at files for 2.2.1. Index: Relnotes =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Relnotes,v retrieving revision 1.28.4.2 retrieving revision 1.28.4.2.2.1 diff -C2 -d -r1.28.4.2 -r1.28.4.2.2.1 *** Relnotes 26 Dec 2001 22:56:50 -0000 1.28.4.2 --- Relnotes 6 Mar 2002 22:00:35 -0000 1.28.4.2.2.1 *************** *** 1,3 **** ! Changes in 2.2 since 2.1.1 ---------------------------- --- 1,3 ---- ! Changes in 2.2.1 since 2.2 ---------------------------- *************** *** 5,55 **** for machine-independent changes. ! ! - The main change is that all toolbox modules have moved to a package called Carbon. ! So things like "import Res" should be changed to "from Carbon import Res", and ! "from Res import *" to "from Carbon.Res import *". Please see the readme file for ! some open questions and join the discussions on pythonmac-sig if you have anything ! to contribute. Aside from reducing clutter this change will also benefit the ! port to Mach-O/OSX Python later. ! - All toolbox modules have been updated to Universal Headers 3.4. ! - Toolbox modules are weaklinked against InterfaceLib (for PPC builds) and raise ! an exception when you call an unimplemented one on an old MacOS. ! - On input MacPython now accepts either \n (unix style) or \r (mac style) newlines ! for text files. This behaviour can be turned off with a preference. ! This is an experimental feature; again: feedback is requested. ! - The IDE looks better on OS X, but still not as good as on OS9. ! - Command-dot handling has been improved a lot: scripts are now much easier to interrupt, ! and they only scan for cmd-. while in the foreground. ! - "Copy" from the MacPython console window was always disabled. Fixed. ! - This release should run on MacOS 8.1 again. ! - A new, rather different GUSI I/O library is used. ! - time.time() returns positive values again. ! - There is a new module macresource which makes it easier to open a resource file ! accompanying your script when the script is not (yet) converted to an applet. ! This module will later also do the right thing in Mach-O/OSX Python. ! - (Carbon only) experimental modules Carbon.CG (CoreGraphics) and CarbonEvt have ! been added. ! - A new, experimental module hfsplus is included, which gives access to some of the ! functionality of the HFS+ API. ! - A new, experimental module gives access to Carbon Events. ! - Threads had a stack that was too small for many serious Python applications (20K). ! They now get 64K. There is still no overflow check, though. ! - Garbage collection and the gc module have (finally) been enabled. ! - EasyDialogs.ProgressBar now has indeterminate progressbars if you specify maxval=0. ! This is also the new default. Patch supplied by Dean Draayer. ! - There are new preferences for enabling old-style division warnings and for ! accepting unix-style newlines in text input files. These can also be set during ! startup, and in addition you can select very verbose import tracing. ! - The NavServices override for StandardFile has moved from early startup to the ! time you import macfs. This speeds up MacPython startup. ! - Various outdated scripts have been moved to :Mac:Unsupported. ! - Various outdated items from :Mac:Lib:test have been removed. ! - C Developers: you know have control over the Python console if you are embedding ! MacPython in another application, thanks to Alexandre Parenteau. :Mac:Demo:embed.html ! has very minimal documentation. ! - BuildCGIApplet works again. ! - The CodeWarrior OSA suite missed quit(). It is back. ! - Contrib:morefindertools is gone, the functionality has been integrated into ! the standard module findertools.py. Known problems --- 5,12 ---- for machine-independent changes. ! - This release should work on multiprocessor OSX machines. ! - The problem with incomplete read()s on sockets has been fixed. ! - NavServices is now weaklinked, so this release should work on a virgin Mac OS 8.1. ! - Much more: to be supplied. Known problems *************** *** 59,66 **** http://www.cwi.nl/~jack/macpython.html. - - MacPython 2.2 (and MacPython 2.1) will not run correctly on a multiprocessor MacOS X - machine, it will quickly deadlock during I/O operations. The GUSI I/O library is suspected, - hints/clues/workarounds are solicited. This problem also occurs intermittently on fast - OS X single-processor machines. - Tkinter does not work under Carbon. - The IDE and Tkinter do not work together. Run tkinter programs under PythonInterpreter. --- 16,19 ---- From mwh@users.sourceforge.net Thu Mar 7 09:58:59 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Thu, 07 Mar 2002 01:58:59 -0800 Subject: [Python-checkins] CVS: python/dist/src setup.py,1.83,1.84 configure.in,1.292,1.293 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv16226 Modified Files: setup.py configure.in Log Message: Apply Jack's patch attached to [ 508779 ] Disable flat namespace on MacOS X I presume you wanted this on the trunk too, Jack? 2.2.1 candidate. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -d -r1.83 -r1.84 *** setup.py 1 Mar 2002 14:16:31 -0000 1.83 --- setup.py 7 Mar 2002 09:58:56 -0000 1.84 *************** *** 605,609 **** # procedure triggers on. frameworkdir = sysconfig.get_config_var('PYTHONFRAMEWORKDIR') ! exts.append( Extension('gestalt', ['gestaltmodule.c']) ) exts.append( Extension('MacOS', ['macosmodule.c'], extra_link_args=['-framework', 'Carbon']) ) --- 605,610 ---- # procedure triggers on. frameworkdir = sysconfig.get_config_var('PYTHONFRAMEWORKDIR') ! exts.append( Extension('gestalt', ['gestaltmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('MacOS', ['macosmodule.c'], extra_link_args=['-framework', 'Carbon']) ) *************** *** 614,619 **** '../Python/getapplbycreator.c'], extra_link_args=['-framework', 'Carbon']) ) ! exts.append( Extension('_CF', ['cf/_CFmodule.c']) ) ! exts.append( Extension('_Res', ['res/_Resmodule.c']) ) exts.append( Extension('_Snd', ['snd/_Sndmodule.c'], extra_link_args=['-framework', 'Carbon']) ) --- 615,622 ---- '../Python/getapplbycreator.c'], extra_link_args=['-framework', 'Carbon']) ) ! exts.append( Extension('_CF', ['cf/_CFmodule.c'], ! extra_link_args=['-framework', 'CoreFoundation']) ) ! exts.append( Extension('_Res', ['res/_Resmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Snd', ['snd/_Sndmodule.c'], extra_link_args=['-framework', 'Carbon']) ) Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.292 retrieving revision 1.293 diff -C2 -d -r1.292 -r1.293 *** configure.in 24 Feb 2002 16:05:05 -0000 1.292 --- configure.in 7 Mar 2002 09:58:56 -0000 1.293 *************** *** 794,799 **** LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)' else ! # No framework. Ignore undefined symbols, assuming they come from Python ! LDSHARED="$LDSHARED -flat_namespace -undefined suppress" fi ;; Linux*|GNU*) LDSHARED="gcc -shared";; --- 794,800 ---- LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)' else ! # No framework, use the Python app as bundle-loader ! BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' ! LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/$(PYTHON)' fi ;; Linux*|GNU*) LDSHARED="gcc -shared";; From mwh@users.sourceforge.net Thu Mar 7 09:59:18 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Thu, 07 Mar 2002 01:59:18 -0800 Subject: [Python-checkins] CVS: python/dist/src configure,1.283,1.284 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv16626 Modified Files: configure Log Message: Regenerate. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.283 retrieving revision 1.284 diff -C2 -d -r1.283 -r1.284 *** configure 24 Feb 2002 16:05:04 -0000 1.283 --- configure 7 Mar 2002 09:59:15 -0000 1.284 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.291 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.292 [...3245 lines suppressed...] if eval "test \"`echo '$''{'ac_cv_type_socklen_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < *************** *** 7595,7599 **** SRCDIRS="Parser Grammar Objects Python Modules" echo $ac_n "checking for build directories""... $ac_c" 1>&6 ! echo "configure:7598: checking for build directories" >&5 for dir in $SRCDIRS; do if test ! -d $dir; then --- 7596,7600 ---- SRCDIRS="Parser Grammar Objects Python Modules" echo $ac_n "checking for build directories""... $ac_c" 1>&6 ! echo "configure:7599: checking for build directories" >&5 for dir in $SRCDIRS; do if test ! -d $dir; then From mwh@users.sourceforge.net Thu Mar 7 10:04:52 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Thu, 07 Mar 2002 02:04:52 -0800 Subject: [Python-checkins] CVS: python/dist/src setup.py,1.73.4.1,1.73.4.2 configure.in,1.288.6.1,1.288.6.2 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv18640 Modified Files: Tag: release22-maint setup.py configure.in Log Message: backport my checkin of revision 1.84 of setup.py revision 1.293 of configure.in Apply Jack's patch attached to [ 508779 ] Disable flat namespace on MacOS X I presume you wanted this on the trunk too, Jack? 2.2.1 candidate. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.73.4.1 retrieving revision 1.73.4.2 diff -C2 -d -r1.73.4.1 -r1.73.4.2 *** setup.py 1 Mar 2002 08:58:32 -0000 1.73.4.1 --- setup.py 7 Mar 2002 10:04:49 -0000 1.73.4.2 *************** *** 587,591 **** # procedure triggers on. frameworkdir = sysconfig.get_config_var('PYTHONFRAMEWORKDIR') ! exts.append( Extension('gestalt', ['gestaltmodule.c']) ) exts.append( Extension('MacOS', ['macosmodule.c'], extra_link_args=['-framework', 'Carbon']) ) --- 587,592 ---- # procedure triggers on. frameworkdir = sysconfig.get_config_var('PYTHONFRAMEWORKDIR') ! exts.append( Extension('gestalt', ['gestaltmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('MacOS', ['macosmodule.c'], extra_link_args=['-framework', 'Carbon']) ) *************** *** 596,601 **** '../Python/getapplbycreator.c'], extra_link_args=['-framework', 'Carbon']) ) ! exts.append( Extension('_CF', ['cf/_CFmodule.c']) ) ! exts.append( Extension('_Res', ['res/_Resmodule.c']) ) exts.append( Extension('_Snd', ['snd/_Sndmodule.c'], extra_link_args=['-framework', 'Carbon']) ) --- 597,604 ---- '../Python/getapplbycreator.c'], extra_link_args=['-framework', 'Carbon']) ) ! exts.append( Extension('_CF', ['cf/_CFmodule.c'], ! extra_link_args=['-framework', 'CoreFoundation']) ) ! exts.append( Extension('_Res', ['res/_Resmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Snd', ['snd/_Sndmodule.c'], extra_link_args=['-framework', 'Carbon']) ) Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.288.6.1 retrieving revision 1.288.6.2 diff -C2 -d -r1.288.6.1 -r1.288.6.2 *** configure.in 25 Feb 2002 10:55:47 -0000 1.288.6.1 --- configure.in 7 Mar 2002 10:04:49 -0000 1.288.6.2 *************** *** 794,799 **** LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)' else ! # No framework. Ignore undefined symbols, assuming they come from Python ! LDSHARED="$LDSHARED -flat_namespace -undefined suppress" fi ;; Linux*) LDSHARED="gcc -shared";; --- 794,800 ---- LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)' else ! # No framework, use the Python app as bundle-loader ! BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' ! LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/$(PYTHON)' fi ;; Linux*) LDSHARED="gcc -shared";; From mwh@users.sourceforge.net Thu Mar 7 10:05:12 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Thu, 07 Mar 2002 02:05:12 -0800 Subject: [Python-checkins] CVS: python/dist/src configure,1.279.6.1,1.279.6.2 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv18697 Modified Files: Tag: release22-maint configure Log Message: Regenerate. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.279.6.1 retrieving revision 1.279.6.2 diff -C2 -d -r1.279.6.1 -r1.279.6.2 *** configure 25 Feb 2002 10:55:46 -0000 1.279.6.1 --- configure 7 Mar 2002 10:05:09 -0000 1.279.6.2 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.288 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.288.6.2 [...3212 lines suppressed...] if eval "test \"`echo '$''{'ac_cv_type_socklen_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < *************** *** 7544,7548 **** SRCDIRS="Parser Grammar Objects Python Modules" echo $ac_n "checking for build directories""... $ac_c" 1>&6 ! echo "configure:7547: checking for build directories" >&5 for dir in $SRCDIRS; do if test ! -d $dir; then --- 7545,7549 ---- SRCDIRS="Parser Grammar Objects Python Modules" echo $ac_n "checking for build directories""... $ac_c" 1>&6 ! echo "configure:7548: checking for build directories" >&5 for dir in $SRCDIRS; do if test ! -d $dir; then From mwh@users.sourceforge.net Thu Mar 7 10:09:51 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Thu, 07 Mar 2002 02:09:51 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_structseq.py,1.2,1.2.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv20209 Modified Files: Tag: release22-maint test_structseq.py Log Message: backport my checkin of revision 1.3 of test_structseq.py Test for [ 526039 ] devious code can crash structseqs Bugfix candidate. I haven't actually fixed this on the branch yet. Will soon. Index: test_structseq.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_structseq.py,v retrieving revision 1.2 retrieving revision 1.2.8.1 diff -C2 -d -r1.2 -r1.2.8.1 *** test_structseq.py 31 Oct 2001 03:46:14 -0000 1.2 --- test_structseq.py 7 Mar 2002 10:09:48 -0000 1.2.8.1 *************** *** 14,16 **** --- 14,28 ---- vereq(t[i:j], astuple[i:j]) + # Devious code could crash structseqs' contructors + class C: + def __getitem__(self, i): + raise IndexError + def __len__(self): + return 9 + + try: + repr(time.struct_time(C())) + except: + pass + # XXX more needed From mwh@users.sourceforge.net Thu Mar 7 10:12:14 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Thu, 07 Mar 2002 02:12:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib os.py,1.50,1.50.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv21104 Modified Files: Tag: release22-maint os.py Log Message: backport my checkin of revision 1.52 of os.py revision 1.52 date: 2002/03/06 17:11:17; author: mwh; state: Exp; lines: +20 -0 Special support for pickling os.stat and os.stat_vfs results portably (the types come from different modules on different platforms). Added tests for pickling these types. May be a bugfix candidate. Index: os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/os.py,v retrieving revision 1.50 retrieving revision 1.50.8.1 diff -C2 -d -r1.50 -r1.50.8.1 *** os.py 30 Oct 2001 05:56:40 -0000 1.50 --- os.py 7 Mar 2002 10:12:11 -0000 1.50.8.1 *************** *** 592,593 **** --- 592,613 ---- return stdin, stdout __all__.append("popen4") + + import copy_reg as _copy_reg + + def _make_stat_result(tup, dict): + return stat_result(tup, dict) + + def _pickle_stat_result(sr): + (type, args) = sr.__reduce__() + return (_make_stat_result, args) + + _copy_reg.pickle(stat_result, _pickle_stat_result,_make_stat_result) + + def _make_statvfs_result(tup, dict): + return statvfs_result(tup, dict) + + def _pickle_statvfs_result(sr): + (type, args) = sr.__reduce__() + return (_make_statvfs_result, args) + + _copy_reg.pickle(statvfs_result, _pickle_statvfs_result,_make_statvfs_result) From mwh@users.sourceforge.net Thu Mar 7 10:12:40 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Thu, 07 Mar 2002 02:12:40 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test pickletester.py,1.12.4.1,1.12.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv21239 Modified Files: Tag: release22-maint pickletester.py Log Message: backport my checkin of revision 1.14 of pickletester.py Special support for pickling os.stat and os.stat_vfs results portably (the types come from different modules on different platforms). Added tests for pickling these types. May be a bugfix candidate. Index: pickletester.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/pickletester.py,v retrieving revision 1.12.4.1 retrieving revision 1.12.4.2 diff -C2 -d -r1.12.4.1 -r1.12.4.2 *** pickletester.py 5 Mar 2002 14:01:28 -0000 1.12.4.1 --- pickletester.py 7 Mar 2002 10:12:38 -0000 1.12.4.2 *************** *** 255,258 **** --- 255,269 ---- u = self.loads(s) self.assertEqual(t, u) + import os + if hasattr(os, "stat"): + t = os.stat(os.curdir) + s = self.dumps(t) + u = self.loads(s) + self.assertEqual(t, u) + if hasattr(os, "statvfs"): + t = os.statvfs(os.curdir) + s = self.dumps(t) + u = self.loads(s) + self.assertEqual(t, u) class AbstractPickleModuleTests(unittest.TestCase): From mwh@users.sourceforge.net Thu Mar 7 10:16:45 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Thu, 07 Mar 2002 02:16:45 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects structseq.c,1.3.6.1,1.3.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv22453 Modified Files: Tag: release22-maint structseq.c Log Message: After some thinking, I decided to move all of this across onto the branch. I don't think it can break code, so the only risk is introducing new bugs. In that vein, can I ask -checkins readers who have time to carefully look this over, check my refcounts &c? TIA. backport my checkin of revision 1.5 of structseq.c Apply (my) patch: [ 526072 ] pickling os.stat results round II structseq's constructors can now take "invisible" fields in a dict. Gave the constructors better error messages. their __reduce__ method puts these fields in a dict. (this is all in aid of getting os.stat_result's to pickle portably) Also fixes [ 526039 ] devious code can crash structseqs Thought needed about how much of this counts as a bugfix. Certainly #526039 needs to be fixed. Index: structseq.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/structseq.c,v retrieving revision 1.3.6.1 retrieving revision 1.3.6.2 diff -C2 -d -r1.3.6.1 -r1.3.6.2 *** structseq.c 5 Mar 2002 14:00:52 -0000 1.3.6.1 --- structseq.c 7 Mar 2002 10:16:43 -0000 1.3.6.2 *************** *** 85,121 **** { PyObject *arg = NULL; PyStructSequence *res = NULL; ! int len, required_len, i; ! static char *kwlist[] = {"sequence", 0}; ! static char msgbuf[128]; ! if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:structseq", ! kwlist, &arg)) return NULL; ! if (!PySequence_Check(arg)) { ! PyErr_SetString(PyExc_TypeError, ! "constructor requires a sequence"); return NULL; } ! len = PySequence_Length(arg); ! required_len = REAL_SIZE_TP(type); ! if (len != required_len) { ! PyOS_snprintf( ! msgbuf, sizeof(msgbuf), ! "constructor takes exactly %d arguments (%d given)", ! required_len, ! len); ! PyErr_SetString(PyExc_TypeError, msgbuf); return NULL; } res = (PyStructSequence*) PyStructSequence_New(type); for (i = 0; i < len; ++i) { ! /* INCREF???? XXXX */ ! res->ob_item[i] = PySequence_GetItem(arg, i); } return (PyObject*) res; } --- 85,161 ---- { PyObject *arg = NULL; + PyObject *dict = NULL; + PyObject *ob; PyStructSequence *res = NULL; ! int len, min_len, max_len, i; ! static char *kwlist[] = {"sequence", "dict", 0}; ! if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:structseq", ! kwlist, &arg, &dict)) return NULL; ! arg = PySequence_Fast(arg, "constructor requires a sequence"); ! ! if (!arg) { return NULL; } ! if (dict && !PyDict_Check(dict)) { ! PyErr_Format(PyExc_TypeError, ! "%.500s() takes a dict as second arg, if any", ! type->tp_name); ! Py_DECREF(arg); return NULL; } + len = PySequence_Fast_GET_SIZE(arg); + min_len = VISIBLE_SIZE_TP(type); + max_len = REAL_SIZE_TP(type); + + if (min_len != max_len) { + if (len < min_len) { + PyErr_Format(PyExc_TypeError, + "%.500s() takes an at least %d-sequence (%d-sequence given)", + type->tp_name, min_len, len); + Py_DECREF(arg); + return NULL; + } + + if (len > max_len) { + PyErr_Format(PyExc_TypeError, + "%.500s() takes an at most %d-sequence (%d-sequence given)", + type->tp_name, max_len, len); + Py_DECREF(arg); + return NULL; + } + } + else { + if (len != min_len) { + PyErr_Format(PyExc_TypeError, + "%.500s() takes a %d-sequence (%d-sequence given)", + type->tp_name, min_len, len); + Py_DECREF(arg); + return NULL; + } + } + res = (PyStructSequence*) PyStructSequence_New(type); for (i = 0; i < len; ++i) { ! PyObject *v = PySequence_Fast_GET_ITEM(arg, i); ! Py_INCREF(v); ! res->ob_item[i] = v; ! } ! for (; i < max_len; ++i) { ! if (dict && (ob = PyDict_GetItemString( ! dict, type->tp_members[i].name))) { ! } ! else { ! ob = Py_None; ! } ! Py_INCREF(ob); ! res->ob_item[i] = ob; } + Py_DECREF(arg); return (PyObject*) res; } *************** *** 193,211 **** { PyObject* tup; ! long n_fields; int i; n_fields = REAL_SIZE(self); ! tup = PyTuple_New(n_fields); if (!tup) { return NULL; } ! for (i = 0; i < n_fields; i++) { Py_INCREF(self->ob_item[i]); PyTuple_SET_ITEM(tup, i, self->ob_item[i]); } ! return Py_BuildValue("(O(O))", self->ob_type, tup); } --- 233,264 ---- { PyObject* tup; ! PyObject* dict; ! long n_fields, n_visible_fields; int i; n_fields = REAL_SIZE(self); ! n_visible_fields = VISIBLE_SIZE(self); ! tup = PyTuple_New(n_visible_fields); if (!tup) { return NULL; } ! dict = PyDict_New(); ! if (!dict) { ! Py_DECREF(tup); ! return NULL; ! } ! ! for (i = 0; i < n_visible_fields; i++) { Py_INCREF(self->ob_item[i]); PyTuple_SET_ITEM(tup, i, self->ob_item[i]); } ! for (; i < n_fields; i++) { ! PyDict_SetItemString(dict, self->ob_type->tp_members[i].name, ! self->ob_item[i]); ! } ! ! return Py_BuildValue("(O(OO))", self->ob_type, tup, dict); } From lemburg@users.sourceforge.net Thu Mar 7 11:14:28 2002 From: lemburg@users.sourceforge.net (M.-A. Lemburg) Date: Thu, 07 Mar 2002 03:14:28 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0263.txt,1.9,1.10 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv3542 Modified Files: pep-0263.txt Log Message: Clarified the class of possible source code encodings. Added link to Martin's patch. Index: pep-0263.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0263.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pep-0263.txt 1 Mar 2002 19:07:46 -0000 1.9 --- pep-0263.txt 7 Mar 2002 11:14:26 -0000 1.10 *************** *** 77,85 **** source code. ! Only ASCII compatible encodings are allowed as source code ! encoding to assure that Python language elements other than ! literals and comments remain readable by ASCII processing tools ! and to avoid problems with wide characters encodings such as ! UTF-16. 2. Handling of escape sequences should continue to work as it does --- 77,87 ---- source code. ! Any encoding which allows processing the first two lines in ! the way indicated above is allowed as source code encoding, ! this includes ASCII compatible encodings as well as certain ! multi-byte encodings such as Shift_JIS. It does not include ! encodings which use two or more bytes for all characters ! like e.g. UTF-16. The reason for this is to keep the encoding ! detection algorithm in the tokenizer simple. 2. Handling of escape sequences should continue to work as it does *************** *** 139,142 **** --- 141,147 ---- for encoding detection as decsribed above. + Martin v. Loewis is working on a patch which implements phase 1. + See [1] for details. + Scope *************** *** 145,150 **** --- 150,161 ---- robust and portable definition. + References + + [1] Phase 1 implementation: + http://sourceforge.net/tracker/?func=detail&atid=305470&aid=526840&group_id=5470 + History + 1.10 and above: see CVS history 1.8: Added '.' to the coding RE. 1.7: Added warnings to phase 1 implementation. Replaced the From neal@metaslash.com Thu Mar 7 12:59:07 2002 From: neal@metaslash.com (Neal Norwitz) Date: Thu, 07 Mar 2002 07:59:07 -0500 Subject: [Python-checkins] CVS: python/dist/src/Objects structseq.c,1.3.6.1,1.3.6.2 References: Message-ID: <3C87641B.30450C0@metaslash.com> Do you need to do: Py_XDECREF(dict); in all the places you Py_DECREF(arg)? Neal -- Michael Hudson wrote: > > Update of /cvsroot/python/python/dist/src/Objects > In directory usw-pr-cvs1:/tmp/cvs-serv22453 > > Modified Files: > Tag: release22-maint > structseq.c > Log Message: > After some thinking, I decided to move all of this across onto > the branch. I don't think it can break code, so the only risk > is introducing new bugs. In that vein, can I ask -checkins readers > who have time to carefully look this over, check my refcounts &c? > TIA. > > backport my checkin of > revision 1.5 of structseq.c > > Apply (my) patch: > > [ 526072 ] pickling os.stat results round II > > structseq's constructors can now take "invisible" fields in a dict. > Gave the constructors better error messages. > their __reduce__ method puts these fields in a dict. > > (this is all in aid of getting os.stat_result's to pickle portably) > > Also fixes > > [ 526039 ] devious code can crash structseqs > > Thought needed about how much of this counts as a bugfix. Certainly > #526039 needs to be fixed. > > Index: structseq.c > =================================================================== > RCS file: /cvsroot/python/python/dist/src/Objects/structseq.c,v > retrieving revision 1.3.6.1 > retrieving revision 1.3.6.2 > diff -C2 -d -r1.3.6.1 -r1.3.6.2 > *** structseq.c 5 Mar 2002 14:00:52 -0000 1.3.6.1 > --- structseq.c 7 Mar 2002 10:16:43 -0000 1.3.6.2 > *************** > *** 85,121 **** > { > PyObject *arg = NULL; > PyStructSequence *res = NULL; > ! int len, required_len, i; > ! static char *kwlist[] = {"sequence", 0}; > ! static char msgbuf[128]; > > ! if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:structseq", > ! kwlist, &arg)) > return NULL; > > ! if (!PySequence_Check(arg)) { > ! PyErr_SetString(PyExc_TypeError, > ! "constructor requires a sequence"); > return NULL; > } > > ! len = PySequence_Length(arg); > ! required_len = REAL_SIZE_TP(type); > ! if (len != required_len) { > ! PyOS_snprintf( > ! msgbuf, sizeof(msgbuf), > ! "constructor takes exactly %d arguments (%d given)", > ! required_len, > ! len); > ! PyErr_SetString(PyExc_TypeError, msgbuf); > return NULL; > } > > res = (PyStructSequence*) PyStructSequence_New(type); > for (i = 0; i < len; ++i) { > ! /* INCREF???? XXXX */ > ! res->ob_item[i] = PySequence_GetItem(arg, i); > } > > return (PyObject*) res; > } > --- 85,161 ---- > { > PyObject *arg = NULL; > + PyObject *dict = NULL; > + PyObject *ob; > PyStructSequence *res = NULL; > ! int len, min_len, max_len, i; > ! static char *kwlist[] = {"sequence", "dict", 0}; > > ! if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:structseq", > ! kwlist, &arg, &dict)) > return NULL; > > ! arg = PySequence_Fast(arg, "constructor requires a sequence"); > ! > ! if (!arg) { > return NULL; > } > > ! if (dict && !PyDict_Check(dict)) { > ! PyErr_Format(PyExc_TypeError, > ! "%.500s() takes a dict as second arg, if any", > ! type->tp_name); > ! Py_DECREF(arg); > return NULL; > } > > + len = PySequence_Fast_GET_SIZE(arg); > + min_len = VISIBLE_SIZE_TP(type); > + max_len = REAL_SIZE_TP(type); > + > + if (min_len != max_len) { > + if (len < min_len) { > + PyErr_Format(PyExc_TypeError, > + "%.500s() takes an at least %d-sequence (%d-sequence given)", > + type->tp_name, min_len, len); > + Py_DECREF(arg); > + return NULL; > + } > + > + if (len > max_len) { > + PyErr_Format(PyExc_TypeError, > + "%.500s() takes an at most %d-sequence (%d-sequence given)", > + type->tp_name, max_len, len); > + Py_DECREF(arg); > + return NULL; > + } > + } > + else { > + if (len != min_len) { > + PyErr_Format(PyExc_TypeError, > + "%.500s() takes a %d-sequence (%d-sequence given)", > + type->tp_name, min_len, len); > + Py_DECREF(arg); > + return NULL; > + } > + } > + > res = (PyStructSequence*) PyStructSequence_New(type); > for (i = 0; i < len; ++i) { > ! PyObject *v = PySequence_Fast_GET_ITEM(arg, i); > ! Py_INCREF(v); > ! res->ob_item[i] = v; > ! } > ! for (; i < max_len; ++i) { > ! if (dict && (ob = PyDict_GetItemString( > ! dict, type->tp_members[i].name))) { > ! } > ! else { > ! ob = Py_None; > ! } > ! Py_INCREF(ob); > ! res->ob_item[i] = ob; > } > > + Py_DECREF(arg); > return (PyObject*) res; > } From mwh@users.sourceforge.net Thu Mar 7 15:13:43 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Thu, 07 Mar 2002 07:13:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects structseq.c,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv3270 Modified Files: structseq.c Log Message: Guido pointed out that I was missing a couple decrefs. Index: structseq.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/structseq.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** structseq.c 6 Mar 2002 17:07:49 -0000 1.5 --- structseq.c 7 Mar 2002 15:13:40 -0000 1.6 *************** *** 234,237 **** --- 234,238 ---- PyObject* tup; PyObject* dict; + PyObject* result; long n_fields, n_visible_fields; int i; *************** *** 260,264 **** } ! return Py_BuildValue("(O(OO))", self->ob_type, tup, dict); } --- 261,270 ---- } ! result = Py_BuildValue("(O(OO))", self->ob_type, tup, dict); ! ! Py_DECREF(tup); ! Py_DECREF(dict); ! ! return result; } From mwh@users.sourceforge.net Thu Mar 7 15:16:09 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Thu, 07 Mar 2002 07:16:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects structseq.c,1.3.6.2,1.3.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv4235 Modified Files: Tag: release22-maint structseq.c Log Message: backport my checkin of revision 1.6 of structseq.c Guido pointed out that I was missing a couple decrefs. Index: structseq.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/structseq.c,v retrieving revision 1.3.6.2 retrieving revision 1.3.6.3 diff -C2 -d -r1.3.6.2 -r1.3.6.3 *** structseq.c 7 Mar 2002 10:16:43 -0000 1.3.6.2 --- structseq.c 7 Mar 2002 15:16:07 -0000 1.3.6.3 *************** *** 234,237 **** --- 234,238 ---- PyObject* tup; PyObject* dict; + PyObject* result; long n_fields, n_visible_fields; int i; *************** *** 260,264 **** } ! return Py_BuildValue("(O(OO))", self->ob_type, tup, dict); } --- 261,270 ---- } ! result = Py_BuildValue("(O(OO))", self->ob_type, tup, dict); ! ! Py_DECREF(tup); ! Py_DECREF(dict); ! ! return result; } From nascheme@users.sourceforge.net Thu Mar 7 18:56:35 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Thu, 07 Mar 2002 10:56:35 -0800 Subject: [Python-checkins] CVS: python/nondist/sf-html index.html,1.12,1.13 Message-ID: Update of /cvsroot/python/python/nondist/sf-html In directory usw-pr-cvs1:/tmp/cvs-serv16606 Modified Files: index.html Log Message: Add link to AMK's "Becoming a Python Developer" article. Index: index.html =================================================================== RCS file: /cvsroot/python/python/nondist/sf-html/index.html,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** index.html 22 Apr 2001 06:22:21 -0000 1.12 --- index.html 7 Mar 2002 18:56:32 -0000 1.13 *************** *** 59,62 **** --- 59,69 ----
  • + Becoming a + Python Developer + - Recommended reading for aspiring Python developers (written by Andrew + Kuchling). +
  • + +
  • python-dev Summaries - Summaries of discussion on the developers' mailing list From bwarsaw@users.sourceforge.net Thu Mar 7 19:20:48 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Thu, 07 Mar 2002 11:20:48 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0010.txt,NONE,1.1 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv24229 Added Files: pep-0010.txt Log Message: PEP 10, Voting Guidelines, Barry Warsaw --- NEW FILE: pep-0010.txt --- PEP: 10 Title: Voting Guidelines Version: $Revision: 1.1 $ Last-Modified: $Date: 2002/03/07 19:20:45 $ Author: barry@zope.com (Barry A. Warsaw) Status: Active Type: Informational Created: 07-Mar-2002 Post-History: Abstract This PEP outlines the python-dev voting guidelines. These guidelines serve to provide feedback or gauge the "wind direction" on a particular proposal, idea, or feature. They don't have a binding force. Rationale When a new idea, feature, patch, etc. is floated in the Python community, either through a PEP or on the mailing lists (most likely on python-dev [1]), it is sometimes helpful to gauge the community's general sentiment. Sometimes people just want to register their opinion of an idea. Sometimes the BDFL wants to take a straw poll. Whatever the reason, these guidelines have been adopted so as to provide a common language for developers. While opinions are (sometimes) useful, but they are never binding. Opinions that are accompanied by rationales are always valued higher than bare scores (this is especially true with -1 votes). Voting Scores The scoring guidelines are loosely derived from the Apache voting procedure [2], with of course our own spin on things. There are 4 possible vote scores: +1 I like it +0 I don't care, but go ahead -0 I don't care, so why bother? -1 I hate it You may occasionally see wild flashes of enthusiasm (either for or against) with vote scores like +2, +1000, or -1000. These aren't really valued much beyond the above scores, but it's nice to see people get excited about such geeky stuff. References [1] Becoming a Python Developer, Andrew Kuchling http://www.amk.ca/python/writing/python-dev.html [2] Apache Project Guidelines and Voting Rules http://httpd.apache.org/dev/guidelines.html Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil fill-column: 70 End: From bwarsaw@users.sourceforge.net Thu Mar 7 19:21:13 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Thu, 07 Mar 2002 11:21:13 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.161,1.162 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv24418 Modified Files: pep-0000.txt Log Message: Added PEP 10, Voting Guidelines, Barry Warsaw Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.161 retrieving revision 1.162 diff -C2 -d -r1.161 -r1.162 *** pep-0000.txt 6 Mar 2002 20:48:22 -0000 1.161 --- pep-0000.txt 7 Mar 2002 19:21:11 -0000 1.162 *************** *** 34,37 **** --- 34,38 ---- I 8 Style Guide for Python Code van Rossum, Warsaw I 9 Sample PEP Template Warsaw + I 10 Voting Guidelines Warsaw Other Informational PEPs *************** *** 160,163 **** --- 161,165 ---- I 8 Style Guide for Python Code van Rossum, Warsaw I 9 Sample PEP Template Warsaw + I 10 Voting Guidelines Warsaw I 42 Small Feature Requests Hylton From bwarsaw@users.sourceforge.net Thu Mar 7 19:26:09 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Thu, 07 Mar 2002 11:26:09 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0010.txt,1.1,1.2 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv26274 Modified Files: pep-0010.txt Log Message: I'm agonna post it today. Index: pep-0010.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0010.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pep-0010.txt 7 Mar 2002 19:20:45 -0000 1.1 --- pep-0010.txt 7 Mar 2002 19:26:07 -0000 1.2 *************** *** 7,11 **** Type: Informational Created: 07-Mar-2002 ! Post-History: --- 7,11 ---- Type: Informational Created: 07-Mar-2002 ! Post-History: 07-Mar-2002 From bwarsaw@users.sourceforge.net Thu Mar 7 20:02:11 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Thu, 07 Mar 2002 12:02:11 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.162,1.163 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv6148 Modified Files: pep-0000.txt Log Message: Don't mention a specific Python version. Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.162 retrieving revision 1.163 diff -C2 -d -r1.162 -r1.163 *** pep-0000.txt 7 Mar 2002 19:21:11 -0000 1.162 --- pep-0000.txt 7 Mar 2002 20:02:09 -0000 1.163 *************** *** 45,54 **** I 272 API for Secret-Key Encryption Algorithms Kuchling ! Accepted PEPs (accepted for Python 2.2; may not be implemented yet) S 252 Making Types Look More Like Classes van Rossum S 253 Subtyping Built-in Types van Rossum ! Open PEPs (under consideration for Python 2.3) I 42 Small Feature Requests Hylton --- 45,54 ---- I 272 API for Secret-Key Encryption Algorithms Kuchling ! Accepted PEPs (accepted; may not be implemented yet) S 252 Making Types Look More Like Classes van Rossum S 253 Subtyping Built-in Types van Rossum ! Open PEPs (under consideration) I 42 Small Feature Requests Hylton From montanaro@users.sourceforge.net Thu Mar 7 22:58:04 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Thu, 07 Mar 2002 14:58:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib pydoc.py,1.57,1.58 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv30162 Modified Files: pydoc.py Log Message: add repr_str as alias for repr_string in both HTMLRepr and TextRepr classes - reflects the change in type("").__name__ between 2.1 and 2.2. The __name__ field is used to find a method to call for particular types. Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** pydoc.py 3 Mar 2002 03:12:30 -0000 1.57 --- pydoc.py 7 Mar 2002 22:58:02 -0000 1.58 *************** *** 312,315 **** --- 312,317 ---- self.escape(testrepr)) + repr_str = repr_string + def repr_instance(self, x, level): try: *************** *** 860,863 **** --- 862,867 ---- return 'r' + testrepr[0] + test + testrepr[0] return testrepr + + repr_str = repr_string def repr_instance(self, x, level): From fdrake@users.sourceforge.net Fri Mar 8 00:54:45 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 07 Mar 2002 16:54:45 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/tut tut.tex,1.158,1.159 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory usw-pr-cvs1:/tmp/cvs-serv26132/tut Modified Files: tut.tex Log Message: "Shortcut" should be "short-circuit". This closes SF bug #526277. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.158 retrieving revision 1.159 diff -C2 -d -r1.158 -r1.159 *** tut.tex 29 Jan 2002 14:53:30 -0000 1.158 --- tut.tex 8 Mar 2002 00:54:43 -0000 1.159 *************** *** 2040,2049 **** The Boolean operators \code{and} and \code{or} are so-called ! \emph{shortcut} operators: their arguments are evaluated from left to ! right, and evaluation stops as soon as the outcome is determined. ! E.g., if \code{A} and \code{C} are true but \code{B} is false, \code{A ! and B and C} does not evaluate the expression C. In general, the ! return value of a shortcut operator, when used as a general value and ! not as a Boolean, is the last evaluated argument. It is possible to assign the result of a comparison or other Boolean --- 2040,2050 ---- The Boolean operators \code{and} and \code{or} are so-called ! \emph{short-circuit} operators: their arguments are evaluated from ! left to right, and evaluation stops as soon as the outcome is ! determined. For example, if \code{A} and \code{C} are true but ! \code{B} is false, \code{A and B and C} does not evaluate the ! expression \code{C}. In general, the return value of a short-circuit ! operator, when used as a general value and not as a Boolean, is the ! last evaluated argument. It is possible to assign the result of a comparison or other Boolean From fdrake@users.sourceforge.net Fri Mar 8 01:01:26 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 07 Mar 2002 17:01:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/tut tut.tex,1.156.4.1.2.1,1.156.4.1.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory usw-pr-cvs1:/tmp/cvs-serv27547/tut Modified Files: Tag: release22-maint tut.tex Log Message: "Shortcut" should be "short-circuit". This closes SF bug #526277. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.156.4.1.2.1 retrieving revision 1.156.4.1.2.2 diff -C2 -d -r1.156.4.1.2.1 -r1.156.4.1.2.2 *** tut.tex 29 Jan 2002 14:54:18 -0000 1.156.4.1.2.1 --- tut.tex 8 Mar 2002 01:01:23 -0000 1.156.4.1.2.2 *************** *** 2040,2049 **** The Boolean operators \code{and} and \code{or} are so-called ! \emph{shortcut} operators: their arguments are evaluated from left to ! right, and evaluation stops as soon as the outcome is determined. ! E.g., if \code{A} and \code{C} are true but \code{B} is false, \code{A ! and B and C} does not evaluate the expression C. In general, the ! return value of a shortcut operator, when used as a general value and ! not as a Boolean, is the last evaluated argument. It is possible to assign the result of a comparison or other Boolean --- 2040,2050 ---- The Boolean operators \code{and} and \code{or} are so-called ! \emph{short-circuit} operators: their arguments are evaluated from ! left to right, and evaluation stops as soon as the outcome is ! determined. For example, if \code{A} and \code{C} are true but ! \code{B} is false, \code{A and B and C} does not evaluate the ! expression \code{C}. In general, the return value of a short-circuit ! operator, when used as a general value and not as a Boolean, is the ! last evaluated argument. It is possible to assign the result of a comparison or other Boolean From fdrake@users.sourceforge.net Fri Mar 8 01:01:52 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 07 Mar 2002 17:01:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/tut tut.tex,1.133.2.5,1.133.2.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory usw-pr-cvs1:/tmp/cvs-serv27668/tut Modified Files: Tag: release21-maint tut.tex Log Message: "Shortcut" should be "short-circuit". This closes SF bug #526277. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.133.2.5 retrieving revision 1.133.2.6 diff -C2 -d -r1.133.2.5 -r1.133.2.6 *** tut.tex 18 Jul 2001 19:21:43 -0000 1.133.2.5 --- tut.tex 8 Mar 2002 01:01:50 -0000 1.133.2.6 *************** *** 2000,2009 **** The Boolean operators \code{and} and \code{or} are so-called ! \emph{shortcut} operators: their arguments are evaluated from left to ! right, and evaluation stops as soon as the outcome is determined. ! E.g., if \code{A} and \code{C} are true but \code{B} is false, \code{A ! and B and C} does not evaluate the expression C. In general, the ! return value of a shortcut operator, when used as a general value and ! not as a Boolean, is the last evaluated argument. It is possible to assign the result of a comparison or other Boolean --- 2000,2010 ---- The Boolean operators \code{and} and \code{or} are so-called ! \emph{short-circuit} operators: their arguments are evaluated from ! left to right, and evaluation stops as soon as the outcome is ! determined. For example, if \code{A} and \code{C} are true but ! \code{B} is false, \code{A and B and C} does not evaluate the ! expression \code{C}. In general, the return value of a short-circuit ! operator, when used as a general value and not as a Boolean, is the ! last evaluated argument. It is possible to assign the result of a comparison or other Boolean From pierslauder@users.sourceforge.net Fri Mar 8 01:53:26 2002 From: pierslauder@users.sourceforge.net (Piers Lauder) Date: Thu, 07 Mar 2002 17:53:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libimaplib.tex,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv5034/dist/src/Doc/lib Modified Files: libimaplib.tex Log Message: add SSL class submitted by Tino Lange Index: libimaplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libimaplib.tex,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** libimaplib.tex 20 Jul 2001 11:04:19 -0000 1.18 --- libimaplib.tex 8 Mar 2002 01:53:24 -0000 1.19 *************** *** 10,23 **** % converted by Fred L. Drake, Jr. . % Revised by ESR, January 2000. \indexii{IMAP4}{protocol} ! This module defines a class, \class{IMAP4}, which encapsulates a ! connection to an IMAP4 server and implements a large subset of the IMAP4rev1 client protocol as defined in \rfc{2060}. It is backward compatible with IMAP4 (\rfc{1730}) servers, but note that the \samp{STATUS} command is not supported in IMAP4. ! A single class is provided by the \module{imaplib} module: \begin{classdesc}{IMAP4}{\optional{host\optional{, port}}} --- 10,25 ---- % converted by Fred L. Drake, Jr. . % Revised by ESR, January 2000. + % Changes for IMAP4_SSL by Tino Lange , March 2002 \indexii{IMAP4}{protocol} + \indexii{IMAP4_SSL}{protocol} ! This module defines two classes, \class{IMAP4} and \class{IMAP4_SSL}, which encapsulate a ! connection to an IMAP4 server and implement a large subset of the IMAP4rev1 client protocol as defined in \rfc{2060}. It is backward compatible with IMAP4 (\rfc{1730}) servers, but note that the \samp{STATUS} command is not supported in IMAP4. ! Two classes are provided by the \module{imaplib} module, \class{IMAP4} is the base class: \begin{classdesc}{IMAP4}{\optional{host\optional{, port}}} *************** *** 49,52 **** --- 51,65 ---- \end{excdesc} + There's also a subclass for secure connections: + + \begin{classdesc}{IMAP4_SSL}{\optional{host\optional{, port\optional{, keyfile\optional{, certfile}}}}} + This is a subclass derived from \class{IMAP4} that connects over an SSL encrypted socket + (to use this class you need a socket module that was compiled with SSL support). + If \var{host} is not specified, \code{''} (the local host) is used. + If \var{port} is omitted, the standard IMAP4-over-SSL port (993) is used. + \var{keyfile} and \var{certfile} are also optional - they can contain a PEM formatted + private key and certificate chain file for the SSL connection. + \end{classdesc} + The following utility functions are defined: *************** *** 309,312 **** --- 322,332 ---- Allow simple extension commands notified by server in \samp{CAPABILITY} response. + \end{methoddesc} + + + Instances of \class{IMAP4_SSL} have just one additional method: + + \begin{methoddesc}{ssl}{} + Returns SSLObject instance used for the secure connection with the server. \end{methoddesc} From pierslauder@users.sourceforge.net Fri Mar 8 01:53:26 2002 From: pierslauder@users.sourceforge.net (Piers Lauder) Date: Thu, 07 Mar 2002 17:53:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib imaplib.py,1.43,1.44 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv5034/dist/src/Lib Modified Files: imaplib.py Log Message: add SSL class submitted by Tino Lange Index: imaplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imaplib.py,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** imaplib.py 22 Feb 2002 01:15:17 -0000 1.43 --- imaplib.py 8 Mar 2002 01:53:24 -0000 1.44 *************** *** 16,21 **** # String method conversion by ESR, February 2001. # GET/SETACL contributed by Anthony Baxter April 2001. ! __version__ = "2.50" import binascii, re, socket, time, random, sys --- 16,22 ---- # String method conversion by ESR, February 2001. # GET/SETACL contributed by Anthony Baxter April 2001. + # IMAP4_SSL contributed by Tino Lange March 2002. ! __version__ = "2.51" import binascii, re, socket, time, random, sys *************** *** 980,983 **** --- 981,1056 ---- i = 0 n -= 1 + + + + class IMAP4_SSL(IMAP4): + + """IMAP4 client class over SSL connection + + Instantiate with: IMAP4_SSL([, host[, port[, keyfile[, certfile]]]]) + + host - host's name (default: localhost); + port - port number (default: standard IMAP4 SSL port). + keyfile - PEM formatted file that contains your private key (default: None); + certfile - PEM formatted certificate chain file (default: None); + + for more documentation see the docstring of the parent class IMAP4. + """ + + + def __init__(self, host = '', port = IMAP4_SSL_PORT, keyfile = None, certfile = None): + self.keyfile = keyfile + self.certfile = certfile + IMAP4.__init__(self, host, port) + + + def open(self, host, port): + """Setup connection to remote server on "host:port". + This connection will be used by the routines: + read, readline, send, shutdown. + """ + self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.sock.connect((self.host, self.port)) + self.sslobj = socket.ssl(self.sock,self.keyfile, self.certfile) + + + def read(self, size): + """Read 'size' bytes from remote.""" + return self.sslobj.read(size) + + + def readline(self): + """Read line from remote.""" + line = "" + while 1: + char = self.sslobj.read(1) + line += char + if char == "\n": return line + + + def send(self, data): + """Send data to remote.""" + self.sslobj.write(data) + + + def shutdown(self): + """Close I/O established in "open".""" + self.sock.close() + + + def socket(self): + """Return socket instance used to connect to IMAP4 server. + + socket = .socket() + """ + return self.sock + + + def ssl(self): + """Return SSLObject instance used to communicate with the IMAP4 server. + + ssl = .socket.ssl() + """ + return self.sslobj From montanaro@users.sourceforge.net Fri Mar 8 02:36:20 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Thu, 07 Mar 2002 18:36:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib BaseHTTPServer.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv13324 Modified Files: BaseHTTPServer.py Log Message: add Content-Type header to error responses this closes patch 502080 Index: BaseHTTPServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/BaseHTTPServer.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** BaseHTTPServer.py 25 Jul 2001 06:12:16 -0000 1.17 --- BaseHTTPServer.py 8 Mar 2002 02:36:18 -0000 1.18 *************** *** 288,291 **** --- 288,292 ---- self.log_error("code %d, message %s", code, message) self.send_response(code, message) + self.send_header("Content-Type", "text/html") self.end_headers() self.wfile.write(self.error_message_format % From fdrake@users.sourceforge.net Fri Mar 8 03:15:52 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 07 Mar 2002 19:15:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/mac libscrap.tex,NONE,1.1 toolbox.tex,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/mac In directory usw-pr-cvs1:/tmp/cvs-serv20972 Modified Files: toolbox.tex Added Files: libscrap.tex Log Message: I started writing more documentation on the Scrap module at one point, but it is difficult to do without a Mac box to try things out on. This expands on what was there only a little bit; hopefully someone with a Mac can work on this as well! --- NEW FILE: libscrap.tex --- \section{\module{Carbon.Scrap} --- Scrap Manager} \declaremodule{standard}{Carbon.Scrap} \platform{Mac} \modulesynopsis{The Scrap Manager provides basic services for implementing cut \&\ paste and clipboard operations.} This module is only fully available on MacOS9 and earlier under classic PPC MacPython. Very limited functionality is available under Carbon MacPython. The Scrap\index{Scrap Manager} Manager supports the simplest form of cut \&\ paste operations on the Macintosh. It can be use for both inter- and intra-application clipboard operations. The \module{Scrap} module provides low-level access to the functions of the Scrap Manager. It contains the following functions: \begin{funcdesc}{InfoScrap}{} Return current information about the scrap. The information is encoded as a tuple containing the fields \code{(\var{size}, \var{handle}, \var{count}, \var{state}, \var{path})}. \begin{tableii}{l|l}{var}{Field}{Meaning} \lineii{size}{Size of the scrap in bytes.} \lineii{handle}{Resource object representing the scrap.} \lineii{count}{Serial number of the scrap contents.} \lineii{state}{Integer; positive if in memory, \code{0} if on disk, negative if uninitialized.} \lineii{path}{Filename of the scrap when stored on disk.} \end{tableii} \end{funcdesc} \begin{seealso} \seetitle[http://developer.apple.com/techpubs/mac/MoreToolbox/MoreToolbox-109.html] {Scrap Manager}{Apple's documentation for the Scrap Manager gives a lot of useful information about using the Scrap Manager in applications.} \end{seealso} Index: toolbox.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/toolbox.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** toolbox.tex 17 Jan 2002 04:51:55 -0000 1.5 --- toolbox.tex 8 Mar 2002 03:15:49 -0000 1.6 *************** *** 134,152 **** ! \section{\module{Carbon.Scrap} --- Scrap Manager} ! \declaremodule{standard}{Carbon.Scrap} ! \platform{Mac} ! \modulesynopsis{The Scrap Manager provides basic services for ! implementing cut \&\ paste and clipboard operations.} ! ! This module is only fully available on MacOS9 and earlier under classic PPC ! MacPython. Very limited functionality is available under Carbon MacPython. ! ! \begin{seealso} ! \seetitle[http://developer.apple.com/techpubs/mac/MoreToolbox/MoreToolbox-109.html]{Scrap ! Manager}{Apple's documentation for the Scrap Manager gives ! a lot of useful information about using the Scrap Manager ! in applications.} ! \end{seealso} --- 134,138 ---- ! \input{libscrap} From fdrake@users.sourceforge.net Fri Mar 8 03:18:21 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 07 Mar 2002 19:18:21 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc Makefile.deps,1.82,1.83 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory usw-pr-cvs1:/tmp/cvs-serv21425 Modified Files: Makefile.deps Log Message: Add entry for mac/libscrap.tex. Index: Makefile.deps =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile.deps,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** Makefile.deps 24 Jan 2002 16:38:08 -0000 1.82 --- Makefile.deps 8 Mar 2002 03:18:19 -0000 1.83 *************** *** 334,338 **** mac/libmacic.tex \ mac/libframework.tex \ ! mac/libminiae.tex INSTFILES = $(HOWTOSTYLES) inst/inst.tex --- 334,339 ---- mac/libmacic.tex \ mac/libframework.tex \ ! mac/libminiae.tex \ ! mac/libscrap.tex INSTFILES = $(HOWTOSTYLES) inst/inst.tex From bwarsaw@users.sourceforge.net Fri Mar 8 05:43:24 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Thu, 07 Mar 2002 21:43:24 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.163,1.164 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv14134 Modified Files: pep-0000.txt Log Message: Add a link to Guido's Parade of PEPs. Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.163 retrieving revision 1.164 diff -C2 -d -r1.163 -r1.164 *** pep-0000.txt 7 Mar 2002 20:02:09 -0000 1.163 --- pep-0000.txt 8 Mar 2002 05:43:22 -0000 1.164 *************** *** 17,20 **** --- 17,24 ---- texts represent their historical record. + The BDFL maintains his own Pronouncements page[2] at + http://www.python.org/doc/essays/pepparade.html which contains his + musings on the various outstanding PEPs. + Index by Category *************** *** 323,327 **** [1] View PEP history online ! http://cvs.sf.net/cgi-bin/viewcvs.cgi/python/python/nondist/peps/ --- 327,334 ---- [1] View PEP history online ! http://cvs.sf.net/cgi-bin/viewcvs.cgi/python/python/nondist/peps/ ! ! [2] The Benevolent Dictator For Life's Parade of PEPs ! http://www.python.org/doc/essays/pepparade.html From tim_one@users.sourceforge.net Fri Mar 8 05:43:34 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 07 Mar 2002 21:43:34 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_mmap.py,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv13773/python/Lib/test Modified Files: test_mmap.py Log Message: SF bug 515943: searching for data with \0 in mmap. mmap_find_method(): this obtained the string to find via s#, but it ignored its length, acting as if it were \0-terminated instead. Someone please run on Linux too (the extended test_mmap works on Windows). Bugfix candidate. Index: test_mmap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mmap.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** test_mmap.py 13 Nov 2001 23:39:47 -0000 1.19 --- test_mmap.py 8 Mar 2002 05:43:32 -0000 1.20 *************** *** 245,248 **** --- 245,273 ---- pass + # Do a tougher .find() test. SF bug 515943 pointed out that, in 2.2, + # searching for data with embedded \0 bytes didn't work. + f = open(TESTFN, 'w+') + + try: # unlink TESTFN no matter what + data = 'aabaac\x00deef\x00\x00aa\x00' + n = len(data) + f.write(data) + m = mmap.mmap(f.fileno(), n) + f.close() + + for start in range(n+1): + for finish in range(start, n+1): + slice = data[start : finish] + vereq(m.find(slice), data.find(slice)) + vereq(m.find(slice + 'x'), -1) + + finally: + try: + os.unlink(TESTFN) + except OSError: + pass + + + print ' Test passed' From tim_one@users.sourceforge.net Fri Mar 8 05:43:34 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 07 Mar 2002 21:43:34 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.37,2.38 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv13773/python/Modules Modified Files: mmapmodule.c Log Message: SF bug 515943: searching for data with \0 in mmap. mmap_find_method(): this obtained the string to find via s#, but it ignored its length, acting as if it were \0-terminated instead. Someone please run on Linux too (the extended test_mmap works on Windows). Bugfix candidate. Index: mmapmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v retrieving revision 2.37 retrieving revision 2.38 diff -C2 -d -r2.37 -r2.38 *** mmapmodule.c 17 Jan 2002 23:15:58 -0000 2.37 --- mmapmodule.c 8 Mar 2002 05:43:32 -0000 2.38 *************** *** 252,269 **** else if ((size_t)start > self->size) start = self->size; - p = self->data + start; ! while (p < e) { ! char *s = p; ! char *n = needle; ! while ((sdata)); } - p++; } return Py_BuildValue ("l", (long) -1); --- 252,265 ---- else if ((size_t)start > self->size) start = self->size; ! for (p = self->data + start; p + len <= e; ++p) { ! int i; ! for (i = 0; i < len && needle[i] == p[i]; ++i) ! /* nothing */; ! if (i == len) { return Py_BuildValue ( "l", (long) (p - self->data)); } } return Py_BuildValue ("l", (long) -1); From pierslauder@users.sourceforge.net Fri Mar 8 09:05:14 2002 From: pierslauder@users.sourceforge.net (Piers Lauder) Date: Fri, 08 Mar 2002 01:05:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib imaplib.py,1.44,1.45 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv20403/dist/src/Lib Modified Files: imaplib.py Log Message: fixed missing IMAP4_SSL_PORT Index: imaplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imaplib.py,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** imaplib.py 8 Mar 2002 01:53:24 -0000 1.44 --- imaplib.py 8 Mar 2002 09:05:12 -0000 1.45 *************** *** 30,33 **** --- 30,34 ---- Debug = 0 IMAP4_PORT = 143 + IMAP4_SSL_PORT = 993 AllowedVersions = ('IMAP4REV1', 'IMAP4') # Most recent first *************** *** 988,992 **** """IMAP4 client class over SSL connection ! Instantiate with: IMAP4_SSL([, host[, port[, keyfile[, certfile]]]]) host - host's name (default: localhost); --- 989,993 ---- """IMAP4 client class over SSL connection ! Instantiate with: IMAP4_SSL([host[, port[, keyfile[, certfile]]]]) host - host's name (default: localhost); From neal@metaslash.com Fri Mar 8 12:55:51 2002 From: neal@metaslash.com (Neal Norwitz) Date: Fri, 08 Mar 2002 07:55:51 -0500 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_mmap.py,1.19,1.20 References: Message-ID: <3C88B4D7.3B6D6CEB@metaslash.com> Tim Peters wrote: > > Update of /cvsroot/python/python/dist/src/Lib/test > In directory usw-pr-cvs1:/tmp/cvs-serv13773/python/Lib/test > > Modified Files: > test_mmap.py > Log Message: > SF bug 515943: searching for data with \0 in mmap. > mmap_find_method(): this obtained the string to find via s#, but it > ignored its length, acting as if it were \0-terminated instead. > > Someone please run on Linux too (the extended test_mmap works on Windows). Works for me: Linux epoch 2.4.7-10 #1 Thu Sep 6 16:46:36 EDT 2001 i686 unknown Red Hat Linux release 7.2 (Enigma) From mwh@users.sourceforge.net Fri Mar 8 13:39:27 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Fri, 08 Mar 2002 05:39:27 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_mmap.py,1.19,1.19.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv25125 Modified Files: Tag: release22-maint test_mmap.py Log Message: backport tim_one's checkin of revision 1.20 of test_mmap.py SF bug 515943: searching for data with \0 in mmap. mmap_find_method(): this obtained the string to find via s#, but it ignored its length, acting as if it were \0-terminated instead. Someone please run on Linux too (the extended test_mmap works on Windows). Bugfix candidate. Index: test_mmap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mmap.py,v retrieving revision 1.19 retrieving revision 1.19.8.1 diff -C2 -d -r1.19 -r1.19.8.1 *** test_mmap.py 13 Nov 2001 23:39:47 -0000 1.19 --- test_mmap.py 8 Mar 2002 13:39:25 -0000 1.19.8.1 *************** *** 245,248 **** --- 245,273 ---- pass + # Do a tougher .find() test. SF bug 515943 pointed out that, in 2.2, + # searching for data with embedded \0 bytes didn't work. + f = open(TESTFN, 'w+') + + try: # unlink TESTFN no matter what + data = 'aabaac\x00deef\x00\x00aa\x00' + n = len(data) + f.write(data) + m = mmap.mmap(f.fileno(), n) + f.close() + + for start in range(n+1): + for finish in range(start, n+1): + slice = data[start : finish] + vereq(m.find(slice), data.find(slice)) + vereq(m.find(slice + 'x'), -1) + + finally: + try: + os.unlink(TESTFN) + except OSError: + pass + + + print ' Test passed' From mwh@users.sourceforge.net Fri Mar 8 13:40:09 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Fri, 08 Mar 2002 05:40:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.35.6.1,2.35.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv25367 Modified Files: Tag: release22-maint mmapmodule.c Log Message: backport tim_one's checkin of revision 2.38 of mmapmodule.c SF bug 515943: searching for data with \0 in mmap. mmap_find_method(): this obtained the string to find via s#, but it ignored its length, acting as if it were \0-terminated instead. Someone please run on Linux too (the extended test_mmap works on Windows). Bugfix candidate. Index: mmapmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v retrieving revision 2.35.6.1 retrieving revision 2.35.6.2 diff -C2 -d -r2.35.6.1 -r2.35.6.2 *** mmapmodule.c 12 Jan 2002 11:13:23 -0000 2.35.6.1 --- mmapmodule.c 8 Mar 2002 13:40:07 -0000 2.35.6.2 *************** *** 252,269 **** else if ((size_t)start > self->size) start = self->size; - p = self->data + start; ! while (p < e) { ! char *s = p; ! char *n = needle; ! while ((sdata)); } - p++; } return Py_BuildValue ("l", (long) -1); --- 252,265 ---- else if ((size_t)start > self->size) start = self->size; ! for (p = self->data + start; p + len <= e; ++p) { ! int i; ! for (i = 0; i < len && needle[i] == p[i]; ++i) ! /* nothing */; ! if (i == len) { return Py_BuildValue ( "l", (long) (p - self->data)); } } return Py_BuildValue ("l", (long) -1); From mwh@users.sourceforge.net Fri Mar 8 13:40:48 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Fri, 08 Mar 2002 05:40:48 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib pydoc.py,1.56,1.56.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv25524 Modified Files: Tag: release22-maint pydoc.py Log Message: backport montanaro's checkin of revision 1.58 of pydoc.py add repr_str as alias for repr_string in both HTMLRepr and TextRepr classes - reflects the change in type("").__name__ between 2.1 and 2.2. The __name__ field is used to find a method to call for particular types. Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.56 retrieving revision 1.56.8.1 diff -C2 -d -r1.56 -r1.56.8.1 *** pydoc.py 31 Oct 2001 04:20:26 -0000 1.56 --- pydoc.py 8 Mar 2002 13:40:46 -0000 1.56.8.1 *************** *** 312,315 **** --- 312,317 ---- self.escape(testrepr)) + repr_str = repr_string + def repr_instance(self, x, level): try: *************** *** 860,863 **** --- 862,867 ---- return 'r' + testrepr[0] + test + testrepr[0] return testrepr + + repr_str = repr_string def repr_instance(self, x, level): From mwh@users.sourceforge.net Fri Mar 8 13:41:11 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Fri, 08 Mar 2002 05:41:11 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib BaseHTTPServer.py,1.17,1.17.16.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv25646 Modified Files: Tag: release22-maint BaseHTTPServer.py Log Message: backport montanaro's checkin of revision 1.18 of BaseHTTPServer.py add Content-Type header to error responses this closes patch 502080 Index: BaseHTTPServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/BaseHTTPServer.py,v retrieving revision 1.17 retrieving revision 1.17.16.1 diff -C2 -d -r1.17 -r1.17.16.1 *** BaseHTTPServer.py 25 Jul 2001 06:12:16 -0000 1.17 --- BaseHTTPServer.py 8 Mar 2002 13:41:09 -0000 1.17.16.1 *************** *** 288,291 **** --- 288,292 ---- self.log_error("code %d, message %s", code, message) self.send_response(code, message) + self.send_header("Content-Type", "text/html") self.end_headers() self.wfile.write(self.error_message_format % From jackjansen@users.sourceforge.net Fri Mar 8 13:43:04 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 08 Mar 2002 05:43:04 -0800 Subject: [Python-checkins] CVS: python/dist/src configure.in,1.293,1.294 configure,1.284,1.285 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv26013 Modified Files: configure.in configure Log Message: When testing for availability of pthreads without special compiler options or libraries also look for thread_detach. SGI has thread_create in libc but complete pthread support only in -lpthread. Fixes #522393. 2.2.1 candidate.Killed by signal 2. Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.293 retrieving revision 1.294 diff -C2 -d -r1.293 -r1.294 *** configure.in 7 Mar 2002 09:58:56 -0000 1.293 --- configure.in 8 Mar 2002 13:43:01 -0000 1.294 *************** *** 466,469 **** --- 466,470 ---- if(pthread_create(&p,NULL,routine,NULL)!=0) return 1; + (void)pthread_detach(p); return 0; } *************** *** 498,501 **** --- 499,503 ---- if(pthread_create(&p,NULL,routine,NULL)!=0) return 1; + (void)pthread_detach(p); return 0; } Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.284 retrieving revision 1.285 diff -C2 -d -r1.284 -r1.285 *** configure 7 Mar 2002 09:59:15 -0000 1.284 --- configure 8 Mar 2002 13:43:01 -0000 1.285 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.292 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.293 [...4383 lines suppressed...] if eval "test \"`echo '$''{'ac_cv_type_socklen_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < *************** *** 7596,7600 **** SRCDIRS="Parser Grammar Objects Python Modules" echo $ac_n "checking for build directories""... $ac_c" 1>&6 ! echo "configure:7599: checking for build directories" >&5 for dir in $SRCDIRS; do if test ! -d $dir; then --- 7598,7602 ---- SRCDIRS="Parser Grammar Objects Python Modules" echo $ac_n "checking for build directories""... $ac_c" 1>&6 ! echo "configure:7601: checking for build directories" >&5 for dir in $SRCDIRS; do if test ! -d $dir; then From mwh@users.sourceforge.net Fri Mar 8 14:11:20 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Fri, 08 Mar 2002 06:11:20 -0800 Subject: [Python-checkins] CVS: python/dist/src configure.in,1.288.6.2,1.288.6.3 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv3255 Modified Files: Tag: release22-maint configure.in Log Message: backport jackjansen's checkin of revision 1.294 of configure.in revision 1.285 of configure When testing for availability of pthreads without special compiler options or libraries also look for thread_detach. SGI has thread_create in libc but complete pthread support only in -lpthread. Fixes #522393. 2.2.1 candidate.Killed by signal 2. Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.288.6.2 retrieving revision 1.288.6.3 diff -C2 -d -r1.288.6.2 -r1.288.6.3 *** configure.in 7 Mar 2002 10:04:49 -0000 1.288.6.2 --- configure.in 8 Mar 2002 14:11:18 -0000 1.288.6.3 *************** *** 466,469 **** --- 466,470 ---- if(pthread_create(&p,NULL,routine,NULL)!=0) return 1; + (void)pthread_detach(p); return 0; } *************** *** 498,501 **** --- 499,503 ---- if(pthread_create(&p,NULL,routine,NULL)!=0) return 1; + (void)pthread_detach(p); return 0; } From mwh@users.sourceforge.net Fri Mar 8 14:11:39 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Fri, 08 Mar 2002 06:11:39 -0800 Subject: [Python-checkins] CVS: python/dist/src configure,1.279.6.2,1.279.6.3 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv3351 Modified Files: Tag: release22-maint configure Log Message: backport jackjansen's checkin of revision 1.294 of configure.in revision 1.285 of configure When testing for availability of pthreads without special compiler options or libraries also look for thread_detach. SGI has thread_create in libc but complete pthread support only in -lpthread. Fixes #522393. 2.2.1 candidate.Killed by signal 2. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.279.6.2 retrieving revision 1.279.6.3 diff -C2 -d -r1.279.6.2 -r1.279.6.3 *** configure 7 Mar 2002 10:05:09 -0000 1.279.6.2 --- configure 8 Mar 2002 14:11:35 -0000 1.279.6.3 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.288.6.2 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.288.6.3 [...4350 lines suppressed...] if eval "test \"`echo '$''{'ac_cv_type_socklen_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < *************** *** 7545,7549 **** SRCDIRS="Parser Grammar Objects Python Modules" echo $ac_n "checking for build directories""... $ac_c" 1>&6 ! echo "configure:7548: checking for build directories" >&5 for dir in $SRCDIRS; do if test ! -d $dir; then --- 7547,7551 ---- SRCDIRS="Parser Grammar Objects Python Modules" echo $ac_n "checking for build directories""... $ac_c" 1>&6 ! echo "configure:7550: checking for build directories" >&5 for dir in $SRCDIRS; do if test ! -d $dir; then From gvanrossum@users.sourceforge.net Fri Mar 8 15:38:39 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 08 Mar 2002 07:38:39 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0285.txt,NONE,1.1 pep-0000.txt,1.164,1.165 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv29072 Modified Files: pep-0000.txt Added Files: pep-0285.txt Log Message: PEP 285: Adding a bool type --- NEW FILE: pep-0285.txt --- PEP: 285 Title: Adding a bool type Version: $Revision: 1.1 $ Last-Modified: $Date: 2002/03/08 15:38:37 $ Author: guido@python.org (Guido van Rossum) Status: Draft Type: Standards Track Created: 8-Mar-2002 Python-Version: 2.3 Post-History: 8-Mar-2002 (python-dev) Abstract This PEP proposes the introduction of a new built-in type, bool, with two constants, False and True. The bool type would be a straightforward subtype (in C) of the int type, and the values False and True would behave like 0 and 1 in most respects (e.g. False==0 and True==1 would be true) except repr() and str(). All built-in operations that conceptually return a Boolean result will be changed to return False or True instead of 0 or 1; for example, comparisons and the "not" operator. Rationale Most languages eventually grow a Boolean type; even C99 has one. It's useful to be able to tell from a function result that the outcome has Boolean semantics. Specification The following Python code specifies most of the properties of the new type: class bool(int): def __new__(cls, val=0, _create=0): if _create: # This is nor part of the spec, # just a hack to bootstrap False and True return int.__new__(cls, not not val) elif val: return True else: return False def __repr__(self): if self: return "True" else: return "False" __str__ = __repr__ def __and__(self, other): if isinstance(other, bool): return bool(int(self) & int(other)) else: return NotImplemented __rand__ = __and__ def __or__(self, other): if isinstance(other, bool): return bool(int(self) | int(other)) else: return NotImplemented __ror__ = __or__ def __xor__(self, other): if isinstance(other, bool): return bool(int(self) ^ int(other)) else: return NotImplemented __rxor__ = __xor__ False = bool(0, _create=1) True = bool(1, _create=1) Issues Because the repr() or str() of a bool value is different from an int value, some code (e.g. doctest-based unit tests) may fail. How much of a backwards compatibility problem this will be, I don't know. If we find this is a real problem, we could add a command-line option to make False and True aliases for 0 and 1 and bool an alias for int. Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil fill-column: 70 End: Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.164 retrieving revision 1.165 diff -C2 -d -r1.164 -r1.165 *** pep-0000.txt 8 Mar 2002 05:43:22 -0000 1.164 --- pep-0000.txt 8 Mar 2002 15:38:37 -0000 1.165 *************** *** 92,95 **** --- 92,96 ---- S 282 A Logging System Mick S 284 Integer for-loops Eppstein, Ewing + S 285 Adding a bool type van Rossum Finished PEPs (done, implemented in CVS) *************** *** 258,261 **** --- 259,263 ---- I 283 Python 2.3 Release Schedule Hylton S 284 Integer for-loops Eppstein, Ewing + S 285 Adding a bool type van Rossum SR 666 Reject Foolish Indentation Creighton From gvanrossum@users.sourceforge.net Fri Mar 8 16:15:07 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 08 Mar 2002 08:15:07 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0285.txt,1.1,1.2 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv11303 Modified Files: pep-0285.txt Log Message: Clarify issues baded upon the first questions. Don't add "(python-dev)" to Post-History header. Index: pep-0285.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0285.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pep-0285.txt 8 Mar 2002 15:38:37 -0000 1.1 --- pep-0285.txt 8 Mar 2002 16:15:04 -0000 1.2 *************** *** 8,12 **** Created: 8-Mar-2002 Python-Version: 2.3 ! Post-History: 8-Mar-2002 (python-dev) --- 8,12 ---- Created: 8-Mar-2002 Python-Version: 2.3 ! Post-History: 8-Mar-2002 *************** *** 82,85 **** --- 82,98 ---- False = bool(0, _create=1) True = bool(1, _create=1) + + The values False and True will be singletons, like None; the C + implementation will not allow other instances of bool to be + created. + + All built-in operations that are defined to return a Boolean + result will be changed to return False or True instead of 0 or 1. + In particular, this affects comparisons (<, <=, ==, !=, >, >=, is, + is not, in, not it), the unary operator 'not', and built-in + functions like hasattr(), isinstance() and issubclass(), the dict + method has_key(), string methods endswith(), isalnum(), isalpha(), + isdigit(), islower(), isspace(), istitle(), isupper(), and + startswith(), and the closed attribute of file objects. From jhylton@users.sourceforge.net Fri Mar 8 17:17:35 2002 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 08 Mar 2002 09:17:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules cStringIO.c,2.32,2.33 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv3697 Modified Files: cStringIO.c Log Message: Fix SF bug #526518 The doc string for cStringIO suggested that str() of a StringIO object was equivalent to getvalue(). This was never true, so repair the doc string. (doctest would have helped here.) Bug fix candidate for any past versions. Index: cStringIO.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cStringIO.c,v retrieving revision 2.32 retrieving revision 2.33 diff -C2 -d -r2.32 -r2.33 *** cStringIO.c 8 Dec 2001 18:02:56 -0000 2.32 --- cStringIO.c 8 Mar 2002 17:17:33 -0000 2.33 *************** *** 68,72 **** " an_output_stream.write(some_stuff)\n" " ...\n" ! " value=an_output_stream.getvalue() # str(an_output_stream) works too!\n" "\n" " an_input_stream=StringIO(a_string)\n" --- 68,72 ---- " an_output_stream.write(some_stuff)\n" " ...\n" ! " value=an_output_stream.getvalue()\n" "\n" " an_input_stream=StringIO(a_string)\n" From akuchling@users.sourceforge.net Fri Mar 8 17:19:12 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Fri, 08 Mar 2002 09:19:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/webchecker webchecker.py,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/webchecker In directory usw-pr-cvs1:/tmp/cvs-serv3956 Modified Files: webchecker.py Log Message: [Bug #512799] urllib.splittype() returns a 2-tuple. (Reported by seb bacon) Index: webchecker.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/webchecker/webchecker.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** webchecker.py 11 Dec 2001 22:41:24 -0000 1.25 --- webchecker.py 8 Mar 2002 17:19:10 -0000 1.26 *************** *** 482,486 **** return self.name_table[url] ! scheme = urllib.splittype(url) if scheme in ('mailto', 'news', 'javascript', 'telnet'): self.note(1, " Not checking %s URL" % scheme) --- 482,486 ---- return self.name_table[url] ! scheme, path = urllib.splittype(url) if scheme in ('mailto', 'news', 'javascript', 'telnet'): self.note(1, " Not checking %s URL" % scheme) From akuchling@users.sourceforge.net Fri Mar 8 17:46:05 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Fri, 08 Mar 2002 09:46:05 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libxmlrpclib.tex,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv12711 Modified Files: libxmlrpclib.tex Log Message: [Bug #486527] Note that the caller has to ensure there are no control characters in strings being passed via XML-RPC. Fix some typos. 2.2.1 bugfix candidate. Index: libxmlrpclib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libxmlrpclib.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** libxmlrpclib.tex 1 Oct 2001 21:05:30 -0000 1.5 --- libxmlrpclib.tex 8 Mar 2002 17:46:02 -0000 1.6 *************** *** 60,63 **** --- 60,73 ---- XML-RPC server errors, or \exception{ProtocolError} used to signal an error in the HTTP/HTTPS transport layer. + + When passing strings, characters special to XML such as \samp{<}, + \samp{>}, and \samp{\&} will be automatically escaped. However, it's + the caller's responsibility to ensure that the string is free of + characters that aren't allowed in XML, such as the control characters + with ASCII values between 0 and 31; failing to do this will result in + an XML-RPC request that isn't well-formed XML. If you have to pass + arbitrary strings via XML-RPC, use the \class{Binary} wrapper class + described below. + \end{classdesc} *************** *** 201,205 **** \begin{memberdesc}{url} ! The URI or URL that triggered te error. \end{memberdesc} --- 211,215 ---- \begin{memberdesc}{url} ! The URI or URL that triggered the error. \end{memberdesc} *************** *** 209,213 **** \begin{memberdesc}{errmsg} ! The eror message of diagnostic string. \end{memberdesc} --- 219,223 ---- \begin{memberdesc}{errmsg} ! The error message or diagnostic string. \end{memberdesc} From akuchling@users.sourceforge.net Fri Mar 8 18:08:50 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Fri, 08 Mar 2002 10:08:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib ConfigParser.py,1.38,1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv18758 Modified Files: ConfigParser.py Log Message: [Bug #523301] ConfigParser.write() produces broken output for values that were originally rfc822-like line continuations. Modified version of a patch from Matthias Ralfs. Index: ConfigParser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ConfigParser.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** ConfigParser.py 18 Oct 2001 21:57:37 -0000 1.38 --- ConfigParser.py 8 Mar 2002 18:08:47 -0000 1.39 *************** *** 345,349 **** fp.write("[DEFAULT]\n") for (key, value) in self.__defaults.items(): ! fp.write("%s = %s\n" % (key, value)) fp.write("\n") for section in self.sections(): --- 345,349 ---- fp.write("[DEFAULT]\n") for (key, value) in self.__defaults.items(): ! fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n") for section in self.sections(): *************** *** 353,357 **** if key == "__name__": continue ! fp.write("%s = %s\n" % (key, value)) fp.write("\n") --- 353,357 ---- if key == "__name__": continue ! fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n") From akuchling@users.sourceforge.net Fri Mar 8 18:10:14 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Fri, 08 Mar 2002 10:10:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_cfgparser,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv19827/output Modified Files: test_cfgparser Log Message: As part of fixing bug #523301, add a simple test of ConfigParser.write() Index: test_cfgparser =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_cfgparser,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_cfgparser 8 Oct 2001 17:13:12 -0000 1.5 --- test_cfgparser 8 Mar 2002 18:10:12 -0000 1.6 *************** *** 1,4 **** --- 1,5 ---- test_cfgparser Testing basic accessors... + Testing writing of files... Testing case sensitivity... Testing interpretation of boolean Values... From akuchling@users.sourceforge.net Fri Mar 8 18:10:14 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Fri, 08 Mar 2002 10:10:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_cfgparser.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv19827 Modified Files: test_cfgparser.py Log Message: As part of fixing bug #523301, add a simple test of ConfigParser.write() Index: test_cfgparser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cfgparser.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** test_cfgparser.py 8 Oct 2001 17:13:11 -0000 1.9 --- test_cfgparser.py 8 Mar 2002 18:10:12 -0000 1.10 *************** *** 15,18 **** --- 15,19 ---- r'Foo Bar', r'Internationalized Stuff', + r'Long Line', r'Section\with$weird%characters[' '\t', r'Spacey Bar', *************** *** 48,52 **** --- 49,72 ---- " that never existed") + verify(cf.get('Long Line', 'foo', raw=1) == + 'this line is much, much longer than my editor\nlikes it.') + + + def write(src): + print "Testing writing of files..." + cf = ConfigParser.ConfigParser() + sio = StringIO.StringIO(src) + cf.readfp(sio) + output = StringIO.StringIO() + cf.write(output) + verify(output, """[DEFAULT] + foo = another very + long line + [Long Line] + foo = this line is much, much longer than my editor + likes it. + """) + def case_sensitivity(): print "Testing case sensitivity..." *************** *** 192,195 **** --- 212,218 ---- [Commented Bar] foo: bar ; comment + [Long Line] + foo: this line is much, much longer than my editor + likes it. [Section\with$weird%characters[""" '\t' r"""] [Internationalized Stuff] *************** *** 199,202 **** --- 222,231 ---- foo[de]=Deutsch """) + write("""[Long Line] + foo: this line is much, much longer than my editor + likes it. + [DEFAULT] + foo: another very + long line""") case_sensitivity() boolean(r""" From akuchling@users.sourceforge.net Fri Mar 8 18:20:02 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Fri, 08 Mar 2002 10:20:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib asyncore.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv22297 Modified Files: asyncore.py Log Message: [Bug #517554] When a signal happens during the select call in asyncore.poll, the select fails with EINTR, which the code catches. However, the code fails to clear the r/w/e arrays (like poll3 does), which means it acts as if every descriptor had received all possible events. Bug report and patch by Cesar Eduardo Barros Index: asyncore.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/asyncore.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** asyncore.py 14 Dec 2001 16:15:11 -0000 1.28 --- asyncore.py 8 Mar 2002 18:19:59 -0000 1.29 *************** *** 81,84 **** --- 81,85 ---- if err[0] != EINTR: raise + r = []; w = []; e = [] if DEBUG: From akuchling@users.sourceforge.net Fri Mar 8 18:27:15 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Fri, 08 Mar 2002 10:27:15 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib asynchat.py,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv23896 Modified Files: asynchat.py Log Message: [Bug #491820] Define two abstract methods to shut up Pychecker, and for documentation purposes. These implementations are the same as the ones suggested by Skip in the bug report. Index: asynchat.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/asynchat.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** asynchat.py 8 Apr 2001 07:23:44 -0000 1.15 --- asynchat.py 8 Mar 2002 18:27:11 -0000 1.16 *************** *** 65,68 **** --- 65,74 ---- asyncore.dispatcher.__init__ (self, conn) + def collect_incoming_data(self, data): + raise NotImplementedError, "must be implemented in subclass" + + def found_terminator(self): + raise NotImplementedError, "must be implemented in subclass" + def set_terminator (self, term): "Set the input delimiter. Can be a fixed string of any length, an integer, or None" From gvanrossum@users.sourceforge.net Fri Mar 8 18:28:05 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 08 Mar 2002 10:28:05 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0285.txt,1.2,1.3 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv24565 Modified Files: pep-0285.txt Log Message: Some more clarifications. Index: pep-0285.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0285.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pep-0285.txt 8 Mar 2002 16:15:04 -0000 1.2 --- pep-0285.txt 8 Mar 2002 18:28:03 -0000 1.3 *************** *** 27,31 **** Most languages eventually grow a Boolean type; even C99 has one. It's useful to be able to tell from a function result that the ! outcome has Boolean semantics. --- 27,33 ---- Most languages eventually grow a Boolean type; even C99 has one. It's useful to be able to tell from a function result that the ! outcome has Boolean semantics, and it helps with things like RPC ! protocols that may prefer to encode Booleans differently from ! integers. *************** *** 37,46 **** class bool(int): ! def __new__(cls, val=0, _create=0): ! if _create: ! # This is nor part of the spec, ! # just a hack to bootstrap False and True ! return int.__new__(cls, not not val) ! elif val: return True else: --- 39,46 ---- class bool(int): ! def __new__(cls, val=0): ! # This constructor doesn't return a new instance; ! # it returns an existing instance ! if val: return True else: *************** *** 79,89 **** __rxor__ = __xor__ ! ! False = bool(0, _create=1) ! True = bool(1, _create=1) The values False and True will be singletons, like None; the C implementation will not allow other instances of bool to be ! created. All built-in operations that are defined to return a Boolean --- 79,91 ---- __rxor__ = __xor__ ! # Bootstrap truth values through sheer willpower ! False = int.__new__(bool, 0) ! True = int.__new__(bool, 1) The values False and True will be singletons, like None; the C implementation will not allow other instances of bool to be ! created. At the C level, the existing globals Py_False and ! Py_True will be identical to the built-in singletons False and ! True. All built-in operations that are defined to return a Boolean *************** *** 96,110 **** startswith(), and the closed attribute of file objects. Issues Because the repr() or str() of a bool value is different from an ! int value, some code (e.g. doctest-based unit tests) may fail. ! How much of a backwards compatibility problem this will be, I ! don't know. If we find this is a real problem, we could add a ! command-line option to make False and True aliases for 0 and 1 and ! bool an alias for int. - Copyright --- 98,121 ---- startswith(), and the closed attribute of file objects. + Note that subclassing from int means that True+1 is valid and + equals 2, and so on. This is important for backwards + compatibility: because comparisons and so on currently return + integer values, there's no way of telling what uses existing + applications make of these values. + Issues Because the repr() or str() of a bool value is different from an ! int value, some code (e.g. doctest-based unit tests, and possibly ! database code that relies on things like "%s" % truthvalue) may ! fail. How much of a backwards compatibility problem this will be, ! I don't know. If we find this is a real problem, we could add a ! command-line option to change the repr() and str() of False and ! True to be '0' and '1'; or we could make this the defined ! behavior, but that would defeat some of the purpose (being able to ! see that a printed result is intended to be a truth value). ! Copyright From jhylton@users.sourceforge.net Fri Mar 8 19:35:54 2002 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 08 Mar 2002 11:35:54 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib httplib.py,1.44,1.45 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv9042 Modified Files: httplib.py Log Message: SF bug report #405939: wrong Host header with proxy In August, Greg said this looked good, so I'm going ahead with it. The fix is different from the one in the bug report. Instead of using a regular expression to extract the host from the url, I use urlparse.urlsplit. Martin commented that the patch doesn't address URLs that have basic authentication username and password in the header. I don't see any code anywhere in httplib that supports this feature, so I'm not going to address it for this fix. Bug fix candidate. Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** httplib.py 16 Feb 2002 23:06:16 -0000 1.44 --- httplib.py 8 Mar 2002 19:35:51 -0000 1.45 *************** *** 70,73 **** --- 70,74 ---- import mimetools import socket + from urlparse import urlsplit try: *************** *** 468,474 **** # as Apache) barf when they see two Host: headers ! # if we need a non-standard port,include it in the header ! if self.port == HTTP_PORT: ! self.putheader('Host', self.host) else: self.putheader('Host', "%s:%s" % (self.host, self.port)) --- 469,481 ---- # as Apache) barf when they see two Host: headers ! # If we need a non-standard port,include it in the header. ! # If the request is going through a proxy, but the host of ! # the actual URL, not the host of the proxy. ! ! if url.startswith('http:'): ! nil, netloc, nil, nil, nil = urlsplit(url) ! self.putheader('Host', netloc) ! elif self.port == HTTP_PORT: ! self.putheader('Host', netloc) else: self.putheader('Host', "%s:%s" % (self.host, self.port)) *************** *** 856,859 **** --- 863,877 ---- print print h.getfile().read() + + # minimal test that code to extract host from url works + class HTTP11(HTTP): + _http_vsn = 11 + _http_vsn_str = 'HTTP/1.1' + + h = HTTP11('www.python.org') + h.putrequest('GET', 'http://www.python.org/~jeremy/') + h.endheaders() + h.getreply() + h.close() if hasattr(socket, 'ssl'): From akuchlin@mems-exchange.org Fri Mar 8 19:39:41 2002 From: akuchlin@mems-exchange.org (Andrew Kuchling) Date: Fri, 8 Mar 2002 14:39:41 -0500 Subject: [Python-checkins] CVS: python/dist/src/Lib httplib.py,1.44,1.45 In-Reply-To: References: Message-ID: <20020308193941.GA10846@ute.mems-exchange.org> On Fri, Mar 08, 2002 at 11:35:54AM -0800, Jeremy Hylton wrote: >SF bug report #405939: wrong Host header with proxy >! if url.startswith('http:'): >! nil, netloc, nil, nil, nil = urlsplit(url) Does it matter that this won't catch https:// URLs? --amk From jeremy@zope.com Fri Mar 8 19:43:22 2002 From: jeremy@zope.com (Jeremy Hylton) Date: Fri, 08 Mar 2002 14:43:22 -0500 Subject: [Python-checkins] CVS: python/dist/src/Lib httplib.py,1.44,1.45 In-Reply-To: <20020308193941.GA10846@ute.mems-exchange.org> Message-ID: On Fri, 8 Mar 2002 14:39:41 -0500 Andrew Kuchling wrote: > On Fri, Mar 08, 2002 at 11:35:54AM -0800, Jeremy Hylton > wrote: > >SF bug report #405939: wrong Host header with proxy > >! if url.startswith('http:'): > >! nil, netloc, nil, nil, nil = > urlsplit(url) > > Does it matter that this won't catch https:// URLs? Probably. I should probably change the initial test to startswith 'http' and then verify that the netloc return from urlsplit() is not ''. Sound good to you? Jeremy From gvanrossum@users.sourceforge.net Fri Mar 8 19:48:46 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 08 Mar 2002 11:48:46 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0285.txt,1.3,1.4 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv12633 Modified Files: pep-0285.txt Log Message: More rationale and issues. Index: pep-0285.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0285.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pep-0285.txt 8 Mar 2002 18:28:03 -0000 1.3 --- pep-0285.txt 8 Mar 2002 19:48:44 -0000 1.4 *************** *** 26,33 **** Most languages eventually grow a Boolean type; even C99 has one. ! It's useful to be able to tell from a function result that the ! outcome has Boolean semantics, and it helps with things like RPC ! protocols that may prefer to encode Booleans differently from ! integers. --- 26,78 ---- Most languages eventually grow a Boolean type; even C99 has one. ! ! Many programmers apparently feel the need for a Boolean type; most ! Python documentation contains a bit of an apology for the absence ! of a Boolean type. I've seen lots of module that defined ! constants "False=0" and "True=1" (or similar) at the top and used ! those. The problem with this is that everybody does it ! differently. For example, should you use "FALSE", "false", ! "False", "F" or even "f"? And should false be the value zero or ! None, or perhaps a truth value of a different type that will print ! as "true" or "false"? Adding a standard bool type to the language ! resolves those issues. ! ! Some external libraries (e.g. databases and RPC packages) need to ! be able to distinguish between Boolean and integral values, and ! while it's usually possible to create a solution, it would be ! easier if the language offered a standard Boolean type. ! ! And here's an argument derived from teaching Python. When showing ! people comparison operators etc. in the interactive shell, I think ! this is a bit ugly: ! ! >>> a = 13 ! >>> b = 12 ! >>> a > b ! 1 ! >>> ! ! If this was: ! ! >>> a > b ! True ! >>> ! ! it would require one millisecond less thinking each time a 0 or 1 ! was printed. ! ! There's also the issue (which I've seen puzzling even experienced ! Pythonistas who had been away from the language for a while) that if ! you see: ! ! >>> cmp(a, b) ! 1 ! >>> cmp(a, a) ! 0 ! >>> ! ! you might be tempted to believe that cmp() also returned a truth ! value. If ints are not (normally) used for Booleans results, this ! would stand out much more clearly as something completely different. *************** *** 111,119 **** database code that relies on things like "%s" % truthvalue) may fail. How much of a backwards compatibility problem this will be, ! I don't know. If we find this is a real problem, we could add a ! command-line option to change the repr() and str() of False and ! True to be '0' and '1'; or we could make this the defined ! behavior, but that would defeat some of the purpose (being able to ! see that a printed result is intended to be a truth value). --- 156,170 ---- database code that relies on things like "%s" % truthvalue) may fail. How much of a backwards compatibility problem this will be, ! I don't know. If we this turns out to be a real problem, we could ! changes the rules so that str() of a bool returns "0" or "1", ! while repr() of a bool still returns "False" or "True". ! ! Other languages (C99, C++, Java) name the constants "false" and ! "true", in all lowercase. In Python, I prefer to stick with the ! example set by the existing built-in constants, which all use ! CapitalizedWords: None, Ellipsis, NotImplemented (as well as all ! built-in exceptions). Python's built-in module uses all lowercase ! for functions and types only. But I'm willing to consider the ! lowercase alternatives if enough people think it looks better. From jhylton@users.sourceforge.net Fri Mar 8 21:11:39 2002 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 08 Mar 2002 13:11:39 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects abstract.c,2.96,2.97 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv1697 Modified Files: abstract.c Log Message: Fix for SF bug 516727: MyInt(2) + "3" -> NotImplemented PyNumber_Add() tries the nb_add slot first, then falls back to sq_concat. However, tt didn't check the return value of sq_concat. If sq_concat returns NotImplemented, raise the standard TypeError. Index: abstract.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v retrieving revision 2.96 retrieving revision 2.97 diff -C2 -d -r2.96 -r2.97 *** abstract.c 2 Mar 2002 04:14:21 -0000 2.96 --- abstract.c 8 Mar 2002 21:11:37 -0000 2.97 *************** *** 606,614 **** if (result == Py_NotImplemented) { PySequenceMethods *m = v->ob_type->tp_as_sequence; ! Py_DECREF(Py_NotImplemented); ! if (m && m->sq_concat) { result = (*m->sq_concat)(v, w); ! } ! else { PyErr_Format( PyExc_TypeError, --- 606,613 ---- if (result == Py_NotImplemented) { PySequenceMethods *m = v->ob_type->tp_as_sequence; ! Py_DECREF(result); ! if (m && m->sq_concat) result = (*m->sq_concat)(v, w); ! if (result == Py_NotImplemented) { PyErr_Format( PyExc_TypeError, From jhylton@users.sourceforge.net Fri Mar 8 21:28:56 2002 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 08 Mar 2002 13:28:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects abstract.c,2.97,2.98 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv6741 Modified Files: abstract.c Log Message: Fix leak of NotImplemented in previous checkin to PyNumber_Add(). If result == Py_NotImplemented, always DECREF it before assigning a new value to result. Index: abstract.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v retrieving revision 2.97 retrieving revision 2.98 diff -C2 -d -r2.97 -r2.98 *** abstract.c 8 Mar 2002 21:11:37 -0000 2.97 --- abstract.c 8 Mar 2002 21:28:54 -0000 2.98 *************** *** 606,619 **** if (result == Py_NotImplemented) { PySequenceMethods *m = v->ob_type->tp_as_sequence; ! Py_DECREF(result); ! if (m && m->sq_concat) result = (*m->sq_concat)(v, w); if (result == Py_NotImplemented) { ! PyErr_Format( PyExc_TypeError, "unsupported operand types for +: '%s' and '%s'", v->ob_type->tp_name, w->ob_type->tp_name); ! result = NULL; } } --- 606,621 ---- if (result == Py_NotImplemented) { PySequenceMethods *m = v->ob_type->tp_as_sequence; ! if (m && m->sq_concat) { ! Py_DECREF(result); result = (*m->sq_concat)(v, w); + } if (result == Py_NotImplemented) { ! Py_DECREF(result); ! PyErr_Format( PyExc_TypeError, "unsupported operand types for +: '%s' and '%s'", v->ob_type->tp_name, w->ob_type->tp_name); ! result = NULL; } } From jhylton@users.sourceforge.net Fri Mar 8 21:32:02 2002 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 08 Mar 2002 13:32:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_pyclbr.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv7405 Modified Files: test_pyclbr.py Log Message: Fix pyclbr test of httplib without really understanding pyclbr. It seems that the new class HTTP11 in httplib.test() isn't discoverable by pyclbr, which causes this test to fail. Index: test_pyclbr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pyclbr.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_pyclbr.py 3 Oct 2001 04:08:26 -0000 1.6 --- test_pyclbr.py 8 Mar 2002 21:31:59 -0000 1.7 *************** *** 141,145 **** cm('httplib', ignore=('error', # set with = ! 'HTTPS')) # not on all platforms cm('Cookie', ignore=('__str__', 'Cookie')) # set with = --- 141,146 ---- cm('httplib', ignore=('error', # set with = ! 'HTTPS', ! 'HTTP11')) # not on all platforms cm('Cookie', ignore=('__str__', 'Cookie')) # set with = From jhylton@users.sourceforge.net Fri Mar 8 21:43:54 2002 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 08 Mar 2002 13:43:54 -0800 Subject: [Python-checkins] CVS: python/dist/src configure.in,1.294,1.295 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv10559 Modified Files: configure.in Log Message: Add fix for AIX as reported by srubben in SF bug #477487. Untested, of course. Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.294 retrieving revision 1.295 diff -C2 -d -r1.294 -r1.295 *** configure.in 8 Mar 2002 13:43:01 -0000 1.294 --- configure.in 8 Mar 2002 21:43:51 -0000 1.295 *************** *** 293,297 **** case $ac_sys_system in AIX*) ! LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); $(LINKCC)";; dgux*) LINKCC="LD_RUN_PATH=$libdir $(LINKCC)";; --- 293,297 ---- case $ac_sys_system in AIX*) ! LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); $LINKCC";; dgux*) LINKCC="LD_RUN_PATH=$libdir $(LINKCC)";; From fdrake@users.sourceforge.net Fri Mar 8 22:02:08 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 08 Mar 2002 14:02:08 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/dist dist.tex,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory usw-pr-cvs1:/tmp/cvs-serv14250/dist Modified Files: dist.tex Log Message: Add more explanation of how data_files is used (esp. where the files end up in the installation and how that location is determined). Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** dist.tex 16 Aug 2001 21:25:24 -0000 1.36 --- dist.tex 8 Mar 2002 22:02:06 -0000 1.37 *************** *** 633,638 **** data files, anything which does not fit in the previous categories. ! \option{data\_files} specify a sequence of \code{(directory, files)} ! pairs in the following way: \begin{verbatim} --- 633,638 ---- data files, anything which does not fit in the previous categories. ! \option{data\_files} specifies a sequence of (\var{directory}, ! \var{files}) pairs in the following way: \begin{verbatim} *************** *** 644,647 **** --- 644,658 ---- Note that you can specify the directory names where the data files will be installed, but you cannot rename the data files themselves. + + Each (\var{directory}, \var{files}) pair in the sequence specifies the + installation directory and the files to install there. If + \var{directory} is a relative path, it is interpreted relative to the + installation prefix (Python's \code{sys.prefix} for pure-Python + packages, \code{sys.exec_prefix} for packages that contain extension + modules). Each file name in \var{files} is interpreted relative to + the \file{setup.py} script at the top of the package source + distribution. No directory information from \var{files} is used to + determine the final location of the installed file; only the name of + the file is used. You can specify the \option{data\_files} options as a simple sequence From fdrake@users.sourceforge.net Fri Mar 8 22:02:19 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 08 Mar 2002 14:02:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/dist dist.tex,1.36,1.36.16.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory usw-pr-cvs1:/tmp/cvs-serv14325/dist Modified Files: Tag: release22-maint dist.tex Log Message: Add more explanation of how data_files is used (esp. where the files end up in the installation and how that location is determined). Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.36 retrieving revision 1.36.16.1 diff -C2 -d -r1.36 -r1.36.16.1 *** dist.tex 16 Aug 2001 21:25:24 -0000 1.36 --- dist.tex 8 Mar 2002 22:02:17 -0000 1.36.16.1 *************** *** 633,638 **** data files, anything which does not fit in the previous categories. ! \option{data\_files} specify a sequence of \code{(directory, files)} ! pairs in the following way: \begin{verbatim} --- 633,638 ---- data files, anything which does not fit in the previous categories. ! \option{data\_files} specifies a sequence of (\var{directory}, ! \var{files}) pairs in the following way: \begin{verbatim} *************** *** 644,647 **** --- 644,658 ---- Note that you can specify the directory names where the data files will be installed, but you cannot rename the data files themselves. + + Each (\var{directory}, \var{files}) pair in the sequence specifies the + installation directory and the files to install there. If + \var{directory} is a relative path, it is interpreted relative to the + installation prefix (Python's \code{sys.prefix} for pure-Python + packages, \code{sys.exec_prefix} for packages that contain extension + modules). Each file name in \var{files} is interpreted relative to + the \file{setup.py} script at the top of the package source + distribution. No directory information from \var{files} is used to + determine the final location of the installed file; only the name of + the file is used. You can specify the \option{data\_files} options as a simple sequence From fdrake@users.sourceforge.net Fri Mar 8 22:02:28 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 08 Mar 2002 14:02:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/dist dist.tex,1.33,1.33.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory usw-pr-cvs1:/tmp/cvs-serv14367/dist Modified Files: Tag: release21-maint dist.tex Log Message: Add more explanation of how data_files is used (esp. where the files end up in the installation and how that location is determined). Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.33 retrieving revision 1.33.4.1 diff -C2 -d -r1.33 -r1.33.4.1 *** dist.tex 1 Mar 2001 18:35:43 -0000 1.33 --- dist.tex 8 Mar 2002 22:02:26 -0000 1.33.4.1 *************** *** 633,638 **** data files, anything which does not fit in the previous categories. ! \option{data\_files} specify a sequence of \code{(directory, files)} ! pairs in the following way: \begin{verbatim} --- 633,638 ---- data files, anything which does not fit in the previous categories. ! \option{data\_files} specifies a sequence of (\var{directory}, ! \var{files}) pairs in the following way: \begin{verbatim} *************** *** 644,647 **** --- 644,658 ---- Note that you can specify the directory names where the data files will be installed, but you cannot rename the data files themselves. + + Each (\var{directory}, \var{files}) pair in the sequence specifies the + installation directory and the files to install there. If + \var{directory} is a relative path, it is interpreted relative to the + installation prefix (Python's \code{sys.prefix} for pure-Python + packages, \code{sys.exec_prefix} for packages that contain extension + modules). Each file name in \var{files} is interpreted relative to + the \file{setup.py} script at the top of the package source + distribution. No directory information from \var{files} is used to + determine the final location of the installed file; only the name of + the file is used. You can specify the \option{data\_files} options as a simple sequence From tim_one@users.sourceforge.net Sat Mar 9 00:06:28 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 08 Mar 2002 16:06:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.247,2.248 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv11689/python/Python Modified Files: bltinmodule.c Log Message: Docstring for filter(): Someone on the Tutor list reasonably complained that it didn't tell enough of the truth. Bugfix candidate (I guess -- it helps and it's harmless). Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.247 retrieving revision 2.248 diff -C2 -d -r2.247 -r2.248 *** bltinmodule.c 12 Jan 2002 11:05:09 -0000 2.247 --- bltinmodule.c 9 Mar 2002 00:06:26 -0000 2.248 *************** *** 248,256 **** static char filter_doc[] = ! "filter(function, sequence) -> list\n\ ! \n\ ! Return a list containing those items of sequence for which function(item)\n\ ! is true. If function is None, return a list of items that are true."; ! static PyObject * --- 248,256 ---- static char filter_doc[] = ! "filter(function or None, sequence) -> list, tuple, or string\n" ! "\n" ! "Return those items of sequence for which function(item) is true. If\n" ! "function is None, return the items that are true. If sequence is a tuple\n" ! "or string, return the same type, else return a list."; static PyObject * From tim_one@users.sourceforge.net Sat Mar 9 04:58:26 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 08 Mar 2002 20:58:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include pyport.h,2.44,2.45 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv1957/python/Include Modified Files: pyport.h Log Message: SF bug 525705: [2.2] underflow raise OverflowException. Another year in the quest to out-guess random C behavior. Added macros Py_ADJUST_ERANGE1(X) and Py_ADJUST_ERANGE2(X, Y). The latter is useful for functions with complex results. Two corrections to errno- after-libm-call are attempted: 1. If the platform set errno to ERANGE due to underflow, clear errno. Some unknown subset of libm versions and link options do this. It's allowed by C89, but I never figured anyone would do it. 2. If the platform did not set errno but overflow occurred, force errno to ERANGE. C89 required setting errno to ERANGE, but C99 doesn't. Some unknown subset of libm versions and link options do it the C99 way now. Bugfix candidate, but hold off until some Linux people actually try it, with and without -lieee. I'll send a help plea to Python-Dev. Index: pyport.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pyport.h,v retrieving revision 2.44 retrieving revision 2.45 diff -C2 -d -r2.44 -r2.45 *** pyport.h 2 Mar 2002 08:43:19 -0000 2.44 --- pyport.h 9 Mar 2002 04:58:24 -0000 2.45 *************** *** 288,291 **** --- 288,326 ---- } while(0) + /* Py_ADJUST_ERANGE1(x) + * Py_ADJUST_ERANGE2(x, y) + * Set errno to 0 before calling a libm function, and invoke one of these + * macros after, passing the function result(s) (Py_ADJUST_ERANGE2 is useful + * for functions returning complex results). This makes two kinds of + * adjustments to errno: (A) If it looks like the platform libm set + * errno=ERANGE due to underflow, clear errno. (B) If it looks like the + * platform libm overflowed but didn't set errno, force errno to ERANGE. In + * effect, we're trying to force a useful implementation of C89 errno + * behavior. + * Caution: + * This isn't reliable. See Py_OVERFLOWED comments. + * X and Y may be evaluated more than once. + */ + #define Py_ADJUST_ERANGE1(X) \ + do { \ + if (errno == 0) { \ + if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \ + errno = ERANGE; \ + } \ + else if (errno == ERANGE && (X) == 0.0) \ + errno = 0; \ + } while(0) + + #define Py_ADJUST_ERANGE2(X, Y) \ + do { \ + if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL || \ + (Y) == Py_HUGE_VAL || (Y) == -Py_HUGE_VAL) { \ + if (errno == 0) \ + errno = ERANGE; \ + } \ + else if (errno == ERANGE) \ + errno = 0; \ + } while(0) + /************************************************************************** Prototypes that are missing from the standard include files on some systems From tim_one@users.sourceforge.net Sat Mar 9 04:58:26 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 08 Mar 2002 20:58:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules cmathmodule.c,2.27,2.28 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv1957/python/Modules Modified Files: cmathmodule.c Log Message: SF bug 525705: [2.2] underflow raise OverflowException. Another year in the quest to out-guess random C behavior. Added macros Py_ADJUST_ERANGE1(X) and Py_ADJUST_ERANGE2(X, Y). The latter is useful for functions with complex results. Two corrections to errno- after-libm-call are attempted: 1. If the platform set errno to ERANGE due to underflow, clear errno. Some unknown subset of libm versions and link options do this. It's allowed by C89, but I never figured anyone would do it. 2. If the platform did not set errno but overflow occurred, force errno to ERANGE. C89 required setting errno to ERANGE, but C99 doesn't. Some unknown subset of libm versions and link options do it the C99 way now. Bugfix candidate, but hold off until some Linux people actually try it, with and without -lieee. I'll send a help plea to Python-Dev. Index: cmathmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cmathmodule.c,v retrieving revision 2.27 retrieving revision 2.28 diff -C2 -d -r2.27 -r2.28 *** cmathmodule.c 6 Sep 2001 08:16:17 -0000 2.27 --- cmathmodule.c 9 Mar 2002 04:58:24 -0000 2.28 *************** *** 338,343 **** x = (*func)(x); PyFPE_END_PROTECT(x) ! Py_SET_ERANGE_IF_OVERFLOW(x.real); ! Py_SET_ERANGE_IF_OVERFLOW(x.imag); if (errno != 0) return math_error(); --- 338,342 ---- x = (*func)(x); PyFPE_END_PROTECT(x) ! Py_ADJUST_ERANGE2(x.real, x.imag); if (errno != 0) return math_error(); From tim_one@users.sourceforge.net Sat Mar 9 04:58:26 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 08 Mar 2002 20:58:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects floatobject.c,2.110,2.111 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv1957/python/Objects Modified Files: floatobject.c Log Message: SF bug 525705: [2.2] underflow raise OverflowException. Another year in the quest to out-guess random C behavior. Added macros Py_ADJUST_ERANGE1(X) and Py_ADJUST_ERANGE2(X, Y). The latter is useful for functions with complex results. Two corrections to errno- after-libm-call are attempted: 1. If the platform set errno to ERANGE due to underflow, clear errno. Some unknown subset of libm versions and link options do this. It's allowed by C89, but I never figured anyone would do it. 2. If the platform did not set errno but overflow occurred, force errno to ERANGE. C89 required setting errno to ERANGE, but C99 doesn't. Some unknown subset of libm versions and link options do it the C99 way now. Bugfix candidate, but hold off until some Linux people actually try it, with and without -lieee. I'll send a help plea to Python-Dev. Index: floatobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v retrieving revision 2.110 retrieving revision 2.111 diff -C2 -d -r2.110 -r2.111 *** floatobject.c 11 Dec 2001 20:31:34 -0000 2.110 --- floatobject.c 9 Mar 2002 04:58:24 -0000 2.111 *************** *** 578,584 **** ix = pow(iv, iw); PyFPE_END_PROTECT(ix) ! Py_SET_ERANGE_IF_OVERFLOW(ix); if (errno != 0) { ! /* XXX could it be another type of error? */ PyErr_SetFromErrno(PyExc_OverflowError); return NULL; --- 578,584 ---- ix = pow(iv, iw); PyFPE_END_PROTECT(ix) ! Py_ADJUST_ERANGE1(ix); if (errno != 0) { ! assert(errno == ERANGE); PyErr_SetFromErrno(PyExc_OverflowError); return NULL; From jhylton@users.sourceforge.net Sat Mar 9 06:07:25 2002 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Fri, 08 Mar 2002 22:07:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib httplib.py,1.45,1.46 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv14755 Modified Files: httplib.py Log Message: Fix SF bug 525520. Don't automatically add a Host: header if the headers passed to request() already has a Host key. Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** httplib.py 8 Mar 2002 19:35:51 -0000 1.45 --- httplib.py 9 Mar 2002 06:07:23 -0000 1.46 *************** *** 411,415 **** raise ! def putrequest(self, method, url): """Send a request to the server. --- 411,415 ---- raise ! def putrequest(self, method, url, skip_host=0): """Send a request to the server. *************** *** 462,483 **** # Issue some standard headers for better HTTP/1.1 compliance ! # this header is issued *only* for HTTP/1.1 connections. more ! # specifically, this means it is only issued when the client uses ! # the new HTTPConnection() class. backwards-compat clients will ! # be using HTTP/1.0 and those clients may be issuing this header ! # themselves. we should NOT issue it twice; some web servers (such ! # as Apache) barf when they see two Host: headers ! # If we need a non-standard port,include it in the header. ! # If the request is going through a proxy, but the host of ! # the actual URL, not the host of the proxy. ! if url.startswith('http:'): ! nil, netloc, nil, nil, nil = urlsplit(url) ! self.putheader('Host', netloc) ! elif self.port == HTTP_PORT: ! self.putheader('Host', netloc) ! else: ! self.putheader('Host', "%s:%s" % (self.host, self.port)) # note: we are assuming that clients will not attempt to set these --- 462,490 ---- # Issue some standard headers for better HTTP/1.1 compliance ! if not skip_host: ! # this header is issued *only* for HTTP/1.1 ! # connections. more specifically, this means it is ! # only issued when the client uses the new ! # HTTPConnection() class. backwards-compat clients ! # will be using HTTP/1.0 and those clients may be ! # issuing this header themselves. we should NOT issue ! # it twice; some web servers (such as Apache) barf ! # when they see two Host: headers ! # If we need a non-standard port,include it in the ! # header. If the request is going through a proxy, ! # but the host of the actual URL, not the host of the ! # proxy. ! netloc = '' ! if url.startswith('http'): ! nil, netloc, nil, nil, nil = urlsplit(url) ! ! if netloc: ! self.putheader('Host', netloc) ! elif self.port == HTTP_PORT: ! self.putheader('Host', self.host) ! else: ! self.putheader('Host', "%s:%s" % (self.host, self.port)) # note: we are assuming that clients will not attempt to set these *************** *** 537,541 **** def _send_request(self, method, url, body, headers): ! self.putrequest(method, url) if body: --- 544,555 ---- def _send_request(self, method, url, body, headers): ! # If headers already contains a host header, then define the ! # optional skip_host argument to putrequest(). The check is ! # harder because field names are case insensitive. ! if (headers.has_key('Host') ! or [k for k in headers.iterkeys() if k.lower() == "host"]): ! self.putrequest(method, url, skip_host=1) ! else: ! self.putrequest(method, url) if body: From loewis@users.sourceforge.net Sat Mar 9 10:06:17 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Sat, 09 Mar 2002 02:06:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ext building.tex,NONE,1.1 ext.tex,1.104,1.105 windows.tex,1.3,1.4 unix.tex,1.2,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory usw-pr-cvs1:/tmp/cvs-serv16657 Modified Files: ext.tex windows.tex Added Files: building.tex Removed Files: unix.tex Log Message: Patch #500136: Update Update ext build documentation. 2.2.1 candidate. --- NEW FILE: building.tex --- \chapter{Building C and \Cpp{} Extensions with distutils \label{building}} \sectionauthor{Martin v. L\"owis}{martin@v.loewis.de} Starting in Python 1.4, Python provides, on \UNIX{}, a special make file for building make files for building dynamically-linked extensions and custom interpreters. Starting with Python 2.0, this mechanism (known as related to Makefile.pre.in, and Setup files) is no longer supported. Building custom interpreters was rarely used, and extensions modules can be build using distutils. Building an extension module using distutils requires that distutils is installed on the build machine, which is included in Python 2.x and available separately for Python 1.5. Since distutils also supports creation of binary packages, users don't necessarily need a compiler and distutils to install the extension. A distutils package contains a driver script, \file{setup.py}. This is a plain Python file, which, in the most simple case, could look like this: \begin{verbatim} from distutils.core import setup, Extension module1 = Extension('demo', sources = ['demo.c']) setup (name = 'PackageName', version = '1.0', description = 'This is a demo package', ext_modules = [module1]) \end{verbatim} With this \file{setup.py}, and a file \file{demo.c}, running \begin{verbatim} python setup.py build \end{verbatim} will compile \file{demo.c}, and produce an extension module named \samp{demo} in the \file{build} directory. Depending on the system, the module file will end up in a subdirectory \file{build/lib.system}, and may have a name like \file{demo.so} or \file{demo.pyd}. In the \file{setup.py}, all execution is performed by calling the \samp{setup} function. This takes a variable number of keyword arguments, of which the example above uses only a subset. Specifically, the example specifies meta-information to build packages, and it specifies the contents of the package. Normally, a package will contain of addition modules, like Python source modules, documentation, subpackages, etc. Please refer to the distutils documentation in \citetitle[../dist/dist.html]{Distributing Python Modules} to learn more about the features of distutils; this section explains building extension modules only. It is common to pre-compute arguments to \function{setup}, to better structure the driver script. In the example above, the\samp{ext_modules} argument to \function{setup} is a list of extension modules, each of which is an instance of the \class{Extension}. In the example, the instance defines an extension named \samp{demo} which is build by compiling a single source file, \file{demo.c}. In many cases, building an extension is more complex, since additional preprocessor defines and libraries may be needed. This is demonstrated in the example below. \begin{verbatim} from distutils.core import setup, Extension module1 = Extension('demo', define_macros = [('MAJOR_VERSION', '1'), ('MINOR_VERSION', '0')], include_dirs = ['/usr/local/include'], libraries = ['tcl83'], library_dirs = ['/usr/local/lib'], sources = ['demo.c']) setup (name = 'PackageName', version = '1.0', description = 'This is a demo package', author = 'Martin v. Loewis', author_email = 'martin@v.loewis.de', url = 'http://www.python.org/doc/current/ext/building.html', long_description = ''' This is really just a demo package. ''', ext_modules = [module1]) \end{verbatim} In this example, \function{setup} is called with additional meta-information, which is recommended when distribution packages have to be built. For the extension itself, it specifies preprocessor defines, include directories, library directories, and libraries. Depending on the compiler, distutils passes this information in different ways to the compiler. For example, on \UNIX{}, this may result in the compilation commands \begin{verbatim} gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -DMAJOR_VERSION=1 -DMINOR_VERSION=0 -I/usr/local/include -I/usr/local/include/python2.2 -c demo.c -o build/temp.linux-i686-2.2/demo.o gcc -shared build/temp.linux-i686-2.2/demo.o -L/usr/local/lib -ltcl83 -o build/lib.linux-i686-2.2/demo.so \end{verbatim} These lines are for demonstration purposes only; distutils users should trust that distutils gets the invocations right. \section{Distributing your extension modules \label{distributing}} When an extension has been successfully build, there are three ways to use it. End-users will typically want to install the module, they do so by running \begin{verbatim} python setup.py install \end{verbatim} Module maintainers should produce source packages; to do so, they run \begin{verbatim} python setup.py sdist \end{verbatim} In some cases, additional files need to be included in a source distribution; this is done through a \file{MANIFEST.in} file; see the distutils documentation for details. If the source distribution has been build successfully, maintainers can also create binary distributions. Depending on the platform, one of the following commands can be used to do so. \begin{verbatim} python setup.py bdist_wininst python setup.py bdist_rpm python setup.py bdist_dumb \end{verbatim} Index: ext.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/ext.tex,v retrieving revision 1.104 retrieving revision 1.105 diff -C2 -d -r1.104 -r1.105 *** ext.tex 20 Aug 2001 19:30:29 -0000 1.104 --- ext.tex 9 Mar 2002 10:06:14 -0000 1.105 *************** *** 53,57 **** \input{extending} \input{newtypes} ! \input{unix} \input{windows} \input{embedding} --- 53,57 ---- \input{extending} \input{newtypes} ! \input{building} \input{windows} \input{embedding} Index: windows.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/windows.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** windows.tex 13 Dec 2001 17:20:32 -0000 1.3 --- windows.tex 9 Mar 2002 10:06:14 -0000 1.4 *************** *** 10,13 **** --- 10,17 ---- software which can be successfully built on both \UNIX{} and Windows. + Module authors are encouraged to use the distutils approach for + building extension modules, instead of the one described in this + section. You will still need the C compiler that was used to build + Python; typically Microsoft Visual \Cpp. \section{A Cookbook Approach \label{win-cookbook}} --- unix.tex DELETED --- From loewis@users.sourceforge.net Sat Mar 9 12:03:01 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Sat, 09 Mar 2002 04:03:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects longobject.c,1.114,1.115 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv4126 Modified Files: longobject.c Log Message: Patch #494047: removes 64-bit ?: to cope on plan9. Index: longobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/longobject.c,v retrieving revision 1.114 retrieving revision 1.115 diff -C2 -d -r1.114 -r1.115 *** longobject.c 2 Mar 2002 04:18:04 -0000 1.114 --- longobject.c 9 Mar 2002 12:02:59 -0000 1.115 *************** *** 695,699 **** SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 1); ! return res < 0 ? (LONG_LONG)res : bytes; } --- 695,703 ---- SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 1); ! /* Plan 9 can't handle LONG_LONG in ? : expressions */ ! if (res < 0) ! return (LONG_LONG)res; ! else ! return bytes; } *************** *** 717,721 **** SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 0); ! return res < 0 ? (unsigned LONG_LONG)res : bytes; } --- 721,729 ---- SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 0); ! /* Plan 9 can't handle LONG_LONG in ? : expressions */ ! if (res < 0) ! return (unsigned LONG_LONG)res; ! else ! return bytes; } From loewis@users.sourceforge.net Sat Mar 9 12:07:53 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Sat, 09 Mar 2002 04:07:53 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.248,2.249 errors.c,2.67,2.68 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv5110 Modified Files: bltinmodule.c errors.c Log Message: Patch #494045: patches errno and stat to cope on plan9. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.248 retrieving revision 2.249 diff -C2 -d -r2.248 -r2.249 *** bltinmodule.c 9 Mar 2002 00:06:26 -0000 2.248 --- bltinmodule.c 9 Mar 2002 12:07:51 -0000 2.249 *************** *** 537,543 **** PyCompilerFlags cf; int exists; - #ifndef RISCOS - struct stat s; - #endif if (!PyArg_ParseTuple(args, "s|O!O!:execfile", --- 537,540 ---- *************** *** 561,576 **** exists = 0; /* Test for existence or directory. */ ! #ifndef RISCOS ! if (!stat(filename, &s)) { ! if (S_ISDIR(s.st_mode)) ! #if defined(PYOS_OS2) && defined(PYCC_VACPP) ! errno = EOS2ERR; ! #else ! errno = EISDIR; ! #endif ! else ! exists = 1; } ! #else if (object_exists(filename)) { if (isdir(filename)) --- 558,574 ---- exists = 0; /* Test for existence or directory. */ ! #if defined(PLAN9) ! { ! Dir *d; ! ! if ((d = dirstat(filename))!=nil) { ! if(d->mode & DMDIR) ! werrstr("is a directory"); ! else ! exists = 1; ! free(d); ! } } ! #elif defined(RISCOS) if (object_exists(filename)) { if (isdir(filename)) *************** *** 579,583 **** exists = 1; } ! #endif /* RISCOS */ if (exists) { --- 577,595 ---- exists = 1; } ! #else /* standard Posix */ ! { ! struct stat s; ! if (stat(filename, &s) == 0) { ! if (S_ISDIR(s.st_mode)) ! # if defined(PY_OS2) && defined(PYCC_VACPP) ! errno = EOS2ERR; ! # else ! errno = EISDIR; ! # endif ! else ! exists = 1; ! } ! } ! #endif if (exists) { Index: errors.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/errors.c,v retrieving revision 2.67 retrieving revision 2.68 diff -C2 -d -r2.67 -r2.68 *** errors.c 3 Mar 2002 21:30:27 -0000 2.67 --- errors.c 9 Mar 2002 12:07:51 -0000 2.68 *************** *** 265,268 **** --- 265,271 ---- char *s; int i = errno; + #ifdef PLAN9 + char errbuf[ERRMAX]; + #endif #ifdef MS_WIN32 char *s_buf = NULL; *************** *** 272,275 **** --- 275,282 ---- return NULL; #endif + #ifdef PLAN9 + rerrstr(errbuf, sizeof errbuf); + s = errbuf; + #else if (i == 0) s = "Error"; /* Sometimes errno didn't get set */ *************** *** 306,310 **** } } ! #endif if (filename != NULL) v = Py_BuildValue("(iss)", i, s, filename); --- 313,318 ---- } } ! #endif /* Unix/Windows */ ! #endif /* PLAN 9*/ if (filename != NULL) v = Py_BuildValue("(iss)", i, s, filename); From loewis@users.sourceforge.net Sat Mar 9 12:10:56 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Sat, 09 Mar 2002 04:10:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python thread.c,2.40,2.41 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv5662 Modified Files: thread.c Log Message: Patch #504224: add plan9 threads include to thread.c. Index: thread.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread.c,v retrieving revision 2.40 retrieving revision 2.41 diff -C2 -d -r2.40 -r2.41 *** thread.c 12 Jan 2002 11:05:11 -0000 2.40 --- thread.c 9 Mar 2002 12:10:54 -0000 2.41 *************** *** 134,137 **** --- 134,141 ---- #endif + #ifdef PLAN9_THREADS + #include "thread_plan9.h" + #endif + /* #ifdef FOOBAR_THREADS From gvanrossum@users.sourceforge.net Sat Mar 9 14:53:06 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sat, 09 Mar 2002 06:53:06 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0285.txt,1.4,1.5 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv763 Modified Files: pep-0285.txt Log Message: Fix subtle bugs in &|^ overloading. Index: pep-0285.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0285.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pep-0285.txt 8 Mar 2002 19:48:44 -0000 1.4 --- pep-0285.txt 9 Mar 2002 14:53:04 -0000 1.5 *************** *** 104,108 **** return bool(int(self) & int(other)) else: ! return NotImplemented __rand__ = __and__ --- 104,108 ---- return bool(int(self) & int(other)) else: ! return int.__and__(self, other) __rand__ = __and__ *************** *** 112,116 **** return bool(int(self) | int(other)) else: ! return NotImplemented __ror__ = __or__ --- 112,116 ---- return bool(int(self) | int(other)) else: ! return int.__or__(self, other) __ror__ = __or__ *************** *** 120,124 **** return bool(int(self) ^ int(other)) else: ! return NotImplemented __rxor__ = __xor__ --- 120,124 ---- return bool(int(self) ^ int(other)) else: ! return int.__xor__(self, other) __rxor__ = __xor__ From gvanrossum@users.sourceforge.net Sun Mar 10 03:36:17 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sat, 09 Mar 2002 19:36:17 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0285.txt,1.5,1.6 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv26723 Modified Files: pep-0285.txt Log Message: Add callable() to the list of functions returning 'bool'. Index: pep-0285.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0285.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pep-0285.txt 9 Mar 2002 14:53:04 -0000 1.5 --- pep-0285.txt 10 Mar 2002 03:36:14 -0000 1.6 *************** *** 138,145 **** In particular, this affects comparisons (<, <=, ==, !=, >, >=, is, is not, in, not it), the unary operator 'not', and built-in ! functions like hasattr(), isinstance() and issubclass(), the dict ! method has_key(), string methods endswith(), isalnum(), isalpha(), ! isdigit(), islower(), isspace(), istitle(), isupper(), and ! startswith(), and the closed attribute of file objects. Note that subclassing from int means that True+1 is valid and --- 138,146 ---- In particular, this affects comparisons (<, <=, ==, !=, >, >=, is, is not, in, not it), the unary operator 'not', and built-in ! functions like callable(), hasattr(), isinstance() and ! issubclass(), the dict method has_key(), string methods ! endswith(), isalnum(), isalpha(), isdigit(), islower(), isspace(), ! istitle(), isupper(), and startswith(), and the closed attribute ! of file objects. Note that subclassing from int means that True+1 is valid and From gvanrossum@users.sourceforge.net Sun Mar 10 04:46:52 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sat, 09 Mar 2002 20:46:52 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0285.txt,1.6,1.7 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv4767 Modified Files: pep-0285.txt Log Message: Some clarifications. Add section on compatibility (and why this means our bool is not very 'pure'). Index: pep-0285.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0285.txt,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pep-0285.txt 10 Mar 2002 03:36:14 -0000 1.6 --- pep-0285.txt 10 Mar 2002 04:46:49 -0000 1.7 *************** *** 16,24 **** with two constants, False and True. The bool type would be a straightforward subtype (in C) of the int type, and the values ! False and True would behave like 0 and 1 in most respects (e.g. ! False==0 and True==1 would be true) except repr() and str(). All ! built-in operations that conceptually return a Boolean result will ! be changed to return False or True instead of 0 or 1; for example, ! comparisons and the "not" operator. --- 16,24 ---- with two constants, False and True. The bool type would be a straightforward subtype (in C) of the int type, and the values ! False and True would behave like 0 and 1 in most respects (for ! example, False==0 and True==1 would be true) except repr() and ! str(). All built-in operations that conceptually return a Boolean ! result will be changed to return False or True instead of 0 or 1; ! for example, comparisons and the "not" operator. *************** *** 38,42 **** resolves those issues. ! Some external libraries (e.g. databases and RPC packages) need to be able to distinguish between Boolean and integral values, and while it's usually possible to create a solution, it would be --- 38,42 ---- resolves those issues. ! Some external libraries (like databases and RPC packages) need to be able to distinguish between Boolean and integral values, and while it's usually possible to create a solution, it would be *************** *** 137,146 **** result will be changed to return False or True instead of 0 or 1. In particular, this affects comparisons (<, <=, ==, !=, >, >=, is, ! is not, in, not it), the unary operator 'not', and built-in ! functions like callable(), hasattr(), isinstance() and ! issubclass(), the dict method has_key(), string methods endswith(), isalnum(), isalpha(), isdigit(), islower(), isspace(), ! istitle(), isupper(), and startswith(), and the closed attribute ! of file objects. Note that subclassing from int means that True+1 is valid and --- 137,147 ---- result will be changed to return False or True instead of 0 or 1. In particular, this affects comparisons (<, <=, ==, !=, >, >=, is, ! is not, in, not it), the unary operator 'not', the built-in ! functions callable(), hasattr(), isinstance() and issubclass(), ! the dict method has_key(), the string and unicode methods endswith(), isalnum(), isalpha(), isdigit(), islower(), isspace(), ! istitle(), isupper(), and startswith(), the unicode methods ! isdecimal() and isnumeric(), and the closed attribute of file ! objects. Note that subclassing from int means that True+1 is valid and *************** *** 151,163 **** Issues Because the repr() or str() of a bool value is different from an ! int value, some code (e.g. doctest-based unit tests, and possibly ! database code that relies on things like "%s" % truthvalue) may ! fail. How much of a backwards compatibility problem this will be, ! I don't know. If we this turns out to be a real problem, we could ! changes the rules so that str() of a bool returns "0" or "1", ! while repr() of a bool still returns "False" or "True". Other languages (C99, C++, Java) name the constants "false" and --- 152,185 ---- + Compatibility + + Because of backwards compatibility, the bool type lacks many + properties that some would like to see. For example, arithmetic + operations with one or two bool arguments is allowed, treating + False as 0 and True as 1. Also, a bool may be used as a sequence + index. + + I don't see this as a problem, and I don't want evolve the + language in this direction either; I don't believe that a stricter + interpretation of "Booleanness" makes the language much clearer. + + Another consequence of the compatibility requirement is that the + expression "True and 6" has the value 6, and similarly the + expression "False or 0" has the value 0. The "and" and "or" + operators are usefully defined to return the first argument that + determines the outcome. Of course, if both arguments are bools, + the outcome is always a bool. It can also easily be coerced into + being a bool by writing for example "bool(x and y)". + + Issues Because the repr() or str() of a bool value is different from an ! int value, some code (for example doctest-based unit tests, and ! possibly database code that relies on things like "%s" % truth) ! may fail. How much of a backwards compatibility problem this will ! be, I don't know. If we this turns out to be a real problem, we ! could changes the rules so that str() of a bool returns "0" or ! "1", while repr() of a bool still returns "False" or "True". Other languages (C99, C++, Java) name the constants "false" and From gvanrossum@users.sourceforge.net Sun Mar 10 05:47:38 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sat, 09 Mar 2002 21:47:38 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0285.txt,1.7,1.8 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv13503 Modified Files: pep-0285.txt Log Message: Add link to implementation. Index: pep-0285.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0285.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pep-0285.txt 10 Mar 2002 04:46:49 -0000 1.7 --- pep-0285.txt 10 Mar 2002 05:47:36 -0000 1.8 *************** *** 192,195 **** --- 192,203 ---- + Implementation + + An experimental, but fairly complete implementation in C has been + uploaded to the SourceForge patch manager: + + http://sourceforge.net/tracker/index.php?func=detail&aid=528022&group_id=5470&atid=305470 + + Copyright From tim_one@users.sourceforge.net Sun Mar 10 07:59:15 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 09 Mar 2002 23:59:15 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_generators.py,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv29778/python/Lib/test Modified Files: test_generators.py Log Message: SF patch 499062: Minor typo in test_generators.py. There's no actual patch there. It's an objection that Guido's example doesn't actually generator "leaves", so change the comment that says it does. Index: test_generators.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_generators.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** test_generators.py 6 Dec 2001 06:23:25 -0000 1.30 --- test_generators.py 10 Mar 2002 07:59:13 -0000 1.31 *************** *** 260,264 **** >>> t = tree("ABCDEFGHIJKLMNOPQRSTUVWXYZ") ! >>> # A recursive generator that generates Tree leaves in in-order. >>> def inorder(t): ... if t: --- 260,264 ---- >>> t = tree("ABCDEFGHIJKLMNOPQRSTUVWXYZ") ! >>> # A recursive generator that generates Tree labels in in-order. >>> def inorder(t): ... if t: From tim_one@users.sourceforge.net Sun Mar 10 07:59:30 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 09 Mar 2002 23:59:30 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0255.txt,1.17,1.18 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv29951 Modified Files: pep-0255.txt Log Message: SF patch 499062: Minor typo in test_generators.py. There's no actual patch there. It's an objection that Guido's example doesn't actually generator "leaves", so change the comment that says it does. Index: pep-0255.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0255.txt,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** pep-0255.txt 15 Aug 2001 05:46:40 -0000 1.17 --- pep-0255.txt 10 Mar 2002 07:59:28 -0000 1.18 *************** *** 323,327 **** return Tree(list[i], tree(list[:i]), tree(list[i+1:])) ! # A recursive generator that generates Tree leaves in in-order. def inorder(t): if t: --- 323,327 ---- return Tree(list[i], tree(list[:i]), tree(list[i+1:])) ! # A recursive generator that generates Tree labels in in-order. def inorder(t): if t: From gvanrossum@users.sourceforge.net Sun Mar 10 14:11:19 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sun, 10 Mar 2002 06:11:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.127,2.128 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv27065 Modified Files: typeobject.c Log Message: Bugfix candidate. Adapter from SF patch 528038; fixes SF bug 527816. The wrapper for __nonzero__ should be wrap_inquiry rather than wrap_unaryfunc, since the slot returns an int, not a PyObject *. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.127 retrieving revision 2.128 diff -C2 -d -r2.127 -r2.128 *** typeobject.c 18 Feb 2002 17:46:48 -0000 2.127 --- typeobject.c 10 Mar 2002 14:11:16 -0000 2.128 *************** *** 3509,3513 **** UNSLOT("__abs__", nb_absolute, slot_nb_absolute, wrap_unaryfunc, "abs(x)"), ! UNSLOT("__nonzero__", nb_nonzero, slot_nb_nonzero, wrap_unaryfunc, "x != 0"), UNSLOT("__invert__", nb_invert, slot_nb_invert, wrap_unaryfunc, "~x"), --- 3509,3513 ---- UNSLOT("__abs__", nb_absolute, slot_nb_absolute, wrap_unaryfunc, "abs(x)"), ! UNSLOT("__nonzero__", nb_nonzero, slot_nb_nonzero, wrap_inquiry, "x != 0"), UNSLOT("__invert__", nb_invert, slot_nb_invert, wrap_unaryfunc, "~x"), From loewis@users.sourceforge.net Sun Mar 10 16:00:01 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Sun, 10 Mar 2002 08:00:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib ftplib.py,1.65,1.66 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv27998 Modified Files: ftplib.py Log Message: Access the exception argument to see whether it starts with '500'. Fixes #527855. Index: ftplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ftplib.py,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** ftplib.py 16 Feb 2002 23:06:15 -0000 1.65 --- ftplib.py 10 Mar 2002 15:59:58 -0000 1.66 *************** *** 488,493 **** return self.voidcmd('CDUP') except error_perm, msg: ! if msg[:3] != '500': ! raise error_perm, msg elif dirname == '': dirname = '.' # does nothing, but could return error --- 488,493 ---- return self.voidcmd('CDUP') except error_perm, msg: ! if msg.args[0][:3] != '500': ! raise elif dirname == '': dirname = '.' # does nothing, but could return error From jvr@users.sourceforge.net Sun Mar 10 19:28:04 2002 From: jvr@users.sourceforge.net (Just van Rossum) Date: Sun, 10 Mar 2002 11:28:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Lib macostools.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib In directory usw-pr-cvs1:/tmp/cvs-serv3745 Modified Files: macostools.py Log Message: mkalias() now also works for folders. Fixes bug #515830. Index: macostools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Lib/macostools.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** macostools.py 21 Jan 2002 23:02:03 -0000 1.13 --- macostools.py 10 Mar 2002 19:28:02 -0000 1.14 *************** *** 35,41 **** else: alias = srcfss.NewAlias() ! srcfinfo = srcfss.GetFInfo() ! ! Res.FSpCreateResFile(dstfss, srcfinfo.Creator, srcfinfo.Type, -1) h = Res.FSpOpenResFile(dstfss, 3) resource = Res.Resource(alias.data) --- 35,45 ---- else: alias = srcfss.NewAlias() ! ! if os.path.isdir(src): ! cr, tp = 'MACS', 'fdrp' ! else: ! cr, tp = srcfss.GetCreatorType() ! ! Res.FSpCreateResFile(dstfss, cr, tp, -1) h = Res.FSpOpenResFile(dstfss, 3) resource = Res.Resource(alias.data) From jackjansen@users.sourceforge.net Sun Mar 10 21:29:57 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 10 Mar 2002 13:29:57 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Tools/IDE PyDebugger.py,1.8,1.8.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory usw-pr-cvs1:/tmp/cvs-serv32509/Mac/Tools/IDE Modified Files: Tag: release22-maint PyDebugger.py Log Message: Backport of 1.9 (missed last time around): Changes by Donovan Preston (and a few minor ones by me) to make IDE run under MachoPython. Mainly making sure we don't call routines that don't exist and representing pathnames in a os.separator-neutral format. Index: PyDebugger.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PyDebugger.py,v retrieving revision 1.8 retrieving revision 1.8.6.1 diff -C2 -d -r1.8 -r1.8.6.1 *** PyDebugger.py 18 Nov 2001 14:12:43 -0000 1.8 --- PyDebugger.py 10 Mar 2002 21:29:55 -0000 1.8.6.1 *************** *** 497,501 **** try: try: ! MacOS.EnableAppswitch(0) if self.quitting: # returning None is not enough, a former BdbQuit exception --- 497,502 ---- try: try: ! if hasattr(MacOS, 'EnableAppswitch'): ! MacOS.EnableAppswitch(0) if self.quitting: # returning None is not enough, a former BdbQuit exception *************** *** 513,517 **** return self.trace_dispatch finally: ! MacOS.EnableAppswitch(-1) except KeyboardInterrupt: self.set_step() --- 514,519 ---- return self.trace_dispatch finally: ! if hasattr(MacOS, 'EnableAppswitch'): ! MacOS.EnableAppswitch(-1) except KeyboardInterrupt: self.set_step() From jackjansen@users.sourceforge.net Sun Mar 10 21:33:21 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 10 Mar 2002 13:33:21 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/waste wastemodule.c,1.21,1.21.4.1 wastescan.py,1.7,1.7.22.1 wastesupport.py,1.14,1.14.20.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/waste In directory usw-pr-cvs1:/tmp/cvs-serv526 Modified Files: Tag: release22-maint wastemodule.c wastescan.py wastesupport.py Log Message: Backport of 1.22: Use waste included with CW in stead of separate package. (But a truer log message would have been "updated to current version of waste", as in MachoPython we use a normal standalone separate Waste distribution). Index: wastemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/waste/wastemodule.c,v retrieving revision 1.21 retrieving revision 1.21.4.1 diff -C2 -d -r1.21 -r1.21.4.1 *** wastemodule.c 18 Dec 2001 15:36:13 -0000 1.21 --- wastemodule.c 10 Mar 2002 21:33:19 -0000 1.21.4.1 *************** *** 267,270 **** --- 267,294 ---- } + static PyObject *WEOObj_WEGetObjectOwner(WEOObject *_self, PyObject *_args) + { + PyObject *_res = NULL; + WEReference _rv; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = WEGetObjectOwner(_self->ob_itself); [...2589 lines suppressed...] --- 2425,2443 ---- "() -> None"}, {"WEHandleTSMEvent", (PyCFunction)waste_WEHandleTSMEvent, 1, ! "(AppleEvent inAppleEvent) -> (AppleEvent ioReply)"}, {"WELongPointToPoint", (PyCFunction)waste_WELongPointToPoint, 1, ! "(LongPt inLongPoint) -> (Point outPoint)"}, {"WEPointToLongPoint", (PyCFunction)waste_WEPointToLongPoint, 1, ! "(Point inPoint) -> (LongPt outLongPoint)"}, {"WESetLongRect", (PyCFunction)waste_WESetLongRect, 1, ! "(SInt32 inLeft, SInt32 inTop, SInt32 inRight, SInt32 inBottom) -> (LongRect outLongRect)"}, {"WELongRectToRect", (PyCFunction)waste_WELongRectToRect, 1, ! "(LongRect inLongRect) -> (Rect outRect)"}, {"WERectToLongRect", (PyCFunction)waste_WERectToLongRect, 1, ! "(Rect inRect) -> (LongRect outLongRect)"}, {"WEOffsetLongRect", (PyCFunction)waste_WEOffsetLongRect, 1, ! "(SInt32 inHorizontalOffset, SInt32 inVerticalOffset) -> (LongRect ioLongRect)"}, {"WELongPointInLongRect", (PyCFunction)waste_WELongPointInLongRect, 1, ! "(LongPt inLongPoint, LongRect inLongRect) -> (Boolean _rv)"}, {"STDObjectHandlers", (PyCFunction)waste_STDObjectHandlers, 1, NULL}, Index: wastescan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/waste/wastescan.py,v retrieving revision 1.7 retrieving revision 1.7.22.1 diff -C2 -d -r1.7 -r1.7.22.1 *** wastescan.py 17 Apr 1998 14:07:55 -0000 1.7 --- wastescan.py 10 Mar 2002 21:33:19 -0000 1.7.22.1 *************** *** 5,12 **** BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen') sys.path.append(BGENDIR) ! from scantools import Scanner_PreUH3 from bgenlocations import MWERKSDIR, TOOLBOXDIR ! WASTEDIR=":::::Waste 1.3 Distribution:WASTE C/C++ Headers:" OBJECT = "TEHandle" --- 5,13 ---- BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen') sys.path.append(BGENDIR) ! from scantools import Scanner from bgenlocations import MWERKSDIR, TOOLBOXDIR ! #WASTEDIR=":::::Waste 1.3 Distribution:WASTE C/C++ Headers:" ! WASTEDIR=MWERKSDIR + 'MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers:' OBJECT = "TEHandle" *************** *** 27,31 **** print "=== Done. It's up to you to compile it now! ===" ! class MyScanner(Scanner_PreUH3): def destination(self, type, name, arglist): --- 28,33 ---- print "=== Done. It's up to you to compile it now! ===" ! #class MyScanner(Scanner_PreUH3): ! class MyScanner(Scanner): def destination(self, type, name, arglist): *************** *** 53,56 **** --- 55,60 ---- "WEGetInfo", "WEVersion", # Unfortunately... + "WEPut", # XXXX TBD: needs array of flavortypes. + "WEGetOneAttribute", # XXXX TBD: output buffer ] *************** *** 61,64 **** --- 65,96 ---- "WEFontIDToNameUPP", "WEFontNameToIDUPP", + "WEClickLoopUPP", + "WEScrollUPP", + "WETSMPreUpdateUPP", + "WETSMPostUpdateUPP", + "WEPreTrackDragUPP", + "WETranslateDragUPP", + "WEHiliteDropAreaUPP", + "WEDrawTextUPP", + "WEDrawTSMHiliteUPP", + "WEPixelToCharUPP", + "WECharToPixelUPP", + "WELineBreakUPP", + "WEWordBreakUPP", + "WECharByteUPP", + "WECharTypeUPP", + "WEEraseUPP", + "WEFluxUPP", + "WENewObjectUPP", + "WEDisposeObjectUPP", + "WEDrawObjectUPP", + "WEClickObjectUPP", + "WEStreamObjectUPP", + "WEHoverObjectUPP", + "WERuler", # XXXX To be done + "WERuler_ptr", # ditto + "WEParaInfo", # XXXX To be done + "WEPrintSession", # XXXX To be done + "WEPrintOptions_ptr", # XXXX To be done ] *************** *** 69,90 **** # WEContinuousStyle ! ([("WEStyleMode", "mode", "OutMode"), ("TextStyle", "ts", "OutMode")], ! [("WEStyleMode", "mode", "InOutMode"), ("TextStyle", "ts", "OutMode")]), # WECopyRange ! ([('Handle', 'hText', 'InMode'), ('StScrpHandle', 'hStyles', 'InMode'), ! ('WESoupHandle', 'hSoup', 'InMode')], ! [('OptHandle', 'hText', 'InMode'), ('OptStScrpHandle', 'hStyles', 'InMode'), ! ('OptSoupHandle', 'hSoup', 'InMode')]), # WEInsert ! ([('StScrpHandle', 'hStyles', 'InMode'), ('WESoupHandle', 'hSoup', 'InMode')], ! [('OptStScrpHandle', 'hStyles', 'InMode'), ('OptSoupHandle', 'hSoup', 'InMode')]), # WEGetObjectOwner ("WEGetObjectOwner", [('WEReference', '*', 'ReturnMode')], ! [('ExistingWEReference', '*', 'ReturnMode')]) ! ] --- 101,129 ---- # WEContinuousStyle ! ([("WEStyleMode", "ioMode", "OutMode"), ("TextStyle", "outTextStyle", "OutMode")], ! [("WEStyleMode", "*", "InOutMode"), ("TextStyle", "*", "*")]), # WECopyRange ! ([('Handle', 'outText', 'InMode'), ('StScrpHandle', 'outStyles', 'InMode'), ! ('WESoupHandle', 'outSoup', 'InMode')], ! [('OptHandle', '*', '*'), ('OptStScrpHandle', '*', '*'), ! ('OptSoupHandle', '*', '*')]), # WEInsert ! ([('StScrpHandle', 'inStyles', 'InMode'), ('WESoupHandle', 'inSoup', 'InMode')], ! [('OptStScrpHandle', '*', '*'), ('OptSoupHandle', '*', '*')]), # WEGetObjectOwner ("WEGetObjectOwner", [('WEReference', '*', 'ReturnMode')], ! [('ExistingWEReference', '*', 'ReturnMode')]), ! ! # WEFindParagraph ! ([("char_ptr", "inKey", "InMode")], ! [("stringptr", "*", "*")]), ! ! # WESetOneAttribute ! ([("void_ptr", "*", "InMode"), ("ByteCount", "*", "InMode")], ! [("InBuffer", "*", "*")]), ] Index: wastesupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/waste/wastesupport.py,v retrieving revision 1.14 retrieving revision 1.14.20.1 diff -C2 -d -r1.14 -r1.14.20.1 *** wastesupport.py 20 Jun 2001 21:21:07 -0000 1.14 --- wastesupport.py 10 Mar 2002 21:33:19 -0000 1.14.20.1 *************** *** 37,40 **** --- 37,41 ---- WEStyleMode = Type("WEStyleMode", "H") + WERulerMode = Type("WERulerMode", "l") WEActionKind = Type("WEActionKind", "h") WEAlignment = Type("WEAlignment", "B") *************** *** 55,58 **** --- 56,62 ---- LongRect = OpaqueType("LongRect", "LongRect") LongRect_ptr = LongRect + + TextEncodingVariant = Type("TextEncodingVariant", "l") + TextEncodingFormat = Type("TextEncodingFormat", "l") includestuff = includestuff + """ From gvanrossum@users.sourceforge.net Mon Mar 11 00:07:15 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sun, 10 Mar 2002 16:07:15 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.116,1.117 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv4829 Modified Files: test_descr.py Log Message: Bugfix candidate. Adapter from SF patch 528038; fixes SF bug 527816. The wrapper for __nonzero__ should be wrap_inquiry rather than wrap_unaryfunc, since the slot returns an int, not a PyObject *. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.116 retrieving revision 1.117 diff -C2 -d -r1.116 -r1.117 *** test_descr.py 2 Mar 2002 04:18:04 -0000 1.116 --- test_descr.py 11 Mar 2002 00:07:13 -0000 1.117 *************** *** 427,430 **** --- 427,433 ---- if verbose: print "Testing int operations..." numops(100, 3) + # The following crashes in Python 2.2 + vereq((1).__nonzero__(), 1) + vereq((0).__nonzero__(), 0) def longs(): From tim_one@users.sourceforge.net Mon Mar 11 00:24:02 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 10 Mar 2002 16:24:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_largefile.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv6297/python/Lib/test Modified Files: test_largefile.py Log Message: file_truncate(): provide full "large file" support on Windows, by dropping MS's inadequate _chsize() function. This was inspired by SF patch 498109 ("fileobject truncate support for win32"), which I rejected. libstdtypes.tex: Someone who knows should update the availability blurb. For example, if it's available on Linux, it would be good to say so. test_largefile: Uncommented the file.truncate() tests, and reworked to do more. The old comment about "permission errors" in the truncation tests under Windows was almost certainly due to that the file wasn't open for *write* access at this point, so of course MS wouldn't let you truncate it. I'd be appalled if a Unixish system did. CAUTION: Someone should run this test on Linux (etc) too. The truncation part was commented out before. Note that test_largefile isn't run by default. Index: test_largefile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_largefile.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_largefile.py 11 Dec 2001 17:57:26 -0000 1.12 --- test_largefile.py 11 Mar 2002 00:24:00 -0000 1.13 *************** *** 129,147 **** f.close() ! ! # XXX add tests for truncate if it exists ! # XXX has truncate ever worked on Windows? specifically on WinNT I get: ! # "IOError: [Errno 13] Permission denied" ! ##try: ! ## newsize = size - 10 ! ## f.seek(newsize) ! ## f.truncate() ! ## expect(f.tell(), newsize) ! ## newsize = newsize - 1 ! ## f.seek(0) ! ## f.truncate(newsize) ! ## expect(f.tell(), newsize) ! ##except AttributeError: ! ## pass os.unlink(name) --- 129,156 ---- f.close() ! if hasattr(f, 'truncate'): ! if test_support.verbose: ! print 'try truncate' ! f = open(name, 'r+b') ! f.seek(0, 2) ! expect(f.tell(), size+1) ! # Cut it back via seek + truncate with no argument. ! newsize = size - 10 ! f.seek(newsize) ! f.truncate() ! expect(f.tell(), newsize) ! # Ensure that truncate(bigger than true size) doesn't grow the file. ! f.truncate(size) ! expect(f.tell(), newsize) ! # Ensure that truncate(smaller than true size) shrinks the file. ! newsize -= 1 ! f.seek(0) ! f.truncate(newsize) ! expect(f.tell(), newsize) ! # cut it waaaaay back ! f.truncate(1) ! f.seek(0) ! expect(len(f.read()), 1) ! f.close() os.unlink(name) From tim_one@users.sourceforge.net Mon Mar 11 00:24:02 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 10 Mar 2002 16:24:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.360,1.361 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv6297/python/Misc Modified Files: NEWS Log Message: file_truncate(): provide full "large file" support on Windows, by dropping MS's inadequate _chsize() function. This was inspired by SF patch 498109 ("fileobject truncate support for win32"), which I rejected. libstdtypes.tex: Someone who knows should update the availability blurb. For example, if it's available on Linux, it would be good to say so. test_largefile: Uncommented the file.truncate() tests, and reworked to do more. The old comment about "permission errors" in the truncation tests under Windows was almost certainly due to that the file wasn't open for *write* access at this point, so of course MS wouldn't let you truncate it. I'd be appalled if a Unixish system did. CAUTION: Someone should run this test on Linux (etc) too. The truncation part was commented out before. Note that test_largefile isn't run by default. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.360 retrieving revision 1.361 diff -C2 -d -r1.360 -r1.361 *** NEWS 3 Mar 2002 21:30:27 -0000 1.360 --- NEWS 11 Mar 2002 00:24:00 -0000 1.361 *************** *** 74,78 **** to stop Python development. Thanks for all the fish! ! - Some of us don't like fish, so we changed Python's magic number scheme to a new one. See Python/import.c for details. --- 74,78 ---- to stop Python development. Thanks for all the fish! ! - Some of us don't like fish, so we changed Python's magic number scheme to a new one. See Python/import.c for details. *************** *** 84,87 **** --- 84,91 ---- Windows + + - file.truncate([newsize]) now works on Windows for all newsize values. + It used to fail if newsize didn't fit in 32 bits, reflecting a + limitation of MS _chsize (which is no longer used). - os.waitpid() is now implemented for Windows, and can be used to block From tim_one@users.sourceforge.net Mon Mar 11 00:24:02 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 10 Mar 2002 16:24:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libstdtypes.tex,1.81,1.82 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv6297/python/Doc/lib Modified Files: libstdtypes.tex Log Message: file_truncate(): provide full "large file" support on Windows, by dropping MS's inadequate _chsize() function. This was inspired by SF patch 498109 ("fileobject truncate support for win32"), which I rejected. libstdtypes.tex: Someone who knows should update the availability blurb. For example, if it's available on Linux, it would be good to say so. test_largefile: Uncommented the file.truncate() tests, and reworked to do more. The old comment about "permission errors" in the truncation tests under Windows was almost certainly due to that the file wasn't open for *write* access at this point, so of course MS wouldn't let you truncate it. I'd be appalled if a Unixish system did. CAUTION: Someone should run this test on Linux (etc) too. The truncation part was commented out before. Note that test_largefile isn't run by default. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** libstdtypes.tex 26 Dec 2001 20:06:40 -0000 1.81 --- libstdtypes.tex 11 Mar 2002 00:24:00 -0000 1.82 *************** *** 1155,1161 **** Truncate the file's size. If the optional \var{size} argument present, the file is truncated to (at most) that size. The size ! defaults to the current position. Availability of this function ! depends on the operating system version (for example, not all ! \UNIX{} versions support this operation). \end{methoddesc} --- 1155,1160 ---- Truncate the file's size. If the optional \var{size} argument present, the file is truncated to (at most) that size. The size ! defaults to the current position. ! Availability: Windows, many \UNIX variants. \end{methoddesc} From tim_one@users.sourceforge.net Mon Mar 11 00:24:02 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 10 Mar 2002 16:24:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects fileobject.c,2.144,2.145 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv6297/python/Objects Modified Files: fileobject.c Log Message: file_truncate(): provide full "large file" support on Windows, by dropping MS's inadequate _chsize() function. This was inspired by SF patch 498109 ("fileobject truncate support for win32"), which I rejected. libstdtypes.tex: Someone who knows should update the availability blurb. For example, if it's available on Linux, it would be good to say so. test_largefile: Uncommented the file.truncate() tests, and reworked to do more. The old comment about "permission errors" in the truncation tests under Windows was almost certainly due to that the file wasn't open for *write* access at this point, so of course MS wouldn't let you truncate it. I'd be appalled if a Unixish system did. CAUTION: Someone should run this test on Linux (etc) too. The truncation part was commented out before. Note that test_largefile isn't run by default. Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.144 retrieving revision 2.145 diff -C2 -d -r2.144 -r2.145 *** fileobject.c 26 Feb 2002 11:36:35 -0000 2.144 --- fileobject.c 11 Mar 2002 00:24:00 -0000 2.145 *************** *** 11,16 **** #ifdef MS_WIN32 #define fileno _fileno ! /* can (almost fully) duplicate with _chsize, see file_truncate */ #define HAVE_FTRUNCATE #endif --- 11,18 ---- #ifdef MS_WIN32 #define fileno _fileno ! /* can simulate truncate with Win32 API functions; see file_truncate */ #define HAVE_FTRUNCATE + #define WINDOWS_LEAN_AND_MEAN + #include #endif *************** *** 380,383 **** --- 382,388 ---- if (!PyArg_ParseTuple(args, "|O:truncate", &newsizeobj)) return NULL; + + /* Set newsize to current postion if newsizeobj NULL, else to the + specified value. */ if (newsizeobj != NULL) { #if !defined(HAVE_LARGEFILE_SUPPORT) *************** *** 390,424 **** if (PyErr_Occurred()) return NULL; ! } else { ! /* Default to current position*/ Py_BEGIN_ALLOW_THREADS errno = 0; newsize = _portable_ftell(f->f_fp); Py_END_ALLOW_THREADS ! if (newsize == -1) { ! PyErr_SetFromErrno(PyExc_IOError); ! clearerr(f->f_fp); ! return NULL; ! } } Py_BEGIN_ALLOW_THREADS errno = 0; ret = fflush(f->f_fp); Py_END_ALLOW_THREADS ! if (ret != 0) goto onioerror; #ifdef MS_WIN32 ! /* can use _chsize; if, however, the newsize overflows 32-bits then ! _chsize is *not* adequate; in this case, an OverflowError is raised */ ! if (newsize > LONG_MAX) { ! PyErr_SetString(PyExc_OverflowError, ! "the new size is too long for _chsize (it is limited to 32-bit values)"); ! return NULL; ! } else { ! Py_BEGIN_ALLOW_THREADS errno = 0; ! ret = _chsize(fileno(f->f_fp), (long)newsize); ! Py_END_ALLOW_THREADS ! if (ret != 0) goto onioerror; } #else --- 395,459 ---- if (PyErr_Occurred()) return NULL; ! } ! else { ! /* Default to current position. */ Py_BEGIN_ALLOW_THREADS errno = 0; newsize = _portable_ftell(f->f_fp); Py_END_ALLOW_THREADS ! if (newsize == -1) ! goto onioerror; } + + /* Flush the file. */ Py_BEGIN_ALLOW_THREADS errno = 0; ret = fflush(f->f_fp); Py_END_ALLOW_THREADS ! if (ret != 0) ! goto onioerror; #ifdef MS_WIN32 ! /* MS _chsize doesn't work if newsize doesn't fit in 32 bits, ! so don't even try using it. truncate() should never grow the ! file, but MS SetEndOfFile will grow a file, so we need to ! compare the specified newsize to the actual size. Some ! optimization could be done here when newsizeobj is NULL. */ ! { ! Py_off_t currentEOF; /* actual size */ ! HANDLE hFile; ! int error; ! ! /* First move to EOF, and set currentEOF to the size. */ errno = 0; ! if (_portable_fseek(f->f_fp, 0, SEEK_END) != 0) ! goto onioerror; ! errno = 0; ! currentEOF = _portable_ftell(f->f_fp); ! if (currentEOF == -1) ! goto onioerror; ! ! if (newsize > currentEOF) ! newsize = currentEOF; /* never grow the file */ ! ! /* Move to newsize, and truncate the file there. */ ! if (newsize != currentEOF) { ! errno = 0; ! if (_portable_fseek(f->f_fp, newsize, SEEK_SET) != 0) ! goto onioerror; ! Py_BEGIN_ALLOW_THREADS ! errno = 0; ! hFile = (HANDLE)_get_osfhandle(fileno(f->f_fp)); ! error = hFile == (HANDLE)-1; ! if (!error) { ! error = SetEndOfFile(hFile) == 0; ! if (error) ! errno = EACCES; ! } ! Py_END_ALLOW_THREADS ! if (error) ! goto onioerror; ! } ! } #else From gvanrossum@users.sourceforge.net Mon Mar 11 01:05:34 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sun, 10 Mar 2002 17:05:34 -0800 Subject: [Python-checkins] CVS: python/dist/src README,1.140,1.141 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv15827 Modified Files: README Log Message: Update version number in README. Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/README,v retrieving revision 1.140 retrieving revision 1.141 diff -C2 -d -r1.140 -r1.141 *** README 27 Feb 2002 13:29:45 -0000 1.140 --- README 11 Mar 2002 01:05:32 -0000 1.141 *************** *** 1,3 **** ! This is Python version 2.2 ========================== --- 1,3 ---- ! This is Python version 2.3 (pre-alpha) ========================== From loewis@users.sourceforge.net Mon Mar 11 06:46:54 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Sun, 10 Mar 2002 22:46:54 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib gzip.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv22818 Modified Files: gzip.py Log Message: Patch #443899: Check modes on files before performing operations. Use IOErrors where file objects use them. Index: gzip.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/gzip.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** gzip.py 13 Oct 2001 18:33:51 -0000 1.28 --- gzip.py 11 Mar 2002 06:46:52 -0000 1.29 *************** *** 62,66 **** 0) else: ! raise ValueError, "Mode " + mode + " not supported" self.fileobj = fileobj --- 62,66 ---- 0) else: ! raise IOError, "Mode " + mode + " not supported" self.fileobj = fileobj *************** *** 134,137 **** --- 134,141 ---- def write(self,data): + if self.mode != WRITE: + import errno + raise IOError(errno.EBADF, "write() on read-only GzipFile object") + if self.fileobj is None: raise ValueError, "write() on closed GzipFile object" *************** *** 143,146 **** --- 147,154 ---- def read(self, size=-1): + if self.mode != READ: + import errno + raise IOError(errno.EBADF, "write() on read-only GzipFile object") + if self.extrasize <= 0 and self.fileobj is None: return '' From sjoerd@users.sourceforge.net Mon Mar 11 09:20:50 2002 From: sjoerd@users.sourceforge.net (Sjoerd Mullender) Date: Mon, 11 Mar 2002 01:20:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules zlibmodule.c,2.57,2.58 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv24247 Modified Files: zlibmodule.c Log Message: Changed C++ comment into standard comment. Index: zlibmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/zlibmodule.c,v retrieving revision 2.57 retrieving revision 2.58 diff -C2 -d -r2.57 -r2.58 *** zlibmodule.c 8 Dec 2001 18:02:58 -0000 2.57 --- zlibmodule.c 11 Mar 2002 09:20:47 -0000 2.58 *************** *** 882,885 **** #ifdef WITH_THREAD zlib_lock = PyThread_allocate_lock(); ! #endif // WITH_THREAD } --- 882,885 ---- #ifdef WITH_THREAD zlib_lock = PyThread_allocate_lock(); ! #endif /* WITH_THREAD */ } From mwh@users.sourceforge.net Mon Mar 11 10:02:20 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 11 Mar 2002 02:02:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules cStringIO.c,2.32,2.32.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv1399 Modified Files: Tag: release22-maint cStringIO.c Log Message: backport jhylton's checkin of revision 2.33 of cStringIO.c Fix SF bug #526518 The doc string for cStringIO suggested that str() of a StringIO object was equivalent to getvalue(). This was never true, so repair the doc string. (doctest would have helped here.) Bug fix candidate for any past versions. Index: cStringIO.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cStringIO.c,v retrieving revision 2.32 retrieving revision 2.32.6.1 diff -C2 -d -r2.32 -r2.32.6.1 *** cStringIO.c 8 Dec 2001 18:02:56 -0000 2.32 --- cStringIO.c 11 Mar 2002 10:02:18 -0000 2.32.6.1 *************** *** 68,72 **** " an_output_stream.write(some_stuff)\n" " ...\n" ! " value=an_output_stream.getvalue() # str(an_output_stream) works too!\n" "\n" " an_input_stream=StringIO(a_string)\n" --- 68,72 ---- " an_output_stream.write(some_stuff)\n" " ...\n" ! " value=an_output_stream.getvalue()\n" "\n" " an_input_stream=StringIO(a_string)\n" From mwh@users.sourceforge.net Mon Mar 11 10:04:09 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 11 Mar 2002 02:04:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/webchecker webchecker.py,1.25,1.25.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/webchecker In directory usw-pr-cvs1:/tmp/cvs-serv1787 Modified Files: Tag: release22-maint webchecker.py Log Message: I presume most of the fixes currently hitting the tree should go into 2.2.1, but it would be nice if people remembered to comment on their fixes' applicability! backport akuchling's checkin of revision 1.26 of webchecker.py [Bug #512799] urllib.splittype() returns a 2-tuple. (Reported by seb bacon) Index: webchecker.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/webchecker/webchecker.py,v retrieving revision 1.25 retrieving revision 1.25.6.1 diff -C2 -d -r1.25 -r1.25.6.1 *** webchecker.py 11 Dec 2001 22:41:24 -0000 1.25 --- webchecker.py 11 Mar 2002 10:04:07 -0000 1.25.6.1 *************** *** 482,486 **** return self.name_table[url] ! scheme = urllib.splittype(url) if scheme in ('mailto', 'news', 'javascript', 'telnet'): self.note(1, " Not checking %s URL" % scheme) --- 482,486 ---- return self.name_table[url] ! scheme, path = urllib.splittype(url) if scheme in ('mailto', 'news', 'javascript', 'telnet'): self.note(1, " Not checking %s URL" % scheme) From mwh@users.sourceforge.net Mon Mar 11 10:05:09 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 11 Mar 2002 02:05:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libxmlrpclib.tex,1.5,1.5.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv1974 Modified Files: Tag: release22-maint libxmlrpclib.tex Log Message: backport akuchling's checkin of revision 1.6 of libxmlrpclib.tex [Bug #486527] Note that the caller has to ensure there are no control characters in strings being passed via XML-RPC. Fix some typos. 2.2.1 bugfix candidate. Index: libxmlrpclib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libxmlrpclib.tex,v retrieving revision 1.5 retrieving revision 1.5.10.1 diff -C2 -d -r1.5 -r1.5.10.1 *** libxmlrpclib.tex 1 Oct 2001 21:05:30 -0000 1.5 --- libxmlrpclib.tex 11 Mar 2002 10:05:07 -0000 1.5.10.1 *************** *** 60,63 **** --- 60,73 ---- XML-RPC server errors, or \exception{ProtocolError} used to signal an error in the HTTP/HTTPS transport layer. + + When passing strings, characters special to XML such as \samp{<}, + \samp{>}, and \samp{\&} will be automatically escaped. However, it's + the caller's responsibility to ensure that the string is free of + characters that aren't allowed in XML, such as the control characters + with ASCII values between 0 and 31; failing to do this will result in + an XML-RPC request that isn't well-formed XML. If you have to pass + arbitrary strings via XML-RPC, use the \class{Binary} wrapper class + described below. + \end{classdesc} *************** *** 201,205 **** \begin{memberdesc}{url} ! The URI or URL that triggered te error. \end{memberdesc} --- 211,215 ---- \begin{memberdesc}{url} ! The URI or URL that triggered the error. \end{memberdesc} *************** *** 209,213 **** \begin{memberdesc}{errmsg} ! The eror message of diagnostic string. \end{memberdesc} --- 219,223 ---- \begin{memberdesc}{errmsg} ! The error message or diagnostic string. \end{memberdesc} From mwh@users.sourceforge.net Mon Mar 11 10:06:38 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 11 Mar 2002 02:06:38 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib httplib.py,1.42.10.1,1.42.10.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv2294 Modified Files: Tag: release22-maint httplib.py Log Message: backport jhylton's checkin of revision 1.45 of httplib.py SF bug report #405939: wrong Host header with proxy In August, Greg said this looked good, so I'm going ahead with it. The fix is different from the one in the bug report. Instead of using a regular expression to extract the host from the url, I use urlparse.urlsplit. Martin commented that the patch doesn't address URLs that have basic authentication username and password in the header. I don't see any code anywhere in httplib that supports this feature, so I'm not going to address it for this fix. Bug fix candidate. Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.42.10.1 retrieving revision 1.42.10.2 diff -C2 -d -r1.42.10.1 -r1.42.10.2 *** httplib.py 16 Feb 2002 23:08:24 -0000 1.42.10.1 --- httplib.py 11 Mar 2002 10:06:36 -0000 1.42.10.2 *************** *** 70,73 **** --- 70,74 ---- import mimetools import socket + from urlparse import urlsplit try: *************** *** 468,474 **** # as Apache) barf when they see two Host: headers ! # if we need a non-standard port,include it in the header ! if self.port == HTTP_PORT: ! self.putheader('Host', self.host) else: self.putheader('Host', "%s:%s" % (self.host, self.port)) --- 469,481 ---- # as Apache) barf when they see two Host: headers ! # If we need a non-standard port,include it in the header. ! # If the request is going through a proxy, but the host of ! # the actual URL, not the host of the proxy. ! ! if url.startswith('http:'): ! nil, netloc, nil, nil, nil = urlsplit(url) ! self.putheader('Host', netloc) ! elif self.port == HTTP_PORT: ! self.putheader('Host', netloc) else: self.putheader('Host', "%s:%s" % (self.host, self.port)) *************** *** 857,860 **** --- 864,878 ---- print print h.getfile().read() + + # minimal test that code to extract host from url works + class HTTP11(HTTP): + _http_vsn = 11 + _http_vsn_str = 'HTTP/1.1' + + h = HTTP11('www.python.org') + h.putrequest('GET', 'http://www.python.org/~jeremy/') + h.endheaders() + h.getreply() + h.close() if hasattr(socket, 'ssl'): From mwh@users.sourceforge.net Mon Mar 11 10:11:48 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 11 Mar 2002 02:11:48 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects abstract.c,2.93.6.1,2.93.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv3490 Modified Files: Tag: release22-maint abstract.c Log Message: backport jhylton's checkin of revision 2.97 of abstract.c Fix for SF bug 516727: MyInt(2) + "3" -> NotImplemented PyNumber_Add() tries the nb_add slot first, then falls back to sq_concat. However, it didn't check the return value of sq_concat. If sq_concat returns NotImplemented, raise the standard TypeError. Index: abstract.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v retrieving revision 2.93.6.1 retrieving revision 2.93.6.2 diff -C2 -d -r2.93.6.1 -r2.93.6.2 *** abstract.c 5 Jan 2002 10:52:38 -0000 2.93.6.1 --- abstract.c 11 Mar 2002 10:11:46 -0000 2.93.6.2 *************** *** 606,614 **** if (result == Py_NotImplemented) { PySequenceMethods *m = v->ob_type->tp_as_sequence; ! Py_DECREF(Py_NotImplemented); ! if (m && m->sq_concat) { result = (*m->sq_concat)(v, w); ! } ! else { PyErr_Format( PyExc_TypeError, --- 606,613 ---- if (result == Py_NotImplemented) { PySequenceMethods *m = v->ob_type->tp_as_sequence; ! Py_DECREF(result); ! if (m && m->sq_concat) result = (*m->sq_concat)(v, w); ! if (result == Py_NotImplemented) { PyErr_Format( PyExc_TypeError, From mwh@users.sourceforge.net Mon Mar 11 10:13:01 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 11 Mar 2002 02:13:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects abstract.c,2.93.6.2,2.93.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv3846 Modified Files: Tag: release22-maint abstract.c Log Message: Probably should have merged the two checkins to this file (oh well). backport jhylton's checkin of revision 2.98 of abstract.c Fix leak of NotImplemented in previous checkin to PyNumber_Add(). If result == Py_NotImplemented, always DECREF it before assigning a new value to result. Index: abstract.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v retrieving revision 2.93.6.2 retrieving revision 2.93.6.3 diff -C2 -d -r2.93.6.2 -r2.93.6.3 *** abstract.c 11 Mar 2002 10:11:46 -0000 2.93.6.2 --- abstract.c 11 Mar 2002 10:12:58 -0000 2.93.6.3 *************** *** 606,619 **** if (result == Py_NotImplemented) { PySequenceMethods *m = v->ob_type->tp_as_sequence; ! Py_DECREF(result); ! if (m && m->sq_concat) result = (*m->sq_concat)(v, w); if (result == Py_NotImplemented) { ! PyErr_Format( PyExc_TypeError, "unsupported operand types for +: '%s' and '%s'", v->ob_type->tp_name, w->ob_type->tp_name); ! result = NULL; } } --- 606,621 ---- if (result == Py_NotImplemented) { PySequenceMethods *m = v->ob_type->tp_as_sequence; ! if (m && m->sq_concat) { ! Py_DECREF(result); result = (*m->sq_concat)(v, w); + } if (result == Py_NotImplemented) { ! Py_DECREF(result); ! PyErr_Format( PyExc_TypeError, "unsupported operand types for +: '%s' and '%s'", v->ob_type->tp_name, w->ob_type->tp_name); ! result = NULL; } } From mwh@users.sourceforge.net Mon Mar 11 10:14:25 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 11 Mar 2002 02:14:25 -0800 Subject: [Python-checkins] CVS: python/dist/src configure.in,1.288.6.3,1.288.6.4 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv4169 Modified Files: Tag: release22-maint configure.in Log Message: backport jhylton's checkin of revision 1.295 of configure.in Add fix for AIX as reported by srubben in SF bug #477487. Untested, of course. Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.288.6.3 retrieving revision 1.288.6.4 diff -C2 -d -r1.288.6.3 -r1.288.6.4 *** configure.in 8 Mar 2002 14:11:18 -0000 1.288.6.3 --- configure.in 11 Mar 2002 10:14:23 -0000 1.288.6.4 *************** *** 293,297 **** case $ac_sys_system in AIX*) ! LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); $(LINKCC)";; dgux*) LINKCC="LD_RUN_PATH=$libdir $(LINKCC)";; --- 293,297 ---- case $ac_sys_system in AIX*) ! LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); $LINKCC";; dgux*) LINKCC="LD_RUN_PATH=$libdir $(LINKCC)";; From mwh@users.sourceforge.net Mon Mar 11 10:15:02 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 11 Mar 2002 02:15:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.246.4.1,2.246.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv4314 Modified Files: Tag: release22-maint bltinmodule.c Log Message: backport tim_one's checkin of revision 2.248 of bltinmodule.c Docstring for filter(): Someone on the Tutor list reasonably complained that it didn't tell enough of the truth. Bugfix candidate (I guess -- it helps and it's harmless). Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.246.4.1 retrieving revision 2.246.4.2 diff -C2 -d -r2.246.4.1 -r2.246.4.2 *** bltinmodule.c 12 Jan 2002 11:13:24 -0000 2.246.4.1 --- bltinmodule.c 11 Mar 2002 10:15:00 -0000 2.246.4.2 *************** *** 248,256 **** static char filter_doc[] = ! "filter(function, sequence) -> list\n\ ! \n\ ! Return a list containing those items of sequence for which function(item)\n\ ! is true. If function is None, return a list of items that are true."; ! static PyObject * --- 248,256 ---- static char filter_doc[] = ! "filter(function or None, sequence) -> list, tuple, or string\n" ! "\n" ! "Return those items of sequence for which function(item) is true. If\n" ! "function is None, return the items that are true. If sequence is a tuple\n" ! "or string, return the same type, else return a list."; static PyObject * From mwh@users.sourceforge.net Mon Mar 11 10:16:25 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 11 Mar 2002 02:16:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include pyport.h,2.40.8.1,2.40.8.2 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv4672 Modified Files: Tag: release22-maint pyport.h Log Message: This has been declared to work. backport tim_one's checkin of revision 2.45 of pyport.h SF bug 525705: [2.2] underflow raise OverflowException. Another year in the quest to out-guess random C behavior. Added macros Py_ADJUST_ERANGE1(X) and Py_ADJUST_ERANGE2(X, Y). The latter is useful for functions with complex results. Two corrections to errno- after-libm-call are attempted: 1. If the platform set errno to ERANGE due to underflow, clear errno. Some unknown subset of libm versions and link options do this. It's allowed by C89, but I never figured anyone would do it. 2. If the platform did not set errno but overflow occurred, force errno to ERANGE. C89 required setting errno to ERANGE, but C99 doesn't. Some unknown subset of libm versions and link options do it the C99 way now. Bugfix candidate, but hold off until some Linux people actually try it, with and without -lieee. I'll send a help plea to Python-Dev. Index: pyport.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pyport.h,v retrieving revision 2.40.8.1 retrieving revision 2.40.8.2 diff -C2 -d -r2.40.8.1 -r2.40.8.2 *** pyport.h 5 Mar 2002 14:24:45 -0000 2.40.8.1 --- pyport.h 11 Mar 2002 10:16:23 -0000 2.40.8.2 *************** *** 286,289 **** --- 286,324 ---- } while(0) + /* Py_ADJUST_ERANGE1(x) + * Py_ADJUST_ERANGE2(x, y) + * Set errno to 0 before calling a libm function, and invoke one of these + * macros after, passing the function result(s) (Py_ADJUST_ERANGE2 is useful + * for functions returning complex results). This makes two kinds of + * adjustments to errno: (A) If it looks like the platform libm set + * errno=ERANGE due to underflow, clear errno. (B) If it looks like the + * platform libm overflowed but didn't set errno, force errno to ERANGE. In + * effect, we're trying to force a useful implementation of C89 errno + * behavior. + * Caution: + * This isn't reliable. See Py_OVERFLOWED comments. + * X and Y may be evaluated more than once. + */ + #define Py_ADJUST_ERANGE1(X) \ + do { \ + if (errno == 0) { \ + if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \ + errno = ERANGE; \ + } \ + else if (errno == ERANGE && (X) == 0.0) \ + errno = 0; \ + } while(0) + + #define Py_ADJUST_ERANGE2(X, Y) \ + do { \ + if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL || \ + (Y) == Py_HUGE_VAL || (Y) == -Py_HUGE_VAL) { \ + if (errno == 0) \ + errno = ERANGE; \ + } \ + else if (errno == ERANGE) \ + errno = 0; \ + } while(0) + /************************************************************************** Prototypes that are missing from the standard include files on some systems From mwh@users.sourceforge.net Mon Mar 11 10:16:49 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 11 Mar 2002 02:16:49 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules cmathmodule.c,2.27,2.27.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv4754 Modified Files: Tag: release22-maint cmathmodule.c Log Message: backport tim_one's checkin of revision 2.28 of cmathmodule.c SF bug 525705: [2.2] underflow raise OverflowException. Another year in the quest to out-guess random C behavior. Added macros Py_ADJUST_ERANGE1(X) and Py_ADJUST_ERANGE2(X, Y). The latter is useful for functions with complex results. Two corrections to errno- after-libm-call are attempted: 1. If the platform set errno to ERANGE due to underflow, clear errno. Some unknown subset of libm versions and link options do this. It's allowed by C89, but I never figured anyone would do it. 2. If the platform did not set errno but overflow occurred, force errno to ERANGE. C89 required setting errno to ERANGE, but C99 doesn't. Some unknown subset of libm versions and link options do it the C99 way now. Bugfix candidate, but hold off until some Linux people actually try it, with and without -lieee. I'll send a help plea to Python-Dev. Index: cmathmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cmathmodule.c,v retrieving revision 2.27 retrieving revision 2.27.14.1 diff -C2 -d -r2.27 -r2.27.14.1 *** cmathmodule.c 6 Sep 2001 08:16:17 -0000 2.27 --- cmathmodule.c 11 Mar 2002 10:16:47 -0000 2.27.14.1 *************** *** 338,343 **** x = (*func)(x); PyFPE_END_PROTECT(x) ! Py_SET_ERANGE_IF_OVERFLOW(x.real); ! Py_SET_ERANGE_IF_OVERFLOW(x.imag); if (errno != 0) return math_error(); --- 338,342 ---- x = (*func)(x); PyFPE_END_PROTECT(x) ! Py_ADJUST_ERANGE2(x.real, x.imag); if (errno != 0) return math_error(); From mwh@users.sourceforge.net Mon Mar 11 10:17:20 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 11 Mar 2002 02:17:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects floatobject.c,2.110,2.110.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv4900 Modified Files: Tag: release22-maint floatobject.c Log Message: backport tim_one's checkin of revision 2.111 of floatobject.c SF bug 525705: [2.2] underflow raise OverflowException. Another year in the quest to out-guess random C behavior. Added macros Py_ADJUST_ERANGE1(X) and Py_ADJUST_ERANGE2(X, Y). The latter is useful for functions with complex results. Two corrections to errno- after-libm-call are attempted: 1. If the platform set errno to ERANGE due to underflow, clear errno. Some unknown subset of libm versions and link options do this. It's allowed by C89, but I never figured anyone would do it. 2. If the platform did not set errno but overflow occurred, force errno to ERANGE. C89 required setting errno to ERANGE, but C99 doesn't. Some unknown subset of libm versions and link options do it the C99 way now. Bugfix candidate, but hold off until some Linux people actually try it, with and without -lieee. I'll send a help plea to Python-Dev. Index: floatobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v retrieving revision 2.110 retrieving revision 2.110.6.1 diff -C2 -d -r2.110 -r2.110.6.1 *** floatobject.c 11 Dec 2001 20:31:34 -0000 2.110 --- floatobject.c 11 Mar 2002 10:17:17 -0000 2.110.6.1 *************** *** 578,584 **** ix = pow(iv, iw); PyFPE_END_PROTECT(ix) ! Py_SET_ERANGE_IF_OVERFLOW(ix); if (errno != 0) { ! /* XXX could it be another type of error? */ PyErr_SetFromErrno(PyExc_OverflowError); return NULL; --- 578,584 ---- ix = pow(iv, iw); PyFPE_END_PROTECT(ix) ! Py_ADJUST_ERANGE1(ix); if (errno != 0) { ! assert(errno == ERANGE); PyErr_SetFromErrno(PyExc_OverflowError); return NULL; From mwh@users.sourceforge.net Mon Mar 11 10:19:18 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 11 Mar 2002 02:19:18 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib httplib.py,1.42.10.2,1.42.10.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv5404 Modified Files: Tag: release22-maint httplib.py Log Message: I *think* this should go in. May be wrong -- please howl in protest if so. backport jhylton's checkin of revision 1.46 of httplib.py Fix SF bug 525520. Don't automatically add a Host: header if the headers passed to request() already has a Host key. Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.42.10.2 retrieving revision 1.42.10.3 diff -C2 -d -r1.42.10.2 -r1.42.10.3 *** httplib.py 11 Mar 2002 10:06:36 -0000 1.42.10.2 --- httplib.py 11 Mar 2002 10:19:16 -0000 1.42.10.3 *************** *** 411,415 **** raise ! def putrequest(self, method, url): """Send a request to the server. --- 411,415 ---- raise ! def putrequest(self, method, url, skip_host=0): """Send a request to the server. *************** *** 462,483 **** # Issue some standard headers for better HTTP/1.1 compliance ! # this header is issued *only* for HTTP/1.1 connections. more ! # specifically, this means it is only issued when the client uses ! # the new HTTPConnection() class. backwards-compat clients will ! # be using HTTP/1.0 and those clients may be issuing this header ! # themselves. we should NOT issue it twice; some web servers (such ! # as Apache) barf when they see two Host: headers ! # If we need a non-standard port,include it in the header. ! # If the request is going through a proxy, but the host of ! # the actual URL, not the host of the proxy. ! if url.startswith('http:'): ! nil, netloc, nil, nil, nil = urlsplit(url) ! self.putheader('Host', netloc) ! elif self.port == HTTP_PORT: ! self.putheader('Host', netloc) ! else: ! self.putheader('Host', "%s:%s" % (self.host, self.port)) # note: we are assuming that clients will not attempt to set these --- 462,490 ---- # Issue some standard headers for better HTTP/1.1 compliance ! if not skip_host: ! # this header is issued *only* for HTTP/1.1 ! # connections. more specifically, this means it is ! # only issued when the client uses the new ! # HTTPConnection() class. backwards-compat clients ! # will be using HTTP/1.0 and those clients may be ! # issuing this header themselves. we should NOT issue ! # it twice; some web servers (such as Apache) barf ! # when they see two Host: headers ! # If we need a non-standard port,include it in the ! # header. If the request is going through a proxy, ! # but the host of the actual URL, not the host of the ! # proxy. ! netloc = '' ! if url.startswith('http'): ! nil, netloc, nil, nil, nil = urlsplit(url) ! ! if netloc: ! self.putheader('Host', netloc) ! elif self.port == HTTP_PORT: ! self.putheader('Host', self.host) ! else: ! self.putheader('Host', "%s:%s" % (self.host, self.port)) # note: we are assuming that clients will not attempt to set these *************** *** 537,541 **** def _send_request(self, method, url, body, headers): ! self.putrequest(method, url) if body: --- 544,555 ---- def _send_request(self, method, url, body, headers): ! # If headers already contains a host header, then define the ! # optional skip_host argument to putrequest(). The check is ! # harder because field names are case insensitive. ! if (headers.has_key('Host') ! or [k for k in headers.iterkeys() if k.lower() == "host"]): ! self.putrequest(method, url, skip_host=1) ! else: ! self.putrequest(method, url) if body: From mwh@users.sourceforge.net Mon Mar 11 10:19:50 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 11 Mar 2002 02:19:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.126.4.1,2.126.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv5500 Modified Files: Tag: release22-maint typeobject.c Log Message: backport gvanrossum's checkin of revision 2.128 of typeobject.c Bugfix candidate. Adapter from SF patch 528038; fixes SF bug 527816. The wrapper for __nonzero__ should be wrap_inquiry rather than wrap_unaryfunc, since the slot returns an int, not a PyObject *. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.126.4.1 retrieving revision 2.126.4.2 diff -C2 -d -r2.126.4.1 -r2.126.4.2 *** typeobject.c 22 Feb 2002 13:31:18 -0000 2.126.4.1 --- typeobject.c 11 Mar 2002 10:19:48 -0000 2.126.4.2 *************** *** 3509,3513 **** UNSLOT("__abs__", nb_absolute, slot_nb_absolute, wrap_unaryfunc, "abs(x)"), ! UNSLOT("__nonzero__", nb_nonzero, slot_nb_nonzero, wrap_unaryfunc, "x != 0"), UNSLOT("__invert__", nb_invert, slot_nb_invert, wrap_unaryfunc, "~x"), --- 3509,3513 ---- UNSLOT("__abs__", nb_absolute, slot_nb_absolute, wrap_unaryfunc, "abs(x)"), ! UNSLOT("__nonzero__", nb_nonzero, slot_nb_nonzero, wrap_inquiry, "x != 0"), UNSLOT("__invert__", nb_invert, slot_nb_invert, wrap_unaryfunc, "~x"), From mwh@users.sourceforge.net Mon Mar 11 10:20:06 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 11 Mar 2002 02:20:06 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.113.4.3,1.113.4.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv5606 Modified Files: Tag: release22-maint test_descr.py Log Message: backport gvanrossum's checkin of revision 1.117 of test_descr.py Bugfix candidate. Adapter from SF patch 528038; fixes SF bug 527816. The wrapper for __nonzero__ should be wrap_inquiry rather than wrap_unaryfunc, since the slot returns an int, not a PyObject *. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.113.4.3 retrieving revision 1.113.4.4 diff -C2 -d -r1.113.4.3 -r1.113.4.4 *** test_descr.py 5 Mar 2002 15:38:43 -0000 1.113.4.3 --- test_descr.py 11 Mar 2002 10:20:04 -0000 1.113.4.4 *************** *** 427,430 **** --- 427,433 ---- if verbose: print "Testing int operations..." numops(100, 3) + # The following crashes in Python 2.2 + vereq((1).__nonzero__(), 1) + vereq((0).__nonzero__(), 0) def longs(): From mwh@users.sourceforge.net Mon Mar 11 10:20:38 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 11 Mar 2002 02:20:38 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib ftplib.py,1.60.10.2,1.60.10.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv5776 Modified Files: Tag: release22-maint ftplib.py Log Message: backport loewis' checkin of revision 1.66 of ftplib.py Access the exception argument to see whether it starts with '500'. Fixes #527855. Index: ftplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ftplib.py,v retrieving revision 1.60.10.2 retrieving revision 1.60.10.3 diff -C2 -d -r1.60.10.2 -r1.60.10.3 *** ftplib.py 16 Feb 2002 23:08:24 -0000 1.60.10.2 --- ftplib.py 11 Mar 2002 10:20:36 -0000 1.60.10.3 *************** *** 493,498 **** return self.voidcmd('CDUP') except error_perm, msg: ! if msg[:3] != '500': ! raise error_perm, msg elif dirname == '': dirname = '.' # does nothing, but could return error --- 493,498 ---- return self.voidcmd('CDUP') except error_perm, msg: ! if msg.args[0][:3] != '500': ! raise elif dirname == '': dirname = '.' # does nothing, but could return error From gvanrossum@users.sourceforge.net Mon Mar 11 13:21:27 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Mon, 11 Mar 2002 05:21:27 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.117,1.118 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv18470 Modified Files: test_descr.py Log Message: Add a check that SF bug 516727 is really fixed. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.117 retrieving revision 1.118 diff -C2 -d -r1.117 -r1.118 *** test_descr.py 11 Mar 2002 00:07:13 -0000 1.117 --- test_descr.py 11 Mar 2002 13:21:25 -0000 1.118 *************** *** 430,433 **** --- 430,443 ---- vereq((1).__nonzero__(), 1) vereq((0).__nonzero__(), 0) + # This returns 'NotImplemented' in Python 2.2 + class C(int): + def __add__(self, other): + return NotImplemented + try: + C() + "" + except TypeError: + pass + else: + raise TestFailed, "NotImplemented should have caused TypeErrpr" def longs(): From nnorwitz@users.sourceforge.net Mon Mar 11 14:44:15 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Mon, 11 Mar 2002 06:44:15 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.118,1.119 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv10014/Lib/test Modified Files: test_descr.py Log Message: Fix typo Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.118 retrieving revision 1.119 diff -C2 -d -r1.118 -r1.119 *** test_descr.py 11 Mar 2002 13:21:25 -0000 1.118 --- test_descr.py 11 Mar 2002 14:44:12 -0000 1.119 *************** *** 439,443 **** pass else: ! raise TestFailed, "NotImplemented should have caused TypeErrpr" def longs(): --- 439,443 ---- pass else: ! raise TestFailed, "NotImplemented should have caused TypeError" def longs(): From bwarsaw@users.sourceforge.net Mon Mar 11 17:23:16 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Mon, 11 Mar 2002 09:23:16 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0002.txt,1.2,1.3 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv25464 Modified Files: pep-0002.txt Log Message: This PEP has a new champion Martijn Faassen, and it actually contains text now. :) Committing for Martijn, after minor formatting and style changes. Index: pep-0002.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0002.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pep-0002.txt 21 Mar 2001 17:35:05 -0000 1.2 --- pep-0002.txt 11 Mar 2002 17:23:14 -0000 1.3 *************** *** 2,17 **** Title: Procedure for Adding New Modules Version: $Revision$ ! Author: esr@snark.thyrsus.com (Eric S. Raymond) ! Status: Deferred Type: Informational ! Created: 07-Aug-2000 ! Post-History: ! Abstract ! This PEP will describes review and voting procedures for ! incorporating candidate modules and extensions into the Python ! core. --- 2,193 ---- Title: Procedure for Adding New Modules Version: $Revision$ ! Last-Modified: $Date$ ! Author: faassen@infrae.com (Martijn Faassen) ! Status: Draft Type: Informational ! Created: 07-Jul-2001 ! Post-History: 07-Jul-2001, 09-Mar-2002 ! Introduction ! The Python Standard Library contributes significantly to Python's ! success. The language comes with "batteries included", so it is ! easy for people to become productive with just the standard ! library alone. It is therefore important that this library grows ! with the language, and that such growth is supported and ! encouraged. ! ! Many contributions to the library are not created by core ! developers but by people from the Python community who are experts ! in their particular field. Furthermore, community members are ! also the users of the standard library, applying it in a great ! diversity of settings. This makes the community well equipped to ! detect and report gaps in the library; things that are missing but ! should be added. ! ! New functionality is commonly added to the library in the form of ! new modules. This PEP will describe the procedure for the ! _addition_ of new modules. PEP 4 deals with procedures for ! deprecation of modules; the _removal_ of old and unused modules ! from the standard library. Finally there is also the issue of ! _changing_ existing modules to make the picture of library ! evolution complete. PEP 3 and PEP 5 give some guidelines on this. ! The continued maintenance of existing modules is an integral part ! of the decision on whether to add a new module to the standard ! library. Therefore, this PEP also introduces concepts ! (integrators, maintainers) relevant to the maintenance issue. ! ! ! Integrators ! ! The integrators are a group of people with the following ! responsibilities: ! ! - They determine if a proposed contribution should become part of ! the standard library. ! ! - They integrate accepted contributions into the standard library. ! ! - They produce standard library releases. ! ! This group of people shall be PythonLabs, led by Guido. ! ! ! Maintainer(s) ! ! All contributions to the standard library need one or more ! maintainers. This can be an individual, but it is frequently a ! group of people such as the XML-SIG. Groups may subdivide ! maintenance tasks among themselves. One ore more maintainers ! shall be the _head maintainer_ (usually this is also the main ! developer). Head maintainers are convenient people the ! integrators can address if they want to resolve specific issues, ! such as the ones detailed later in this document. ! ! ! Developers(s) ! ! Contributions to the standard library have been developed by one ! or more developers. The initial maintainers are the original ! developers unless there are special circumstances (which should be ! detailed in the PEP proposing the contribution). ! ! ! Acceptance Procedure ! ! When developers wish to have a contribution accepted into the ! standard library, they will first form a group of maintainers ! (normally initially consisting of themselves). ! ! Then, this group shall produce a PEP called a library PEP. A ! library PEP is a special form of standards track PEP. The library ! PEP gives an overview of the proposed contribution, along with the ! proposed contribution as the reference implementation. This PEP ! should also contain a motivation on why this contribution should ! be part of the standard library. ! ! One or more maintainers shall step forward as PEP champion (the ! people listed in the Author field are the champions). The PEP ! champion(s) shall be the initial head maintainer(s). ! ! As described in PEP 1, a standards track PEP should consist of a ! design document and a reference implementation. The library PEP ! differs from a normal standard track PEP in that the reference ! implementation should in this case always already have been ! written before the PEP is to be reviewed for inclusion by the ! integrators and to be commented upon by the community; the ! reference implementation _is_ the proposed contribution. ! ! This different requirement exists for the following reasons: ! ! - The integrators can only properly evaluate a contribution to the ! standard library when there is source code and documentation to ! look at; i.e. the reference implementation is always necessary ! to aid people in studying the PEP. ! ! - Even rejected contributions will be useful outside the standard ! library, so there will a lower risk of waste of effort by the ! developers. ! ! - It will impress the integrators of the seriousness of ! contribution and will help guard them against having to evaluate ! too many frivolous proposals. ! ! Once the library PEP has been submitted for review, the ! integrators will then evaluate it. The PEP will follow the normal ! PEP work flow as described in PEP 1. If the PEP is accepted, they ! will work through the head maintainers to make the contribution ! ready for integration. ! ! ! Maintenance Procedure ! ! After a contribution has been accepted, the job is not over for ! both integrators and maintainers. The integrators will forward ! any bug reports in the standard library to the appropriate head ! maintainers. ! ! Before the feature freeze preparing for a release of the standard ! library, the integrators will check with the head maintainers for ! all contributions, to see if there are any updates to be included ! in the next release. The integrators will evaluate any such ! updates for issues like backwards compatibility and may require ! PEPs if the changes are deemed to be large. ! ! The head maintainers should take an active role in keeping up to ! date with the Python development process. If a head maintainer is ! unable to function in this way, he or she should announce the ! intention to step down to the integrators and the rest of the ! maintainers, so that a replacement can step forward. The ! integrators should at all times be capable of reaching the head ! maintainers by email. ! ! In the case where no head maintainer can be found (possibly ! because there are no maintainers left), the integrators will issue ! a call to the community at large asking for new maintainers to ! step forward. If no one does, the integrators can decide to ! declare the contribution deprecated as described in PEP 4. ! ! ! Open issues ! ! There needs to be some procedure so that the integrators can ! always reach the maintainers (or at least the head maintainers). ! This could be accomplished by a mailing list to which all head ! maintainers should be subscribed (this could be python-dev). ! Another possibility, which may be useful in any case, is the ! maintenance of a list similar to that of the list of PEPs which ! lists all the contributions and their head maintainers with ! contact info. This could in fact be part of the list of the PEPs, ! as a new contribution requires a PEP. But since the ! authors/owners of a PEP introducing a new module may eventually be ! different from those who maintain it, this wouldn't resolve all ! issues yet. ! ! Should there be a list of what criteria integrators use for ! evaluating contributions? (Source code but also things like ! documentation and a test suite, as well as such vague things like ! 'dependability of the maintainers'.) ! ! This relates to all the technical issues; check-in privileges, ! coding style requirements, documentation requirements, test suite ! requirements. These are preferably part of another PEP. ! ! Should the current standard library be subdivided among ! maintainers? Many parts already have (informal) maintainers; it ! may be good to make this more explicit. ! ! Perhaps there is a better word for 'contribution'; the word ! 'contribution' may not imply enough that the process (of ! development and maintenance) does not stop after the contribution ! is accepted and integrated into the library. ! ! Relationship to the mythical Catalog? ! ! ! Copyright ! ! This document has been placed in the public domain. *************** *** 20,22 **** --- 196,199 ---- mode: indented-text indent-tabs-mode: nil + fill-column: 70 End: From bwarsaw@users.sourceforge.net Mon Mar 11 17:24:11 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Mon, 11 Mar 2002 09:24:11 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.165,1.166 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv25726 Modified Files: pep-0000.txt Log Message: PEP 2 is undeferred now that Martijn Faassen has taken over. Added Martijn's name to the list of PEP authors and removed Eric Raymond's (since he no longer authors any PEPs). Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.165 retrieving revision 1.166 diff -C2 -d -r1.165 -r1.166 *** pep-0000.txt 8 Mar 2002 15:38:37 -0000 1.165 --- pep-0000.txt 11 Mar 2002 17:24:09 -0000 1.166 *************** *** 31,34 **** --- 31,35 ---- I 0 Index of Python Enhancement Proposals Warsaw I 1 PEP Guidelines Warsaw, Hylton + I 2 Procedure for Adding New Modules Faassen I 3 Guidelines for Handling Bug Reports Hylton I 4 Deprecation of Standard Modules von Loewis *************** *** 129,133 **** Empty PEPs (or containing only an abstract) - ID 2 Procedure for Adding New Modules Raymond SD 210 Decoupling the Interpreter Loop Ascher ID 220 Coroutines, Generators, Continuations McMillan --- 130,133 ---- *************** *** 158,162 **** I 0 Index of Python Enhancement Proposals Warsaw I 1 PEP Guidelines Warsaw, Hylton ! ID 2 Procedure for Adding New Modules Raymond I 3 Guidelines for Handling Bug Reports Hylton I 4 Deprecation of Standard Modules von Loewis --- 158,162 ---- I 0 Index of Python Enhancement Proposals Warsaw I 1 PEP Guidelines Warsaw, Hylton ! I 2 Procedure for Adding New Modules Faassen I 3 Guidelines for Handling Bug Reports Hylton I 4 Deprecation of Standard Modules von Loewis *************** *** 289,292 **** --- 289,293 ---- Evans, Clark C. cce@clarkevans.com Ewing, Greg greg@cosc.canterbury.ac.nz + Faassen, Martijn faassen@infrae.com Giacometti, Frédéric B. fred@arakne.com Goodger, David dgoodger@bigfoot.com *************** *** 311,315 **** Petrone, Jason jp@demonseed.net Prescod, Paul paul@prescod.net - Raymond, Eric esr@snark.thyrsus.com Reifschneider, Sean jafo-pep@tummy.com Riehl, Jonathan jriehl@spaceship.com --- 312,315 ---- From bwarsaw@users.sourceforge.net Mon Mar 11 17:30:37 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Mon, 11 Mar 2002 09:30:37 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0286.txt,NONE,1.1 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv27422 Added Files: pep-0286.txt Log Message: PEP 286, Enhanced Argument Tuples, Martin von Loewis --- NEW FILE: pep-0286.txt --- PEP: 286 Title: Enhanced Argument Tuples Version: $Revision: 1.1 $ Last-Modified: $Date: 2002/03/11 17:30:35 $ Author: loewis@informatik.hu-berlin.de (Martin von Loewis) Status: Active Type: Standards Track Created: 3-Mar-2002 Python-Version: 2.3 Post-History: Abstract PyArg_ParseTuple is confronted with difficult memory management if an argument converter creates new memory. To deal with these cases, a specialized argument type is proposed. Problem description Today, argument tuples keep references to the function arguments, which are guaranteed to live as long as the argument tuple exists which is at least as long as the function call is being executed. In some cases, parsing an argument will allocate new memory, which is then to be released by the caller. This has two problems: 1. In case of failure, the application cannot know what memory to release; most callers don't even know that they have the responsibility to release that memory. Example for this are the N converter (bug #416288) and the es# converter (bug #501716). 2. Even for successful argument parsing, it is still inconvenient for the caller to be responsible for releasing the memory. In some cases, this is unnecessarily inefficient. For example, the es converter copies the conversion result into memory, even though there already is a string object that has the right contents. Proposed solution A new type 'argument tuple' is introduced. This type derives from tuple, adding an __dict__ member (at tp_dictoffset -4). Instances of this type might get the following attributes: - 'failobjects', a list of objects which need to be deallocated in case of success - 'okobjects', a list of object which will be released when the argument tuple is released To manage this type, the following functions will be added, and used appropriately in ceval.c and getargs.c: - PyArgTuple_New(int); - PyArgTuple_AddFailObject(PyObject*, PyObject*); - PyArgTuple_AddFailMemory(PyObject*, void*); - PyArgTuple_AddOkObject(PyObject*, PyObject*); - PyArgTuple_AddOkMemory(PyObject*, void*); - PyArgTuple_ClearFailed(PyObject*); When argument parsing fails, all fail objects will be released through Py_DECREF, and all fail memory will be released through PyMem_Free. If parsing succeeds, the references to the fail objects and fail memory are dropped, without releasing anything. When the argument tuple is released, all ok objects and memory will be released. If those functions are called with an object of a different type, a warning is issued and no further action is taken; usage of the affected converters without using argument tuples is deprecated. Affected converters The following converters will add fail memory and fail objects: N, es, et, es#, et# (unless memory is passed into the converter) New converters To simplify Unicode conversion, the e* converters are duplicated as E* converters (Es, Et, Es#, Et#). The usage of the E* converters is identical to that of the e* converters, except that the application will not need to manage the resulting memory. This will be implemented through registration of Ok objects with the argument tuple. The e* converters are deprecated. Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil fill-column: 70 End: From bwarsaw@users.sourceforge.net Mon Mar 11 17:31:05 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Mon, 11 Mar 2002 09:31:05 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.166,1.167 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv27590 Modified Files: pep-0000.txt Log Message: Added PEP 286, Enhanced Argument Tuples, Martin von Loewis Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.166 retrieving revision 1.167 diff -C2 -d -r1.166 -r1.167 *** pep-0000.txt 11 Mar 2002 17:24:09 -0000 1.166 --- pep-0000.txt 11 Mar 2002 17:31:02 -0000 1.167 *************** *** 94,97 **** --- 94,98 ---- S 284 Integer for-loops Eppstein, Ewing S 285 Adding a bool type van Rossum + S 286 Enhanced Argument Tuples von Loewis Finished PEPs (done, implemented in CVS) *************** *** 260,263 **** --- 261,265 ---- S 284 Integer for-loops Eppstein, Ewing S 285 Adding a bool type van Rossum + S 286 Enhanced Argument Tuples von Loewis SR 666 Reject Foolish Indentation Creighton From bwarsaw@users.sourceforge.net Mon Mar 11 17:36:53 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Mon, 11 Mar 2002 09:36:53 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0006.txt,1.7,1.8 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv29249 Modified Files: pep-0006.txt Log Message: Status changed to Active. Index: pep-0006.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0006.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pep-0006.txt 21 Oct 2001 18:24:08 -0000 1.7 --- pep-0006.txt 11 Mar 2002 17:36:50 -0000 1.8 *************** *** 3,7 **** Version: $Revision$ Author: aahz@pobox.com (Aahz) ! Status: Draft Type: Informational Created: 15-Mar-2001 --- 3,7 ---- Version: $Revision$ Author: aahz@pobox.com (Aahz) ! Status: Active Type: Informational Created: 15-Mar-2001 From bwarsaw@users.sourceforge.net Mon Mar 11 17:33:52 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Mon, 11 Mar 2002 09:33:52 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0279.txt,1.5,1.6 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv28327 Modified Files: pep-0279.txt Log Message: PEP 279 update from Raymond Hettinger Index: pep-0279.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0279.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pep-0279.txt 4 Mar 2002 13:20:02 -0000 1.5 --- pep-0279.txt 11 Mar 2002 17:33:49 -0000 1.6 *************** *** 21,64 **** Rationale ! Starting with xrange() and xreadlines(), Python has been evolving ! toward a model that provides lazy evaluation as an alternative ! when complete evaluation is not desired because of memory ! restrictions or availability of data. ! ! Starting with Python 2.2, a second evolutionary direction came in ! the form of iterators and generators. The iter() factory function ! and generators were provided as convenient means of creating ! iterators. Deep changes were made to use iterators as a unifying ! theme throughout Python. The unification came in the form of establishing a common iterable interface for mappings, sequences, ! and file objects. In the case of mappings and file objects, lazy ! evaluation became the norm. ! The next steps in the evolution of generators are: ! 1. Add built-in functions which provide lazy alternatives to their ! complete evaluation counterparts and one other convenience ! function which was made possible once iterators and generators ! became available. The new functions are xzip, xmap, xfilter, ! and indexed. ! 2. Provide a generator alternative to list comprehensions [3] ! making generator creation as convenient as list creation. ! 3. Extend the syntax of the 'yield' keyword to enable generator ! parameter passing. The resulting increase in power simplifies ! the creation of consumer streams which have a complex execution ! state and/or variable state. ! 4. Add a generator method to enable exceptions to be passed to a generator. Currently, there is no clean method for triggering exceptions from outside the generator. Also, generator exception passing helps mitigate the try/finally prohibition for generators. All of the suggestions are designed to take advantage of the existing implementation and require little additional effort to incorporate. Each is backward compatible and requires no new ! keywords. These generator tools go into Python 2.3 when generators become final and are not imported from __future__. --- 21,81 ---- Rationale ! Python 2.2 introduced the concept of an iterable interface as proposed ! in PEP 234 [4]. The iter() factory function was provided as common ! calling convention and deep changes were made to use iterators as a ! unifying theme throughout Python. The unification came in the form of establishing a common iterable interface for mappings, sequences, ! and file objects. ! Generators, as proposed in PEP 255 [1], were introduced as a means for ! making it easier to create iterators, especially ones with a complex ! internal execution or variable states. When I created new programs, ! generators were often the tool of choice for creating an iterator. ! However, when updating existing programs, I found that the tool had ! another use, one that improved program function as well as structure. ! Those programs exhibited a pattern of creating large lists and then ! looping over them. As data sizes increased, the programs encountered ! scalability limitations owing to excessive memory consumption (and ! malloc time) for the intermediate lists. Generators were found to be ! directly substitutable for the lists while eliminating the memory ! issues through lazy evaluation a.k.a. just in time manufacturing. ! Python itself encountered similar issues. As a result, xrange() and ! xreadlines() were introduced. And, in the case of file objects and ! mappings, lazy evaluation became the norm. Generators provide a tool ! to program memory conserving for-loops whenever complete evaluation is ! not desired because of memory restrictions or availability of data. ! The next steps in the evolution of generators are: ! 1. Add a new builtin function, indexed() which was made possible ! once iterators and generators became available. It provides ! all iterables with the same advantage that iteritem() affords ! to dictionaries -- a compact, readable, reliable index notation. ! ! 2. Establish a generator alternative to list comprehensions [3] ! to provide a simple way to convert a list comprehensions into ! generators whenever memory issues arise. ! ! 3. Add a generator method to enable exceptions to be passed to a generator. Currently, there is no clean method for triggering exceptions from outside the generator. Also, generator exception passing helps mitigate the try/finally prohibition for generators. + 4. [Proposal 4 is now deferred until Python 2.4] + Extend the syntax of the 'yield' keyword to enable generator + parameter passing. The resulting increase in power simplifies + the creation of consumer streams which have a complex execution + state and/or variable state. + All of the suggestions are designed to take advantage of the existing implementation and require little additional effort to incorporate. Each is backward compatible and requires no new ! keywords. The first three generator tools go into Python 2.3 when generators become final and are not imported from __future__. + The fourth proposal should be considered deferred and will be + proposed for Python 2.4 after the Python community has more + experience with generators. *************** *** 67,149 **** There is not currently a CPython implementation; however, a simulation ! module written in pure Python is available on SourceForge [8]. The simulation covers every feature proposed in this PEP and is meant to allow direct experimentation with the proposals. ! There is also a module [9] with working source code for all of the examples used in this PEP. It serves as a test suite for the simulator and it documents how each of the new features works in practice. ! Specification for new built-ins: ! ! def xfilter(pred, gen): ! ''' ! xfilter(...) ! xfilter(function, sequence) -> list ! ! Return an iterator containing those items of sequence for ! which function is true. If function is None, return a list of ! items that are true. ! ''' ! if pred is None: ! for i in gen: ! if i: ! yield i ! else: ! for i in gen: ! if pred(i): ! yield i ! ! def xmap(fun, *collections): ### Code from Python Cookbook [6] ! ''' ! xmap(...) ! xmap(function, sequence[, sequence, ...]) -> list ! ! Return an iterator applying the function to the items of the ! argument collection(s). If more than one collection is given, ! the function is called with an argument list consisting of the ! corresponding item of each collection, substituting None for ! missing values when not all collections have the same length. ! If the function is None, return an iterator of the items of the ! collection (or an iterator of tuples if more than one collection). ! ''' ! gens = map(iter, collections) ! values_left = [1] ! def values(): ! # Emulate map behavior by padding sequences with None ! # when they run out of values. ! values_left[0] = 0 ! for i in range(len(gens)): ! iterator = gens[i] ! if iterator is None: ! yield None ! else: ! try: ! yield iterator.next() ! values_left[0] = 1 ! except StopIteration: ! gens[i] = None ! yield None ! while 1: ! args = tuple(values()) ! if not values_left[0]: ! raise StopIteration ! yield fun(*args) ! ! def xzip(*collections): ! ''' ! xzip(...) ! xzip(seq1 [, seq2 [...]]) -> [(seq1[0], seq2[0] ...), (...)] ! ! Return a iterator of tuples, where each tuple contains the ! i-th element from each of the argument sequences or iterable. ! The returned iterator is truncated in length to the length of ! the shortest argument collection. ! ''' ! gens = map(iter, collections) ! while 1: ! yield tuple([g.next() for g in gens]) def indexed(collection, cnt=0, limit=None): --- 84,105 ---- There is not currently a CPython implementation; however, a simulation ! module written in pure Python is available on SourceForge [7]. The simulation covers every feature proposed in this PEP and is meant to allow direct experimentation with the proposals. ! There is also a module [8] with working source code for all of the examples used in this PEP. It serves as a test suite for the simulator and it documents how each of the new features works in practice. + The authors and implementers of PEP 255 [1] were contacted to provide + their assessment of whether these enhancements were going to be + straight-forward to implement and require only minor modification + of the existing generator code. Neil felt the assertion was correct. + Ka-Ping thought so also. GvR said he could believe that it was true. + Tim did not have an opportunity to give an assessment. + ! Specification for a new builtin: def indexed(collection, cnt=0, limit=None): *************** *** 160,164 **** xrange, sequence, or iterable object. Also, those proposals were presented and evaluated in the world prior to Python 2.2 which did ! not include generators. As a result, the generator-less version in PEP 212 had the disadvantage of consuming memory with a giant list of tuples. The generator version presented here is fast and light, --- 116,120 ---- xrange, sequence, or iterable object. Also, those proposals were presented and evaluated in the world prior to Python 2.2 which did ! not include generators. As a result, the non-generator version in PEP 212 had the disadvantage of consuming memory with a giant list of tuples. The generator version presented here is fast and light, *************** *** 166,199 **** in mid-stream. ! ! Note B: An alternate, simplified definition of indexed is: ! ! def indexed(collection, cnt=0, limit=sys.maxint): ! 'Generates an indexed series: (0,seqn[0]), (1,seqn[1]) ...' ! return xzip( xrange(cnt,limit), collection ) ! ! ! Note C: As it stands, the Python code for xmap is slow. The actual ! implementation of the functions should be written in C for speed. ! The pure Python code listed above is meant only to specify how the ! functions would behave, in particular that they should as closely as ! possible emulate their non-lazy counterparts. ! Note D: Almost all of the PEP reviewers welcomed these functions but were ! divided as to whether they should be built-ins or in a separate module. ! The main argument for a separate module was to slow the rate of language ! inflation. The main argument for built-ins was that these functions are ! destined to be part of a core programming style, applicable to any object ! with an iterable interface. Just as zip() solves the problem of looping ! over multiple sequences, the indexed() function solves the loop counter ! problem. Likewise, the x-functions solve the problem of applying ! functional constructs without forcing the evaluation of an entire sequence. ! If only one built-in were allowed, then indexed() is the most important general purpose tool, solving the broadest class of problems while ! improving program brevity, clarity and reliability. Specification for Generator Comprehensions: --- 122,172 ---- in mid-stream. ! There are other PEPs which touch on related issues: integer iterators, ! integer for-loops, and one for modifying the arguments to range and ! xrange. The indexed() proposal does not preclude the other proposals ! and it still meets an important need even if those are adopted -- the need ! to count items in any iterable. The other proposals give a means of ! producing an index but not the corresponding value. This is especially ! problematic if a sequence is given which doesn't support random access ! such as a file object, generator, or sequence defined with __getitem__. ! Note B: Almost all of the PEP reviewers welcomed the function but were ! divided as to whether there should be any builtins. The main argument ! for a separate module was to slow the rate of language inflation. The ! main argument for a builtin was that the function is destined to be ! part of a core programming style, applicable to any object with an ! iterable interface. Just as zip() solves the problem of looping ! over multiple sequences, the indexed() function solves the loop ! counter problem. ! If only one builtin is allowed, then indexed() is the most important general purpose tool, solving the broadest class of problems while ! improving program brevity, clarity and reliability. ! + Commentary from GvR: filter and map should die and be subsumed into list + comprehensions, not grow more variants. I'd rather introduce builtins + that do iterator algebra (e.g. the iterzip that I've often used as + an example). + + Commentary from Ka-Ping Yee: I'm also quite happy with everything you + proposed ... and the extra builtins (really 'indexed' in particular) + are things I have wanted for a long time. + + Commentary from Neil Schemenauer: The new builtins sound okay. Guido + may be concerned with increasing the number of builtins too much. You + might be better off selling them as part of a module. If you use a + module then you can add lots of useful functions (Haskell has lots of + them that we could steal). + Author response: Prior to these comments, four builtins were proposed. + After the comments, xmap xfilter and xzip were withdrawn. The one + that remains is vital for the language and is proposed by itself. + + I still secretly covet xzip() a.k.a. iterzip() but think that it will + happen on its own someday. + + Specification for Generator Comprehensions: *************** *** 225,229 **** minus side, the brackets may falsely suggest that the whole expression returns a list. Most of the feedback received to date ! indicates that brackets are helpful and not misleading. Note B: List comprehensions expose their looping variable and --- 198,211 ---- minus side, the brackets may falsely suggest that the whole expression returns a list. Most of the feedback received to date ! indicates that brackets are helpful and not misleading. Unfortunately, ! the one dissent is from GvR. ! ! A key advantage of the generator comprehension syntax is that it ! makes it trivially easy to transform existing list comprehension ! code to a generator by adding yield. Likewise, it can be converted ! back to a list by deleting yield. This makes it easy to scale-up ! programs from small datasets to ones large enough to warrant ! just in time evaluation. ! Note B: List comprehensions expose their looping variable and *************** *** 247,252 **** ! Specification for Generator Parameter Passing: 1. Allow 'yield' to assign a value as in: --- 229,341 ---- + Commentary from GvR: Cute hack, but I think the use of the [] syntax + strongly suggests that it would return a list, not an iterator. I + also think that this is trying to turn Python into a functional + language, where most algorithms use lazy infinite sequences, and I + just don't think that's where its future lies. + + Commentary from Ka-Ping Yee: I am very happy with the things you have + proposed in this PEP. I feel quite positive about generator + comprehensions and have no reservations. So a +1 on that. ! Commentary from Neil Schemenauer: I'm -0 on the generator list ! comprehensions. They don't seem to add much. You could easily use ! a nested generator to do the same thing. They smell like lambda. ! ! Author response: This may be before its time in that some people still ! don't like list comprehensions and half of this PEP's reviewers did ! not have any use for generators in any form. What I like best about ! generator comprehensions is that I can design using list ! comprehensions and then easily switch to a generator (by adding ! yield) in response to scalability requirements (when the list ! comprehension produces too large of an intermediate result). ! ! ! ! Specification for Generator Exception Passing: ! ! Add a .throw(exception) method to the generator interface: ! ! def logger(): ! start = time.time() ! log = [] ! try: ! while 1:0 ! log.append( time.time() - start ) ! yield log[-1] ! except WriteLog: ! return log ! ! g = logger() ! for i in [10,20,40,80,160]: ! testsuite(i) ! g.next() ! g.throw(WriteLog) ! ! There is no existing work-around for triggering an exception ! inside a generator. This is a true deficiency. It is the only ! case in Python where active code cannot be excepted to or through. ! ! Generator exception passing also helps address an intrinsic limitation ! on generators, the prohibition against their using try/finally to ! trigger clean-up code [1]. Without .throw(), the current work-around ! forces the resolution or clean-up code to be moved outside the generator. ! ! ! Note A: The name of the throw method was selected for several ! reasons. Raise is a keyword and so cannot be used as a method ! name. Unlike raise which immediately raises an exception from the ! current execution point, throw will first return to the generator ! and then raise the exception. The word throw is suggestive of ! putting the exception in another location. The word throw is ! already associated with exceptions in other languages. ! ! Alternative method names were considered: resolve(), signal(), ! genraise(), raiseinto(), and flush(). None of these seem to fit ! as well as throw(). ! ! ! Note B: The throw syntax should exactly match raise's syntax: ! ! throw([expression, [expression, [expression]]]) ! ! Accordingly, it should be implemented to handle all of the following: ! ! raise string g.throw(string) ! raise string, data g.throw(string,data) ! raise class, instance g.throw(class,instance) ! raise instance g.throw(instance) ! raise g.throw() ! ! ! Commentary from GvR: I'm not convinced that the cleanup problem that ! this is trying to solve exists in practice. I've never felt the need ! to put yield inside a try/except. I think the PEP doesn't make enough ! of a case that this is useful. ! ! Commentary from Ka-Ping Yee: I agree that the exception issue needs to ! be resolved and [that] you have suggested a fine solution. ! ! Commentary from Neil Schemenauer: The exception passing idea is one I ! hadn't thought of before and looks interesting. If we enable the ! passing of values back, then we should add this feature too. ! ! Author response: If the sole use of generators is to simplify writing ! iterators for lazy producers, then the odds of needing generator ! exception passing are very slim. If, on the other hand, generators ! are used to write lazy consumers, create coroutines, generate output ! streams, or simply for their marvelous capability for restarting a ! previously frozen state, THEN the need to raise exceptions will ! come up almost every time. ! ! I'm no judge of what is truly Pythonic, but am still astonished ! that there can exist blocks of code that can't be excepted to or ! through, that the try/finally combination is blocked, and that the ! only work-around is to rewrite as a class and move the exception ! code out of the function or method being excepted. ! ! ! ! Specification for Generator Parameter Passing [Deferred Proposal] 1. Allow 'yield' to assign a value as in: *************** *** 326,330 **** ostream.next(firstdat) # Analogous to file.write(dat) ostream.next(seconddat) ! ostream.throw(FlushStream) # This feature proposed below --- 415,419 ---- ostream.next(firstdat) # Analogous to file.write(dat) ostream.next(seconddat) ! ostream.throw(FlushStream) # This feature proposed above *************** *** 332,336 **** Loop over the picture files in a directory, shrink them ! one at a time to thumbnail size using PIL [7], and send them to a lazy consumer. That consumer is responsible for creating a large blank image, accepting thumbnails one at a time and placing them --- 421,425 ---- Loop over the picture files in a directory, shrink them ! one at a time to thumbnail size using PIL [6], and send them to a lazy consumer. That consumer is responsible for creating a large blank image, accepting thumbnails one at a time and placing them *************** *** 351,462 **** ! Specification for Generator Exception Passing: ! ! Add a .throw(exception) method to the generator interface: ! ! def mygen(): ! try: ! while 1: ! x = yield None ! print x ! except FlushStream: ! print 'Done' ! ! g = mygen() ! g.next(5) ! g.throw(FlushStream) ! There is no existing work-around for triggering an exception ! inside a generator. This is a true deficiency. It is the only ! case in Python where active code cannot be excepted to or through. ! Even if the .next(arg) proposal is not adopted, we should add the ! .throw() method. ! Generator exception passing also helps address an intrinsic limitation ! on generators, the prohibition against their using try/finally to ! trigger clean-up code [1]. Without .throw(), the current work-around ! forces the resolution or clean-up code to be moved outside the generator. ! - Note A: The name of the throw method was selected for several - reasons. Raise is a keyword and so cannot be used as a method - name. Unlike raise which immediately raises an exception from the - current execution point, throw will first return to the generator - and then raise the exception. The word throw is suggestive of - putting the exception in another location. The word throw is - already associated with exceptions in other languages. - Alternative method names were considered: resolve(), signal(), - genraise(), raiseinto(), and flush(). None of these seem to fit - as well as throw(). ! Note B: The throw syntax should exactly match raise's syntax: ! ! throw([expression, [expression, [expression]]]) ! ! Accordingly, it should be implemented to handle all of the following: ! raise string g.throw(string) ! raise string, data g.throw(string,data) ! raise class, instance g.throw(class,instance) ! raise instance g.throw(instance) ! raise g.throw() ! ! ! Discussion of Restartability: ! ! Inside for-loops, generators are not substitutable for lists unless they ! are accessed only once. A second access only works for restartable ! objects like lists, dicts, objects defined with __getitem__, and ! xrange objects. Generators are not the only objects which are not ! restartable. Other examples of non-restartable sequences include file ! objects, xreadlines objects, and the result of iter(callable,sentinel). ! ! Since the proposed built-in functions return generators, they are also ! non-restartable. As a result, 'xmap' is not substitutable for 'map' in ! the following example: ! ! alphabet = map(chr, xrange(ord('a'), ord('z')+1)) ! twoletterwords = [a+b for a in alphabet for b in alphabet] ! ! Since generator comprehensions also return generators, they are not ! restartable. Consequently, they are not substitutable for list ! comprehensions in the following example: ! ! digits = [str(i) for i in xrange(10)] ! alphadig = [a+d for a in 'abcdefg' for d in digits] ! ! To achieve substitutabity, generator comprehensions and x-functions ! can be implemented in a way that supports restarts. PEP 234 [4] ! explicitly states that restarts are to be supported through repeated ! calls to iter(). With that guidance, it is easy to add restartability ! to generator comprehensions using a simple wrapper class around the ! generator function and modifying the implementation above to return: ! ! g = Restartable(__temp) # instead of g = __temp() ! ! Restartable is a simple (12 line) class which calls the generator function ! to create a new, re-wound generator whenever iter() requests a restart. ! Calls to .next() are simply forwarded to the generator. The Python source ! code for the Restartable class can found in the PEP 279 simulator [8]. ! An actual implementation in C can achieve re-startability directly and ! would not need the slow class wrapper used in the pure Python simulation. ! ! The XLazy library [10] shows how restarts can be implemented for xmap, ! xfilter, and xzip. ! ! The upside of adding restart capability is that more list comprehensions ! can be made lazy and save memory by adding 'yield'. Likewise, ! more expressions that use map, filter, and zip can be made lazy just by ! adding 'x'. ! A possible downside is that x-functions have no control over whether their ! inputs are themselves restartable. With non-restartable inputs like ! generators or files, an x-function restart will not produce a meaningful ! result. References --- 440,490 ---- + Commentary from GvR: We discussed this at length when we were hashing + out generators and coroutines, and found that there's always a problem + with this: the argument to the first next() call has to be thrown away, + because it doesn't correspond to a yield statement. This looks ugly + (note that the example code has a dummy call to next() to get the + generator going). But there may be useful examples that can only be + programmed (elegantly) with this feature, so I'm reserving judgment. + I can believe that it's easy to implement. ! Commentary from Ka-Ping Yee: I also think there is a lot of power to be ! gained from generator argument passing. ! Commentary from Neil Schemenauer: I like the idea of being able to pass ! values back into a generator. I originally pitched this idea to Guido ! but in the end we decided against it (at least for the initial ! implementation). There was a few issues to work out but I can't seem ! to remember what they were. My feeling is that we need to wait until ! the Python community has more experience with generators before adding ! this feature. Maybe for 2.4 but not for 2.3. In the mean time you ! can work around this limitation by making your generator a method. ! Values can be passed back by mutating the instance. ! Author response: Okay, consider this part of the proposal deferred ! until 2.4. + Restartability ! [Discussion of restartability deleted] ! Commentary from GvR: The PEP then goes on to discuss restartable ! iterators. I think this is an evil idea obtained from reading too ! much about C++ STL iterators. It should definitely be a separate ! PEP if the author wants me to take this seriously. ! Commentary from Ka-Ping Yee: I have less of an opinion on restartability ! since i have not yet had to really run into that issue. It seems ! reasonable that it might be good idea, though perhaps YAGNI will apply ! here until I experience the need for it first-hand. + Author response: Over thirty reviewers responded, only one was interested + in restartability on the theory that it made life easier for beginners + and that it made lazy evaluation more substitutable for full + evaluation. I was never sold on it myself. Consider it retracted. + References *************** *** 477,496 **** http://gnosis.cx/publish/programming/charming_python_b5.txt ! [6] The code fragment for xmap() was found at: ! http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66448 ! ! [7] PIL, the Python Imaging Library can be found at: http://www.pythonware.com/products/pil/ ! [8] A pure Python simulation of every feature in this PEP is at: http://sourceforge.net/tracker/download.php?group_id=5470&atid=305470&file_id=17348&aid=513752 ! [9] The full, working source code for each of the examples in this PEP along with other examples and tests is at: http://sourceforge.net/tracker/download.php?group_id=5470&atid=305470&file_id=17412&aid=513756 ! [10] Oren Tirosh's XLazy library with re-startable x-functions is at: ! http://www.tothink.com/python/dataflow/ ! Copyright --- 505,519 ---- http://gnosis.cx/publish/programming/charming_python_b5.txt ! [6] PIL, the Python Imaging Library can be found at: http://www.pythonware.com/products/pil/ ! [7] A pure Python simulation of every feature in this PEP is at: http://sourceforge.net/tracker/download.php?group_id=5470&atid=305470&file_id=17348&aid=513752 ! [8] The full, working source code for each of the examples in this PEP along with other examples and tests is at: http://sourceforge.net/tracker/download.php?group_id=5470&atid=305470&file_id=17412&aid=513756 ! Copyright From bwarsaw@users.sourceforge.net Mon Mar 11 17:40:52 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Mon, 11 Mar 2002 09:40:52 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0276.txt,1.1,1.2 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv30522 Modified Files: pep-0276.txt Log Message: James's last update, and mark this PEP rejected. Index: pep-0276.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0276.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pep-0276.txt 13 Nov 2001 20:52:37 -0000 1.1 --- pep-0276.txt 11 Mar 2002 17:40:50 -0000 1.2 *************** *** 4,8 **** Last-Modified: $Date$ Author: james_althoff@i2.com (Jim Althoff) ! Status: Draft Type: Standards Track Created: 12-Nov-2001 --- 4,8 ---- Last-Modified: $Date$ Author: james_althoff@i2.com (Jim Althoff) ! Status: Rejected Type: Standards Track Created: 12-Nov-2001 *************** *** 98,108 **** function to generate a sequence of indices as in, for example: ! for rowcount in range(table.getRowCount()): ! print table.getValueAt(rowcount, 0) or ! for rowcount in xrange(table.getRowCount()): ! print table.getValueAt(rowcount, 0) From time to time there are discussions in the Python community --- 98,108 ---- function to generate a sequence of indices as in, for example: ! for rowcount in range(table.getRowCount()): ! print table.getValueAt(rowcount, 0) or ! for rowcount in xrange(table.getRowCount()): ! print table.getValueAt(rowcount, 0) From time to time there are discussions in the Python community *************** *** 121,125 **** - Unwieldy, especially when combined with the len() function, i.e., xrange(len(sequence)) ! - Not as convenient as equivalent mechanisms in other languages, --- 121,125 ---- - Unwieldy, especially when combined with the len() function, i.e., xrange(len(sequence)) ! - Not as convenient as equivalent mechanisms in other languages, *************** *** 162,167 **** for-loop idiom: ! for rowcount in table.getRowCount(): ! print table.getValueAt(rowcount, 0) The following benefits for this approach vis-a-vis the current --- 162,167 ---- for-loop idiom: ! for rowcount in table.getRowCount(): ! print table.getValueAt(rowcount, 0) The following benefits for this approach vis-a-vis the current *************** *** 191,198 **** lists, tuples, dictionaries, strings, and files. - Preliminary discussion on the Python interest mailing list - suggests a reasonable amount of initial support for this PEP - (along with some dissents/issues noted below). - Backwards Compatibility --- 191,194 ---- *************** *** 211,216 **** xrange(), for example: ! for rowcount in table.getRowCount(): ! print table.getValueAt(rowcount, 0) in Python 2.2 raises a TypeError exception. --- 207,212 ---- xrange(), for example: ! for rowcount in table.getRowCount(): ! print table.getValueAt(rowcount, 0) in Python 2.2 raises a TypeError exception. *************** *** 239,247 **** - Issues: ! Based on some preliminary discussion on the Python interest ! mailing list, the following concerns have been voiced: - Is it obvious that iter(5) maps to the sequence 0,1,2,3,4? --- 235,264 ---- Issues: ! Extensive discussions concerning PEP 276 on the Python interest ! mailing list suggests a range of opinions: some in favor, some ! neutral, some against. Those in favor tend to agree with the ! claims above of the usefulness, convenience, ease of learning, ! and simplicity of a simple iterator for integers. ! ! Issues with PEP 276 include: ! ! - Using range/xrange is fine as is. ! ! Response: Some posters feel this way. Other disagree. ! ! - Some feel that iterating over the sequence "0, 1, 2, ..., n-1" ! for an integer n is not intuitive. "for i in 5:" is considered ! (by some) to be "non-obvious", for example. Some dislike this ! usage because it doesn't have "the right feel". Some dislike it ! because they believe that this type of usage forces one to view ! integers as a sequences and this seems wrong to them. Some ! dislike it because they prefer to view for-loops as dealing ! with explicit sequences rather than with arbitrary iterators. ! ! Response: Some like the proposed idiom and see it as simple, ! elegant, easy to learn, and easy to use. Some are neutral on ! this issue. Others, as noted, dislike it. - Is it obvious that iter(5) maps to the sequence 0,1,2,3,4? *************** *** 251,265 **** (inclusively) the index whose value is one less than the length of the sequence, it is argued that the proposed sequence is ! reasonably intuitive to a Python programmer while being useful ! and practical. ! ! - "in" (as in "for i in x") does not match standard English usage ! in this case. "up to" or something similar might be better. ! ! Response: Not everyone felt that matching standard English ! perfectly is a requirement. It is noted that "for:else:" ! doesn't match standard English very well either. And few are ! excited about adding a new keyword, especially just to get a ! somewhat better match to standard English usage. - Possible ambiguity --- 268,277 ---- (inclusively) the index whose value is one less than the length of the sequence, it is argued that the proposed sequence is ! reasonably intuitive to the Python programmer while being useful ! and practical. More importantly, it is argued that once learned ! this convention is very easy to remember. Note that the doc ! string for the range function makes a reference to the ! natural and useful association between range(n) and the indices ! for a list whose length is n. - Possible ambiguity *************** *** 269,302 **** might be mistaken for ! for i in (10,): print i ! Response: The predicted ambiguity was not readily apparent to ! several of the posters. ! - It would be better to add special new syntax such as: ! for i in 0..10: print i ! Response: There are other PEPs that take this approach[2][3]. ! - It would be better to reuse the ellipsis literal syntax (...) ! Response: Shares disadvantages of other proposals that require ! changes to the syntax. Needs more design to determine how it ! would handle the general case of start,stop,step, ! open/closed/half-closed intervals, etc. Needs a PEP. ! - It would be better to reuse the slicing literal syntax attached ! to the int class, e.g., int[0:10] ! Response: Same as previous response. In addition, design ! consideration needs to be given to what it would mean if one ! uses slicing syntax after some arbitrary class other than class ! int. Needs a PEP. - Might dissuade newbies from using the indexed for-loop idiom when the standard "for item in collection:" idiom is clearly better. ! Response: The standard idiom is so nice when "it fits" that it needs neither extra "carrot" nor "stick". On the other hand, one does notice cases of overuse/misuse of the standard idiom --- 281,335 ---- might be mistaken for ! for i in (10,): print i ! Response: This is exactly the same situation with strings in ! current Python (replace 10 with 'spam' in the above, for ! example). ! - Too general: in the newest releases of Python there are ! contexts -- as with for-loops -- where iterators are called ! implicitly. Some fear that having an iterator invoked for ! an integer in one of the context (excluding for-loops) might ! lead to unexpected behavior and bugs. The "x, = 1" example ! noted above is an a case in point. ! Response: From the author's perspective the examples of the ! above that were identified in the PEP 276 discussions did ! not appear to be ones that would be accidentally misused ! in ways that would lead to subtle and hard-to-detect errors. ! In addition, it seems that there is a way to deal with this ! issue by using a variation of what is outlined in the ! specification section of this proposal. Instead of adding ! an __iter__ method to class int, change the for-loop handling ! code to convert (in essense) from ! for i in n: # when isinstance(n,int) is 1 ! to ! for i in xrange(n): ! This approach gives the same results in a for-loop as an ! __iter__ method would but would prevent iteration on integer ! values in any other context. Lists and tuples, for example, ! don't have __iter__ and are handled with special code. ! Integer values would be one more special case. ! ! - "i in n" seems very unnatural. ! ! Response: Some feel that "i in len(mylist)" would be easily ! understandable and useful. Some don't like it, particularly ! when a literal is used as in "i in 5". If the variant ! mentioned in the response to the previous issue is implemented, ! this issue is moot. If not, then one could also address this ! issue by defining a __contains__ method in class int that would ! always raise a TypeError. This would then make the behavior of ! "i in n" identical to that of current Python. - Might dissuade newbies from using the indexed for-loop idiom when the standard "for item in collection:" idiom is clearly better. ! Response: The standard idiom is so nice when it fits that it needs neither extra "carrot" nor "stick". On the other hand, one does notice cases of overuse/misuse of the standard idiom *************** *** 304,370 **** idiom), as in: ! for item in sequence: ! print sequence.index(item) ! ! - Doesn't handle the general case of start,stop,step ! ! Response: use the existing range() or xrange() mechanisms. Or, ! see below. ! ! ! Extension ! ! If one wants to handle general indexing (start,stop,step) without ! having to resort to using the range() or xrange() functions then ! the following could be incorporated into the current proposal. ! ! Add an "iter" method (or use some other preferred name) to ! types.IntType with the following signature: ! ! def iter(start=0, step=1): ! ! This method would have the (hopefully) obvious semantics. ! ! Then one could do, for example: ! ! x = 100 ! for i in x.iter(start=1, step=2): ! print i ! ! Under this extension (for x bound to an int), ! for i in x: ! would be equivalent to ! for i in x.iter(): ! and to ! for i in x.iter(start=0, step=1): ! This extension is consistent with the generalization provided by ! the current mechanism for dictionaries whereby one can use: ! for k in d.iterkeys(): ! for v in d.itervalues(): ! for k,v in d.iteritems(): ! depending on one's needs, given that ! for i in d: ! has a meaning aimed at the most common and useful case (d.iterkeys()). Implementation ! An implementation is not available at this time and although the ! author is not qualified to comment on such he will, nonetheless, ! speculate that this might be straightforward and, hopefully, might ! consist of little more than setting the tp_iter slot in ! types.IntType to point to a simple iterator function that would be ! similar to -- or perhaps even a wrapper around -- the xrange() ! function. --- 337,388 ---- idiom), as in: ! for item in sequence: ! print sequence.index(item) ! - Why not propose even bigger changes? ! The majority of disagreement with PEP 276 came from those who ! favor much larger changes to Python to address the more general ! problem of specifying a sequence of integers where such ! a specification is general enough to handle the starting value, ! ending value, and stepping value of the sequence and also ! addresses variations of open, closed, and half-open (half-closed) ! integer intervals. Many suggestions of such were discussed. ! These include: ! - adding Haskell-like notation for specifying a sequence of ! integers in a literal list, ! - various uses of slicing notation to specify sequences, ! - changes to the syntax of for-in loops to allow the use of ! relational operators in the loop header, ! - creation of an integer-interval class along with methods that ! overload relational operators or division operators ! to provide "slicing" on integer-interval objects, ! - and more. ! It should be noted that there was much debate but not an ! overwhelming concensus for any of these larger-scale suggestions. ! Clearly, PEP 276 does not propose such a large-scale change ! and instead focuses on a specific problem area. Towards the ! end of the discussion period, several posters expressed favor ! for the narrow focus and simplicity of PEP 276 vis-a-vis the more ! ambitious suggestions that were advanced. There did appear to be ! concensus for the need for a PEP for any such larger-scale, ! alternative suggestion. In light of this recognition, details of ! the various alternative suggestions are not discussed here further. Implementation ! An implementation is not available at this time but is expected ! to be straightforward. The author has implemented a subclass of ! int with an __iter__ method (written in Python) as a means to test ! out the ideas in this proposal, however. From bwarsaw@users.sourceforge.net Mon Mar 11 17:41:09 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Mon, 11 Mar 2002 09:41:09 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.167,1.168 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv30608 Modified Files: pep-0000.txt Log Message: PEP 276 is now formally rejected. Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.167 retrieving revision 1.168 diff -C2 -d -r1.167 -r1.168 *** pep-0000.txt 11 Mar 2002 17:31:02 -0000 1.167 --- pep-0000.txt 11 Mar 2002 17:41:07 -0000 1.168 *************** *** 85,89 **** S 274 Dict Comprehensions Warsaw S 275 Switching on Multiple Values Lemburg - S 276 Simple Iterator for ints Althoff S 277 Unicode file name support for Windows NT Hodgson S 278 Universal Newline Support Jansen --- 85,88 ---- *************** *** 150,153 **** --- 149,153 ---- SR 259 Omit printing newline after newline van Rossum SR 271 Prefixing sys.path by command line option Giacometti + SR 276 Simple Iterator for ints Althoff SR 666 Reject Foolish Indentation Creighton *************** *** 251,255 **** S 274 Dict Comprehensions Warsaw S 275 Switching on Multiple Values Lemburg ! S 276 Simple Iterator for ints Althoff S 277 Unicode file name support for Windows NT Hodgson S 278 Universal Newline Support Jansen --- 251,255 ---- S 274 Dict Comprehensions Warsaw S 275 Switching on Multiple Values Lemburg ! SR 276 Simple Iterator for ints Althoff S 277 Unicode file name support for Windows NT Hodgson S 278 Universal Newline Support Jansen From tim.one@comcast.net Mon Mar 11 17:50:51 2002 From: tim.one@comcast.net (Tim Peters) Date: Mon, 11 Mar 2002 12:50:51 -0500 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.167,1.168 In-Reply-To: Message-ID: [Barry] > Modified Files: > pep-0000.txt > Log Message: > PEP 276 is now formally rejected. It shouldn't be rejected unless/until the reason for rejection is recorded in the PEP. (Even if it's only "butt ugly" .) From barry@zope.com Mon Mar 11 18:11:00 2002 From: barry@zope.com (Barry A. Warsaw) Date: Mon, 11 Mar 2002 13:11:00 -0500 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.167,1.168 References: Message-ID: <15500.62260.919538.330290@anthem.wooz.org> >>>>> "TP" == Tim Peters writes: TP> [Barry] >> Modified Files: pep-0000.txt Log Message: PEP 276 is now >> formally rejected. TP> It shouldn't be rejected unless/until the reason for rejection TP> is recorded in the PEP. (Even if it's only "butt ugly" TP> .) Guido, do you mind adding a rejection reason to the PEP? -Barry From guido@python.org Mon Mar 11 18:32:44 2002 From: guido@python.org (Guido van Rossum) Date: Mon, 11 Mar 2002 13:32:44 -0500 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.167,1.168 In-Reply-To: Your message of "Mon, 11 Mar 2002 13:11:00 EST." <15500.62260.919538.330290@anthem.wooz.org> References: <15500.62260.919538.330290@anthem.wooz.org> Message-ID: <200203111832.g2BIWiP04841@pcp742651pcs.reston01.va.comcast.net> > TP> It shouldn't be rejected unless/until the reason for rejection > TP> is recorded in the PEP. (Even if it's only "butt ugly" > TP> .) > > Guido, do you mind adding a rejection reason to the PEP? Um, I didn't formally reject it, and would prefer to keep it open for now. --Guido van Rossum (home page: http://www.python.org/~guido/) From fdrake@users.sourceforge.net Mon Mar 11 18:42:10 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 11 Mar 2002 10:42:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc Makefile.deps,1.83,1.84 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory usw-pr-cvs1:/tmp/cvs-serv17469 Modified Files: Makefile.deps Log Message: Make the extension manual format using the Makefile; recent changes broke the dependency information. Index: Makefile.deps =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile.deps,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -d -r1.83 -r1.84 *** Makefile.deps 8 Mar 2002 03:18:19 -0000 1.83 --- Makefile.deps 11 Mar 2002 18:42:08 -0000 1.84 *************** *** 57,61 **** ext/extending.tex \ ext/newtypes.tex \ ! ext/unix.tex \ ext/windows.tex \ ext/embedding.tex \ --- 57,61 ---- ext/extending.tex \ ext/newtypes.tex \ ! ext/building.tex \ ext/windows.tex \ ext/embedding.tex \ From fdrake@users.sourceforge.net Mon Mar 11 18:46:31 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 11 Mar 2002 10:46:31 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/api abstract.tex,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv18616/api Modified Files: abstract.tex Log Message: Documentation for PyObject_GetIter(), contributed by Greg Chapman (with only minor changes by Fred). This closes SF bug #498607. Index: abstract.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/abstract.tex,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** abstract.tex 26 Dec 2001 16:53:48 -0000 1.9 --- abstract.tex 11 Mar 2002 18:46:29 -0000 1.10 *************** *** 308,311 **** --- 308,319 ---- \end{cfuncdesc} + \begin{cfuncdesc}{PyObject*}{PyObject_GetIter}{PyObject *o} + This is equivalent to the Python expression \samp{iter(\var{o})}. + It returns a new iterator for the object argument, or the object + itself if the object is already an iterator. Raises + \exception{TypeError} and returns \NULL{} if the object cannot be + iterated. + \end{cfuncdesc} + \section{Number Protocol \label{number}} *************** *** 856,863 **** \begin{verbatim} ! PyObject *iterator = ...; PyObject *item; ! while (item = PyIter_Next(iter)) { /* do something with item */ ... --- 864,875 ---- \begin{verbatim} ! PyObject *iterator = PyObject_GetIter(obj); PyObject *item; ! if (iterator == NULL) { ! /* propagate error */ ! } ! ! while (item = PyIter_Next(iterator)) { /* do something with item */ ... *************** *** 865,870 **** Py_DECREF(item); } if (PyErr_Occurred()) { ! /* propogate error */ } else { --- 877,885 ---- Py_DECREF(item); } + + Py_DECREF(iterator); + if (PyErr_Occurred()) { ! /* propagate error */ } else { From bwarsaw@users.sourceforge.net Mon Mar 11 18:54:42 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Mon, 11 Mar 2002 10:54:42 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0276.txt,1.2,1.3 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv20865 Modified Files: pep-0276.txt Log Message: Un-reject this PEP. Index: pep-0276.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0276.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pep-0276.txt 11 Mar 2002 17:40:50 -0000 1.2 --- pep-0276.txt 11 Mar 2002 18:54:40 -0000 1.3 *************** *** 4,8 **** Last-Modified: $Date$ Author: james_althoff@i2.com (Jim Althoff) ! Status: Rejected Type: Standards Track Created: 12-Nov-2001 --- 4,8 ---- Last-Modified: $Date$ Author: james_althoff@i2.com (Jim Althoff) ! Status: Active Type: Standards Track Created: 12-Nov-2001 From bwarsaw@users.sourceforge.net Mon Mar 11 18:55:33 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Mon, 11 Mar 2002 10:55:33 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.168,1.169 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv21318 Modified Files: pep-0000.txt Log Message: Unreject PEP 276 Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.168 retrieving revision 1.169 diff -C2 -d -r1.168 -r1.169 *** pep-0000.txt 11 Mar 2002 17:41:07 -0000 1.168 --- pep-0000.txt 11 Mar 2002 18:55:31 -0000 1.169 *************** *** 85,88 **** --- 85,89 ---- S 274 Dict Comprehensions Warsaw S 275 Switching on Multiple Values Lemburg + S 276 Simple Iterator for ints Althoff S 277 Unicode file name support for Windows NT Hodgson S 278 Universal Newline Support Jansen *************** *** 149,153 **** SR 259 Omit printing newline after newline van Rossum SR 271 Prefixing sys.path by command line option Giacometti - SR 276 Simple Iterator for ints Althoff SR 666 Reject Foolish Indentation Creighton --- 150,153 ---- *************** *** 251,255 **** S 274 Dict Comprehensions Warsaw S 275 Switching on Multiple Values Lemburg ! SR 276 Simple Iterator for ints Althoff S 277 Unicode file name support for Windows NT Hodgson S 278 Universal Newline Support Jansen --- 251,255 ---- S 274 Dict Comprehensions Warsaw S 275 Switching on Multiple Values Lemburg ! S 276 Simple Iterator for ints Althoff S 277 Unicode file name support for Windows NT Hodgson S 278 Universal Newline Support Jansen From barry@zope.com Mon Mar 11 18:56:11 2002 From: barry@zope.com (Barry A. Warsaw) Date: Mon, 11 Mar 2002 13:56:11 -0500 Subject: [Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.167,1.168 References: <15500.62260.919538.330290@anthem.wooz.org> <200203111832.g2BIWiP04841@pcp742651pcs.reston01.va.comcast.net> Message-ID: <15500.64971.602650.524442@anthem.wooz.org> >>>>> "GvR" == Guido van Rossum writes: GvR> Um, I didn't formally reject it, and would prefer to keep it GvR> open for now. I've un-rejected it. -Barry From fdrake@users.sourceforge.net Mon Mar 11 19:02:01 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 11 Mar 2002 11:02:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/api abstract.tex,1.8.6.1,1.8.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv23448/api Modified Files: Tag: release22-maint abstract.tex Log Message: Documentation for PyObject_GetIter(), contributed by Greg Chapman (with only minor changes by Fred). This closes SF bug #498607. Index: abstract.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/abstract.tex,v retrieving revision 1.8.6.1 retrieving revision 1.8.6.2 diff -C2 -d -r1.8.6.1 -r1.8.6.2 *** abstract.tex 28 Dec 2001 04:30:38 -0000 1.8.6.1 --- abstract.tex 11 Mar 2002 19:01:58 -0000 1.8.6.2 *************** *** 308,311 **** --- 308,319 ---- \end{cfuncdesc} + \begin{cfuncdesc}{PyObject*}{PyObject_GetIter}{PyObject *o} + This is equivalent to the Python expression \samp{iter(\var{o})}. + It returns a new iterator for the object argument, or the object + itself if the object is already an iterator. Raises + \exception{TypeError} and returns \NULL{} if the object cannot be + iterated. + \end{cfuncdesc} + \section{Number Protocol \label{number}} *************** *** 856,863 **** \begin{verbatim} ! PyObject *iterator = ...; PyObject *item; ! while (item = PyIter_Next(iter)) { /* do something with item */ ... --- 864,875 ---- \begin{verbatim} ! PyObject *iterator = PyObject_GetIter(obj); PyObject *item; ! if (iterator == NULL) { ! /* propagate error */ ! } ! ! while (item = PyIter_Next(iterator)) { /* do something with item */ ... *************** *** 865,870 **** Py_DECREF(item); } if (PyErr_Occurred()) { ! /* propogate error */ } else { --- 877,885 ---- Py_DECREF(item); } + + Py_DECREF(iterator); + if (PyErr_Occurred()) { ! /* propagate error */ } else { From bwarsaw@users.sourceforge.net Mon Mar 11 19:31:46 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Mon, 11 Mar 2002 11:31:46 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0279.txt,1.6,1.7 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv30928 Modified Files: pep-0279.txt Log Message: One more update from Raymond Hettinger. Index: pep-0279.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0279.txt,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pep-0279.txt 11 Mar 2002 17:33:49 -0000 1.6 --- pep-0279.txt 11 Mar 2002 19:31:23 -0000 1.7 *************** *** 52,56 **** 1. Add a new builtin function, indexed() which was made possible once iterators and generators became available. It provides ! all iterables with the same advantage that iteritem() affords to dictionaries -- a compact, readable, reliable index notation. --- 52,56 ---- 1. Add a new builtin function, indexed() which was made possible once iterators and generators became available. It provides ! all iterables with the same advantage that iteritems() affords to dictionaries -- a compact, readable, reliable index notation. *************** *** 160,163 **** --- 160,169 ---- module then you can add lots of useful functions (Haskell has lots of them that we could steal). + + Commentary for Magnus Lie Hetland: I think indexed would be a useful and + natural built-in function. I would certainly use it a lot. + I like indexed() a lot; +1. I'm quite happy to have it make PEP 281 + obsolete. Adding a separate module for iterator utilities seems like + a good idea. Author response: Prior to these comments, four builtins were proposed. *************** *** 243,246 **** --- 249,257 ---- a nested generator to do the same thing. They smell like lambda. + Commentary for Magnus Lie Hetland: Generator comprehensions seem mildly + useful, but I vote +0. Defining a separate, named generator would + probably be my preference. On the other hand, I do see the advantage + of "scaling up" from list comprehensions. + Author response: This may be before its time in that some people still don't like list comprehensions and half of this PEP's reviewers did *************** *** 262,266 **** try: while 1:0 ! log.append( time.time() - start ) yield log[-1] except WriteLog: --- 273,277 ---- try: while 1:0 ! log.append( time.time() - start ) yield log[-1] except WriteLog: *************** *** 321,325 **** passing of values back, then we should add this feature too. ! Author response: If the sole use of generators is to simplify writing iterators for lazy producers, then the odds of needing generator exception passing are very slim. If, on the other hand, generators --- 332,339 ---- passing of values back, then we should add this feature too. ! Commentary for Magnus Lie Hetland: Even though I cannot speak for the ! ease of implementation, I vote +1 for the exception passing mechanism. ! ! Author response: When the sole use of generators is to simplify writing iterators for lazy producers, then the odds of needing generator exception passing are very slim. If, on the other hand, generators *************** *** 462,465 **** --- 476,486 ---- Values can be passed back by mutating the instance. + Commentary for Magnus Lie Hetland: I like the generator parameter + passing mechanism. Although I see no need to defer it, deferral seems + to be the most likely scenario, and in the meantime I guess the + functionality can be emulated either by implementing the generator + as a method, or by passing a parameter with the exception + passing mechanism. + Author response: Okay, consider this part of the proposal deferred until 2.4. *************** *** 480,483 **** --- 501,507 ---- reasonable that it might be good idea, though perhaps YAGNI will apply here until I experience the need for it first-hand. + + Commentary for Magnus Lie Hetland: I guess there is no real need to comment + on restartability, but I can't see that I have any need for it. Author response: Over thirty reviewers responded, only one was interested From tim_one@users.sourceforge.net Tue Mar 12 03:04:46 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 11 Mar 2002 19:04:46 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects fileobject.c,2.145,2.146 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv17165/python/Objects Modified Files: fileobject.c Log Message: Change Windows file.truncate() to (a) restore the original file position, and (b) stop trying to prevent file growth. Beef up the file.truncate() docs. Change test_largefile.py to stop assuming that f.truncate() moves the file pointer to the truncation point, and to verify instead that it leaves the file position alone. Remove the test for what happens when a specified size exceeds the original file size (it's ill-defined, according to the Single Unix Spec). Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.145 retrieving revision 2.146 diff -C2 -d -r2.145 -r2.146 *** fileobject.c 11 Mar 2002 00:24:00 -0000 2.145 --- fileobject.c 12 Mar 2002 03:04:44 -0000 2.146 *************** *** 416,454 **** #ifdef MS_WIN32 /* MS _chsize doesn't work if newsize doesn't fit in 32 bits, ! so don't even try using it. truncate() should never grow the ! file, but MS SetEndOfFile will grow a file, so we need to ! compare the specified newsize to the actual size. Some ! optimization could be done here when newsizeobj is NULL. */ { ! Py_off_t currentEOF; /* actual size */ HANDLE hFile; int error; ! /* First move to EOF, and set currentEOF to the size. */ ! errno = 0; ! if (_portable_fseek(f->f_fp, 0, SEEK_END) != 0) ! goto onioerror; ! errno = 0; ! currentEOF = _portable_ftell(f->f_fp); ! if (currentEOF == -1) ! goto onioerror; ! ! if (newsize > currentEOF) ! newsize = currentEOF; /* never grow the file */ ! ! /* Move to newsize, and truncate the file there. */ ! if (newsize != currentEOF) { errno = 0; ! if (_portable_fseek(f->f_fp, newsize, SEEK_SET) != 0) goto onioerror; Py_BEGIN_ALLOW_THREADS errno = 0; ! hFile = (HANDLE)_get_osfhandle(fileno(f->f_fp)); ! error = hFile == (HANDLE)-1; ! if (!error) { ! error = SetEndOfFile(hFile) == 0; ! if (error) ! errno = EACCES; ! } Py_END_ALLOW_THREADS if (error) --- 416,443 ---- #ifdef MS_WIN32 /* MS _chsize doesn't work if newsize doesn't fit in 32 bits, ! so don't even try using it. */ { ! Py_off_t current; /* current file position */ HANDLE hFile; int error; ! /* current <- current file postion. */ ! if (newsizeobj == NULL) ! current = newsize; ! else { ! Py_BEGIN_ALLOW_THREADS errno = 0; ! current = _portable_ftell(f->f_fp); ! Py_END_ALLOW_THREADS ! if (current == -1) goto onioerror; + } + + /* Move to newsize. */ + if (current != newsize) { Py_BEGIN_ALLOW_THREADS errno = 0; ! error = _portable_fseek(f->f_fp, newsize, SEEK_SET) ! != 0; Py_END_ALLOW_THREADS if (error) *************** *** 456,459 **** --- 445,472 ---- } + /* Truncate. Note that this may grow the file! */ + Py_BEGIN_ALLOW_THREADS + errno = 0; + hFile = (HANDLE)_get_osfhandle(fileno(f->f_fp)); + error = hFile == (HANDLE)-1; + if (!error) { + error = SetEndOfFile(hFile) == 0; + if (error) + errno = EACCES; + } + Py_END_ALLOW_THREADS + if (error) + goto onioerror; + + /* Restore original file position. */ + if (current != newsize) { + Py_BEGIN_ALLOW_THREADS + errno = 0; + error = _portable_fseek(f->f_fp, current, SEEK_SET) + != 0; + Py_END_ALLOW_THREADS + if (error) + goto onioerror; + } } #else From tim_one@users.sourceforge.net Tue Mar 12 03:04:46 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 11 Mar 2002 19:04:46 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_largefile.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv17165/python/Lib/test Modified Files: test_largefile.py Log Message: Change Windows file.truncate() to (a) restore the original file position, and (b) stop trying to prevent file growth. Beef up the file.truncate() docs. Change test_largefile.py to stop assuming that f.truncate() moves the file pointer to the truncation point, and to verify instead that it leaves the file position alone. Remove the test for what happens when a specified size exceeds the original file size (it's ill-defined, according to the Single Unix Spec). Index: test_largefile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_largefile.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** test_largefile.py 11 Mar 2002 00:24:00 -0000 1.13 --- test_largefile.py 12 Mar 2002 03:04:44 -0000 1.14 *************** *** 134,155 **** f = open(name, 'r+b') f.seek(0, 2) ! expect(f.tell(), size+1) # Cut it back via seek + truncate with no argument. newsize = size - 10 f.seek(newsize) f.truncate() ! expect(f.tell(), newsize) ! # Ensure that truncate(bigger than true size) doesn't grow the file. ! f.truncate(size) ! expect(f.tell(), newsize) # Ensure that truncate(smaller than true size) shrinks the file. newsize -= 1 ! f.seek(0) f.truncate(newsize) ! expect(f.tell(), newsize) # cut it waaaaay back - f.truncate(1) f.seek(0) ! expect(len(f.read()), 1) f.close() --- 134,161 ---- f = open(name, 'r+b') f.seek(0, 2) ! expect(f.tell(), size+1) # else we've lost track of the true size # Cut it back via seek + truncate with no argument. newsize = size - 10 f.seek(newsize) f.truncate() ! expect(f.tell(), newsize) # else pointer moved ! f.seek(0, 2) ! expect(f.tell(), newsize) # else wasn't truncated # Ensure that truncate(smaller than true size) shrinks the file. newsize -= 1 ! f.seek(42) f.truncate(newsize) ! expect(f.tell(), 42) # else pointer moved ! f.seek(0, 2) ! expect(f.tell(), newsize) # else wasn't truncated ! ! # XXX truncate(larger than true size) is ill-defined across platforms ! # cut it waaaaay back f.seek(0) ! f.truncate(1) ! expect(f.tell(), 0) # else pointer moved ! expect(len(f.read()), 1) # else wasn't truncated ! f.close() From tim_one@users.sourceforge.net Tue Mar 12 03:04:46 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 11 Mar 2002 19:04:46 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libstdtypes.tex,1.82,1.83 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv17165/python/Doc/lib Modified Files: libstdtypes.tex Log Message: Change Windows file.truncate() to (a) restore the original file position, and (b) stop trying to prevent file growth. Beef up the file.truncate() docs. Change test_largefile.py to stop assuming that f.truncate() moves the file pointer to the truncation point, and to verify instead that it leaves the file position alone. Remove the test for what happens when a specified size exceeds the original file size (it's ill-defined, according to the Single Unix Spec). Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** libstdtypes.tex 11 Mar 2002 00:24:00 -0000 1.82 --- libstdtypes.tex 12 Mar 2002 03:04:44 -0000 1.83 *************** *** 162,166 **** \subsection{Numeric Types \label{typesnumeric}} ! There are four numeric types: \dfn{plain integers}, \dfn{long integers}, \dfn{floating point numbers}, and \dfn{complex numbers}. Plain integers (also just called \dfn{integers}) --- 162,166 ---- \subsection{Numeric Types \label{typesnumeric}} ! There are four numeric types: \dfn{plain integers}, \dfn{long integers}, \dfn{floating point numbers}, and \dfn{complex numbers}. Plain integers (also just called \dfn{integers}) *************** *** 179,183 **** Complex numbers have a real and imaginary part, which are both implemented using \ctype{double} in C. To extract these parts from ! a complex number \var{z}, use \code{\var{z}.real} and \code{\var{z}.imag}. Numbers are created by numeric literals or as the result of built-in --- 179,183 ---- Complex numbers have a real and imaginary part, which are both implemented using \ctype{double} in C. To extract these parts from ! a complex number \var{z}, use \code{\var{z}.real} and \code{\var{z}.imag}. Numbers are created by numeric literals or as the result of built-in *************** *** 249,253 **** \item[(1)] For (plain or long) integer division, the result is an integer. ! The result is always rounded towards minus infinity: 1/2 is 0, (-1)/2 is -1, 1/(-2) is -1, and (-1)/(-2) is 0. Note that the result is a long integer if either operand is a long integer, regardless of --- 249,253 ---- \item[(1)] For (plain or long) integer division, the result is an integer. ! The result is always rounded towards minus infinity: 1/2 is 0, (-1)/2 is -1, 1/(-2) is -1, and (-1)/(-2) is 0. Note that the result is a long integer if either operand is a long integer, regardless of *************** *** 473,477 **** \code{len(\var{s}) + \var{j}} is substituted. But note that \code{-0} is still \code{0}. ! \item[(3)] The slice of \var{s} from \var{i} to \var{j} is defined as the sequence of items with index \var{k} such that \code{\var{i} <= --- 473,477 ---- \code{len(\var{s}) + \var{j}} is substituted. But note that \code{-0} is still \code{0}. ! \item[(3)] The slice of \var{s} from \var{i} to \var{j} is defined as the sequence of items with index \var{k} such that \code{\var{i} <= *************** *** 809,813 **** Additional string operations are defined in standard modules \refmodule{string}\refstmodindex{string} and ! \refmodule{re}.\refstmodindex{re} --- 809,813 ---- Additional string operations are defined in standard modules \refmodule{string}\refstmodindex{string} and ! \refmodule{re}.\refstmodindex{re} *************** *** 882,886 **** deprecated since Python 1.4. ! \item[(2)] Raises an exception when \var{x} is not a list object. The \method{extend()} method is experimental and not supported by mutable sequence types other than lists. --- 882,886 ---- deprecated since Python 1.4. ! \item[(2)] Raises an exception when \var{x} is not a list object. The \method{extend()} method is experimental and not supported by mutable sequence types other than lists. *************** *** 1035,1039 **** File objects\obindex{file} are implemented using C's \code{stdio} package and can be created with the built-in constructor ! \function{file()}\bifuncindex{file} described in section \ref{built-in-funcs}, ``Built-in Functions.''\footnote{\function{file()} is new in Python 2.2. The older built-in \function{open()} is an --- 1035,1039 ---- File objects\obindex{file} are implemented using C's \code{stdio} package and can be created with the built-in constructor ! \function{file()}\bifuncindex{file} described in section \ref{built-in-funcs}, ``Built-in Functions.''\footnote{\function{file()} is new in Python 2.2. The older built-in \function{open()} is an *************** *** 1101,1108 **** Read one entire line from the file. A trailing newline character is kept in the string\footnote{ ! The advantage of leaving the newline on is that an empty string ! can be returned to mean \EOF{} without being ambiguous. Another ! advantage is that (in cases where it might matter, for example. if you ! want to make an exact copy of a file while scanning its lines) you can tell whether the last line of a file ended in a newline or not (yes this happens!). --- 1101,1108 ---- Read one entire line from the file. A trailing newline character is kept in the string\footnote{ ! The advantage of leaving the newline on is that an empty string ! can be returned to mean \EOF{} without being ambiguous. Another ! advantage is that (in cases where it might matter, for example. if you ! want to make an exact copy of a file while scanning its lines) you can tell whether the last line of a file ended in a newline or not (yes this happens!). *************** *** 1153,1159 **** \begin{methoddesc}[file]{truncate}{\optional{size}} ! Truncate the file's size. If the optional \var{size} argument present, the file is truncated to (at most) that size. The size ! defaults to the current position. Availability: Windows, many \UNIX variants. \end{methoddesc} --- 1153,1164 ---- \begin{methoddesc}[file]{truncate}{\optional{size}} ! Truncate the file's size. If the optional \var{size} argument is present, the file is truncated to (at most) that size. The size ! defaults to the current position. The current file position is ! not changed. Note that if a specified size exceeds the file's ! current size, the result is platform-dependent: possibilities ! include that file may remain unchanged, increase to the specified ! size as if zero-filled, or increase to the specified size with ! undefined new content. Availability: Windows, many \UNIX variants. \end{methoddesc} From fdrake@users.sourceforge.net Tue Mar 12 14:26:39 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 12 Mar 2002 06:26:39 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/hotshot log.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/hotshot In directory usw-pr-cvs1:/tmp/cvs-serv19642 Modified Files: log.py Log Message: Set/update self.cwd properly. Index: log.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/hotshot/log.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** log.py 29 Oct 2001 20:57:23 -0000 1.4 --- log.py 12 Mar 2002 14:26:37 -0000 1.5 *************** *** 38,42 **** --- 38,48 ---- self._nextitem = self._reader.next self._info = self._reader.info + if self._info.has_key('current-directory'): + self.cwd = self._info['current-directory'] + else: + self.cwd = None self._stack = [] + self._append = self._stack.append + self._pop = self._stack.pop def addinfo(self, key, value): *************** *** 54,57 **** --- 60,85 ---- pass + def get_filename(self, fileno): + try: + return self._filemap[fileno] + except KeyError: + raise ValueError, "unknown fileno" + + def get_filenames(self): + return self._filemap.values() + + def get_fileno(self, filename): + filename = os.path.normcase(os.path.normpath(filename)) + for fileno, name in self._filemap.items(): + if name == filename: + return fileno + raise ValueError, "unknown filename" + + def get_funcname(self, fileno, lineno): + try: + return self._funcmap[(fileno, lineno)] + except KeyError: + raise ValueError, "unknown function location" + # Iteration support: # This adds an optional (& ignored) parameter to next() so that the *************** *** 67,92 **** self._reader.close() raise StopIteration() if what == WHAT_DEFINE_FILE: ! self._filemap[fileno] = tdelta ! continue ! if what == WHAT_DEFINE_FUNC: filename = self._filemap[fileno] self._funcmap[(fileno, lineno)] = (filename, tdelta) ! continue ! if what == WHAT_ADD_INFO: # value already loaded into self.info; call the # overridable addinfo() handler so higher-level code # can pick up the new value self.addinfo(tdelta, lineno) - continue - if what == WHAT_ENTER: - t = self._decode_location(fileno, lineno) - filename, funcname = t - self._stack.append((filename, funcname, lineno)) - elif what == WHAT_EXIT: - filename, funcname, lineno = self._stack.pop() else: ! filename, funcname, firstlineno = self._stack[-1] ! return what, (filename, lineno, funcname), tdelta if sys.version < "2.2": --- 95,129 ---- self._reader.close() raise StopIteration() + + # handle the most common cases first + + if what == WHAT_ENTER: + filename, funcname = self._decode_location(fileno, lineno) + self._append((filename, funcname, lineno)) + return what, (filename, lineno, funcname), tdelta + + if what == WHAT_EXIT: + filename, funcname, lineno = self._pop() + return what, (filename, lineno, funcname), tdelta + + if what == WHAT_LINENO: + filename, funcname, firstlineno = self._stack[-1] + return what, (filename, lineno, funcname), tdelta + if what == WHAT_DEFINE_FILE: ! filename = os.path.normcase(os.path.normpath(tdelta)) ! self._filemap[fileno] = filename ! elif what == WHAT_DEFINE_FUNC: filename = self._filemap[fileno] self._funcmap[(fileno, lineno)] = (filename, tdelta) ! elif what == WHAT_ADD_INFO: # value already loaded into self.info; call the # overridable addinfo() handler so higher-level code # can pick up the new value + if tdelta == 'current-directory': + self.cwd = lineno self.addinfo(tdelta, lineno) else: ! raise ValueError, "unknown event type" if sys.version < "2.2": From jackjansen@users.sourceforge.net Tue Mar 12 15:05:13 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 12 Mar 2002 07:05:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Lib macostools.py,1.12.14.1,1.12.14.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib In directory usw-pr-cvs1:/tmp/cvs-serv2273 Modified Files: Tag: release22-maint macostools.py Log Message: Backport of 1.14: mkalias() now also works for folders. Fixes bug #515830. Index: macostools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Lib/macostools.py,v retrieving revision 1.12.14.1 retrieving revision 1.12.14.2 diff -C2 -d -r1.12.14.1 -r1.12.14.2 *** macostools.py 24 Feb 2002 22:50:03 -0000 1.12.14.1 --- macostools.py 12 Mar 2002 15:05:11 -0000 1.12.14.2 *************** *** 35,41 **** else: alias = srcfss.NewAlias() ! srcfinfo = srcfss.GetFInfo() ! ! Res.FSpCreateResFile(dstfss, srcfinfo.Creator, srcfinfo.Type, -1) h = Res.FSpOpenResFile(dstfss, 3) resource = Res.Resource(alias.data) --- 35,45 ---- else: alias = srcfss.NewAlias() ! ! if os.path.isdir(src): ! cr, tp = 'MACS', 'fdrp' ! else: ! cr, tp = srcfss.GetCreatorType() ! ! Res.FSpCreateResFile(dstfss, cr, tp, -1) h = Res.FSpOpenResFile(dstfss, 3) resource = Res.Resource(alias.data) From jackjansen@users.sourceforge.net Tue Mar 12 15:25:56 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 12 Mar 2002 07:25:56 -0800 Subject: [Python-checkins] CVS: python/dist/src configure.in,1.295,1.296 configure,1.285,1.286 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv12073 Modified Files: configure.in configure Log Message: Add a -Wno-long-double flag to the compile flags on Mac OS X. Fixes bug 525481. (Probably not a 2.2.1 candidate, unless the fix that introduced a long double into objimpl.h (rev. 2.44) is backported to 2.2.1). Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.295 retrieving revision 1.296 diff -C2 -d -r1.295 -r1.296 *** configure.in 8 Mar 2002 21:43:51 -0000 1.295 --- configure.in 12 Mar 2002 15:25:52 -0000 1.296 *************** *** 399,403 **** case $ac_sys_system in Darwin*) ! OPT="$OPT -no-cpp-precomp";; esac fi --- 399,403 ---- case $ac_sys_system in Darwin*) ! OPT="$OPT -Wno-long-double -no-cpp-precomp";; esac fi Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.285 retrieving revision 1.286 diff -C2 -d -r1.285 -r1.286 *** configure 8 Mar 2002 13:43:01 -0000 1.285 --- configure 12 Mar 2002 15:25:52 -0000 1.286 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.293 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.295 # Guess values for system-dependent variables and create Makefiles. *************** *** 1429,1433 **** case $ac_sys_system in AIX*) ! LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); $(LINKCC)";; dgux*) LINKCC="LD_RUN_PATH=$libdir $(LINKCC)";; --- 1429,1433 ---- case $ac_sys_system in AIX*) ! LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); $LINKCC";; dgux*) LINKCC="LD_RUN_PATH=$libdir $(LINKCC)";; *************** *** 1690,1694 **** case $ac_sys_system in Darwin*) ! OPT="$OPT -no-cpp-precomp";; esac fi --- 1690,1694 ---- case $ac_sys_system in Darwin*) ! OPT="$OPT -Wno-long-double -no-cpp-precomp";; esac fi From montanaro@users.sourceforge.net Tue Mar 12 19:16:21 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Tue, 12 Mar 2002 11:16:21 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib popen2.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv15544 Modified Files: popen2.py Log Message: Popen3 and Popen4 should be in __all__ Index: popen2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/popen2.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** popen2.py 24 Feb 2002 05:32:32 -0000 1.21 --- popen2.py 12 Mar 2002 19:16:19 -0000 1.22 *************** *** 11,15 **** import types ! __all__ = ["popen2", "popen3", "popen4"] MAXFD = 256 # Max number of file descriptors (os.getdtablesize()???) --- 11,15 ---- import types ! __all__ = ["popen2", "popen3", "popen4", "Popen3", "Popen4"] MAXFD = 256 # Max number of file descriptors (os.getdtablesize()???) From montanaro@users.sourceforge.net Tue Mar 12 19:48:05 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Tue, 12 Mar 2002 11:48:05 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib popen2.py,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv28717 Modified Files: popen2.py Log Message: back out spurious change from 1.22 Index: popen2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/popen2.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** popen2.py 12 Mar 2002 19:16:19 -0000 1.22 --- popen2.py 12 Mar 2002 19:48:03 -0000 1.23 *************** *** 11,15 **** import types ! __all__ = ["popen2", "popen3", "popen4", "Popen3", "Popen4"] MAXFD = 256 # Max number of file descriptors (os.getdtablesize()???) --- 11,15 ---- import types ! __all__ = ["popen2", "popen3", "popen4"] MAXFD = 256 # Max number of file descriptors (os.getdtablesize()???) From fdrake@users.sourceforge.net Tue Mar 12 19:49:34 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 12 Mar 2002 11:49:34 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libwarnings.tex,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv29441/lib Modified Files: libwarnings.tex Log Message: "level" keyword argument in example should be "stacklevel". This closes SF bug #517684. Index: libwarnings.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwarnings.tex,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** libwarnings.tex 14 Aug 2001 21:51:50 -0000 1.6 --- libwarnings.tex 12 Mar 2002 19:49:31 -0000 1.7 *************** *** 154,158 **** \begin{verbatim} def deprecation(message): ! warnings.warn(message, DeprecationWarning, level=2) \end{verbatim} --- 154,158 ---- \begin{verbatim} def deprecation(message): ! warnings.warn(message, DeprecationWarning, stacklevel=2) \end{verbatim} From fdrake@users.sourceforge.net Tue Mar 12 19:51:18 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 12 Mar 2002 11:51:18 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libwarnings.tex,1.6,1.6.16.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv30183/lib Modified Files: Tag: release22-maint libwarnings.tex Log Message: "level" keyword argument in example should be "stacklevel". This closes SF bug #517684. Index: libwarnings.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwarnings.tex,v retrieving revision 1.6 retrieving revision 1.6.16.1 diff -C2 -d -r1.6 -r1.6.16.1 *** libwarnings.tex 14 Aug 2001 21:51:50 -0000 1.6 --- libwarnings.tex 12 Mar 2002 19:51:16 -0000 1.6.16.1 *************** *** 154,158 **** \begin{verbatim} def deprecation(message): ! warnings.warn(message, DeprecationWarning, level=2) \end{verbatim} --- 154,158 ---- \begin{verbatim} def deprecation(message): ! warnings.warn(message, DeprecationWarning, stacklevel=2) \end{verbatim} From fdrake@users.sourceforge.net Tue Mar 12 19:52:01 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 12 Mar 2002 11:52:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libwarnings.tex,1.5,1.5.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv30546/lib Modified Files: Tag: release21-maint libwarnings.tex Log Message: "level" keyword argument in example should be "stacklevel". This closes SF bug #517684. Index: libwarnings.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwarnings.tex,v retrieving revision 1.5 retrieving revision 1.5.4.1 diff -C2 -d -r1.5 -r1.5.4.1 *** libwarnings.tex 28 Feb 2001 23:34:21 -0000 1.5 --- libwarnings.tex 12 Mar 2002 19:51:59 -0000 1.5.4.1 *************** *** 154,158 **** \begin{verbatim} def deprecation(message): ! warnings.warn(message, DeprecationWarning, level=2) \end{verbatim} --- 154,158 ---- \begin{verbatim} def deprecation(message): ! warnings.warn(message, DeprecationWarning, stacklevel=2) \end{verbatim} From fdrake@users.sourceforge.net Tue Mar 12 20:12:56 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 12 Mar 2002 12:12:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/api concrete.tex,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv6000 Modified Files: concrete.tex Log Message: Add a note that Py_None needs the same reference count treatment as any other PyObject *. This closes SF bug #494007. Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** concrete.tex 23 Jan 2002 10:54:41 -0000 1.8 --- concrete.tex 12 Mar 2002 20:12:54 -0000 1.9 *************** *** 75,79 **** \begin{cvardesc}{PyObject*}{Py_None} The Python \code{None} object, denoting lack of value. This object ! has no methods. \end{cvardesc} --- 75,80 ---- \begin{cvardesc}{PyObject*}{Py_None} The Python \code{None} object, denoting lack of value. This object ! has no methods. It needs to be treated just like any other object ! with respect to reference counts. \end{cvardesc} From fdrake@users.sourceforge.net Tue Mar 12 20:17:13 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 12 Mar 2002 12:17:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/api concrete.tex,1.6,1.6.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv7554 Modified Files: Tag: release22-maint concrete.tex Log Message: Add a note that Py_None needs the same reference count treatment as any other PyObject *. This closes SF bug #494007. Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.6 retrieving revision 1.6.6.1 diff -C2 -d -r1.6 -r1.6.6.1 *** concrete.tex 11 Dec 2001 19:40:16 -0000 1.6 --- concrete.tex 12 Mar 2002 20:17:11 -0000 1.6.6.1 *************** *** 75,79 **** \begin{cvardesc}{PyObject*}{Py_None} The Python \code{None} object, denoting lack of value. This object ! has no methods. \end{cvardesc} --- 75,80 ---- \begin{cvardesc}{PyObject*}{Py_None} The Python \code{None} object, denoting lack of value. This object ! has no methods. It needs to be treated just like any other object ! with respect to reference counts. \end{cvardesc} From fdrake@users.sourceforge.net Tue Mar 12 20:18:03 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 12 Mar 2002 12:18:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/api api.tex,1.117.2.11,1.117.2.12 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv7807 Modified Files: Tag: release21-maint api.tex Log Message: Add a note that Py_None needs the same reference count treatment as any other PyObject *. This closes SF bug #494007. Index: api.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/api.tex,v retrieving revision 1.117.2.11 retrieving revision 1.117.2.12 diff -C2 -d -r1.117.2.11 -r1.117.2.12 *** api.tex 6 Dec 2001 20:38:15 -0000 1.117.2.11 --- api.tex 12 Mar 2002 20:18:01 -0000 1.117.2.12 *************** *** 2175,2179 **** \begin{cvardesc}{PyObject*}{Py_None} The Python \code{None} object, denoting lack of value. This object has ! no methods. \end{cvardesc} --- 2175,2180 ---- \begin{cvardesc}{PyObject*}{Py_None} The Python \code{None} object, denoting lack of value. This object has ! no methods. It needs to be treated just like any other object with ! respect to reference counts. \end{cvardesc} From gvanrossum@users.sourceforge.net Tue Mar 12 20:37:04 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Tue, 12 Mar 2002 12:37:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects moduleobject.c,2.40,2.41 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv14407 Modified Files: moduleobject.c Log Message: Fix for SF bug #529050 - ModuleType.__new__ crash. There were several places that assumed the md_dict field was always set, but it needn't be. Fixed these to be more careful. I changed PyModule_GetDict() to initialize md_dict to a new dictionary if it's NULL. Bugfix candidate. Index: moduleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/moduleobject.c,v retrieving revision 2.40 retrieving revision 2.41 diff -C2 -d -r2.40 -r2.41 *** moduleobject.c 21 Oct 2001 22:27:35 -0000 2.40 --- moduleobject.c 12 Mar 2002 20:37:02 -0000 2.41 *************** *** 44,52 **** PyModule_GetDict(PyObject *m) { if (!PyModule_Check(m)) { PyErr_BadInternalCall(); return NULL; } ! return ((PyModuleObject *)m) -> md_dict; } --- 44,56 ---- PyModule_GetDict(PyObject *m) { + PyObject *d; if (!PyModule_Check(m)) { PyErr_BadInternalCall(); return NULL; } ! d = ((PyModuleObject *)m) -> md_dict; ! if (d == NULL) ! ((PyModuleObject *)m) -> md_dict = d = PyDict_New(); ! return d; } *************** *** 54,57 **** --- 58,62 ---- PyModule_GetName(PyObject *m) { + PyObject *d; PyObject *nameobj; if (!PyModule_Check(m)) { *************** *** 59,65 **** return NULL; } ! nameobj = PyDict_GetItemString(((PyModuleObject *)m)->md_dict, ! "__name__"); ! if (nameobj == NULL || !PyString_Check(nameobj)) { PyErr_SetString(PyExc_SystemError, "nameless module"); return NULL; --- 64,72 ---- return NULL; } ! d = ((PyModuleObject *)m)->md_dict; ! if (d == NULL || ! (nameobj = PyDict_GetItemString(d, "__name__")) == NULL || ! !PyString_Check(nameobj)) ! { PyErr_SetString(PyExc_SystemError, "nameless module"); return NULL; *************** *** 71,74 **** --- 78,82 ---- PyModule_GetFilename(PyObject *m) { + PyObject *d; PyObject *fileobj; if (!PyModule_Check(m)) { *************** *** 76,82 **** return NULL; } ! fileobj = PyDict_GetItemString(((PyModuleObject *)m)->md_dict, ! "__file__"); ! if (fileobj == NULL || !PyString_Check(fileobj)) { PyErr_SetString(PyExc_SystemError, "module filename missing"); return NULL; --- 84,92 ---- return NULL; } ! d = ((PyModuleObject *)m)->md_dict; ! if (d == NULL || ! (fileobj = PyDict_GetItemString(d, "__file__")) == NULL || ! !PyString_Check(fileobj)) ! { PyErr_SetString(PyExc_SystemError, "module filename missing"); return NULL; *************** *** 100,103 **** --- 110,115 ---- d = ((PyModuleObject *)m)->md_dict; + if (d == NULL) + return; /* First, clear only names starting with a single underscore */ From gvanrossum@users.sourceforge.net Tue Mar 12 20:43:34 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Tue, 12 Mar 2002 12:43:34 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.119,1.120 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv17549 Modified Files: test_descr.py Log Message: Test for the fix I just checked in to moduleobject.c. Bugfix candidate. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.119 retrieving revision 1.120 diff -C2 -d -r1.119 -r1.120 *** test_descr.py 11 Mar 2002 14:44:12 -0000 1.119 --- test_descr.py 12 Mar 2002 20:43:31 -0000 1.120 *************** *** 2731,2734 **** --- 2731,2745 ---- z = deepcopy(a) # This blew up before + def modules(): + if verbose: print "Testing uninitialized module objects..." + from types import ModuleType as M + m = M.__new__(M) + str(m) + vereq(hasattr(m, "__name__"), 0) + vereq(hasattr(m, "__file__"), 0) + vereq(hasattr(m, "foo"), 0) + vereq(m.__dict__, None) + m.foo = 1 + vereq(m.__dict__, {"foo": 1}) def test_main(): *************** *** 2787,2790 **** --- 2798,2802 ---- strops() deepcopyrecursive() + modules() if verbose: print "All OK" From fdrake@users.sourceforge.net Tue Mar 12 21:38:34 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 12 Mar 2002 13:38:34 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.216.4.2,2.216.4.3 timemodule.c,2.118.6.1,2.118.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv5503 Modified Files: Tag: release22-maint posixmodule.c timemodule.c Log Message: Update docstrings to use te attribute names of the new structures returned by stat and time functions. This closes SF patch #523271. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.216.4.2 retrieving revision 2.216.4.3 diff -C2 -d -r2.216.4.2 -r2.216.4.3 *** posixmodule.c 12 Jan 2002 11:13:23 -0000 2.216.4.2 --- posixmodule.c 12 Mar 2002 21:38:31 -0000 2.216.4.3 *************** *** 1301,1305 **** static char posix_stat__doc__[] = ! "stat(path) -> (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime)\n\ Perform a stat system call on the given path."; --- 1301,1306 ---- static char posix_stat__doc__[] = ! "stat(path) -> (st_mode, st_ino, st_dev, st_nlink, st_uid, st_gid,\n\ ! st_size, st_atime, st_mtime, st_ctime)\n\ Perform a stat system call on the given path."; *************** *** 3369,3373 **** static char posix_lstat__doc__[] = ! "lstat(path) -> (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime)\n\ Like stat(path), but do not follow symbolic links."; --- 3370,3375 ---- static char posix_lstat__doc__[] = ! "lstat(path) -> (st_mode, st_ino, st_dev, st_nlink, st_uid, st_gid,\n\ ! st_size, st_atime, st_mtime, st_ctime)\n\ Like stat(path), but do not follow symbolic links."; Index: timemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v retrieving revision 2.118.6.1 retrieving revision 2.118.6.2 diff -C2 -d -r2.118.6.1 -r2.118.6.2 *** timemodule.c 12 Jan 2002 11:13:24 -0000 2.118.6.1 --- timemodule.c 12 Mar 2002 21:38:31 -0000 2.118.6.2 *************** *** 286,290 **** static char gmtime_doc[] = ! "gmtime([seconds]) -> (year,month,day,hour,minute,second,weekday,dayofyear,dst)\n\ \n\ Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.\n\ --- 286,291 ---- static char gmtime_doc[] = ! "gmtime([seconds]) -> (tm_year, tm_mon, tm_day, tm_hour, tm_min,\n\ ! tm_sec, tm_wday, tm_yday, tm_isdst)\n\ \n\ Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.\n\ *************** *** 303,307 **** static char localtime_doc[] = ! "localtime([seconds]) -> (year,month,day,hour,minute,second,weekday,dayofyear,dst)\n\ \n\ Convert seconds since the Epoch to a time tuple expressing local time.\n\ --- 304,308 ---- static char localtime_doc[] = ! "localtime([seconds]) -> (tm_year,tm_mon,tm_day,tm_hour,tm_min,tm_sec,tm_wday,tm_yday,tm_isdst)\n\ \n\ Convert seconds since the Epoch to a time tuple expressing local time.\n\ From fdrake@users.sourceforge.net Tue Mar 12 21:38:51 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 12 Mar 2002 13:38:51 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.224,2.225 timemodule.c,2.123,2.124 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv5586 Modified Files: posixmodule.c timemodule.c Log Message: Update docstrings to use te attribute names of the new structures returned by stat and time functions. This closes SF patch #523271. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.224 retrieving revision 2.225 diff -C2 -d -r2.224 -r2.225 *** posixmodule.c 3 Mar 2002 23:17:02 -0000 2.224 --- posixmodule.c 12 Mar 2002 21:38:49 -0000 2.225 *************** *** 1316,1320 **** static char posix_stat__doc__[] = ! "stat(path) -> (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime)\n\ Perform a stat system call on the given path."; --- 1316,1321 ---- static char posix_stat__doc__[] = ! "stat(path) -> (st_mode, st_ino, st_dev, st_nlink, st_uid, st_gid,\n\ ! st_size, st_atime, st_mtime, st_ctime)\n\ Perform a stat system call on the given path."; *************** *** 4057,4061 **** static char posix_lstat__doc__[] = ! "lstat(path) -> (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime)\n\ Like stat(path), but do not follow symbolic links."; --- 4058,4063 ---- static char posix_lstat__doc__[] = ! "lstat(path) -> (st_mode, st_ino, st_dev, st_nlink, st_uid, st_gid,\n\ ! st_size, st_atime, st_mtime, st_ctime)\n\ Like stat(path), but do not follow symbolic links."; Index: timemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v retrieving revision 2.123 retrieving revision 2.124 diff -C2 -d -r2.123 -r2.124 *** timemodule.c 3 Mar 2002 02:59:16 -0000 2.123 --- timemodule.c 12 Mar 2002 21:38:49 -0000 2.124 *************** *** 286,290 **** static char gmtime_doc[] = ! "gmtime([seconds]) -> (year,month,day,hour,minute,second,weekday,dayofyear,dst)\n\ \n\ Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.\n\ --- 286,291 ---- static char gmtime_doc[] = ! "gmtime([seconds]) -> (tm_year, tm_mon, tm_day, tm_hour, tm_min,\n\ ! tm_sec, tm_wday, tm_yday, tm_isdst)\n\ \n\ Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.\n\ *************** *** 303,307 **** static char localtime_doc[] = ! "localtime([seconds]) -> (year,month,day,hour,minute,second,weekday,dayofyear,dst)\n\ \n\ Convert seconds since the Epoch to a time tuple expressing local time.\n\ --- 304,308 ---- static char localtime_doc[] = ! "localtime([seconds]) -> (tm_year,tm_mon,tm_day,tm_hour,tm_min,tm_sec,tm_wday,tm_yday,tm_isdst)\n\ \n\ Convert seconds since the Epoch to a time tuple expressing local time.\n\ From fdrake@users.sourceforge.net Tue Mar 12 21:49:46 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 12 Mar 2002 13:49:46 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules xxmodule.c,2.25,2.26 xxsubtype.c,2.12,2.13 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv8771 Modified Files: xxmodule.c xxsubtype.c Log Message: Change the example code to prefer PyModule_Add*() instead of using the module dictionary directly. Also, be more careful about not re-initializing globals in the event of re-initialization of a C extension. Index: xxmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/xxmodule.c,v retrieving revision 2.25 retrieving revision 2.26 diff -C2 -d -r2.25 -r2.26 *** xxmodule.c 8 Dec 2001 18:02:58 -0000 2.25 --- xxmodule.c 12 Mar 2002 21:49:44 -0000 2.26 *************** *** 232,237 **** /* Add some symbolic constants to the module */ ! d = PyModule_GetDict(m); ! ErrorObject = PyErr_NewException("xx.error", NULL, NULL); ! PyDict_SetItemString(d, "error", ErrorObject); } --- 232,241 ---- /* Add some symbolic constants to the module */ ! if (ErrorObject == NULL) { ! ErrorObject = PyErr_NewException("xx.error", NULL, NULL); ! if (ErrorObject == NULL) ! return; ! } ! Py_INCREF(ErrorObject); ! PyModule_AddObject(d, "error", ErrorObject); } Index: xxsubtype.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/xxsubtype.c,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -d -r2.12 -r2.13 *** xxsubtype.c 17 Dec 2001 18:26:19 -0000 2.12 --- xxsubtype.c 12 Mar 2002 21:49:44 -0000 2.13 *************** *** 239,243 **** initxxsubtype(void) { ! PyObject *m, *d; /* Fill in deferred data addresses. This must be done before --- 239,243 ---- initxxsubtype(void) { ! PyObject *m; /* Fill in deferred data addresses. This must be done before *************** *** 264,279 **** return; - d = PyModule_GetDict(m); - if (d == NULL) - return; - Py_INCREF(&spamlist_type); ! if (PyDict_SetItemString(d, "spamlist", ! (PyObject *) &spamlist_type) < 0) return; Py_INCREF(&spamdict_type); ! if (PyDict_SetItemString(d, "spamdict", ! (PyObject *) &spamdict_type) < 0) return; } --- 264,275 ---- return; Py_INCREF(&spamlist_type); ! if (PyModule_AddObject(m, "spamlist", ! (PyObject *) &spamlist_type) < 0) return; Py_INCREF(&spamdict_type); ! if (PyModule_AddObject(m, "spamdict", ! (PyObject *) &spamdict_type) < 0) return; } From loewis@users.sourceforge.net Tue Mar 12 22:05:04 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Tue, 12 Mar 2002 14:05:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _localemodule.c,2.25,2.26 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv13806 Modified Files: _localemodule.c Log Message: Verify arguments for nl_langinfo. Fixes #528879. Index: _localemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v retrieving revision 2.25 retrieving revision 2.26 diff -C2 -d -r2.25 -r2.26 *** _localemodule.c 28 Nov 2001 20:27:42 -0000 2.25 --- _localemodule.c 12 Mar 2002 22:05:02 -0000 2.26 *************** *** 1,4 **** /*********************************************************** ! Copyright (C) 1997 Martin von Loewis Permission to use, copy, modify, and distribute this software and its --- 1,4 ---- /*********************************************************** ! Copyright (C) 1997, 2002 Martin von Loewis Permission to use, copy, modify, and distribute this software and its *************** *** 416,419 **** --- 416,507 ---- #ifdef HAVE_LANGINFO_H + #define LANGINFO(X) {#X, X} + struct langinfo_constant{ + char* name; + int value; + } langinfo_constants[] = + { + /* These constants should exist on any langinfo implementation */ + LANGINFO(DAY_1), + LANGINFO(DAY_2), + LANGINFO(DAY_3), + LANGINFO(DAY_4), + LANGINFO(DAY_5), + LANGINFO(DAY_6), + LANGINFO(DAY_7), + + LANGINFO(ABDAY_1), + LANGINFO(ABDAY_2), + LANGINFO(ABDAY_3), + LANGINFO(ABDAY_4), + LANGINFO(ABDAY_5), + LANGINFO(ABDAY_6), + LANGINFO(ABDAY_7), + + LANGINFO(MON_1), + LANGINFO(MON_2), + LANGINFO(MON_3), + LANGINFO(MON_4), + LANGINFO(MON_5), + LANGINFO(MON_6), + LANGINFO(MON_7), + LANGINFO(MON_8), + LANGINFO(MON_9), + LANGINFO(MON_10), + LANGINFO(MON_11), + LANGINFO(MON_12), + + LANGINFO(ABMON_1), + LANGINFO(ABMON_2), + LANGINFO(ABMON_3), + LANGINFO(ABMON_4), + LANGINFO(ABMON_5), + LANGINFO(ABMON_6), + LANGINFO(ABMON_7), + LANGINFO(ABMON_8), + LANGINFO(ABMON_9), + LANGINFO(ABMON_10), + LANGINFO(ABMON_11), + LANGINFO(ABMON_12), + + #ifdef RADIXCHAR + /* The following are not available with glibc 2.0 */ + LANGINFO(RADIXCHAR), + LANGINFO(THOUSEP), + /* YESSTR and NOSTR are deprecated in glibc, since they are + a special case of message translation, which should be rather + done using gettext. So we don't expose it to Python in the + first place. + LANGINFO(YESSTR), + LANGINFO(NOSTR), + */ + LANGINFO(CRNCYSTR), + #endif + + LANGINFO(D_T_FMT), + LANGINFO(D_FMT), + LANGINFO(T_FMT), + LANGINFO(AM_STR), + LANGINFO(PM_STR), + + #ifdef CODESET + /* The following constants are available only with XPG4. */ + LANGINFO(CODESET), + LANGINFO(T_FMT_AMPM), + LANGINFO(ERA), + LANGINFO(ERA_D_FMT), + LANGINFO(ERA_D_T_FMT), + LANGINFO(ERA_T_FMT), + LANGINFO(ALT_DIGITS), + LANGINFO(YESEXPR), + LANGINFO(NOEXPR), + #endif + #ifdef _DATE_FMT + /* This is not available in all glibc versions that have CODESET. */ + LANGINFO(_DATE_FMT), + #endif + {0, 0} + }; + static char nl_langinfo__doc__[] = "nl_langinfo(key) -> string\n" *************** *** 424,433 **** PyLocale_nl_langinfo(PyObject* self, PyObject* args) { ! int item; if (!PyArg_ParseTuple(args, "i:nl_langinfo", &item)) return NULL; ! return PyString_FromString(nl_langinfo(item)); } ! #endif --- 512,528 ---- PyLocale_nl_langinfo(PyObject* self, PyObject* args) { ! int item, i; if (!PyArg_ParseTuple(args, "i:nl_langinfo", &item)) return NULL; ! /* Check whether this is a supported constant. GNU libc sometimes ! returns numeric values in the char* return value, which would ! crash PyString_FromString. */ ! for (i = 0; langinfo_constants[i].name; i++) ! if (langinfo_constants[i].value == item) ! return PyString_FromString(nl_langinfo(item)); ! PyErr_SetString(PyExc_ValueError, "unsupported langinfo constant"); ! return NULL; } ! #endif /* HAVE_LANGINFO_H */ *************** *** 456,459 **** --- 551,557 ---- { PyObject *m, *d, *x; + #ifdef HAVE_LANGINFO_H + int i; + #endif m = Py_InitModule("_locale", PyLocale_Methods); *************** *** 502,586 **** Py_XDECREF(x); - #define ADDINT(X) PyModule_AddIntConstant(m, #X, X) #ifdef HAVE_LANGINFO_H ! /* These constants should exist on any langinfo implementation */ ! ADDINT(DAY_1); ! ADDINT(DAY_2); ! ADDINT(DAY_3); ! ADDINT(DAY_4); ! ADDINT(DAY_5); ! ADDINT(DAY_6); ! ADDINT(DAY_7); ! ! ADDINT(ABDAY_1); ! ADDINT(ABDAY_2); ! ADDINT(ABDAY_3); ! ADDINT(ABDAY_4); ! ADDINT(ABDAY_5); ! ADDINT(ABDAY_6); ! ADDINT(ABDAY_7); ! ! ADDINT(MON_1); ! ADDINT(MON_2); ! ADDINT(MON_3); ! ADDINT(MON_4); ! ADDINT(MON_5); ! ADDINT(MON_6); ! ADDINT(MON_7); ! ADDINT(MON_8); ! ADDINT(MON_9); ! ADDINT(MON_10); ! ADDINT(MON_11); ! ADDINT(MON_12); ! ! ADDINT(ABMON_1); ! ADDINT(ABMON_2); ! ADDINT(ABMON_3); ! ADDINT(ABMON_4); ! ADDINT(ABMON_5); ! ADDINT(ABMON_6); ! ADDINT(ABMON_7); ! ADDINT(ABMON_8); ! ADDINT(ABMON_9); ! ADDINT(ABMON_10); ! ADDINT(ABMON_11); ! ADDINT(ABMON_12); ! ! #ifdef RADIXCHAR ! /* The following are not available with glibc 2.0 */ ! ADDINT(RADIXCHAR); ! ADDINT(THOUSEP); ! /* YESSTR and NOSTR are deprecated in glibc, since they are ! a special case of message translation, which should be rather ! done using gettext. So we don't expose it to Python in the ! first place. ! ADDINT(YESSTR); ! ADDINT(NOSTR); ! */ ! ADDINT(CRNCYSTR); ! #endif ! ! ADDINT(D_T_FMT); ! ADDINT(D_FMT); ! ADDINT(T_FMT); ! ADDINT(AM_STR); ! ADDINT(PM_STR); ! ! #ifdef CODESET ! /* The following constants are available only with XPG4. */ ! ADDINT(CODESET); ! ADDINT(T_FMT_AMPM); ! ADDINT(ERA); ! ADDINT(ERA_D_FMT); ! ADDINT(ERA_D_T_FMT); ! ADDINT(ERA_T_FMT); ! ADDINT(ALT_DIGITS); ! ADDINT(YESEXPR); ! ADDINT(NOEXPR); ! #endif ! #ifdef _DATE_FMT ! /* This is not available in all glibc versions that have CODESET. */ ! ADDINT(_DATE_FMT); #endif - #endif /* HAVE_LANGINFO_H */ } --- 600,608 ---- Py_XDECREF(x); #ifdef HAVE_LANGINFO_H ! for (i = 0; langinfo_constants[i].name; i++) { ! PyModule_AddIntConstant(m, langinfo_constants[i].name, ! langinfo_constants[i].value); ! } #endif } From tim_one@users.sourceforge.net Tue Mar 12 22:33:53 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Tue, 12 Mar 2002 14:33:53 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.c,1.6,1.7 datetime.h,1.3,1.4 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv23342 Modified Files: datetime.c datetime.h Log Message: Changes to get this to compile on Windows. The test passes -- yippee! Index: datetime.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** datetime.c 6 Mar 2002 05:53:34 -0000 1.6 --- datetime.c 12 Mar 2002 22:33:51 -0000 1.7 *************** *** 32,35 **** --- 32,37 ---- ((o)->data[9] = ((v) & 0x0000ff))) + staticforward PyTypeObject PyDateTime_Type; + /* * General calendrical helper functions *************** *** 343,348 **** ! PyTypeObject PyDateTime_Type = { ! PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ "datetime.datetime", /* tp_name */ --- 345,350 ---- ! statichere PyTypeObject PyDateTime_Type = { ! PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "datetime.datetime", /* tp_name */ *************** *** 399,402 **** --- 401,406 ---- PyObject *m; PyObject *d, *dt; + + PyDateTime_Type.ob_type = &PyType_Type; if (PyType_Ready(&PyDateTime_Type) < 0) Index: datetime.h =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** datetime.h 6 Mar 2002 04:05:59 -0000 1.3 --- datetime.h 12 Mar 2002 22:33:51 -0000 1.4 *************** *** 14,20 **** - extern DL_IMPORT(PyTypeObject) PyDateTime_Type; - - #define PyDateTime_GET_YEAR(o) (((PyDateTime_Object*)o)->data[0] << 8 \ | ((PyDateTime_Object*)o)->data[1]) --- 14,17 ---- From fdrake@users.sourceforge.net Wed Mar 13 02:44:52 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 12 Mar 2002 18:44:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/perl python.perl,1.117,1.118 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/perl In directory usw-pr-cvs1:/tmp/cvs-serv3336/perl Modified Files: python.perl Log Message: Change the way \textasciitilde is implemented so it works more consistently (dropping tildes into data that still goes through LaTeX-like processing is a bad idea). Index: python.perl =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/perl/python.perl,v retrieving revision 1.117 retrieving revision 1.118 diff -C2 -d -r1.117 -r1.118 *** python.perl 5 Mar 2002 04:04:06 -0000 1.117 --- python.perl 13 Mar 2002 02:44:50 -0000 1.118 *************** *** 86,90 **** # the older version of LaTeX2HTML we use doesn't support this, but we use it: ! sub do_cmd_textasciitilde{ '~' . @_[0]; } sub do_cmd_textasciicircum{ '^' . @_[0]; } sub do_cmd_textbar{ '|' . @_[0]; } --- 86,90 ---- # the older version of LaTeX2HTML we use doesn't support this, but we use it: ! sub do_cmd_textasciitilde{ '~' . @_[0]; } sub do_cmd_textasciicircum{ '^' . @_[0]; } sub do_cmd_textbar{ '|' . @_[0]; } From fdrake@users.sourceforge.net Wed Mar 13 02:46:00 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 12 Mar 2002 18:46:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/perl python.perl,1.116,1.116.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/perl In directory usw-pr-cvs1:/tmp/cvs-serv3669/perl Modified Files: Tag: release22-maint python.perl Log Message: Change the way \textasciitilde is implemented so it works more consistently (dropping tildes into data that still goes through LaTeX-like processing is a bad idea). Index: python.perl =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/perl/python.perl,v retrieving revision 1.116 retrieving revision 1.116.4.1 diff -C2 -d -r1.116 -r1.116.4.1 *** python.perl 14 Dec 2001 22:50:05 -0000 1.116 --- python.perl 13 Mar 2002 02:45:58 -0000 1.116.4.1 *************** *** 86,90 **** # the older version of LaTeX2HTML we use doesn't support this, but we use it: ! sub do_cmd_textasciitilde{ '~' . @_[0]; } sub do_cmd_textasciicircum{ '^' . @_[0]; } sub do_cmd_textbar{ '|' . @_[0]; } --- 86,90 ---- # the older version of LaTeX2HTML we use doesn't support this, but we use it: ! sub do_cmd_textasciitilde{ '~' . @_[0]; } sub do_cmd_textasciicircum{ '^' . @_[0]; } sub do_cmd_textbar{ '|' . @_[0]; } From fdrake@users.sourceforge.net Wed Mar 13 02:46:19 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 12 Mar 2002 18:46:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/perl python.perl,1.98.2.3,1.98.2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/perl In directory usw-pr-cvs1:/tmp/cvs-serv3805/perl Modified Files: Tag: release21-maint python.perl Log Message: Change the way \textasciitilde is implemented so it works more consistently (dropping tildes into data that still goes through LaTeX-like processing is a bad idea). Index: python.perl =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/perl/python.perl,v retrieving revision 1.98.2.3 retrieving revision 1.98.2.4 diff -C2 -d -r1.98.2.3 -r1.98.2.4 *** python.perl 22 Jun 2001 15:51:28 -0000 1.98.2.3 --- python.perl 13 Mar 2002 02:46:17 -0000 1.98.2.4 *************** *** 86,90 **** # the older version of LaTeX2HTML we use doesn't support this, but we use it: ! sub do_cmd_textasciitilde{ '~' . @_[0]; } sub do_cmd_textasciicircum{ '^' . @_[0]; } --- 86,90 ---- # the older version of LaTeX2HTML we use doesn't support this, but we use it: ! sub do_cmd_textasciitilde{ '~' . @_[0]; } sub do_cmd_textasciicircum{ '^' . @_[0]; } From fdrake@users.sourceforge.net Wed Mar 13 02:48:26 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 12 Mar 2002 18:48:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/doc doc.tex,1.59,1.60 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/doc In directory usw-pr-cvs1:/tmp/cvs-serv4324/doc Modified Files: doc.tex Log Message: Extend the list of special characters and magic markup used to produce them to include various characters used in code samples, URLs, and other special contexts. This closes SF bug #525684. Index: doc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/doc/doc.tex,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** doc.tex 17 Jan 2002 12:35:20 -0000 1.59 --- doc.tex 13 Mar 2002 02:48:24 -0000 1.60 *************** *** 392,403 **** There are a number of less-used marks in \LaTeX{} which are used ! to enter non-\ASCII{} characters, especially those used in ! European names. Given that these are often used adjacent to other ! characters, the markup required to produce the proper character ! may need to be followed by a space or an empty group, or the ! markup can be enclosed in a group. Some which are found in Python ! documentation are: \begin{tableii}{c|l}{textrm}{Character}{Markup} \lineii{\c c}{\code{\e c c}} \lineii{\"o}{\code{\e"o}} --- 392,407 ---- There are a number of less-used marks in \LaTeX{} which are used ! to enter characters which are not found in \ASCII{} or which a ! considered special, or \emph{active} in \TeX{} or \LaTeX. Given ! that these are often used adjacent to other characters, the markup ! required to produce the proper character may need to be followed ! by a space or an empty group, or the markup can be enclosed in a ! group. Some which are found in Python documentation are: \begin{tableii}{c|l}{textrm}{Character}{Markup} + \lineii{\textasciicircum}{\code{\e textasciicircum}} + \lineii{\textasciitilde}{\code{\e textasciitilde}} + \lineii{\textgreater}{\code{\e textgreater}} + \lineii{\textless}{\code{\e textless}} \lineii{\c c}{\code{\e c c}} \lineii{\"o}{\code{\e"o}} From nnorwitz@users.sourceforge.net Wed Mar 13 03:14:28 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Tue, 12 Mar 2002 19:14:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib inspect.py,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv11624/Lib Modified Files: inspect.py Log Message: SF #515015, raise exception if code not found in findsource() Index: inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** inspect.py 15 Oct 2001 22:03:31 -0000 1.26 --- inspect.py 13 Mar 2002 03:14:26 -0000 1.27 *************** *** 407,410 **** --- 407,411 ---- lnum = lnum - 1 return lines, lnum + raise IOError, 'could not find code object' def getcomments(object): From nnorwitz@users.sourceforge.net Wed Mar 13 03:19:20 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Tue, 12 Mar 2002 19:19:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib inspect.py,1.26,1.26.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv12816 Modified Files: Tag: release22-maint inspect.py Log Message: SF #515015, raise exception if code not found in findsource() Index: inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v retrieving revision 1.26 retrieving revision 1.26.10.1 diff -C2 -d -r1.26 -r1.26.10.1 *** inspect.py 15 Oct 2001 22:03:31 -0000 1.26 --- inspect.py 13 Mar 2002 03:19:18 -0000 1.26.10.1 *************** *** 407,410 **** --- 407,411 ---- lnum = lnum - 1 return lines, lnum + raise IOError, 'could not find code object' def getcomments(object): From fdrake@users.sourceforge.net Wed Mar 13 03:55:13 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 12 Mar 2002 19:55:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ext newtypes.tex,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory usw-pr-cvs1:/tmp/cvs-serv21495/ext Modified Files: newtypes.tex Log Message: Describe how to support the iterator protocol in extension types. This closes SF bug #420851. Index: newtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/newtypes.tex,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** newtypes.tex 16 Jan 2002 14:55:05 -0000 1.7 --- newtypes.tex 13 Mar 2002 03:55:11 -0000 1.8 *************** *** 714,721 **** \subsection{Abstract Protocol Support} \begin{verbatim} ! tp_as_number; ! tp_as_sequence; ! tp_as_mapping; \end{verbatim} --- 714,737 ---- \subsection{Abstract Protocol Support} + Python supports a variety of \emph{abstract} `protocols;' the specific + interfaces provided to use these interfaces are documented in the + \citetitle[../api/api.html]{Python/C API Reference Manual} in the + chapter ``\ulink{Abstract Objects Layer}{../api/abstract.html}.'' + + A number of these abstract interfaces were defined early in the + development of the Python implementation. In particular, the number, + mapping, and sequence protocols have been part of Python since the + beginning. Other protocols have been added over time. For protocols + which depend on several handler routines from the type implementation, + the older protocols have been defined as optional blocks of handlers + referenced by the type object, while newer protocols have been added + using additional slots in the main type object, with a flag bit being + set to indicate that the slots are present. (The flag bit does not + indicate that the slot values are non-\NULL.) + \begin{verbatim} ! PyNumberMethods tp_as_number; ! PySequenceMethods tp_as_sequence; ! PyMappingMethods tp_as_mapping; \end{verbatim} *************** *** 778,782 **** \end{enumerate} ! Here is a desultory example of the implementation of call function. \begin{verbatim} --- 794,798 ---- \end{enumerate} ! Here is a desultory example of the implementation of the call function. \begin{verbatim} *************** *** 805,808 **** --- 821,864 ---- } \end{verbatim} + + XXX some fields need to be added here... + + + \begin{verbatim} + /* Added in release 2.2 */ + /* Iterators */ + getiterfunc tp_iter; + iternextfunc tp_iternext; + \end{verbatim} + + These functions provide support for the iterator protocol. Any object + which wishes to support iteration over it's contents (which may be + generated during iteration) must implement the \code{tp_iter} + handler. Objects which are returned by a \code{tp_iter} handler must + implement both the \code{tp_iter} and \code{tp_iternext} handlers. + Both handlers take exactly one parameter, the instance for which they + are being called, and return a new reference. In the case of an + error, they should set an exception and return \NULL. + + For an object which represents an iterable collection, the + \code{tp_iter} handler must return an iterator object. The iterator + object is responsible for maintaining the state of the iteration. For + collections which can support multiple iterators which do not + interfere with each other (as lists and tuples do), a new iterator + should be created and returned. Objects which can only be iterated + over once (usually due to side effects of iteration) should implement + this handler by returning a new reference to themselves, and should + also implement the \code{tp_iternext} handler. File objects are an + example of such an iterator. + + Iterator objects should implement both handlers. The \code{tp_iter} + handler should return a new reference to the iterator (this is the + same as the \code{tp_iter} handler for objects which can only be + iterated over destructively). The \code{tp_iternext} handler should + return a new reference to the next object in the iteration if there is + one. If the iteration has reached the end, it may return \NULL{} + without setting an exception or it may set \exception{StopIteration}; + avoiding the exception can yield slightly better performance. If an + actual error occurs, it should set an exception and return \NULL. From fdrake@users.sourceforge.net Wed Mar 13 03:56:56 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 12 Mar 2002 19:56:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ext newtypes.tex,1.6.6.1,1.6.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory usw-pr-cvs1:/tmp/cvs-serv21902/ext Modified Files: Tag: release22-maint newtypes.tex Log Message: Describe how to support the iterator protocol in extension types. This closes SF bug #420851. Index: newtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/newtypes.tex,v retrieving revision 1.6.6.1 retrieving revision 1.6.6.2 diff -C2 -d -r1.6.6.1 -r1.6.6.2 *** newtypes.tex 17 Jan 2002 06:15:25 -0000 1.6.6.1 --- newtypes.tex 13 Mar 2002 03:56:54 -0000 1.6.6.2 *************** *** 714,721 **** \subsection{Abstract Protocol Support} \begin{verbatim} ! tp_as_number; ! tp_as_sequence; ! tp_as_mapping; \end{verbatim} --- 714,737 ---- \subsection{Abstract Protocol Support} + Python supports a variety of \emph{abstract} `protocols;' the specific + interfaces provided to use these interfaces are documented in the + \citetitle[../api/api.html]{Python/C API Reference Manual} in the + chapter ``\ulink{Abstract Objects Layer}{../api/abstract.html}.'' + + A number of these abstract interfaces were defined early in the + development of the Python implementation. In particular, the number, + mapping, and sequence protocols have been part of Python since the + beginning. Other protocols have been added over time. For protocols + which depend on several handler routines from the type implementation, + the older protocols have been defined as optional blocks of handlers + referenced by the type object, while newer protocols have been added + using additional slots in the main type object, with a flag bit being + set to indicate that the slots are present. (The flag bit does not + indicate that the slot values are non-\NULL.) + \begin{verbatim} ! PyNumberMethods tp_as_number; ! PySequenceMethods tp_as_sequence; ! PyMappingMethods tp_as_mapping; \end{verbatim} *************** *** 778,782 **** \end{enumerate} ! Here is a desultory example of the implementation of call function. \begin{verbatim} --- 794,798 ---- \end{enumerate} ! Here is a desultory example of the implementation of the call function. \begin{verbatim} *************** *** 805,808 **** --- 821,864 ---- } \end{verbatim} + + XXX some fields need to be added here... + + + \begin{verbatim} + /* Added in release 2.2 */ + /* Iterators */ + getiterfunc tp_iter; + iternextfunc tp_iternext; + \end{verbatim} + + These functions provide support for the iterator protocol. Any object + which wishes to support iteration over it's contents (which may be + generated during iteration) must implement the \code{tp_iter} + handler. Objects which are returned by a \code{tp_iter} handler must + implement both the \code{tp_iter} and \code{tp_iternext} handlers. + Both handlers take exactly one parameter, the instance for which they + are being called, and return a new reference. In the case of an + error, they should set an exception and return \NULL. + + For an object which represents an iterable collection, the + \code{tp_iter} handler must return an iterator object. The iterator + object is responsible for maintaining the state of the iteration. For + collections which can support multiple iterators which do not + interfere with each other (as lists and tuples do), a new iterator + should be created and returned. Objects which can only be iterated + over once (usually due to side effects of iteration) should implement + this handler by returning a new reference to themselves, and should + also implement the \code{tp_iternext} handler. File objects are an + example of such an iterator. + + Iterator objects should implement both handlers. The \code{tp_iter} + handler should return a new reference to the iterator (this is the + same as the \code{tp_iter} handler for objects which can only be + iterated over destructively). The \code{tp_iternext} handler should + return a new reference to the next object in the iteration if there is + one. If the iteration has reached the end, it may return \NULL{} + without setting an exception or it may set \exception{StopIteration}; + avoiding the exception can yield slightly better performance. If an + actual error occurs, it should set an exception and return \NULL. From fdrake@users.sourceforge.net Wed Mar 13 05:47:28 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 12 Mar 2002 21:47:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib weakref.py,1.8,1.8.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv10910 Modified Files: Tag: release21-maint weakref.py Log Message: Fix SF bug #529273: WeakValueDictionary.setdefault() raised UnboundLocalError since it used the name of a global function as the name of a local. The patch is almost identical to that submitted with the bug report. Index: weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/weakref.py,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -C2 -d -r1.8 -r1.8.2.1 *** weakref.py 16 Apr 2001 17:34:48 -0000 1.8 --- weakref.py 13 Mar 2002 05:47:26 -0000 1.8.2.1 *************** *** 85,97 **** def setdefault(self, key, default): try: ! ref = self.data[key] except KeyError: def remove(o, data=self.data, key=key): del data[key] ! ref = ref(default, remove) ! self.data[key] = ref return default else: ! return ref() def update(self, dict): --- 85,96 ---- def setdefault(self, key, default): try: ! wr = self.data[key] except KeyError: def remove(o, data=self.data, key=key): del data[key] ! self.data[key] = ref(default, remove) return default else: ! return wr() def update(self, dict): From fdrake@users.sourceforge.net Wed Mar 13 05:49:08 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 12 Mar 2002 21:49:08 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_weakref.py,1.7,1.7.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv11141/test Modified Files: Tag: release21-maint test_weakref.py Log Message: Add a test that was added in Python 2.2: test Weak*Dictionary.setdefault(). The purpose is to avoid regression on SF bug #529273. This test is stronger than the one submitted with the bug report. Index: test_weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -C2 -d -r1.7 -r1.7.2.1 *** test_weakref.py 16 Apr 2001 17:37:27 -0000 1.7 --- test_weakref.py 13 Mar 2002 05:49:06 -0000 1.7.2.1 *************** *** 281,284 **** --- 281,309 ---- "deleting the keys did not clear the dictionary") + def check_setdefault(self, klass, key, value1, value2): + self.assert_(value1 is not value2, + "invalid test" + " -- value parameters must be distinct objects") + weakdict = klass() + o = weakdict.setdefault(key, value1) + self.assert_(o is value1) + self.assert_(weakdict.has_key(key)) + self.assert_(weakdict.get(key) is value1) + self.assert_(weakdict[key] is value1) + + o = weakdict.setdefault(key, value2) + self.assert_(o is value1) + self.assert_(weakdict.has_key(key)) + self.assert_(weakdict.get(key) is value1) + self.assert_(weakdict[key] is value1) + + def test_weak_valued_dict_setdefault(self): + self.check_setdefault(weakref.WeakValueDictionary, + "key", C(), C()) + + def test_weak_keyed_dict_setdefault(self): + self.check_setdefault(weakref.WeakKeyDictionary, + C(), "value 1", "value 2") + def check_update(self, klass, dict): weakdict = klass() From tim_one@users.sourceforge.net Wed Mar 13 21:51:58 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Wed, 13 Mar 2002 13:51:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild readme.txt,1.22,1.23 zlib.dsp,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv29528/python/dist/src/PCbuild Modified Files: readme.txt zlib.dsp Log Message: Move to zlib 1.1.4 on Windows (the new version that squashes the "double free" glitch). Bugfix candidate -- I'll backpatch this into 2.2.1 later this week. Index: readme.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/readme.txt,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** readme.txt 13 Feb 2002 23:56:46 -0000 1.22 --- readme.txt 13 Mar 2002 21:51:55 -0000 1.23 *************** *** 78,92 **** zlib - NOTE: This procedure is new (& simpler, & safer) for 2.1a2. Python wrapper for the zlib compression library. Get the source code ! for version 1.1.3 from a convenient mirror at: ! http://www.info-zip.org/pub/infozip/zlib/ ! Unpack into dist\zlib-1.1.3. A custom pre-link step in the zlib project settings should manage to ! build zlib-1.1.3\zlib.lib by magic before zlib.pyd (or zlib_d.pyd) is linked in PCbuild\. However, the zlib project is not smart enough to remove anything under ! zlib-1.1.3\ when you do a clean, so if you want to rebuild zlib.lib ! you need to clean up zlib-1.1.3\ by hand. bsddb --- 78,91 ---- zlib Python wrapper for the zlib compression library. Get the source code ! for version 1.1.4 from a convenient mirror at: ! http://www.gzip.org/zlib/ ! Unpack into dist\zlib-1.1.4. A custom pre-link step in the zlib project settings should manage to ! build zlib-1.1.4\zlib.lib by magic before zlib.pyd (or zlib_d.pyd) is linked in PCbuild\. However, the zlib project is not smart enough to remove anything under ! zlib-1.1.4\ when you do a clean, so if you want to rebuild zlib.lib ! you need to clean up zlib-1.1.4\ by hand. bsddb Index: zlib.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/zlib.dsp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** zlib.dsp 31 Jan 2001 10:28:03 -0000 1.15 --- zlib.dsp 13 Mar 2002 21:51:55 -0000 1.16 *************** *** 45,49 **** F90=df.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "..\..\zlib-1.1.3" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 --- 45,49 ---- F90=df.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "..\..\zlib-1.1.4" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 *************** *** 55,64 **** LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 ! # ADD LINK32 ..\..\zlib-1.1.3\zlib.lib /nologo /base:"0x1e1B0000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./zlib.pyd" /export:initzlib # SUBTRACT LINK32 /pdb:none # Begin Special Build Tool SOURCE="$(InputPath)" PreLink_Desc=Checking static zlib has been built ! PreLink_Cmds=cd ..\..\zlib-1.1.3 nmake -nologo -f msdos\makefile.w32 zlib.lib # End Special Build Tool --- 55,64 ---- LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 ! # ADD LINK32 ..\..\zlib-1.1.4\zlib.lib /nologo /base:"0x1e1B0000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./zlib.pyd" /export:initzlib # SUBTRACT LINK32 /pdb:none # Begin Special Build Tool SOURCE="$(InputPath)" PreLink_Desc=Checking static zlib has been built ! PreLink_Cmds=cd ..\..\zlib-1.1.4 nmake -nologo -f msdos\makefile.w32 zlib.lib # End Special Build Tool *************** *** 78,82 **** F90=df.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "..\..\zlib-1.1.3" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 --- 78,82 ---- F90=df.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "..\..\zlib-1.1.4" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 *************** *** 88,97 **** LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept ! # ADD LINK32 ..\..\zlib-1.1.3\zlib.lib /nologo /base:"0x1e1B0000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./zlib_d.pyd" /pdbtype:sept /export:initzlib # SUBTRACT LINK32 /pdb:none # Begin Special Build Tool SOURCE="$(InputPath)" PreLink_Desc=Checking static zlib has been built ! PreLink_Cmds=cd ..\..\zlib-1.1.3 nmake -nologo -f msdos\makefile.w32 zlib.lib # End Special Build Tool --- 88,97 ---- LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept ! # ADD LINK32 ..\..\zlib-1.1.4\zlib.lib /nologo /base:"0x1e1B0000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./zlib_d.pyd" /pdbtype:sept /export:initzlib # SUBTRACT LINK32 /pdb:none # Begin Special Build Tool SOURCE="$(InputPath)" PreLink_Desc=Checking static zlib has been built ! PreLink_Cmds=cd ..\..\zlib-1.1.4 nmake -nologo -f msdos\makefile.w32 zlib.lib # End Special Build Tool From jackjansen@users.sourceforge.net Wed Mar 13 22:50:57 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Wed, 13 Mar 2002 14:50:57 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0278.txt,1.2,1.3 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv14018 Modified Files: pep-0278.txt Log Message: - --with-universal-newlines is now the default - U is the mode character that signal universal newlines in open in stead of t. - Clarified why output isn't handled. - Clarified various questions on unicode, exec, locks, etc. Index: pep-0278.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0278.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pep-0278.txt 5 Feb 2002 23:50:38 -0000 1.2 --- pep-0278.txt 13 Mar 2002 22:50:54 -0000 1.3 *************** *** 31,44 **** Specification ! Universal newline support needs to be enabled during the configure ! of Python. In a Python with universal newline support the feature is ! automatically enabled for all import statements and source() ! calls. In a Python with universal newline support open() the mode ! parameter can also be "t", meaning "open for input as a text file ! with universal newline interpretation". Mode "t" cannot be combined with other mode flags such as "+". Any line ending in the input file will be seen as a '\n' in Python, so little other code has --- 31,45 ---- Specification ! Universal newline support needs to be enabled by default, ! but can be disabled during the configure of Python. In a Python with universal newline support the feature is ! automatically enabled for all import statements and execfile() ! calls. There is no special support for eval() or exec. In a Python with universal newline support open() the mode ! parameter can also be "U", meaning "open for input as a text file ! with universal newline interpretation". Mode "rU" is also allowed, ! for symmetry with "rb". Mode "U" cannot be combined with other mode flags such as "+". Any line ending in the input file will be seen as a '\n' in Python, so little other code has *************** *** 72,85 **** Python source module) to be handled easily. - Universal newline support is implemented (for this release) as a - compile time option because there is a performance penalty, even - though it should be a small one. - There is no output implementation of universal newlines, Python programs are expected to handle this by themselves or write files with platform-local convention otherwise. The reason for this is that input is the difficult case, outputting different newlines to ! a file is already easy enough in Python. It would also slow down ! all "normal" Python output, even if only a little. While universal newlines are automatically enabled for import they --- 73,122 ---- Python source module) to be handled easily. There is no output implementation of universal newlines, Python programs are expected to handle this by themselves or write files with platform-local convention otherwise. The reason for this is that input is the difficult case, outputting different newlines to ! a file is already easy enough in Python. ! ! Also, an output implementation would be much more difficult than an ! input implementation, surprisingly: a lot of output is done through ! PyXXX_Print() methods, and at this point the file object is not ! available anymore, only a FILE *. So, an output implementation would ! need to somehow go from the FILE* to the file object, because that ! is where the current newline delimiter is stored. ! ! The input implementation has no such problem: there are no cases in ! the Python source tree where files are partially read from C, ! partially from Python, and such cases are expected to be rare in ! extension modules. If such cases exist the only problem is that the ! newlines attribute of the file object is not updated during the ! fread() or fgets() calls that are done direct from C. ! ! A partial output implementation, where strings passed to fp.write() ! would be converted to use fp.newlines as their line terminated but ! all other output would not is far too surprising, in my view. ! ! Because there is no output support for universal newlines there is ! also no support for a mode "rU+": the surprise factor of the ! previous paragraph would hold to an even stronger degree. ! ! There is no support for universal newlines in strings passed to ! eval() or exec. It is envisioned that such strings always have the ! standard \n line feed, if the strings come from a file that file can ! be read with universal newlines. ! ! I think there are no special issues with unicode. utf-16 shouldn't ! pose any new problems, as such files need to be opened in binary ! mode anyway. Interaction with utf-8 I am not 100% sure about: is it ! possible for a 0x0a or 0x0d byte to occur as part of a multibyte ! escape without the stadnard meaning of CR or LF? I assume not, ! because if such bytes are allowed it would mean that readline() on ! Unix would terminate the read on a 0x0d (and on MacOS on a 0x0a) ! without a full line being read. ! ! Universal newline files should work fine with iterators and ! xreadlines() as these eventually call the normal file ! readline/readlines methods. ! While universal newlines are automatically enabled for import they *************** *** 89,95 **** - Compatibility. Programs which already do their own ! interpretation of \r\n in text files would break. Programs ! which open binary files as text files on Unix would also break ! (but it could be argued they deserve it :-). - Interface clarity. Universal newlines are only supported for --- 126,136 ---- - Compatibility. Programs which already do their own ! interpretation of \r\n in text files would break. Examples of such ! programs would be editors which warn you when you open a file with ! a different newline convention. If universal newlines was made the ! default such an editor would silently convert your line endings to ! the local convention on save. Programs which open binary files as ! text files on Unix would also break (but it could be argued they ! deserve it :-). - Interface clarity. Universal newlines are only supported for *************** *** 118,121 **** --- 159,166 ---- would argue that if you read the same FileObject in two threads simultaneously you are asking for trouble anyway. + + Note that no globally accessible pointers are manipulated in the + fgets() or fread() replacement routines, just some integer-valued + flags, so the chances of core dumps are zero (he said:-). From tim_one@users.sourceforge.net Wed Mar 13 23:56:50 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Wed, 13 Mar 2002 15:56:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.124.6.3,2.124.6.4 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv29340/Objects Modified Files: Tag: release22-maint unicodeobject.c Log Message: Move to zlib 1.1.4 on Windows (the new version that squashes the "double free" glitch). unicodeobject.c: squash compiler warnings. Noting that test_pyclbr currently fails in 2.2.1: test_others (__main__.PyclbrTest) ... ??? HTTP11 FAIL Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.124.6.3 retrieving revision 2.124.6.4 diff -C2 -d -r2.124.6.3 -r2.124.6.4 *** unicodeobject.c 25 Feb 2002 14:51:00 -0000 2.124.6.3 --- unicodeobject.c 13 Mar 2002 23:56:48 -0000 2.124.6.4 *************** *** 1201,1205 **** if (0xDC00 <= ch2 && ch2 <= 0xDFFF) { ! if ((p - q) >= (cbAllocated - 4)) { /* Provide enough room for some more surrogates */ --- 1201,1205 ---- if (0xDC00 <= ch2 && ch2 <= 0xDFFF) { ! if ((Py_uintptr_t)(p - q) >= (cbAllocated - 4)) { /* Provide enough room for some more surrogates */ *************** *** 1226,1230 **** } else { ! if ((p - q) >= (cbAllocated - 4)) { /* Provide enough room for some more surrogates */ --- 1226,1230 ---- } else { ! if ((Py_uintptr_t)(p - q) >= (cbAllocated - 4)) { /* Provide enough room for some more surrogates */ From tim_one@users.sourceforge.net Wed Mar 13 23:56:50 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Wed, 13 Mar 2002 15:56:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild readme.txt,1.21,1.21.16.1 zlib.dsp,1.15,1.15.24.1 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv29340/PCbuild Modified Files: Tag: release22-maint readme.txt zlib.dsp Log Message: Move to zlib 1.1.4 on Windows (the new version that squashes the "double free" glitch). unicodeobject.c: squash compiler warnings. Noting that test_pyclbr currently fails in 2.2.1: test_others (__main__.PyclbrTest) ... ??? HTTP11 FAIL Index: readme.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/readme.txt,v retrieving revision 1.21 retrieving revision 1.21.16.1 diff -C2 -d -r1.21 -r1.21.16.1 *** readme.txt 28 Jul 2001 07:56:38 -0000 1.21 --- readme.txt 13 Mar 2002 23:56:48 -0000 1.21.16.1 *************** *** 75,89 **** zlib - NOTE: This procedure is new (& simpler, & safer) for 2.1a2. Python wrapper for the zlib compression library. Get the source code ! for version 1.1.3 from a convenient mirror at: ! http://www.info-zip.org/pub/infozip/zlib/ ! Unpack into dist\zlib-1.1.3. A custom pre-link step in the zlib project settings should manage to ! build zlib-1.1.3\zlib.lib by magic before zlib.pyd (or zlib_d.pyd) is linked in PCbuild\. However, the zlib project is not smart enough to remove anything under ! zlib-1.1.3\ when you do a clean, so if you want to rebuild zlib.lib ! you need to clean up zlib-1.1.3\ by hand. bsddb --- 75,88 ---- zlib Python wrapper for the zlib compression library. Get the source code ! for version 1.1.4 from a convenient mirror at: ! http://www.gzip.org/zlib/ ! Unpack into dist\zlib-1.1.4. A custom pre-link step in the zlib project settings should manage to ! build zlib-1.1.4\zlib.lib by magic before zlib.pyd (or zlib_d.pyd) is linked in PCbuild\. However, the zlib project is not smart enough to remove anything under ! zlib-1.1.4\ when you do a clean, so if you want to rebuild zlib.lib ! you need to clean up zlib-1.1.4\ by hand. bsddb Index: zlib.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/zlib.dsp,v retrieving revision 1.15 retrieving revision 1.15.24.1 diff -C2 -d -r1.15 -r1.15.24.1 *** zlib.dsp 31 Jan 2001 10:28:03 -0000 1.15 --- zlib.dsp 13 Mar 2002 23:56:48 -0000 1.15.24.1 *************** *** 45,49 **** F90=df.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "..\..\zlib-1.1.3" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 --- 45,49 ---- F90=df.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "..\..\zlib-1.1.4" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 *************** *** 55,64 **** LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 ! # ADD LINK32 ..\..\zlib-1.1.3\zlib.lib /nologo /base:"0x1e1B0000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./zlib.pyd" /export:initzlib # SUBTRACT LINK32 /pdb:none # Begin Special Build Tool SOURCE="$(InputPath)" PreLink_Desc=Checking static zlib has been built ! PreLink_Cmds=cd ..\..\zlib-1.1.3 nmake -nologo -f msdos\makefile.w32 zlib.lib # End Special Build Tool --- 55,64 ---- LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 ! # ADD LINK32 ..\..\zlib-1.1.4\zlib.lib /nologo /base:"0x1e1B0000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./zlib.pyd" /export:initzlib # SUBTRACT LINK32 /pdb:none # Begin Special Build Tool SOURCE="$(InputPath)" PreLink_Desc=Checking static zlib has been built ! PreLink_Cmds=cd ..\..\zlib-1.1.4 nmake -nologo -f msdos\makefile.w32 zlib.lib # End Special Build Tool *************** *** 78,82 **** F90=df.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "..\..\zlib-1.1.3" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 --- 78,82 ---- F90=df.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "..\..\zlib-1.1.4" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 *************** *** 88,97 **** LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept ! # ADD LINK32 ..\..\zlib-1.1.3\zlib.lib /nologo /base:"0x1e1B0000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./zlib_d.pyd" /pdbtype:sept /export:initzlib # SUBTRACT LINK32 /pdb:none # Begin Special Build Tool SOURCE="$(InputPath)" PreLink_Desc=Checking static zlib has been built ! PreLink_Cmds=cd ..\..\zlib-1.1.3 nmake -nologo -f msdos\makefile.w32 zlib.lib # End Special Build Tool --- 88,97 ---- LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept ! # ADD LINK32 ..\..\zlib-1.1.4\zlib.lib /nologo /base:"0x1e1B0000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./zlib_d.pyd" /pdbtype:sept /export:initzlib # SUBTRACT LINK32 /pdb:none # Begin Special Build Tool SOURCE="$(InputPath)" PreLink_Desc=Checking static zlib has been built ! PreLink_Cmds=cd ..\..\zlib-1.1.4 nmake -nologo -f msdos\makefile.w32 zlib.lib # End Special Build Tool From montanaro@users.sourceforge.net Thu Mar 14 17:35:28 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Thu, 14 Mar 2002 09:35:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libxmlrpclib.tex,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv25523 Modified Files: libxmlrpclib.tex Log Message: update text to refer to ServerProxy class in preference to Server, which is only retained for backward compatibility with older versions of the library. Index: libxmlrpclib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libxmlrpclib.tex,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** libxmlrpclib.tex 8 Mar 2002 17:46:02 -0000 1.6 --- libxmlrpclib.tex 14 Mar 2002 17:35:25 -0000 1.7 *************** *** 18,24 **** objects and XML on the wire. ! \begin{classdesc}{Server}{uri\optional{, transport\optional{, ! encoding\optional{, verbose}}}} ! A \class{Server} instance is a server proxy that manages communication with a remote XML-RPC server. The required first argument is a URI (Uniform Resource Indicator), and will normally be the URL of the --- 18,24 ---- objects and XML on the wire. ! \begin{classdesc}{ServerProxy}{uri\optional{, transport\optional{, ! encoding\optional{, verbose}}}} ! A \class{ServerProxy} instance is an object that manages communication with a remote XML-RPC server. The required first argument is a URI (Uniform Resource Indicator), and will normally be the URL of the *************** *** 35,39 **** fetch other server-associated metadata. ! \class{Server} instance methods take Python basic types and objects as arguments and return Python basic types and classes. Types that are conformable (e.g. that can be marshalled through XML), include the --- 35,39 ---- fetch other server-associated metadata. ! \class{ServerProxy} instance methods take Python basic types and objects as arguments and return Python basic types and classes. Types that are conformable (e.g. that can be marshalled through XML), include the *************** *** 70,73 **** --- 70,76 ---- described below. + \class{Server} is retained as an alias for \class{ServerProxy} for backwards + compatibility. New code should use \class{ServerProxy}. + \end{classdesc} *************** *** 84,90 **** ! \subsection{Server Objects \label{server-objects}} ! A \class{Server} instance proxy object has a method corresponding to each remote procedure call accepted by the XML-RPC server. Calling the method performs an RPC, dispatched by both name and argument --- 87,93 ---- ! \subsection{ServerProxy Objects \label{serverproxy-objects}} ! A \class{ServerProxy} instance has a method corresponding to each remote procedure call accepted by the XML-RPC server. Calling the method performs an RPC, dispatched by both name and argument *************** *** 245,250 **** # simple test program (from the XML-RPC specification) ! # server = Server("http://localhost:8000") # local server ! server = Server("http://betty.userland.com") print server --- 248,253 ---- # simple test program (from the XML-RPC specification) ! # server = ServerProxy("http://localhost:8000") # local server ! server = ServerProxy("http://betty.userland.com") print server From mwh@users.sourceforge.net Thu Mar 14 17:13:51 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Thu, 14 Mar 2002 09:13:51 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_pyclbr.py,1.6,1.6.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv17554 Modified Files: Tag: release22-maint test_pyclbr.py Log Message: I don't understand it either... backport jhylton's checkin of revision 1.7 of test_pyclbr.py Fix pyclbr test of httplib without really understanding pyclbr. It seems that the new class HTTP11 in httplib.test() isn't discoverable by pyclbr, which causes this test to fail. Index: test_pyclbr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pyclbr.py,v retrieving revision 1.6 retrieving revision 1.6.10.1 diff -C2 -d -r1.6 -r1.6.10.1 *** test_pyclbr.py 3 Oct 2001 04:08:26 -0000 1.6 --- test_pyclbr.py 14 Mar 2002 17:06:55 -0000 1.6.10.1 *************** *** 141,145 **** cm('httplib', ignore=('error', # set with = ! 'HTTPS')) # not on all platforms cm('Cookie', ignore=('__str__', 'Cookie')) # set with = --- 141,146 ---- cm('httplib', ignore=('error', # set with = ! 'HTTPS', ! 'HTTP11')) # not on all platforms cm('Cookie', ignore=('__str__', 'Cookie')) # set with = From mwh@users.sourceforge.net Thu Mar 14 17:17:12 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Thu, 14 Mar 2002 09:17:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.113.4.4,1.113.4.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv19935 Modified Files: Tag: release22-maint test_descr.py Log Message: backport gvanrossum's checkin of revision 1.118 of test_descr.py Add a check that SF bug 516727 is really fixed. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.113.4.4 retrieving revision 1.113.4.5 diff -C2 -d -r1.113.4.4 -r1.113.4.5 *** test_descr.py 11 Mar 2002 10:20:04 -0000 1.113.4.4 --- test_descr.py 14 Mar 2002 17:16:27 -0000 1.113.4.5 *************** *** 430,433 **** --- 430,443 ---- vereq((1).__nonzero__(), 1) vereq((0).__nonzero__(), 0) + # This returns 'NotImplemented' in Python 2.2 + class C(int): + def __add__(self, other): + return NotImplemented + try: + C() + "" + except TypeError: + pass + else: + raise TestFailed, "NotImplemented should have caused TypeErrpr" def longs(): From tim_one@users.sourceforge.net Thu Mar 14 19:06:03 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 14 Mar 2002 11:06:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.361,1.362 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv22529/python/Misc Modified Files: NEWS Log Message: News about zlib-1.1.4. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.361 retrieving revision 1.362 diff -C2 -d -r1.361 -r1.362 *** NEWS 11 Mar 2002 00:24:00 -0000 1.361 --- NEWS 14 Mar 2002 19:06:01 -0000 1.362 *************** *** 21,24 **** --- 21,29 ---- Extension modules + - A security hole ("double free") was found in zlib-1.1.3, a popular + third party compression library used by some Python modules. The + hole was quickly plugged in zlib-1.1.4, and the Windows build of + Python now ships with zlib-1.1.4. + - pwd and grp return enhanced tuples now, with symbolic field names. From tim_one@users.sourceforge.net Thu Mar 14 19:07:23 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 14 Mar 2002 11:07:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.337.2.4.2.2,1.337.2.4.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv22958/221/Misc Modified Files: Tag: release22-maint NEWS Log Message: zlib-1.1.4 news. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.337.2.4.2.2 retrieving revision 1.337.2.4.2.3 diff -C2 -d -r1.337.2.4.2.2 -r1.337.2.4.2.3 *** NEWS 3 Mar 2002 21:32:00 -0000 1.337.2.4.2.2 --- NEWS 14 Mar 2002 19:07:20 -0000 1.337.2.4.2.3 *************** *** 9,12 **** --- 9,19 ---- fixes the bug that no proper line number is given for bad \x escapes. + Extension modules + + - A security hole ("double free") was found in zlib-1.1.3, a popular + third party compression library used by some Python modules. The + hole was quickly plugged in zlib-1.1.4, and the Windows build of + Python 2.2.1 now ships with zlib-1.1.4. + Library From tim_one@users.sourceforge.net Thu Mar 14 21:11:53 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 14 Mar 2002 13:11:53 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild BUILDno.txt,1.26.4.1,1.26.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv22721/PCbuild Modified Files: Tag: release22-maint BUILDno.txt Log Message: Fiddle Windows build number description. Index: BUILDno.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/BUILDno.txt,v retrieving revision 1.26.4.1 retrieving revision 1.26.4.2 diff -C2 -d -r1.26.4.1 -r1.26.4.2 *** BUILDno.txt 28 Feb 2002 07:43:20 -0000 1.26.4.1 --- BUILDno.txt 14 Mar 2002 21:11:51 -0000 1.26.4.2 *************** *** 34,38 **** Windows Python BUILD numbers ---------------------------- ! 32 2.2.1c1 "Soon" 28 2.2 final --- 34,38 ---- Windows Python BUILD numbers ---------------------------- ! 32 2.2.1a1 "Soon" 28 2.2 final From tim_one@users.sourceforge.net Thu Mar 14 22:43:47 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 14 Mar 2002 14:43:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include patchlevel.h,2.60.2.1.2.2,2.60.2.1.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv18399/Include Modified Files: Tag: release22-maint patchlevel.h Log Message: Rename this build 2.2.1c1. Index: patchlevel.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/patchlevel.h,v retrieving revision 2.60.2.1.2.2 retrieving revision 2.60.2.1.2.3 diff -C2 -d -r2.60.2.1.2.2 -r2.60.2.1.2.3 *** patchlevel.h 28 Feb 2002 07:43:20 -0000 2.60.2.1.2.2 --- patchlevel.h 14 Mar 2002 22:43:44 -0000 2.60.2.1.2.3 *************** *** 23,31 **** #define PY_MINOR_VERSION 2 #define PY_MICRO_VERSION 1 ! #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA #define PY_RELEASE_SERIAL 1 /* Version as a string */ ! #define PY_VERSION "2.2.1a1" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. --- 23,31 ---- #define PY_MINOR_VERSION 2 #define PY_MICRO_VERSION 1 ! #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA #define PY_RELEASE_SERIAL 1 /* Version as a string */ ! #define PY_VERSION "2.2.1c1" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. From tim_one@users.sourceforge.net Thu Mar 14 22:43:47 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 14 Mar 2002 14:43:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild BUILDno.txt,1.26.4.2,1.26.4.3 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv18399/PCbuild Modified Files: Tag: release22-maint BUILDno.txt Log Message: Rename this build 2.2.1c1. Index: BUILDno.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/BUILDno.txt,v retrieving revision 1.26.4.2 retrieving revision 1.26.4.3 diff -C2 -d -r1.26.4.2 -r1.26.4.3 *** BUILDno.txt 14 Mar 2002 21:11:51 -0000 1.26.4.2 --- BUILDno.txt 14 Mar 2002 22:43:45 -0000 1.26.4.3 *************** *** 34,38 **** Windows Python BUILD numbers ---------------------------- ! 32 2.2.1a1 "Soon" 28 2.2 final --- 34,38 ---- Windows Python BUILD numbers ---------------------------- ! 32 2.2.1c1 "Soon" 28 2.2 final From tim_one@users.sourceforge.net Thu Mar 14 22:46:57 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 14 Mar 2002 14:46:57 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python20.wse,1.98.4.1,1.98.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv19859/PCbuild Modified Files: Tag: release22-maint python20.wse Log Message: Fiddle Windows installer to call this "2.2.1 release candidate 1". Index: python20.wse =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.wse,v retrieving revision 1.98.4.1 retrieving revision 1.98.4.2 diff -C2 -d -r1.98.4.1 -r1.98.4.2 *** python20.wse 28 Feb 2002 07:43:20 -0000 1.98.4.1 --- python20.wse 14 Mar 2002 22:46:55 -0000 1.98.4.2 *************** *** 2,6 **** item: Global Version=8.14 ! Title=Python 2.2.1 alpha 1 Flags=00010100 Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 --- 2,6 ---- item: Global Version=8.14 ! Title=Python 2.2.1 release candidate 1 Flags=00010100 Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 *************** *** 19,25 **** Patch Threshold=85 Patch Memory=4000 ! EXE Filename=Python-2.2.1a1.exe Dialogs Version=8 ! Version File=2.2.1a1 Version Description=Python Programming Language Version Copyright=©2002 Python Software Foundation --- 19,25 ---- Patch Threshold=85 Patch Memory=4000 ! EXE Filename=Python-2.2.1c1.exe Dialogs Version=8 ! Version File=2.2.1c1 Version Description=Python Programming Language Version Copyright=©2002 Python Software Foundation *************** *** 65,69 **** item: Set Variable Variable=PYVER_STRING ! Value=2.2a1 end item: Remark --- 65,69 ---- item: Set Variable Variable=PYVER_STRING ! Value=2.2.1c1 end item: Remark From jackjansen@users.sourceforge.net Thu Mar 14 22:47:33 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Thu, 14 Mar 2002 14:47:33 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0278.txt,1.3,1.4 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv20105 Modified Files: pep-0278.txt Log Message: Added a line clarifying that newline conversion happens not only for readline() but for all input calls. Index: pep-0278.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0278.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pep-0278.txt 13 Mar 2002 22:50:54 -0000 1.3 --- pep-0278.txt 14 Mar 2002 22:47:31 -0000 1.4 *************** *** 46,49 **** --- 46,52 ---- to change to handle universal newlines. + Conversion of newlines happens in all calls that read data: read(), + readline(), readlines(), etc. + There is no special support for output to file with a different newline convention. From tim_one@users.sourceforge.net Thu Mar 14 22:48:52 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 14 Mar 2002 14:48:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild BUILDno.txt,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv20616/python/PCbuild Modified Files: BUILDno.txt Log Message: Update master Windows buildno list to reflect impending 2.2.1c1. Index: BUILDno.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/BUILDno.txt,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** BUILDno.txt 28 Feb 2002 07:27:48 -0000 1.31 --- BUILDno.txt 14 Mar 2002 22:48:50 -0000 1.32 *************** *** 34,38 **** Windows Python BUILD numbers ---------------------------- ! 32 2.2.1a1 "Soon" 31 2.1.2 final --- 34,38 ---- Windows Python BUILD numbers ---------------------------- ! 32 2.2.1c1 "Soon" 31 2.1.2 final From fdrake@users.sourceforge.net Thu Mar 14 22:56:06 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 14 Mar 2002 14:56:06 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/texinputs boilerplate.tex,1.70.2.1.2.1,1.70.2.1.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory usw-pr-cvs1:/tmp/cvs-serv23316/texinputs Modified Files: Tag: release22-maint boilerplate.tex Log Message: Update version number prior to release candidate. Index: boilerplate.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/boilerplate.tex,v retrieving revision 1.70.2.1.2.1 retrieving revision 1.70.2.1.2.2 diff -C2 -d -r1.70.2.1.2.1 -r1.70.2.1.2.2 *** boilerplate.tex 28 Dec 2001 04:27:46 -0000 1.70.2.1.2.1 --- boilerplate.tex 14 Mar 2002 22:56:04 -0000 1.70.2.1.2.2 *************** *** 8,11 **** \date{\today} % XXX update before release! \release{2.2.1} % software release, not documentation ! \setreleaseinfo{--} % empty for final release \setshortversion{2.2} % major.minor only for software --- 8,11 ---- \date{\today} % XXX update before release! \release{2.2.1} % software release, not documentation ! \setreleaseinfo{c1} % empty for final release \setshortversion{2.2} % major.minor only for software From fdrake@users.sourceforge.net Thu Mar 14 22:56:06 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 14 Mar 2002 14:56:06 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc Makefile,1.235.2.1.2.1,1.235.2.1.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory usw-pr-cvs1:/tmp/cvs-serv23316 Modified Files: Tag: release22-maint Makefile Log Message: Update version number prior to release candidate. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile,v retrieving revision 1.235.2.1.2.1 retrieving revision 1.235.2.1.2.2 diff -C2 -d -r1.235.2.1.2.1 -r1.235.2.1.2.2 *** Makefile 28 Dec 2001 04:27:45 -0000 1.235.2.1.2.1 --- Makefile 14 Mar 2002 22:56:04 -0000 1.235.2.1.2.2 *************** *** 67,71 **** # This is the *documentation* release, and is used to construct the file # names of the downloadable tarballs. ! RELEASE=2.2.1-- PYTHON= python --- 67,71 ---- # This is the *documentation* release, and is used to construct the file # names of the downloadable tarballs. ! RELEASE=2.2.1c1 PYTHON= python From gvanrossum@users.sourceforge.net Thu Mar 14 23:03:17 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Thu, 14 Mar 2002 15:03:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.128,2.129 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv26314 Modified Files: typeobject.c Log Message: "Fix" for SF bug #520644: __slots__ are not pickled. As promised in my response to the bug report, I'm not really fixing it; in fact, one could argule over what the proper fix should do. Instead, I'm adding a little magic that raises TypeError if you try to pickle an instance of a class that has __slots__ but doesn't define or override __getstate__. This is done by adding a bozo __getstate__ that always raises TypeError. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.128 retrieving revision 2.129 diff -C2 -d -r2.128 -r2.129 *** typeobject.c 10 Mar 2002 14:11:16 -0000 2.128 --- typeobject.c 14 Mar 2002 23:03:14 -0000 2.129 *************** *** 851,854 **** --- 851,869 ---- }; + /* bozo: __getstate__ that raises TypeError */ + + static PyObject * + bozo_func(PyObject *self, PyObject *args) + { + PyErr_SetString(PyExc_TypeError, + "a class that defines __slots__ without " + "defining __getstate__ cannot be pickled"); + return NULL; + } + + static PyMethodDef bozo_ml = {"__getstate__", bozo_func}; + + static PyObject *bozo_obj = NULL; + static PyObject * type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds) *************** *** 974,977 **** --- 989,1013 ---- } } + if (slots != NULL) { + /* See if *this* class defines __getstate__ */ + PyObject *getstate = PyDict_GetItemString(dict, + "__getstate__"); + if (getstate == NULL) { + /* If not, provide a bozo that raises TypeError */ + if (bozo_obj == NULL) { + bozo_obj = PyCFunction_New(&bozo_ml, NULL); + if (bozo_obj == NULL) { + /* XXX decref various things */ + return NULL; + } + } + if (PyDict_SetItemString(dict, + "__getstate__", + bozo_obj) < 0) { + /* XXX decref various things */ + return NULL; + } + } + } if (slots == NULL && base->tp_dictoffset == 0 && (base->tp_setattro == PyObject_GenericSetAttr || *************** *** 1655,1659 **** if (descr == NULL) return -1; ! if (PyDict_SetItemString(dict,meth->ml_name,descr) < 0) return -1; Py_DECREF(descr); --- 1691,1695 ---- if (descr == NULL) return -1; ! if (PyDict_SetItemString(dict,meth->ml_name, descr) < 0) return -1; Py_DECREF(descr); From gvanrossum@users.sourceforge.net Thu Mar 14 23:03:43 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Thu, 14 Mar 2002 15:03:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.120,1.121 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv26557 Modified Files: test_descr.py Log Message: "Fix" for SF bug #520644: __slots__ are not pickled. As promised in my response to the bug report, I'm not really fixing it; in fact, one could argule over what the proper fix should do. Instead, I'm adding a little magic that raises TypeError if you try to pickle an instance of a class that has __slots__ but doesn't define or override __getstate__. This is done by adding a bozo __getstate__ that always raises TypeError. Bugfix candidate (also the checkin to typeobject.c, of course). Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.120 retrieving revision 1.121 diff -C2 -d -r1.120 -r1.121 *** test_descr.py 12 Mar 2002 20:43:31 -0000 1.120 --- test_descr.py 14 Mar 2002 23:03:41 -0000 1.121 *************** *** 2451,2454 **** --- 2451,2542 ---- print "b = y =", b + def pickleslots(): + if verbose: print "Testing pickling of classes with __slots__ ..." + import pickle, cPickle + # Pickling of classes with __slots__ but without __getstate__ should fail + global B, C, D, E + class B(object): + pass + for base in [object, B]: + class C(base): + __slots__ = ['a'] + class D(C): + pass + try: + pickle.dumps(C()) + except TypeError: + pass + else: + raise TestFailed, "should fail: pickle C instance - %s" % base + try: + cPickle.dumps(C()) + except TypeError: + pass + else: + raise TestFailed, "should fail: cPickle C instance - %s" % base + try: + pickle.dumps(C()) + except TypeError: + pass + else: + raise TestFailed, "should fail: pickle D instance - %s" % base + try: + cPickle.dumps(D()) + except TypeError: + pass + else: + raise TestFailed, "should fail: cPickle D instance - %s" % base + # Give C a __getstate__ and __setstate__ + class C(base): + __slots__ = ['a'] + def __getstate__(self): + try: + d = self.__dict__.copy() + except AttributeError: + d = {} + try: + d['a'] = self.a + except AttributeError: + pass + return d + def __setstate__(self, d): + for k, v in d.items(): + setattr(self, k, v) + class D(C): + pass + # Now it should work + x = C() + y = pickle.loads(pickle.dumps(x)) + vereq(hasattr(y, 'a'), 0) + y = cPickle.loads(cPickle.dumps(x)) + vereq(hasattr(y, 'a'), 0) + x.a = 42 + y = pickle.loads(pickle.dumps(x)) + vereq(y.a, 42) + y = cPickle.loads(cPickle.dumps(x)) + vereq(y.a, 42) + x = D() + x.a = 42 + x.b = 100 + y = pickle.loads(pickle.dumps(x)) + vereq(y.a + y.b, 142) + y = cPickle.loads(cPickle.dumps(x)) + vereq(y.a + y.b, 142) + # But a subclass that adds a slot should not work + class E(C): + __slots__ = ['b'] + try: + pickle.dumps(E()) + except TypeError: + pass + else: + raise TestFailed, "should fail: pickle E instance - %s" % base + try: + cPickle.dumps(E()) + except TypeError: + pass + else: + raise TestFailed, "should fail: cPickle E instance - %s" % base + def copies(): if verbose: print "Testing copy.copy() and copy.deepcopy()..." *************** *** 2799,2802 **** --- 2887,2891 ---- deepcopyrecursive() modules() + pickleslots() if verbose: print "All OK" From gvanrossum@users.sourceforge.net Thu Mar 14 23:05:57 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Thu, 14 Mar 2002 15:05:57 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.362,1.363 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv27759 Modified Files: NEWS Log Message: "Fix" for SF bug #520644: __slots__ are not pickled. As promised in my response to the bug report, I'm not really fixing it; in fact, one could argule over what the proper fix should do. Instead, I'm adding a little magic that raises TypeError if you try to pickle an instance of a class that has __slots__ but doesn't define or override __getstate__. This is done by adding a bozo __getstate__ that always raises TypeError. Bugfix candidate (also the checkin to typeobject.c, of course). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.362 retrieving revision 1.363 diff -C2 -d -r1.362 -r1.363 *** NEWS 14 Mar 2002 19:06:01 -0000 1.362 --- NEWS 14 Mar 2002 23:05:54 -0000 1.363 *************** *** 7,10 **** --- 7,16 ---- Core and builtins + - If you try to pickle an instance of a class that has __slots__ but + doesn't define or override __getstate__, a TypeError is now raised. + This is done by adding a bozo __getstate__ to the class that always + raises TypeError. (Before, this would appear to be pickled, but the + state of the slots would be lost.) + - PyErr_Display will provide file and line information for all exceptions that have an attribute print_file_and_line, not just SyntaxErrors. From jackjansen@users.sourceforge.net Thu Mar 14 23:13:35 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Thu, 14 Mar 2002 15:13:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Build PythonStandalone.mcp,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Build In directory usw-pr-cvs1:/tmp/cvs-serv30564/Python/Mac/Build Modified Files: PythonStandalone.mcp Log Message: Updated for new included expat and new waste. Index: PythonStandalone.mcp =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Build/PythonStandalone.mcp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 Binary files /tmp/cvscplVVW and /tmp/cvsEBIGQK differ From jackjansen@users.sourceforge.net Thu Mar 14 23:14:45 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Thu, 14 Mar 2002 15:14:45 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/scripts genpluginprojects.py,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/scripts In directory usw-pr-cvs1:/tmp/cvs-serv31034/Python/Mac/scripts Modified Files: genpluginprojects.py Log Message: Modifed for new included expat. Index: genpluginprojects.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/scripts/genpluginprojects.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** genpluginprojects.py 11 Jan 2002 12:39:03 -0000 1.27 --- genpluginprojects.py 14 Mar 2002 23:14:43 -0000 1.28 *************** *** 37,41 **** libraries=[], extradirs=[], extraexportsymbols=[], outputdir=":::Lib:lib-dynload", ! libraryflags=None, stdlibraryflags=None): if architecture == "all": # For the time being we generate two project files. Not as nice as --- 37,41 ---- libraries=[], extradirs=[], extraexportsymbols=[], outputdir=":::Lib:lib-dynload", ! libraryflags=None, stdlibraryflags=None, prefixname=None): if architecture == "all": # For the time being we generate two project files. Not as nice as *************** *** 77,81 **** print "Warning: %s: sourcefile not found: %s"%(module, sources[0]) sourcedirs = [] ! if architecture == "carbon": prefixname = "mwerks_carbonplugin_config.h" else: --- 77,83 ---- print "Warning: %s: sourcefile not found: %s"%(module, sources[0]) sourcedirs = [] ! if prefixname: ! pass ! elif architecture == "carbon": prefixname = "mwerks_carbonplugin_config.h" else: *************** *** 103,110 **** FORCEREBUILD = force # Standard Python modules ! genpluginproject("all", "pyexpat", ! sources=["pyexpat.c"], ! libraries=["libexpat.ppc.lib"], ! extradirs=["::::expat:*"]) genpluginproject("all", "zlib", libraries=["zlib.ppc.Lib"], --- 105,118 ---- FORCEREBUILD = force # Standard Python modules ! genpluginproject("ppc", "pyexpat", ! sources=["pyexpat.c", "xmlparse.c", "xmlrole.c", "xmltok.c"], ! extradirs=[":::Modules:expat"], ! prefixname="mwerks_pyexpat_config.h" ! ) ! genpluginproject("carbon", "pyexpat", ! sources=["pyexpat.c", "xmlparse.c", "xmlrole.c", "xmltok.c"], ! extradirs=[":::Modules:expat"], ! prefixname="mwerks_carbonpyexpat_config.h" ! ) genpluginproject("all", "zlib", libraries=["zlib.ppc.Lib"], From nnorwitz@users.sourceforge.net Thu Mar 14 23:48:20 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Thu, 14 Mar 2002 15:48:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib asyncore.py,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv10474/Lib Modified Files: asyncore.py Log Message: Remove duplicate "import os" Index: asyncore.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/asyncore.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** asyncore.py 8 Mar 2002 18:19:59 -0000 1.29 --- asyncore.py 14 Mar 2002 23:48:18 -0000 1.30 *************** *** 512,516 **** # Regardless, this is useful for pipes, and stdin/stdout... - import os if os.name == 'posix': import fcntl --- 512,515 ---- From nnorwitz@users.sourceforge.net Fri Mar 15 01:35:21 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Thu, 14 Mar 2002 17:35:21 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib asyncore.py,1.28,1.28.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv12272/Lib Modified Files: Tag: release22-maint asyncore.py Log Message: Remove duplicate "import os" Index: asyncore.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/asyncore.py,v retrieving revision 1.28 retrieving revision 1.28.4.1 diff -C2 -d -r1.28 -r1.28.4.1 *** asyncore.py 14 Dec 2001 16:15:11 -0000 1.28 --- asyncore.py 15 Mar 2002 01:35:19 -0000 1.28.4.1 *************** *** 511,515 **** # Regardless, this is useful for pipes, and stdin/stdout... - import os if os.name == 'posix': import fcntl --- 511,514 ---- From montanaro@users.sourceforge.net Fri Mar 15 02:54:05 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Thu, 14 Mar 2002 18:54:05 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test regrtest.py,1.71,1.72 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv3612 Modified Files: regrtest.py Log Message: first cut at skip-list for hp-ux 11 based upon input from Bill Lawler at HP. Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** regrtest.py 8 Feb 2002 20:13:53 -0000 1.71 --- regrtest.py 15 Mar 2002 02:54:03 -0000 1.72 *************** *** 643,646 **** --- 643,676 ---- test_winsound """, + 'hp-ux11': + """ + test_al + test_bsddb + test_cd + test_cl + test_curses + test_dl + test_gdbm + test_gl + test_gzip + test_imgfile + test_largefile + test_linuxaudiodev + test_locale + test_minidom + test_nis + test_ntpath + test_openpty + test_pyexpat + test_sax + test_socket_ssl + test_socketserver + test_sunaudiodev + test_unicode_file + test_winreg + test_winsound + test_zipfile + test_zlib + """, } From montanaro@users.sourceforge.net Fri Mar 15 03:57:06 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Thu, 14 Mar 2002 19:57:06 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_calendar.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv14933 Modified Files: test_calendar.py Log Message: added test case to catch index errors with _localized_name class Index: test_calendar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_calendar.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_calendar.py 12 Dec 2001 05:38:08 -0000 1.1 --- test_calendar.py 15 Mar 2002 03:57:04 -0000 1.2 *************** *** 27,30 **** --- 27,34 ---- calendar.setfirstweekday(orig) + def test_enumerateweekdays(self): + self.assertRaises(IndexError, calendar.day_abbr.__getitem__, -10) + self.assertRaises(IndexError, calendar.day_name.__getitem__, 10) + self.assertEqual(len([d for d in calendar.day_abbr]), 7) def test_main(): From montanaro@users.sourceforge.net Fri Mar 15 04:08:40 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Thu, 14 Mar 2002 20:08:40 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib calendar.py,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv16772 Modified Files: calendar.py Log Message: make _localized_name instances work more like the tuples they replaced. In particular, negative indexes work and they are limited by the actual length of the names they represent (weekday and month names). This closes bug #503202. Index: calendar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/calendar.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** calendar.py 22 May 2001 15:58:30 -0000 1.22 --- calendar.py 15 Mar 2002 04:08:38 -0000 1.23 *************** *** 26,41 **** class _localized_name: ! def __init__(self, format): self.format = format def __getitem__(self, item): return strftime(self.format, (item,)*9).capitalize() # Full and abbreviated names of weekdays ! day_name = _localized_name('%A') ! day_abbr = _localized_name('%a') # Full and abbreviated names of months (1-based arrays!!!) ! month_name = _localized_name('%B') ! month_abbr = _localized_name('%b') # Constants for weekdays --- 26,48 ---- class _localized_name: ! def __init__(self, format, len): self.format = format + self.len = len def __getitem__(self, item): + if item > self.len-1 or item < -self.len: + raise IndexError + if item < 0: + item += self.len return strftime(self.format, (item,)*9).capitalize() + def __len__(self): + return self.len # Full and abbreviated names of weekdays ! day_name = _localized_name('%A', 7) ! day_abbr = _localized_name('%a', 7) # Full and abbreviated names of months (1-based arrays!!!) ! month_name = _localized_name('%B', 12) ! month_abbr = _localized_name('%b', 12) # Constants for weekdays From loewis@users.sourceforge.net Fri Mar 15 09:16:42 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 15 Mar 2002 01:16:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules pypcre.c,2.22,2.23 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv15346/Modules Modified Files: pypcre.c Log Message: Include Python.h first. Fixes #530159. Index: pypcre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pypcre.c,v retrieving revision 2.22 retrieving revision 2.23 diff -C2 -d -r2.22 -r2.23 *** pypcre.c 2 Aug 2000 13:41:18 -0000 2.22 --- pypcre.c 15 Mar 2002 09:16:40 -0000 2.23 *************** *** 46,51 **** #define FOR_PYTHON - #include "pcre-int.h" #include "Python.h" #include #include "graminit.h" --- 46,51 ---- #define FOR_PYTHON #include "Python.h" + #include "pcre-int.h" #include #include "graminit.h" From mwh@users.sourceforge.net Fri Mar 15 10:19:01 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Fri, 15 Mar 2002 02:19:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib os.py,1.52,1.53 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv29116 Modified Files: os.py Log Message: Fix [ 530236 ] os.py assumes existence of statvfs_resul This was pretty dense of me. Sorry. 2.2.1 candidate. Index: os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/os.py,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** os.py 6 Mar 2002 17:11:17 -0000 1.52 --- os.py 15 Mar 2002 10:18:58 -0000 1.53 *************** *** 613,617 **** return (_make_stat_result, args) ! _copy_reg.pickle(stat_result, _pickle_stat_result,_make_stat_result) def _make_statvfs_result(tup, dict): --- 613,620 ---- return (_make_stat_result, args) ! try: ! _copy_reg.pickle(stat_result, _pickle_stat_result, _make_stat_result) ! except NameError: # stat_result may not exist ! pass def _make_statvfs_result(tup, dict): *************** *** 622,624 **** return (_make_statvfs_result, args) ! _copy_reg.pickle(statvfs_result, _pickle_statvfs_result,_make_statvfs_result) --- 625,631 ---- return (_make_statvfs_result, args) ! try: ! _copy_reg.pickle(statvfs_result, _pickle_statvfs_result, ! _make_statvfs_result) ! except NameError: # stat_result may not exist ! pass From mwh@users.sourceforge.net Fri Mar 15 10:22:01 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Fri, 15 Mar 2002 02:22:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib os.py,1.53,1.54 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv29998 Modified Files: os.py Log Message: .... Index: os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/os.py,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** os.py 15 Mar 2002 10:18:58 -0000 1.53 --- os.py 15 Mar 2002 10:21:59 -0000 1.54 *************** *** 628,631 **** _copy_reg.pickle(statvfs_result, _pickle_statvfs_result, _make_statvfs_result) ! except NameError: # stat_result may not exist pass --- 628,631 ---- _copy_reg.pickle(statvfs_result, _pickle_statvfs_result, _make_statvfs_result) ! except NameError: # statvfs_result may not exist pass From mwh@users.sourceforge.net Fri Mar 15 10:23:14 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Fri, 15 Mar 2002 02:23:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include cellobject.h,2.1,2.1.24.1 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv30356 Modified Files: Tag: release22-maint cellobject.h Log Message: backport jhylton's checkin of revision 2.2 of cellobject.h Cells are not VAR objects. Noted by Jason Orendorff, SF #520768. Bug fix candidate for 2.1 & 2.2. Index: cellobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/cellobject.h,v retrieving revision 2.1 retrieving revision 2.1.24.1 diff -C2 -d -r2.1 -r2.1.24.1 *** cellobject.h 25 Jan 2001 20:04:14 -0000 2.1 --- cellobject.h 15 Mar 2002 10:23:11 -0000 2.1.24.1 *************** *** 8,12 **** typedef struct { ! PyObject_VAR_HEAD PyObject *ob_ref; } PyCellObject; --- 8,12 ---- typedef struct { ! PyObject_HEAD PyObject *ob_ref; } PyCellObject; From mwh@users.sourceforge.net Fri Mar 15 10:24:16 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Fri, 15 Mar 2002 02:24:16 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib ConfigParser.py,1.38,1.38.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv30593 Modified Files: Tag: release22-maint ConfigParser.py Log Message: I presume this should go here. backport akuchling's checkin of revision 1.39 of ConfigParser.py [Bug #523301] ConfigParser.write() produces broken output for values that were originally rfc822-like line continuations. Modified version of a patch from Matthias Ralfs. Index: ConfigParser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ConfigParser.py,v retrieving revision 1.38 retrieving revision 1.38.10.1 diff -C2 -d -r1.38 -r1.38.10.1 *** ConfigParser.py 18 Oct 2001 21:57:37 -0000 1.38 --- ConfigParser.py 15 Mar 2002 10:24:14 -0000 1.38.10.1 *************** *** 345,349 **** fp.write("[DEFAULT]\n") for (key, value) in self.__defaults.items(): ! fp.write("%s = %s\n" % (key, value)) fp.write("\n") for section in self.sections(): --- 345,349 ---- fp.write("[DEFAULT]\n") for (key, value) in self.__defaults.items(): ! fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n") for section in self.sections(): *************** *** 353,357 **** if key == "__name__": continue ! fp.write("%s = %s\n" % (key, value)) fp.write("\n") --- 353,357 ---- if key == "__name__": continue ! fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n") From mwh@users.sourceforge.net Fri Mar 15 10:24:44 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Fri, 15 Mar 2002 02:24:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_cfgparser,1.5,1.5.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv30722 Modified Files: Tag: release22-maint test_cfgparser Log Message: backport akuchling's checkin of revision 1.6 of test_cfgparser As part of fixing bug #523301, add a simple test of ConfigParser.write() Index: test_cfgparser =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_cfgparser,v retrieving revision 1.5 retrieving revision 1.5.10.1 diff -C2 -d -r1.5 -r1.5.10.1 *** test_cfgparser 8 Oct 2001 17:13:12 -0000 1.5 --- test_cfgparser 15 Mar 2002 10:24:42 -0000 1.5.10.1 *************** *** 1,4 **** --- 1,5 ---- test_cfgparser Testing basic accessors... + Testing writing of files... Testing case sensitivity... Testing interpretation of boolean Values... From mwh@users.sourceforge.net Fri Mar 15 10:25:14 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Fri, 15 Mar 2002 02:25:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_cfgparser.py,1.9,1.9.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv30863 Modified Files: Tag: release22-maint test_cfgparser.py Log Message: backport akuchling's checkin of revision 1.10 of test_cfgparser.py As part of fixing bug #523301, add a simple test of ConfigParser.write() Index: test_cfgparser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cfgparser.py,v retrieving revision 1.9 retrieving revision 1.9.10.1 diff -C2 -d -r1.9 -r1.9.10.1 *** test_cfgparser.py 8 Oct 2001 17:13:11 -0000 1.9 --- test_cfgparser.py 15 Mar 2002 10:25:12 -0000 1.9.10.1 *************** *** 15,18 **** --- 15,19 ---- r'Foo Bar', r'Internationalized Stuff', + r'Long Line', r'Section\with$weird%characters[' '\t', r'Spacey Bar', *************** *** 48,52 **** --- 49,72 ---- " that never existed") + verify(cf.get('Long Line', 'foo', raw=1) == + 'this line is much, much longer than my editor\nlikes it.') + + + def write(src): + print "Testing writing of files..." + cf = ConfigParser.ConfigParser() + sio = StringIO.StringIO(src) + cf.readfp(sio) + output = StringIO.StringIO() + cf.write(output) + verify(output, """[DEFAULT] + foo = another very + long line + [Long Line] + foo = this line is much, much longer than my editor + likes it. + """) + def case_sensitivity(): print "Testing case sensitivity..." *************** *** 192,195 **** --- 212,218 ---- [Commented Bar] foo: bar ; comment + [Long Line] + foo: this line is much, much longer than my editor + likes it. [Section\with$weird%characters[""" '\t' r"""] [Internationalized Stuff] *************** *** 199,202 **** --- 222,231 ---- foo[de]=Deutsch """) + write("""[Long Line] + foo: this line is much, much longer than my editor + likes it. + [DEFAULT] + foo: another very + long line""") case_sensitivity() boolean(r""" From mwh@users.sourceforge.net Fri Mar 15 10:29:10 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Fri, 15 Mar 2002 02:29:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ext building.tex,NONE,1.1.2.1 ext.tex,1.104,1.104.14.1 windows.tex,1.3,1.3.6.1 unix.tex,1.2,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory usw-pr-cvs1:/tmp/cvs-serv31397 Modified Files: Tag: release22-maint ext.tex windows.tex Added Files: Tag: release22-maint building.tex Removed Files: Tag: release22-maint unix.tex Log Message: Backport loewis' checkin of revision 1.104 of ext.tex revision 1.4 of windows.tex revision 1.1 of building.tex removal of unix.tex Patch #500136: Update Update ext build documentation. 2.2.1 candidate. --- NEW FILE: building.tex --- \chapter{Building C and \Cpp{} Extensions with distutils \label{building}} \sectionauthor{Martin v. L\"owis}{martin@v.loewis.de} Starting in Python 1.4, Python provides, on \UNIX{}, a special make file for building make files for building dynamically-linked extensions and custom interpreters. Starting with Python 2.0, this mechanism (known as related to Makefile.pre.in, and Setup files) is no longer supported. Building custom interpreters was rarely used, and extensions modules can be build using distutils. Building an extension module using distutils requires that distutils is installed on the build machine, which is included in Python 2.x and available separately for Python 1.5. Since distutils also supports creation of binary packages, users don't necessarily need a compiler and distutils to install the extension. A distutils package contains a driver script, \file{setup.py}. This is a plain Python file, which, in the most simple case, could look like this: \begin{verbatim} from distutils.core import setup, Extension module1 = Extension('demo', sources = ['demo.c']) setup (name = 'PackageName', version = '1.0', description = 'This is a demo package', ext_modules = [module1]) \end{verbatim} With this \file{setup.py}, and a file \file{demo.c}, running \begin{verbatim} python setup.py build \end{verbatim} will compile \file{demo.c}, and produce an extension module named \samp{demo} in the \file{build} directory. Depending on the system, the module file will end up in a subdirectory \file{build/lib.system}, and may have a name like \file{demo.so} or \file{demo.pyd}. In the \file{setup.py}, all execution is performed by calling the \samp{setup} function. This takes a variable number of keyword arguments, of which the example above uses only a subset. Specifically, the example specifies meta-information to build packages, and it specifies the contents of the package. Normally, a package will contain of addition modules, like Python source modules, documentation, subpackages, etc. Please refer to the distutils documentation in \citetitle[../dist/dist.html]{Distributing Python Modules} to learn more about the features of distutils; this section explains building extension modules only. It is common to pre-compute arguments to \function{setup}, to better structure the driver script. In the example above, the\samp{ext_modules} argument to \function{setup} is a list of extension modules, each of which is an instance of the \class{Extension}. In the example, the instance defines an extension named \samp{demo} which is build by compiling a single source file, \file{demo.c}. In many cases, building an extension is more complex, since additional preprocessor defines and libraries may be needed. This is demonstrated in the example below. \begin{verbatim} from distutils.core import setup, Extension module1 = Extension('demo', define_macros = [('MAJOR_VERSION', '1'), ('MINOR_VERSION', '0')], include_dirs = ['/usr/local/include'], libraries = ['tcl83'], library_dirs = ['/usr/local/lib'], sources = ['demo.c']) setup (name = 'PackageName', version = '1.0', description = 'This is a demo package', author = 'Martin v. Loewis', author_email = 'martin@v.loewis.de', url = 'http://www.python.org/doc/current/ext/building.html', long_description = ''' This is really just a demo package. ''', ext_modules = [module1]) \end{verbatim} In this example, \function{setup} is called with additional meta-information, which is recommended when distribution packages have to be built. For the extension itself, it specifies preprocessor defines, include directories, library directories, and libraries. Depending on the compiler, distutils passes this information in different ways to the compiler. For example, on \UNIX{}, this may result in the compilation commands \begin{verbatim} gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -DMAJOR_VERSION=1 -DMINOR_VERSION=0 -I/usr/local/include -I/usr/local/include/python2.2 -c demo.c -o build/temp.linux-i686-2.2/demo.o gcc -shared build/temp.linux-i686-2.2/demo.o -L/usr/local/lib -ltcl83 -o build/lib.linux-i686-2.2/demo.so \end{verbatim} These lines are for demonstration purposes only; distutils users should trust that distutils gets the invocations right. \section{Distributing your extension modules \label{distributing}} When an extension has been successfully build, there are three ways to use it. End-users will typically want to install the module, they do so by running \begin{verbatim} python setup.py install \end{verbatim} Module maintainers should produce source packages; to do so, they run \begin{verbatim} python setup.py sdist \end{verbatim} In some cases, additional files need to be included in a source distribution; this is done through a \file{MANIFEST.in} file; see the distutils documentation for details. If the source distribution has been build successfully, maintainers can also create binary distributions. Depending on the platform, one of the following commands can be used to do so. \begin{verbatim} python setup.py bdist_wininst python setup.py bdist_rpm python setup.py bdist_dumb \end{verbatim} Index: ext.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/ext.tex,v retrieving revision 1.104 retrieving revision 1.104.14.1 diff -C2 -d -r1.104 -r1.104.14.1 *** ext.tex 20 Aug 2001 19:30:29 -0000 1.104 --- ext.tex 15 Mar 2002 10:29:08 -0000 1.104.14.1 *************** *** 53,57 **** \input{extending} \input{newtypes} ! \input{unix} \input{windows} \input{embedding} --- 53,57 ---- \input{extending} \input{newtypes} ! \input{building} \input{windows} \input{embedding} Index: windows.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/windows.tex,v retrieving revision 1.3 retrieving revision 1.3.6.1 diff -C2 -d -r1.3 -r1.3.6.1 *** windows.tex 13 Dec 2001 17:20:32 -0000 1.3 --- windows.tex 15 Mar 2002 10:29:08 -0000 1.3.6.1 *************** *** 10,13 **** --- 10,17 ---- software which can be successfully built on both \UNIX{} and Windows. + Module authors are encouraged to use the distutils approach for + building extension modules, instead of the one described in this + section. You will still need the C compiler that was used to build + Python; typically Microsoft Visual \Cpp. \section{A Cookbook Approach \label{win-cookbook}} --- unix.tex DELETED --- From mwh@users.sourceforge.net Fri Mar 15 10:32:09 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Fri, 15 Mar 2002 02:32:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib asyncore.py,1.28.4.1,1.28.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv32403 Modified Files: Tag: release22-maint asyncore.py Log Message: backport akuchling's checkin of revision 1.29 of asyncore.py [Bug #517554] When a signal happens during the select call in asyncore.poll, the select fails with EINTR, which the code catches. However, the code fails to clear the r/w/e arrays (like poll3 does), which means it acts as if every descriptor had received all possible events. Bug report and patch by Cesar Eduardo Barros Index: asyncore.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/asyncore.py,v retrieving revision 1.28.4.1 retrieving revision 1.28.4.2 diff -C2 -d -r1.28.4.1 -r1.28.4.2 *** asyncore.py 15 Mar 2002 01:35:19 -0000 1.28.4.1 --- asyncore.py 15 Mar 2002 10:32:07 -0000 1.28.4.2 *************** *** 81,84 **** --- 81,85 ---- if err[0] != EINTR: raise + r = []; w = []; e = [] if DEBUG: From mwh@users.sourceforge.net Fri Mar 15 10:35:38 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Fri, 15 Mar 2002 02:35:38 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects moduleobject.c,2.40,2.40.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv2456 Modified Files: Tag: release22-maint moduleobject.c Log Message: backport gvanrossum's checkin of revision 2.41 of moduleobject.c Fix for SF bug #529050 - ModuleType.__new__ crash. There were several places that assumed the md_dict field was always set, but it needn't be. Fixed these to be more careful. I changed PyModule_GetDict() to initialize md_dict to a new dictionary if it's NULL. Bugfix candidate. Index: moduleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/moduleobject.c,v retrieving revision 2.40 retrieving revision 2.40.8.1 diff -C2 -d -r2.40 -r2.40.8.1 *** moduleobject.c 21 Oct 2001 22:27:35 -0000 2.40 --- moduleobject.c 15 Mar 2002 10:35:36 -0000 2.40.8.1 *************** *** 44,52 **** PyModule_GetDict(PyObject *m) { if (!PyModule_Check(m)) { PyErr_BadInternalCall(); return NULL; } ! return ((PyModuleObject *)m) -> md_dict; } --- 44,56 ---- PyModule_GetDict(PyObject *m) { + PyObject *d; if (!PyModule_Check(m)) { PyErr_BadInternalCall(); return NULL; } ! d = ((PyModuleObject *)m) -> md_dict; ! if (d == NULL) ! ((PyModuleObject *)m) -> md_dict = d = PyDict_New(); ! return d; } *************** *** 54,57 **** --- 58,62 ---- PyModule_GetName(PyObject *m) { + PyObject *d; PyObject *nameobj; if (!PyModule_Check(m)) { *************** *** 59,65 **** return NULL; } ! nameobj = PyDict_GetItemString(((PyModuleObject *)m)->md_dict, ! "__name__"); ! if (nameobj == NULL || !PyString_Check(nameobj)) { PyErr_SetString(PyExc_SystemError, "nameless module"); return NULL; --- 64,72 ---- return NULL; } ! d = ((PyModuleObject *)m)->md_dict; ! if (d == NULL || ! (nameobj = PyDict_GetItemString(d, "__name__")) == NULL || ! !PyString_Check(nameobj)) ! { PyErr_SetString(PyExc_SystemError, "nameless module"); return NULL; *************** *** 71,74 **** --- 78,82 ---- PyModule_GetFilename(PyObject *m) { + PyObject *d; PyObject *fileobj; if (!PyModule_Check(m)) { *************** *** 76,82 **** return NULL; } ! fileobj = PyDict_GetItemString(((PyModuleObject *)m)->md_dict, ! "__file__"); ! if (fileobj == NULL || !PyString_Check(fileobj)) { PyErr_SetString(PyExc_SystemError, "module filename missing"); return NULL; --- 84,92 ---- return NULL; } ! d = ((PyModuleObject *)m)->md_dict; ! if (d == NULL || ! (fileobj = PyDict_GetItemString(d, "__file__")) == NULL || ! !PyString_Check(fileobj)) ! { PyErr_SetString(PyExc_SystemError, "module filename missing"); return NULL; *************** *** 100,103 **** --- 110,115 ---- d = ((PyModuleObject *)m)->md_dict; + if (d == NULL) + return; /* First, clear only names starting with a single underscore */ From mwh@users.sourceforge.net Fri Mar 15 10:35:57 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Fri, 15 Mar 2002 02:35:57 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.113.4.5,1.113.4.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv2524 Modified Files: Tag: release22-maint test_descr.py Log Message: backport gvanrossum's checkin of revision 1.120 of test_descr.py Test for the fix I just checked in to moduleobject.c. Bugfix candidate. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.113.4.5 retrieving revision 1.113.4.6 diff -C2 -d -r1.113.4.5 -r1.113.4.6 *** test_descr.py 14 Mar 2002 17:16:27 -0000 1.113.4.5 --- test_descr.py 15 Mar 2002 10:35:55 -0000 1.113.4.6 *************** *** 2731,2734 **** --- 2731,2745 ---- z = deepcopy(a) # This blew up before + def modules(): + if verbose: print "Testing uninitialized module objects..." + from types import ModuleType as M + m = M.__new__(M) + str(m) + vereq(hasattr(m, "__name__"), 0) + vereq(hasattr(m, "__file__"), 0) + vereq(hasattr(m, "foo"), 0) + vereq(m.__dict__, None) + m.foo = 1 + vereq(m.__dict__, {"foo": 1}) def test_main(): *************** *** 2787,2790 **** --- 2798,2802 ---- strops() deepcopyrecursive() + modules() if verbose: print "All OK" From loewis@users.sourceforge.net Fri Mar 15 13:40:33 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 15 Mar 2002 05:40:33 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects object.c,2.164,2.165 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv24784 Modified Files: object.c Log Message: Patch #517521: Consider byte strings before Unicode strings in PyObject_Get/SetAttr. Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.164 retrieving revision 2.165 diff -C2 -d -r2.164 -r2.165 *** object.c 2 Mar 2002 08:43:19 -0000 2.164 --- object.c 15 Mar 2002 13:40:30 -0000 2.165 *************** *** 1086,1104 **** PyTypeObject *tp = v->ob_type; #ifdef Py_USING_UNICODE ! /* The Unicode to string conversion is done here because the ! existing tp_getattro slots expect a string object as name ! and we wouldn't want to break those. */ ! if (PyUnicode_Check(name)) { ! name = _PyUnicode_AsDefaultEncodedString(name, NULL); ! if (name == NULL) ! return NULL; ! } ! else #endif ! if (!PyString_Check(name)) { ! PyErr_SetString(PyExc_TypeError, ! "attribute name must be string"); ! return NULL; } if (tp->tp_getattro != NULL) --- 1086,1106 ---- PyTypeObject *tp = v->ob_type; + if (!PyString_Check(name)) { #ifdef Py_USING_UNICODE ! /* The Unicode to string conversion is done here because the ! existing tp_getattro slots expect a string object as name ! and we wouldn't want to break those. */ ! if (PyUnicode_Check(name)) { ! name = _PyUnicode_AsDefaultEncodedString(name, NULL); ! if (name == NULL) ! return NULL; ! } ! else #endif ! { ! PyErr_SetString(PyExc_TypeError, ! "attribute name must be string"); ! return NULL; ! } } if (tp->tp_getattro != NULL) *************** *** 1130,1148 **** int err; #ifdef Py_USING_UNICODE ! /* The Unicode to string conversion is done here because the ! existing tp_setattro slots expect a string object as name ! and we wouldn't want to break those. */ ! if (PyUnicode_Check(name)) { ! name = PyUnicode_AsEncodedString(name, NULL, NULL); ! if (name == NULL) ! return -1; ! } ! else #endif ! if (!PyString_Check(name)){ ! PyErr_SetString(PyExc_TypeError, ! "attribute name must be string"); ! return -1; } else --- 1132,1152 ---- int err; + if (!PyString_Check(name)){ #ifdef Py_USING_UNICODE ! /* The Unicode to string conversion is done here because the ! existing tp_setattro slots expect a string object as name ! and we wouldn't want to break those. */ ! if (PyUnicode_Check(name)) { ! name = PyUnicode_AsEncodedString(name, NULL, NULL); ! if (name == NULL) ! return -1; ! } ! else #endif ! { ! PyErr_SetString(PyExc_TypeError, ! "attribute name must be string"); ! return -1; ! } } else *************** *** 1218,1236 **** PyObject **dictptr; #ifdef Py_USING_UNICODE ! /* The Unicode to string conversion is done here because the ! existing tp_setattro slots expect a string object as name ! and we wouldn't want to break those. */ ! if (PyUnicode_Check(name)) { ! name = PyUnicode_AsEncodedString(name, NULL, NULL); ! if (name == NULL) ! return NULL; ! } ! else #endif ! if (!PyString_Check(name)){ ! PyErr_SetString(PyExc_TypeError, ! "attribute name must be string"); ! return NULL; } else --- 1222,1242 ---- PyObject **dictptr; + if (!PyString_Check(name)){ #ifdef Py_USING_UNICODE ! /* The Unicode to string conversion is done here because the ! existing tp_setattro slots expect a string object as name ! and we wouldn't want to break those. */ ! if (PyUnicode_Check(name)) { ! name = PyUnicode_AsEncodedString(name, NULL, NULL); ! if (name == NULL) ! return NULL; ! } ! else #endif ! { ! PyErr_SetString(PyExc_TypeError, ! "attribute name must be string"); ! return NULL; ! } } else *************** *** 1292,1310 **** int res = -1; #ifdef Py_USING_UNICODE ! /* The Unicode to string conversion is done here because the ! existing tp_setattro slots expect a string object as name ! and we wouldn't want to break those. */ ! if (PyUnicode_Check(name)) { ! name = PyUnicode_AsEncodedString(name, NULL, NULL); ! if (name == NULL) ! return -1; ! } ! else #endif ! if (!PyString_Check(name)){ ! PyErr_SetString(PyExc_TypeError, ! "attribute name must be string"); ! return -1; } else --- 1298,1318 ---- int res = -1; + if (!PyString_Check(name)){ #ifdef Py_USING_UNICODE ! /* The Unicode to string conversion is done here because the ! existing tp_setattro slots expect a string object as name ! and we wouldn't want to break those. */ ! if (PyUnicode_Check(name)) { ! name = PyUnicode_AsEncodedString(name, NULL, NULL); ! if (name == NULL) ! return -1; ! } ! else #endif ! { ! PyErr_SetString(PyExc_TypeError, ! "attribute name must be string"); ! return -1; ! } } else From jackjansen@users.sourceforge.net Fri Mar 15 13:47:34 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 15 Mar 2002 05:47:34 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib webbrowser.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv26704 Modified Files: webbrowser.py Log Message: If no webbrowsers were found _tryorder would be empty, cmd would never be set and the "del cmd" would fail. Fixed. 2.2.1 candidate. Index: webbrowser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/webbrowser.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** webbrowser.py 11 Feb 2002 18:11:09 -0000 1.28 --- webbrowser.py 15 Mar 2002 13:47:32 -0000 1.29 *************** *** 323,326 **** --- 323,327 ---- register(cmd.lower(), None, GenericBrowser( "%s '%%s'" % cmd.lower())) + cmd = None # to make del work if _tryorder was empty del cmd From loewis@users.sourceforge.net Fri Mar 15 13:48:23 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 15 Mar 2002 05:48:23 -0800 Subject: [Python-checkins] CVS: python/dist/src configure,1.286,1.287 configure.in,1.296,1.297 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv26788 Modified Files: configure configure.in Log Message: Patch 527434: Avoid double inclusion of thread.o on Sol2.8. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.286 retrieving revision 1.287 diff -C2 -d -r1.286 -r1.287 *** configure 12 Mar 2002 15:25:52 -0000 1.286 --- configure 15 Mar 2002 13:48:19 -0000 1.287 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.295 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.296 [...2439 lines suppressed...] if eval "test \"`echo '$''{'ac_cv_type_socklen_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < *************** *** 7598,7602 **** SRCDIRS="Parser Grammar Objects Python Modules" echo $ac_n "checking for build directories""... $ac_c" 1>&6 ! echo "configure:7601: checking for build directories" >&5 for dir in $SRCDIRS; do if test ! -d $dir; then --- 7601,7605 ---- SRCDIRS="Parser Grammar Objects Python Modules" echo $ac_n "checking for build directories""... $ac_c" 1>&6 ! echo "configure:7604: checking for build directories" >&5 for dir in $SRCDIRS; do if test ! -d $dir; then Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.296 retrieving revision 1.297 diff -C2 -d -r1.296 -r1.297 *** configure.in 12 Mar 2002 15:25:52 -0000 1.296 --- configure.in 15 Mar 2002 13:48:21 -0000 1.297 *************** *** 1134,1141 **** LIBOBJS="$LIBOBJS thread.o" USE_THREAD_MODULE=""]) ! AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD) ! LIBS="$LIBS -lthread" ! LIBOBJS="$LIBOBJS thread.o" ! USE_THREAD_MODULE=""]) if test "$USE_THREAD_MODULE" != "#" --- 1134,1144 ---- LIBOBJS="$LIBOBJS thread.o" USE_THREAD_MODULE=""]) ! ! if test $posix_threads != "yes"; then ! AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD) ! LIBS="$LIBS -lthread" ! LIBOBJS="$LIBOBJS thread.o" ! USE_THREAD_MODULE=""]) ! fi if test "$USE_THREAD_MODULE" != "#" From loewis@users.sourceforge.net Fri Mar 15 13:53:24 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 15 Mar 2002 05:53:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom minidom.py,1.43,1.43.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory usw-pr-cvs1:/tmp/cvs-serv28670 Modified Files: Tag: release22-maint minidom.py Log Message: Patch #527427: minidom fails to use NodeList sometimes. Index: minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/minidom.py,v retrieving revision 1.43 retrieving revision 1.43.6.1 diff -C2 -d -r1.43 -r1.43.6.1 *** minidom.py 6 Dec 2001 18:27:48 -0000 1.43 --- minidom.py 15 Mar 2002 13:53:20 -0000 1.43.6.1 *************** *** 585,592 **** def getElementsByTagName(self, name): ! return _getElementsByTagNameHelper(self, name, []) def getElementsByTagNameNS(self, namespaceURI, localName): ! return _getElementsByTagNameNSHelper(self, namespaceURI, localName, []) def __repr__(self): --- 585,592 ---- def getElementsByTagName(self, name): ! return _getElementsByTagNameHelper(self, name, NodeList()) def getElementsByTagNameNS(self, namespaceURI, localName): ! return _getElementsByTagNameNSHelper(self, namespaceURI, localName, NodeList()) def __repr__(self): *************** *** 933,940 **** def getElementsByTagName(self, name): ! return _getElementsByTagNameHelper(self, name, []) def getElementsByTagNameNS(self, namespaceURI, localName): ! return _getElementsByTagNameNSHelper(self, namespaceURI, localName, []) def writexml(self, writer, indent="", addindent="", newl=""): --- 933,940 ---- def getElementsByTagName(self, name): ! return _getElementsByTagNameHelper(self, name, NodeList()) def getElementsByTagNameNS(self, namespaceURI, localName): ! return _getElementsByTagNameNSHelper(self, namespaceURI, localName, NodeList()) def writexml(self, writer, indent="", addindent="", newl=""): From montanaro@users.sourceforge.net Fri Mar 15 13:52:46 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Fri, 15 Mar 2002 05:52:46 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib calendar.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv28471 Modified Files: calendar.py Log Message: Corrected _localized_name.__getitem__ based on code in patch 503202 (which I thought was just a bug report, so didn't notice - doh!). This handles slicing, which v 1.23 didn't. Index: calendar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/calendar.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** calendar.py 15 Mar 2002 04:08:38 -0000 1.23 --- calendar.py 15 Mar 2002 13:52:43 -0000 1.24 *************** *** 30,38 **** self.len = len def __getitem__(self, item): ! if item > self.len-1 or item < -self.len: ! raise IndexError ! if item < 0: ! item += self.len ! return strftime(self.format, (item,)*9).capitalize() def __len__(self): return self.len --- 30,40 ---- self.len = len def __getitem__(self, item): ! if isinstance(item, int): ! if item < 0: item += self.len ! if not 0 <= item < self.len: ! raise IndexError, "out of range" ! return strftime(self.format, (item,)*9).capitalize() ! elif isinstance(item, type(slice(0))): ! return [self[e] for e in range(self.len)].__getslice__(item.start, item.stop) def __len__(self): return self.len *************** *** 43,48 **** # Full and abbreviated names of months (1-based arrays!!!) ! month_name = _localized_name('%B', 12) ! month_abbr = _localized_name('%b', 12) # Constants for weekdays --- 45,50 ---- # Full and abbreviated names of months (1-based arrays!!!) ! month_name = _localized_name('%B', 13) ! month_abbr = _localized_name('%b', 13) # Constants for weekdays From jackjansen@users.sourceforge.net Fri Mar 15 13:50:56 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 15 Mar 2002 05:50:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_longexp.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv27686 Modified Files: test_longexp.py Log Message: Skip test_longexp for MacPython on Mac OS X. It triggers a pathological realloc slowdown. Some tests with shorter expressions lead me to the conclusion that it will eventually finish, but it may take a few weeks:-) 2.2.1 candidate. Index: test_longexp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_longexp.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_longexp.py 24 Feb 2002 05:32:32 -0000 1.4 --- test_longexp.py 15 Mar 2002 13:50:54 -0000 1.5 *************** *** 2,9 **** import sys ! from test_support import TestFailed REPS = 65580 if sys.platform == "os2emx": raise TestFailed, "OS/2+EMX port has malloc problems with long expressions" --- 2,13 ---- import sys ! from test_support import TestFailed, TestSkipped REPS = 65580 + if sys.platform == 'mac': + import gestalt + if gestalt.gestalt('sysv') > 0x9ff: + raise TestSkipped, 'Triggers pathological malloc slowdown on OSX MacPython' if sys.platform == "os2emx": raise TestFailed, "OS/2+EMX port has malloc problems with long expressions" From loewis@users.sourceforge.net Fri Mar 15 13:52:03 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 15 Mar 2002 05:52:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom minidom.py,1.43,1.44 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory usw-pr-cvs1:/tmp/cvs-serv27896 Modified Files: minidom.py Log Message: Patch #527427: minidom fails to use NodeList sometimes. Index: minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/minidom.py,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** minidom.py 6 Dec 2001 18:27:48 -0000 1.43 --- minidom.py 15 Mar 2002 13:51:59 -0000 1.44 *************** *** 45,49 **** def NodeList(): return [] ! class Node(xml.dom.Node): --- 45,49 ---- def NodeList(): return [] ! class Node(xml.dom.Node): *************** *** 585,592 **** def getElementsByTagName(self, name): ! return _getElementsByTagNameHelper(self, name, []) def getElementsByTagNameNS(self, namespaceURI, localName): ! return _getElementsByTagNameNSHelper(self, namespaceURI, localName, []) def __repr__(self): --- 585,592 ---- def getElementsByTagName(self, name): ! return _getElementsByTagNameHelper(self, name, NodeList()) def getElementsByTagNameNS(self, namespaceURI, localName): ! return _getElementsByTagNameNSHelper(self, namespaceURI, localName, NodeList()) def __repr__(self): *************** *** 933,940 **** def getElementsByTagName(self, name): ! return _getElementsByTagNameHelper(self, name, []) def getElementsByTagNameNS(self, namespaceURI, localName): ! return _getElementsByTagNameNSHelper(self, namespaceURI, localName, []) def writexml(self, writer, indent="", addindent="", newl=""): --- 933,940 ---- def getElementsByTagName(self, name): ! return _getElementsByTagNameHelper(self, name, NodeList()) def getElementsByTagNameNS(self, namespaceURI, localName): ! return _getElementsByTagNameNSHelper(self, namespaceURI, localName, NodeList()) def writexml(self, writer, indent="", addindent="", newl=""): From fdrake@users.sourceforge.net Fri Mar 15 14:37:46 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 15 Mar 2002 06:37:46 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom minidom.py,1.43.6.1,1.43.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory usw-pr-cvs1:/tmp/cvs-serv9504/xml/dom Modified Files: Tag: release22-maint minidom.py Log Message: Wrap a couple of long lines. Index: minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/minidom.py,v retrieving revision 1.43.6.1 retrieving revision 1.43.6.2 diff -C2 -d -r1.43.6.1 -r1.43.6.2 *** minidom.py 15 Mar 2002 13:53:20 -0000 1.43.6.1 --- minidom.py 15 Mar 2002 14:37:44 -0000 1.43.6.2 *************** *** 588,592 **** def getElementsByTagNameNS(self, namespaceURI, localName): ! return _getElementsByTagNameNSHelper(self, namespaceURI, localName, NodeList()) def __repr__(self): --- 588,593 ---- def getElementsByTagNameNS(self, namespaceURI, localName): ! return _getElementsByTagNameNSHelper(self, namespaceURI, localName, ! NodeList()) def __repr__(self): *************** *** 936,940 **** def getElementsByTagNameNS(self, namespaceURI, localName): ! return _getElementsByTagNameNSHelper(self, namespaceURI, localName, NodeList()) def writexml(self, writer, indent="", addindent="", newl=""): --- 937,942 ---- def getElementsByTagNameNS(self, namespaceURI, localName): ! return _getElementsByTagNameNSHelper(self, namespaceURI, localName, ! NodeList()) def writexml(self, writer, indent="", addindent="", newl=""): From fdrake@users.sourceforge.net Fri Mar 15 14:37:27 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 15 Mar 2002 06:37:27 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom minidom.py,1.44,1.45 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory usw-pr-cvs1:/tmp/cvs-serv9371/xml/dom Modified Files: minidom.py Log Message: Wrap a couple of long lines. Index: minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/minidom.py,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** minidom.py 15 Mar 2002 13:51:59 -0000 1.44 --- minidom.py 15 Mar 2002 14:37:23 -0000 1.45 *************** *** 588,592 **** def getElementsByTagNameNS(self, namespaceURI, localName): ! return _getElementsByTagNameNSHelper(self, namespaceURI, localName, NodeList()) def __repr__(self): --- 588,593 ---- def getElementsByTagNameNS(self, namespaceURI, localName): ! return _getElementsByTagNameNSHelper(self, namespaceURI, localName, ! NodeList()) def __repr__(self): *************** *** 936,940 **** def getElementsByTagNameNS(self, namespaceURI, localName): ! return _getElementsByTagNameNSHelper(self, namespaceURI, localName, NodeList()) def writexml(self, writer, indent="", addindent="", newl=""): --- 937,942 ---- def getElementsByTagNameNS(self, namespaceURI, localName): ! return _getElementsByTagNameNSHelper(self, namespaceURI, localName, ! NodeList()) def writexml(self, writer, indent="", addindent="", newl=""): From bwarsaw@users.sourceforge.net Fri Mar 15 16:46:48 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Fri, 15 Mar 2002 08:46:48 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc python-mode.el,4.6,4.7 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv11038 Modified Files: python-mode.el Log Message: (py-honor-comment-indentation, py-compute-indentation): Fix the implementation to match the documentation for py-honor-comment-indentation w.r.t. not nil or t value. In that case it should still ignore ## for indentation purposes. Closes SF bug #523825, w/ patch provided by Christian Stork (mod'd by Barry). Python 2.2.1 candidate. Index: python-mode.el =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/python-mode.el,v retrieving revision 4.6 retrieving revision 4.7 diff -C2 -d -r4.6 -r4.7 *** python-mode.el 6 Jul 2001 20:38:11 -0000 4.6 --- python-mode.el 15 Mar 2002 16:46:46 -0000 4.7 *************** *** 185,190 **** purposes. ! When not nil or t, comment lines that begin with a `#' are used as ! indentation hints, unless the comment character is in column zero." :type '(choice (const :tag "Skip all comment lines (fast)" nil) --- 185,190 ---- purposes. ! When not nil or t, comment lines that begin with a single `#' are used ! as indentation hints, unless the comment character is in column zero." :type '(choice (const :tag "Skip all comment lines (fast)" nil) *************** *** 1903,1907 **** (save-excursion (back-to-indentation) ! (not (zerop (current-column))))) )) ))) --- 1903,1911 ---- (save-excursion (back-to-indentation) ! (and (not (looking-at prefix-re)) ! (or (looking-at "[^#]") ! (not (zerop (current-column))) ! )) ! )) )) ))) From lemburg@users.sourceforge.net Fri Mar 15 17:07:14 2002 From: lemburg@users.sourceforge.net (M.-A. Lemburg) Date: Fri, 15 Mar 2002 09:07:14 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0263.txt,1.10,1.11 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv21038 Modified Files: pep-0263.txt Log Message: Changed Python's source code encoding default to ASCII. Added note about handling of Unicode literals in phase 1. Index: pep-0263.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0263.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pep-0263.txt 7 Mar 2002 11:14:26 -0000 1.10 --- pep-0263.txt 15 Mar 2002 17:07:12 -0000 1.11 *************** *** 41,48 **** Defining the Encoding ! Just as in coercion of strings to Unicode, Python will default to ! the interpreter's default encoding (which is ASCII in standard ! Python installations) as standard encoding if no other encoding ! hints are given. To define a source code encoding, a magic comment must --- 41,46 ---- Defining the Encoding ! Python will default to ASCII as standard encoding if no other ! encoding hints are given. To define a source code encoding, a magic comment must *************** *** 77,86 **** source code. ! Any encoding which allows processing the first two lines in ! the way indicated above is allowed as source code encoding, ! this includes ASCII compatible encodings as well as certain multi-byte encodings such as Shift_JIS. It does not include ! encodings which use two or more bytes for all characters ! like e.g. UTF-16. The reason for this is to keep the encoding detection algorithm in the tokenizer simple. --- 75,84 ---- source code. ! Any encoding which allows processing the first two lines in the ! way indicated above is allowed as source code encoding, this ! includes ASCII compatible encodings as well as certain multi-byte encodings such as Shift_JIS. It does not include ! encodings which use two or more bytes for all characters like ! e.g. UTF-16. The reason for this is to keep the encoding detection algorithm in the tokenizer simple. *************** *** 117,133 **** require major changes in the internals of the interpreter and enforcing the use of magic comments in source code files which ! place non-default encoding characters in string literals, comments and Unicode literals, the proposed solution should be implemented in two phases: ! 1. Implement the magic comment detection and default encoding ! handling, but only apply the detected encoding to Unicode ! literals in the source file. In addition to this step and to aid in the transition to explicit encoding declaration, the tokenizer must check the ! complete source file for compliance with the default encoding ! (which usually is ASCII). If the source file does not properly ! decode, a single warning is generated per file. 2. Change the tokenizer/compiler base string type from char* to --- 115,134 ---- require major changes in the internals of the interpreter and enforcing the use of magic comments in source code files which ! place non-ASCII characters in string literals, comments and Unicode literals, the proposed solution should be implemented in two phases: ! 1. Implement the magic comment detection, but only apply the ! detected encoding to Unicode literals in the source file. ! ! If no magic comment is used, Python should continue to ! use the standard [raw-]unicode-escape codecs for Unicode ! literals. In addition to this step and to aid in the transition to explicit encoding declaration, the tokenizer must check the ! complete source file for compliance with the declared ! encoding. If the source file does not properly decode, a single ! warning is generated per file. 2. Change the tokenizer/compiler base string type from char* to From loewis@users.sourceforge.net Fri Mar 15 17:42:19 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 15 Mar 2002 09:42:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects fileobject.c,2.146,2.147 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv10488/Objects Modified Files: fileobject.c Log Message: Patch #530105: Allow file object may to be subtyped Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.146 retrieving revision 2.147 diff -C2 -d -r2.146 -r2.147 *** fileobject.c 12 Mar 2002 03:04:44 -0000 2.146 --- fileobject.c 15 Mar 2002 17:42:16 -0000 2.147 *************** *** 39,53 **** - typedef struct { - PyObject_HEAD - FILE *f_fp; - PyObject *f_name; - PyObject *f_mode; - int (*f_close)(FILE *); - int f_softspace; /* Flag used by 'print' command */ - int f_binary; /* Flag which indicates whether the file is open - open in binary (1) or test (0) mode */ - } PyFileObject; - FILE * PyFile_AsFile(PyObject *f) --- 39,42 ---- From loewis@users.sourceforge.net Fri Mar 15 17:42:19 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 15 Mar 2002 09:42:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include fileobject.h,2.25,2.26 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv10488/Include Modified Files: fileobject.h Log Message: Patch #530105: Allow file object may to be subtyped Index: fileobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/fileobject.h,v retrieving revision 2.25 retrieving revision 2.26 diff -C2 -d -r2.25 -r2.26 *** fileobject.h 28 Nov 2001 22:13:25 -0000 2.25 --- fileobject.h 15 Mar 2002 17:42:16 -0000 2.26 *************** *** 8,11 **** --- 8,22 ---- #endif + typedef struct { + PyObject_HEAD + FILE *f_fp; + PyObject *f_name; + PyObject *f_mode; + int (*f_close)(FILE *); + int f_softspace; /* Flag used by 'print' command */ + int f_binary; /* Flag which indicates whether the file is + open in binary (1) or test (0) mode */ + } PyFileObject; + extern DL_IMPORT(PyTypeObject) PyFile_Type; From gvanrossum@users.sourceforge.net Fri Mar 15 18:14:41 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 15 Mar 2002 10:14:41 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep2html.py,1.32,1.33 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv29631 Modified Files: pep2html.py Log Message: Add -b/--browse option, which uses the webbrowser module to show the generated HTML in your browser. (The local HTML without -i, the remote HTML with -i; PEP 0 when no pep argument is given.) Fix the help text for -i (referenced sf_username which wasn't defined). Sort the files when processing all of them (glob doesn't sort, alas). Index: pep2html.py =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep2html.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** pep2html.py 1 Mar 2002 19:07:46 -0000 1.32 --- pep2html.py 15 Mar 2002 18:14:39 -0000 1.33 *************** *** 10,18 **** SF username -i/--install After generating the HTML, install it and the plain text source file (.txt) SourceForge. In that case the user's name is used in the scp ! and ssh commands, unless sf_username is given (in which case, it is ! used instead). Without -i, sf_username is ignored. -q/--quiet --- 10,25 ---- SF username + -b/--browse + After generating the HTML, direct your web browser to view it + (using the Python webbrowser module). If both -i and -b are + given, this will browse the on-line HTML; otherwise it will + browse the local HTML. If no pep arguments are given, this + will browse PEP 0. + -i/--install After generating the HTML, install it and the plain text source file (.txt) SourceForge. In that case the user's name is used in the scp ! and ssh commands, unless -u sf_username is given (in which case, it is ! used instead). Without -i, -u is ignored. -q/--quiet *************** *** 38,41 **** --- 45,49 ---- PEPURL = 'pep-%04d.html' PEPCVSURL = 'http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/nondist/peps/pep-%04d.txt' + PEPDIRRUL = 'http://www.python.org/peps/' *************** *** 255,258 **** --- 263,284 ---- + def browse_file(pep): + import webbrowser + file = find_pep(pep) + if file.endswith(".txt"): + file = file[:-3] + "html" + file = os.path.abspath(file) + url = "file:" + file + webbrowser.open(url) + + def browse_remote(pep): + import webbrowser + file = find_pep(pep) + if file.endswith(".txt"): + file = file[:-3] + "html" + url = PEPDIRRUL + file + webbrowser.open(url) + + def main(): # defaults *************** *** 260,267 **** username = '' verbose = 1 try: ! opts, args = getopt.getopt(sys.argv[1:], 'ihqu:', ! ['install', 'help', 'quiet', 'user=']) except getopt.error, msg: usage(1, msg) --- 286,295 ---- username = '' verbose = 1 + browse = 0 try: ! opts, args = getopt.getopt( ! sys.argv[1:], 'bihqu:', ! ['browse', 'install', 'help', 'quiet', 'user=']) except getopt.error, msg: usage(1, msg) *************** *** 276,279 **** --- 304,309 ---- elif opt in ('-q', '--quiet'): verbose = 0 + elif opt in ('-b', '--browse'): + browse = 1 if args: *************** *** 285,297 **** newfile = make_html(file, verbose=verbose) html.append(newfile) else: # do them all peptxt = [] ! for file in glob.glob("pep-*.txt"): peptxt.append(file) make_html(file, verbose=verbose) html = ["pep-*.html"] if update: push_pep(html, peptxt, username, verbose) --- 315,340 ---- newfile = make_html(file, verbose=verbose) html.append(newfile) + if browse and not update: + browse_file(pep) else: # do them all peptxt = [] ! files = glob.glob("pep-*.txt") ! files.sort() ! for file in files: peptxt.append(file) make_html(file, verbose=verbose) html = ["pep-*.html"] + if browse and not update: + browse_file("0") + if update: push_pep(html, peptxt, username, verbose) + if browse: + if args: + for pep in args: + browse_remote(pep) + else: + browse_remote("0") From fdrake@users.sourceforge.net Fri Mar 15 22:36:03 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 15 Mar 2002 14:36:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc Makefile.deps,1.81.4.1,1.81.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory usw-pr-cvs1:/tmp/cvs-serv5582 Modified Files: Tag: release22-maint Makefile.deps Log Message: Update to reflect changes in the extending & embedding doc. Index: Makefile.deps =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile.deps,v retrieving revision 1.81.4.1 retrieving revision 1.81.4.2 diff -C2 -d -r1.81.4.1 -r1.81.4.2 *** Makefile.deps 24 Jan 2002 16:39:26 -0000 1.81.4.1 --- Makefile.deps 15 Mar 2002 22:36:01 -0000 1.81.4.2 *************** *** 57,61 **** ext/extending.tex \ ext/newtypes.tex \ ! ext/unix.tex \ ext/windows.tex \ ext/embedding.tex \ --- 57,61 ---- ext/extending.tex \ ext/newtypes.tex \ ! ext/building.tex \ ext/windows.tex \ ext/embedding.tex \ From fdrake@users.sourceforge.net Fri Mar 15 22:36:57 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 15 Mar 2002 14:36:57 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/texinputs howto.cls,1.12,1.12.22.1 manual.cls,1.17,1.17.24.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory usw-pr-cvs1:/tmp/cvs-serv6013/texinputs Modified Files: Tag: release22-maint howto.cls manual.cls Log Message: Make the release status obvious in the title area. Index: howto.cls =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/howto.cls,v retrieving revision 1.12 retrieving revision 1.12.22.1 diff -C2 -d -r1.12 -r1.12.22.1 *** howto.cls 17 Nov 2000 19:05:12 -0000 1.12 --- howto.cls 15 Mar 2002 22:36:55 -0000 1.12.22.1 *************** *** 62,66 **** \begin{flushright} {\rm\Huge\py@HeaderFamily \@title} \par ! {\em\large\py@HeaderFamily \py@release} \par \vspace{25pt} {\Large\py@HeaderFamily \@author} \par --- 62,66 ---- \begin{flushright} {\rm\Huge\py@HeaderFamily \@title} \par ! {\em\large\py@HeaderFamily \py@release\releaseinfo} \par \vspace{25pt} {\Large\py@HeaderFamily \@author} \par Index: manual.cls =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/manual.cls,v retrieving revision 1.17 retrieving revision 1.17.24.1 diff -C2 -d -r1.17 -r1.17.24.1 *** manual.cls 5 Sep 2000 15:19:56 -0000 1.17 --- manual.cls 15 Mar 2002 22:36:55 -0000 1.17.24.1 *************** *** 76,80 **** \begin{flushright}% {\rm\Huge\py@HeaderFamily \@title \par}% ! {\em\LARGE\py@HeaderFamily \py@release \par} \vfill {\LARGE\py@HeaderFamily \@author \par} --- 76,80 ---- \begin{flushright}% {\rm\Huge\py@HeaderFamily \@title \par}% ! {\em\LARGE\py@HeaderFamily \py@release\releaseinfo \par} \vfill {\LARGE\py@HeaderFamily \@author \par} From fdrake@users.sourceforge.net Fri Mar 15 22:38:18 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 15 Mar 2002 14:38:18 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/texinputs howto.cls,1.12,1.13 manual.cls,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory usw-pr-cvs1:/tmp/cvs-serv6385/texinputs Modified Files: howto.cls manual.cls Log Message: Make the release status obvious in the title area. Index: howto.cls =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/howto.cls,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** howto.cls 17 Nov 2000 19:05:12 -0000 1.12 --- howto.cls 15 Mar 2002 22:38:16 -0000 1.13 *************** *** 62,66 **** \begin{flushright} {\rm\Huge\py@HeaderFamily \@title} \par ! {\em\large\py@HeaderFamily \py@release} \par \vspace{25pt} {\Large\py@HeaderFamily \@author} \par --- 62,66 ---- \begin{flushright} {\rm\Huge\py@HeaderFamily \@title} \par ! {\em\large\py@HeaderFamily \py@release\releaseinfo} \par \vspace{25pt} {\Large\py@HeaderFamily \@author} \par Index: manual.cls =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/manual.cls,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** manual.cls 5 Sep 2000 15:19:56 -0000 1.17 --- manual.cls 15 Mar 2002 22:38:16 -0000 1.18 *************** *** 76,80 **** \begin{flushright}% {\rm\Huge\py@HeaderFamily \@title \par}% ! {\em\LARGE\py@HeaderFamily \py@release \par} \vfill {\LARGE\py@HeaderFamily \@author \par} --- 76,80 ---- \begin{flushright}% {\rm\Huge\py@HeaderFamily \@title \par}% ! {\em\LARGE\py@HeaderFamily \py@release\releaseinfo \par} \vfill {\LARGE\py@HeaderFamily \@author \par} From fdrake@users.sourceforge.net Fri Mar 15 23:18:07 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 15 Mar 2002 15:18:07 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/perl python.perl,1.116.4.1,1.116.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/perl In directory usw-pr-cvs1:/tmp/cvs-serv19862/perl Modified Files: Tag: release22-maint python.perl Log Message: Revise the markup related to the grammar productions to increase the level of predictability. This is not really "good" markup, but is arguably better than we had before. This closes SF bug #523117. Index: python.perl =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/perl/python.perl,v retrieving revision 1.116.4.1 retrieving revision 1.116.4.2 diff -C2 -d -r1.116.4.1 -r1.116.4.2 *** python.perl 13 Mar 2002 02:45:58 -0000 1.116.4.1 --- python.perl 15 Mar 2002 23:18:05 -0000 1.116.4.2 *************** *** 806,809 **** --- 806,821 ---- } + sub do_cmd_productioncont{ + local($_) = @_; + my $defn = next_argument(); + return ("\n" + . "  \n" + . "  \n" + . " " + . translate_commands($defn) + . "" + . $_); + } + sub process_grammar_files{ my $lang; *************** *** 846,849 **** --- 858,862 ---- sub strip_grammar_markup{ local($_) = @_; + s/\\productioncont/ /g; s/\\production(<<\d+>>)(.+)\1/\n\2 ::= /g; s/\\token(<<\d+>>)(.+)\1/\2/g; From fdrake@users.sourceforge.net Fri Mar 15 23:18:07 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 15 Mar 2002 15:18:07 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/texinputs python.sty,1.88,1.88.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory usw-pr-cvs1:/tmp/cvs-serv19862/texinputs Modified Files: Tag: release22-maint python.sty Log Message: Revise the markup related to the grammar productions to increase the level of predictability. This is not really "good" markup, but is arguably better than we had before. This closes SF bug #523117. Index: python.sty =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/python.sty,v retrieving revision 1.88 retrieving revision 1.88.4.1 diff -C2 -d -r1.88 -r1.88.4.1 *** python.sty 14 Dec 2001 22:50:06 -0000 1.88 --- python.sty 15 Mar 2002 23:18:05 -0000 1.88.4.1 *************** *** 54,61 **** % this style file. \newcommand{\py@linkToName}[2]{% ! \pdfannotlink attr{/Border [0 0 0]} goto name{#1}% \py@LinkColor#2\py@NormalColor% \pdfendlink% ! } % Compute the padded page number separately since we end up with a pair of % \relax tokens; this gets the right string computed and works. --- 54,61 ---- % this style file. \newcommand{\py@linkToName}[2]{% ! \pdfstartlink attr{/Border [0 0 0]} goto name{#1}% \py@LinkColor#2\py@NormalColor% \pdfendlink% ! } % Compute the padded page number separately since we end up with a pair of % \relax tokens; this gets the right string computed and works. *************** *** 789,793 **** \ifpdf \newcommand{\url}[1]{{% ! \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}% \py@LinkColor% color of the link text \small\sf #1% --- 789,793 ---- \ifpdf \newcommand{\url}[1]{{% ! \pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}% \py@LinkColor% color of the link text \small\sf #1% *************** *** 865,871 **** \ifpdf % The \noindent here is a hack -- we're forcing pdfTeX into ! % horizontal mode since \pdfannotlink requires that. \newcommand{\ulink}[2]{\noindent{% ! \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#2)}% \py@LinkColor% color of the link text #1% --- 865,871 ---- \ifpdf % The \noindent here is a hack -- we're forcing pdfTeX into ! % horizontal mode since \pdfstartlink requires that. \newcommand{\ulink}[2]{\noindent{% ! \pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#2)}% \py@LinkColor% color of the link text #1% *************** *** 900,914 **** \def\optional##1{{\Large[}##1{\Large]}} \def\production##1##2{\code{##1}&::=&\code{##2}\\} ! \def\orgroup##1{{\def\oritem{\textbar\ }##1}} ! \def\orgroup*##1{{ ! \def\oritem{\\ \textbar&} ! % This uses math mode's ``negative thin space'' to avoid a weird ! % indentation that I've not been able to figure out, but ! % probably relates to nesting tabular environments. ! $\!\!\!\!\!\!\!\!\!\!$% ! \begin{tabular}[t]{ll} ! \ & ##1 ! \end{tabular} ! }} \def\token##1{##1} \let\grammartoken=\token --- 900,904 ---- \def\optional##1{{\Large[}##1{\Large]}} \def\production##1##2{\code{##1}&::=&\code{##2}\\} ! \def\productioncont##1{& &\code{##1}\\} \def\token##1{##1} \let\grammartoken=\token From fdrake@users.sourceforge.net Fri Mar 15 23:18:07 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 15 Mar 2002 15:18:07 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref2.tex,1.34,1.34.6.1 ref5.tex,1.53,1.53.4.1 ref6.tex,1.47,1.47.4.1 ref7.tex,1.29.8.2,1.29.8.3 refa1.tex,1.9.8.1,1.9.8.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv19862/ref Modified Files: Tag: release22-maint ref2.tex ref5.tex ref6.tex ref7.tex refa1.tex Log Message: Revise the markup related to the grammar productions to increase the level of predictability. This is not really "good" markup, but is arguably better than we had before. This closes SF bug #523117. Index: ref2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref2.tex,v retrieving revision 1.34 retrieving revision 1.34.6.1 diff -C2 -d -r1.34 -r1.34.6.1 *** ref2.tex 11 Dec 2001 17:46:38 -0000 1.34 --- ref2.tex 15 Mar 2002 23:18:05 -0000 1.34.6.1 *************** *** 319,324 **** | '"' \token{shortstringitem}* '"'} \production{longstring} ! {"'''" \token{longstringitem}* "'''" ! | '"""' \token{longstringitem}* '"""'} \production{shortstringitem} {\token{shortstringchar} | \token{escapeseq}} --- 319,324 ---- | '"' \token{shortstringitem}* '"'} \production{longstring} ! {"'''" \token{longstringitem}* "'''"} ! \productioncont{| '"""' \token{longstringitem}* '"""'} \production{shortstringitem} {\token{shortstringchar} | \token{escapeseq}} Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.53 retrieving revision 1.53.4.1 diff -C2 -d -r1.53 -r1.53.4.1 *** ref5.tex 14 Dec 2001 16:57:31 -0000 1.53 --- ref5.tex 15 Mar 2002 23:18:05 -0000 1.53.4.1 *************** *** 55,60 **** {\token{identifier} | \token{literal} | \token{enclosure}} \production{enclosure} ! {\token{parenth_form} | \token{list_display} ! | \token{dict_display} | \token{string_conversion}} \end{productionlist} --- 55,60 ---- {\token{identifier} | \token{literal} | \token{enclosure}} \production{enclosure} ! {\token{parenth_form} | \token{list_display}} ! \productioncont{| \token{dict_display} | \token{string_conversion}} \end{productionlist} *************** *** 113,119 **** \begin{productionlist} \production{literal} ! {\token{stringliteral} | \token{integer} ! | \token{longinteger} | \token{floatnumber} ! | \token{imagnumber}} \end{productionlist} --- 113,118 ---- \begin{productionlist} \production{literal} ! {\token{stringliteral} | \token{integer} | \token{longinteger}} ! \productioncont{| \token{floatnumber} | \token{imagnumber}} \end{productionlist} *************** *** 440,450 **** {\token{primary} "(" [\token{argument_list} [","]] ")"} \production{argument_list} ! {\token{positional_arguments} ["," \token{keyword_arguments} ! ["," "*" \token{expression} ["," "**" \token{expression}]]] ! | \token{keyword_arguments} ["," "*" \token{expression} ! ["," "**" \token{expression}]] ! | "*" \token{expression} ["," "**" \token{expression}] ! | "**" \token{expression} ! } \production{positional_arguments} {\token{expression} ("," \token{expression})*} --- 439,448 ---- {\token{primary} "(" [\token{argument_list} [","]] ")"} \production{argument_list} ! {\token{positional_arguments} ["," \token{keyword_arguments}} ! \productioncont{ ["," "*" \token{expression} ["," "**" \token{expression}]]]} ! \productioncont{| \token{keyword_arguments} ["," "*" \token{expression}} ! \productioncont{ ["," "**" \token{expression}]]} ! \productioncont{| "*" \token{expression} ["," "**" \token{expression}]} ! \productioncont{| "**" \token{expression}} \production{positional_arguments} {\token{expression} ("," \token{expression})*} *************** *** 667,672 **** \production{m_expr} {\token{u_expr} | \token{m_expr} "*" \token{u_expr} ! | \token{m_expr} "/" \token{u_expr} ! | \token{m_expr} "\%" \token{u_expr}} \production{a_expr} {\token{m_expr} | \token{aexpr} "+" \token{m_expr} --- 665,670 ---- \production{m_expr} {\token{u_expr} | \token{m_expr} "*" \token{u_expr} ! | \token{m_expr} "/" \token{u_expr}} ! \productioncont{| \token{m_expr} "\%" \token{u_expr}} \production{a_expr} {\token{m_expr} | \token{aexpr} "+" \token{m_expr} *************** *** 802,807 **** {\token{or_expr} ( \token{comp_operator} \token{or_expr} )*} \production{comp_operator} ! {"<" | ">" | "==" | ">=" | "<=" | "<>" | "!=" ! | "is" ["not"] | ["not"] "in"} \end{productionlist} --- 800,805 ---- {\token{or_expr} ( \token{comp_operator} \token{or_expr} )*} \production{comp_operator} ! {"<" | ">" | "==" | ">=" | "<=" | "<>" | "!="} ! \productioncont{| "is" ["not"] | ["not"] "in"} \end{productionlist} Index: ref6.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref6.tex,v retrieving revision 1.47 retrieving revision 1.47.4.1 diff -C2 -d -r1.47 -r1.47.4.1 *** ref6.tex 14 Dec 2001 22:55:14 -0000 1.47 --- ref6.tex 15 Mar 2002 23:18:05 -0000 1.47.4.1 *************** *** 7,26 **** \begin{productionlist} ! \production{simple_stmt} ! {\token{expression_stmt} ! | \token{assert_stmt} ! | \token{assignment_stmt} ! | \token{augmented_assignment_stmt} ! | \token{pass_stmt} ! | \token{del_stmt} ! | \token{print_stmt} ! | \token{return_stmt} ! | \token{yield_stmt} ! | \token{raise_stmt} ! | \token{break_stmt} ! | \token{continue_stmt} ! | \token{import_stmt} ! | \token{global_stmt} ! | \token{exec_stmt}} \end{productionlist} --- 7,25 ---- \begin{productionlist} ! \production{simple_stmt}{\token{expression_stmt}} ! \productioncont{| \token{assert_stmt}} ! \productioncont{| \token{assignment_stmt}} ! \productioncont{| \token{augmented_assignment_stmt}} ! \productioncont{| \token{pass_stmt}} ! \productioncont{| \token{del_stmt}} ! \productioncont{| \token{print_stmt}} ! \productioncont{| \token{return_stmt}} ! \productioncont{| \token{yield_stmt}} ! \productioncont{| \token{raise_stmt}} ! \productioncont{| \token{break_stmt}} ! \productioncont{| \token{continue_stmt}} ! \productioncont{| \token{import_stmt}} ! \productioncont{| \token{global_stmt}} ! \productioncont{| \token{exec_stmt}} \end{productionlist} *************** *** 113,122 **** {\token{target} ("," \token{target})* [","]} \production{target} ! {\token{identifier} ! | "(" \token{target_list} ")" ! | "[" \token{target_list} "]" ! | \token{attributeref} ! | \token{subscription} ! | \token{slicing}} \end{productionlist} --- 112,121 ---- {\token{target} ("," \token{target})* [","]} \production{target} ! {\token{identifier}} ! \productioncont{| "(" \token{target_list} ")"} ! \productioncont{| "[" \token{target_list} "]"} ! \productioncont{| \token{attributeref}} ! \productioncont{| \token{subscription}} ! \productioncont{| \token{slicing}} \end{productionlist} *************** *** 265,269 **** ! \subsection{Augmented Assignment statements \label{augassign}} Augmented assignment is the combination, in a single statement, of a binary --- 264,268 ---- ! \subsection{Augmented assignment statements \label{augassign}} Augmented assignment is the combination, in a single statement, of a binary *************** *** 276,288 **** {\token{target} \token{augop} \token{expression_list}} \production{augop} ! {"+=" | "-=" | "*=" | "/=" | "\%=" | "**=" ! | ">>=" | "<<=" | "\&=" | "\textasciicircum=" | "|="} ! \production{target} ! {\token{identifier} ! | "(" \token{target_list} ")" ! | "[" \token{target_list} "]" ! | \token{attributeref} ! | \token{subscription} ! | \token{slicing}} \end{productionlist} --- 275,280 ---- {\token{target} \token{augop} \token{expression_list}} \production{augop} ! {"+=" | "-=" | "*=" | "/=" | "\%=" | "**="} ! \productioncont{| ">>=" | "<<=" | "\&=" | "\textasciicircum=" | "|="} \end{productionlist} *************** *** 365,371 **** \begin{productionlist} \production{print_stmt} ! {"print" ( \optional{\token{expression} ("," \token{expression})* \optional{","}} ! | ">\code{>}" \token{expression} ! \optional{("," \token{expression})+ \optional{","}})} \end{productionlist} --- 357,363 ---- \begin{productionlist} \production{print_stmt} ! {"print" ( \optional{\token{expression} ("," \token{expression})* \optional{","}}} ! \productioncont{| ">\code{>}" \token{expression} ! \optional{("," \token{expression})+ \optional{","}} )} \end{productionlist} *************** *** 601,609 **** \production{import_stmt} {"import" \token{module} ["as" \token{name}] ! ( "," \token{module} ["as" \token{name}] )* ! | "from" \token{module} "import" \token{identifier} ! ["as" \token{name}] ! ( "," \token{identifier} ["as" \token{name}] )* ! | "from" \token{module} "import" "*"} \production{module} {(\token{identifier} ".")* \token{identifier}} --- 593,601 ---- \production{import_stmt} {"import" \token{module} ["as" \token{name}] ! ( "," \token{module} ["as" \token{name}] )*} ! \productioncont{| "from" \token{module} "import" \token{identifier} ! ["as" \token{name}]} ! \productioncont{ ( "," \token{identifier} ["as" \token{name}] )*} ! \productioncont{| "from" \token{module} "import" "*"} \production{module} {(\token{identifier} ".")* \token{identifier}} Index: ref7.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref7.tex,v retrieving revision 1.29.8.2 retrieving revision 1.29.8.3 diff -C2 -d -r1.29.8.2 -r1.29.8.3 *** ref7.tex 22 Feb 2002 15:40:45 -0000 1.29.8.2 --- ref7.tex 15 Mar 2002 23:18:05 -0000 1.29.8.3 *************** *** 43,48 **** \begin{productionlist} \production{compound_stmt} ! {\token{if_stmt} | \token{while_stmt} | \token{for_stmt} ! | \token{try_stmt} | \token{funcdef} | \token{classdef}} \production{suite} {\token{stmt_list} NEWLINE --- 43,52 ---- \begin{productionlist} \production{compound_stmt} ! {\token{if_stmt}} ! \productioncont{| \token{while_stmt}} ! \productioncont{| \token{for_stmt}} ! \productioncont{| \token{try_stmt}} ! \productioncont{| \token{funcdef}} ! \productioncont{| \token{classdef}} \production{suite} {\token{stmt_list} NEWLINE *************** *** 74,80 **** \begin{productionlist} \production{if_stmt} ! {"if" \token{expression} ":" \token{suite} ! ( "elif" \token{expression} ":" \token{suite} )* ! ["else" ":" \token{suite}]} \end{productionlist} --- 78,84 ---- \begin{productionlist} \production{if_stmt} ! {"if" \token{expression} ":" \token{suite}} ! \productioncont{( "elif" \token{expression} ":" \token{suite} )*} ! \productioncont{["else" ":" \token{suite}]} \end{productionlist} *************** *** 98,103 **** \begin{productionlist} \production{while_stmt} ! {"while" \token{expression} ":" \token{suite} ! ["else" ":" \token{suite}]} \end{productionlist} --- 102,107 ---- \begin{productionlist} \production{while_stmt} ! {"while" \token{expression} ":" \token{suite}} ! \productioncont{["else" ":" \token{suite}]} \end{productionlist} *************** *** 127,132 **** \production{for_stmt} {"for" \token{target_list} "in" \token{expression_list} ! ":" \token{suite} ! ["else" ":" \token{suite}]} \end{productionlist} --- 131,136 ---- \production{for_stmt} {"for" \token{target_list} "in" \token{expression_list} ! ":" \token{suite}} ! \productioncont{["else" ":" \token{suite}]} \end{productionlist} *************** *** 193,200 **** {\token{try_exc_stmt} | \token{try_fin_stmt}} \production{try_exc_stmt} ! {"try" ":" \token{suite} ! ("except" [\token{expression} ["," \token{target}]] ":" ! \token{suite})+ ! ["else" ":" \token{suite}]} \production{try_fin_stmt} {"try" ":" \token{suite} --- 197,204 ---- {\token{try_exc_stmt} | \token{try_fin_stmt}} \production{try_exc_stmt} ! {"try" ":" \token{suite}} ! \productioncont{("except" [\token{expression} ! ["," \token{target}]] ":" \token{suite})+} ! \productioncont{["else" ":" \token{suite}]} \production{try_fin_stmt} {"try" ":" \token{suite} *************** *** 311,318 **** ":" \token{suite}} \production{parameter_list} ! {(\token{defparameter} ",")* ! ("*" \token{identifier} [, "**" \token{identifier}] ! | "**" \token{identifier} ! | \token{defparameter} [","])} \production{defparameter} {\token{parameter} ["=" \token{expression}]} --- 315,322 ---- ":" \token{suite}} \production{parameter_list} ! {(\token{defparameter} ",")*} ! \productioncont{("*" \token{identifier} [, "**" \token{identifier}]} ! \productioncont{| "**" \token{identifier} ! | \token{defparameter} [","])} \production{defparameter} {\token{parameter} ["=" \token{expression}]} Index: refa1.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/refa1.tex,v retrieving revision 1.9.8.1 retrieving revision 1.9.8.2 diff -C2 -d -r1.9.8.1 -r1.9.8.2 *** refa1.tex 21 Jan 2002 16:09:42 -0000 1.9.8.1 --- refa1.tex 15 Mar 2002 23:18:05 -0000 1.9.8.2 *************** *** 21,31 **** before the release in which the feature becomes standard. ! \begin{verbatim} ! future_statement: "from" "__future__" "import" feature ["as" name] ! ("," feature ["as" name])* ! ! feature: identifier ! name: identifier ! \end{verbatim} A future statement must appear near the top of the module. The only --- 21,31 ---- before the release in which the feature becomes standard. ! \begin{productionlist}[*] ! \production{future_statement} ! {"from" "__future__" "import" feature ["as" name]} ! \productioncont{("," feature ["as" name])*} ! \production{feature}{identifier} ! \production{name}{identifier} ! \end{productionlist} A future statement must appear near the top of the module. The only From fdrake@users.sourceforge.net Fri Mar 15 23:21:39 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 15 Mar 2002 15:21:39 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/perl python.perl,1.118,1.119 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/perl In directory usw-pr-cvs1:/tmp/cvs-serv21631/perl Modified Files: python.perl Log Message: Revise the markup related to the grammar productions to increase the level of predictability. This is not really "good" markup, but is arguably better than we had before. This closes SF bug #523117. Index: python.perl =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/perl/python.perl,v retrieving revision 1.118 retrieving revision 1.119 diff -C2 -d -r1.118 -r1.119 *** python.perl 13 Mar 2002 02:44:50 -0000 1.118 --- python.perl 15 Mar 2002 23:21:37 -0000 1.119 *************** *** 808,811 **** --- 808,823 ---- } + sub do_cmd_productioncont{ + local($_) = @_; + my $defn = next_argument(); + return ("\n" + . "  \n" + . "  \n" + . " " + . translate_commands($defn) + . "" + . $_); + } + sub process_grammar_files{ my $lang; *************** *** 848,851 **** --- 860,864 ---- sub strip_grammar_markup{ local($_) = @_; + s/\\productioncont/ /g; s/\\production(<<\d+>>)(.+)\1/\n\2 ::= /g; s/\\token(<<\d+>>)(.+)\1/\2/g; From fdrake@users.sourceforge.net Fri Mar 15 23:21:39 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 15 Mar 2002 15:21:39 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref2.tex,1.34,1.35 ref5.tex,1.53,1.54 ref6.tex,1.47,1.48 ref7.tex,1.31,1.32 refa1.tex,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv21631/ref Modified Files: ref2.tex ref5.tex ref6.tex ref7.tex refa1.tex Log Message: Revise the markup related to the grammar productions to increase the level of predictability. This is not really "good" markup, but is arguably better than we had before. This closes SF bug #523117. Index: ref2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref2.tex,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** ref2.tex 11 Dec 2001 17:46:38 -0000 1.34 --- ref2.tex 15 Mar 2002 23:21:37 -0000 1.35 *************** *** 319,324 **** | '"' \token{shortstringitem}* '"'} \production{longstring} ! {"'''" \token{longstringitem}* "'''" ! | '"""' \token{longstringitem}* '"""'} \production{shortstringitem} {\token{shortstringchar} | \token{escapeseq}} --- 319,324 ---- | '"' \token{shortstringitem}* '"'} \production{longstring} ! {"'''" \token{longstringitem}* "'''"} ! \productioncont{| '"""' \token{longstringitem}* '"""'} \production{shortstringitem} {\token{shortstringchar} | \token{escapeseq}} Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** ref5.tex 14 Dec 2001 16:57:31 -0000 1.53 --- ref5.tex 15 Mar 2002 23:21:37 -0000 1.54 *************** *** 55,60 **** {\token{identifier} | \token{literal} | \token{enclosure}} \production{enclosure} ! {\token{parenth_form} | \token{list_display} ! | \token{dict_display} | \token{string_conversion}} \end{productionlist} --- 55,60 ---- {\token{identifier} | \token{literal} | \token{enclosure}} \production{enclosure} ! {\token{parenth_form} | \token{list_display}} ! \productioncont{| \token{dict_display} | \token{string_conversion}} \end{productionlist} *************** *** 113,119 **** \begin{productionlist} \production{literal} ! {\token{stringliteral} | \token{integer} ! | \token{longinteger} | \token{floatnumber} ! | \token{imagnumber}} \end{productionlist} --- 113,118 ---- \begin{productionlist} \production{literal} ! {\token{stringliteral} | \token{integer} | \token{longinteger}} ! \productioncont{| \token{floatnumber} | \token{imagnumber}} \end{productionlist} *************** *** 440,450 **** {\token{primary} "(" [\token{argument_list} [","]] ")"} \production{argument_list} ! {\token{positional_arguments} ["," \token{keyword_arguments} ! ["," "*" \token{expression} ["," "**" \token{expression}]]] ! | \token{keyword_arguments} ["," "*" \token{expression} ! ["," "**" \token{expression}]] ! | "*" \token{expression} ["," "**" \token{expression}] ! | "**" \token{expression} ! } \production{positional_arguments} {\token{expression} ("," \token{expression})*} --- 439,448 ---- {\token{primary} "(" [\token{argument_list} [","]] ")"} \production{argument_list} ! {\token{positional_arguments} ["," \token{keyword_arguments}} ! \productioncont{ ["," "*" \token{expression} ["," "**" \token{expression}]]]} ! \productioncont{| \token{keyword_arguments} ["," "*" \token{expression}} ! \productioncont{ ["," "**" \token{expression}]]} ! \productioncont{| "*" \token{expression} ["," "**" \token{expression}]} ! \productioncont{| "**" \token{expression}} \production{positional_arguments} {\token{expression} ("," \token{expression})*} *************** *** 667,672 **** \production{m_expr} {\token{u_expr} | \token{m_expr} "*" \token{u_expr} ! | \token{m_expr} "/" \token{u_expr} ! | \token{m_expr} "\%" \token{u_expr}} \production{a_expr} {\token{m_expr} | \token{aexpr} "+" \token{m_expr} --- 665,670 ---- \production{m_expr} {\token{u_expr} | \token{m_expr} "*" \token{u_expr} ! | \token{m_expr} "/" \token{u_expr}} ! \productioncont{| \token{m_expr} "\%" \token{u_expr}} \production{a_expr} {\token{m_expr} | \token{aexpr} "+" \token{m_expr} *************** *** 802,807 **** {\token{or_expr} ( \token{comp_operator} \token{or_expr} )*} \production{comp_operator} ! {"<" | ">" | "==" | ">=" | "<=" | "<>" | "!=" ! | "is" ["not"] | ["not"] "in"} \end{productionlist} --- 800,805 ---- {\token{or_expr} ( \token{comp_operator} \token{or_expr} )*} \production{comp_operator} ! {"<" | ">" | "==" | ">=" | "<=" | "<>" | "!="} ! \productioncont{| "is" ["not"] | ["not"] "in"} \end{productionlist} Index: ref6.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref6.tex,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** ref6.tex 14 Dec 2001 22:55:14 -0000 1.47 --- ref6.tex 15 Mar 2002 23:21:37 -0000 1.48 *************** *** 7,26 **** \begin{productionlist} ! \production{simple_stmt} ! {\token{expression_stmt} ! | \token{assert_stmt} ! | \token{assignment_stmt} ! | \token{augmented_assignment_stmt} ! | \token{pass_stmt} ! | \token{del_stmt} ! | \token{print_stmt} ! | \token{return_stmt} ! | \token{yield_stmt} ! | \token{raise_stmt} ! | \token{break_stmt} ! | \token{continue_stmt} ! | \token{import_stmt} ! | \token{global_stmt} ! | \token{exec_stmt}} \end{productionlist} --- 7,25 ---- \begin{productionlist} ! \production{simple_stmt}{\token{expression_stmt}} ! \productioncont{| \token{assert_stmt}} ! \productioncont{| \token{assignment_stmt}} ! \productioncont{| \token{augmented_assignment_stmt}} ! \productioncont{| \token{pass_stmt}} ! \productioncont{| \token{del_stmt}} ! \productioncont{| \token{print_stmt}} ! \productioncont{| \token{return_stmt}} ! \productioncont{| \token{yield_stmt}} ! \productioncont{| \token{raise_stmt}} ! \productioncont{| \token{break_stmt}} ! \productioncont{| \token{continue_stmt}} ! \productioncont{| \token{import_stmt}} ! \productioncont{| \token{global_stmt}} ! \productioncont{| \token{exec_stmt}} \end{productionlist} *************** *** 113,122 **** {\token{target} ("," \token{target})* [","]} \production{target} ! {\token{identifier} ! | "(" \token{target_list} ")" ! | "[" \token{target_list} "]" ! | \token{attributeref} ! | \token{subscription} ! | \token{slicing}} \end{productionlist} --- 112,121 ---- {\token{target} ("," \token{target})* [","]} \production{target} ! {\token{identifier}} ! \productioncont{| "(" \token{target_list} ")"} ! \productioncont{| "[" \token{target_list} "]"} ! \productioncont{| \token{attributeref}} ! \productioncont{| \token{subscription}} ! \productioncont{| \token{slicing}} \end{productionlist} *************** *** 265,269 **** ! \subsection{Augmented Assignment statements \label{augassign}} Augmented assignment is the combination, in a single statement, of a binary --- 264,268 ---- ! \subsection{Augmented assignment statements \label{augassign}} Augmented assignment is the combination, in a single statement, of a binary *************** *** 276,288 **** {\token{target} \token{augop} \token{expression_list}} \production{augop} ! {"+=" | "-=" | "*=" | "/=" | "\%=" | "**=" ! | ">>=" | "<<=" | "\&=" | "\textasciicircum=" | "|="} ! \production{target} ! {\token{identifier} ! | "(" \token{target_list} ")" ! | "[" \token{target_list} "]" ! | \token{attributeref} ! | \token{subscription} ! | \token{slicing}} \end{productionlist} --- 275,280 ---- {\token{target} \token{augop} \token{expression_list}} \production{augop} ! {"+=" | "-=" | "*=" | "/=" | "\%=" | "**="} ! \productioncont{| ">>=" | "<<=" | "\&=" | "\textasciicircum=" | "|="} \end{productionlist} *************** *** 365,371 **** \begin{productionlist} \production{print_stmt} ! {"print" ( \optional{\token{expression} ("," \token{expression})* \optional{","}} ! | ">\code{>}" \token{expression} ! \optional{("," \token{expression})+ \optional{","}})} \end{productionlist} --- 357,363 ---- \begin{productionlist} \production{print_stmt} ! {"print" ( \optional{\token{expression} ("," \token{expression})* \optional{","}}} ! \productioncont{| ">\code{>}" \token{expression} ! \optional{("," \token{expression})+ \optional{","}} )} \end{productionlist} *************** *** 601,609 **** \production{import_stmt} {"import" \token{module} ["as" \token{name}] ! ( "," \token{module} ["as" \token{name}] )* ! | "from" \token{module} "import" \token{identifier} ! ["as" \token{name}] ! ( "," \token{identifier} ["as" \token{name}] )* ! | "from" \token{module} "import" "*"} \production{module} {(\token{identifier} ".")* \token{identifier}} --- 593,601 ---- \production{import_stmt} {"import" \token{module} ["as" \token{name}] ! ( "," \token{module} ["as" \token{name}] )*} ! \productioncont{| "from" \token{module} "import" \token{identifier} ! ["as" \token{name}]} ! \productioncont{ ( "," \token{identifier} ["as" \token{name}] )*} ! \productioncont{| "from" \token{module} "import" "*"} \production{module} {(\token{identifier} ".")* \token{identifier}} Index: ref7.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref7.tex,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** ref7.tex 22 Feb 2002 15:40:23 -0000 1.31 --- ref7.tex 15 Mar 2002 23:21:37 -0000 1.32 *************** *** 43,48 **** \begin{productionlist} \production{compound_stmt} ! {\token{if_stmt} | \token{while_stmt} | \token{for_stmt} ! | \token{try_stmt} | \token{funcdef} | \token{classdef}} \production{suite} {\token{stmt_list} NEWLINE --- 43,52 ---- \begin{productionlist} \production{compound_stmt} ! {\token{if_stmt}} ! \productioncont{| \token{while_stmt}} ! \productioncont{| \token{for_stmt}} ! \productioncont{| \token{try_stmt}} ! \productioncont{| \token{funcdef}} ! \productioncont{| \token{classdef}} \production{suite} {\token{stmt_list} NEWLINE *************** *** 74,80 **** \begin{productionlist} \production{if_stmt} ! {"if" \token{expression} ":" \token{suite} ! ( "elif" \token{expression} ":" \token{suite} )* ! ["else" ":" \token{suite}]} \end{productionlist} --- 78,84 ---- \begin{productionlist} \production{if_stmt} ! {"if" \token{expression} ":" \token{suite}} ! \productioncont{( "elif" \token{expression} ":" \token{suite} )*} ! \productioncont{["else" ":" \token{suite}]} \end{productionlist} *************** *** 98,103 **** \begin{productionlist} \production{while_stmt} ! {"while" \token{expression} ":" \token{suite} ! ["else" ":" \token{suite}]} \end{productionlist} --- 102,107 ---- \begin{productionlist} \production{while_stmt} ! {"while" \token{expression} ":" \token{suite}} ! \productioncont{["else" ":" \token{suite}]} \end{productionlist} *************** *** 127,132 **** \production{for_stmt} {"for" \token{target_list} "in" \token{expression_list} ! ":" \token{suite} ! ["else" ":" \token{suite}]} \end{productionlist} --- 131,136 ---- \production{for_stmt} {"for" \token{target_list} "in" \token{expression_list} ! ":" \token{suite}} ! \productioncont{["else" ":" \token{suite}]} \end{productionlist} *************** *** 193,200 **** {\token{try_exc_stmt} | \token{try_fin_stmt}} \production{try_exc_stmt} ! {"try" ":" \token{suite} ! ("except" [\token{expression} ["," \token{target}]] ":" ! \token{suite})+ ! ["else" ":" \token{suite}]} \production{try_fin_stmt} {"try" ":" \token{suite} --- 197,204 ---- {\token{try_exc_stmt} | \token{try_fin_stmt}} \production{try_exc_stmt} ! {"try" ":" \token{suite}} ! \productioncont{("except" [\token{expression} ! ["," \token{target}]] ":" \token{suite})+} ! \productioncont{["else" ":" \token{suite}]} \production{try_fin_stmt} {"try" ":" \token{suite} *************** *** 311,318 **** ":" \token{suite}} \production{parameter_list} ! {(\token{defparameter} ",")* ! ("*" \token{identifier} [, "**" \token{identifier}] ! | "**" \token{identifier} ! | \token{defparameter} [","])} \production{defparameter} {\token{parameter} ["=" \token{expression}]} --- 315,322 ---- ":" \token{suite}} \production{parameter_list} ! {(\token{defparameter} ",")*} ! \productioncont{("*" \token{identifier} [, "**" \token{identifier}]} ! \productioncont{| "**" \token{identifier} ! | \token{defparameter} [","])} \production{defparameter} {\token{parameter} ["=" \token{expression}]} Index: refa1.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/refa1.tex,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** refa1.tex 21 Jan 2002 16:09:18 -0000 1.10 --- refa1.tex 15 Mar 2002 23:21:37 -0000 1.11 *************** *** 21,31 **** before the release in which the feature becomes standard. ! \begin{verbatim} ! future_statement: "from" "__future__" "import" feature ["as" name] ! ("," feature ["as" name])* ! ! feature: identifier ! name: identifier ! \end{verbatim} A future statement must appear near the top of the module. The only --- 21,31 ---- before the release in which the feature becomes standard. ! \begin{productionlist}[*] ! \production{future_statement} ! {"from" "__future__" "import" feature ["as" name]} ! \productioncont{("," feature ["as" name])*} ! \production{feature}{identifier} ! \production{name}{identifier} ! \end{productionlist} A future statement must appear near the top of the module. The only From fdrake@users.sourceforge.net Fri Mar 15 23:21:39 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 15 Mar 2002 15:21:39 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/texinputs python.sty,1.88,1.89 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory usw-pr-cvs1:/tmp/cvs-serv21631/texinputs Modified Files: python.sty Log Message: Revise the markup related to the grammar productions to increase the level of predictability. This is not really "good" markup, but is arguably better than we had before. This closes SF bug #523117. Index: python.sty =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/python.sty,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -d -r1.88 -r1.89 *** python.sty 14 Dec 2001 22:50:06 -0000 1.88 --- python.sty 15 Mar 2002 23:21:37 -0000 1.89 *************** *** 54,61 **** % this style file. \newcommand{\py@linkToName}[2]{% ! \pdfannotlink attr{/Border [0 0 0]} goto name{#1}% \py@LinkColor#2\py@NormalColor% \pdfendlink% ! } % Compute the padded page number separately since we end up with a pair of % \relax tokens; this gets the right string computed and works. --- 54,61 ---- % this style file. \newcommand{\py@linkToName}[2]{% ! \pdfstartlink attr{/Border [0 0 0]} goto name{#1}% \py@LinkColor#2\py@NormalColor% \pdfendlink% ! } % Compute the padded page number separately since we end up with a pair of % \relax tokens; this gets the right string computed and works. *************** *** 789,793 **** \ifpdf \newcommand{\url}[1]{{% ! \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}% \py@LinkColor% color of the link text \small\sf #1% --- 789,793 ---- \ifpdf \newcommand{\url}[1]{{% ! \pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}% \py@LinkColor% color of the link text \small\sf #1% *************** *** 865,871 **** \ifpdf % The \noindent here is a hack -- we're forcing pdfTeX into ! % horizontal mode since \pdfannotlink requires that. \newcommand{\ulink}[2]{\noindent{% ! \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#2)}% \py@LinkColor% color of the link text #1% --- 865,871 ---- \ifpdf % The \noindent here is a hack -- we're forcing pdfTeX into ! % horizontal mode since \pdfstartlink requires that. \newcommand{\ulink}[2]{\noindent{% ! \pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#2)}% \py@LinkColor% color of the link text #1% *************** *** 900,914 **** \def\optional##1{{\Large[}##1{\Large]}} \def\production##1##2{\code{##1}&::=&\code{##2}\\} ! \def\orgroup##1{{\def\oritem{\textbar\ }##1}} ! \def\orgroup*##1{{ ! \def\oritem{\\ \textbar&} ! % This uses math mode's ``negative thin space'' to avoid a weird ! % indentation that I've not been able to figure out, but ! % probably relates to nesting tabular environments. ! $\!\!\!\!\!\!\!\!\!\!$% ! \begin{tabular}[t]{ll} ! \ & ##1 ! \end{tabular} ! }} \def\token##1{##1} \let\grammartoken=\token --- 900,904 ---- \def\optional##1{{\Large[}##1{\Large]}} \def\production##1##2{\code{##1}&::=&\code{##2}\\} ! \def\productioncont##1{& &\code{##1}\\} \def\token##1{##1} \let\grammartoken=\token From jackjansen@users.sourceforge.net Sat Mar 16 00:34:06 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 15 Mar 2002 16:34:06 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/OSXResources/iconsrc PythonApplet.psd,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSXResources/iconsrc In directory usw-pr-cvs1:/tmp/cvs-serv23618/Python/Mac/OSXResources/iconsrc Added Files: PythonApplet.psd Log Message: Applet icon. --- NEW FILE: PythonApplet.psd --- 8BPS         ÿÀ   ™í÷Xÿ ?óÞ#ï )Ãé^ö<ò»^•Ô=f t¬šþ¢½†C¿µð:¸±îá%; 2%aõ~¿{sѺ%C7«Z%âbº+®¿&ÏsYü†ê›kßÔºZ¹ý'êÛöVó7«ó]Có«Äÿ ¦ÑHÛ]l  ª ³8BIMnormÿ # $ óòóóòóµR #Øñòýñÿòñòññòò #Ôôóóôôóôýó ôóóôóôôóôóþôóôôóëôõôôã>& +=ùÿþÿk%'  æååæåæååæååüæåææåå÷æ # $ #Ùòñòñòñýòýñîò òóòóóòóO #Ôüóôóóôóóýôóôóóúô ôõôõôôã?& ÷øø÷ø÷à; üýüüýü÷:' +=ùÿþÿk$'  ãâããââãâÜ>EêÿêÿE>àúâ ãââãâãââãââûãÿâãââãâããâñãäão* # $ òñòññòçA #Øñòòýñ #Ôüóôóôþó ôóóôôóóôôóóôôþóýôþóöô õôôõôõõôã?& ýüüýýü÷:' +=úÿþÿk%'  Ô6 ÞN ìo máìÿ ü±.mͪ™ê 8íçÿ¡ !)28>CFFEA<5/& å ì í ñ ò ž ž ž ž ž ÷ÿ™çÿÑÿ›ÿÿ•—þÿžœ”ýÿ 2,)ÿÿ˜š˜š™™êÿýÿÿ 23,ÿÿ™™›ž—šêÿþÿþ 210ÿÿ™™šœ˜šêÿþÿþ 211ÿ›˜›š™™êÿþÿþ šã(43¨Ýà¡CùR¬Ð7(í•)434+êÿ GEAJILIKLKKþLMLLMLýMþLÿMLKKMþLÿJI?: 3FHIFLJJIKLKöLÿM÷LÿK JKKMKHJ<4/ïÿúÿý ù GEAJILIKLKKþLMLLMLýMþLÿMLKKMþLÿJI?: 3FHIFLJJIKLKöLÿM÷LÿK JKKMKHJ<4/ïÿúÿý fgÿffÿÿ š™šð™ š™š› ÿefeeffêÿÿÿý GEAJILIKLKKþLMLLMLýMþLÿMLKKMþLÿJI?: 3FHIFLJJIKLKöLÿM÷LÿK JKKMKHJ<4/ïÿúÿý ™Ûÿº›…RÚË5ù301432ü3 UÔýÿÿÙöÿÞâàÿ÷ÿþþ×ÿ šáÿ³˜—ÛÛÄ}4û3433234û3 MÀûÿÿÀ™õþËÑàÿ÷ÿÿþ A¥òþÿÀ˜ôý¨±àÿ÷ÿÿþ Õz™ÄܳžÝݸaì3 8©ñÿÏšöÿÎÒàÿøÿÿþÿýÚÿ ®HÝ™ÄÞ½ªÝÖ“Fì3 4qÙþÜ«úþ»ÂàÿøÿÿþÿýÜÿ úuhÝÝ™ÂÞÐÅÞÈWë3 23­óî×ýý¤­àÿùÿþþÿýÝÿß•¨þÞ™ÃÞÔÍÞ¸Pé3›éõãþý¤­àÿùÿÿþþýÞÿ¾HÛÞþß™ÃßÚÔÞªJë3 23Šàøîþý¡«àÿùÿÿþýþýßÿŽSûßšÅßÝØÍf6é3=ªôùÿü ªëÿ šã(43¨Ýà¡CùR¬Ð7(í•)45Ðèþç èçèèççèÇ}Õøÿ éÞO3:977557ý6ÿ8ÿ9þ8ÿ9 ¦ìÿòÿÿý ¦ñÿ Š&Eòóòóóòòóýòóó Û#Ôôóóôôóôýó ôóóôóôôóôóþôóôôóëôõôôã> <èïÿ uìÿ ¦ëÿ ¦åÿ ªÎÿÃÿñ2$„ûþœ*ÑÍÿÁÿ o+>ùÿþÿl'>èÌÿÀÿº(Êþ@*IöËÿ¿ÿñ0 wÉÿ½ÿigéÈÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ½ÿýþûýýþÓÿ¿ÿþþýþþý   ý Jãþÿÿnéþšàÿöÿÿþ×ÿ +Éüÿÿh µÿJ—ÚÚ¾bï !±úÿÿb ïþÿ_ Õz ÝÝ­<ì ŸÛåääåå·—Úñÿ Š×ååæýåJ¢òÿ æååæåæååæååüæäÇ,ý ã!Ïìíììííìüí ¦ìÿòÿÿý ¦ñÿ ôõôõôôã? <èïÿ uìÿ ¦ëÿ ÷øø÷ø÷à<Göèÿ ¦åÿ Ë&Ñøøùøùøøþùýø üýüüýü÷;*GöÑÿÅÿ{(=ø÷ýè/uÏÿÄÿº(ÒýýþýýþË- ªÎÿÃÿñ2$„þþýþþœ*ÑÍÿÁÿ o+>ùÿþÿl&>èÌÿÀÿº(Êþ@*IöËÿ¿ÿñ0 wÉÿ½ÿigéÈÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ½ÿýþûýýþÓÿ¿ÿþþýþþý ¡Óùÿÿžfïý}‰àÿ÷ÿÿþ f‡HiÛÜÖµ™šð™ š™¡êüÿ¡fðý€Œàÿøÿþþ Õzf±Ý–jÝÝÏ¬ì™ žÔøÿ¡iòþµ¼àÿøÿÿþÿýÚÿ ®HÝe±Ý§ÝÜÁ¡ì™ š¸îÿ¹…÷ý™£àÿøÿÿþÿýÜÿ úthÝÞf¯ÞǯÝÔ©ë™ š™×ùãÅýûwƒàÿùÿþþÿýÝÿ ß•¨ÞÞßf°ÞνÞΦé™ÎõíÕþûv‚àÿùÿÿþþýÞÿ¾HÛÞßßÞe°ÞÕÊÝÉ£é™Åñóæþût€àÿùÿÿþýþýßÿŽSàüßf²ßÛØØ®œë™ ˜™œÕ÷öÿûq€ëÿ ›ŸÕäãääåS‡úðÿ ¦ìÿòÿÿý ¦ñÿ uìÿ ¦ëÿ ¦åÿ ýüüýýü÷;*GöÑÿÅÿ{(=ø÷ýè/uÏÿÄÿº(ÒþýýþýþþýË- ªÎÿÃÿñ2$„þýýþœ*ÑÍÿÁÿ o+>úÿþÿl'>èÌÿÀÿº(Êþ@*IöËÿ¿ÿñ0 wÉÿ½ÿigéÈÿÿÿÿÿÿÿÿÿ Ô6 ÞN ìo ï ì ë ê é From jackjansen@users.sourceforge.net Sat Mar 16 00:35:38 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 15 Mar 2002 16:35:38 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0278.txt,1.4,1.5 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv23866 Modified Files: pep-0278.txt Log Message: One more "t" replaced by "U". Unicode is confirmed "newline-safe". Index: pep-0278.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0278.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pep-0278.txt 14 Mar 2002 22:47:31 -0000 1.4 --- pep-0278.txt 16 Mar 2002 00:35:36 -0000 1.5 *************** *** 111,120 **** I think there are no special issues with unicode. utf-16 shouldn't pose any new problems, as such files need to be opened in binary ! mode anyway. Interaction with utf-8 I am not 100% sure about: is it ! possible for a 0x0a or 0x0d byte to occur as part of a multibyte ! escape without the stadnard meaning of CR or LF? I assume not, ! because if such bytes are allowed it would mean that readline() on ! Unix would terminate the read on a 0x0d (and on MacOS on a 0x0a) ! without a full line being read. Universal newline files should work fine with iterators and --- 111,116 ---- I think there are no special issues with unicode. utf-16 shouldn't pose any new problems, as such files need to be opened in binary ! mode anyway. Interaction with utf-8 is fine too: values 0x0a and 0x0d ! cannot occur as part of a multibyte sequence. Universal newline files should work fine with iterators and *************** *** 125,129 **** While universal newlines are automatically enabled for import they are not for opening, where you have to specifically say open(..., ! "t"). This is open to debate, but here are a few reasons for this design: --- 121,125 ---- While universal newlines are automatically enabled for import they are not for opening, where you have to specifically say open(..., ! "U"). This is open to debate, but here are a few reasons for this design: From fdrake@users.sourceforge.net Sat Mar 16 04:52:38 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 15 Mar 2002 20:52:38 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/texinputs python.sty,1.89,1.90 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory usw-pr-cvs1:/tmp/cvs-serv27446/texinputs Modified Files: python.sty Log Message: pdfTeX 0.13 and 0.14 do not agree on the name of the macro, and I will not change the installed version on either of the machines I use to format the docs. Instead, use a compatibility hack to support both versions. This is also better for external users of the Python styles. Index: python.sty =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/python.sty,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** python.sty 15 Mar 2002 23:21:37 -0000 1.89 --- python.sty 16 Mar 2002 04:52:36 -0000 1.90 *************** *** 49,52 **** --- 49,60 ---- \let\py@OldContentsline=\contentsline % + % Backward compatibility hack: pdfTeX 0.13 defined \pdfannotlink, + % but it changed to \pdfstartlink in 0.14. This let's us use either + % version and still get useful behavior. + % + \@ifundefined{pdfstartlink}{ + \let\pdfstartlink=\pdfannotlink + }{} + % % Macro that takes two args: the name to link to and the content of % the link. This takes care of the PDF magic, getting the colors From fdrake@users.sourceforge.net Sat Mar 16 04:52:57 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 15 Mar 2002 20:52:57 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/texinputs python.sty,1.88.4.1,1.88.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory usw-pr-cvs1:/tmp/cvs-serv27569/texinputs Modified Files: Tag: release22-maint python.sty Log Message: pdfTeX 0.13 and 0.14 do not agree on the name of the macro, and I will not change the installed version on either of the machines I use to format the docs. Instead, use a compatibility hack to support both versions. This is also better for external users of the Python styles. Index: python.sty =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/python.sty,v retrieving revision 1.88.4.1 retrieving revision 1.88.4.2 diff -C2 -d -r1.88.4.1 -r1.88.4.2 *** python.sty 15 Mar 2002 23:18:05 -0000 1.88.4.1 --- python.sty 16 Mar 2002 04:52:55 -0000 1.88.4.2 *************** *** 49,52 **** --- 49,60 ---- \let\py@OldContentsline=\contentsline % + % Backward compatibility hack: pdfTeX 0.13 defined \pdfannotlink, + % but it changed to \pdfstartlink in 0.14. This let's us use either + % version and still get useful behavior. + % + \@ifundefined{pdfstartlink}{ + \let\pdfstartlink=\pdfannotlink + }{} + % % Macro that takes two args: the name to link to and the content of % the link. This takes care of the PDF magic, getting the colors From fdrake@users.sourceforge.net Sat Mar 16 05:10:24 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 15 Mar 2002 21:10:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libre.tex,1.73.6.2,1.73.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv2965/lib Modified Files: Tag: release22-maint libre.tex Log Message: Clarify the descriptions of the positive and negative lookbehind assertions. Added examples of positive lookbehind assertions. This closes SF bug #529708. Index: libre.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v retrieving revision 1.73.6.2 retrieving revision 1.73.6.3 diff -C2 -d -r1.73.6.2 -r1.73.6.3 *** libre.tex 25 Feb 2002 18:57:04 -0000 1.73.6.2 --- libre.tex 16 Mar 2002 05:10:22 -0000 1.73.6.3 *************** *** 273,288 **** \item[\code{(?<=...)}] Matches if the current position in the string is preceded by a match for \regexp{...} that ends at the current ! position. This is called a positive lookbehind assertion. ! \regexp{(?<=abc)def} will match \samp{abcdef}, since the lookbehind ! will back up 3 characters and check if the contained pattern matches. ! The contained pattern must only match strings of some fixed length, ! meaning that \regexp{abc} or \regexp{a|b} are allowed, but \regexp{a*} ! isn't. \item[\code{(?>> import re ! >>> m = re.search('(?<=abc)def', 'abdef') ! >>> m.group(0) ! 'def' ! \end{verbatim} ! ! This example looks for a word following a hyphen: ! ! \begin{verbatim} ! >>> m = re.search('(?<=-)\w+', 'spam-egg') ! >>> m.group(0) ! 'egg' ! \end{verbatim} \item[\code{(? Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv24044/lib Modified Files: libre.tex Log Message: Clarify the descriptions of the positive and negative lookbehind assertions. Added examples of positive lookbehind assertions. This closes SF bug #529708. Index: libre.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** libre.tex 5 Mar 2002 04:02:39 -0000 1.77 --- libre.tex 16 Mar 2002 05:58:12 -0000 1.78 *************** *** 273,288 **** \item[\code{(?<=...)}] Matches if the current position in the string is preceded by a match for \regexp{...} that ends at the current ! position. This is called a positive lookbehind assertion. ! \regexp{(?<=abc)def} will match \samp{abcdef}, since the lookbehind ! will back up 3 characters and check if the contained pattern matches. ! The contained pattern must only match strings of some fixed length, ! meaning that \regexp{abc} or \regexp{a|b} are allowed, but \regexp{a*} ! isn't. \item[\code{(?>> import re ! >>> m = re.search('(?<=abc)def', 'abdef') ! >>> m.group(0) ! 'def' ! \end{verbatim} ! ! This example looks for a word following a hyphen: ! ! \begin{verbatim} ! >>> m = re.search('(?<=-)\w+', 'spam-egg') ! >>> m.group(0) ! 'egg' ! \end{verbatim} \item[\code{(? Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv1608/lib Modified Files: Tag: release21-maint libre.tex Log Message: Clarify the descriptions of the positive and negative lookbehind assertions. Added examples of positive lookbehind assertions. This closes SF bug #529708. Index: libre.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v retrieving revision 1.60.2.3 retrieving revision 1.60.2.4 diff -C2 -d -r1.60.2.3 -r1.60.2.4 *** libre.tex 14 Feb 2002 15:26:15 -0000 1.60.2.3 --- libre.tex 16 Mar 2002 06:26:20 -0000 1.60.2.4 *************** *** 256,271 **** \item[\code{(?<=...)}] Matches if the current position in the string is preceded by a match for \regexp{...} that ends at the current ! position. This is called a positive lookbehind assertion. ! \regexp{(?<=abc)def} will match \samp{abcdef}, since the lookbehind ! will back up 3 characters and check if the contained pattern matches. ! The contained pattern must only match strings of some fixed length, ! meaning that \regexp{abc} or \regexp{a|b} are allowed, but \regexp{a*} ! isn't. \item[\code{(?>> import re ! >>> m = re.search('(?<=abc)def', 'abdef') ! >>> m.group(0) ! 'def' ! \end{verbatim} ! ! This example looks for a word following a hyphen: ! ! \begin{verbatim} ! >>> m = re.search('(?<=-)\w+', 'spam-egg') ! >>> m.group(0) ! 'egg' ! \end{verbatim} \item[\code{(? Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv4773/ref Modified Files: Tag: release22-maint ref5.tex Log Message: Markup error: braces not properly marked in dictionary display grammer productions. Fixes SF bug #520959. Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.53.4.1 retrieving revision 1.53.4.2 diff -C2 -d -r1.53.4.1 -r1.53.4.2 *** ref5.tex 15 Mar 2002 23:18:05 -0000 1.53.4.1 --- ref5.tex 16 Mar 2002 06:35:01 -0000 1.53.4.2 *************** *** 212,216 **** \begin{productionlist} \production{dict_display} ! {"{" [\token{key_datum_list}] "}"} \production{key_datum_list} {\token{key_datum} ("," \token{key_datum})* [","]} --- 212,216 ---- \begin{productionlist} \production{dict_display} ! {"\{" [\token{key_datum_list}] "\}"} \production{key_datum_list} {\token{key_datum} ("," \token{key_datum})* [","]} From fdrake@users.sourceforge.net Sat Mar 16 06:35:56 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 15 Mar 2002 22:35:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref5.tex,1.54,1.55 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv5132/ref Modified Files: ref5.tex Log Message: Markup error: braces not properly marked in dictionary display grammer productions. Fixes SF bug #520959. Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** ref5.tex 15 Mar 2002 23:21:37 -0000 1.54 --- ref5.tex 16 Mar 2002 06:35:54 -0000 1.55 *************** *** 212,216 **** \begin{productionlist} \production{dict_display} ! {"{" [\token{key_datum_list}] "}"} \production{key_datum_list} {\token{key_datum} ("," \token{key_datum})* [","]} --- 212,216 ---- \begin{productionlist} \production{dict_display} ! {"\{" [\token{key_datum_list}] "\}"} \production{key_datum_list} {\token{key_datum} ("," \token{key_datum})* [","]} From sjoerd@acm.org Sat Mar 16 09:35:18 2002 From: sjoerd@acm.org (Sjoerd Mullender) Date: Sat, 16 Mar 2002 10:35:18 +0100 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libre.tex,1.77,1.78 References: Message-ID: <3C9311D6.AF5811D8@acm.org> I don't think the first example will actually work: there is a "c" missing in the to-be-matched string. "Fred L. Drake" wrote: > > Update of /cvsroot/python/python/dist/src/Doc/lib > In directory usw-pr-cvs1:/tmp/cvs-serv24044/lib > > Modified Files: > libre.tex > Log Message: > Clarify the descriptions of the positive and negative lookbehind assertions. > Added examples of positive lookbehind assertions. > This closes SF bug #529708. > > Index: libre.tex > =================================================================== > RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v > retrieving revision 1.77 > retrieving revision 1.78 > diff -C2 -d -r1.77 -r1.78 > *** libre.tex 5 Mar 2002 04:02:39 -0000 1.77 > --- libre.tex 16 Mar 2002 05:58:12 -0000 1.78 > *************** > *** 273,288 **** > \item[\code{(?<=...)}] Matches if the current position in the string > is preceded by a match for \regexp{...} that ends at the current > ! position. This is called a positive lookbehind assertion. > ! \regexp{(?<=abc)def} will match \samp{abcdef}, since the lookbehind > ! will back up 3 characters and check if the contained pattern matches. > ! The contained pattern must only match strings of some fixed length, > ! meaning that \regexp{abc} or \regexp{a|b} are allowed, but \regexp{a*} > ! isn't. > > \item[\code{(? ! is not preceded by a match for \regexp{...}. This > ! is called a negative lookbehind assertion. Similar to positive lookbehind > assertions, the contained pattern must only match strings of some > ! fixed length. > > \end{list} > --- 273,309 ---- > \item[\code{(?<=...)}] Matches if the current position in the string > is preceded by a match for \regexp{...} that ends at the current > ! position. This is called a \dfn{positive lookbehind assertion}. > ! \regexp{(?<=abc)def} will find a match in \samp{abcdef}, since the > ! lookbehind will back up 3 characters and check if the contained > ! pattern matches. The contained pattern must only match strings of > ! some fixed length, meaning that \regexp{abc} or \regexp{a|b} are > ! allowed, but \regexp{a*} and \regexp{a\{3,4\}} are not. Note that > ! patterns which start with positive lookbehind assertions will never > ! match at the beginning of the string being searched; you will most > ! likely want to use the \function{search()} function rather than the > ! \function{match()} function: > ! > ! \begin{verbatim} > ! >>> import re > ! >>> m = re.search('(?<=abc)def', 'abdef') > ! >>> m.group(0) > ! 'def' > ! \end{verbatim} > ! > ! This example looks for a word following a hyphen: > ! > ! \begin{verbatim} > ! >>> m = re.search('(?<=-)\w+', 'spam-egg') > ! >>> m.group(0) > ! 'egg' > ! \end{verbatim} > > \item[\code{(? ! is not preceded by a match for \regexp{...}. This is called a > ! \dfn{negative lookbehind assertion}. Similar to positive lookbehind > assertions, the contained pattern must only match strings of some > ! fixed length. Patterns which start with negative lookbehind > ! assertions will may match at the beginning of the string being > ! searched. > > \end{list} > > _______________________________________________ > Python-checkins mailing list > Python-checkins@python.org > http://mail.python.org/mailman/listinfo/python-checkins From fdrake@acm.org Sat Mar 16 13:50:52 2002 From: fdrake@acm.org (Fred L. Drake, Jr.) Date: Sat, 16 Mar 2002 08:50:52 -0500 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libre.tex,1.77,1.78 In-Reply-To: <3C9311D6.AF5811D8@acm.org> References: <3C9311D6.AF5811D8@acm.org> Message-ID: <15507.19900.334428.127192@grendel.zope.com> Sjoerd Mullender writes: > I don't think the first example will actually work: there is a "c" > missing in the to-be-matched string. That's what I get for re-typing the example instead of copying it from the interactive session. (Yes, I did *try* it to be sure!) Fix coming up... -Fred -- Fred L. Drake, Jr. PythonLabs at Zope Corporation From fdrake@users.sourceforge.net Sat Mar 16 13:53:25 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Sat, 16 Mar 2002 05:53:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libre.tex,1.73.6.3,1.73.6.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv17424/lib Modified Files: Tag: release22-maint libre.tex Log Message: Fix stupid typo in example. Index: libre.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v retrieving revision 1.73.6.3 retrieving revision 1.73.6.4 diff -C2 -d -r1.73.6.3 -r1.73.6.4 *** libre.tex 16 Mar 2002 05:10:22 -0000 1.73.6.3 --- libre.tex 16 Mar 2002 13:53:23 -0000 1.73.6.4 *************** *** 286,290 **** \begin{verbatim} >>> import re ! >>> m = re.search('(?<=abc)def', 'abdef') >>> m.group(0) 'def' --- 286,290 ---- \begin{verbatim} >>> import re ! >>> m = re.search('(?<=abc)def', 'abcdef') >>> m.group(0) 'def' From fdrake@users.sourceforge.net Sat Mar 16 13:53:37 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Sat, 16 Mar 2002 05:53:37 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libre.tex,1.60.2.4,1.60.2.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv17566/lib Modified Files: Tag: release21-maint libre.tex Log Message: Fix stupid typo in example. Index: libre.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v retrieving revision 1.60.2.4 retrieving revision 1.60.2.5 diff -C2 -d -r1.60.2.4 -r1.60.2.5 *** libre.tex 16 Mar 2002 06:26:20 -0000 1.60.2.4 --- libre.tex 16 Mar 2002 13:53:35 -0000 1.60.2.5 *************** *** 269,273 **** \begin{verbatim} >>> import re ! >>> m = re.search('(?<=abc)def', 'abdef') >>> m.group(0) 'def' --- 269,273 ---- \begin{verbatim} >>> import re ! >>> m = re.search('(?<=abc)def', 'abcdef') >>> m.group(0) 'def' From fdrake@users.sourceforge.net Sat Mar 16 14:01:15 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Sat, 16 Mar 2002 06:01:15 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libre.tex,1.78,1.79 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv21128/lib Modified Files: libre.tex Log Message: Fix stupid typo in example. Index: libre.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** libre.tex 16 Mar 2002 05:58:12 -0000 1.78 --- libre.tex 16 Mar 2002 14:01:12 -0000 1.79 *************** *** 286,290 **** \begin{verbatim} >>> import re ! >>> m = re.search('(?<=abc)def', 'abdef') >>> m.group(0) 'def' --- 286,290 ---- \begin{verbatim} >>> import re ! >>> m = re.search('(?<=abc)def', 'abcdef') >>> m.group(0) 'def' From mwh@users.sourceforge.net Sat Mar 16 17:53:54 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sat, 16 Mar 2002 09:53:54 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/hotshot log.py,1.4,1.4.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/hotshot In directory usw-pr-cvs1:/tmp/cvs-serv20982 Modified Files: Tag: release22-maint log.py Log Message: Naughty Fred forgot to mark this as a bugfix candidate. backport fdrake's checkin of revision 1.5 of log.py Set/update self.cwd properly. Index: log.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/hotshot/log.py,v retrieving revision 1.4 retrieving revision 1.4.8.1 diff -C2 -d -r1.4 -r1.4.8.1 *** log.py 29 Oct 2001 20:57:23 -0000 1.4 --- log.py 16 Mar 2002 17:53:51 -0000 1.4.8.1 *************** *** 38,42 **** --- 38,48 ---- self._nextitem = self._reader.next self._info = self._reader.info + if self._info.has_key('current-directory'): + self.cwd = self._info['current-directory'] + else: + self.cwd = None self._stack = [] + self._append = self._stack.append + self._pop = self._stack.pop def addinfo(self, key, value): *************** *** 54,57 **** --- 60,85 ---- pass + def get_filename(self, fileno): + try: + return self._filemap[fileno] + except KeyError: + raise ValueError, "unknown fileno" + + def get_filenames(self): + return self._filemap.values() + + def get_fileno(self, filename): + filename = os.path.normcase(os.path.normpath(filename)) + for fileno, name in self._filemap.items(): + if name == filename: + return fileno + raise ValueError, "unknown filename" + + def get_funcname(self, fileno, lineno): + try: + return self._funcmap[(fileno, lineno)] + except KeyError: + raise ValueError, "unknown function location" + # Iteration support: # This adds an optional (& ignored) parameter to next() so that the *************** *** 67,92 **** self._reader.close() raise StopIteration() if what == WHAT_DEFINE_FILE: ! self._filemap[fileno] = tdelta ! continue ! if what == WHAT_DEFINE_FUNC: filename = self._filemap[fileno] self._funcmap[(fileno, lineno)] = (filename, tdelta) ! continue ! if what == WHAT_ADD_INFO: # value already loaded into self.info; call the # overridable addinfo() handler so higher-level code # can pick up the new value self.addinfo(tdelta, lineno) - continue - if what == WHAT_ENTER: - t = self._decode_location(fileno, lineno) - filename, funcname = t - self._stack.append((filename, funcname, lineno)) - elif what == WHAT_EXIT: - filename, funcname, lineno = self._stack.pop() else: ! filename, funcname, firstlineno = self._stack[-1] ! return what, (filename, lineno, funcname), tdelta if sys.version < "2.2": --- 95,129 ---- self._reader.close() raise StopIteration() + + # handle the most common cases first + + if what == WHAT_ENTER: + filename, funcname = self._decode_location(fileno, lineno) + self._append((filename, funcname, lineno)) + return what, (filename, lineno, funcname), tdelta + + if what == WHAT_EXIT: + filename, funcname, lineno = self._pop() + return what, (filename, lineno, funcname), tdelta + + if what == WHAT_LINENO: + filename, funcname, firstlineno = self._stack[-1] + return what, (filename, lineno, funcname), tdelta + if what == WHAT_DEFINE_FILE: ! filename = os.path.normcase(os.path.normpath(tdelta)) ! self._filemap[fileno] = filename ! elif what == WHAT_DEFINE_FUNC: filename = self._filemap[fileno] self._funcmap[(fileno, lineno)] = (filename, tdelta) ! elif what == WHAT_ADD_INFO: # value already loaded into self.info; call the # overridable addinfo() handler so higher-level code # can pick up the new value + if tdelta == 'current-directory': + self.cwd = lineno self.addinfo(tdelta, lineno) else: ! raise ValueError, "unknown event type" if sys.version < "2.2": From mwh@users.sourceforge.net Sat Mar 16 17:54:22 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sat, 16 Mar 2002 09:54:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _localemodule.c,2.25,2.25.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv21138 Modified Files: Tag: release22-maint _localemodule.c Log Message: backport loewis' checkin of revision 2.26 of _localemodule.c Verify arguments for nl_langinfo. Fixes #528879. Index: _localemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v retrieving revision 2.25 retrieving revision 2.25.6.1 diff -C2 -d -r2.25 -r2.25.6.1 *** _localemodule.c 28 Nov 2001 20:27:42 -0000 2.25 --- _localemodule.c 16 Mar 2002 17:54:20 -0000 2.25.6.1 *************** *** 1,4 **** /*********************************************************** ! Copyright (C) 1997 Martin von Loewis Permission to use, copy, modify, and distribute this software and its --- 1,4 ---- /*********************************************************** ! Copyright (C) 1997, 2002 Martin von Loewis Permission to use, copy, modify, and distribute this software and its *************** *** 416,419 **** --- 416,507 ---- #ifdef HAVE_LANGINFO_H + #define LANGINFO(X) {#X, X} + struct langinfo_constant{ + char* name; + int value; + } langinfo_constants[] = + { + /* These constants should exist on any langinfo implementation */ + LANGINFO(DAY_1), + LANGINFO(DAY_2), + LANGINFO(DAY_3), + LANGINFO(DAY_4), + LANGINFO(DAY_5), + LANGINFO(DAY_6), + LANGINFO(DAY_7), + + LANGINFO(ABDAY_1), + LANGINFO(ABDAY_2), + LANGINFO(ABDAY_3), + LANGINFO(ABDAY_4), + LANGINFO(ABDAY_5), + LANGINFO(ABDAY_6), + LANGINFO(ABDAY_7), + + LANGINFO(MON_1), + LANGINFO(MON_2), + LANGINFO(MON_3), + LANGINFO(MON_4), + LANGINFO(MON_5), + LANGINFO(MON_6), + LANGINFO(MON_7), + LANGINFO(MON_8), + LANGINFO(MON_9), + LANGINFO(MON_10), + LANGINFO(MON_11), + LANGINFO(MON_12), + + LANGINFO(ABMON_1), + LANGINFO(ABMON_2), + LANGINFO(ABMON_3), + LANGINFO(ABMON_4), + LANGINFO(ABMON_5), + LANGINFO(ABMON_6), + LANGINFO(ABMON_7), + LANGINFO(ABMON_8), + LANGINFO(ABMON_9), + LANGINFO(ABMON_10), + LANGINFO(ABMON_11), + LANGINFO(ABMON_12), + + #ifdef RADIXCHAR + /* The following are not available with glibc 2.0 */ + LANGINFO(RADIXCHAR), + LANGINFO(THOUSEP), + /* YESSTR and NOSTR are deprecated in glibc, since they are + a special case of message translation, which should be rather + done using gettext. So we don't expose it to Python in the + first place. + LANGINFO(YESSTR), + LANGINFO(NOSTR), + */ + LANGINFO(CRNCYSTR), + #endif + + LANGINFO(D_T_FMT), + LANGINFO(D_FMT), + LANGINFO(T_FMT), + LANGINFO(AM_STR), + LANGINFO(PM_STR), + + #ifdef CODESET + /* The following constants are available only with XPG4. */ + LANGINFO(CODESET), + LANGINFO(T_FMT_AMPM), + LANGINFO(ERA), + LANGINFO(ERA_D_FMT), + LANGINFO(ERA_D_T_FMT), + LANGINFO(ERA_T_FMT), + LANGINFO(ALT_DIGITS), + LANGINFO(YESEXPR), + LANGINFO(NOEXPR), + #endif + #ifdef _DATE_FMT + /* This is not available in all glibc versions that have CODESET. */ + LANGINFO(_DATE_FMT), + #endif + {0, 0} + }; + static char nl_langinfo__doc__[] = "nl_langinfo(key) -> string\n" *************** *** 424,433 **** PyLocale_nl_langinfo(PyObject* self, PyObject* args) { ! int item; if (!PyArg_ParseTuple(args, "i:nl_langinfo", &item)) return NULL; ! return PyString_FromString(nl_langinfo(item)); } ! #endif --- 512,528 ---- PyLocale_nl_langinfo(PyObject* self, PyObject* args) { ! int item, i; if (!PyArg_ParseTuple(args, "i:nl_langinfo", &item)) return NULL; ! /* Check whether this is a supported constant. GNU libc sometimes ! returns numeric values in the char* return value, which would ! crash PyString_FromString. */ ! for (i = 0; langinfo_constants[i].name; i++) ! if (langinfo_constants[i].value == item) ! return PyString_FromString(nl_langinfo(item)); ! PyErr_SetString(PyExc_ValueError, "unsupported langinfo constant"); ! return NULL; } ! #endif /* HAVE_LANGINFO_H */ *************** *** 456,459 **** --- 551,557 ---- { PyObject *m, *d, *x; + #ifdef HAVE_LANGINFO_H + int i; + #endif m = Py_InitModule("_locale", PyLocale_Methods); *************** *** 502,586 **** Py_XDECREF(x); - #define ADDINT(X) PyModule_AddIntConstant(m, #X, X) #ifdef HAVE_LANGINFO_H ! /* These constants should exist on any langinfo implementation */ ! ADDINT(DAY_1); ! ADDINT(DAY_2); ! ADDINT(DAY_3); ! ADDINT(DAY_4); ! ADDINT(DAY_5); ! ADDINT(DAY_6); ! ADDINT(DAY_7); ! ! ADDINT(ABDAY_1); ! ADDINT(ABDAY_2); ! ADDINT(ABDAY_3); ! ADDINT(ABDAY_4); ! ADDINT(ABDAY_5); ! ADDINT(ABDAY_6); ! ADDINT(ABDAY_7); ! ! ADDINT(MON_1); ! ADDINT(MON_2); ! ADDINT(MON_3); ! ADDINT(MON_4); ! ADDINT(MON_5); ! ADDINT(MON_6); ! ADDINT(MON_7); ! ADDINT(MON_8); ! ADDINT(MON_9); ! ADDINT(MON_10); ! ADDINT(MON_11); ! ADDINT(MON_12); ! ! ADDINT(ABMON_1); ! ADDINT(ABMON_2); ! ADDINT(ABMON_3); ! ADDINT(ABMON_4); ! ADDINT(ABMON_5); ! ADDINT(ABMON_6); ! ADDINT(ABMON_7); ! ADDINT(ABMON_8); ! ADDINT(ABMON_9); ! ADDINT(ABMON_10); ! ADDINT(ABMON_11); ! ADDINT(ABMON_12); ! ! #ifdef RADIXCHAR ! /* The following are not available with glibc 2.0 */ ! ADDINT(RADIXCHAR); ! ADDINT(THOUSEP); ! /* YESSTR and NOSTR are deprecated in glibc, since they are ! a special case of message translation, which should be rather ! done using gettext. So we don't expose it to Python in the ! first place. ! ADDINT(YESSTR); ! ADDINT(NOSTR); ! */ ! ADDINT(CRNCYSTR); ! #endif ! ! ADDINT(D_T_FMT); ! ADDINT(D_FMT); ! ADDINT(T_FMT); ! ADDINT(AM_STR); ! ADDINT(PM_STR); ! ! #ifdef CODESET ! /* The following constants are available only with XPG4. */ ! ADDINT(CODESET); ! ADDINT(T_FMT_AMPM); ! ADDINT(ERA); ! ADDINT(ERA_D_FMT); ! ADDINT(ERA_D_T_FMT); ! ADDINT(ERA_T_FMT); ! ADDINT(ALT_DIGITS); ! ADDINT(YESEXPR); ! ADDINT(NOEXPR); ! #endif ! #ifdef _DATE_FMT ! /* This is not available in all glibc versions that have CODESET. */ ! ADDINT(_DATE_FMT); #endif - #endif /* HAVE_LANGINFO_H */ } --- 600,608 ---- Py_XDECREF(x); #ifdef HAVE_LANGINFO_H ! for (i = 0; langinfo_constants[i].name; i++) { ! PyModule_AddIntConstant(m, langinfo_constants[i].name, ! langinfo_constants[i].value); ! } #endif } From mwh@users.sourceforge.net Sat Mar 16 17:56:53 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sat, 16 Mar 2002 09:56:53 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.126.4.2,2.126.4.3 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv22040 Modified Files: Tag: release22-maint typeobject.c Log Message: backport gvanrossum's checkin of revision 2.129 of typeobject.c "Fix" for SF bug #520644: __slots__ are not pickled. As promised in my response to the bug report, I'm not really fixing it; in fact, one could argule over what the proper fix should do. Instead, I'm adding a little magic that raises TypeError if you try to pickle an instance of a class that has __slots__ but doesn't define or override __getstate__. This is done by adding a bozo __getstate__ that always raises TypeError. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.126.4.2 retrieving revision 2.126.4.3 diff -C2 -d -r2.126.4.2 -r2.126.4.3 *** typeobject.c 11 Mar 2002 10:19:48 -0000 2.126.4.2 --- typeobject.c 16 Mar 2002 17:56:51 -0000 2.126.4.3 *************** *** 851,854 **** --- 851,869 ---- }; + /* bozo: __getstate__ that raises TypeError */ + + static PyObject * + bozo_func(PyObject *self, PyObject *args) + { + PyErr_SetString(PyExc_TypeError, + "a class that defines __slots__ without " + "defining __getstate__ cannot be pickled"); + return NULL; + } + + static PyMethodDef bozo_ml = {"__getstate__", bozo_func}; + + static PyObject *bozo_obj = NULL; + static PyObject * type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds) *************** *** 974,977 **** --- 989,1013 ---- } } + if (slots != NULL) { + /* See if *this* class defines __getstate__ */ + PyObject *getstate = PyDict_GetItemString(dict, + "__getstate__"); + if (getstate == NULL) { + /* If not, provide a bozo that raises TypeError */ + if (bozo_obj == NULL) { + bozo_obj = PyCFunction_New(&bozo_ml, NULL); + if (bozo_obj == NULL) { + /* XXX decref various things */ + return NULL; + } + } + if (PyDict_SetItemString(dict, + "__getstate__", + bozo_obj) < 0) { + /* XXX decref various things */ + return NULL; + } + } + } if (slots == NULL && base->tp_dictoffset == 0 && (base->tp_setattro == PyObject_GenericSetAttr || *************** *** 1655,1659 **** if (descr == NULL) return -1; ! if (PyDict_SetItemString(dict,meth->ml_name,descr) < 0) return -1; Py_DECREF(descr); --- 1691,1695 ---- if (descr == NULL) return -1; ! if (PyDict_SetItemString(dict,meth->ml_name, descr) < 0) return -1; Py_DECREF(descr); From mwh@users.sourceforge.net Sat Mar 16 17:57:28 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sat, 16 Mar 2002 09:57:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.113.4.6,1.113.4.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv22199 Modified Files: Tag: release22-maint test_descr.py Log Message: backport gvanrossum's checkin of revision 1.121 of test_descr.py "Fix" for SF bug #520644: __slots__ are not pickled. As promised in my response to the bug report, I'm not really fixing it; in fact, one could argule over what the proper fix should do. Instead, I'm adding a little magic that raises TypeError if you try to pickle an instance of a class that has __slots__ but doesn't define or override __getstate__. This is done by adding a bozo __getstate__ that always raises TypeError. Bugfix candidate (also the checkin to typeobject.c, of course). Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.113.4.6 retrieving revision 1.113.4.7 diff -C2 -d -r1.113.4.6 -r1.113.4.7 *** test_descr.py 15 Mar 2002 10:35:55 -0000 1.113.4.6 --- test_descr.py 16 Mar 2002 17:57:26 -0000 1.113.4.7 *************** *** 2451,2454 **** --- 2451,2542 ---- print "b = y =", b + def pickleslots(): + if verbose: print "Testing pickling of classes with __slots__ ..." + import pickle, cPickle + # Pickling of classes with __slots__ but without __getstate__ should fail + global B, C, D, E + class B(object): + pass + for base in [object, B]: + class C(base): + __slots__ = ['a'] + class D(C): + pass + try: + pickle.dumps(C()) + except TypeError: + pass + else: + raise TestFailed, "should fail: pickle C instance - %s" % base + try: + cPickle.dumps(C()) + except TypeError: + pass + else: + raise TestFailed, "should fail: cPickle C instance - %s" % base + try: + pickle.dumps(C()) + except TypeError: + pass + else: + raise TestFailed, "should fail: pickle D instance - %s" % base + try: + cPickle.dumps(D()) + except TypeError: + pass + else: + raise TestFailed, "should fail: cPickle D instance - %s" % base + # Give C a __getstate__ and __setstate__ + class C(base): + __slots__ = ['a'] + def __getstate__(self): + try: + d = self.__dict__.copy() + except AttributeError: + d = {} + try: + d['a'] = self.a + except AttributeError: + pass + return d + def __setstate__(self, d): + for k, v in d.items(): + setattr(self, k, v) + class D(C): + pass + # Now it should work + x = C() + y = pickle.loads(pickle.dumps(x)) + vereq(hasattr(y, 'a'), 0) + y = cPickle.loads(cPickle.dumps(x)) + vereq(hasattr(y, 'a'), 0) + x.a = 42 + y = pickle.loads(pickle.dumps(x)) + vereq(y.a, 42) + y = cPickle.loads(cPickle.dumps(x)) + vereq(y.a, 42) + x = D() + x.a = 42 + x.b = 100 + y = pickle.loads(pickle.dumps(x)) + vereq(y.a + y.b, 142) + y = cPickle.loads(cPickle.dumps(x)) + vereq(y.a + y.b, 142) + # But a subclass that adds a slot should not work + class E(C): + __slots__ = ['b'] + try: + pickle.dumps(E()) + except TypeError: + pass + else: + raise TestFailed, "should fail: pickle E instance - %s" % base + try: + cPickle.dumps(E()) + except TypeError: + pass + else: + raise TestFailed, "should fail: cPickle E instance - %s" % base + def copies(): if verbose: print "Testing copy.copy() and copy.deepcopy()..." *************** *** 2799,2802 **** --- 2887,2891 ---- deepcopyrecursive() modules() + pickleslots() if verbose: print "All OK" From mwh@users.sourceforge.net Sat Mar 16 17:58:23 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sat, 16 Mar 2002 09:58:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules pypcre.c,2.22,2.22.26.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv22406 Modified Files: Tag: release22-maint pypcre.c Log Message: backport loewis' checkin of revision 2.23 of pypcre.c Include Python.h first. Fixes #530159. Index: pypcre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pypcre.c,v retrieving revision 2.22 retrieving revision 2.22.26.1 diff -C2 -d -r2.22 -r2.22.26.1 *** pypcre.c 2 Aug 2000 13:41:18 -0000 2.22 --- pypcre.c 16 Mar 2002 17:58:21 -0000 2.22.26.1 *************** *** 46,51 **** #define FOR_PYTHON - #include "pcre-int.h" #include "Python.h" #include #include "graminit.h" --- 46,51 ---- #define FOR_PYTHON #include "Python.h" + #include "pcre-int.h" #include #include "graminit.h" From mwh@users.sourceforge.net Sat Mar 16 18:01:07 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sat, 16 Mar 2002 10:01:07 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib calendar.py,1.22,1.22.18.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv23250 Modified Files: Tag: release22-maint calendar.py Log Message: This checkin backport two checkins by Skip. backport montanaro's checkin of revision 1.24 of calendar.py make _localized_name instances work more like the tuples they replaced. In particular, negative indexes work and they are limited by the actual length of the names they represent (weekday and month names). This closes bug #503202. [and then] Corrected _localized_name.__getitem__ based on code in patch 503202 (which I thought was just a bug report, so didn't notice - doh!). This handles slicing, which v 1.23 didn't. Index: calendar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/calendar.py,v retrieving revision 1.22 retrieving revision 1.22.18.1 diff -C2 -d -r1.22 -r1.22.18.1 *** calendar.py 22 May 2001 15:58:30 -0000 1.22 --- calendar.py 16 Mar 2002 18:01:05 -0000 1.22.18.1 *************** *** 26,41 **** class _localized_name: ! def __init__(self, format): self.format = format def __getitem__(self, item): ! return strftime(self.format, (item,)*9).capitalize() # Full and abbreviated names of weekdays ! day_name = _localized_name('%A') ! day_abbr = _localized_name('%a') # Full and abbreviated names of months (1-based arrays!!!) ! month_name = _localized_name('%B') ! month_abbr = _localized_name('%b') # Constants for weekdays --- 26,50 ---- class _localized_name: ! def __init__(self, format, len): self.format = format + self.len = len def __getitem__(self, item): ! if isinstance(item, int): ! if item < 0: item += self.len ! if not 0 <= item < self.len: ! raise IndexError, "out of range" ! return strftime(self.format, (item,)*9).capitalize() ! elif isinstance(item, type(slice(0))): ! return [self[e] for e in range(self.len)].__getslice__(item.start, item.stop) ! def __len__(self): ! return self.len # Full and abbreviated names of weekdays ! day_name = _localized_name('%A', 7) ! day_abbr = _localized_name('%a', 7) # Full and abbreviated names of months (1-based arrays!!!) ! month_name = _localized_name('%B', 13) ! month_abbr = _localized_name('%b', 13) # Constants for weekdays From mwh@users.sourceforge.net Sat Mar 16 18:02:22 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sat, 16 Mar 2002 10:02:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib os.py,1.50.8.1,1.50.8.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv23697 Modified Files: Tag: release22-maint os.py Log Message: backport my checkin of revision 1.54 of os.py Fix [ 530236 ] os.py assumes existence of statvfs_resul This was pretty dense of me. Sorry. 2.2.1 candidate. Index: os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/os.py,v retrieving revision 1.50.8.1 retrieving revision 1.50.8.2 diff -C2 -d -r1.50.8.1 -r1.50.8.2 *** os.py 7 Mar 2002 10:12:11 -0000 1.50.8.1 --- os.py 16 Mar 2002 18:02:20 -0000 1.50.8.2 *************** *** 602,606 **** return (_make_stat_result, args) ! _copy_reg.pickle(stat_result, _pickle_stat_result,_make_stat_result) def _make_statvfs_result(tup, dict): --- 602,609 ---- return (_make_stat_result, args) ! try: ! _copy_reg.pickle(stat_result, _pickle_stat_result, _make_stat_result) ! except NameError: # stat_result may not exist ! pass def _make_statvfs_result(tup, dict): *************** *** 611,613 **** return (_make_statvfs_result, args) ! _copy_reg.pickle(statvfs_result, _pickle_statvfs_result,_make_statvfs_result) --- 614,620 ---- return (_make_statvfs_result, args) ! try: ! _copy_reg.pickle(statvfs_result, _pickle_statvfs_result, ! _make_statvfs_result) ! except NameError: # statvfs_result may not exist ! pass From mwh@users.sourceforge.net Sat Mar 16 18:03:45 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sat, 16 Mar 2002 10:03:45 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc python-mode.el,4.6,4.6.18.1 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv24218 Modified Files: Tag: release22-maint python-mode.el Log Message: backport bwarsaw's checkin of revision 4.7 of python-mode.el (py-honor-comment-indentation, py-compute-indentation): Fix the implementation to match the documentation for py-honor-comment-indentation w.r.t. not nil or t value. In that case it should still ignore ## for indentation purposes. Closes SF bug #523825, w/ patch provided by Christian Stork (mod'd by Barry). Python 2.2.1 candidate. Index: python-mode.el =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/python-mode.el,v retrieving revision 4.6 retrieving revision 4.6.18.1 diff -C2 -d -r4.6 -r4.6.18.1 *** python-mode.el 6 Jul 2001 20:38:11 -0000 4.6 --- python-mode.el 16 Mar 2002 18:03:42 -0000 4.6.18.1 *************** *** 185,190 **** purposes. ! When not nil or t, comment lines that begin with a `#' are used as ! indentation hints, unless the comment character is in column zero." :type '(choice (const :tag "Skip all comment lines (fast)" nil) --- 185,190 ---- purposes. ! When not nil or t, comment lines that begin with a single `#' are used ! as indentation hints, unless the comment character is in column zero." :type '(choice (const :tag "Skip all comment lines (fast)" nil) *************** *** 1903,1907 **** (save-excursion (back-to-indentation) ! (not (zerop (current-column))))) )) ))) --- 1903,1911 ---- (save-excursion (back-to-indentation) ! (and (not (looking-at prefix-re)) ! (or (looking-at "[^#]") ! (not (zerop (current-column))) ! )) ! )) )) ))) From mwh@users.sourceforge.net Sat Mar 16 18:19:35 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sat, 16 Mar 2002 10:19:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.337.2.4.2.3,1.337.2.4.2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv28149/Misc Modified Files: Tag: release22-maint NEWS Log Message: Backport Tim's work on getting file.truncate working better on Win32. "cvs diff | patch" managed to stick the NEWS item in the 2.2 final section! I wonder which silly man wrote patch . Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.337.2.4.2.3 retrieving revision 1.337.2.4.2.4 diff -C2 -d -r1.337.2.4.2.3 -r1.337.2.4.2.4 *** NEWS 14 Mar 2002 19:07:20 -0000 1.337.2.4.2.3 --- NEWS 16 Mar 2002 18:19:33 -0000 1.337.2.4.2.4 *************** *** 5,8 **** --- 5,14 ---- Core and builtins + - If you try to pickle an instance of a class that has __slots__ but + doesn't define or override __getstate__, a TypeError is now raised. + This is done by adding a bozo __getstate__ to the class that always + raises TypeError. (Before, this would appear to be pickled, but the + state of the slots would be lost.) + - PyErr_Display will provide file and line information for all exceptions that have an attribute print_file_and_line, not just SyntaxErrors. This *************** *** 21,24 **** --- 27,36 ---- arbitrary shell code can't be executed because a bogus URL was passed in. + + Windows + + - file.truncate([newsize]) now works on Windows for all newsize values. + It used to fail if newsize didn't fit in 32 bits, reflecting a + limitation of MS _chsize (which is no longer used). What's New in Python 2.2 final? From mwh@users.sourceforge.net Sat Mar 16 18:19:35 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sat, 16 Mar 2002 10:19:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_largefile.py,1.12,1.12.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv28149/Lib/test Modified Files: Tag: release22-maint test_largefile.py Log Message: Backport Tim's work on getting file.truncate working better on Win32. "cvs diff | patch" managed to stick the NEWS item in the 2.2 final section! I wonder which silly man wrote patch . Index: test_largefile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_largefile.py,v retrieving revision 1.12 retrieving revision 1.12.6.1 diff -C2 -d -r1.12 -r1.12.6.1 *** test_largefile.py 11 Dec 2001 17:57:26 -0000 1.12 --- test_largefile.py 16 Mar 2002 18:19:33 -0000 1.12.6.1 *************** *** 129,147 **** f.close() ! # XXX add tests for truncate if it exists ! # XXX has truncate ever worked on Windows? specifically on WinNT I get: ! # "IOError: [Errno 13] Permission denied" ! ##try: ! ## newsize = size - 10 ! ## f.seek(newsize) ! ## f.truncate() ! ## expect(f.tell(), newsize) ! ## newsize = newsize - 1 ! ## f.seek(0) ! ## f.truncate(newsize) ! ## expect(f.tell(), newsize) ! ##except AttributeError: ! ## pass os.unlink(name) --- 129,162 ---- f.close() + if hasattr(f, 'truncate'): + if test_support.verbose: + print 'try truncate' + f = open(name, 'r+b') + f.seek(0, 2) + expect(f.tell(), size+1) # else we've lost track of the true size + # Cut it back via seek + truncate with no argument. + newsize = size - 10 + f.seek(newsize) + f.truncate() + expect(f.tell(), newsize) # else pointer moved + f.seek(0, 2) + expect(f.tell(), newsize) # else wasn't truncated + # Ensure that truncate(smaller than true size) shrinks the file. + newsize -= 1 + f.seek(42) + f.truncate(newsize) + expect(f.tell(), 42) # else pointer moved + f.seek(0, 2) + expect(f.tell(), newsize) # else wasn't truncated ! # XXX truncate(larger than true size) is ill-defined across platforms ! ! # cut it waaaaay back ! f.seek(0) ! f.truncate(1) ! expect(f.tell(), 0) # else pointer moved ! expect(len(f.read()), 1) # else wasn't truncated ! ! f.close() os.unlink(name) From mwh@users.sourceforge.net Sat Mar 16 18:19:36 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sat, 16 Mar 2002 10:19:36 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libstdtypes.tex,1.80.6.1,1.80.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv28149/Doc/lib Modified Files: Tag: release22-maint libstdtypes.tex Log Message: Backport Tim's work on getting file.truncate working better on Win32. "cvs diff | patch" managed to stick the NEWS item in the 2.2 final section! I wonder which silly man wrote patch . Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.80.6.1 retrieving revision 1.80.6.2 diff -C2 -d -r1.80.6.1 -r1.80.6.2 *** libstdtypes.tex 28 Dec 2001 04:37:37 -0000 1.80.6.1 --- libstdtypes.tex 16 Mar 2002 18:19:33 -0000 1.80.6.2 *************** *** 162,166 **** \subsection{Numeric Types \label{typesnumeric}} ! There are four numeric types: \dfn{plain integers}, \dfn{long integers}, \dfn{floating point numbers}, and \dfn{complex numbers}. Plain integers (also just called \dfn{integers}) --- 162,166 ---- \subsection{Numeric Types \label{typesnumeric}} ! There are four numeric types: \dfn{plain integers}, \dfn{long integers}, \dfn{floating point numbers}, and \dfn{complex numbers}. Plain integers (also just called \dfn{integers}) *************** *** 179,183 **** Complex numbers have a real and imaginary part, which are both implemented using \ctype{double} in C. To extract these parts from ! a complex number \var{z}, use \code{\var{z}.real} and \code{\var{z}.imag}. Numbers are created by numeric literals or as the result of built-in --- 179,183 ---- Complex numbers have a real and imaginary part, which are both implemented using \ctype{double} in C. To extract these parts from ! a complex number \var{z}, use \code{\var{z}.real} and \code{\var{z}.imag}. Numbers are created by numeric literals or as the result of built-in *************** *** 249,253 **** \item[(1)] For (plain or long) integer division, the result is an integer. ! The result is always rounded towards minus infinity: 1/2 is 0, (-1)/2 is -1, 1/(-2) is -1, and (-1)/(-2) is 0. Note that the result is a long integer if either operand is a long integer, regardless of --- 249,253 ---- \item[(1)] For (plain or long) integer division, the result is an integer. ! The result is always rounded towards minus infinity: 1/2 is 0, (-1)/2 is -1, 1/(-2) is -1, and (-1)/(-2) is 0. Note that the result is a long integer if either operand is a long integer, regardless of *************** *** 473,477 **** \code{len(\var{s}) + \var{j}} is substituted. But note that \code{-0} is still \code{0}. ! \item[(3)] The slice of \var{s} from \var{i} to \var{j} is defined as the sequence of items with index \var{k} such that \code{\var{i} <= --- 473,477 ---- \code{len(\var{s}) + \var{j}} is substituted. But note that \code{-0} is still \code{0}. ! \item[(3)] The slice of \var{s} from \var{i} to \var{j} is defined as the sequence of items with index \var{k} such that \code{\var{i} <= *************** *** 809,813 **** Additional string operations are defined in standard modules \refmodule{string}\refstmodindex{string} and ! \refmodule{re}.\refstmodindex{re} --- 809,813 ---- Additional string operations are defined in standard modules \refmodule{string}\refstmodindex{string} and ! \refmodule{re}.\refstmodindex{re} *************** *** 882,886 **** deprecated since Python 1.4. ! \item[(2)] Raises an exception when \var{x} is not a list object. The \method{extend()} method is experimental and not supported by mutable sequence types other than lists. --- 882,886 ---- deprecated since Python 1.4. ! \item[(2)] Raises an exception when \var{x} is not a list object. The \method{extend()} method is experimental and not supported by mutable sequence types other than lists. *************** *** 1035,1039 **** File objects\obindex{file} are implemented using C's \code{stdio} package and can be created with the built-in constructor ! \function{file()}\bifuncindex{file} described in section \ref{built-in-funcs}, ``Built-in Functions.''\footnote{\function{file()} is new in Python 2.2. The older built-in \function{open()} is an --- 1035,1039 ---- File objects\obindex{file} are implemented using C's \code{stdio} package and can be created with the built-in constructor ! \function{file()}\bifuncindex{file} described in section \ref{built-in-funcs}, ``Built-in Functions.''\footnote{\function{file()} is new in Python 2.2. The older built-in \function{open()} is an *************** *** 1101,1108 **** Read one entire line from the file. A trailing newline character is kept in the string\footnote{ ! The advantage of leaving the newline on is that an empty string ! can be returned to mean \EOF{} without being ambiguous. Another ! advantage is that (in cases where it might matter, for example. if you ! want to make an exact copy of a file while scanning its lines) you can tell whether the last line of a file ended in a newline or not (yes this happens!). --- 1101,1108 ---- Read one entire line from the file. A trailing newline character is kept in the string\footnote{ ! The advantage of leaving the newline on is that an empty string ! can be returned to mean \EOF{} without being ambiguous. Another ! advantage is that (in cases where it might matter, for example. if you ! want to make an exact copy of a file while scanning its lines) you can tell whether the last line of a file ended in a newline or not (yes this happens!). *************** *** 1153,1161 **** \begin{methoddesc}[file]{truncate}{\optional{size}} ! Truncate the file's size. If the optional \var{size} argument present, the file is truncated to (at most) that size. The size ! defaults to the current position. Availability of this function ! depends on the operating system version (for example, not all ! \UNIX{} versions support this operation). \end{methoddesc} --- 1153,1165 ---- \begin{methoddesc}[file]{truncate}{\optional{size}} ! Truncate the file's size. If the optional \var{size} argument is present, the file is truncated to (at most) that size. The size ! defaults to the current position. The current file position is ! not changed. Note that if a specified size exceeds the file's ! current size, the result is platform-dependent: possibilities ! include that file may remain unchanged, increase to the specified ! size as if zero-filled, or increase to the specified size with ! undefined new content. ! Availability: Windows, many \UNIX variants. \end{methoddesc} From mwh@users.sourceforge.net Sat Mar 16 18:19:36 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sat, 16 Mar 2002 10:19:36 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects fileobject.c,2.141.6.1,2.141.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv28149/Objects Modified Files: Tag: release22-maint fileobject.c Log Message: Backport Tim's work on getting file.truncate working better on Win32. "cvs diff | patch" managed to stick the NEWS item in the 2.2 final section! I wonder which silly man wrote patch . Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.141.6.1 retrieving revision 2.141.6.2 diff -C2 -d -r2.141.6.1 -r2.141.6.2 *** fileobject.c 12 Jan 2002 11:13:24 -0000 2.141.6.1 --- fileobject.c 16 Mar 2002 18:19:33 -0000 2.141.6.2 *************** *** 11,16 **** #ifdef MS_WIN32 #define fileno _fileno ! /* can (almost fully) duplicate with _chsize, see file_truncate */ #define HAVE_FTRUNCATE #endif --- 11,18 ---- #ifdef MS_WIN32 #define fileno _fileno ! /* can simulate truncate with Win32 API functions; see file_truncate */ #define HAVE_FTRUNCATE + #define WINDOWS_LEAN_AND_MEAN + #include #endif *************** *** 376,379 **** --- 378,384 ---- if (!PyArg_ParseTuple(args, "|O:truncate", &newsizeobj)) return NULL; + + /* Set newsize to current postion if newsizeobj NULL, else to the + specified value. */ if (newsizeobj != NULL) { #if !defined(HAVE_LARGEFILE_SUPPORT) *************** *** 386,420 **** if (PyErr_Occurred()) return NULL; ! } else { ! /* Default to current position*/ Py_BEGIN_ALLOW_THREADS errno = 0; newsize = _portable_ftell(f->f_fp); Py_END_ALLOW_THREADS ! if (newsize == -1) { ! PyErr_SetFromErrno(PyExc_IOError); ! clearerr(f->f_fp); ! return NULL; ! } } Py_BEGIN_ALLOW_THREADS errno = 0; ret = fflush(f->f_fp); Py_END_ALLOW_THREADS ! if (ret != 0) goto onioerror; #ifdef MS_WIN32 ! /* can use _chsize; if, however, the newsize overflows 32-bits then ! _chsize is *not* adequate; in this case, an OverflowError is raised */ ! if (newsize > LONG_MAX) { ! PyErr_SetString(PyExc_OverflowError, ! "the new size is too long for _chsize (it is limited to 32-bit values)"); ! return NULL; ! } else { Py_BEGIN_ALLOW_THREADS errno = 0; ! ret = _chsize(fileno(f->f_fp), (long)newsize); Py_END_ALLOW_THREADS ! if (ret != 0) goto onioerror; } #else --- 391,468 ---- if (PyErr_Occurred()) return NULL; ! } ! else { ! /* Default to current position. */ Py_BEGIN_ALLOW_THREADS errno = 0; newsize = _portable_ftell(f->f_fp); Py_END_ALLOW_THREADS ! if (newsize == -1) ! goto onioerror; } + + /* Flush the file. */ Py_BEGIN_ALLOW_THREADS errno = 0; ret = fflush(f->f_fp); Py_END_ALLOW_THREADS ! if (ret != 0) ! goto onioerror; #ifdef MS_WIN32 ! /* MS _chsize doesn't work if newsize doesn't fit in 32 bits, ! so don't even try using it. */ ! { ! Py_off_t current; /* current file position */ ! HANDLE hFile; ! int error; ! ! /* current <- current file postion. */ ! if (newsizeobj == NULL) ! current = newsize; ! else { ! Py_BEGIN_ALLOW_THREADS ! errno = 0; ! current = _portable_ftell(f->f_fp); ! Py_END_ALLOW_THREADS ! if (current == -1) ! goto onioerror; ! } ! ! /* Move to newsize. */ ! if (current != newsize) { ! Py_BEGIN_ALLOW_THREADS ! errno = 0; ! error = _portable_fseek(f->f_fp, newsize, SEEK_SET) ! != 0; ! Py_END_ALLOW_THREADS ! if (error) ! goto onioerror; ! } ! ! /* Truncate. Note that this may grow the file! */ Py_BEGIN_ALLOW_THREADS errno = 0; ! hFile = (HANDLE)_get_osfhandle(fileno(f->f_fp)); ! error = hFile == (HANDLE)-1; ! if (!error) { ! error = SetEndOfFile(hFile) == 0; ! if (error) ! errno = EACCES; ! } Py_END_ALLOW_THREADS ! if (error) ! goto onioerror; ! ! /* Restore original file position. */ ! if (current != newsize) { ! Py_BEGIN_ALLOW_THREADS ! errno = 0; ! error = _portable_fseek(f->f_fp, current, SEEK_SET) ! != 0; ! Py_END_ALLOW_THREADS ! if (error) ! goto onioerror; ! } } #else From mwh@users.sourceforge.net Sat Mar 16 18:33:33 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sat, 16 Mar 2002 10:33:33 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_longexp.py,1.3,1.3.24.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv2570 Modified Files: Tag: release22-maint test_longexp.py Log Message: Merge jackjansen's checking of revision 1.5. Index: test_longexp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_longexp.py,v retrieving revision 1.3 retrieving revision 1.3.24.1 diff -C2 -d -r1.3 -r1.3.24.1 *** test_longexp.py 23 Oct 2000 17:22:07 -0000 1.3 --- test_longexp.py 16 Mar 2002 18:33:31 -0000 1.3.24.1 *************** *** 1,3 **** --- 1,11 ---- + import sys + from test_support import TestSkipped + REPS = 65580 + + if sys.platform == 'mac': + import gestalt + if gestalt.gestalt('sysv') > 0x9ff: + raise TestSkipped, 'Triggers pathological malloc slowdown on OSX MacPython' l = eval("[" + "2," * REPS + "]") From tim.one@comcast.net Sat Mar 16 21:12:14 2002 From: tim.one@comcast.net (Tim Peters) Date: Sat, 16 Mar 2002 16:12:14 -0500 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_largefile.py,1.12,1.12.6.1 In-Reply-To: Message-ID: > Modified Files: > Tag: release22-maint > test_largefile.py > Log Message: > Backport Tim's work on getting file.truncate working better on Win32. I think this is questionable for a bugfix release, and that's why I didn't mark it "bugfix candidate". It definitely changes behavior in "very large file position" cases, and I have no idea whether the current implementation exactly reproduces the old one in all "normal" cases (the semantics of the old MS _chsize() aren't documented by MS in sufficient detail to say). From loewis@users.sourceforge.net Sun Mar 17 09:53:53 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Sun, 17 Mar 2002 01:53:53 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python thread_pthread.h,2.38,2.39 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv15131 Modified Files: thread_pthread.h Log Message: Patch #525532: Add support for POSIX semaphores. Index: thread_pthread.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_pthread.h,v retrieving revision 2.38 retrieving revision 2.39 diff -C2 -d -r2.38 -r2.39 *** thread_pthread.h 19 Jan 2002 22:02:55 -0000 2.38 --- thread_pthread.h 17 Mar 2002 09:53:51 -0000 2.39 *************** *** 12,15 **** --- 12,19 ---- #endif #include + #ifdef _POSIX_SEMAPHORES + #include + #include + #endif *************** *** 77,80 **** --- 81,94 ---- + /* Whether or not to use semaphores directly rather than emulating them with + * mutexes and condition variables: + */ + #ifdef _POSIX_SEMAPHORES + # define USE_SEMAPHORES + #else + # undef USE_SEMAPHORES + #endif + + /* On platforms that don't use standard POSIX threads pthread_sigmask() * isn't present. DEC threads uses sigprocmask() instead as do most *************** *** 295,298 **** --- 309,415 ---- #endif /* NO_EXIT_PROG */ + #ifdef USE_SEMAPHORES + + /* + * Lock support. + */ + + PyThread_type_lock + PyThread_allocate_lock(void) + { + sem_t *lock; + int status, error = 0; + + dprintf(("PyThread_allocate_lock called\n")); + if (!initialized) + PyThread_init_thread(); + + lock = (sem_t *)malloc(sizeof(sem_t)); + + if (lock) { + status = sem_init(lock,0,1); + CHECK_STATUS("sem_init"); + + if (error) { + free((void *)lock); + lock = NULL; + } + } + + dprintf(("PyThread_allocate_lock() -> %p\n", lock)); + return (PyThread_type_lock)lock; + } + + void + PyThread_free_lock(PyThread_type_lock lock) + { + sem_t *thelock = (sem_t *)lock; + int status, error = 0; + + dprintf(("PyThread_free_lock(%p) called\n", lock)); + + if (!thelock) + return; + + status = sem_destroy(thelock); + CHECK_STATUS("sem_destroy"); + + free((void *)thelock); + } + + /* + * As of February 2002, Cygwin thread implementations mistakenly report error + * codes in the return value of the sem_ calls (like the pthread_ functions). + * Correct implementations return -1 and put the code in errno. This supports + * either. + */ + static int + fix_status(int status) + { + return (status == -1) ? errno : status; + } + + int + PyThread_acquire_lock(PyThread_type_lock lock, int waitflag) + { + int success; + sem_t *thelock = (sem_t *)lock; + int status, error = 0; + + dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); + + do { + if (waitflag) + status = fix_status(sem_wait(thelock)); + else + status = fix_status(sem_trywait(thelock)); + } while (status == EINTR); /* Retry if interrupted by a signal */ + + if (waitflag) { + CHECK_STATUS("sem_wait"); + } else if (status != EAGAIN) { + CHECK_STATUS("sem_trywait"); + } + + success = (status == 0) ? 1 : 0; + + dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); + return success; + } + + void + PyThread_release_lock(PyThread_type_lock lock) + { + sem_t *thelock = (sem_t *)lock; + int status, error = 0; + + dprintf(("PyThread_release_lock(%p) called\n", lock)); + + status = sem_post(thelock); + CHECK_STATUS("sem_post"); + } + + #else /* USE_SEMAPHORES */ + /* * Lock support. *************** *** 406,407 **** --- 523,526 ---- CHECK_STATUS("pthread_cond_signal"); } + + #endif /* USE_SEMAPHORES */ From mwh@users.sourceforge.net Sun Mar 17 15:55:52 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sun, 17 Mar 2002 07:55:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.337.2.4.2.4,1.337.2.4.2.5 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv20548/Misc Modified Files: Tag: release22-maint NEWS Log Message: Take Tim's work on file.truncate out of 2.2.1 again. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.337.2.4.2.4 retrieving revision 1.337.2.4.2.5 diff -C2 -d -r1.337.2.4.2.4 -r1.337.2.4.2.5 *** NEWS 16 Mar 2002 18:19:33 -0000 1.337.2.4.2.4 --- NEWS 17 Mar 2002 15:55:50 -0000 1.337.2.4.2.5 *************** *** 28,36 **** passed in. - Windows - - - file.truncate([newsize]) now works on Windows for all newsize values. - It used to fail if newsize didn't fit in 32 bits, reflecting a - limitation of MS _chsize (which is no longer used). What's New in Python 2.2 final? --- 28,31 ---- From mwh@users.sourceforge.net Sun Mar 17 15:55:53 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sun, 17 Mar 2002 07:55:53 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects fileobject.c,2.141.6.2,2.141.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv20548/Objects Modified Files: Tag: release22-maint fileobject.c Log Message: Take Tim's work on file.truncate out of 2.2.1 again. Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.141.6.2 retrieving revision 2.141.6.3 diff -C2 -d -r2.141.6.2 -r2.141.6.3 *** fileobject.c 16 Mar 2002 18:19:33 -0000 2.141.6.2 --- fileobject.c 17 Mar 2002 15:55:50 -0000 2.141.6.3 *************** *** 11,18 **** #ifdef MS_WIN32 #define fileno _fileno ! /* can simulate truncate with Win32 API functions; see file_truncate */ #define HAVE_FTRUNCATE - #define WINDOWS_LEAN_AND_MEAN - #include #endif --- 11,16 ---- #ifdef MS_WIN32 #define fileno _fileno ! /* can (almost fully) duplicate with _chsize, see file_truncate */ #define HAVE_FTRUNCATE #endif *************** *** 378,384 **** if (!PyArg_ParseTuple(args, "|O:truncate", &newsizeobj)) return NULL; - - /* Set newsize to current postion if newsizeobj NULL, else to the - specified value. */ if (newsizeobj != NULL) { #if !defined(HAVE_LARGEFILE_SUPPORT) --- 376,379 ---- *************** *** 391,468 **** if (PyErr_Occurred()) return NULL; ! } ! else { ! /* Default to current position. */ Py_BEGIN_ALLOW_THREADS errno = 0; newsize = _portable_ftell(f->f_fp); Py_END_ALLOW_THREADS ! if (newsize == -1) ! goto onioerror; } - - /* Flush the file. */ Py_BEGIN_ALLOW_THREADS errno = 0; ret = fflush(f->f_fp); Py_END_ALLOW_THREADS ! if (ret != 0) ! goto onioerror; #ifdef MS_WIN32 ! /* MS _chsize doesn't work if newsize doesn't fit in 32 bits, ! so don't even try using it. */ ! { ! Py_off_t current; /* current file position */ ! HANDLE hFile; ! int error; ! ! /* current <- current file postion. */ ! if (newsizeobj == NULL) ! current = newsize; ! else { ! Py_BEGIN_ALLOW_THREADS ! errno = 0; ! current = _portable_ftell(f->f_fp); ! Py_END_ALLOW_THREADS ! if (current == -1) ! goto onioerror; ! } ! ! /* Move to newsize. */ ! if (current != newsize) { ! Py_BEGIN_ALLOW_THREADS ! errno = 0; ! error = _portable_fseek(f->f_fp, newsize, SEEK_SET) ! != 0; ! Py_END_ALLOW_THREADS ! if (error) ! goto onioerror; ! } ! ! /* Truncate. Note that this may grow the file! */ Py_BEGIN_ALLOW_THREADS errno = 0; ! hFile = (HANDLE)_get_osfhandle(fileno(f->f_fp)); ! error = hFile == (HANDLE)-1; ! if (!error) { ! error = SetEndOfFile(hFile) == 0; ! if (error) ! errno = EACCES; ! } Py_END_ALLOW_THREADS ! if (error) ! goto onioerror; ! ! /* Restore original file position. */ ! if (current != newsize) { ! Py_BEGIN_ALLOW_THREADS ! errno = 0; ! error = _portable_fseek(f->f_fp, current, SEEK_SET) ! != 0; ! Py_END_ALLOW_THREADS ! if (error) ! goto onioerror; ! } } #else --- 386,420 ---- if (PyErr_Occurred()) return NULL; ! } else { ! /* Default to current position*/ Py_BEGIN_ALLOW_THREADS errno = 0; newsize = _portable_ftell(f->f_fp); Py_END_ALLOW_THREADS ! if (newsize == -1) { ! PyErr_SetFromErrno(PyExc_IOError); ! clearerr(f->f_fp); ! return NULL; ! } } Py_BEGIN_ALLOW_THREADS errno = 0; ret = fflush(f->f_fp); Py_END_ALLOW_THREADS ! if (ret != 0) goto onioerror; #ifdef MS_WIN32 ! /* can use _chsize; if, however, the newsize overflows 32-bits then ! _chsize is *not* adequate; in this case, an OverflowError is raised */ ! if (newsize > LONG_MAX) { ! PyErr_SetString(PyExc_OverflowError, ! "the new size is too long for _chsize (it is limited to 32-bit values)"); ! return NULL; ! } else { Py_BEGIN_ALLOW_THREADS errno = 0; ! ret = _chsize(fileno(f->f_fp), (long)newsize); Py_END_ALLOW_THREADS ! if (ret != 0) goto onioerror; } #else From mwh@users.sourceforge.net Sun Mar 17 15:55:52 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sun, 17 Mar 2002 07:55:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libstdtypes.tex,1.80.6.2,1.80.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv20548/Doc/lib Modified Files: Tag: release22-maint libstdtypes.tex Log Message: Take Tim's work on file.truncate out of 2.2.1 again. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.80.6.2 retrieving revision 1.80.6.3 diff -C2 -d -r1.80.6.2 -r1.80.6.3 *** libstdtypes.tex 16 Mar 2002 18:19:33 -0000 1.80.6.2 --- libstdtypes.tex 17 Mar 2002 15:55:50 -0000 1.80.6.3 *************** *** 162,166 **** \subsection{Numeric Types \label{typesnumeric}} ! There are four numeric types: \dfn{plain integers}, \dfn{long integers}, \dfn{floating point numbers}, and \dfn{complex numbers}. Plain integers (also just called \dfn{integers}) --- 162,166 ---- \subsection{Numeric Types \label{typesnumeric}} ! There are four numeric types: \dfn{plain integers}, \dfn{long integers}, \dfn{floating point numbers}, and \dfn{complex numbers}. Plain integers (also just called \dfn{integers}) *************** *** 179,183 **** Complex numbers have a real and imaginary part, which are both implemented using \ctype{double} in C. To extract these parts from ! a complex number \var{z}, use \code{\var{z}.real} and \code{\var{z}.imag}. Numbers are created by numeric literals or as the result of built-in --- 179,183 ---- Complex numbers have a real and imaginary part, which are both implemented using \ctype{double} in C. To extract these parts from ! a complex number \var{z}, use \code{\var{z}.real} and \code{\var{z}.imag}. Numbers are created by numeric literals or as the result of built-in *************** *** 249,253 **** \item[(1)] For (plain or long) integer division, the result is an integer. ! The result is always rounded towards minus infinity: 1/2 is 0, (-1)/2 is -1, 1/(-2) is -1, and (-1)/(-2) is 0. Note that the result is a long integer if either operand is a long integer, regardless of --- 249,253 ---- \item[(1)] For (plain or long) integer division, the result is an integer. ! The result is always rounded towards minus infinity: 1/2 is 0, (-1)/2 is -1, 1/(-2) is -1, and (-1)/(-2) is 0. Note that the result is a long integer if either operand is a long integer, regardless of *************** *** 473,477 **** \code{len(\var{s}) + \var{j}} is substituted. But note that \code{-0} is still \code{0}. ! \item[(3)] The slice of \var{s} from \var{i} to \var{j} is defined as the sequence of items with index \var{k} such that \code{\var{i} <= --- 473,477 ---- \code{len(\var{s}) + \var{j}} is substituted. But note that \code{-0} is still \code{0}. ! \item[(3)] The slice of \var{s} from \var{i} to \var{j} is defined as the sequence of items with index \var{k} such that \code{\var{i} <= *************** *** 809,813 **** Additional string operations are defined in standard modules \refmodule{string}\refstmodindex{string} and ! \refmodule{re}.\refstmodindex{re} --- 809,813 ---- Additional string operations are defined in standard modules \refmodule{string}\refstmodindex{string} and ! \refmodule{re}.\refstmodindex{re} *************** *** 882,886 **** deprecated since Python 1.4. ! \item[(2)] Raises an exception when \var{x} is not a list object. The \method{extend()} method is experimental and not supported by mutable sequence types other than lists. --- 882,886 ---- deprecated since Python 1.4. ! \item[(2)] Raises an exception when \var{x} is not a list object. The \method{extend()} method is experimental and not supported by mutable sequence types other than lists. *************** *** 1035,1039 **** File objects\obindex{file} are implemented using C's \code{stdio} package and can be created with the built-in constructor ! \function{file()}\bifuncindex{file} described in section \ref{built-in-funcs}, ``Built-in Functions.''\footnote{\function{file()} is new in Python 2.2. The older built-in \function{open()} is an --- 1035,1039 ---- File objects\obindex{file} are implemented using C's \code{stdio} package and can be created with the built-in constructor ! \function{file()}\bifuncindex{file} described in section \ref{built-in-funcs}, ``Built-in Functions.''\footnote{\function{file()} is new in Python 2.2. The older built-in \function{open()} is an *************** *** 1101,1108 **** Read one entire line from the file. A trailing newline character is kept in the string\footnote{ ! The advantage of leaving the newline on is that an empty string ! can be returned to mean \EOF{} without being ambiguous. Another ! advantage is that (in cases where it might matter, for example. if you ! want to make an exact copy of a file while scanning its lines) you can tell whether the last line of a file ended in a newline or not (yes this happens!). --- 1101,1108 ---- Read one entire line from the file. A trailing newline character is kept in the string\footnote{ ! The advantage of leaving the newline on is that an empty string ! can be returned to mean \EOF{} without being ambiguous. Another ! advantage is that (in cases where it might matter, for example. if you ! want to make an exact copy of a file while scanning its lines) you can tell whether the last line of a file ended in a newline or not (yes this happens!). *************** *** 1153,1165 **** \begin{methoddesc}[file]{truncate}{\optional{size}} ! Truncate the file's size. If the optional \var{size} argument is present, the file is truncated to (at most) that size. The size ! defaults to the current position. The current file position is ! not changed. Note that if a specified size exceeds the file's ! current size, the result is platform-dependent: possibilities ! include that file may remain unchanged, increase to the specified ! size as if zero-filled, or increase to the specified size with ! undefined new content. ! Availability: Windows, many \UNIX variants. \end{methoddesc} --- 1153,1161 ---- \begin{methoddesc}[file]{truncate}{\optional{size}} ! Truncate the file's size. If the optional \var{size} argument present, the file is truncated to (at most) that size. The size ! defaults to the current position. Availability of this function ! depends on the operating system version (for example, not all ! \UNIX{} versions support this operation). \end{methoddesc} From mwh@users.sourceforge.net Sun Mar 17 15:55:52 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sun, 17 Mar 2002 07:55:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_largefile.py,1.12.6.1,1.12.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv20548/Lib/test Modified Files: Tag: release22-maint test_largefile.py Log Message: Take Tim's work on file.truncate out of 2.2.1 again. Index: test_largefile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_largefile.py,v retrieving revision 1.12.6.1 retrieving revision 1.12.6.2 diff -C2 -d -r1.12.6.1 -r1.12.6.2 *** test_largefile.py 16 Mar 2002 18:19:33 -0000 1.12.6.1 --- test_largefile.py 17 Mar 2002 15:55:50 -0000 1.12.6.2 *************** *** 129,162 **** f.close() - if hasattr(f, 'truncate'): - if test_support.verbose: - print 'try truncate' - f = open(name, 'r+b') - f.seek(0, 2) - expect(f.tell(), size+1) # else we've lost track of the true size - # Cut it back via seek + truncate with no argument. - newsize = size - 10 - f.seek(newsize) - f.truncate() - expect(f.tell(), newsize) # else pointer moved - f.seek(0, 2) - expect(f.tell(), newsize) # else wasn't truncated - # Ensure that truncate(smaller than true size) shrinks the file. - newsize -= 1 - f.seek(42) - f.truncate(newsize) - expect(f.tell(), 42) # else pointer moved - f.seek(0, 2) - expect(f.tell(), newsize) # else wasn't truncated - - # XXX truncate(larger than true size) is ill-defined across platforms ! # cut it waaaaay back ! f.seek(0) ! f.truncate(1) ! expect(f.tell(), 0) # else pointer moved ! expect(len(f.read()), 1) # else wasn't truncated ! ! f.close() os.unlink(name) --- 129,147 ---- f.close() ! # XXX add tests for truncate if it exists ! # XXX has truncate ever worked on Windows? specifically on WinNT I get: ! # "IOError: [Errno 13] Permission denied" ! ##try: ! ## newsize = size - 10 ! ## f.seek(newsize) ! ## f.truncate() ! ## expect(f.tell(), newsize) ! ## newsize = newsize - 1 ! ## f.seek(0) ! ## f.truncate(newsize) ! ## expect(f.tell(), newsize) ! ##except AttributeError: ! ## pass os.unlink(name) From loewis@users.sourceforge.net Sun Mar 17 17:19:03 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Sun, 17 Mar 2002 09:19:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python thread_pthread.h,2.39,2.40 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv6115 Modified Files: thread_pthread.h Log Message: Document that _POSIX_SEMAPHORES is predefined. Index: thread_pthread.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_pthread.h,v retrieving revision 2.39 retrieving revision 2.40 diff -C2 -d -r2.39 -r2.40 *** thread_pthread.h 17 Mar 2002 09:53:51 -0000 2.39 --- thread_pthread.h 17 Mar 2002 17:19:00 -0000 2.40 *************** *** 12,15 **** --- 12,19 ---- #endif #include + + /* The POSIX spec says that implementations supporting the sem_* + family of functions must indicate this by defining + _POSIX_SEMAPHORES. */ #ifdef _POSIX_SEMAPHORES #include From mwh@users.sourceforge.net Sun Mar 17 17:54:34 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sun, 17 Mar 2002 09:54:34 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib tempfile.py,1.34,1.34.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv13535 Modified Files: Tag: release22-maint tempfile.py Log Message: So there is some merit in slogging through ~4800 lines of cvs log. Bring tempfile.py up to date from the trunk. There have been three checkins (all by Tim): SF bug #509805 tempfile.gettempdir not threadsafe This is an ancient race when multiple threads call gettempdir() (or anything relying on it) for the first time. Fixed x-platform via the Big Hammer of rearranging the code to serialize the first calls. Subsequent calls are as fast as before. Note that the Python test suite can't provoke this bug: it requires setting up multiple threads making the very first calls into tempfile, but the test suite uses tempfile several times before getting to test_threadedtempfile. Bugfix candidate. [and] New TemporaryFile implementation for Windows: this doesn't need a TemproraryFileWrapper wrapper anymore, and should be immune from the problem that a temp file inherited by a spawned process caused an attempt to close the temp file in the spawning process to blow up (the unlink in TemporaryFileWrapper.close() blew up with a "Permission denied" error because, despite that the temp file got closed in the spawning process, the spawned process still had it open by virtue of C-level file descriptor inheritance). In context, that bug took days to figure out . [and] Thanks to Detlef Lannert for pointing out a typo in the code that uses _DummyMutex on platforms without threads. The first and third of these are pretty clearly bugfixes; I think the second is too. Index: tempfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tempfile.py,v retrieving revision 1.34 retrieving revision 1.34.4.1 diff -C2 -d -r1.34 -r1.34.4.1 *** tempfile.py 18 Dec 2001 23:22:01 -0000 1.34 --- tempfile.py 17 Mar 2002 17:54:32 -0000 1.34.4.1 *************** *** 18,21 **** --- 18,45 ---- if tempdir is not None: return tempdir + + # _gettempdir_inner deduces whether a candidate temp dir is usable by + # trying to create a file in it, and write to it. If that succeeds, + # great, it closes the file and unlinks it. There's a race, though: + # the *name* of the test file it tries is the same across all threads + # under most OSes (Linux is an exception), and letting multiple threads + # all try to open, write to, close, and unlink a single file can cause + # a variety of bogus errors (e.g., you cannot unlink a file under + # Windows if anyone has it open, and two threads cannot create the + # same file in O_EXCL mode under Unix). The simplest cure is to serialize + # calls to _gettempdir_inner. This isn't a real expense, because the + # first thread to succeed sets the global tempdir, and all subsequent + # calls to gettempdir() reuse that without trying _gettempdir_inner. + _tempdir_lock.acquire() + try: + return _gettempdir_inner() + finally: + _tempdir_lock.release() + + def _gettempdir_inner(): + """Function to calculate the directory to use.""" + global tempdir + if tempdir is not None: + return tempdir try: pwd = os.getcwd() *************** *** 170,175 **** os.close(fd) raise else: ! # Non-unix -- can't unlink file that's still open, use wrapper file = open(name, mode, bufsize) return TemporaryFileWrapper(file, name) --- 194,215 ---- os.close(fd) raise + elif os.name == 'nt': + # Windows -- can't unlink an open file, but O_TEMPORARY creates a + # file that "deletes itself" when the last handle is closed. + # O_NOINHERIT ensures processes created via spawn() don't get a + # handle to this too. That would be a security hole, and, on my + # Win98SE box, when an O_TEMPORARY file is inherited by a spawned + # process, the fd in the spawned process seems to lack the + # O_TEMPORARY flag, so the file doesn't go away by magic then if the + # spawning process closes it first. + flags = (os.O_RDWR | os.O_CREAT | os.O_EXCL | + os.O_TEMPORARY | os.O_NOINHERIT) + if 'b' in mode: + flags |= os.O_BINARY + fd = os.open(name, flags, 0700) + return os.fdopen(fd, mode, bufsize) else: ! # Assume we can't unlink a file that's still open, or arrange for ! # an automagically self-deleting file -- use wrapper. file = open(name, mode, bufsize) return TemporaryFileWrapper(file, name) *************** *** 180,185 **** # usually be a Python int, but if _counter.get_next() is called often # enough, it will become a Python long. ! # Note that the only name that survives this next block of code ! # is "_counter". class _ThreadSafeCounter: --- 220,225 ---- # usually be a Python int, but if _counter.get_next() is called often # enough, it will become a Python long. ! # Note that the only names that survive this next block of code ! # are "_counter" and "_tempdir_lock". class _ThreadSafeCounter: *************** *** 210,217 **** --- 250,259 ---- _counter = _ThreadSafeCounter(_DummyMutex()) + _tempdir_lock = _DummyMutex() del _DummyMutex else: _counter = _ThreadSafeCounter(thread.allocate_lock()) + _tempdir_lock = thread.allocate_lock() del thread From mwh@users.sourceforge.net Sun Mar 17 18:02:54 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sun, 17 Mar 2002 10:02:54 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib tempfile.py,1.34.4.1,1.34.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv16683 Modified Files: Tag: release22-maint tempfile.py Log Message: Stop using not-exposed-in-22x os.O_ constants. Index: tempfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tempfile.py,v retrieving revision 1.34.4.1 retrieving revision 1.34.4.2 diff -C2 -d -r1.34.4.1 -r1.34.4.2 *** tempfile.py 17 Mar 2002 17:54:32 -0000 1.34.4.1 --- tempfile.py 17 Mar 2002 18:02:51 -0000 1.34.4.2 *************** *** 194,215 **** os.close(fd) raise - elif os.name == 'nt': - # Windows -- can't unlink an open file, but O_TEMPORARY creates a - # file that "deletes itself" when the last handle is closed. - # O_NOINHERIT ensures processes created via spawn() don't get a - # handle to this too. That would be a security hole, and, on my - # Win98SE box, when an O_TEMPORARY file is inherited by a spawned - # process, the fd in the spawned process seems to lack the - # O_TEMPORARY flag, so the file doesn't go away by magic then if the - # spawning process closes it first. - flags = (os.O_RDWR | os.O_CREAT | os.O_EXCL | - os.O_TEMPORARY | os.O_NOINHERIT) - if 'b' in mode: - flags |= os.O_BINARY - fd = os.open(name, flags, 0700) - return os.fdopen(fd, mode, bufsize) else: ! # Assume we can't unlink a file that's still open, or arrange for ! # an automagically self-deleting file -- use wrapper. file = open(name, mode, bufsize) return TemporaryFileWrapper(file, name) --- 194,199 ---- os.close(fd) raise else: ! # Non-unix -- can't unlink file that's still open, use wrapper file = open(name, mode, bufsize) return TemporaryFileWrapper(file, name) From mwh@users.sourceforge.net Sun Mar 17 18:05:05 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sun, 17 Mar 2002 10:05:05 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_dumbdbm.py,1.4,1.4.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv17275 Modified Files: Tag: release22-maint test_dumbdbm.py Log Message: Backport Tim's checkin of revision 1.5: This test left a new set of 3 junk files behind each time it was run. Index: test_dumbdbm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_dumbdbm.py,v retrieving revision 1.4 retrieving revision 1.4.8.1 diff -C2 -d -r1.4 -r1.4.8.1 *** test_dumbdbm.py 13 Nov 2001 21:51:26 -0000 1.4 --- test_dumbdbm.py 17 Mar 2002 18:05:03 -0000 1.4.8.1 *************** *** 10,15 **** import tempfile class DumbDBMTestCase(unittest.TestCase): - _fname = tempfile.mktemp() _dict = {'0': '', 'a': 'Python:', --- 10,23 ---- import tempfile + _fname = tempfile.mktemp() + + def _delete_files(): + for ext in [".dir", ".dat", ".bak"]: + try: + os.unlink(_fname + ext) + except OSError: + pass + class DumbDBMTestCase(unittest.TestCase): _dict = {'0': '', 'a': 'Python:', *************** *** 27,35 **** def test_dumbdbm_creation(self): ! for ext in [".dir", ".dat", ".bak"]: ! try: os.unlink(self._fname+ext) ! except OSError: pass ! ! f = dumbdbm.open(self._fname, 'c') self.assertEqual(f.keys(), []) for key in self._dict: --- 35,40 ---- def test_dumbdbm_creation(self): ! _delete_files() ! f = dumbdbm.open(_fname, 'c') self.assertEqual(f.keys(), []) for key in self._dict: *************** *** 39,43 **** def test_dumbdbm_modification(self): ! f = dumbdbm.open(self._fname, 'w') self._dict['g'] = f['g'] = "indented" self.read_helper(f) --- 44,48 ---- def test_dumbdbm_modification(self): ! f = dumbdbm.open(_fname, 'w') self._dict['g'] = f['g'] = "indented" self.read_helper(f) *************** *** 45,54 **** def test_dumbdbm_read(self): ! f = dumbdbm.open(self._fname, 'r') self.read_helper(f) f.close() def test_dumbdbm_keys(self): ! f = dumbdbm.open(self._fname) keys = self.keys_helper(f) f.close() --- 50,59 ---- def test_dumbdbm_read(self): ! f = dumbdbm.open(_fname, 'r') self.read_helper(f) f.close() def test_dumbdbm_keys(self): ! f = dumbdbm.open(_fname) keys = self.keys_helper(f) f.close() *************** *** 66,71 **** def test_main(): ! test_support.run_unittest(DumbDBMTestCase) ! if __name__ == "__main__": --- 71,78 ---- def test_main(): ! try: ! test_support.run_unittest(DumbDBMTestCase) ! finally: ! _delete_files() if __name__ == "__main__": From loewis@users.sourceforge.net Sun Mar 17 18:19:15 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Sun, 17 Mar 2002 10:19:15 -0800 Subject: [Python-checkins] CVS: python/dist/src/Demo/tix tixwidgets.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/tix In directory usw-pr-cvs1:/tmp/cvs-serv20863 Modified Files: tixwidgets.py Log Message: Patch #485959: Various changes to Tix demos. Index: tixwidgets.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/tixwidgets.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tixwidgets.py 1 Mar 2002 13:07:34 -0000 1.5 --- tixwidgets.py 17 Mar 2002 18:19:13 -0000 1.6 *************** *** 155,159 **** try: tkMessageBox.showerror ('Error', text) except: pass ! tkinspect_quit (1) def destroy (self): --- 155,160 ---- try: tkMessageBox.showerror ('Error', text) except: pass ! self.exit = 1 ! raise SystemExit, 1 def destroy (self): *************** *** 421,427 **** def MkFileBox(w): msg = Tix.Message(w, relief=Tix.FLAT, width=240, anchor=Tix.N, ! text='The TixFileSelectBox is a Motif-style box with various enhancements. For example, you can adjust the size of the two listboxes and your past selections are recorded.') box = Tix.FileSelectBox(w) msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3) --- 422,432 ---- def MkFileBox(w): + """The FileSelectBox is a Motif-style box with various enhancements. + For example, you can adjust the size of the two listboxes + and your past selections are recorded. + """ msg = Tix.Message(w, relief=Tix.FLAT, width=240, anchor=Tix.N, ! text='The Tix FileSelectBox is a Motif-style box with various enhancements. For example, you can adjust the size of the two listboxes and your past selections are recorded.') box = Tix.FileSelectBox(w) msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3) From loewis@users.sourceforge.net Sun Mar 17 18:19:15 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Sun, 17 Mar 2002 10:19:15 -0800 Subject: [Python-checkins] CVS: python/dist/src/Demo/tix/samples Balloon.py,1.1,1.2 BtnBox.py,1.1,1.2 CmpImg.py,1.1,1.2 ComboBox.py,1.1,1.2 Control.py,1.2,1.3 DirList.py,1.1,1.2 DirTree.py,1.1,1.2 NoteBook.py,1.1,1.2 OptMenu.py,1.1,1.2 PopMenu.py,1.1,1.2 SHList1.py,1.2,1.3 SHList2.py,1.2,1.3 Tree.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/tix/samples In directory usw-pr-cvs1:/tmp/cvs-serv20863/samples Modified Files: Balloon.py BtnBox.py CmpImg.py ComboBox.py Control.py DirList.py DirTree.py NoteBook.py OptMenu.py PopMenu.py SHList1.py SHList2.py Tree.py Log Message: Patch #485959: Various changes to Tix demos. Index: Balloon.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/Balloon.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Balloon.py 21 Mar 2001 07:42:07 -0000 1.1 --- Balloon.py 17 Mar 2002 18:19:13 -0000 1.2 *************** *** 1,4 **** ! #!/usr/local/bin/python ! # # $Id$ # --- 1,4 ---- ! # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- ! # # $Id$ # *************** *** 6,10 **** # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone --- 6,10 ---- # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets.py": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone *************** *** 18,45 **** import Tix ! def RunSample(w): ! status = Tix.Label(w, width=40, relief=Tix.SUNKEN, bd=1) ! status.pack(side=Tix.BOTTOM, fill=Tix.Y, padx=2, pady=1) ! # Create two mysterious widgets that need balloon help ! button1 = Tix.Button(w, text='Something Unexpected', ! command=lambda w=w: w.destroy()) ! button2 = Tix.Button(w, text='Something Else Unexpected') ! button2['command'] = lambda w=button2: w.destroy() ! button1.pack(side=Tix.TOP, expand=1) ! button2.pack(side=Tix.TOP, expand=1) ! # Create the balloon widget and associate it with the widgets that we want ! # to provide tips for: ! b = Tix.Balloon(w, statusbar=status) ! b.bind_widget(button1, balloonmsg='Close Window', ! statusmsg='Press this button to close this window') ! b.bind_widget(button2, balloonmsg='Self-destruct button', ! statusmsg='Press this button and it will destroy itself') if __name__ == '__main__': root = Tix.Tk() - RunSample(root) - root.mainloop() --- 18,68 ---- import Tix ! TCL_ALL_EVENTS = 0 ! def RunSample (root): ! balloon = DemoBalloon(root) ! balloon.mainloop() ! balloon.destroy() ! class DemoBalloon: ! def __init__(self, w): ! self.root = w ! self.exit = -1 ! z = w.winfo_toplevel() ! z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd()) ! ! status = Tix.Label(w, width=40, relief=Tix.SUNKEN, bd=1) ! status.pack(side=Tix.BOTTOM, fill=Tix.Y, padx=2, pady=1) ! ! # Create two mysterious widgets that need balloon help ! button1 = Tix.Button(w, text='Something Unexpected', ! command=self.quitcmd) ! button2 = Tix.Button(w, text='Something Else Unexpected') ! button2['command'] = lambda w=button2: w.destroy() ! button1.pack(side=Tix.TOP, expand=1) ! button2.pack(side=Tix.TOP, expand=1) ! ! # Create the balloon widget and associate it with the widgets that we want ! # to provide tips for: ! b = Tix.Balloon(w, statusbar=status) ! ! b.bind_widget(button1, balloonmsg='Close Window', ! statusmsg='Press this button to close this window') ! b.bind_widget(button2, balloonmsg='Self-destruct button', ! statusmsg='Press this button and it will destroy itself') ! ! def quitcmd (self): ! self.exit = 0 ! ! def mainloop(self): ! foundEvent = 1 ! while self.exit < 0 and foundEvent > 0: ! foundEvent = self.root.tk.dooneevent(TCL_ALL_EVENTS) ! ! def destroy (self): ! self.root.destroy() if __name__ == '__main__': root = Tix.Tk() RunSample(root) Index: BtnBox.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/BtnBox.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BtnBox.py 21 Mar 2001 07:42:07 -0000 1.1 --- BtnBox.py 17 Mar 2002 18:19:13 -0000 1.2 *************** *** 1,3 **** ! #!/usr/local/bin/python # # $Id$ --- 1,3 ---- ! # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- # # $Id$ *************** *** 6,10 **** # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone --- 6,10 ---- # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets.py": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone Index: CmpImg.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/CmpImg.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CmpImg.py 21 Mar 2001 07:42:07 -0000 1.1 --- CmpImg.py 17 Mar 2002 18:19:13 -0000 1.2 *************** *** 1,3 **** ! #!/usr/local/bin/python # # $Id$ --- 1,3 ---- ! # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- # # $Id$ *************** *** 6,10 **** # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone --- 6,10 ---- # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets.py": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone Index: ComboBox.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/ComboBox.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ComboBox.py 21 Mar 2001 07:42:07 -0000 1.1 --- ComboBox.py 17 Mar 2002 18:19:13 -0000 1.2 *************** *** 1,3 **** ! #!/usr/local/bin/python # # $Id$ --- 1,3 ---- ! # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- # # $Id$ *************** *** 6,10 **** # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone --- 6,10 ---- # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets.py": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone *************** *** 86,96 **** def select_month(event=None): ! print "Month =", demo_month.get() def select_year(event=None): ! print "Year =", demo_year.get() def ok_command(w): ! print "Month =", demo_month.get(), ", Year=", demo_year.get() w.destroy() --- 86,98 ---- def select_month(event=None): ! # tixDemo:Status "Month = %s" % demo_month.get() ! pass def select_year(event=None): ! # tixDemo:Status "Year = %s" % demo_year.get() ! pass def ok_command(w): ! # tixDemo:Status "Month = %s, Year= %s" % (demo_month.get(), demo_year.get()) w.destroy() Index: Control.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/Control.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Control.py 11 May 2001 19:52:03 -0000 1.2 --- Control.py 17 Mar 2002 18:19:13 -0000 1.3 *************** *** 1,4 **** ! #!/usr/local/bin/python ! # # $Id$ # --- 1,4 ---- ! # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- ! # # $Id$ # *************** *** 6,10 **** # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone --- 6,10 ---- # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets.py": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone *************** *** 18,72 **** # integer values; one lets you select floating point values and the last # one lets you select a few names. ! # import Tix ! def RunSample(w): ! global demo_maker, demo_thrust, demo_num_engines ! demo_maker = Tix.StringVar() ! demo_thrust = Tix.DoubleVar() ! demo_num_engines = Tix.IntVar() ! demo_maker.set('P&W') ! demo_thrust.set(20000.0) ! demo_num_engines.set(2) ! top = Tix.Frame(w, bd=1, relief=Tix.RAISED) ! # $w.top.a allows only integer values ! # ! # [Hint] The -options switch sets the options of the subwidgets. ! # [Hint] We set the label.width subwidget option of the Controls to ! # be 16 so that their labels appear to be aligned. ! # ! a = Tix.Control(top, label='Number of Engines: ', integer=1, ! variable=demo_num_engines, min=1, max=4, ! options='entry.width 10 label.width 20 label.anchor e') ! ! b = Tix.Control(top, label='Thrust: ', integer=0, ! min='10000.0', max='60000.0', step=500, ! variable=demo_thrust, ! options='entry.width 10 label.width 20 label.anchor e') ! c = Tix.Control(top, label='Engine Maker: ', value='P&W', ! variable=demo_maker, ! options='entry.width 10 label.width 20 label.anchor e') ! # We can't define these in the init because the widget 'c' doesn't ! # exist yet and we need to reference it ! c['incrcmd'] = lambda w=c: adjust_maker(w, 1) ! c['decrcmd'] = lambda w=c: adjust_maker(w, -1) ! c['validatecmd'] = lambda w=c: validate_maker(w) ! a.pack(side=Tix.TOP, anchor=Tix.W) ! b.pack(side=Tix.TOP, anchor=Tix.W) ! c.pack(side=Tix.TOP, anchor=Tix.W) ! box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL) ! box.add('ok', text='Ok', underline=0, width=6, ! command=lambda w=w: ok_command(w)) ! box.add('cancel', text='Cancel', underline=0, width=6, ! command=lambda w=w: w.destroy()) ! box.pack(side=Tix.BOTTOM, fill=Tix.X) ! top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1) maker_list = ['P&W', 'GE', 'Rolls Royce'] --- 18,97 ---- # integer values; one lets you select floating point values and the last # one lets you select a few names. ! import Tix ! TCL_ALL_EVENTS = 0 ! def RunSample (root): ! control = DemoControl(root) ! control.mainloop() ! control.destroy() ! class DemoControl: ! def __init__(self, w): ! self.root = w ! self.exit = -1 ! global demo_maker, demo_thrust, demo_num_engines ! demo_maker = Tix.StringVar() ! demo_thrust = Tix.DoubleVar() ! demo_num_engines = Tix.IntVar() ! demo_maker.set('P&W') ! demo_thrust.set(20000.0) ! demo_num_engines.set(2) ! top = Tix.Frame(w, bd=1, relief=Tix.RAISED) ! # $w.top.a allows only integer values ! # ! # [Hint] The -options switch sets the options of the subwidgets. ! # [Hint] We set the label.width subwidget option of the Controls to ! # be 16 so that their labels appear to be aligned. ! # ! a = Tix.Control(top, label='Number of Engines: ', integer=1, ! variable=demo_num_engines, min=1, max=4, ! options='entry.width 10 label.width 20 label.anchor e') ! b = Tix.Control(top, label='Thrust: ', integer=0, ! min='10000.0', max='60000.0', step=500, ! variable=demo_thrust, ! options='entry.width 10 label.width 20 label.anchor e') ! ! c = Tix.Control(top, label='Engine Maker: ', value='P&W', ! variable=demo_maker, ! options='entry.width 10 label.width 20 label.anchor e') ! ! # We can't define these in the init because the widget 'c' doesn't ! # exist yet and we need to reference it ! c['incrcmd'] = lambda w=c: adjust_maker(w, 1) ! c['decrcmd'] = lambda w=c: adjust_maker(w, -1) ! c['validatecmd'] = lambda w=c: validate_maker(w) ! ! a.pack(side=Tix.TOP, anchor=Tix.W) ! b.pack(side=Tix.TOP, anchor=Tix.W) ! c.pack(side=Tix.TOP, anchor=Tix.W) ! ! box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL) ! box.add('ok', text='Ok', underline=0, width=6, ! command=self.okcmd) ! box.add('cancel', text='Cancel', underline=0, width=6, ! command=self.quitcmd) ! box.pack(side=Tix.BOTTOM, fill=Tix.X) ! top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1) ! ! def okcmd (self): ! # tixDemo:Status "Selected %d of %s engines each of thrust %d", (demo_num_engines.get(), demo_maker.get(), demo_thrust.get()) ! self.quitcmd() ! ! def quitcmd (self): ! self.exit = 0 ! ! def mainloop(self): ! while self.exit < 0: ! self.root.tk.dooneevent(TCL_ALL_EVENTS) ! ! def destroy (self): ! self.root.destroy() maker_list = ['P&W', 'GE', 'Rolls Royce'] *************** *** 93,102 **** return maker_list[i] - def ok_command(w): - print "Selected", demo_num_engines.get(), "of", demo_maker.get(), " engines each of thrust", demo_thrust.get() - w.destroy() - if __name__ == '__main__': root = Tix.Tk() RunSample(root) - root.mainloop() --- 118,122 ---- Index: DirList.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/DirList.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DirList.py 11 Nov 2001 14:07:37 -0000 1.1 --- DirList.py 17 Mar 2002 18:19:13 -0000 1.2 *************** *** 6,10 **** # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "widget": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone --- 6,10 ---- # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets.py": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone *************** *** 20,32 **** from Tkconstants import * - TCL_DONT_WAIT = 1<<1 - TCL_WINDOW_EVENTS = 1<<2 - TCL_FILE_EVENTS = 1<<3 - TCL_TIMER_EVENTS = 1<<4 - TCL_IDLE_EVENTS = 1<<5 TCL_ALL_EVENTS = 0 def RunSample (root): - global dirlist dirlist = DemoDirList(root) dirlist.mainloop() --- 20,26 ---- *************** *** 39,43 **** z = w.winfo_toplevel() ! z.wm_title('Tix.DirList Widget Demo') # Create the tixDirList and the tixLabelEntry widgets on the on the top --- 33,37 ---- z = w.winfo_toplevel() ! z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd()) # Create the tixDirList and the tixLabelEntry widgets on the on the top *************** *** 99,103 **** box.pack( anchor='s', fill='x', side=BOTTOM) - z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd()) def copy_name (self, dir, ent): --- 93,96 ---- *************** *** 109,118 **** def okcmd (self): ! # tixDemo:Status "You have selected the directory" + $self.dlist_dir ! self.quitcmd() def quitcmd (self): - # self.root.destroy() self.exit = 0 --- 102,109 ---- def okcmd (self): ! # tixDemo:Status "You have selected the directory" + self.dlist_dir self.quitcmd() def quitcmd (self): self.exit = 0 *************** *** 120,124 **** while self.exit < 0: self.root.tk.dooneevent(TCL_ALL_EVENTS) - # self.root.tk.dooneevent(TCL_DONT_WAIT) def destroy (self): --- 111,114 ---- *************** *** 126,130 **** # This "if" statement makes it possible to run this script file inside or ! # outside of the main demo program "widget". # if __name__== '__main__' : --- 116,120 ---- # This "if" statement makes it possible to run this script file inside or ! # outside of the main demo program "tixwidgets.py". # if __name__== '__main__' : Index: DirTree.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/DirTree.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DirTree.py 11 Nov 2001 14:07:37 -0000 1.1 --- DirTree.py 17 Mar 2002 18:19:13 -0000 1.2 *************** *** 6,10 **** # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "widget": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone --- 6,10 ---- # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets.py": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone *************** *** 20,33 **** from Tkconstants import * ! def RunSample (w): ! DemoDirTree(w) class DemoDirTree: def __init__(self, w): self.root = w z = w.winfo_toplevel() ! z.wm_title('Tix.DirTree Widget Demo') ! # Create the tixDirTree and the tixLabelEntry widgets on the on the top # of the dialog box --- 20,38 ---- from Tkconstants import * ! TCL_ALL_EVENTS = 0 ! ! def RunSample (root): ! dirtree = DemoDirTree(root) ! dirtree.mainloop() ! dirtree.destroy() class DemoDirTree: def __init__(self, w): self.root = w + self.exit = -1 z = w.winfo_toplevel() ! z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd()) ! # Create the tixDirTree and the tixLabelEntry widgets on the on the top # of the dialog box *************** *** 91,108 **** def okcmd (self): ! # tixDemo:Status "You have selected the directory" + $self.dlist_dir ! self.quitcmd() def quitcmd (self): self.root.destroy() # This "if" statement makes it possible to run this script file inside or ! # outside of the main demo program "widget". # if __name__== '__main__' : root=Tix.Tk() RunSample(root) - root.mainloop() - root.destroy() --- 96,118 ---- def okcmd (self): ! # tixDemo:Status "You have selected the directory" + self.dlist_dir self.quitcmd() def quitcmd (self): + # tixDemo:Status "You have selected the directory" + self.dlist_dir + self.exit = 0 + + def mainloop(self): + while self.exit < 0: + self.root.tk.dooneevent(TCL_ALL_EVENTS) + + def destroy (self): self.root.destroy() # This "if" statement makes it possible to run this script file inside or ! # outside of the main demo program "tixwidgets.py". # if __name__== '__main__' : root=Tix.Tk() RunSample(root) Index: NoteBook.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/NoteBook.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NoteBook.py 21 Mar 2001 07:42:07 -0000 1.1 --- NoteBook.py 17 Mar 2002 18:19:13 -0000 1.2 *************** *** 1,3 **** ! #!/usr/local/bin/python # # $Id$ --- 1,3 ---- ! # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- # # $Id$ *************** *** 6,10 **** # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone --- 6,10 ---- # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets.py": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone Index: OptMenu.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/OptMenu.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OptMenu.py 21 Mar 2001 07:42:07 -0000 1.1 --- OptMenu.py 17 Mar 2002 18:19:13 -0000 1.2 *************** *** 1,3 **** ! #!/usr/local/bin/python # # $Id$ --- 1,3 ---- ! # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- # # $Id$ *************** *** 6,10 **** # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone --- 6,10 ---- # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets.py": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone *************** *** 60,64 **** def ok_command(w): ! print "Convert file from", demo_opt_from.get(), " to", demo_opt_to.get() w.destroy() --- 60,64 ---- def ok_command(w): ! # tixDemo:Status "Convert file from %s to %s" % ( demo_opt_from.get(), demo_opt_to.get()) w.destroy() Index: PopMenu.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/PopMenu.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PopMenu.py 21 Mar 2001 07:42:07 -0000 1.1 --- PopMenu.py 17 Mar 2002 18:19:13 -0000 1.2 *************** *** 1,9 **** ! # Tix Demostration Program ! # ! # $Id$ # # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "widget": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone --- 1,10 ---- ! # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- # + # $Id$ + # + # Tix Demostration Program # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets.py": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone Index: SHList1.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/SHList1.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SHList1.py 11 Nov 2001 14:07:37 -0000 1.2 --- SHList1.py 17 Mar 2002 18:19:13 -0000 1.3 *************** *** 6,10 **** # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone --- 6,10 ---- # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets.py": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone *************** *** 16,108 **** import Tix ! def RunSample (w) : ! # We create the frame and the ScrolledHList widget ! # at the top of the dialog box ! # ! top = Tix.Frame( w, relief=Tix.RAISED, bd=1) ! # Put a simple hierachy into the HList (two levels). Use colors and ! # separator widgets (frames) to make the list look fancy ! # ! top.a = Tix.ScrolledHList(top) ! top.a.pack( expand=1, fill=Tix.BOTH, padx=10, pady=10, side=Tix.TOP) ! # This is our little relational database ! # ! bosses = [ ! ('jeff', 'Jeff Waxman'), ! ('john', 'John Lee'), ! ('peter', 'Peter Kenson') ! ] ! employees = [ ! ('alex', 'john', 'Alex Kellman'), ! ('alan', 'john', 'Alan Adams'), ! ('andy', 'peter', 'Andreas Crawford'), ! ('doug', 'jeff', 'Douglas Bloom'), ! ('jon', 'peter', 'Jon Baraki'), ! ('chris', 'jeff', 'Chris Geoffrey'), ! ('chuck', 'jeff', 'Chuck McLean') ! ] ! hlist=top.a.hlist ! # Let configure the appearance of the HList subwidget ! # ! hlist.config( separator='.', width=25, drawbranch=0, indent=10) ! count=0 ! for boss,name in bosses : ! if count : ! f=Tix.Frame(hlist, name='sep%d' % count, height=2, width=150, ! bd=2, relief=Tix.SUNKEN ) ! hlist.add_child( itemtype=Tix.WINDOW, ! window=f, state=Tix.DISABLED ) ! ! hlist.add(boss, itemtype=Tix.TEXT, text=name) ! count = count+1 ! ! for person,boss,name in employees : ! # '.' is the separator character we chose above ! # ! key= boss + '.' + person ! # ^^^^ ^^^^^^ ! # parent entryPath / child's name - hlist.add( key, text=name ) ! # [Hint] Make sure the keys (e.g. 'boss.person') you choose ! # are unique names. If you cannot be sure of this (because of ! # the structure of your database, e.g.) you can use the ! # "add_child" command instead: ! # ! # hlist.addchild( boss, text=name) ! # ^^^^ ! # parent entryPath ! # Use a ButtonBox to hold the buttons. ! # ! box= Tix.ButtonBox(top, orientation=Tix.HORIZONTAL ) ! box.add( 'ok', text='Ok', underline=0, width=6, ! command = lambda w=w: w.quit() ) - box.add( 'cancel', text='Cancel', underline=0, width=6, - command = lambda w=w: w.quit() ) ! box.pack( side=Tix.BOTTOM, fill=Tix.X) ! top.pack( side=Tix.TOP, fill=Tix.BOTH, expand=1 ) # This "if" statement makes it possible to run this script file inside or ! # outside of the main demo program "widget". # if __name__== '__main__' : root=Tix.Tk() RunSample(root) ! root.mainloop() ! root.destroy() --- 16,132 ---- import Tix ! TCL_ALL_EVENTS = 0 ! def RunSample (root): ! shlist = DemoSHList(root) ! shlist.mainloop() ! shlist.destroy() ! ! class DemoSHList: ! def __init__(self, w): ! self.root = w ! self.exit = -1 ! z = w.winfo_toplevel() ! z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd()) ! ! # We create the frame and the ScrolledHList widget ! # at the top of the dialog box ! # ! top = Tix.Frame( w, relief=Tix.RAISED, bd=1) + # Put a simple hierachy into the HList (two levels). Use colors and + # separator widgets (frames) to make the list look fancy + # + top.a = Tix.ScrolledHList(top) + top.a.pack( expand=1, fill=Tix.BOTH, padx=10, pady=10, side=Tix.TOP) ! # This is our little relational database ! # ! bosses = [ ! ('jeff', 'Jeff Waxman'), ! ('john', 'John Lee'), ! ('peter', 'Peter Kenson') ! ] ! employees = [ ! ('alex', 'john', 'Alex Kellman'), ! ('alan', 'john', 'Alan Adams'), ! ('andy', 'peter', 'Andreas Crawford'), ! ('doug', 'jeff', 'Douglas Bloom'), ! ('jon', 'peter', 'Jon Baraki'), ! ('chris', 'jeff', 'Chris Geoffrey'), ! ('chuck', 'jeff', 'Chuck McLean') ! ] ! hlist=top.a.hlist ! # Let configure the appearance of the HList subwidget ! # ! hlist.config( separator='.', width=25, drawbranch=0, indent=10) ! count=0 ! for boss,name in bosses : ! if count : ! f=Tix.Frame(hlist, name='sep%d' % count, height=2, width=150, ! bd=2, relief=Tix.SUNKEN ) ! hlist.add_child( itemtype=Tix.WINDOW, ! window=f, state=Tix.DISABLED ) ! hlist.add(boss, itemtype=Tix.TEXT, text=name) ! count = count+1 ! for person,boss,name in employees : ! # '.' is the separator character we chose above ! # ! key= boss + '.' + person ! # ^^^^ ^^^^^^ ! # parent entryPath / child's name + hlist.add( key, text=name ) ! # [Hint] Make sure the keys (e.g. 'boss.person') you choose ! # are unique names. If you cannot be sure of this (because of ! # the structure of your database, e.g.) you can use the ! # "add_child" command instead: ! # ! # hlist.addchild( boss, text=name) ! # ^^^^ ! # parent entryPath ! # Use a ButtonBox to hold the buttons. ! # ! box= Tix.ButtonBox(top, orientation=Tix.HORIZONTAL ) ! box.add( 'ok', text='Ok', underline=0, width=6, ! command = self.okcmd) ! ! box.add( 'cancel', text='Cancel', underline=0, width=6, ! command = self.quitcmd) ! ! box.pack( side=Tix.BOTTOM, fill=Tix.X) ! top.pack( side=Tix.TOP, fill=Tix.BOTH, expand=1 ) ! ! def okcmd (self): ! self.quitcmd() ! ! def quitcmd (self): ! self.exit = 0 ! ! def mainloop(self): ! while self.exit < 0: ! self.root.tk.dooneevent(TCL_ALL_EVENTS) ! ! def destroy (self): ! self.root.destroy() # This "if" statement makes it possible to run this script file inside or ! # outside of the main demo program "tixwidgets.py". # if __name__== '__main__' : root=Tix.Tk() RunSample(root) ! Index: SHList2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/SHList2.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SHList2.py 11 Nov 2001 14:07:37 -0000 1.2 --- SHList2.py 17 Mar 2002 18:19:13 -0000 1.3 *************** *** 6,10 **** # # This sample program is structured in such a way so that it can be ! # executed from the PyTix demo program "tixwidget": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone --- 6,10 ---- # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidget": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone *************** *** 19,145 **** import Tix ! def RunSample (w) : ! # We create the frame and the ScrolledHList widget ! # at the top of the dialog box ! # ! top = Tix.Frame( w, relief=Tix.RAISED, bd=1) ! # Put a simple hierachy into the HList (two levels). Use colors and ! # separator widgets (frames) to make the list look fancy ! # ! top.a = Tix.ScrolledHList(top, options='hlist.columns 3 hlist.header 1' ) ! top.a.pack( expand=1, fill=Tix.BOTH, padx=10, pady=10, side=Tix.TOP) ! hlist=top.a.hlist ! # Create the title for the HList widget ! # >> Notice that we have set the hlist.header subwidget option to true ! # so that the header is displayed ! # ! boldfont=hlist.tk.call('tix','option','get','bold_font') ! # First some styles for the headers ! style={} ! style['header'] = Tix.DisplayStyle(Tix.TEXT, refwindow=top, ! anchor=Tix.CENTER, padx=8, pady=2, font = boldfont ) ! hlist.header_create(0, itemtype=Tix.TEXT, text='Name', ! style=style['header']) ! hlist.header_create(1, itemtype=Tix.TEXT, text='Position', ! style=style['header']) ! # Notice that we use 3 columns in the hlist widget. This way when the user ! # expands the windows wide, the right side of the header doesn't look ! # chopped off. The following line ensures that the 3 column header is ! # not shown unless the hlist window is wider than its contents. ! # ! hlist.column_width(2,0) ! # This is our little relational database ! # ! boss = ('doe', 'John Doe', 'Director') ! managers = [ ! ('jeff', 'Jeff Waxman', 'Manager'), ! ('john', 'John Lee', 'Manager'), ! ('peter', 'Peter Kenson', 'Manager') ! ] ! employees = [ ! ('alex', 'john', 'Alex Kellman', 'Clerk'), ! ('alan', 'john', 'Alan Adams', 'Clerk'), ! ('andy', 'peter', 'Andreas Crawford', 'Salesman'), ! ('doug', 'jeff', 'Douglas Bloom', 'Clerk'), ! ('jon', 'peter', 'Jon Baraki', 'Salesman'), ! ('chris', 'jeff', 'Chris Geoffrey', 'Clerk'), ! ('chuck', 'jeff', 'Chuck McLean', 'Cleaner') ! ] ! style['mgr_name'] = Tix.DisplayStyle(Tix.TEXT, refwindow=top) ! style['mgr_posn'] = Tix.DisplayStyle(Tix.TEXT, padx=8, refwindow=top) ! style['empl_name'] = Tix.DisplayStyle(Tix.TEXT, refwindow=top) ! style['empl_posn'] = Tix.DisplayStyle(Tix.TEXT, padx=8, refwindow=top) ! # Let configure the appearance of the HList subwidget ! # ! hlist.config(separator='.', width=25, drawbranch=0, indent=10) ! hlist.column_width(0, chars=20) ! # Create the boss ! # ! hlist.add ('.', itemtype=Tix.TEXT, text=boss[1], ! style=style['mgr_name']) ! hlist.item_create('.', 1, itemtype=Tix.TEXT, text=boss[2], ! style=style['mgr_posn']) ! # Create the managers ! # ! for key,name,posn in managers : ! e= '.'+ key ! hlist.add(e, itemtype=Tix.TEXT, text=name, ! style=style['mgr_name']) ! hlist.item_create(e, 1, itemtype=Tix.TEXT, text=posn, ! style=style['mgr_posn']) ! for key,mgr,name,posn in employees : ! # "." is the separator character we chose above ! entrypath = '.' + mgr + '.' + key ! # ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ! # parent entryPath / child's name ! hlist.add(entrypath, text=name, style=style['empl_name']) ! hlist.item_create(entrypath, 1, itemtype=Tix.TEXT, ! text = posn, style = style['empl_posn'] ) ! - # Use a ButtonBox to hold the buttons. - # - box= Tix.ButtonBox(top, orientation=Tix.HORIZONTAL ) - box.add( 'ok', text='Ok', underline=0, width=6, - command = lambda w=w: w.quit() ) ! box.add( 'cancel', text='Cancel', underline=0, width=6, ! command = lambda w=w: w.quit() ) ! box.pack( side=Tix.BOTTOM, fill=Tix.X) ! top.pack( side=Tix.TOP, fill=Tix.BOTH, expand=1 ) # This "if" statement makes it possible to run this script file inside or ! # outside of the main demo program "widget". # if __name__== '__main__' : root=Tix.Tk() RunSample(root) ! root.mainloop() ! root.destroy() --- 19,169 ---- import Tix ! TCL_ALL_EVENTS = 0 ! def RunSample (root): ! shlist = DemoSHList(root) ! shlist.mainloop() ! shlist.destroy() ! ! class DemoSHList: ! def __init__(self, w): ! self.root = w ! self.exit = -1 ! z = w.winfo_toplevel() ! z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd()) ! ! # We create the frame and the ScrolledHList widget ! # at the top of the dialog box ! # ! top = Tix.Frame( w, relief=Tix.RAISED, bd=1) ! # Put a simple hierachy into the HList (two levels). Use colors and ! # separator widgets (frames) to make the list look fancy ! # ! top.a = Tix.ScrolledHList(top, options='hlist.columns 3 hlist.header 1' ) ! top.a.pack( expand=1, fill=Tix.BOTH, padx=10, pady=10, side=Tix.TOP) ! hlist=top.a.hlist ! # Create the title for the HList widget ! # >> Notice that we have set the hlist.header subwidget option to true ! # so that the header is displayed ! # ! boldfont=hlist.tk.call('tix','option','get','bold_font') ! # First some styles for the headers ! style={} ! style['header'] = Tix.DisplayStyle(Tix.TEXT, refwindow=hlist, ! anchor=Tix.CENTER, padx=8, pady=2, font = boldfont ) ! hlist.header_create(0, itemtype=Tix.TEXT, text='Name', ! style=style['header']) ! hlist.header_create(1, itemtype=Tix.TEXT, text='Position', ! style=style['header']) ! # Notice that we use 3 columns in the hlist widget. This way when the user ! # expands the windows wide, the right side of the header doesn't look ! # chopped off. The following line ensures that the 3 column header is ! # not shown unless the hlist window is wider than its contents. ! # ! hlist.column_width(2,0) ! # This is our little relational database ! # ! boss = ('doe', 'John Doe', 'Director') ! managers = [ ! ('jeff', 'Jeff Waxman', 'Manager'), ! ('john', 'John Lee', 'Manager'), ! ('peter', 'Peter Kenson', 'Manager') ! ] ! employees = [ ! ('alex', 'john', 'Alex Kellman', 'Clerk'), ! ('alan', 'john', 'Alan Adams', 'Clerk'), ! ('andy', 'peter', 'Andreas Crawford', 'Salesman'), ! ('doug', 'jeff', 'Douglas Bloom', 'Clerk'), ! ('jon', 'peter', 'Jon Baraki', 'Salesman'), ! ('chris', 'jeff', 'Chris Geoffrey', 'Clerk'), ! ('chuck', 'jeff', 'Chuck McLean', 'Cleaner') ! ] ! style['mgr_name'] = Tix.DisplayStyle(Tix.TEXT, refwindow=hlist) ! style['mgr_posn'] = Tix.DisplayStyle(Tix.TEXT, padx=8, refwindow=hlist) ! style['empl_name'] = Tix.DisplayStyle(Tix.TEXT, refwindow=hlist) ! style['empl_posn'] = Tix.DisplayStyle(Tix.TEXT, padx=8, refwindow=hlist) ! # Let configure the appearance of the HList subwidget ! # ! hlist.config(separator='.', width=25, drawbranch=0, indent=10) ! hlist.column_width(0, chars=20) ! # Create the boss ! # ! hlist.add ('.', itemtype=Tix.TEXT, text=boss[1], ! style=style['mgr_name']) ! hlist.item_create('.', 1, itemtype=Tix.TEXT, text=boss[2], ! style=style['mgr_posn']) ! # Create the managers ! # ! for key,name,posn in managers : ! e= '.'+ key ! hlist.add(e, itemtype=Tix.TEXT, text=name, ! style=style['mgr_name']) ! hlist.item_create(e, 1, itemtype=Tix.TEXT, text=posn, ! style=style['mgr_posn']) ! for key,mgr,name,posn in employees : ! # "." is the separator character we chose above ! entrypath = '.' + mgr + '.' + key ! # ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ! # parent entryPath / child's name ! hlist.add(entrypath, text=name, style=style['empl_name']) ! hlist.item_create(entrypath, 1, itemtype=Tix.TEXT, ! text = posn, style = style['empl_posn'] ) ! # Use a ButtonBox to hold the buttons. ! # ! box= Tix.ButtonBox(top, orientation=Tix.HORIZONTAL ) ! box.add( 'ok', text='Ok', underline=0, width=6, ! command = self.okcmd ) ! box.add( 'cancel', text='Cancel', underline=0, width=6, ! command = self.quitcmd ) ! ! box.pack( side=Tix.BOTTOM, fill=Tix.X) ! top.pack( side=Tix.TOP, fill=Tix.BOTH, expand=1 ) ! ! def okcmd (self): ! self.quitcmd() ! ! def quitcmd (self): ! self.exit = 0 ! ! def mainloop(self): ! while self.exit < 0: ! self.root.tk.dooneevent(TCL_ALL_EVENTS) ! ! def destroy (self): ! self.root.destroy() # This "if" statement makes it possible to run this script file inside or ! # outside of the main demo program "tixwidgets.py". # if __name__== '__main__' : root=Tix.Tk() RunSample(root) ! Index: Tree.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/tix/samples/Tree.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Tree.py 21 Mar 2001 07:42:07 -0000 1.1 --- Tree.py 17 Mar 2002 18:19:13 -0000 1.2 *************** *** 1,3 **** ! #!/usr/local/bin/python # # $Id$ --- 1,3 ---- ! # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- # # $Id$ *************** *** 6,10 **** # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone --- 6,10 ---- # # This sample program is structured in such a way so that it can be ! # executed from the Tix demo program "tixwidgets.py": it must have a # procedure called "RunSample". It should also have the "if" statment # at the end of this file so that it can be run as a standalone From loewis@users.sourceforge.net Sun Mar 17 18:37:24 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Sun, 17 Mar 2002 10:37:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libbasehttp.tex,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv24799/Doc/lib Modified Files: libbasehttp.tex Log Message: Patch #430706: Persistent connections in BaseHTTPServer. Index: libbasehttp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libbasehttp.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** libbasehttp.tex 14 Jul 2001 02:50:55 -0000 1.13 --- libbasehttp.tex 17 Mar 2002 18:37:22 -0000 1.14 *************** *** 124,130 **** \begin{memberdesc}{protocol_version} ! This specifies the HTTP protocol version used in responses. ! Typically, this should not be overridden. Defaults to ! \code{'HTTP/1.0'}. \end{memberdesc} --- 124,133 ---- \begin{memberdesc}{protocol_version} ! This specifies the HTTP protocol version used in responses. If set ! to \code{'HTTP/1.1'}, the server will permit HTTP persistent ! connections; however, your server \emph{must} then include an ! accurate \code{Content-Length} header (using \method{send_header()}) ! in all of its responses to clients. For backwards compatibility, ! the setting defaults to \code{'HTTP/1.0'}. \end{memberdesc} *************** *** 149,155 **** \begin{methoddesc}{handle}{} ! Overrides the superclass' \method{handle()} method to provide the ! specific handler behavior. This method will parse and dispatch ! the request to the appropriate \method{do_*()} method. \end{methoddesc} --- 152,165 ---- \begin{methoddesc}{handle}{} ! Calls \method{handle_one_request()} once (or, if persistent connections ! are enabled, multiple times) to handle incoming HTTP requests. ! You should never need to override it; instead, implement appropriate ! \method{do_*()} methods. ! \end{methoddesc} ! ! \begin{methoddesc}{handle_one_request}{} ! This method will parse and dispatch ! the request to the appropriate \method{do_*()} method. You should ! never need to override it. \end{methoddesc} From loewis@users.sourceforge.net Sun Mar 17 18:37:24 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Sun, 17 Mar 2002 10:37:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib BaseHTTPServer.py,1.18,1.19 SimpleHTTPServer.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv24799/Lib Modified Files: BaseHTTPServer.py SimpleHTTPServer.py Log Message: Patch #430706: Persistent connections in BaseHTTPServer. Index: BaseHTTPServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/BaseHTTPServer.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** BaseHTTPServer.py 8 Mar 2002 02:36:18 -0000 1.18 --- BaseHTTPServer.py 17 Mar 2002 18:37:22 -0000 1.19 *************** *** 3,7 **** Note: the class in this module doesn't implement any HTTP request; see SimpleHTTPServer for simple implementations of GET, HEAD and POST ! (including CGI scripts). Contents: --- 3,8 ---- Note: the class in this module doesn't implement any HTTP request; see SimpleHTTPServer for simple implementations of GET, HEAD and POST ! (including CGI scripts). It does, however, optionally implement HTTP/1.1 ! persistent connections, as of version 0.3. Contents: *************** *** 12,21 **** XXX To do: - - send server version - log requests even later (to capture byte count) - log user-agent header and other interesting goodies - send error log to separate file - - are request names really case sensitive? - """ --- 13,19 ---- *************** *** 29,33 **** # # URL: http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-v10-spec-00.txt ! # Log files --- 27,39 ---- # # URL: http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-v10-spec-00.txt ! # ! # and ! # ! # Network Working Group R. Fielding ! # Request for Comments: 2616 et al ! # Obsoletes: 2068 June 1999 ! # Category: Standards Track ! # ! # URL: http://www.faqs.org/rfcs/rfc2616.html # Log files *************** *** 61,66 **** # at the time the request was made!) ! ! __version__ = "0.2" __all__ = ["HTTPServer", "BaseHTTPRequestHandler"] --- 67,71 ---- # at the time the request was made!) ! __version__ = "0.3" __all__ = ["HTTPServer", "BaseHTTPRequestHandler"] *************** *** 71,74 **** --- 76,80 ---- import mimetools import SocketServer + import cStringIO # Default error message *************** *** 123,129 **** where is a (case-sensitive) keyword such as GET or POST, is a string containing path information for the request, ! and should be the string "HTTP/1.0". is encoded ! using the URL encoding scheme (using %xx to signify the ASCII ! character with hex code xx). The protocol is vague about whether lines are separated by LF --- 129,135 ---- where is a (case-sensitive) keyword such as GET or POST, is a string containing path information for the request, ! and should be the string "HTTP/1.0" or "HTTP/1.1". ! is encoded using the URL encoding scheme (using %xx to signify ! the ASCII character with hex code xx). The protocol is vague about whether lines are separated by LF *************** *** 144,148 **** the reply consists of just the data. ! The reply form of the HTTP 1.0 protocol again has three parts: 1. One line giving the response code --- 150,154 ---- the reply consists of just the data. ! The reply form of the HTTP 1.x protocol again has three parts: 1. One line giving the response code *************** *** 156,160 **** ! where is the protocol version (always "HTTP/1.0"), is a 3-digit response code indicating success or failure of the request, and is an optional --- 162,166 ---- ! where is the protocol version ("HTTP/1.0" or "HTTP/1.1"), is a 3-digit response code indicating success or failure of the request, and is an optional *************** *** 222,225 **** --- 228,232 ---- """ self.request_version = version = "HTTP/0.9" # Default + self.close_connection = 1 requestline = self.raw_requestline if requestline[-2:] == '\r\n': *************** *** 234,251 **** self.send_error(400, "Bad request version (%s)" % `version`) return 0 elif len(words) == 2: [command, path] = words if command != 'GET': self.send_error(400, "Bad HTTP/0.9 request type (%s)" % `command`) return 0 else: self.send_error(400, "Bad request syntax (%s)" % `requestline`) return 0 self.command, self.path, self.request_version = command, path, version ! self.headers = self.MessageClass(self.rfile, 0) return 1 ! def handle(self): """Handle a single HTTP request. --- 241,290 ---- self.send_error(400, "Bad request version (%s)" % `version`) return 0 + try: + version_number = float(version.split('/', 1)[1]) + except ValueError: + self.send_error(400, "Bad request version (%s)" % `version`) + return 0 + if version_number >= 1.1 and self.protocol_version >= "HTTP/1.1": + self.close_connection = 0 + if version_number >= 2.0: + self.send_error(505, + "Invalid HTTP Version (%f)" % version_number) + return 0 elif len(words) == 2: [command, path] = words + self.close_connection = 1 if command != 'GET': self.send_error(400, "Bad HTTP/0.9 request type (%s)" % `command`) return 0 + elif not words: + return 0 else: self.send_error(400, "Bad request syntax (%s)" % `requestline`) return 0 self.command, self.path, self.request_version = command, path, version ! ! # Deal with pipelining ! bytes = "" ! while 1: ! line = self.rfile.readline() ! bytes = bytes + line ! if line == '\r\n' or line == '\n' or line == '': ! break ! ! # Examine the headers and look for a Connection directive ! hfile = cStringIO.StringIO(bytes) ! self.headers = self.MessageClass(hfile) ! ! conntype = self.headers.get('Connection', "") ! if conntype.lower() == 'close': ! self.close_connection = 1 ! elif (conntype.lower() == 'keep-alive' and ! self.protocol_version >= "HTTP/1.1"): ! self.close_connection = 0 return 1 ! def handle_one_request(self): """Handle a single HTTP request. *************** *** 255,260 **** """ - self.raw_requestline = self.rfile.readline() if not self.parse_request(): # An error code has been sent, just exit return --- 294,301 ---- """ self.raw_requestline = self.rfile.readline() + if not self.raw_requestline: + self.close_connection = 1 + return if not self.parse_request(): # An error code has been sent, just exit return *************** *** 266,269 **** --- 307,318 ---- method() + def handle(self): + """Handle multiple requests if necessary.""" + self.close_connection = 1 + + self.handle_one_request() + while not self.close_connection: + self.handle_one_request() + def send_error(self, code, message=None): """Send and log an error reply. *************** *** 287,297 **** explain = long self.log_error("code %d, message %s", code, message) self.send_response(code, message) self.send_header("Content-Type", "text/html") self.end_headers() ! self.wfile.write(self.error_message_format % ! {'code': code, ! 'message': message, ! 'explain': explain}) error_message_format = DEFAULT_ERROR_MESSAGE --- 336,347 ---- explain = long self.log_error("code %d, message %s", code, message) + content = (self.error_message_format % + {'code': code, 'message': message, 'explain': explain}) self.send_response(code, message) self.send_header("Content-Type", "text/html") + self.send_header('Connection', 'close') self.end_headers() ! if self.command != 'HEAD' and code >= 200 and code not in (204, 304): ! self.wfile.write(content) error_message_format = DEFAULT_ERROR_MESSAGE *************** *** 306,316 **** self.log_request(code) if message is None: ! if self.responses.has_key(code): message = self.responses[code][0] else: message = '' if self.request_version != 'HTTP/0.9': ! self.wfile.write("%s %s %s\r\n" % ! (self.protocol_version, str(code), message)) self.send_header('Server', self.version_string()) self.send_header('Date', self.date_time_string()) --- 356,367 ---- self.log_request(code) if message is None: ! if code in self.responses: message = self.responses[code][0] else: message = '' if self.request_version != 'HTTP/0.9': ! self.wfile.write("%s %d %s\r\n" % ! (self.protocol_version, code, message)) ! # print (self.protocol_version, code, message) self.send_header('Server', self.version_string()) self.send_header('Date', self.date_time_string()) *************** *** 321,324 **** --- 372,381 ---- self.wfile.write("%s: %s\r\n" % (keyword, value)) + if keyword.lower() == 'connection': + if value.lower() == 'close': + self.close_connection = 1 + elif value.lower() == 'keep-alive': + self.close_connection = 0 + def end_headers(self): """Send the blank line ending the MIME headers.""" *************** *** 414,419 **** # The version of the HTTP protocol we support. ! # Don't override unless you know what you're doing (hint: incoming ! # requests are required to have exactly this version string). protocol_version = "HTTP/1.0" --- 471,475 ---- # The version of the HTTP protocol we support. ! # Set this to HTTP/1.1 to enable automatic keepalive protocol_version = "HTTP/1.0" *************** *** 425,440 **** # See http://www.w3.org/hypertext/WWW/Protocols/HTTP/HTRESP.html responses = { 200: ('OK', 'Request fulfilled, document follows'), 201: ('Created', 'Document created, URL follows'), 202: ('Accepted', 'Request accepted, processing continues off-line'), ! 203: ('Partial information', 'Request fulfilled from cache'), 204: ('No response', 'Request fulfilled, nothing follows'), ! 301: ('Moved', 'Object moved permanently -- see URI list'), 302: ('Found', 'Object moved temporarily -- see URI list'), ! 303: ('Method', 'Object moved -- see Method and URL list'), 304: ('Not modified', ! 'Document has not changed singe given time'), 400: ('Bad request', --- 481,509 ---- # See http://www.w3.org/hypertext/WWW/Protocols/HTTP/HTRESP.html responses = { + 100: ('Continue', 'Request received, please continue'), + 101: ('Switching Protocols', + 'Switching to new protocol; obey Upgrade header'), + 200: ('OK', 'Request fulfilled, document follows'), 201: ('Created', 'Document created, URL follows'), 202: ('Accepted', 'Request accepted, processing continues off-line'), ! 203: ('Non-Authoritative Information', 'Request fulfilled from cache'), 204: ('No response', 'Request fulfilled, nothing follows'), + 205: ('Reset Content', 'Clear input form for further input.'), + 206: ('Partial Content', 'Partial content follows.'), ! 300: ('Multiple Choices', ! 'Object has several resources -- see URI list'), ! 301: ('Moved Permanently', 'Object moved permanently -- see URI list'), 302: ('Found', 'Object moved temporarily -- see URI list'), ! 303: ('See Other', 'Object moved -- see Method and URL list'), 304: ('Not modified', ! 'Document has not changed since given time'), ! 305: ('Use Proxy', ! 'You must use proxy specified in Location to access this ' ! 'resource.'), ! 307: ('Temporary Redirect', ! 'Object moved temporarily -- see URI list'), 400: ('Bad request', *************** *** 446,464 **** 403: ('Forbidden', 'Request forbidden -- authorization will not help'), ! 404: ('Not found', 'Nothing matches the given URI'), 500: ('Internal error', 'Server got itself in trouble'), ! 501: ('Not implemented', 'Server does not support this operation'), ! 502: ('Service temporarily overloaded', 'The server cannot process the request due to a high load'), ! 503: ('Gateway timeout', 'The gateway server did not receive a timely response'), ! } def test(HandlerClass = BaseHTTPRequestHandler, ! ServerClass = HTTPServer): """Test the HTTP request handler class. --- 515,552 ---- 403: ('Forbidden', 'Request forbidden -- authorization will not help'), ! 404: ('Not Found', 'Nothing matches the given URI'), ! 405: ('Method Not Allowed', ! 'Specified method is invalid for this server.'), ! 406: ('Not Acceptable', 'URI not available in preferred format.'), ! 407: ('Proxy Authentication Required', 'You must authenticate with ' ! 'this proxy before proceeding.'), ! 408: ('Request Time-out', 'Request timed out; try again later.'), ! 409: ('Conflict', 'Request conflict.'), ! 410: ('Gone', ! 'URI no longer exists and has been permanently removed.'), ! 411: ('Length Required', 'Client must specify Content-Length.'), ! 412: ('Precondition Failed', 'Precondition in headers is false.'), ! 413: ('Request Entity Too Large', 'Entity is too large.'), ! 414: ('Request-URI Too Long', 'URI is too long.'), ! 415: ('Unsupported Media Type', 'Entity body in unsupported format.'), ! 416: ('Requested Range Not Satisfiable', ! 'Cannot satisfy request range.'), ! 417: ('Expectation Failed', ! 'Expect condition could not be satisfied.'), 500: ('Internal error', 'Server got itself in trouble'), ! 501: ('Not Implemented', 'Server does not support this operation'), ! 502: ('Bad Gateway', 'Invalid responses from another server/proxy.'), ! 503: ('Service temporarily overloaded', 'The server cannot process the request due to a high load'), ! 504: ('Gateway timeout', 'The gateway server did not receive a timely response'), ! 505: ('HTTP Version not supported', 'Cannot fulfill request.'), } def test(HandlerClass = BaseHTTPRequestHandler, ! ServerClass = HTTPServer, protocol="HTTP/1.0"): """Test the HTTP request handler class. *************** *** 474,477 **** --- 562,566 ---- server_address = ('', port) + HandlerClass.protocol_version = protocol httpd = ServerClass(server_address, HandlerClass) Index: SimpleHTTPServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/SimpleHTTPServer.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** SimpleHTTPServer.py 9 Feb 2001 10:26:06 -0000 1.17 --- SimpleHTTPServer.py 17 Mar 2002 18:37:22 -0000 1.18 *************** *** 83,86 **** --- 83,87 ---- self.send_response(200) self.send_header("Content-type", ctype) + self.send_header("Content-Length", str(os.fstat(f.fileno())[6])) self.end_headers() return f *************** *** 116,122 **** --- 117,125 ---- f.write('
  • %s\n' % (linkname, displayname)) f.write("\n
    \n") + length = f.tell() f.seek(0) self.send_response(200) self.send_header("Content-type", "text/html") + self.send_header("Content-Length", str(length)) self.end_headers() return f From loewis@users.sourceforge.net Sun Mar 17 18:37:25 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Sun, 17 Mar 2002 10:37:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.363,1.364 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv24799/Misc Modified Files: NEWS Log Message: Patch #430706: Persistent connections in BaseHTTPServer. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.363 retrieving revision 1.364 diff -C2 -d -r1.363 -r1.364 *** NEWS 14 Mar 2002 23:05:54 -0000 1.363 --- NEWS 17 Mar 2002 18:37:22 -0000 1.364 *************** *** 45,48 **** --- 45,51 ---- Library + - The BaseHTTPServer implements now optionally HTTP/1.1 persistent + connections. + - socket module: the SSL support was broken out of the main _socket module C helper and placed into a new _ssl helper From tim_one@users.sourceforge.net Sun Mar 17 18:56:22 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 17 Mar 2002 10:56:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib inspect.py,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv28202/python/Lib Modified Files: inspect.py Log Message: SF patch 530070: pydoc regression, from Martin and Guido. Change the way __doc__ is handled, to avoid blowing up on non-string __doc__ values. Index: inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** inspect.py 13 Mar 2002 03:14:26 -0000 1.27 --- inspect.py 17 Mar 2002 18:56:20 -0000 1.28 *************** *** 264,269 **** indented to line up with blocks of code, any whitespace than can be uniformly removed from the second line onwards is removed.""" ! if hasattr(object, '__doc__') and object.__doc__: ! lines = string.split(string.expandtabs(object.__doc__), '\n') margin = None for line in lines[1:]: --- 264,278 ---- indented to line up with blocks of code, any whitespace than can be uniformly removed from the second line onwards is removed.""" ! try: ! doc = object.__doc__ ! except AttributeError: ! return None ! if not isinstance(doc, (str, unicode)): ! return None ! try: ! lines = string.split(string.expandtabs(doc), '\n') ! except UnicodeError: ! return None ! else: margin = None for line in lines[1:]: From tim_one@users.sourceforge.net Sun Mar 17 18:56:22 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 17 Mar 2002 10:56:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.129,2.130 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv28202/python/Objects Modified Files: typeobject.c Log Message: SF patch 530070: pydoc regression, from Martin and Guido. Change the way __doc__ is handled, to avoid blowing up on non-string __doc__ values. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.129 retrieving revision 2.130 diff -C2 -d -r2.129 -r2.130 *** typeobject.c 14 Mar 2002 23:03:14 -0000 2.129 --- typeobject.c 17 Mar 2002 18:56:20 -0000 2.130 *************** *** 80,87 **** --- 80,104 ---- } + static PyObject * + type_get_doc(PyTypeObject *type, void *context) + { + PyObject *result; + if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) { + if (type->tp_doc == NULL) { + Py_INCREF(Py_None); + return Py_None; + } + return PyString_FromString(type->tp_doc); + } + result = PyDict_GetItemString(type->tp_dict, "__doc__"); + Py_INCREF(result); + return result; + } + static PyGetSetDef type_getsets[] = { {"__name__", (getter)type_name, NULL, NULL}, {"__module__", (getter)type_module, (setter)type_set_module, NULL}, {"__dict__", (getter)type_dict, NULL, NULL}, + {"__doc__", (getter)type_get_doc, NULL, NULL}, {0} }; *************** *** 1080,1086 **** /* Set tp_doc to a copy of dict['__doc__'], if the latter is there ! and is a string. Note that the tp_doc slot will only be used ! by C code -- python code will use the version in tp_dict, so ! it isn't that important that non string __doc__'s are ignored. */ { --- 1097,1102 ---- /* Set tp_doc to a copy of dict['__doc__'], if the latter is there ! and is a string. The __doc__ accessor will first look for tp_doc; ! if that fails, it will still look into __dict__. */ { From tim_one@users.sourceforge.net Sun Mar 17 18:57:09 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 17 Mar 2002 10:57:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib inspect.py,1.26.10.1,1.26.10.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv28927/221/Lib Modified Files: Tag: release22-maint inspect.py Log Message: SF patch 530070: pydoc regression, from Martin and Guido. Change the way __doc__ is handled, to avoid blowing up on non-string __doc__ values. Index: inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v retrieving revision 1.26.10.1 retrieving revision 1.26.10.2 diff -C2 -d -r1.26.10.1 -r1.26.10.2 *** inspect.py 13 Mar 2002 03:19:18 -0000 1.26.10.1 --- inspect.py 17 Mar 2002 18:57:07 -0000 1.26.10.2 *************** *** 264,269 **** indented to line up with blocks of code, any whitespace than can be uniformly removed from the second line onwards is removed.""" ! if hasattr(object, '__doc__') and object.__doc__: ! lines = string.split(string.expandtabs(object.__doc__), '\n') margin = None for line in lines[1:]: --- 264,278 ---- indented to line up with blocks of code, any whitespace than can be uniformly removed from the second line onwards is removed.""" ! try: ! doc = object.__doc__ ! except AttributeError: ! return None ! if not isinstance(doc, (str, unicode)): ! return None ! try: ! lines = string.split(string.expandtabs(doc), '\n') ! except UnicodeError: ! return None ! else: margin = None for line in lines[1:]: From tim_one@users.sourceforge.net Sun Mar 17 18:57:09 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 17 Mar 2002 10:57:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.126.4.3,2.126.4.4 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv28927/221/Objects Modified Files: Tag: release22-maint typeobject.c Log Message: SF patch 530070: pydoc regression, from Martin and Guido. Change the way __doc__ is handled, to avoid blowing up on non-string __doc__ values. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.126.4.3 retrieving revision 2.126.4.4 diff -C2 -d -r2.126.4.3 -r2.126.4.4 *** typeobject.c 16 Mar 2002 17:56:51 -0000 2.126.4.3 --- typeobject.c 17 Mar 2002 18:57:07 -0000 2.126.4.4 *************** *** 80,87 **** --- 80,104 ---- } + static PyObject * + type_get_doc(PyTypeObject *type, void *context) + { + PyObject *result; + if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) { + if (type->tp_doc == NULL) { + Py_INCREF(Py_None); + return Py_None; + } + return PyString_FromString(type->tp_doc); + } + result = PyDict_GetItemString(type->tp_dict, "__doc__"); + Py_INCREF(result); + return result; + } + static PyGetSetDef type_getsets[] = { {"__name__", (getter)type_name, NULL, NULL}, {"__module__", (getter)type_module, (setter)type_set_module, NULL}, {"__dict__", (getter)type_dict, NULL, NULL}, + {"__doc__", (getter)type_get_doc, NULL, NULL}, {0} }; *************** *** 1080,1086 **** /* Set tp_doc to a copy of dict['__doc__'], if the latter is there ! and is a string. Note that the tp_doc slot will only be used ! by C code -- python code will use the version in tp_dict, so ! it isn't that important that non string __doc__'s are ignored. */ { --- 1097,1102 ---- /* Set tp_doc to a copy of dict['__doc__'], if the latter is there ! and is a string. The __doc__ accessor will first look for tp_doc; ! if that fails, it will still look into __dict__. */ { From mwh@users.sourceforge.net Sun Mar 17 18:59:34 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sun, 17 Mar 2002 10:59:34 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_calendar.py,1.1,1.1.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv29400 Modified Files: Tag: release22-maint test_calendar.py Log Message: Backport a little test from Skip. Index: test_calendar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_calendar.py,v retrieving revision 1.1 retrieving revision 1.1.6.1 diff -C2 -d -r1.1 -r1.1.6.1 *** test_calendar.py 12 Dec 2001 05:38:08 -0000 1.1 --- test_calendar.py 17 Mar 2002 18:59:32 -0000 1.1.6.1 *************** *** 27,30 **** --- 27,34 ---- calendar.setfirstweekday(orig) + def test_enumerateweekdays(self): + self.assertRaises(IndexError, calendar.day_abbr.__getitem__, -10) + self.assertRaises(IndexError, calendar.day_name.__getitem__, 10) + self.assertEqual(len([d for d in calendar.day_abbr]), 7) def test_main(): From mwh@users.sourceforge.net Sun Mar 17 19:02:13 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sun, 17 Mar 2002 11:02:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.61.6.1,2.61.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv30087 Modified Files: Tag: release22-maint _cursesmodule.c Log Message: Backport my fix from a whiles back: Fix for [ #504284 ] Last build problems on AIX I'm ignoring the suggestion that this should be an autoconf test in the interests of having a fix today. Feel free to quibble. Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.61.6.1 retrieving revision 2.61.6.2 diff -C2 -d -r2.61.6.1 -r2.61.6.2 *** _cursesmodule.c 6 Feb 2002 17:11:51 -0000 2.61.6.1 --- _cursesmodule.c 17 Mar 2002 19:02:10 -0000 2.61.6.2 *************** *** 2311,2322 **** } ! #ifdef __hpux ! /* tparm is declared with 10 arguments on HP/UX 11. ! If this is a problem on other platforms as well, ! an autoconf test should be added to determine ! whether tparm can be called with a variable number ! of arguments. Perhaps the other arguments should ! be initialized in this case also. */ ! result = tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8,i9); #else switch (PyTuple_GET_SIZE(args)) { --- 2311,2322 ---- } ! #if defined(__hpux) || defined(_AIX) ! /* tparm is declared with 10 arguments on a few platforms ! (HP-UX, AIX). If this proves to be a problem on other ! platforms as well, perhaps an autoconf test should be ! added to determine whether tparm can be called with a ! variable number of arguments. Perhaps the other arguments ! should be initialized in this case also. */ ! result = tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8,i9); #else switch (PyTuple_GET_SIZE(args)) { *************** *** 2352,2356 **** break; } ! #endif /* __hpux */ return PyString_FromString(result); } --- 2352,2356 ---- break; } ! #endif /* defined(__hpux) || defined(_AIX) */ return PyString_FromString(result); } From mwh@users.sourceforge.net Sun Mar 17 19:05:20 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sun, 17 Mar 2002 11:05:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libxmlrpclib.tex,1.5.10.1,1.5.10.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv30624 Modified Files: Tag: release22-maint libxmlrpclib.tex Log Message: Backport montanero's checkin of revision 1.7: update text to refer to ServerProxy class in preference to Server, which is only retained for backward compatibility with older versions of the library. Index: libxmlrpclib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libxmlrpclib.tex,v retrieving revision 1.5.10.1 retrieving revision 1.5.10.2 diff -C2 -d -r1.5.10.1 -r1.5.10.2 *** libxmlrpclib.tex 11 Mar 2002 10:05:07 -0000 1.5.10.1 --- libxmlrpclib.tex 17 Mar 2002 19:05:18 -0000 1.5.10.2 *************** *** 18,24 **** objects and XML on the wire. ! \begin{classdesc}{Server}{uri\optional{, transport\optional{, ! encoding\optional{, verbose}}}} ! A \class{Server} instance is a server proxy that manages communication with a remote XML-RPC server. The required first argument is a URI (Uniform Resource Indicator), and will normally be the URL of the --- 18,24 ---- objects and XML on the wire. ! \begin{classdesc}{ServerProxy}{uri\optional{, transport\optional{, ! encoding\optional{, verbose}}}} ! A \class{ServerProxy} instance is an object that manages communication with a remote XML-RPC server. The required first argument is a URI (Uniform Resource Indicator), and will normally be the URL of the *************** *** 35,39 **** fetch other server-associated metadata. ! \class{Server} instance methods take Python basic types and objects as arguments and return Python basic types and classes. Types that are conformable (e.g. that can be marshalled through XML), include the --- 35,39 ---- fetch other server-associated metadata. ! \class{ServerProxy} instance methods take Python basic types and objects as arguments and return Python basic types and classes. Types that are conformable (e.g. that can be marshalled through XML), include the *************** *** 70,73 **** --- 70,76 ---- described below. + \class{Server} is retained as an alias for \class{ServerProxy} for backwards + compatibility. New code should use \class{ServerProxy}. + \end{classdesc} *************** *** 84,90 **** ! \subsection{Server Objects \label{server-objects}} ! A \class{Server} instance proxy object has a method corresponding to each remote procedure call accepted by the XML-RPC server. Calling the method performs an RPC, dispatched by both name and argument --- 87,93 ---- ! \subsection{ServerProxy Objects \label{serverproxy-objects}} ! A \class{ServerProxy} instance has a method corresponding to each remote procedure call accepted by the XML-RPC server. Calling the method performs an RPC, dispatched by both name and argument *************** *** 245,250 **** # simple test program (from the XML-RPC specification) ! # server = Server("http://localhost:8000") # local server ! server = Server("http://betty.userland.com") print server --- 248,253 ---- # simple test program (from the XML-RPC specification) ! # server = ServerProxy("http://localhost:8000") # local server ! server = ServerProxy("http://betty.userland.com") print server From mwh@users.sourceforge.net Sun Mar 17 19:31:30 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sun, 17 Mar 2002 11:31:30 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.113.4.7,1.113.4.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv3520 Modified Files: Tag: release22-maint test_descr.py Log Message: Backport nnorwitz's checkin of revision 1.119: Fix typo Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.113.4.7 retrieving revision 1.113.4.8 diff -C2 -d -r1.113.4.7 -r1.113.4.8 *** test_descr.py 16 Mar 2002 17:57:26 -0000 1.113.4.7 --- test_descr.py 17 Mar 2002 19:31:28 -0000 1.113.4.8 *************** *** 439,443 **** pass else: ! raise TestFailed, "NotImplemented should have caused TypeErrpr" def longs(): --- 439,443 ---- pass else: ! raise TestFailed, "NotImplemented should have caused TypeError" def longs(): From mwh@users.sourceforge.net Sun Mar 17 19:36:51 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sun, 17 Mar 2002 11:36:51 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc README,1.16,1.16.8.1 unicode.txt,3.11,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv4968 Modified Files: Tag: release22-maint README Removed Files: Tag: release22-maint unicode.txt Log Message: Backport a checkin of Guido's: Remove stub for unicode.txt. Resort README in dictionary order. Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/README,v retrieving revision 1.16 retrieving revision 1.16.8.1 diff -C2 -d -r1.16 -r1.16.8.1 *** README 26 Oct 2001 15:01:16 -0000 1.16 --- README 17 Mar 2002 19:36:48 -0000 1.16.8.1 *************** *** 12,30 **** BeOS-NOTES Notes for building on BeOS BeOS-setup.py setup.py replacement for BeOS, see BeOS-NOTES HISTORY News from previous releases -- oldest last HPUX-NOTES Notes about dynamic loading under HP-UX ! NEWS News for this release ! PURIFY.README Information for Purify users Porting Mini-FAQ on porting to new platforms README The file you're reading now RFD Request For Discussion about a Python newsgroup RPM (Old) tools to build RPMs - cheatsheet Quick summary of Python by Ken Manheimer - find_recursionlimit.py Script to find a value for sys.maxrecursionlimit - gdbinit Handy stuff to put in your .gdbinit file, if you use gdb - indent.pro GNU indent profile approximating my C style - python-mode.el Emacs mode for editing Python programs - python.man UNIX man page for the python interpreter setuid-prog.c C helper program for set-uid Python scripts - unicode.txt Marc-Andre Lemburg's specification of the Unicode API vgrindefs Python configuration for vgrind (a generic pretty printer) --- 12,29 ---- BeOS-NOTES Notes for building on BeOS BeOS-setup.py setup.py replacement for BeOS, see BeOS-NOTES + cheatsheet Quick summary of Python by Ken Manheimer + find_recursionlimit.py Script to find a value for sys.maxrecursionlimit + gdbinit Handy stuff to put in your .gdbinit file, if you use gdb HISTORY News from previous releases -- oldest last HPUX-NOTES Notes about dynamic loading under HP-UX ! indent.pro GNU indent profile approximating my C style ! NEWS News for this release (for some meaning of "this") Porting Mini-FAQ on porting to new platforms + PURIFY.README Information for Purify users + python.man UNIX man page for the python interpreter + python-mode.el Emacs mode for editing Python programs README The file you're reading now RFD Request For Discussion about a Python newsgroup RPM (Old) tools to build RPMs setuid-prog.c C helper program for set-uid Python scripts vgrindefs Python configuration for vgrind (a generic pretty printer) --- unicode.txt DELETED --- From mwh@users.sourceforge.net Sun Mar 17 19:39:26 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sun, 17 Mar 2002 11:39:26 -0800 Subject: [Python-checkins] CVS: python/dist/src README,1.136.4.2,1.136.4.3 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv5570 Modified Files: Tag: release22-maint README Log Message: Another Guido backport: Quick build: clarify that you have to do "make install" as root; OS info: add info about Red Hat's python and python2. Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/README,v retrieving revision 1.136.4.2 retrieving revision 1.136.4.3 diff -C2 -d -r1.136.4.2 -r1.136.4.3 *** README 27 Feb 2002 13:33:29 -0000 1.136.4.2 --- README 17 Mar 2002 19:39:24 -0000 1.136.4.3 *************** *** 42,48 **** To start building right away (on UNIX): type "./configure" in the ! current directory and when it finishes, type "make". The section ! `Build instructions' below is still recommended reading, especially ! the part on customizing Modules/Setup. --- 42,51 ---- To start building right away (on UNIX): type "./configure" in the ! current directory and when it finishes, type "make". This creates an ! executable "./python"; to install in /usr/local, first do "su root" ! and then "make install". ! ! The section `Build Instructions' below is still recommended reading, ! especially the part on customizing Modules/Setup. *************** *** 249,252 **** --- 252,262 ---- module now needs the -lcrypt option. The setup.py script takes care of this automatically. + + Red Hat Linux: There's an executable /usr/bin/python which is Python + 1.5.2 on most Red Hat installations; several key Red Hat tools + require this version. Python 2.1.x may be installed as + /usr/bin/python2. The Makefile installs Python as + /usr/local/bin/python, which may or may not take precedence + over /usr/bin/python, depending on how you have set up $PATH. FreeBSD 3.x and probably platforms with NCurses that use libmytinfo or From mwh@users.sourceforge.net Sun Mar 17 19:42:20 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sun, 17 Mar 2002 11:42:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules main.c,1.61.6.1,1.61.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv6202 Modified Files: Tag: release22-maint main.c Log Message: Backport a checkin of lemburg's: Remove mentioning of -U option in "python -h" output. Index: main.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/main.c,v retrieving revision 1.61.6.1 retrieving revision 1.61.6.2 diff -C2 -d -r1.61.6.1 -r1.61.6.2 *** main.c 12 Jan 2002 11:13:23 -0000 1.61.6.1 --- main.c 17 Mar 2002 19:42:18 -0000 1.61.6.2 *************** *** 61,65 **** "; static char *usage_3 = "\ - -U : Unicode literals: treats '...' literals like u'...'\n\ -v : verbose (trace import statements) (also PYTHONVERBOSE=x)\n\ -V : print the Python version number and exit\n\ --- 61,64 ---- From mwh@users.sourceforge.net Sun Mar 17 19:47:41 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sun, 17 Mar 2002 11:47:41 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils unixccompiler.py,1.38,1.38.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv7275 Modified Files: Tag: release22-maint unixccompiler.py Log Message: Backport a checkin of jvr's: on MacOSX/Darwin, use ranlib when building static libs. I hope this belongs on the branch... Index: unixccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/unixccompiler.py,v retrieving revision 1.38 retrieving revision 1.38.6.1 diff -C2 -d -r1.38 -r1.38.6.1 *** unixccompiler.py 11 Dec 2001 05:04:24 -0000 1.38 --- unixccompiler.py 17 Mar 2002 19:47:39 -0000 1.38.6.1 *************** *** 18,22 **** __revision__ = "$Id$" ! import string, re, os from types import * from copy import copy --- 18,22 ---- __revision__ = "$Id$" ! import string, re, os, sys from types import * from copy import copy *************** *** 62,65 **** --- 62,68 ---- 'ranlib' : None, } + + if sys.platform[:6] == "darwin": + executables['ranlib'] = ["ranlib"] # Needed for the filename generation methods provided by the base From mwh@users.sourceforge.net Sun Mar 17 20:47:13 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Sun, 17 Mar 2002 12:47:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.337.2.4.2.5,1.337.2.4.2.6 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv26709 Modified Files: Tag: release22-maint NEWS Log Message: A first cut at NEWS for 2.2.1c1. Please comment! You can find logs at http://starship.python.net/crew/mwh/cvslog3.txt on the assumption that you don't want to fight cvs yourself. In particular, I need a better explanation of the bugs that have been fixed in the email package. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.337.2.4.2.5 retrieving revision 1.337.2.4.2.6 diff -C2 -d -r1.337.2.4.2.5 -r1.337.2.4.2.6 *** NEWS 17 Mar 2002 15:55:50 -0000 1.337.2.4.2.5 --- NEWS 17 Mar 2002 20:47:11 -0000 1.337.2.4.2.6 *************** *** 1,6 **** ! What's New in Python 2.2.1 XXX? Release date: XXX =============================== Core and builtins --- 1,9 ---- ! What's New in Python 2.2.1c1? Release date: XXX =============================== + This is primarily a bugfix release. Many bugs have been fixed since + the release of 2.2 final. Some of the more notable are listed here. + Core and builtins *************** *** 11,17 **** state of the slots would be lost.) ! - PyErr_Display will provide file and line information for all exceptions ! that have an attribute print_file_and_line, not just SyntaxErrors. This ! fixes the bug that no proper line number is given for bad \x escapes. Extension modules --- 14,42 ---- state of the slots would be lost.) ! - (1).__nonzero__() would dump core. ! ! - Tim has had another go at getting sensible behaviour with respect to ! floating point underflow/overflow. ! ! - Adding an instance of subclass of int to, say, a string, could ! erroneously return "NotImplemented" instead of raising a TypeError. ! ! - Subclassing longs could cause core dumps in certain circumstances. ! ! - PyErr_Display will provide file and line information for all ! exceptions that have an attribute print_file_and_line, not just ! SyntaxErrors. This fixes the bug that no proper line number is given ! for bad \x escapes. ! ! - sys.setprofile() and sys.settrace() would dump core if called with ! no arguments. ! ! - An obscure & small memory overrun in wide unicode builds have been ! fixed. ! ! - __doc__ can now be of arbitrary type (in particular, it can be a ! unicode string). ! ! - complex objects are now immutable (as they should always have been). Extension modules *************** *** 22,30 **** --- 47,80 ---- Python 2.2.1 now ships with zlib-1.1.4. + - new.instancemethod no longer fails for new-style classes. + + - The "pseudo-sequences" returned by os.stat(), os.fstat(), + time.localtime() can now be pickled. + + - Due to a cut and paste error the object exported as + posix.statvfs_result was in fact posix.stat_result. + Library + - The copy module can be used in restricted execution mode. + + - A few bugs in the email package have been fixed. + XXX more detail! + + - StringIO's attitude to unicode strings has been reverted to that of + the 2.1.x branch (note cStringIO still knows nothing about unicode). + - webbrowser: tightened up the command passed to os.system() so that arbitrary shell code can't be executed because a bogus URL was passed in. + + - Recursive structures containing new-style classes can now by + deep-copied. + + - ftplib defaults to passive mode (again). + + Tools + + - Bugs in IDLE's autoindent when using new-style division were fixed. From jackjansen@users.sourceforge.net Sun Mar 17 21:46:50 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 17 Mar 2002 13:46:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-irix6 regen,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-irix6 In directory usw-pr-cvs1:/tmp/cvs-serv28621 Modified Files: regen Log Message: Patch by Michael Pruett: make regen work on Irix 6.0 and 6.5. Index: regen =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/regen,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** regen 31 Jul 2001 08:47:55 -0000 1.2 --- regen 17 Mar 2002 21:46:48 -0000 1.3 *************** *** 1,5 **** #! /bin/sh case `uname -sr` in ! 'IRIX '[45].*) ;; *) echo Probably not on an IRIX system 1>&2 exit 1;; --- 1,6 ---- #! /bin/sh case `uname -sr` in ! 'IRIX '[456].*) ;; ! 'IRIX64 '[456].*) ;; *) echo Probably not on an IRIX system 1>&2 exit 1;; From jackjansen@users.sourceforge.net Sun Mar 17 21:49:22 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 17 Mar 2002 13:49:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-irix6 ERRNO.py,1.1,1.2 FILE.py,1.1,1.2 IN.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-irix6 In directory usw-pr-cvs1:/tmp/cvs-serv30657 Modified Files: ERRNO.py FILE.py IN.py Log Message: Regenerated for Irix 6.5. Index: ERRNO.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/ERRNO.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ERRNO.py 15 Jan 1997 19:18:37 -0000 1.1 --- ERRNO.py 17 Mar 2002 21:49:20 -0000 1.2 *************** *** 1,7 **** ! # Generated by h2py from /usr/include/sys/errno.h # Included from standards.h __KBASE = 1000 __IRIXBASE = 1000 EPERM = 1 ENOENT = 2 --- 1,11 ---- ! # Generated by h2py from /usr/include/errno.h ! ! # Included from sys/errno.h # Included from standards.h __KBASE = 1000 __IRIXBASE = 1000 + __FTNBASE = 4000 + __FTNLAST = 5999 EPERM = 1 ENOENT = 2 *************** *** 50,53 **** --- 54,58 ---- EDEADLK = 45 ENOLCK = 46 + ECKPT = 47 EBADE = 50 EBADR = 51 *************** *** 139,143 **** --- 144,150 ---- ENOTSUP = 1008 ENOATTR = 1009 + EFSCORRUPTED = 1010 EDIRCORRUPTED = 1010 + EWRONGFS = 1011 EDQUOT = 1133 ENFSREMOTE = 1135 *************** *** 162,163 **** --- 169,180 ---- EINVALTIME = 1318 EDESTROYED = 1319 + EBDHDL = 1400 + EDELAY = 1401 + ENOBWD = 1402 + EBADRSPEC = 1403 + EBADTSPEC = 1404 + EBADFILT = 1405 + EMIGRATED = 1500 + EMIGRATING = 1501 + ECELLDOWN = 1502 + EMEMRETRY = 1600 Index: FILE.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/FILE.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FILE.py 15 Jan 1997 19:18:40 -0000 1.1 --- FILE.py 17 Mar 2002 21:49:20 -0000 1.2 *************** *** 13,16 **** --- 13,18 ---- _MIPS_SIM_NABI32 = 2 _MIPS_SIM_ABI64 = 3 + + # Included from sys/pthread.h P_MYID = (-1) P_MYHOSTID = (-1) *************** *** 30,33 **** --- 32,37 ---- NEWDEV = 1 MKDEV_VER = NEWDEV + def IS_STRING_SPEC_DEV(x): return ((dev_t)(x)==__makedev(MKDEV_VER, 0, 0)) + def major(dev): return __major(MKDEV_VER, dev) *************** *** 43,55 **** NBBY = 8 # Included from sys/sema.h MUTEX_DEFAULT = 0x0 ! METER_NAMSZ = 8 def mutex_spinlock(l): return splhi() def mutex_spintrylock(l): return splhi() - def spinlock_islocked(l): return issplhi(getsr()) - def spinlock_initialized(l): return 1 --- 47,476 ---- NBBY = 8 + # Included from sys/cpumask.h + MAXCPU = 128 + def CPUMASK_INDEX(bit): return ((bit) >> 6) + + def CPUMASK_SHFT(bit): return ((bit) & 0x3f) + + def CPUMASK_IS_ZERO(p): return ((p) == 0) + + def CPUMASK_IS_NONZERO(p): return ((p) != 0) + + + # Included from sys/nodemask.h + def CNODEMASK_IS_ZERO(p): return ((p) == 0) + + def CNODEMASK_IS_NONZERO(p): return ((p) != 0) + + # Included from sys/sema.h + + # Included from sys/timespec.h + + # Included from sys/param.h + + # Included from sys/signal.h + SIGHUP = 1 + SIGINT = 2 + SIGQUIT = 3 + SIGILL = 4 + SIGTRAP = 5 + SIGIOT = 6 + SIGABRT = 6 + SIGEMT = 7 + SIGFPE = 8 + SIGKILL = 9 + SIGBUS = 10 + SIGSEGV = 11 + SIGSYS = 12 + SIGPIPE = 13 + SIGALRM = 14 + SIGTERM = 15 + SIGUSR1 = 16 + SIGUSR2 = 17 + SIGCLD = 18 + SIGCHLD = 18 + SIGPWR = 19 + SIGWINCH = 20 + SIGURG = 21 + SIGPOLL = 22 + SIGIO = 22 + SIGSTOP = 23 + SIGTSTP = 24 + SIGCONT = 25 + SIGTTIN = 26 + SIGTTOU = 27 + SIGVTALRM = 28 + SIGPROF = 29 + SIGXCPU = 30 + SIGXFSZ = 31 + SIGK32 = 32 + SIGCKPT = 33 + SIGRESTART = 34 + SIGUME = 35 + SIGPTINTR = 47 + SIGPTRESCHED = 48 + SIGRTMIN = 49 + SIGRTMAX = 64 + __sigargs = int + + # Included from sys/sigevent.h + SIGEV_NONE = 128 + SIGEV_SIGNAL = 129 + SIGEV_CALLBACK = 130 + SIGEV_THREAD = 131 + + # Included from sys/siginfo.h + SI_MAXSZ = 128 + SI_USER = 0 + SI_KILL = SI_USER + SI_QUEUE = -1 + SI_ASYNCIO = -2 + SI_TIMER = -3 + SI_MESGQ = -4 + ILL_ILLOPC = 1 + ILL_ILLOPN = 2 + ILL_ILLADR = 3 + ILL_ILLTRP = 4 + ILL_PRVOPC = 5 + ILL_PRVREG = 6 + ILL_COPROC = 7 + ILL_BADSTK = 8 + NSIGILL = 8 + FPE_INTDIV = 1 + FPE_INTOVF = 2 + FPE_FLTDIV = 3 + FPE_FLTOVF = 4 + FPE_FLTUND = 5 + FPE_FLTRES = 6 + FPE_FLTINV = 7 + FPE_FLTSUB = 8 + NSIGFPE = 8 + SEGV_MAPERR = 1 + SEGV_ACCERR = 2 + NSIGSEGV = 2 + BUS_ADRALN = 1 + BUS_ADRERR = 2 + BUS_OBJERR = 3 + NSIGBUS = 3 + TRAP_BRKPT = 1 + TRAP_TRACE = 2 + NSIGTRAP = 2 + CLD_EXITED = 1 + CLD_KILLED = 2 + CLD_DUMPED = 3 + CLD_TRAPPED = 4 + CLD_STOPPED = 5 + CLD_CONTINUED = 6 + NSIGCLD = 6 + POLL_IN = 1 + POLL_OUT = 2 + POLL_MSG = 3 + POLL_ERR = 4 + POLL_PRI = 5 + POLL_HUP = 6 + NSIGPOLL = 6 + UME_ECCERR = 1 + NSIGUME = 1 + SIG_NOP = 0 + SIG_BLOCK = 1 + SIG_UNBLOCK = 2 + SIG_SETMASK = 3 + SIG_SETMASK32 = 256 + SA_ONSTACK = 0x00000001 + SA_RESETHAND = 0x00000002 + SA_RESTART = 0x00000004 + SA_SIGINFO = 0x00000008 + SA_NODEFER = 0x00000010 + SA_NOCLDWAIT = 0x00010000 + SA_NOCLDSTOP = 0x00020000 + _SA_BSDCALL = 0x10000000 + MINSIGSTKSZ = 512 + SIGSTKSZ = 8192 + SS_ONSTACK = 0x00000001 + SS_DISABLE = 0x00000002 + + # Included from sys/ucontext.h + NGREG = 36 + NGREG = 37 + GETCONTEXT = 0 + SETCONTEXT = 1 + UC_SIGMASK = 001 + UC_STACK = 002 + UC_CPU = 004 + UC_MAU = 010 + UC_MCONTEXT = (UC_CPU|UC_MAU) + UC_ALL = (UC_SIGMASK|UC_STACK|UC_MCONTEXT) + CTX_R0 = 0 + CTX_AT = 1 + CTX_V0 = 2 + CTX_V1 = 3 + CTX_A0 = 4 + CTX_A1 = 5 + CTX_A2 = 6 + CTX_A3 = 7 + CTX_T0 = 8 + CTX_T1 = 9 + CTX_T2 = 10 + CTX_T3 = 11 + CTX_T4 = 12 + CTX_T5 = 13 + CTX_T6 = 14 + CTX_T7 = 15 + CTX_A4 = 8 + CTX_A5 = 9 + CTX_A6 = 10 + CTX_A7 = 11 + CTX_T0 = 12 + CTX_T1 = 13 + CTX_T2 = 14 + CTX_T3 = 15 + CTX_S0 = 16 + CTX_S1 = 17 + CTX_S2 = 18 + CTX_S3 = 19 + CTX_S4 = 20 + CTX_S5 = 21 + CTX_S6 = 22 + CTX_S7 = 23 + CTX_T8 = 24 + CTX_T9 = 25 + CTX_K0 = 26 + CTX_K1 = 27 + CTX_GP = 28 + CTX_SP = 29 + CTX_S8 = 30 + CTX_RA = 31 + CTX_MDLO = 32 + CTX_MDHI = 33 + CTX_CAUSE = 34 + CTX_EPC = 35 + CTX_SR = 36 + CXT_R0 = CTX_R0 + CXT_AT = CTX_AT + CXT_V0 = CTX_V0 + CXT_V1 = CTX_V1 + CXT_A0 = CTX_A0 + CXT_A1 = CTX_A1 + CXT_A2 = CTX_A2 + CXT_A3 = CTX_A3 + CXT_T0 = CTX_T0 + CXT_T1 = CTX_T1 + CXT_T2 = CTX_T2 + CXT_T3 = CTX_T3 + CXT_T4 = CTX_T4 + CXT_T5 = CTX_T5 + CXT_T6 = CTX_T6 + CXT_T7 = CTX_T7 + CXT_S0 = CTX_S0 + CXT_S1 = CTX_S1 + CXT_S2 = CTX_S2 + CXT_S3 = CTX_S3 + CXT_S4 = CTX_S4 + CXT_S5 = CTX_S5 + CXT_S6 = CTX_S6 + CXT_S7 = CTX_S7 + CXT_T8 = CTX_T8 + CXT_T9 = CTX_T9 + CXT_K0 = CTX_K0 + CXT_K1 = CTX_K1 + CXT_GP = CTX_GP + CXT_SP = CTX_SP + CXT_S8 = CTX_S8 + CXT_RA = CTX_RA + CXT_MDLO = CTX_MDLO + CXT_MDHI = CTX_MDHI + CXT_CAUSE = CTX_CAUSE + CXT_EPC = CTX_EPC + CXT_SR = CTX_SR + CTX_FV0 = 0 + CTX_FV1 = 2 + CTX_FA0 = 12 + CTX_FA1 = 13 + CTX_FA2 = 14 + CTX_FA3 = 15 + CTX_FA4 = 16 + CTX_FA5 = 17 + CTX_FA6 = 18 + CTX_FA7 = 19 + CTX_FT0 = 4 + CTX_FT1 = 5 + CTX_FT2 = 6 + CTX_FT3 = 7 + CTX_FT4 = 8 + CTX_FT5 = 9 + CTX_FT6 = 10 + CTX_FT7 = 11 + CTX_FT8 = 20 + CTX_FT9 = 21 + CTX_FT10 = 22 + CTX_FT11 = 23 + CTX_FT12 = 1 + CTX_FT13 = 3 + CTX_FS0 = 24 + CTX_FS1 = 25 + CTX_FS2 = 26 + CTX_FS3 = 27 + CTX_FS4 = 28 + CTX_FS5 = 29 + CTX_FS6 = 30 + CTX_FS7 = 31 + CTX_FT8 = 21 + CTX_FT9 = 23 + CTX_FT10 = 25 + CTX_FT11 = 27 + CTX_FT12 = 29 + CTX_FT13 = 31 + CTX_FT14 = 1 + CTX_FT15 = 3 + CTX_FS0 = 20 + CTX_FS1 = 22 + CTX_FS2 = 24 + CTX_FS3 = 26 + CTX_FS4 = 28 + CTX_FS5 = 30 + SV_ONSTACK = 0x0001 + SV_INTERRUPT = 0x0002 + NUMBSDSIGS = (32) + def sigmask(sig): return (1L << ((sig)-1)) + + def sigmask(sig): return (1L << ((sig)-1)) + + SIG_ERR = (-1) + SIG_IGN = (1) + SIG_HOLD = (2) + SIG_DFL = (0) + NSIG = 65 + MAXSIG = (NSIG-1) + NUMSIGS = (NSIG-1) + BRK_USERBP = 0 + BRK_KERNELBP = 1 + BRK_ABORT = 2 + BRK_BD_TAKEN = 3 + BRK_BD_NOTTAKEN = 4 + BRK_SSTEPBP = 5 + BRK_OVERFLOW = 6 + BRK_DIVZERO = 7 + BRK_RANGE = 8 + BRK_PSEUDO_OP_BIT = 0x80 + BRK_PSEUDO_OP_MAX = 0x3 + BRK_CACHE_SYNC = 0x80 + BRK_MULOVF = 1023 + _POSIX_VERSION = 199506L + _POSIX_VERSION = 199506 + _POSIX_VDISABLE = 0 + MAX_INPUT = 512 + MAX_CANON = 256 + UID_NOBODY = 60001 + GID_NOBODY = UID_NOBODY + UID_NOACCESS = 60002 + MAXPID = 0x7ffffff0 + MAXUID = 0x7fffffff + MAXLINK = 30000 + SSIZE = 1 + SINCR = 1 + KSTKSIZE = 1 + EXTKSTKSIZE = 1 + KSTKIDX = 0 + KSTEIDX = 1 + EXTKSTKSIZE = 0 + KSTKIDX = 0 + CANBSIZ = 256 + HZ = 100 + TICK = 10000000 + NOFILE = 20 + NGROUPS_UMIN = 0 + NGROUPS_UMAX = 32 + NGROUPS = 16 + PMASK = 0177 + PCATCH = 0400 + PLTWAIT = 01000 + PRECALC = 01000 + PSWP = 0 + PINOD = 10 + PSNDD = PINOD + PRIBIO = 20 + PZERO = 25 + PMEM = 0 + NZERO = 20 + PPIPE = 26 + PVFS = 27 + PWAIT = 30 + PSLEP = 39 + PUSER = 60 + PBATCH_CRITICAL = -1 + PTIME_SHARE = -2 + PTIME_SHARE_OVER = -3 + PBATCH = -4 + PWEIGHTLESS = -5 + IO_NBPC = 4096 + IO_BPCSHIFT = 12 + MIN_NBPC = 4096 + MIN_BPCSHIFT = 12 + MIN_CPSSHIFT = 10 + BPCSHIFT = 12 + CPSSHIFT = 10 + BPCSHIFT = 14 + CPSSHIFT = 12 + CPSSHIFT = 11 + BPSSHIFT = (BPCSHIFT+CPSSHIFT) + NULL = 0L + CMASK = 022 + NODEV = (-1) + NOPAGE = (-1) + NBPSCTR = 512 + SCTRSHFT = 9 + def BASEPRI(psw): return (((psw) & SR_IMASK) == SR_IMASK0) + + def BASEPRI(psw): return (((psw) & SR_IMASK) == SR_IMASK) + + def USERMODE(psw): return (((psw) & SR_KSU_MSK) == SR_KSU_USR) + + MAXPATHLEN = 1024 + MAXSYMLINKS = 30 + MAXNAMELEN = 256 + PIPE_BUF = 10240 + PIPE_MAX = 10240 + NBBY = 8 + BBSHIFT = 9 + BBSIZE = (1<> BBSHIFT) + + def OFFTOBBT(bytes): return ((off_t)(bytes) >> BBSHIFT) + + def BBTOOFF(bbs): return ((off_t)(bbs) << BBSHIFT) + + SEEKLIMIT32 = 0x7fffffff + MAXBSIZE = 8192 + DEV_BSIZE = BBSIZE + DEV_BSHIFT = BBSHIFT + def btodb(bytes): return \ + + def dbtob(db): return \ + + BLKDEV_IOSHIFT = BPCSHIFT + BLKDEV_IOSIZE = (1<> BLKDEV_IOSHIFT) + + def BLKDEV_LTOP(bn): return ((bn) * BLKDEV_BB) + + MAXHOSTNAMELEN = 256 + def DELAY(n): return us_delay(n) + + def DELAYBUS(n): return us_delaybus(n) + + TIMEPOKE_NOW = -100L MUTEX_DEFAULT = 0x0 ! METER_NAMSZ = 16 ! METER_NO_SEQ = -1 def mutex_spinlock(l): return splhi() def mutex_spintrylock(l): return splhi() def spinlock_initialized(l): return 1 *************** *** 57,67 **** SV_LIFO = 0x2 SV_PRIO = 0x4 SV_DEFAULT = SV_FIFO SEMA_NOHIST = 0x0001 SEMA_LOCK = 0x0004 ! SEMA_METER = 0x0008 ! SEMA_NAMSZ = METER_NAMSZ ! MR_ACCESS = 0x1 ! MR_UPDATE = 0x2 def mp_mutex_unlock(m): return mutex_unlock(m) --- 478,497 ---- SV_LIFO = 0x2 SV_PRIO = 0x4 + SV_KEYED = 0x6 SV_DEFAULT = SV_FIFO SEMA_NOHIST = 0x0001 SEMA_LOCK = 0x0004 ! NSCHEDCLASS = (-(PWEIGHTLESS)+1) ! MR_ACCESS = 1 ! MR_UPDATE = 2 ! MRLOCK_BARRIER = 0x1 ! MRLOCK_BEHAVIOR = 0x2 ! MRLOCK_DBLTRIPPABLE = 0x4 ! MRLOCK_ALLOW_EQUAL_PRI = 0x8 ! MRLOCK_DEFAULT = MRLOCK_BARRIER ! def mraccess(mrp): return mraccessf(mrp, 0) ! ! def mrupdate(mrp): return mrupdatef(mrp, 0) ! def mp_mutex_unlock(m): return mutex_unlock(m) *************** *** 70,100 **** def mp_mutex_spinlock(m): return mutex_spinlock(m) - def mp_mutex_trylock(m): return 1 - - def mp_mutex_spinlock(m): return 1 - - def nested_spintrylock(m): return 1 - - def mp_mrunlock(a): return mrunlock(a) - - def mp_cpsema(x): return cpsema(x) - - def mp_cvsema(x): return cvsema(x) - - def mp_cpsema(x): return 1 - - def mp_cvsema(x): return 0 MON_LOCKED = 0x01 MON_WAITING = 0x02 MON_TIMEOUT = 0x04 def initlock(l): return spinlock_init(l,0) def ownlock(x): return 1 - def splock(x): return 1 - - def io_splock(x): return 1 - def mutex_enter(m): return mutex_lock(m, PZERO) --- 500,515 ---- def mp_mutex_spinlock(m): return mutex_spinlock(m) + # Included from sys/mon.h MON_LOCKED = 0x01 MON_WAITING = 0x02 MON_TIMEOUT = 0x04 + MON_DOSRV = 0x08 + MON_RUN = 0x10 + MR_READER_BUCKETS = 13 def initlock(l): return spinlock_init(l,0) def ownlock(x): return 1 def mutex_enter(m): return mutex_lock(m, PZERO) *************** *** 113,117 **** def rw_exit(r): return mrunlock(r) ! def rw_tryupgrade(r): return cmrpromote(r) def rw_downgrade(r): return mrdemote(r) --- 528,532 ---- def rw_exit(r): return mrunlock(r) ! def rw_tryupgrade(r): return mrtrypromote(r) def rw_downgrade(r): return mrdemote(r) *************** *** 123,126 **** --- 538,545 ---- def RW_READ_HELD(r): return ismrlocked(r, MR_ACCESS) + MS_FREE = 0 + MS_UPD = 1 + MS_ACC = 2 + MS_WAITERS = 4 # Included from sys/fcntl.h *************** *** 135,138 **** --- 554,558 ---- FNONBLK = FNONBLOCK FDIRECT = 0x8000 + FBULK = 0x10000 FDIRENT64 = 0x8000 FCREAT = 0x0100 *************** *** 151,154 **** --- 571,575 ---- O_LARGEFILE = 0x2000 O_DIRECT = 0x8000 + O_BULK = 0x10000 O_CREAT = 0x100 O_TRUNC = 0x200 *************** *** 160,164 **** F_GETFL = 3 F_SETFL = 4 - F_GETLK = 14 F_SETLK = 6 F_SETLKW = 7 --- 581,584 ---- *************** *** 168,171 **** --- 588,600 ---- F_SETBSDLK = 12 F_SETBSDLKW = 13 + F_GETLK = 14 + F_CHKLK = 15 + F_CHKLKW = 16 + F_CLNLK = 17 + F_RSETLK = 20 + F_RGETLK = 21 + F_RSETLKW = 22 + F_GETOWN = 23 + F_SETOWN = 24 F_DIOINFO = 30 F_FSGETXATTR = 31 *************** *** 184,193 **** F_GETBMAPA = 44 F_FSGETXATTRA = 45 ! F_GETALLLK = 46 ! F_RSETLK = 20 ! F_RGETLK = 21 ! F_RSETLKW = 22 ! F_GETOWN = 23 ! F_SETOWN = 24 F_RDLCK = 01 F_WRLCK = 02 --- 613,627 ---- F_GETBMAPA = 44 F_FSGETXATTRA = 45 ! F_SETBIOSIZE = 46 ! F_GETBIOSIZE = 47 ! F_GETOPS = 50 ! F_DMAPI = 51 ! F_FSYNC = 52 ! F_FSYNC64 = 53 ! F_GETBDSATTR = 54 ! F_SETBDSATTR = 55 ! F_GETBMAPX = 56 ! F_SETPRIO = 57 ! F_GETPRIO = 58 F_RDLCK = 01 F_WRLCK = 02 *************** *** 196,200 **** FD_CLOEXEC = 1 FD_NODUP_FORK = 4 ! FMASK = 0x90FF FOPEN = 0xFFFFFFFF FREAD = 0x01 --- 630,640 ---- FD_CLOEXEC = 1 FD_NODUP_FORK = 4 ! BMV_IF_ATTRFORK = 0x1 ! BMV_IF_NO_DMAPI_READ = 0x2 ! BMV_IF_PREALLOC = 0x4 ! BMV_IF_VALID = (BMV_IF_ATTRFORK|BMV_IF_NO_DMAPI_READ|BMV_IF_PREALLOC) ! BMV_OF_PREALLOC = 0x1 ! BMV_IF_EXTENDED = 0x40000000 ! FMASK = 0x190FF FOPEN = 0xFFFFFFFF FREAD = 0x01 *************** *** 210,236 **** FLARGEFILE = 0x2000 FDIRECT = 0x8000 FCREAT = 0x0100 FTRUNC = 0x0200 FEXCL = 0x0400 FNOCTTY = 0x0800 - FMARK = 0x4000 - FDEFER = 0x2000 - FINPROGRESS = 0x0400 FINVIS = 0x0100 ! FNMFS = 0x2000 FDIRENT64 = 0x8000 ! FCLOSEXEC = 001 ! FDSHD = 0x0001 ! FDNOMARK = 0x0002 ! FDIGNPROGRESS = 0x0004 LOCK_SH = 1 LOCK_EX = 2 LOCK_NB = 4 LOCK_UN = 8 F_OK = 0 X_OK = 1 W_OK = 2 R_OK = 4 - L_SET = 0 - L_INCR = 1 - L_XTND = 2 --- 650,674 ---- FLARGEFILE = 0x2000 FDIRECT = 0x8000 + FBULK = 0x10000 FCREAT = 0x0100 FTRUNC = 0x0200 FEXCL = 0x0400 FNOCTTY = 0x0800 FINVIS = 0x0100 ! FSOCKET = 0x0200 ! FINPROGRESS = 0x0400 ! FPRIORITY = 0x0800 ! FPRIO = 0x4000 FDIRENT64 = 0x8000 ! FCLOSEXEC = 0x01 LOCK_SH = 1 LOCK_EX = 2 LOCK_NB = 4 LOCK_UN = 8 + L_SET = 0 + L_INCR = 1 + L_XTND = 2 F_OK = 0 X_OK = 1 W_OK = 2 R_OK = 4 Index: IN.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/IN.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IN.py 15 Jan 1997 19:18:50 -0000 1.1 --- IN.py 17 Mar 2002 21:49:20 -0000 1.2 *************** *** 1,4 **** --- 1,6 ---- # Generated by h2py from /usr/include/netinet/in.h + # Included from standards.h + # Included from sgidefs.h _MIPS_ISA_MIPS1 = 1 *************** *** 10,32 **** _MIPS_SIM_ABI64 = 3 - # Included from sys/endian.h - LITTLE_ENDIAN = 1234 - BIG_ENDIAN = 4321 - PDP_ENDIAN = 3412 - BYTE_ORDER = BIG_ENDIAN - BYTE_ORDER = LITTLE_ENDIAN - def ntohl(x): return (x) - - def ntohs(x): return (x) - - def htonl(x): return (x) - - def htons(x): return (x) - - def htonl(x): return ntohl(x) - - def htons(x): return ntohs(x) - - # Included from sys/bsd_types.h --- 12,15 ---- *************** *** 43,46 **** --- 26,31 ---- NEWDEV = 1 MKDEV_VER = NEWDEV + def IS_STRING_SPEC_DEV(x): return ((dev_t)(x)==__makedev(MKDEV_VER, 0, 0)) + def major(dev): return __major(MKDEV_VER, dev) *************** *** 49,54 **** # Included from sys/select.h - - # Included from standards.h FD_SETSIZE = 1024 __NBBY = 8 --- 34,37 ---- *************** *** 57,61 **** --- 40,90 ---- NULL = 0L NBBY = 8 + + # Included from sys/endian.h + LITTLE_ENDIAN = 1234 + BIG_ENDIAN = 4321 + PDP_ENDIAN = 3412 + _LITTLE_ENDIAN = 1234 + _BIG_ENDIAN = 4321 + _PDP_ENDIAN = 3412 + _BYTE_ORDER = _BIG_ENDIAN + _BYTE_ORDER = _LITTLE_ENDIAN + def ntohl(x): return (x) + + def ntohs(x): return (x) + + def htonl(x): return (x) + + def htons(x): return (x) + + def htonl(x): return ntohl(x) + + def htons(x): return ntohs(x) + + + # Included from sys/types.h + + # Included from sys/pthread.h + P_MYID = (-1) + P_MYHOSTID = (-1) + + # Included from sys/cpumask.h + MAXCPU = 128 + def CPUMASK_INDEX(bit): return ((bit) >> 6) + + def CPUMASK_SHFT(bit): return ((bit) & 0x3f) + + def CPUMASK_IS_ZERO(p): return ((p) == 0) + + def CPUMASK_IS_NONZERO(p): return ((p) != 0) + + + # Included from sys/nodemask.h + def CNODEMASK_IS_ZERO(p): return ((p) == 0) + + def CNODEMASK_IS_NONZERO(p): return ((p) != 0) + IPPROTO_IP = 0 + IPPROTO_HOPOPTS = 0 IPPROTO_ICMP = 1 IPPROTO_IGMP = 2 *************** *** 65,84 **** --- 94,183 ---- IPPROTO_ST = 5 IPPROTO_TCP = 6 + IPPROTO_UCL = 7 IPPROTO_EGP = 8 + IPPROTO_IGP = 9 + IPPROTO_BBN_RCC_MON = 10 + IPPROTO_NVP_II = 11 IPPROTO_PUP = 12 + IPPROTO_ARGUS = 13 + IPPROTO_EMCON = 14 + IPPROTO_XNET = 15 + IPPROTO_CHAOS = 16 IPPROTO_UDP = 17 + IPPROTO_MUX = 18 + IPPROTO_DCN_MEAS = 19 + IPPROTO_HMP = 20 + IPPROTO_PRM = 21 IPPROTO_IDP = 22 + IPPROTO_TRUNK_1 = 23 + IPPROTO_TRUNK_2 = 24 + IPPROTO_LEAF_1 = 25 + IPPROTO_LEAF_2 = 26 + IPPROTO_RDP = 27 + IPPROTO_IRTP = 28 IPPROTO_TP = 29 + IPPROTO_NETBLT = 30 + IPPROTO_MFE_NSP = 31 + IPPROTO_MERIT_INP = 32 + IPPROTO_SEP = 33 + IPPROTO_3PC = 34 + IPPROTO_IDPR = 35 IPPROTO_XTP = 36 + IPPROTO_DDP = 37 + IPPROTO_IDPR_CMTP = 38 + IPPROTO_TPPP = 39 + IPPROTO_IL = 40 + IPPROTO_IPV6 = 41 + IPPROTO_ROUTING = 43 + IPPROTO_FRAGMENT = 44 IPPROTO_RSVP = 46 + IPPROTO_ESP = 50 + IPPROTO_AH = 51 + IPPROTO_ICMPV6 = 58 + IPPROTO_NONE = 59 + IPPROTO_DSTOPTS = 60 + IPPROTO_CFTP = 62 IPPROTO_HELLO = 63 + IPPROTO_SAT_EXPAK = 64 + IPPROTO_KRYPTOLAN = 65 + IPPROTO_RVD = 66 + IPPROTO_IPPC = 67 + IPPROTO_SAT_MON = 69 + IPPROTO_VISA = 70 + IPPROTO_IPCV = 71 + IPPROTO_CPNX = 72 + IPPROTO_CPHB = 73 + IPPROTO_WSN = 74 + IPPROTO_PVP = 75 + IPPROTO_BR_SAT_MON = 76 IPPROTO_ND = 77 + IPPROTO_WB_MON = 78 + IPPROTO_WB_EXPAK = 79 IPPROTO_EON = 80 + IPPROTO_VMTP = 81 + IPPROTO_SECURE_VMTP = 82 + IPPROTO_VINES = 83 + IPPROTO_TTP = 84 + IPPROTO_NSFNET_IGP = 85 + IPPROTO_DGP = 86 + IPPROTO_TCF = 87 + IPPROTO_IGRP = 88 IPPROTO_OSPF = 89 + IPPROTO_SPRITE_RPC = 90 + IPPROTO_LARP = 91 + IPPROTO_MTP = 92 + IPPROTO_AX25 = 93 IPPROTO_SWIPE = 94 + IPPROTO_MICP = 95 + IPPROTO_AES_SP3_D = 96 + IPPROTO_ETHERIP = 97 + IPPROTO_ENCAPHDR = 98 IPPROTO_RAW = 255 IPPROTO_MAX = 256 + IPPROTO_STP = 257 IPPORT_RESERVED = 1024 IPPORT_MAXPORT = 65535 + INET_ADDRSTRLEN = 16 + INET6_ADDRSTRLEN = 46 def IN_CLASSA(i): return (((__int32_t)(i) & 0x80000000) == 0) *************** *** 111,114 **** --- 210,344 ---- INADDR_NONE = 0xffffffff IN_LOOPBACKNET = 127 + IPNGVERSION = 6 + IPV6_FLOWINFO_FLOWLABEL = 0x00ffffff + IPV6_FLOWINFO_PRIORITY = 0x0f000000 + IPV6_FLOWINFO_PRIFLOW = 0x0fffffff + IPV6_FLOWINFO_SRFLAG = 0x10000000 + IPV6_FLOWINFO_VERSION = 0xf0000000 + IPV6_PRIORITY_UNCHARACTERIZED = 0x00000000 + IPV6_PRIORITY_FILLER = 0x01000000 + IPV6_PRIORITY_UNATTENDED = 0x02000000 + IPV6_PRIORITY_RESERVED1 = 0x03000000 + IPV6_PRIORITY_BULK = 0x04000000 + IPV6_PRIORITY_RESERVED2 = 0x05000000 + IPV6_PRIORITY_INTERACTIVE = 0x06000000 + IPV6_PRIORITY_CONTROL = 0x07000000 + IPV6_PRIORITY_8 = 0x08000000 + IPV6_PRIORITY_9 = 0x09000000 + IPV6_PRIORITY_10 = 0x0a000000 + IPV6_PRIORITY_11 = 0x0b000000 + IPV6_PRIORITY_12 = 0x0c000000 + IPV6_PRIORITY_13 = 0x0d000000 + IPV6_PRIORITY_14 = 0x0e000000 + IPV6_PRIORITY_15 = 0x0f000000 + IPV6_SRFLAG_STRICT = 0x10000000 + IPV6_SRFLAG_LOOSE = 0x00000000 + IPV6_VERSION = 0x60000000 + IPV6_FLOWINFO_FLOWLABEL = 0xffffff00 + IPV6_FLOWINFO_PRIORITY = 0x0000000f + IPV6_FLOWINFO_PRIFLOW = 0xffffff0f + IPV6_FLOWINFO_SRFLAG = 0x00000010 + IPV6_FLOWINFO_VERSION = 0x000000f0 + IPV6_PRIORITY_UNCHARACTERIZED = 0x00000000 + IPV6_PRIORITY_FILLER = 0x00000001 + IPV6_PRIORITY_UNATTENDED = 0x00000002 + IPV6_PRIORITY_RESERVED1 = 0x00000003 + IPV6_PRIORITY_BULK = 0x00000004 + IPV6_PRIORITY_RESERVED2 = 0x00000005 + IPV6_PRIORITY_INTERACTIVE = 0x00000006 + IPV6_PRIORITY_CONTROL = 0x00000007 + IPV6_PRIORITY_8 = 0x00000008 + IPV6_PRIORITY_9 = 0x00000009 + IPV6_PRIORITY_10 = 0x0000000a + IPV6_PRIORITY_11 = 0x0000000b + IPV6_PRIORITY_12 = 0x0000000c + IPV6_PRIORITY_13 = 0x0000000d + IPV6_PRIORITY_14 = 0x0000000e + IPV6_PRIORITY_15 = 0x0000000f + IPV6_SRFLAG_STRICT = 0x00000010 + IPV6_SRFLAG_LOOSE = 0x00000000 + IPV6_VERSION = 0x00000060 + def IPV6_GET_FLOWLABEL(x): return (ntohl(x) & 0x00ffffff) + + def IPV6_GET_PRIORITY(x): return ((ntohl(x) >> 24) & 0xf) + + def IPV6_GET_VERSION(x): return ((ntohl(x) >> 28) & 0xf) + + def IPV6_SET_FLOWLABEL(x): return (htonl(x) & IPV6_FLOWINFO_FLOWLABEL) + + def IPV6_SET_PRIORITY(x): return (htonl((x & 0xf) << 24)) + + def CLR_ADDR6(a): return \ + + def IS_ANYSOCKADDR(a): return \ + + def IS_ANYADDR6(a): return \ + + def IS_COMPATSOCKADDR(a): return \ + + def IS_COMPATADDR6(a): return \ + + def IS_LOOPSOCKADDR(a): return \ + + def IS_LOOPADDR6(a): return \ + + def IS_IPV4SOCKADDR(a): return \ + + def IS_IPV4ADDR6(a): return \ + + def IS_LOOPSOCKADDR(a): return \ + + def IS_LOOPADDR6(a): return \ + + def IS_IPV4SOCKADDR(a): return \ + + def IS_IPV4ADDR6(a): return \ + + def IS_LOCALADDR6(a): return ((a).s6_addr8[0] == 0xfe) + + def IS_LINKLADDR6(a): return \ + + def IS_SITELADDR6(a): return \ + + def IS_MULTIADDR6(a): return ((a).s6_addr8[0] == 0xff) + + def MADDR6_FLAGS(a): return ((a).s6_addr8[1] >> 4) + + MADDR6_FLG_WK = 0 + MADDR6_FLG_TS = 1 + def MADDR6_SCOPE(a): return ((a).s6_addr8[1] & 0x0f) + + MADDR6_SCP_NODE = 0x1 + MADDR6_SCP_LINK = 0x2 + MADDR6_SCP_SITE = 0x5 + MADDR6_SCP_ORG = 0x8 + MADDR6_SCP_GLO = 0xe + MADDR6_ALLNODES = 1 + MADDR6_ALLROUTERS = 2 + MADDR6_ALLHOSTS = 3 + def IN6_IS_ADDR_UNSPECIFIED(p): return IS_ANYADDR6(*p) + + def IN6_IS_ADDR_LOOPBACK(p): return IS_LOOPADDR6(*p) + + def IN6_IS_ADDR_MULTICAST(p): return IS_MULTIADDR6(*p) + + def IN6_IS_ADDR_LINKLOCAL(p): return IS_LINKLADDR6(*p) + + def IN6_IS_ADDR_SITELOCAL(p): return IS_SITELADDR6(*p) + + def IN6_IS_ADDR_V4MAPPED(p): return IS_IPV4ADDR6(*p) + + def IN6_IS_ADDR_V4COMPAT(p): return IS_COMPATADDR6(*p) + + def IN6_IS_ADDR_MC_NODELOCAL(p): return \ + + def IN6_IS_ADDR_MC_LINKLOCAL(p): return \ + + def IN6_IS_ADDR_MC_SITELOCAL(p): return \ + + def IN6_IS_ADDR_MC_ORGLOCAL(p): return \ + + def IN6_IS_ADDR_MC_GLOBAL(p): return \ + IP_OPTIONS = 1 IP_HDRINCL = 2 *************** *** 129,133 **** IP_RSVP_ON = 28 IP_SENDSRCADDR = 36 IP_DEFAULT_MULTICAST_TTL = 1 IP_DEFAULT_MULTICAST_LOOP = 1 ! IP_MAX_MEMBERSHIPS = 20 --- 359,385 ---- IP_RSVP_ON = 28 IP_SENDSRCADDR = 36 + IPV6_UNICAST_HOPS = IP_TTL + IPV6_MULTICAST_IF = IP_MULTICAST_IF + IPV6_MULTICAST_HOPS = IP_MULTICAST_TTL + IPV6_MULTICAST_LOOP = IP_MULTICAST_LOOP + IPV6_ADD_MEMBERSHIP = IP_ADD_MEMBERSHIP + IPV6_DROP_MEMBERSHIP = IP_DROP_MEMBERSHIP + IPV6_SENDIF = 40 + IPV6_NOPROBE = 42 + IPV6_RECVPKTINFO = 43 + IPV6_PKTINFO = 44 + IP_RECVTTL = 45 + IPV6_RECVHOPS = IP_RECVTTL + IPV6_CHECKSUM = 46 + ICMP6_FILTER = 47 + IPV6_HOPLIMIT = 48 + IPV6_HOPOPTS = 49 + IPV6_DSTOPTS = 50 + IPV6_RTHDR = 51 + IPV6_PKTOPTIONS = 52 + IPV6_NEXTHOP = 53 IP_DEFAULT_MULTICAST_TTL = 1 IP_DEFAULT_MULTICAST_LOOP = 1 ! IPV6_RTHDR_LOOSE = 0 ! IPV6_RTHDR_STRICT = 1 ! IPV6_RTHDR_TYPE_0 = 0 From montanaro@users.sourceforge.net Sun Mar 17 23:03:44 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Sun, 17 Mar 2002 15:03:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_dumbdbm.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv8634 Modified Files: test_dumbdbm.py Log Message: restructure a bit to not rely on test case execution ordering add test case for bug #482460 Index: test_dumbdbm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_dumbdbm.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_dumbdbm.py 30 Jan 2002 07:32:53 -0000 1.5 --- test_dumbdbm.py 17 Mar 2002 23:03:42 -0000 1.6 *************** *** 31,39 **** def __init__(self, *args): unittest.TestCase.__init__(self, *args) - self._dkeys = self._dict.keys() - self._dkeys.sort() def test_dumbdbm_creation(self): - _delete_files() f = dumbdbm.open(_fname, 'c') self.assertEqual(f.keys(), []) --- 31,36 ---- *************** *** 44,47 **** --- 41,45 ---- def test_dumbdbm_modification(self): + self.init_db() f = dumbdbm.open(_fname, 'w') self._dict['g'] = f['g'] = "indented" *************** *** 50,53 **** --- 48,52 ---- def test_dumbdbm_read(self): + self.init_db() f = dumbdbm.open(_fname, 'r') self.read_helper(f) *************** *** 55,62 **** --- 54,72 ---- def test_dumbdbm_keys(self): + self.init_db() f = dumbdbm.open(_fname) keys = self.keys_helper(f) f.close() + def test_write_write_read(self): + # test for bug #482460 + f = dumbdbm.open(_fname) + f['1'] = 'hello' + f['1'] = 'hello2' + f.close() + f = dumbdbm.open(_fname) + self.assertEqual(f['1'], 'hello2') + f.close() + def read_helper(self, f): keys = self.keys_helper(f) *************** *** 64,72 **** self.assertEqual(self._dict[key], f[key]) def keys_helper(self, f): keys = f.keys() keys.sort() ! self.assertEqual(keys, self._dkeys) return keys def test_main(): --- 74,96 ---- self.assertEqual(self._dict[key], f[key]) + def init_db(self): + f = dumbdbm.open(_fname, 'w') + for k in self._dict: + f[k] = self._dict[k] + f.close() + def keys_helper(self, f): keys = f.keys() keys.sort() ! dkeys = self._dict.keys() ! dkeys.sort() ! self.assertEqual(keys, dkeys) return keys + + def tearDown(self): + _delete_files() + + def setUp(self): + _delete_files() def test_main(): From montanaro@users.sourceforge.net Sun Mar 17 23:15:04 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Sun, 17 Mar 2002 15:15:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libxmlrpclib.tex,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv14122 Modified Files: libxmlrpclib.tex Log Message: added note that xmlrpclib won't marshal instances of subclasses of the builtin types Index: libxmlrpclib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libxmlrpclib.tex,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** libxmlrpclib.tex 14 Mar 2002 17:35:25 -0000 1.7 --- libxmlrpclib.tex 17 Mar 2002 23:15:02 -0000 1.8 *************** *** 59,63 **** may also raise a special \exception{Fault} instance, used to signal XML-RPC server errors, or \exception{ProtocolError} used to signal an ! error in the HTTP/HTTPS transport layer. When passing strings, characters special to XML such as \samp{<}, --- 59,65 ---- may also raise a special \exception{Fault} instance, used to signal XML-RPC server errors, or \exception{ProtocolError} used to signal an ! error in the HTTP/HTTPS transport layer. Note that even though starting ! with Python 2.2 you can subclass builtin types, the xmlrpclib module ! currently does not marshal instances of such subclasses. When passing strings, characters special to XML such as \samp{<}, From prescod@users.sourceforge.net Mon Mar 18 02:13:50 2002 From: prescod@users.sourceforge.net (Paul Prescod) Date: Sun, 17 Mar 2002 18:13:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib netrc.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv20396 Modified Files: netrc.py Log Message: netrc will now raise a more predictable exception when $HOME is not set (as it is often not on Windows). The code was always designed so that it would raise an IOError if there was no .netrc. But if there was no $HOME it would return a KeyError which would be somewhat unexpected for code that didn't know the algorithm it used to find .netrc. The particular code that triggered this problem for me was ftpmirror.py which handled the IOError gracefully, but not the KeyError. Index: netrc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/netrc.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** netrc.py 15 Apr 2001 12:51:42 -0000 1.12 --- netrc.py 18 Mar 2002 02:13:48 -0000 1.13 *************** *** 23,27 **** def __init__(self, file=None): if not file: ! file = os.path.join(os.environ['HOME'], ".netrc") fp = open(file) self.hosts = {} --- 23,30 ---- def __init__(self, file=None): if not file: ! try: ! file = os.path.join(os.environ['HOME'], ".netrc") ! except KeyError: ! raise IOError("Could not find .netrc: $HOME is not set") fp = open(file) self.hosts = {} From montanaro@users.sourceforge.net Mon Mar 18 03:00:40 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Sun, 17 Mar 2002 19:00:40 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_anydbm.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv29611 Added Files: test_anydbm.py Log Message: initial test_anydbm module - based on test_dumbdbm.py --- NEW FILE: test_anydbm.py --- #! /usr/bin/env python """Test script for the anydbm module based on testdumbdbm.py """ import os import test_support import unittest import anydbm import tempfile import glob _fname = tempfile.mktemp() def _delete_files(): # we don't know the precise name the underlying database uses # so we use glob to locate all names for f in glob.glob(_fname + "*"): try: os.unlink(f) except OSError: pass class AnyDBMTestCase(unittest.TestCase): _dict = {'0': '', 'a': 'Python:', 'b': 'Programming', 'c': 'the', 'd': 'way', 'f': 'Guido', 'g': 'intended' } def __init__(self, *args): unittest.TestCase.__init__(self, *args) def test_anydbm_creation(self): f = anydbm.open(_fname, 'c') self.assertEqual(f.keys(), []) for key in self._dict: f[key] = self._dict[key] self.read_helper(f) f.close() def test_anydbm_modification(self): self.init_db() f = anydbm.open(_fname, 'c') self._dict['g'] = f['g'] = "indented" self.read_helper(f) f.close() def test_anydbm_read(self): self.init_db() f = anydbm.open(_fname, 'r') self.read_helper(f) f.close() def test_anydbm_keys(self): self.init_db() f = anydbm.open(_fname, 'r') keys = self.keys_helper(f) f.close() def read_helper(self, f): keys = self.keys_helper(f) for key in self._dict: self.assertEqual(self._dict[key], f[key]) def init_db(self): f = anydbm.open(_fname, 'n') for k in self._dict: f[k] = self._dict[k] f.close() def keys_helper(self, f): keys = f.keys() keys.sort() dkeys = self._dict.keys() dkeys.sort() self.assertEqual(keys, dkeys) return keys def tearDown(self): _delete_files() def setUp(self): _delete_files() def test_main(): try: test_support.run_unittest(AnyDBMTestCase) finally: _delete_files() if __name__ == "__main__": test_main() From gvanrossum@users.sourceforge.net Mon Mar 18 03:05:38 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sun, 17 Mar 2002 19:05:38 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects funcobject.c,2.50,2.50.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv30061/Objects Modified Files: Tag: release22-maint funcobject.c Log Message: Fix for SF bug 528132 (Armin Rigo): classmethod().__get__() segfault The proper fix is not quite what was submitted; it's really better to take the class of the object passed rather than calling PyMethod_New with NULL pointer args, because that can then cause other core dumps later. I also added a testcase for the fix to classmethods() in test_descr.py. I'll apply this to 2.3 too. Index: funcobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v retrieving revision 2.50 retrieving revision 2.50.4.1 diff -C2 -d -r2.50 -r2.50.4.1 *** funcobject.c 17 Dec 2001 11:39:56 -0000 2.50 --- funcobject.c 18 Mar 2002 03:05:35 -0000 2.50.4.1 *************** *** 475,478 **** --- 475,480 ---- return NULL; } + if (type == NULL) + type = (PyObject *)(obj->ob_type); return PyMethod_New(cm->cm_callable, type, (PyObject *)(type->ob_type)); From gvanrossum@users.sourceforge.net Mon Mar 18 03:05:38 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sun, 17 Mar 2002 19:05:38 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.113.4.8,1.113.4.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv30061/Lib/test Modified Files: Tag: release22-maint test_descr.py Log Message: Fix for SF bug 528132 (Armin Rigo): classmethod().__get__() segfault The proper fix is not quite what was submitted; it's really better to take the class of the object passed rather than calling PyMethod_New with NULL pointer args, because that can then cause other core dumps later. I also added a testcase for the fix to classmethods() in test_descr.py. I'll apply this to 2.3 too. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.113.4.8 retrieving revision 1.113.4.9 diff -C2 -d -r1.113.4.8 -r1.113.4.9 *** test_descr.py 17 Mar 2002 19:31:28 -0000 1.113.4.8 --- test_descr.py 18 Mar 2002 03:05:36 -0000 1.113.4.9 *************** *** 1209,1212 **** --- 1209,1217 ---- vereq(d.foo(1), (d, 1)) vereq(D.foo(d, 1), (d, 1)) + # Test for a specific crash (SF bug 528132) + def f(cls, arg): return (cls, arg) + ff = classmethod(f) + vereq(ff.__get__(0, int)(42), (int, 42)) + vereq(ff.__get__(0)(42), (int, 42)) def staticmethods(): From montanaro@users.sourceforge.net Mon Mar 18 03:07:22 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Sun, 17 Mar 2002 19:07:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib anydbm.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv30631 Modified Files: anydbm.py Log Message: dump the string exception fallback for anydbm.error. Index: anydbm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/anydbm.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** anydbm.py 11 May 2001 18:27:00 -0000 1.11 --- anydbm.py 18 Mar 2002 03:07:20 -0000 1.12 *************** *** 43,51 **** """ ! try: ! class error(Exception): ! pass ! except (NameError, TypeError): ! error = "anydbm.error" _names = ['dbhash', 'gdbm', 'dbm', 'dumbdbm'] --- 43,48 ---- """ ! class error(Exception): ! pass _names = ['dbhash', 'gdbm', 'dbm', 'dumbdbm'] From gvanrossum@users.sourceforge.net Mon Mar 18 03:09:08 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sun, 17 Mar 2002 19:09:08 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects funcobject.c,2.50,2.51 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv30809/Objects Modified Files: funcobject.c Log Message: Fix for SF bug 528132 (Armin Rigo): classmethod().__get__() segfault The proper fix is not quite what was submitted; it's really better to take the class of the object passed rather than calling PyMethod_New with NULL pointer args, because that can then cause other core dumps later. I also added a testcase for the fix to classmethods() in test_descr.py. I've already applied this to the 2.2 branch. Index: funcobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v retrieving revision 2.50 retrieving revision 2.51 diff -C2 -d -r2.50 -r2.51 *** funcobject.c 17 Dec 2001 11:39:56 -0000 2.50 --- funcobject.c 18 Mar 2002 03:09:06 -0000 2.51 *************** *** 475,478 **** --- 475,480 ---- return NULL; } + if (type == NULL) + type = (PyObject *)(obj->ob_type); return PyMethod_New(cm->cm_callable, type, (PyObject *)(type->ob_type)); From gvanrossum@users.sourceforge.net Mon Mar 18 03:09:08 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sun, 17 Mar 2002 19:09:08 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.121,1.122 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv30809/Lib/test Modified Files: test_descr.py Log Message: Fix for SF bug 528132 (Armin Rigo): classmethod().__get__() segfault The proper fix is not quite what was submitted; it's really better to take the class of the object passed rather than calling PyMethod_New with NULL pointer args, because that can then cause other core dumps later. I also added a testcase for the fix to classmethods() in test_descr.py. I've already applied this to the 2.2 branch. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.121 retrieving revision 1.122 diff -C2 -d -r1.121 -r1.122 *** test_descr.py 14 Mar 2002 23:03:41 -0000 1.121 --- test_descr.py 18 Mar 2002 03:09:06 -0000 1.122 *************** *** 1209,1212 **** --- 1209,1217 ---- vereq(d.foo(1), (d, 1)) vereq(D.foo(d, 1), (d, 1)) + # Test for a specific crash (SF bug 528132) + def f(cls, arg): return (cls, arg) + ff = classmethod(f) + vereq(ff.__get__(0, int)(42), (int, 42)) + vereq(ff.__get__(0)(42), (int, 42)) def staticmethods(): From loewis@users.sourceforge.net Mon Mar 18 08:37:21 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Mon, 18 Mar 2002 00:37:21 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib urllib2.py,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv32346 Modified Files: urllib2.py Log Message: Patch #525870: Avoid duplicate stat calls, use st_ attributes. Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** urllib2.py 11 Feb 2002 20:46:10 -0000 1.25 --- urllib2.py 18 Mar 2002 08:37:19 -0000 1.26 *************** *** 103,107 **** import time import os - import stat import gopherlib import posixpath --- 103,106 ---- *************** *** 878,885 **** localfile = url2pathname(file) stats = os.stat(localfile) ! size = stats[stat.ST_SIZE] ! modified = rfc822.formatdate(stats[stat.ST_MTIME]) mtype = mimetypes.guess_type(file)[0] - stats = os.stat(localfile) headers = mimetools.Message(StringIO( 'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' % --- 877,883 ---- localfile = url2pathname(file) stats = os.stat(localfile) ! size = stats.st_size ! modified = rfc822.formatdate(stats.st_mtime) mtype = mimetypes.guess_type(file)[0] headers = mimetools.Message(StringIO( 'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' % From loewis@users.sourceforge.net Mon Mar 18 08:56:25 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Mon, 18 Mar 2002 00:56:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/faqwiz move-faqwiz.sh,NONE,1.1 README,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/faqwiz In directory usw-pr-cvs1:/tmp/cvs-serv6817 Modified Files: README Added Files: move-faqwiz.sh Log Message: Patch #512466: Script to move faqwiz entries. --- NEW FILE: move-faqwiz.sh --- #!/bin/sh # # Christian Reis # # Moves # # Example: # # blackjesus:~> ./move-faqwiz.sh 2\.1 3\.2 # Moving FAQ question 02.001 to 03.002 if [ x$2 == x ]; then echo "Need 2 args: original_version final_version." exit 2 fi if [ ! -d data -o ! -d data/RCS ]; then echo "Run this inside the faqwiz data/ directory's parent dir." exit 2 fi function cut_n_pad() { t=`echo $1 | cut -d. -f $2` export $3=`echo $t | awk "{ tmp = \\$0; l = length(tmp); for (i = 0; i < $2-l+1; i++) { tmp = "0".tmp } print tmp }"` } cut_n_pad $1 1 prefix1 cut_n_pad $1 2 suffix1 cut_n_pad $2 1 prefix2 cut_n_pad $2 2 suffix2 tmpfile=tmp$RANDOM.tmp file1=faq$prefix1.$suffix1.htp file2=faq$prefix2.$suffix2.htp echo "Moving FAQ question $prefix1.$suffix1 to $prefix2.$suffix2" sed -e "s/$1\./$2\./g" data/$file1 > ${tmpfile}1 sed -e "s/$1\./$2\./g" data/RCS/$file1,v > ${tmpfile}2 if [ -f data/$file2 ]; then echo "Target FAQ exists. Won't clobber." exit 2 fi mv ${tmpfile}1 data/$file2 mv ${tmpfile}2 data/RCS/$file2,v mv data/$file1 data/$file1.orig mv data/RCS/$file1,v data/RCS/$file1,v.orig Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/faqwiz/README,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** README 8 Apr 1998 21:37:13 -0000 1.12 --- README 18 Mar 2002 08:56:23 -0000 1.13 *************** *** 22,25 **** --- 22,26 ---- faqconf.py main configuration module faqcust.py additional local customization module (optional) + move-faqwiz.sh Script to move faqwiz entries. From loewis@users.sourceforge.net Mon Mar 18 10:41:23 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Mon, 18 Mar 2002 02:41:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib robotparser.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv4239 Modified Files: robotparser.py Log Message: Patch #499513: use readline() instead of readlines(). Removed the unnecessary redirection limit code which is already in FancyURLopener. Index: robotparser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/robotparser.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** robotparser.py 28 Feb 2002 15:24:47 -0000 1.11 --- robotparser.py 18 Mar 2002 10:41:20 -0000 1.12 *************** *** 5,9 **** You can choose between two licenses when using this package: 1) GNU GPLv2 ! 2) PYTHON 2.0 OPEN SOURCE LICENSE The robots.txt Exclusion Protocol is implemented as specified in --- 5,9 ---- You can choose between two licenses when using this package: 1) GNU GPLv2 ! 2) PSF license for Python 2.2 The robots.txt Exclusion Protocol is implemented as specified in *************** *** 43,47 **** opener = URLopener() f = opener.open(self.url) ! lines = f.readlines() self.errcode = opener.errcode if self.errcode == 401 or self.errcode == 403: --- 43,51 ---- opener = URLopener() f = opener.open(self.url) ! lines = [] ! line = f.readline() ! while line: ! lines.append(line.strip()) ! line = f.readline() self.errcode = opener.errcode if self.errcode == 401 or self.errcode == 403: *************** *** 64,68 **** for line in lines: - line = line.strip() linenumber = linenumber + 1 if not line: --- 68,71 ---- *************** *** 210,215 **** apply(urllib.FancyURLopener.__init__, (self,) + args) self.errcode = 200 - self.tries = 0 - self.maxtries = 10 def http_error_default(self, url, fp, errcode, errmsg, headers): --- 213,216 ---- *************** *** 217,231 **** return urllib.FancyURLopener.http_error_default(self, url, fp, errcode, errmsg, headers) - - def http_error_302(self, url, fp, errcode, errmsg, headers, data=None): - self.tries += 1 - if self.tries >= self.maxtries: - return self.http_error_default(url, fp, 500, - "Internal Server Error: Redirect Recursion", - headers) - result = urllib.FancyURLopener.http_error_302(self, url, fp, errcode, - errmsg, headers, data) - self.tries = 0 - return result def _check(a,b): --- 218,221 ---- From loewis@users.sourceforge.net Mon Mar 18 10:43:20 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Mon, 18 Mar 2002 02:43:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib robotparser.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv4930 Modified Files: robotparser.py Log Message: Correctly set default entry in all cases. Index: robotparser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/robotparser.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** robotparser.py 18 Mar 2002 10:41:20 -0000 1.12 --- robotparser.py 18 Mar 2002 10:43:18 -0000 1.13 *************** *** 59,62 **** --- 59,69 ---- self.parse(lines) + def _add_entry(self, entry): + if "*" in entry.useragents: + # the default entry is considered last + self.default_entry = entry + else: + self.entries.append(entry) + def parse(self, lines): """parse the input lines from a robot.txt file. *************** *** 77,85 **** state = 0 elif state==2: ! if "*" in entry.useragents: ! # the default entry is considered last ! self.default_entry = entry ! else: ! self.entries.append(entry) entry = Entry() state = 0 --- 84,88 ---- state = 0 elif state==2: ! self._add_entry(entry) entry = Entry() state = 0 *************** *** 100,104 **** " line before any user-agent" " directive" % linenumber) ! self.entries.append(entry) entry = Entry() entry.useragents.append(line[1]) --- 103,107 ---- " line before any user-agent" " directive" % linenumber) ! self._add_entry(entry) entry = Entry() entry.useragents.append(line[1]) From jackjansen@users.sourceforge.net Mon Mar 18 10:44:51 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 18 Mar 2002 02:44:51 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac Relnotes,1.28.4.2.2.1,1.28.4.2.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac In directory usw-pr-cvs1:/tmp/cvs-serv5345 Modified Files: Tag: release22-maint Relnotes Log Message: Finished 2.2.1 release notes. Index: Relnotes =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Relnotes,v retrieving revision 1.28.4.2.2.1 retrieving revision 1.28.4.2.2.2 diff -C2 -d -r1.28.4.2.2.1 -r1.28.4.2.2.2 *** Relnotes 6 Mar 2002 22:00:35 -0000 1.28.4.2.2.1 --- Relnotes 18 Mar 2002 10:44:49 -0000 1.28.4.2.2.2 *************** *** 3,12 **** These release notes refer to Mac-specific changes only. See NEWS (in the Misc folder) ! for machine-independent changes. - This release should work on multiprocessor OSX machines. - The problem with incomplete read()s on sockets has been fixed. - NavServices is now weaklinked, so this release should work on a virgin Mac OS 8.1. ! - Much more: to be supplied. Known problems --- 3,55 ---- These release notes refer to Mac-specific changes only. See NEWS (in the Misc folder) ! for machine-independent changes. These notes are meant primarily for MacPython ! but some of the information may be relevant to using Mac-specific features under ! Mac OS X unix Python (a.k.a. MachoPython) too. - This release should work on multiprocessor OSX machines. - The problem with incomplete read()s on sockets has been fixed. - NavServices is now weaklinked, so this release should work on a virgin Mac OS 8.1. ! - test_longexp took days to finish on OSX. It now fails with a message so the ! other tests continue. ! - The IDE looks better under OSX after redesign of some windows. ! - The IDE browser now has some understanding of the 2.2 object model. ! - IDE readline() output is echoed to the output window. ! - IDE output is flushed to the screen more often under OSX. ! - IDE doesn't have a second quit menu under OSX anymore. ! - IDE scrollbars now have live feedback. ! - IDE now does copy/paste under OSX. ! - IDE: minimal support for floating windows. ! - The IDE now sort-of works under MachoPython. ! - macostools.mkalias() can now handle folders. ! - macresource module fixed to work under MachoPython. ! - macfs.FSRef objects now have an as_pathname method. ! - The ic module returned bogus values for creator/type. Fixed. ! - Carbon.App: support for various missing methods added. ! - Carbon.CarbonEvt: various method signatures fixed. ! - Carbon.CF: Unicode support added. ! - Carbon.CG: did not import. Fixed. ! - Carbon.CG: various missing methods added. ! - Carbon.Ctl: ControlActionProcs weren't supported. Fixed. ! - Carbon.Drag: exceptions in callback routines are now printed. ! - Carbon.Fm: QDTextBounds was missing. Added. ! - Carbon.Menu: support for optional MenuObjs was added. ! - Carbon.Mlte: unicode support added. ! - Carbon.Scrap: fixed to work under Carbon by finally implementing the ! Carbon Scrap Manager interface. ! - Carbon.Snd: SndRecord and SndRecordToFile were missing. Added. ! - Applescript suites had a problem with the required events being in either Standard ! or Required. Fixed by introducing a new common base suite for them. ! - Applescript example rewritten. ! - Applescript can now handle Unicode parameters. ! - An Applescript suite with a start() event no longer causes problems. ! - Exceptions in AE callback routines are now printed. ! - waste: updated to current version, thereby getting it to work under MachoPython. ! - gensuitemodule: better handling of verbs that are Python keywords. ! - gensuitemodule: enum values are now identify()d. ! - MachoPython: Python.app build process fixed. ! - MachoPython: Python.app can now be called from the command line. ! - MachoPython: MacOS error exceptions now include the textual error in ! stead of only the numeric error code. ! - Embedding: don't call PyMac_OutputSeen if we have a custom console. Known problems From mwh@users.sourceforge.net Mon Mar 18 12:43:35 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 18 Mar 2002 04:43:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.124.6.4,2.124.6.5 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv7635 Modified Files: Tag: release22-maint unicodeobject.c Log Message: Fix [ 531306 ] ucs4 build horked. Classic C mistake, I think. Also squashed a couple of warnings in the ucs4 build. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.124.6.4 retrieving revision 2.124.6.5 diff -C2 -d -r2.124.6.4 -r2.124.6.5 *** unicodeobject.c 13 Mar 2002 23:56:48 -0000 2.124.6.4 --- unicodeobject.c 18 Mar 2002 12:43:33 -0000 2.124.6.5 *************** *** 1208,1211 **** --- 1208,1212 ---- goto onError; p = PyString_AS_STRING(v) + (p - q); + q = PyString_AS_STRING(v); } *************** *** 1233,1236 **** --- 1234,1238 ---- goto onError; p = PyString_AS_STRING(v) + (p - q); + q = PyString_AS_STRING(v); } *************** *** 1247,1251 **** onError: ! Py_DECREF(v); return NULL; } --- 1249,1253 ---- onError: ! Py_XDECREF(v); return NULL; } *************** *** 5526,5535 **** default: ! PyErr_Format(PyExc_ValueError, ! "unsupported format character '%c' (0x%x) " ! "at index %i", ! (31<=c && c<=126) ? c : '?', ! c, fmt -1 - PyUnicode_AS_UNICODE(uformat)); ! goto onError; } if (sign) { --- 5528,5537 ---- default: ! PyErr_Format(PyExc_ValueError, ! "unsupported format character '%c' (0x%x) " ! "at index %i", ! (31<=c && c<=126) ? (int)c : '?', ! (int)c, (fmt -1 - PyUnicode_AS_UNICODE(uformat))); ! goto onError; } if (sign) { From loewis@users.sourceforge.net Mon Mar 18 12:44:10 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Mon, 18 Mar 2002 04:44:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcompileall.tex,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv8132/Doc/lib Modified Files: libcompileall.tex Log Message: Patch #495598: add an -q (quiet) option to pycompile. Index: libcompileall.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcompileall.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** libcompileall.tex 3 Apr 2000 20:13:53 -0000 1.2 --- libcompileall.tex 18 Mar 2002 12:44:08 -0000 1.3 *************** *** 18,22 **** \begin{funcdesc}{compile_dir}{dir\optional{, maxlevels\optional{, ! ddir\optional{, force}}}} Recursively descend the directory tree named by \var{dir}, compiling all \file{.py} files along the way. The \var{maxlevels} parameter --- 18,23 ---- \begin{funcdesc}{compile_dir}{dir\optional{, maxlevels\optional{, ! ddir\optional{, force\optional{, ! rx\optional{, quiet}}}}}} Recursively descend the directory tree named by \var{dir}, compiling all \file{.py} files along the way. The \var{maxlevels} parameter *************** *** 25,29 **** which the filenames used in error messages will be generated. If \var{force} is true, modules are re-compiled even if the timestamps ! are up to date. \end{funcdesc} --- 26,37 ---- which the filenames used in error messages will be generated. If \var{force} is true, modules are re-compiled even if the timestamps ! are up to date. ! ! If \var{rx} is given, it specifies a regular expression of file ! names to exclude from the search; that expression is searched for in ! the full path. ! ! If \var{quiet} is true, nothing is printed to the standard output ! in normal operation. \end{funcdesc} From loewis@users.sourceforge.net Mon Mar 18 12:44:10 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Mon, 18 Mar 2002 04:44:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib compileall.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv8132/Lib Modified Files: compileall.py Log Message: Patch #495598: add an -q (quiet) option to pycompile. Index: compileall.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compileall.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** compileall.py 18 Apr 2001 01:20:21 -0000 1.9 --- compileall.py 18 Mar 2002 12:44:08 -0000 1.10 *************** *** 20,24 **** __all__ = ["compile_dir","compile_path"] ! def compile_dir(dir, maxlevels=10, ddir=None, force=0, rx=None): """Byte-compile all modules in the given directory tree. --- 20,25 ---- __all__ = ["compile_dir","compile_path"] ! def compile_dir(dir, maxlevels=10, ddir=None, ! force=0, rx=None, quiet=0): """Byte-compile all modules in the given directory tree. *************** *** 30,36 **** directory name that will show up in error messages) force: if 1, force compilation, even if timestamps are up-to-date """ ! print 'Listing', dir, '...' try: names = os.listdir(dir) --- 31,39 ---- directory name that will show up in error messages) force: if 1, force compilation, even if timestamps are up-to-date + quiet: if 1, be quiet during compilation """ ! if not quiet: ! print 'Listing', dir, '...' try: names = os.listdir(dir) *************** *** 58,62 **** except os.error: ctime = 0 if (ctime > ftime) and not force: continue ! print 'Compiling', fullname, '...' try: ok = py_compile.compile(fullname, None, dfile) --- 61,66 ---- except os.error: ctime = 0 if (ctime > ftime) and not force: continue ! if not quiet: ! print 'Compiling', fullname, '...' try: ok = py_compile.compile(fullname, None, dfile) *************** *** 78,86 **** os.path.isdir(fullname) and \ not os.path.islink(fullname): ! if not compile_dir(fullname, maxlevels - 1, dfile, force, rx): success = 0 return success ! def compile_path(skip_curdir=1, maxlevels=0, force=0): """Byte-compile all module on sys.path. --- 82,90 ---- os.path.isdir(fullname) and \ not os.path.islink(fullname): ! if not compile_dir(fullname, maxlevels - 1, dfile, force, rx, quiet): success = 0 return success ! def compile_path(skip_curdir=1, maxlevels=0, force=0, quiet=0): """Byte-compile all module on sys.path. *************** *** 90,93 **** --- 94,98 ---- maxlevels: max recursion level (default 0) force: as for compile_dir() (default 0) + quiet: as for compile_dir() (default 0) """ *************** *** 97,101 **** print 'Skipping current directory' else: ! success = success and compile_dir(dir, maxlevels, None, force) return success --- 102,107 ---- print 'Skipping current directory' else: ! success = success and compile_dir(dir, maxlevels, None, ! force, quiet=quiet) return success *************** *** 104,114 **** import getopt try: ! opts, args = getopt.getopt(sys.argv[1:], 'lfd:x:') except getopt.error, msg: print msg ! print "usage: python compileall.py [-l] [-f] [-d destdir] " \ "[-s regexp] [directory ...]" print "-l: don't recurse down" print "-f: force rebuild even if timestamps are up-to-date" print "-d destdir: purported directory name for error messages" print " if no directory arguments, -l sys.path is assumed" --- 110,121 ---- import getopt try: ! opts, args = getopt.getopt(sys.argv[1:], 'lfqd:x:') except getopt.error, msg: print msg ! print "usage: python compileall.py [-l] [-f] [-q] [-d destdir] " \ "[-s regexp] [directory ...]" print "-l: don't recurse down" print "-f: force rebuild even if timestamps are up-to-date" + print "-q: quiet operation" print "-d destdir: purported directory name for error messages" print " if no directory arguments, -l sys.path is assumed" *************** *** 119,122 **** --- 126,130 ---- ddir = None force = 0 + quiet = 0 rx = None for o, a in opts: *************** *** 124,127 **** --- 132,136 ---- if o == '-d': ddir = a if o == '-f': force = 1 + if o == '-q': quiet = 1 if o == '-x': import re *************** *** 135,139 **** if args: for dir in args: ! if not compile_dir(dir, maxlevels, ddir, force, rx): success = 0 else: --- 144,149 ---- if args: for dir in args: ! if not compile_dir(dir, maxlevels, ddir, ! force, rx, quiet): success = 0 else: From loewis@users.sourceforge.net Mon Mar 18 12:44:10 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Mon, 18 Mar 2002 04:44:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.364,1.365 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv8132/Misc Modified Files: NEWS Log Message: Patch #495598: add an -q (quiet) option to pycompile. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.364 retrieving revision 1.365 diff -C2 -d -r1.364 -r1.365 *** NEWS 17 Mar 2002 18:37:22 -0000 1.364 --- NEWS 18 Mar 2002 12:44:08 -0000 1.365 *************** *** 45,48 **** --- 45,50 ---- Library + - compileall now supports quiet operation. + - The BaseHTTPServer implements now optionally HTTP/1.1 persistent connections. From mwh@users.sourceforge.net Mon Mar 18 12:47:54 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 18 Mar 2002 04:47:54 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.124.6.5,2.124.6.6 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv9222 Modified Files: Tag: release22-maint unicodeobject.c Log Message: Martin's fix for [ 529104 ] broken error handling in unicode-escape I presume this will need to be fixed on the trunk, too. Later. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.124.6.5 retrieving revision 2.124.6.6 diff -C2 -d -r2.124.6.5 -r2.124.6.6 *** unicodeobject.c 18 Mar 2002 12:43:33 -0000 2.124.6.5 --- unicodeobject.c 18 Mar 2002 12:47:52 -0000 2.124.6.6 *************** *** 1508,1513 **** static ! int unicodeescape_decoding_error(const char **source, ! Py_UNICODE *x, const char *errors, const char *details) --- 1508,1512 ---- static ! int unicodeescape_decoding_error(Py_UNICODE **x, const char *errors, const char *details) *************** *** 1524,1528 **** } else if (strcmp(errors,"replace") == 0) { ! *x = Py_UNICODE_REPLACEMENT_CHARACTER; return 0; } --- 1523,1528 ---- } else if (strcmp(errors,"replace") == 0) { ! **x = Py_UNICODE_REPLACEMENT_CHARACTER; ! (*x)++; return 0; } *************** *** 1622,1628 **** c = (unsigned char) s[i]; if (!isxdigit(c)) { ! if (unicodeescape_decoding_error(&s, &x, errors, message)) goto onError; ! chr = x; i++; break; --- 1622,1628 ---- c = (unsigned char) s[i]; if (!isxdigit(c)) { ! if (unicodeescape_decoding_error(&p, errors, message)) goto onError; ! chr = 0xffffffff; i++; break; *************** *** 1637,1640 **** --- 1637,1644 ---- } s += i; + if (chr == 0xffffffff) + /* _decoding_error will have already written into the + target buffer. */ + break; store: /* when we get here, chr is a 32-bit unicode character */ *************** *** 1654,1662 **** } else { if (unicodeescape_decoding_error( ! &s, &x, errors, "illegal Unicode character") ) goto onError; - *p++ = x; /* store replacement character */ } break; --- 1658,1665 ---- } else { if (unicodeescape_decoding_error( ! &p, errors, "illegal Unicode character") ) goto onError; } break; *************** *** 1693,1704 **** } } ! if (unicodeescape_decoding_error(&s, &x, errors, message)) goto onError; - *p++ = x; break; default: ! *p++ = '\\'; ! *p++ = (unsigned char)s[-1]; break; } --- 1696,1712 ---- } } ! if (unicodeescape_decoding_error(&p, errors, message)) goto onError; break; default: ! if (s > end) { ! if (unicodeescape_decoding_error(&p, errors, "\\ at end of string")) ! goto onError; ! } ! else { ! *p++ = '\\'; ! *p++ = (unsigned char)s[-1]; ! } break; } *************** *** 1903,1907 **** while (s < end) { unsigned char c; ! Py_UNICODE x; int i; --- 1911,1915 ---- while (s < end) { unsigned char c; ! Py_UCS4 x; int i; *************** *** 1932,1938 **** c = (unsigned char)s[i]; if (!isxdigit(c)) { ! if (unicodeescape_decoding_error(&s, &x, errors, "truncated \\uXXXX")) goto onError; i++; break; --- 1940,1947 ---- c = (unsigned char)s[i]; if (!isxdigit(c)) { ! if (unicodeescape_decoding_error(&p, errors, "truncated \\uXXXX")) goto onError; + x = 0xffffffff; i++; break; *************** *** 1947,1951 **** } s += i; ! *p++ = x; } if (_PyUnicode_Resize(&v, (int)(p - buf))) --- 1956,1961 ---- } s += i; ! if (x != 0xffffffff) ! *p++ = x; } if (_PyUnicode_Resize(&v, (int)(p - buf))) From mwh@users.sourceforge.net Mon Mar 18 12:54:53 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 18 Mar 2002 04:54:53 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.47,1.47.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv11778 Modified Files: Tag: release22-maint test_unicode.py Log Message: doerwalter's failing examples from [ 529104 ] broken error handling in unicode-escape Index: test_unicode.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.47 retrieving revision 1.47.6.1 diff -C2 -d -r1.47 -r1.47.6.1 *** test_unicode.py 10 Dec 2001 20:57:34 -0000 1.47 --- test_unicode.py 18 Mar 2002 12:54:51 -0000 1.47.6.1 *************** *** 540,543 **** --- 540,551 ---- verify(unicode('Andr\202 x','ascii','replace') == u'Andr\uFFFD x') + verify("\\N{foo}xx".decode("unicode-escape", "ignore") == u"xx") + try: + "\\".decode("unicode-escape") + except ValueError: + pass + else: + raise TestFailed, '"\\".decode("unicode-escape") should fail' + verify(u'hello'.encode('ascii') == 'hello') verify(u'hello'.encode('utf-7') == 'hello') From mwh@users.sourceforge.net Mon Mar 18 12:59:40 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 18 Mar 2002 04:59:40 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules sre.h,2.21,2.21.16.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv13056 Modified Files: Tag: release22-maint sre.h Log Message: Remove extraneous #define as per effbot's instructions in: [ 530285 ] redefining SRE_CODE in Modules/sre.h Another one for the trunk, later. Index: sre.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre.h,v retrieving revision 2.21 retrieving revision 2.21.16.1 diff -C2 -d -r2.21 -r2.21.16.1 *** sre.h 2 Jul 2001 16:42:49 -0000 2.21 --- sre.h 18 Mar 2002 12:59:38 -0000 2.21.16.1 *************** *** 22,27 **** #endif - #define SRE_CODE unsigned short - typedef struct { PyObject_VAR_HEAD --- 22,25 ---- From mwh@users.sourceforge.net Mon Mar 18 13:03:42 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 18 Mar 2002 05:03:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib urlparse.py,1.31,1.31.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv14588 Modified Files: Tag: release22-maint urlparse.py Log Message: amk's fix attached to [ 516299 ] urlparse can get fragments wrong Index: urlparse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urlparse.py,v retrieving revision 1.31 retrieving revision 1.31.6.1 diff -C2 -d -r1.31 -r1.31.6.1 *** urlparse.py 16 Nov 2001 02:52:57 -0000 1.31 --- urlparse.py 18 Mar 2002 13:03:40 -0000 1.31.6.1 *************** *** 88,92 **** i = url.find('/', 2) if i < 0: ! i = len(url) netloc = url[2:i] url = url[i:] --- 88,94 ---- i = url.find('/', 2) if i < 0: ! i = url.find('#') ! if i < 0: ! i = len(url) netloc = url[2:i] url = url[i:] From mwh@users.sourceforge.net Mon Mar 18 13:03:42 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 18 Mar 2002 05:03:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_urlparse.py,1.2,1.2.24.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv14588/test Modified Files: Tag: release22-maint test_urlparse.py Log Message: amk's fix attached to [ 516299 ] urlparse can get fragments wrong Index: test_urlparse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_urlparse.py,v retrieving revision 1.2 retrieving revision 1.2.24.1 diff -C2 -d -r1.2 -r1.2.24.1 *** test_urlparse.py 5 Jan 2001 05:57:04 -0000 1.2 --- test_urlparse.py 18 Mar 2002 13:03:40 -0000 1.2.24.1 *************** *** 5,8 **** --- 5,26 ---- RFC1808_BASE = "http://a/b/c/d;p?q#f" + for url, expected in [('http://www.python.org', + ('http', 'www.python.org', '', '', '', '')), + ('http://www.python.org#abc', + ('http', 'www.python.org', '', '', '', 'abc')), + ('http://www.python.org/#abc', + ('http', 'www.python.org', '/', '', '', 'abc')), + (RFC1808_BASE, + ('http', 'a', '/b/c/d', 'p', 'q', 'f')), + ]: + result = urlparse.urlparse(url) + print "%-13s = %r" % (url, result) + if result != expected: + errors += 1 + print "urlparse(%r)" % url + print ("expected %r,\n" + " got %r") % (expected, result) + print + def checkJoin(relurl, expected): global errors From mwh@users.sourceforge.net Mon Mar 18 13:03:42 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 18 Mar 2002 05:03:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_urlparse,1.2,1.2.24.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv14588/test/output Modified Files: Tag: release22-maint test_urlparse Log Message: amk's fix attached to [ 516299 ] urlparse can get fragments wrong Index: test_urlparse =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_urlparse,v retrieving revision 1.2 retrieving revision 1.2.24.1 diff -C2 -d -r1.2 -r1.2.24.1 *** test_urlparse 5 Jan 2001 05:57:04 -0000 1.2 --- test_urlparse 18 Mar 2002 13:03:40 -0000 1.2.24.1 *************** *** 1,3 **** --- 1,8 ---- test_urlparse + http://www.python.org = ('http', 'www.python.org', '', '', '', '') + http://www.python.org#abc = ('http', 'www.python.org', '', '', '', 'abc') + http://www.python.org/#abc = ('http', 'www.python.org', '/', '', '', 'abc') + http://a/b/c/d;p?q#f = ('http', 'a', '/b/c/d', 'p', 'q', 'f') + urlparse.urljoin() tests From mwh@users.sourceforge.net Mon Mar 18 13:06:02 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 18 Mar 2002 05:06:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib urlparse.py,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv15395 Modified Files: urlparse.py Log Message: amk's fix attached to [ 516299 ] urlparse can get fragments wrong Index: urlparse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urlparse.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** urlparse.py 16 Nov 2001 02:52:57 -0000 1.31 --- urlparse.py 18 Mar 2002 13:06:00 -0000 1.32 *************** *** 88,92 **** i = url.find('/', 2) if i < 0: ! i = len(url) netloc = url[2:i] url = url[i:] --- 88,94 ---- i = url.find('/', 2) if i < 0: ! i = url.find('#') ! if i < 0: ! i = len(url) netloc = url[2:i] url = url[i:] From mwh@users.sourceforge.net Mon Mar 18 13:06:02 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 18 Mar 2002 05:06:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_urlparse,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv15395/test/output Modified Files: test_urlparse Log Message: amk's fix attached to [ 516299 ] urlparse can get fragments wrong Index: test_urlparse =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_urlparse,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_urlparse 5 Jan 2001 05:57:04 -0000 1.2 --- test_urlparse 18 Mar 2002 13:06:00 -0000 1.3 *************** *** 1,3 **** --- 1,8 ---- test_urlparse + http://www.python.org = ('http', 'www.python.org', '', '', '', '') + http://www.python.org#abc = ('http', 'www.python.org', '', '', '', 'abc') + http://www.python.org/#abc = ('http', 'www.python.org', '/', '', '', 'abc') + http://a/b/c/d;p?q#f = ('http', 'a', '/b/c/d', 'p', 'q', 'f') + urlparse.urljoin() tests From mwh@users.sourceforge.net Mon Mar 18 13:06:02 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 18 Mar 2002 05:06:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_urlparse.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv15395/test Modified Files: test_urlparse.py Log Message: amk's fix attached to [ 516299 ] urlparse can get fragments wrong Index: test_urlparse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_urlparse.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_urlparse.py 5 Jan 2001 05:57:04 -0000 1.2 --- test_urlparse.py 18 Mar 2002 13:06:00 -0000 1.3 *************** *** 5,8 **** --- 5,26 ---- RFC1808_BASE = "http://a/b/c/d;p?q#f" + for url, expected in [('http://www.python.org', + ('http', 'www.python.org', '', '', '', '')), + ('http://www.python.org#abc', + ('http', 'www.python.org', '', '', '', 'abc')), + ('http://www.python.org/#abc', + ('http', 'www.python.org', '/', '', '', 'abc')), + (RFC1808_BASE, + ('http', 'a', '/b/c/d', 'p', 'q', 'f')), + ]: + result = urlparse.urlparse(url) + print "%-13s = %r" % (url, result) + if result != expected: + errors += 1 + print "urlparse(%r)" % url + print ("expected %r,\n" + " got %r") % (expected, result) + print + def checkJoin(relurl, expected): global errors From mwh@users.sourceforge.net Mon Mar 18 13:10:15 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 18 Mar 2002 05:10:15 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-irix6 regen,1.2,1.2.16.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-irix6 In directory usw-pr-cvs1:/tmp/cvs-serv16834 Modified Files: Tag: release22-maint regen Log Message: backport jackjansen's checkin of revision 1.3 of regen Patch by Michael Pruett: make regen work on Irix 6.0 and 6.5. Index: regen =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/regen,v retrieving revision 1.2 retrieving revision 1.2.16.1 diff -C2 -d -r1.2 -r1.2.16.1 *** regen 31 Jul 2001 08:47:55 -0000 1.2 --- regen 18 Mar 2002 13:10:13 -0000 1.2.16.1 *************** *** 1,5 **** #! /bin/sh case `uname -sr` in ! 'IRIX '[45].*) ;; *) echo Probably not on an IRIX system 1>&2 exit 1;; --- 1,6 ---- #! /bin/sh case `uname -sr` in ! 'IRIX '[456].*) ;; ! 'IRIX64 '[456].*) ;; *) echo Probably not on an IRIX system 1>&2 exit 1;; From mwh@users.sourceforge.net Mon Mar 18 13:10:44 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 18 Mar 2002 05:10:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-irix6 ERRNO.py,1.1,1.1.30.1 FILE.py,1.1,1.1.30.1 IN.py,1.1,1.1.30.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-irix6 In directory usw-pr-cvs1:/tmp/cvs-serv16997 Modified Files: Tag: release22-maint ERRNO.py FILE.py IN.py Log Message: backport jackjansen's checkin of revision 1.2 of ERRNO.py revision 1.2 of FILE.py revision 1.2 of IN.py Regenerated for Irix 6.5. Index: ERRNO.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/ERRNO.py,v retrieving revision 1.1 retrieving revision 1.1.30.1 diff -C2 -d -r1.1 -r1.1.30.1 *** ERRNO.py 15 Jan 1997 19:18:37 -0000 1.1 --- ERRNO.py 18 Mar 2002 13:10:41 -0000 1.1.30.1 *************** *** 1,7 **** ! # Generated by h2py from /usr/include/sys/errno.h # Included from standards.h __KBASE = 1000 __IRIXBASE = 1000 EPERM = 1 ENOENT = 2 --- 1,11 ---- ! # Generated by h2py from /usr/include/errno.h ! ! # Included from sys/errno.h # Included from standards.h __KBASE = 1000 __IRIXBASE = 1000 + __FTNBASE = 4000 + __FTNLAST = 5999 EPERM = 1 ENOENT = 2 *************** *** 50,53 **** --- 54,58 ---- EDEADLK = 45 ENOLCK = 46 + ECKPT = 47 EBADE = 50 EBADR = 51 *************** *** 139,143 **** --- 144,150 ---- ENOTSUP = 1008 ENOATTR = 1009 + EFSCORRUPTED = 1010 EDIRCORRUPTED = 1010 + EWRONGFS = 1011 EDQUOT = 1133 ENFSREMOTE = 1135 *************** *** 162,163 **** --- 169,180 ---- EINVALTIME = 1318 EDESTROYED = 1319 + EBDHDL = 1400 + EDELAY = 1401 + ENOBWD = 1402 + EBADRSPEC = 1403 + EBADTSPEC = 1404 + EBADFILT = 1405 + EMIGRATED = 1500 + EMIGRATING = 1501 + ECELLDOWN = 1502 + EMEMRETRY = 1600 Index: FILE.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/FILE.py,v retrieving revision 1.1 retrieving revision 1.1.30.1 diff -C2 -d -r1.1 -r1.1.30.1 *** FILE.py 15 Jan 1997 19:18:40 -0000 1.1 --- FILE.py 18 Mar 2002 13:10:41 -0000 1.1.30.1 *************** *** 13,16 **** --- 13,18 ---- _MIPS_SIM_NABI32 = 2 _MIPS_SIM_ABI64 = 3 + + # Included from sys/pthread.h P_MYID = (-1) P_MYHOSTID = (-1) *************** *** 30,33 **** --- 32,37 ---- NEWDEV = 1 MKDEV_VER = NEWDEV + def IS_STRING_SPEC_DEV(x): return ((dev_t)(x)==__makedev(MKDEV_VER, 0, 0)) + def major(dev): return __major(MKDEV_VER, dev) *************** *** 43,55 **** NBBY = 8 # Included from sys/sema.h MUTEX_DEFAULT = 0x0 ! METER_NAMSZ = 8 def mutex_spinlock(l): return splhi() def mutex_spintrylock(l): return splhi() - def spinlock_islocked(l): return issplhi(getsr()) - def spinlock_initialized(l): return 1 --- 47,476 ---- NBBY = 8 + # Included from sys/cpumask.h + MAXCPU = 128 + def CPUMASK_INDEX(bit): return ((bit) >> 6) + + def CPUMASK_SHFT(bit): return ((bit) & 0x3f) + + def CPUMASK_IS_ZERO(p): return ((p) == 0) + + def CPUMASK_IS_NONZERO(p): return ((p) != 0) + + + # Included from sys/nodemask.h + def CNODEMASK_IS_ZERO(p): return ((p) == 0) + + def CNODEMASK_IS_NONZERO(p): return ((p) != 0) + + # Included from sys/sema.h + + # Included from sys/timespec.h + + # Included from sys/param.h + + # Included from sys/signal.h + SIGHUP = 1 + SIGINT = 2 + SIGQUIT = 3 + SIGILL = 4 + SIGTRAP = 5 + SIGIOT = 6 + SIGABRT = 6 + SIGEMT = 7 + SIGFPE = 8 + SIGKILL = 9 + SIGBUS = 10 + SIGSEGV = 11 + SIGSYS = 12 + SIGPIPE = 13 + SIGALRM = 14 + SIGTERM = 15 + SIGUSR1 = 16 + SIGUSR2 = 17 + SIGCLD = 18 + SIGCHLD = 18 + SIGPWR = 19 + SIGWINCH = 20 + SIGURG = 21 + SIGPOLL = 22 + SIGIO = 22 + SIGSTOP = 23 + SIGTSTP = 24 + SIGCONT = 25 + SIGTTIN = 26 + SIGTTOU = 27 + SIGVTALRM = 28 + SIGPROF = 29 + SIGXCPU = 30 + SIGXFSZ = 31 + SIGK32 = 32 + SIGCKPT = 33 + SIGRESTART = 34 + SIGUME = 35 + SIGPTINTR = 47 + SIGPTRESCHED = 48 + SIGRTMIN = 49 + SIGRTMAX = 64 + __sigargs = int + + # Included from sys/sigevent.h + SIGEV_NONE = 128 + SIGEV_SIGNAL = 129 + SIGEV_CALLBACK = 130 + SIGEV_THREAD = 131 + + # Included from sys/siginfo.h + SI_MAXSZ = 128 + SI_USER = 0 + SI_KILL = SI_USER + SI_QUEUE = -1 + SI_ASYNCIO = -2 + SI_TIMER = -3 + SI_MESGQ = -4 + ILL_ILLOPC = 1 + ILL_ILLOPN = 2 + ILL_ILLADR = 3 + ILL_ILLTRP = 4 + ILL_PRVOPC = 5 + ILL_PRVREG = 6 + ILL_COPROC = 7 + ILL_BADSTK = 8 + NSIGILL = 8 + FPE_INTDIV = 1 + FPE_INTOVF = 2 + FPE_FLTDIV = 3 + FPE_FLTOVF = 4 + FPE_FLTUND = 5 + FPE_FLTRES = 6 + FPE_FLTINV = 7 + FPE_FLTSUB = 8 + NSIGFPE = 8 + SEGV_MAPERR = 1 + SEGV_ACCERR = 2 + NSIGSEGV = 2 + BUS_ADRALN = 1 + BUS_ADRERR = 2 + BUS_OBJERR = 3 + NSIGBUS = 3 + TRAP_BRKPT = 1 + TRAP_TRACE = 2 + NSIGTRAP = 2 + CLD_EXITED = 1 + CLD_KILLED = 2 + CLD_DUMPED = 3 + CLD_TRAPPED = 4 + CLD_STOPPED = 5 + CLD_CONTINUED = 6 + NSIGCLD = 6 + POLL_IN = 1 + POLL_OUT = 2 + POLL_MSG = 3 + POLL_ERR = 4 + POLL_PRI = 5 + POLL_HUP = 6 + NSIGPOLL = 6 + UME_ECCERR = 1 + NSIGUME = 1 + SIG_NOP = 0 + SIG_BLOCK = 1 + SIG_UNBLOCK = 2 + SIG_SETMASK = 3 + SIG_SETMASK32 = 256 + SA_ONSTACK = 0x00000001 + SA_RESETHAND = 0x00000002 + SA_RESTART = 0x00000004 + SA_SIGINFO = 0x00000008 + SA_NODEFER = 0x00000010 + SA_NOCLDWAIT = 0x00010000 + SA_NOCLDSTOP = 0x00020000 + _SA_BSDCALL = 0x10000000 + MINSIGSTKSZ = 512 + SIGSTKSZ = 8192 + SS_ONSTACK = 0x00000001 + SS_DISABLE = 0x00000002 + + # Included from sys/ucontext.h + NGREG = 36 + NGREG = 37 + GETCONTEXT = 0 + SETCONTEXT = 1 + UC_SIGMASK = 001 + UC_STACK = 002 + UC_CPU = 004 + UC_MAU = 010 + UC_MCONTEXT = (UC_CPU|UC_MAU) + UC_ALL = (UC_SIGMASK|UC_STACK|UC_MCONTEXT) + CTX_R0 = 0 + CTX_AT = 1 + CTX_V0 = 2 + CTX_V1 = 3 + CTX_A0 = 4 + CTX_A1 = 5 + CTX_A2 = 6 + CTX_A3 = 7 + CTX_T0 = 8 + CTX_T1 = 9 + CTX_T2 = 10 + CTX_T3 = 11 + CTX_T4 = 12 + CTX_T5 = 13 + CTX_T6 = 14 + CTX_T7 = 15 + CTX_A4 = 8 + CTX_A5 = 9 + CTX_A6 = 10 + CTX_A7 = 11 + CTX_T0 = 12 + CTX_T1 = 13 + CTX_T2 = 14 + CTX_T3 = 15 + CTX_S0 = 16 + CTX_S1 = 17 + CTX_S2 = 18 + CTX_S3 = 19 + CTX_S4 = 20 + CTX_S5 = 21 + CTX_S6 = 22 + CTX_S7 = 23 + CTX_T8 = 24 + CTX_T9 = 25 + CTX_K0 = 26 + CTX_K1 = 27 + CTX_GP = 28 + CTX_SP = 29 + CTX_S8 = 30 + CTX_RA = 31 + CTX_MDLO = 32 + CTX_MDHI = 33 + CTX_CAUSE = 34 + CTX_EPC = 35 + CTX_SR = 36 + CXT_R0 = CTX_R0 + CXT_AT = CTX_AT + CXT_V0 = CTX_V0 + CXT_V1 = CTX_V1 + CXT_A0 = CTX_A0 + CXT_A1 = CTX_A1 + CXT_A2 = CTX_A2 + CXT_A3 = CTX_A3 + CXT_T0 = CTX_T0 + CXT_T1 = CTX_T1 + CXT_T2 = CTX_T2 + CXT_T3 = CTX_T3 + CXT_T4 = CTX_T4 + CXT_T5 = CTX_T5 + CXT_T6 = CTX_T6 + CXT_T7 = CTX_T7 + CXT_S0 = CTX_S0 + CXT_S1 = CTX_S1 + CXT_S2 = CTX_S2 + CXT_S3 = CTX_S3 + CXT_S4 = CTX_S4 + CXT_S5 = CTX_S5 + CXT_S6 = CTX_S6 + CXT_S7 = CTX_S7 + CXT_T8 = CTX_T8 + CXT_T9 = CTX_T9 + CXT_K0 = CTX_K0 + CXT_K1 = CTX_K1 + CXT_GP = CTX_GP + CXT_SP = CTX_SP + CXT_S8 = CTX_S8 + CXT_RA = CTX_RA + CXT_MDLO = CTX_MDLO + CXT_MDHI = CTX_MDHI + CXT_CAUSE = CTX_CAUSE + CXT_EPC = CTX_EPC + CXT_SR = CTX_SR + CTX_FV0 = 0 + CTX_FV1 = 2 + CTX_FA0 = 12 + CTX_FA1 = 13 + CTX_FA2 = 14 + CTX_FA3 = 15 + CTX_FA4 = 16 + CTX_FA5 = 17 + CTX_FA6 = 18 + CTX_FA7 = 19 + CTX_FT0 = 4 + CTX_FT1 = 5 + CTX_FT2 = 6 + CTX_FT3 = 7 + CTX_FT4 = 8 + CTX_FT5 = 9 + CTX_FT6 = 10 + CTX_FT7 = 11 + CTX_FT8 = 20 + CTX_FT9 = 21 + CTX_FT10 = 22 + CTX_FT11 = 23 + CTX_FT12 = 1 + CTX_FT13 = 3 + CTX_FS0 = 24 + CTX_FS1 = 25 + CTX_FS2 = 26 + CTX_FS3 = 27 + CTX_FS4 = 28 + CTX_FS5 = 29 + CTX_FS6 = 30 + CTX_FS7 = 31 + CTX_FT8 = 21 + CTX_FT9 = 23 + CTX_FT10 = 25 + CTX_FT11 = 27 + CTX_FT12 = 29 + CTX_FT13 = 31 + CTX_FT14 = 1 + CTX_FT15 = 3 + CTX_FS0 = 20 + CTX_FS1 = 22 + CTX_FS2 = 24 + CTX_FS3 = 26 + CTX_FS4 = 28 + CTX_FS5 = 30 + SV_ONSTACK = 0x0001 + SV_INTERRUPT = 0x0002 + NUMBSDSIGS = (32) + def sigmask(sig): return (1L << ((sig)-1)) + + def sigmask(sig): return (1L << ((sig)-1)) + + SIG_ERR = (-1) + SIG_IGN = (1) + SIG_HOLD = (2) + SIG_DFL = (0) + NSIG = 65 + MAXSIG = (NSIG-1) + NUMSIGS = (NSIG-1) + BRK_USERBP = 0 + BRK_KERNELBP = 1 + BRK_ABORT = 2 + BRK_BD_TAKEN = 3 + BRK_BD_NOTTAKEN = 4 + BRK_SSTEPBP = 5 + BRK_OVERFLOW = 6 + BRK_DIVZERO = 7 + BRK_RANGE = 8 + BRK_PSEUDO_OP_BIT = 0x80 + BRK_PSEUDO_OP_MAX = 0x3 + BRK_CACHE_SYNC = 0x80 + BRK_MULOVF = 1023 + _POSIX_VERSION = 199506L + _POSIX_VERSION = 199506 + _POSIX_VDISABLE = 0 + MAX_INPUT = 512 + MAX_CANON = 256 + UID_NOBODY = 60001 + GID_NOBODY = UID_NOBODY + UID_NOACCESS = 60002 + MAXPID = 0x7ffffff0 + MAXUID = 0x7fffffff + MAXLINK = 30000 + SSIZE = 1 + SINCR = 1 + KSTKSIZE = 1 + EXTKSTKSIZE = 1 + KSTKIDX = 0 + KSTEIDX = 1 + EXTKSTKSIZE = 0 + KSTKIDX = 0 + CANBSIZ = 256 + HZ = 100 + TICK = 10000000 + NOFILE = 20 + NGROUPS_UMIN = 0 + NGROUPS_UMAX = 32 + NGROUPS = 16 + PMASK = 0177 + PCATCH = 0400 + PLTWAIT = 01000 + PRECALC = 01000 + PSWP = 0 + PINOD = 10 + PSNDD = PINOD + PRIBIO = 20 + PZERO = 25 + PMEM = 0 + NZERO = 20 + PPIPE = 26 + PVFS = 27 + PWAIT = 30 + PSLEP = 39 + PUSER = 60 + PBATCH_CRITICAL = -1 + PTIME_SHARE = -2 + PTIME_SHARE_OVER = -3 + PBATCH = -4 + PWEIGHTLESS = -5 + IO_NBPC = 4096 + IO_BPCSHIFT = 12 + MIN_NBPC = 4096 + MIN_BPCSHIFT = 12 + MIN_CPSSHIFT = 10 + BPCSHIFT = 12 + CPSSHIFT = 10 + BPCSHIFT = 14 + CPSSHIFT = 12 + CPSSHIFT = 11 + BPSSHIFT = (BPCSHIFT+CPSSHIFT) + NULL = 0L + CMASK = 022 + NODEV = (-1) + NOPAGE = (-1) + NBPSCTR = 512 + SCTRSHFT = 9 + def BASEPRI(psw): return (((psw) & SR_IMASK) == SR_IMASK0) + + def BASEPRI(psw): return (((psw) & SR_IMASK) == SR_IMASK) + + def USERMODE(psw): return (((psw) & SR_KSU_MSK) == SR_KSU_USR) + + MAXPATHLEN = 1024 + MAXSYMLINKS = 30 + MAXNAMELEN = 256 + PIPE_BUF = 10240 + PIPE_MAX = 10240 + NBBY = 8 + BBSHIFT = 9 + BBSIZE = (1<> BBSHIFT) + + def OFFTOBBT(bytes): return ((off_t)(bytes) >> BBSHIFT) + + def BBTOOFF(bbs): return ((off_t)(bbs) << BBSHIFT) + + SEEKLIMIT32 = 0x7fffffff + MAXBSIZE = 8192 + DEV_BSIZE = BBSIZE + DEV_BSHIFT = BBSHIFT + def btodb(bytes): return \ + + def dbtob(db): return \ + + BLKDEV_IOSHIFT = BPCSHIFT + BLKDEV_IOSIZE = (1<> BLKDEV_IOSHIFT) + + def BLKDEV_LTOP(bn): return ((bn) * BLKDEV_BB) + + MAXHOSTNAMELEN = 256 + def DELAY(n): return us_delay(n) + + def DELAYBUS(n): return us_delaybus(n) + + TIMEPOKE_NOW = -100L MUTEX_DEFAULT = 0x0 ! METER_NAMSZ = 16 ! METER_NO_SEQ = -1 def mutex_spinlock(l): return splhi() def mutex_spintrylock(l): return splhi() def spinlock_initialized(l): return 1 *************** *** 57,67 **** SV_LIFO = 0x2 SV_PRIO = 0x4 SV_DEFAULT = SV_FIFO SEMA_NOHIST = 0x0001 SEMA_LOCK = 0x0004 ! SEMA_METER = 0x0008 ! SEMA_NAMSZ = METER_NAMSZ ! MR_ACCESS = 0x1 ! MR_UPDATE = 0x2 def mp_mutex_unlock(m): return mutex_unlock(m) --- 478,497 ---- SV_LIFO = 0x2 SV_PRIO = 0x4 + SV_KEYED = 0x6 SV_DEFAULT = SV_FIFO SEMA_NOHIST = 0x0001 SEMA_LOCK = 0x0004 ! NSCHEDCLASS = (-(PWEIGHTLESS)+1) ! MR_ACCESS = 1 ! MR_UPDATE = 2 ! MRLOCK_BARRIER = 0x1 ! MRLOCK_BEHAVIOR = 0x2 ! MRLOCK_DBLTRIPPABLE = 0x4 ! MRLOCK_ALLOW_EQUAL_PRI = 0x8 ! MRLOCK_DEFAULT = MRLOCK_BARRIER ! def mraccess(mrp): return mraccessf(mrp, 0) ! ! def mrupdate(mrp): return mrupdatef(mrp, 0) ! def mp_mutex_unlock(m): return mutex_unlock(m) *************** *** 70,100 **** def mp_mutex_spinlock(m): return mutex_spinlock(m) - def mp_mutex_trylock(m): return 1 - - def mp_mutex_spinlock(m): return 1 - - def nested_spintrylock(m): return 1 - - def mp_mrunlock(a): return mrunlock(a) - - def mp_cpsema(x): return cpsema(x) - - def mp_cvsema(x): return cvsema(x) - - def mp_cpsema(x): return 1 - - def mp_cvsema(x): return 0 MON_LOCKED = 0x01 MON_WAITING = 0x02 MON_TIMEOUT = 0x04 def initlock(l): return spinlock_init(l,0) def ownlock(x): return 1 - def splock(x): return 1 - - def io_splock(x): return 1 - def mutex_enter(m): return mutex_lock(m, PZERO) --- 500,515 ---- def mp_mutex_spinlock(m): return mutex_spinlock(m) + # Included from sys/mon.h MON_LOCKED = 0x01 MON_WAITING = 0x02 MON_TIMEOUT = 0x04 + MON_DOSRV = 0x08 + MON_RUN = 0x10 + MR_READER_BUCKETS = 13 def initlock(l): return spinlock_init(l,0) def ownlock(x): return 1 def mutex_enter(m): return mutex_lock(m, PZERO) *************** *** 113,117 **** def rw_exit(r): return mrunlock(r) ! def rw_tryupgrade(r): return cmrpromote(r) def rw_downgrade(r): return mrdemote(r) --- 528,532 ---- def rw_exit(r): return mrunlock(r) ! def rw_tryupgrade(r): return mrtrypromote(r) def rw_downgrade(r): return mrdemote(r) *************** *** 123,126 **** --- 538,545 ---- def RW_READ_HELD(r): return ismrlocked(r, MR_ACCESS) + MS_FREE = 0 + MS_UPD = 1 + MS_ACC = 2 + MS_WAITERS = 4 # Included from sys/fcntl.h *************** *** 135,138 **** --- 554,558 ---- FNONBLK = FNONBLOCK FDIRECT = 0x8000 + FBULK = 0x10000 FDIRENT64 = 0x8000 FCREAT = 0x0100 *************** *** 151,154 **** --- 571,575 ---- O_LARGEFILE = 0x2000 O_DIRECT = 0x8000 + O_BULK = 0x10000 O_CREAT = 0x100 O_TRUNC = 0x200 *************** *** 160,164 **** F_GETFL = 3 F_SETFL = 4 - F_GETLK = 14 F_SETLK = 6 F_SETLKW = 7 --- 581,584 ---- *************** *** 168,171 **** --- 588,600 ---- F_SETBSDLK = 12 F_SETBSDLKW = 13 + F_GETLK = 14 + F_CHKLK = 15 + F_CHKLKW = 16 + F_CLNLK = 17 + F_RSETLK = 20 + F_RGETLK = 21 + F_RSETLKW = 22 + F_GETOWN = 23 + F_SETOWN = 24 F_DIOINFO = 30 F_FSGETXATTR = 31 *************** *** 184,193 **** F_GETBMAPA = 44 F_FSGETXATTRA = 45 ! F_GETALLLK = 46 ! F_RSETLK = 20 ! F_RGETLK = 21 ! F_RSETLKW = 22 ! F_GETOWN = 23 ! F_SETOWN = 24 F_RDLCK = 01 F_WRLCK = 02 --- 613,627 ---- F_GETBMAPA = 44 F_FSGETXATTRA = 45 ! F_SETBIOSIZE = 46 ! F_GETBIOSIZE = 47 ! F_GETOPS = 50 ! F_DMAPI = 51 ! F_FSYNC = 52 ! F_FSYNC64 = 53 ! F_GETBDSATTR = 54 ! F_SETBDSATTR = 55 ! F_GETBMAPX = 56 ! F_SETPRIO = 57 ! F_GETPRIO = 58 F_RDLCK = 01 F_WRLCK = 02 *************** *** 196,200 **** FD_CLOEXEC = 1 FD_NODUP_FORK = 4 ! FMASK = 0x90FF FOPEN = 0xFFFFFFFF FREAD = 0x01 --- 630,640 ---- FD_CLOEXEC = 1 FD_NODUP_FORK = 4 ! BMV_IF_ATTRFORK = 0x1 ! BMV_IF_NO_DMAPI_READ = 0x2 ! BMV_IF_PREALLOC = 0x4 ! BMV_IF_VALID = (BMV_IF_ATTRFORK|BMV_IF_NO_DMAPI_READ|BMV_IF_PREALLOC) ! BMV_OF_PREALLOC = 0x1 ! BMV_IF_EXTENDED = 0x40000000 ! FMASK = 0x190FF FOPEN = 0xFFFFFFFF FREAD = 0x01 *************** *** 210,236 **** FLARGEFILE = 0x2000 FDIRECT = 0x8000 FCREAT = 0x0100 FTRUNC = 0x0200 FEXCL = 0x0400 FNOCTTY = 0x0800 - FMARK = 0x4000 - FDEFER = 0x2000 - FINPROGRESS = 0x0400 FINVIS = 0x0100 ! FNMFS = 0x2000 FDIRENT64 = 0x8000 ! FCLOSEXEC = 001 ! FDSHD = 0x0001 ! FDNOMARK = 0x0002 ! FDIGNPROGRESS = 0x0004 LOCK_SH = 1 LOCK_EX = 2 LOCK_NB = 4 LOCK_UN = 8 F_OK = 0 X_OK = 1 W_OK = 2 R_OK = 4 - L_SET = 0 - L_INCR = 1 - L_XTND = 2 --- 650,674 ---- FLARGEFILE = 0x2000 FDIRECT = 0x8000 + FBULK = 0x10000 FCREAT = 0x0100 FTRUNC = 0x0200 FEXCL = 0x0400 FNOCTTY = 0x0800 FINVIS = 0x0100 ! FSOCKET = 0x0200 ! FINPROGRESS = 0x0400 ! FPRIORITY = 0x0800 ! FPRIO = 0x4000 FDIRENT64 = 0x8000 ! FCLOSEXEC = 0x01 LOCK_SH = 1 LOCK_EX = 2 LOCK_NB = 4 LOCK_UN = 8 + L_SET = 0 + L_INCR = 1 + L_XTND = 2 F_OK = 0 X_OK = 1 W_OK = 2 R_OK = 4 Index: IN.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/IN.py,v retrieving revision 1.1 retrieving revision 1.1.30.1 diff -C2 -d -r1.1 -r1.1.30.1 *** IN.py 15 Jan 1997 19:18:50 -0000 1.1 --- IN.py 18 Mar 2002 13:10:41 -0000 1.1.30.1 *************** *** 1,4 **** --- 1,6 ---- # Generated by h2py from /usr/include/netinet/in.h + # Included from standards.h + # Included from sgidefs.h _MIPS_ISA_MIPS1 = 1 *************** *** 10,32 **** _MIPS_SIM_ABI64 = 3 - # Included from sys/endian.h - LITTLE_ENDIAN = 1234 - BIG_ENDIAN = 4321 - PDP_ENDIAN = 3412 - BYTE_ORDER = BIG_ENDIAN - BYTE_ORDER = LITTLE_ENDIAN - def ntohl(x): return (x) - - def ntohs(x): return (x) - - def htonl(x): return (x) - - def htons(x): return (x) - - def htonl(x): return ntohl(x) - - def htons(x): return ntohs(x) - - # Included from sys/bsd_types.h --- 12,15 ---- *************** *** 43,46 **** --- 26,31 ---- NEWDEV = 1 MKDEV_VER = NEWDEV + def IS_STRING_SPEC_DEV(x): return ((dev_t)(x)==__makedev(MKDEV_VER, 0, 0)) + def major(dev): return __major(MKDEV_VER, dev) *************** *** 49,54 **** # Included from sys/select.h - - # Included from standards.h FD_SETSIZE = 1024 __NBBY = 8 --- 34,37 ---- *************** *** 57,61 **** --- 40,90 ---- NULL = 0L NBBY = 8 + + # Included from sys/endian.h + LITTLE_ENDIAN = 1234 + BIG_ENDIAN = 4321 + PDP_ENDIAN = 3412 + _LITTLE_ENDIAN = 1234 + _BIG_ENDIAN = 4321 + _PDP_ENDIAN = 3412 + _BYTE_ORDER = _BIG_ENDIAN + _BYTE_ORDER = _LITTLE_ENDIAN + def ntohl(x): return (x) + + def ntohs(x): return (x) + + def htonl(x): return (x) + + def htons(x): return (x) + + def htonl(x): return ntohl(x) + + def htons(x): return ntohs(x) + + + # Included from sys/types.h + + # Included from sys/pthread.h + P_MYID = (-1) + P_MYHOSTID = (-1) + + # Included from sys/cpumask.h + MAXCPU = 128 + def CPUMASK_INDEX(bit): return ((bit) >> 6) + + def CPUMASK_SHFT(bit): return ((bit) & 0x3f) + + def CPUMASK_IS_ZERO(p): return ((p) == 0) + + def CPUMASK_IS_NONZERO(p): return ((p) != 0) + + + # Included from sys/nodemask.h + def CNODEMASK_IS_ZERO(p): return ((p) == 0) + + def CNODEMASK_IS_NONZERO(p): return ((p) != 0) + IPPROTO_IP = 0 + IPPROTO_HOPOPTS = 0 IPPROTO_ICMP = 1 IPPROTO_IGMP = 2 *************** *** 65,84 **** --- 94,183 ---- IPPROTO_ST = 5 IPPROTO_TCP = 6 + IPPROTO_UCL = 7 IPPROTO_EGP = 8 + IPPROTO_IGP = 9 + IPPROTO_BBN_RCC_MON = 10 + IPPROTO_NVP_II = 11 IPPROTO_PUP = 12 + IPPROTO_ARGUS = 13 + IPPROTO_EMCON = 14 + IPPROTO_XNET = 15 + IPPROTO_CHAOS = 16 IPPROTO_UDP = 17 + IPPROTO_MUX = 18 + IPPROTO_DCN_MEAS = 19 + IPPROTO_HMP = 20 + IPPROTO_PRM = 21 IPPROTO_IDP = 22 + IPPROTO_TRUNK_1 = 23 + IPPROTO_TRUNK_2 = 24 + IPPROTO_LEAF_1 = 25 + IPPROTO_LEAF_2 = 26 + IPPROTO_RDP = 27 + IPPROTO_IRTP = 28 IPPROTO_TP = 29 + IPPROTO_NETBLT = 30 + IPPROTO_MFE_NSP = 31 + IPPROTO_MERIT_INP = 32 + IPPROTO_SEP = 33 + IPPROTO_3PC = 34 + IPPROTO_IDPR = 35 IPPROTO_XTP = 36 + IPPROTO_DDP = 37 + IPPROTO_IDPR_CMTP = 38 + IPPROTO_TPPP = 39 + IPPROTO_IL = 40 + IPPROTO_IPV6 = 41 + IPPROTO_ROUTING = 43 + IPPROTO_FRAGMENT = 44 IPPROTO_RSVP = 46 + IPPROTO_ESP = 50 + IPPROTO_AH = 51 + IPPROTO_ICMPV6 = 58 + IPPROTO_NONE = 59 + IPPROTO_DSTOPTS = 60 + IPPROTO_CFTP = 62 IPPROTO_HELLO = 63 + IPPROTO_SAT_EXPAK = 64 + IPPROTO_KRYPTOLAN = 65 + IPPROTO_RVD = 66 + IPPROTO_IPPC = 67 + IPPROTO_SAT_MON = 69 + IPPROTO_VISA = 70 + IPPROTO_IPCV = 71 + IPPROTO_CPNX = 72 + IPPROTO_CPHB = 73 + IPPROTO_WSN = 74 + IPPROTO_PVP = 75 + IPPROTO_BR_SAT_MON = 76 IPPROTO_ND = 77 + IPPROTO_WB_MON = 78 + IPPROTO_WB_EXPAK = 79 IPPROTO_EON = 80 + IPPROTO_VMTP = 81 + IPPROTO_SECURE_VMTP = 82 + IPPROTO_VINES = 83 + IPPROTO_TTP = 84 + IPPROTO_NSFNET_IGP = 85 + IPPROTO_DGP = 86 + IPPROTO_TCF = 87 + IPPROTO_IGRP = 88 IPPROTO_OSPF = 89 + IPPROTO_SPRITE_RPC = 90 + IPPROTO_LARP = 91 + IPPROTO_MTP = 92 + IPPROTO_AX25 = 93 IPPROTO_SWIPE = 94 + IPPROTO_MICP = 95 + IPPROTO_AES_SP3_D = 96 + IPPROTO_ETHERIP = 97 + IPPROTO_ENCAPHDR = 98 IPPROTO_RAW = 255 IPPROTO_MAX = 256 + IPPROTO_STP = 257 IPPORT_RESERVED = 1024 IPPORT_MAXPORT = 65535 + INET_ADDRSTRLEN = 16 + INET6_ADDRSTRLEN = 46 def IN_CLASSA(i): return (((__int32_t)(i) & 0x80000000) == 0) *************** *** 111,114 **** --- 210,344 ---- INADDR_NONE = 0xffffffff IN_LOOPBACKNET = 127 + IPNGVERSION = 6 + IPV6_FLOWINFO_FLOWLABEL = 0x00ffffff + IPV6_FLOWINFO_PRIORITY = 0x0f000000 + IPV6_FLOWINFO_PRIFLOW = 0x0fffffff + IPV6_FLOWINFO_SRFLAG = 0x10000000 + IPV6_FLOWINFO_VERSION = 0xf0000000 + IPV6_PRIORITY_UNCHARACTERIZED = 0x00000000 + IPV6_PRIORITY_FILLER = 0x01000000 + IPV6_PRIORITY_UNATTENDED = 0x02000000 + IPV6_PRIORITY_RESERVED1 = 0x03000000 + IPV6_PRIORITY_BULK = 0x04000000 + IPV6_PRIORITY_RESERVED2 = 0x05000000 + IPV6_PRIORITY_INTERACTIVE = 0x06000000 + IPV6_PRIORITY_CONTROL = 0x07000000 + IPV6_PRIORITY_8 = 0x08000000 + IPV6_PRIORITY_9 = 0x09000000 + IPV6_PRIORITY_10 = 0x0a000000 + IPV6_PRIORITY_11 = 0x0b000000 + IPV6_PRIORITY_12 = 0x0c000000 + IPV6_PRIORITY_13 = 0x0d000000 + IPV6_PRIORITY_14 = 0x0e000000 + IPV6_PRIORITY_15 = 0x0f000000 + IPV6_SRFLAG_STRICT = 0x10000000 + IPV6_SRFLAG_LOOSE = 0x00000000 + IPV6_VERSION = 0x60000000 + IPV6_FLOWINFO_FLOWLABEL = 0xffffff00 + IPV6_FLOWINFO_PRIORITY = 0x0000000f + IPV6_FLOWINFO_PRIFLOW = 0xffffff0f + IPV6_FLOWINFO_SRFLAG = 0x00000010 + IPV6_FLOWINFO_VERSION = 0x000000f0 + IPV6_PRIORITY_UNCHARACTERIZED = 0x00000000 + IPV6_PRIORITY_FILLER = 0x00000001 + IPV6_PRIORITY_UNATTENDED = 0x00000002 + IPV6_PRIORITY_RESERVED1 = 0x00000003 + IPV6_PRIORITY_BULK = 0x00000004 + IPV6_PRIORITY_RESERVED2 = 0x00000005 + IPV6_PRIORITY_INTERACTIVE = 0x00000006 + IPV6_PRIORITY_CONTROL = 0x00000007 + IPV6_PRIORITY_8 = 0x00000008 + IPV6_PRIORITY_9 = 0x00000009 + IPV6_PRIORITY_10 = 0x0000000a + IPV6_PRIORITY_11 = 0x0000000b + IPV6_PRIORITY_12 = 0x0000000c + IPV6_PRIORITY_13 = 0x0000000d + IPV6_PRIORITY_14 = 0x0000000e + IPV6_PRIORITY_15 = 0x0000000f + IPV6_SRFLAG_STRICT = 0x00000010 + IPV6_SRFLAG_LOOSE = 0x00000000 + IPV6_VERSION = 0x00000060 + def IPV6_GET_FLOWLABEL(x): return (ntohl(x) & 0x00ffffff) + + def IPV6_GET_PRIORITY(x): return ((ntohl(x) >> 24) & 0xf) + + def IPV6_GET_VERSION(x): return ((ntohl(x) >> 28) & 0xf) + + def IPV6_SET_FLOWLABEL(x): return (htonl(x) & IPV6_FLOWINFO_FLOWLABEL) + + def IPV6_SET_PRIORITY(x): return (htonl((x & 0xf) << 24)) + + def CLR_ADDR6(a): return \ + + def IS_ANYSOCKADDR(a): return \ + + def IS_ANYADDR6(a): return \ + + def IS_COMPATSOCKADDR(a): return \ + + def IS_COMPATADDR6(a): return \ + + def IS_LOOPSOCKADDR(a): return \ + + def IS_LOOPADDR6(a): return \ + + def IS_IPV4SOCKADDR(a): return \ + + def IS_IPV4ADDR6(a): return \ + + def IS_LOOPSOCKADDR(a): return \ + + def IS_LOOPADDR6(a): return \ + + def IS_IPV4SOCKADDR(a): return \ + + def IS_IPV4ADDR6(a): return \ + + def IS_LOCALADDR6(a): return ((a).s6_addr8[0] == 0xfe) + + def IS_LINKLADDR6(a): return \ + + def IS_SITELADDR6(a): return \ + + def IS_MULTIADDR6(a): return ((a).s6_addr8[0] == 0xff) + + def MADDR6_FLAGS(a): return ((a).s6_addr8[1] >> 4) + + MADDR6_FLG_WK = 0 + MADDR6_FLG_TS = 1 + def MADDR6_SCOPE(a): return ((a).s6_addr8[1] & 0x0f) + + MADDR6_SCP_NODE = 0x1 + MADDR6_SCP_LINK = 0x2 + MADDR6_SCP_SITE = 0x5 + MADDR6_SCP_ORG = 0x8 + MADDR6_SCP_GLO = 0xe + MADDR6_ALLNODES = 1 + MADDR6_ALLROUTERS = 2 + MADDR6_ALLHOSTS = 3 + def IN6_IS_ADDR_UNSPECIFIED(p): return IS_ANYADDR6(*p) + + def IN6_IS_ADDR_LOOPBACK(p): return IS_LOOPADDR6(*p) + + def IN6_IS_ADDR_MULTICAST(p): return IS_MULTIADDR6(*p) + + def IN6_IS_ADDR_LINKLOCAL(p): return IS_LINKLADDR6(*p) + + def IN6_IS_ADDR_SITELOCAL(p): return IS_SITELADDR6(*p) + + def IN6_IS_ADDR_V4MAPPED(p): return IS_IPV4ADDR6(*p) + + def IN6_IS_ADDR_V4COMPAT(p): return IS_COMPATADDR6(*p) + + def IN6_IS_ADDR_MC_NODELOCAL(p): return \ + + def IN6_IS_ADDR_MC_LINKLOCAL(p): return \ + + def IN6_IS_ADDR_MC_SITELOCAL(p): return \ + + def IN6_IS_ADDR_MC_ORGLOCAL(p): return \ + + def IN6_IS_ADDR_MC_GLOBAL(p): return \ + IP_OPTIONS = 1 IP_HDRINCL = 2 *************** *** 129,133 **** IP_RSVP_ON = 28 IP_SENDSRCADDR = 36 IP_DEFAULT_MULTICAST_TTL = 1 IP_DEFAULT_MULTICAST_LOOP = 1 ! IP_MAX_MEMBERSHIPS = 20 --- 359,385 ---- IP_RSVP_ON = 28 IP_SENDSRCADDR = 36 + IPV6_UNICAST_HOPS = IP_TTL + IPV6_MULTICAST_IF = IP_MULTICAST_IF + IPV6_MULTICAST_HOPS = IP_MULTICAST_TTL + IPV6_MULTICAST_LOOP = IP_MULTICAST_LOOP + IPV6_ADD_MEMBERSHIP = IP_ADD_MEMBERSHIP + IPV6_DROP_MEMBERSHIP = IP_DROP_MEMBERSHIP + IPV6_SENDIF = 40 + IPV6_NOPROBE = 42 + IPV6_RECVPKTINFO = 43 + IPV6_PKTINFO = 44 + IP_RECVTTL = 45 + IPV6_RECVHOPS = IP_RECVTTL + IPV6_CHECKSUM = 46 + ICMP6_FILTER = 47 + IPV6_HOPLIMIT = 48 + IPV6_HOPOPTS = 49 + IPV6_DSTOPTS = 50 + IPV6_RTHDR = 51 + IPV6_PKTOPTIONS = 52 + IPV6_NEXTHOP = 53 IP_DEFAULT_MULTICAST_TTL = 1 IP_DEFAULT_MULTICAST_LOOP = 1 ! IPV6_RTHDR_LOOSE = 0 ! IPV6_RTHDR_STRICT = 1 ! IPV6_RTHDR_TYPE_0 = 0 From mwh@users.sourceforge.net Mon Mar 18 13:31:33 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 18 Mar 2002 05:31:33 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib StringIO.py,1.19.12.1,1.19.12.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv23898 Modified Files: Tag: release22-maint StringIO.py Log Message: Make StringIO work in non-unicode builds. Lots of tests fail in non-unicode builds, but I think most of these are "bugs" in the tests. I hope so, anyway. Index: StringIO.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/StringIO.py,v retrieving revision 1.19.12.1 retrieving revision 1.19.12.2 diff -C2 -d -r1.19.12.1 -r1.19.12.2 *** StringIO.py 28 Jan 2002 15:00:27 -0000 1.19.12.1 --- StringIO.py 18 Mar 2002 13:31:30 -0000 1.19.12.2 *************** *** 40,44 **** def __init__(self, buf = ''): # Force self.buf to be a string or unicode ! if type(buf) is not types.UnicodeType: buf = str(buf) self.buf = buf --- 40,44 ---- def __init__(self, buf = ''): # Force self.buf to be a string or unicode ! if type(buf) not in types.StringTypes: buf = str(buf) self.buf = buf *************** *** 139,143 **** if not s: return # Force s to be a string or unicode ! if type(s) is not types.UnicodeType: s = str(s) if self.pos > self.len: --- 139,143 ---- if not s: return # Force s to be a string or unicode ! if type(s) not in types.StringTypes: s = str(s) if self.pos > self.len: From mwh@users.sourceforge.net Mon Mar 18 13:31:33 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 18 Mar 2002 05:31:33 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_StringIO.py,1.10.6.1,1.10.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv23898/test Modified Files: Tag: release22-maint test_StringIO.py Log Message: Make StringIO work in non-unicode builds. Lots of tests fail in non-unicode builds, but I think most of these are "bugs" in the tests. I hope so, anyway. Index: test_StringIO.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_StringIO.py,v retrieving revision 1.10.6.1 retrieving revision 1.10.6.2 diff -C2 -d -r1.10.6.1 -r1.10.6.2 *** test_StringIO.py 28 Jan 2002 15:01:42 -0000 1.10.6.1 --- test_StringIO.py 18 Mar 2002 13:31:31 -0000 1.10.6.2 *************** *** 72,89 **** MODULE = StringIO ! def test_unicode(self): ! # The StringIO module also supports concatenating Unicode ! # snippets to larger Unicode strings. This is tested by this ! # method. Note that cStringIO does not support this extension. ! f = self.MODULE.StringIO() ! f.write(self._line[:6]) ! f.seek(3) ! f.write(unicode(self._line[20:26])) ! f.write(unicode(self._line[52])) ! s = f.getvalue() ! self.assertEqual(s, unicode('abcuvwxyz!')) ! self.assertEqual(type(s), types.UnicodeType) class TestcStringIO(TestGenericStringIO): --- 72,90 ---- MODULE = StringIO ! if test_support.have_unicode: ! def test_unicode(self): ! # The StringIO module also supports concatenating Unicode ! # snippets to larger Unicode strings. This is tested by this ! # method. Note that cStringIO does not support this extension. ! f = self.MODULE.StringIO() ! f.write(self._line[:6]) ! f.seek(3) ! f.write(unicode(self._line[20:26])) ! f.write(unicode(self._line[52])) ! s = f.getvalue() ! self.assertEqual(s, unicode('abcuvwxyz!')) ! self.assertEqual(type(s), types.UnicodeType) class TestcStringIO(TestGenericStringIO): From jackjansen@users.sourceforge.net Mon Mar 18 15:24:24 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 18 Mar 2002 07:24:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/bgen/bgen macsupport.py,1.26,1.27 bgenType.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/bgen/bgen In directory usw-pr-cvs1:/tmp/cvs-serv6252 Modified Files: macsupport.py bgenType.py Log Message: Some structures should be passed to Py_BuildValue by reference, not by value, notably FSSpec and FSRef objects. First half of fix for #531291. 2.2.1 candidate. Index: macsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/macsupport.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** macsupport.py 1 Jan 2002 22:39:58 -0000 1.26 --- macsupport.py 18 Mar 2002 15:24:22 -0000 1.27 *************** *** 47,53 **** # File System Specifications FSSpec_ptr = OpaqueType("FSSpec", "PyMac_BuildFSSpec", "PyMac_GetFSSpec") ! FSSpec = OpaqueByValueType("FSSpec", "PyMac_BuildFSSpec", "PyMac_GetFSSpec") FSRef_ptr = OpaqueType("FSRef", "PyMac_BuildFSRef", "PyMac_GetFSRef") ! FSRef = OpaqueByValueType("FSRef", "PyMac_BuildFSRef", "PyMac_GetFSRef") # OSType and ResType: 4-byte character strings --- 47,53 ---- # File System Specifications FSSpec_ptr = OpaqueType("FSSpec", "PyMac_BuildFSSpec", "PyMac_GetFSSpec") ! FSSpec = OpaqueByValueStructType("FSSpec", "PyMac_BuildFSSpec", "PyMac_GetFSSpec") FSRef_ptr = OpaqueType("FSRef", "PyMac_BuildFSRef", "PyMac_GetFSRef") ! FSRef = OpaqueByValueStructType("FSRef", "PyMac_BuildFSRef", "PyMac_GetFSRef") # OSType and ResType: 4-byte character strings Index: bgenType.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenType.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** bgenType.py 1 Jan 2002 22:40:02 -0000 1.7 --- bgenType.py 18 Mar 2002 15:24:22 -0000 1.8 *************** *** 234,237 **** --- 234,245 ---- def mkvalueArgs(self, name): return "%s, %s" % (self.new, name) + + class OpaqueByValueStructType(OpaqueByValueType): + """Similar to OpaqueByValueType, but we also pass this to mkvalue by + address, in stead of by value. + """ + + def mkvalueArgs(self, name): + return "%s, &%s" % (self.new, name) From jackjansen@users.sourceforge.net Mon Mar 18 15:31:10 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 18 Mar 2002 07:31:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/res _Resmodule.c,1.9,1.10 ressupport.py,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/res In directory usw-pr-cvs1:/tmp/cvs-serv8923 Modified Files: _Resmodule.c ressupport.py Log Message: Some of the newer routines return an OSErr, like most toolbox calls, in stead of depending on ResError(). Second half of fix for #531291. 2.2.1 candidate. Index: _Resmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/res/_Resmodule.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** _Resmodule.c 4 Jan 2002 16:00:19 -0000 1.9 --- _Resmodule.c 18 Mar 2002 15:31:07 -0000 1.10 *************** *** 629,642 **** { PyObject *_res = NULL; ! OSErr _rv; if (!PyArg_ParseTuple(_args, "")) return NULL; ! _rv = ResError(); ! { ! OSErr _err = ResError(); ! if (_err != noErr) return PyMac_Error(_err); ! } ! _res = Py_BuildValue("h", ! _rv); return _res; } --- 629,639 ---- { PyObject *_res = NULL; ! OSErr _err; if (!PyArg_ParseTuple(_args, "")) return NULL; ! _err = ResError(); ! if (_err != noErr) return PyMac_Error(_err); ! Py_INCREF(Py_None); ! _res = Py_None; return _res; } *************** *** 1223,1227 **** { PyObject *_res = NULL; ! OSErr _rv; SInt16 refNum; RsrcChainLocation where; --- 1220,1224 ---- { PyObject *_res = NULL; ! OSErr _err; SInt16 refNum; RsrcChainLocation where; *************** *** 1230,1241 **** &where)) return NULL; ! _rv = InsertResourceFile(refNum, ! where); ! { ! OSErr _err = ResError(); ! if (_err != noErr) return PyMac_Error(_err); ! } ! _res = Py_BuildValue("h", ! _rv); return _res; } --- 1227,1235 ---- &where)) return NULL; ! _err = InsertResourceFile(refNum, ! where); ! if (_err != noErr) return PyMac_Error(_err); ! Py_INCREF(Py_None); ! _res = Py_None; return _res; } *************** *** 1247,1262 **** { PyObject *_res = NULL; ! OSErr _rv; SInt16 refNum; if (!PyArg_ParseTuple(_args, "h", &refNum)) return NULL; ! _rv = DetachResourceFile(refNum); ! { ! OSErr _err = ResError(); ! if (_err != noErr) return PyMac_Error(_err); ! } ! _res = Py_BuildValue("h", ! _rv); return _res; } --- 1241,1253 ---- { PyObject *_res = NULL; ! OSErr _err; SInt16 refNum; if (!PyArg_ParseTuple(_args, "h", &refNum)) return NULL; ! _err = DetachResourceFile(refNum); ! if (_err != noErr) return PyMac_Error(_err); ! Py_INCREF(Py_None); ! _res = Py_None; return _res; } *************** *** 1295,1299 **** { PyObject *_res = NULL; ! OSErr _rv; FSSpec spec; SignedByte permission; --- 1286,1290 ---- { PyObject *_res = NULL; ! OSErr _err; FSSpec spec; SignedByte permission; *************** *** 1303,1315 **** &permission)) return NULL; ! _rv = FSpOpenOrphanResFile(&spec, ! permission, ! &refNum); ! { ! OSErr _err = ResError(); ! if (_err != noErr) return PyMac_Error(_err); ! } ! _res = Py_BuildValue("hh", ! _rv, refNum); return _res; --- 1294,1302 ---- &permission)) return NULL; ! _err = FSpOpenOrphanResFile(&spec, ! permission, ! &refNum); ! if (_err != noErr) return PyMac_Error(_err); ! _res = Py_BuildValue("h", refNum); return _res; *************** *** 1322,1336 **** { PyObject *_res = NULL; ! OSErr _rv; SInt16 refNum; if (!PyArg_ParseTuple(_args, "")) return NULL; ! _rv = GetTopResourceFile(&refNum); ! { ! OSErr _err = ResError(); ! if (_err != noErr) return PyMac_Error(_err); ! } ! _res = Py_BuildValue("hh", ! _rv, refNum); return _res; --- 1309,1319 ---- { PyObject *_res = NULL; ! OSErr _err; SInt16 refNum; if (!PyArg_ParseTuple(_args, "")) return NULL; ! _err = GetTopResourceFile(&refNum); ! if (_err != noErr) return PyMac_Error(_err); ! _res = Py_BuildValue("h", refNum); return _res; *************** *** 1343,1347 **** { PyObject *_res = NULL; ! OSErr _rv; SInt16 curRefNum; SInt16 nextRefNum; --- 1326,1330 ---- { PyObject *_res = NULL; ! OSErr _err; SInt16 curRefNum; SInt16 nextRefNum; *************** *** 1349,1360 **** &curRefNum)) return NULL; ! _rv = GetNextResourceFile(curRefNum, ! &nextRefNum); ! { ! OSErr _err = ResError(); ! if (_err != noErr) return PyMac_Error(_err); ! } ! _res = Py_BuildValue("hh", ! _rv, nextRefNum); return _res; --- 1332,1339 ---- &curRefNum)) return NULL; ! _err = GetNextResourceFile(curRefNum, ! &nextRefNum); ! if (_err != noErr) return PyMac_Error(_err); ! _res = Py_BuildValue("h", nextRefNum); return _res; *************** *** 1408,1413 **** } _res = Py_BuildValue("O&O&", ! PyMac_BuildFSRef, newRef, ! PyMac_BuildFSSpec, newSpec); return _res; } --- 1387,1392 ---- } _res = Py_BuildValue("O&O&", ! PyMac_BuildFSRef, &newRef, ! PyMac_BuildFSSpec, &newSpec); return _res; } *************** *** 1442,1446 **** { PyObject *_res = NULL; ! OSErr _rv; FSRef parentRef; UniChar *nameLength__in__; --- 1421,1425 ---- { PyObject *_res = NULL; ! OSErr _err; FSRef parentRef; UniChar *nameLength__in__; *************** *** 1459,1477 **** nameLength__len__ = nameLength__in_len__; forkNameLength__len__ = forkNameLength__in_len__; ! _rv = FSCreateResourceFile(&parentRef, ! nameLength__len__, nameLength__in__, ! 0, ! (FSCatalogInfo *)0, ! forkNameLength__len__, forkNameLength__in__, ! &newRef, ! &newSpec); ! { ! OSErr _err = ResError(); ! if (_err != noErr) return PyMac_Error(_err); ! } ! _res = Py_BuildValue("hO&O&", ! _rv, ! PyMac_BuildFSRef, newRef, ! PyMac_BuildFSSpec, newSpec); return _res; } --- 1438,1452 ---- nameLength__len__ = nameLength__in_len__; forkNameLength__len__ = forkNameLength__in_len__; ! _err = FSCreateResourceFile(&parentRef, ! nameLength__len__, nameLength__in__, ! 0, ! (FSCatalogInfo *)0, ! forkNameLength__len__, forkNameLength__in__, ! &newRef, ! &newSpec); ! if (_err != noErr) return PyMac_Error(_err); ! _res = Py_BuildValue("O&O&", ! PyMac_BuildFSRef, &newRef, ! PyMac_BuildFSSpec, &newSpec); return _res; } *************** *** 1483,1487 **** { PyObject *_res = NULL; ! OSErr _rv; FSRef ref; UniChar *forkNameLength__in__; --- 1458,1462 ---- { PyObject *_res = NULL; ! OSErr _err; FSRef ref; UniChar *forkNameLength__in__; *************** *** 1496,1509 **** return NULL; forkNameLength__len__ = forkNameLength__in_len__; ! _rv = FSOpenResourceFile(&ref, ! forkNameLength__len__, forkNameLength__in__, ! permissions, ! &refNum); ! { ! OSErr _err = ResError(); ! if (_err != noErr) return PyMac_Error(_err); ! } ! _res = Py_BuildValue("hh", ! _rv, refNum); return _res; --- 1471,1480 ---- return NULL; forkNameLength__len__ = forkNameLength__in_len__; ! _err = FSOpenResourceFile(&ref, ! forkNameLength__len__, forkNameLength__in__, ! permissions, ! &refNum); ! if (_err != noErr) return PyMac_Error(_err); ! _res = Py_BuildValue("h", refNum); return _res; *************** *** 1574,1578 **** "(short refNum) -> None"}, {"ResError", (PyCFunction)Res_ResError, 1, ! "() -> (OSErr _rv)"}, {"CurResFile", (PyCFunction)Res_CurResFile, 1, "() -> (short _rv)"}, --- 1545,1549 ---- "(short refNum) -> None"}, {"ResError", (PyCFunction)Res_ResError, 1, ! "() -> None"}, {"CurResFile", (PyCFunction)Res_CurResFile, 1, "() -> (short _rv)"}, *************** *** 1645,1654 **** #if TARGET_API_MAC_CARBON {"InsertResourceFile", (PyCFunction)Res_InsertResourceFile, 1, ! "(SInt16 refNum, RsrcChainLocation where) -> (OSErr _rv)"}, #endif #if TARGET_API_MAC_CARBON {"DetachResourceFile", (PyCFunction)Res_DetachResourceFile, 1, ! "(SInt16 refNum) -> (OSErr _rv)"}, #endif --- 1616,1625 ---- #if TARGET_API_MAC_CARBON {"InsertResourceFile", (PyCFunction)Res_InsertResourceFile, 1, ! "(SInt16 refNum, RsrcChainLocation where) -> None"}, #endif #if TARGET_API_MAC_CARBON {"DetachResourceFile", (PyCFunction)Res_DetachResourceFile, 1, ! "(SInt16 refNum) -> None"}, #endif *************** *** 1660,1674 **** #if TARGET_API_MAC_CARBON {"FSpOpenOrphanResFile", (PyCFunction)Res_FSpOpenOrphanResFile, 1, ! "(FSSpec spec, SignedByte permission) -> (OSErr _rv, SInt16 refNum)"}, #endif #if TARGET_API_MAC_CARBON {"GetTopResourceFile", (PyCFunction)Res_GetTopResourceFile, 1, ! "() -> (OSErr _rv, SInt16 refNum)"}, #endif #if TARGET_API_MAC_CARBON {"GetNextResourceFile", (PyCFunction)Res_GetNextResourceFile, 1, ! "(SInt16 curRefNum) -> (OSErr _rv, SInt16 nextRefNum)"}, #endif {"FSOpenResFile", (PyCFunction)Res_FSOpenResFile, 1, --- 1631,1645 ---- #if TARGET_API_MAC_CARBON {"FSpOpenOrphanResFile", (PyCFunction)Res_FSpOpenOrphanResFile, 1, ! "(FSSpec spec, SignedByte permission) -> (SInt16 refNum)"}, #endif #if TARGET_API_MAC_CARBON {"GetTopResourceFile", (PyCFunction)Res_GetTopResourceFile, 1, ! "() -> (SInt16 refNum)"}, #endif #if TARGET_API_MAC_CARBON {"GetNextResourceFile", (PyCFunction)Res_GetNextResourceFile, 1, ! "(SInt16 curRefNum) -> (SInt16 nextRefNum)"}, #endif {"FSOpenResFile", (PyCFunction)Res_FSOpenResFile, 1, *************** *** 1681,1690 **** #if TARGET_API_MAC_CARBON {"FSCreateResourceFile", (PyCFunction)Res_FSCreateResourceFile, 1, ! "(FSRef parentRef, Buffer nameLength, Buffer forkNameLength) -> (OSErr _rv, FSRef newRef, FSSpec newSpec)"}, #endif #if TARGET_API_MAC_CARBON {"FSOpenResourceFile", (PyCFunction)Res_FSOpenResourceFile, 1, ! "(FSRef ref, Buffer forkNameLength, SignedByte permissions) -> (OSErr _rv, SInt16 refNum)"}, #endif {"Resource", (PyCFunction)Res_Resource, 1, --- 1652,1661 ---- #if TARGET_API_MAC_CARBON {"FSCreateResourceFile", (PyCFunction)Res_FSCreateResourceFile, 1, ! "(FSRef parentRef, Buffer nameLength, Buffer forkNameLength) -> (FSRef newRef, FSSpec newSpec)"}, #endif #if TARGET_API_MAC_CARBON {"FSOpenResourceFile", (PyCFunction)Res_FSOpenResourceFile, 1, ! "(FSRef ref, Buffer forkNameLength, SignedByte permissions) -> (SInt16 refNum)"}, #endif {"Resource", (PyCFunction)Res_Resource, 1, Index: ressupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/res/ressupport.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** ressupport.py 1 Jan 2002 22:43:07 -0000 1.19 --- ressupport.py 18 Mar 2002 15:31:08 -0000 1.20 *************** *** 9,20 **** def checkit(self): ! OutLbrace() ! Output("OSErr _err = ResError();") ! Output("if (_err != noErr) return PyMac_Error(_err);") ! OutRbrace() FunctionGenerator.checkit(self) # XXX ! class ResFunction(ResMixIn, FunctionGenerator): pass ! class ResMethod(ResMixIn, MethodGenerator): pass RsrcChainLocation = Type("RsrcChainLocation", "h") --- 9,21 ---- def checkit(self): ! if self.returntype.__class__ != OSErrType: ! OutLbrace() ! Output("OSErr _err = ResError();") ! Output("if (_err != noErr) return PyMac_Error(_err);") ! OutRbrace() FunctionGenerator.checkit(self) # XXX ! class ResFunction(ResMixIn, OSErrFunctionGenerator): pass ! class ResMethod(ResMixIn, OSErrMethodGenerator): pass RsrcChainLocation = Type("RsrcChainLocation", "h") From jackjansen@users.sourceforge.net Mon Mar 18 15:38:26 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 18 Mar 2002 07:38:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/res _Resmodule.c,1.7.4.1,1.7.4.2 ressupport.py,1.18.4.1,1.18.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/res In directory usw-pr-cvs1:/tmp/cvs-serv10887 Modified Files: Tag: release22-maint _Resmodule.c ressupport.py Log Message: Backport of _Resmodule.c 1.10 and ressupport.py 1.20: Some of the newer routines return an OSErr, like most toolbox calls, in stead of depending on ResError(). Second half of fix for #531291. Index: _Resmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/res/_Resmodule.c,v retrieving revision 1.7.4.1 retrieving revision 1.7.4.2 diff -C2 -d -r1.7.4.1 -r1.7.4.2 *** _Resmodule.c 27 Feb 2002 23:16:52 -0000 1.7.4.1 --- _Resmodule.c 18 Mar 2002 15:38:24 -0000 1.7.4.2 *************** *** 629,642 **** { PyObject *_res = NULL; ! OSErr _rv; if (!PyArg_ParseTuple(_args, "")) return NULL; ! _rv = ResError(); ! { ! OSErr _err = ResError(); ! if (_err != noErr) return PyMac_Error(_err); ! } ! _res = Py_BuildValue("h", ! _rv); return _res; } --- 629,639 ---- { PyObject *_res = NULL; ! OSErr _err; if (!PyArg_ParseTuple(_args, "")) return NULL; ! _err = ResError(); ! if (_err != noErr) return PyMac_Error(_err); ! Py_INCREF(Py_None); ! _res = Py_None; return _res; } *************** *** 1223,1227 **** { PyObject *_res = NULL; ! OSErr _rv; SInt16 refNum; RsrcChainLocation where; --- 1220,1224 ---- { PyObject *_res = NULL; ! OSErr _err; SInt16 refNum; RsrcChainLocation where; *************** *** 1230,1241 **** &where)) return NULL; ! _rv = InsertResourceFile(refNum, ! where); ! { ! OSErr _err = ResError(); ! if (_err != noErr) return PyMac_Error(_err); ! } ! _res = Py_BuildValue("h", ! _rv); return _res; } --- 1227,1235 ---- &where)) return NULL; ! _err = InsertResourceFile(refNum, ! where); ! if (_err != noErr) return PyMac_Error(_err); ! Py_INCREF(Py_None); ! _res = Py_None; return _res; } *************** *** 1247,1262 **** { PyObject *_res = NULL; ! OSErr _rv; SInt16 refNum; if (!PyArg_ParseTuple(_args, "h", &refNum)) return NULL; ! _rv = DetachResourceFile(refNum); ! { ! OSErr _err = ResError(); ! if (_err != noErr) return PyMac_Error(_err); ! } ! _res = Py_BuildValue("h", ! _rv); return _res; } --- 1241,1253 ---- { PyObject *_res = NULL; ! OSErr _err; SInt16 refNum; if (!PyArg_ParseTuple(_args, "h", &refNum)) return NULL; ! _err = DetachResourceFile(refNum); ! if (_err != noErr) return PyMac_Error(_err); ! Py_INCREF(Py_None); ! _res = Py_None; return _res; } *************** *** 1295,1299 **** { PyObject *_res = NULL; ! OSErr _rv; FSSpec spec; SignedByte permission; --- 1286,1290 ---- { PyObject *_res = NULL; ! OSErr _err; FSSpec spec; SignedByte permission; *************** *** 1303,1315 **** &permission)) return NULL; ! _rv = FSpOpenOrphanResFile(&spec, ! permission, ! &refNum); ! { ! OSErr _err = ResError(); ! if (_err != noErr) return PyMac_Error(_err); ! } ! _res = Py_BuildValue("hh", ! _rv, refNum); return _res; --- 1294,1302 ---- &permission)) return NULL; ! _err = FSpOpenOrphanResFile(&spec, ! permission, ! &refNum); ! if (_err != noErr) return PyMac_Error(_err); ! _res = Py_BuildValue("h", refNum); return _res; *************** *** 1322,1336 **** { PyObject *_res = NULL; ! OSErr _rv; SInt16 refNum; if (!PyArg_ParseTuple(_args, "")) return NULL; ! _rv = GetTopResourceFile(&refNum); ! { ! OSErr _err = ResError(); ! if (_err != noErr) return PyMac_Error(_err); ! } ! _res = Py_BuildValue("hh", ! _rv, refNum); return _res; --- 1309,1319 ---- { PyObject *_res = NULL; ! OSErr _err; SInt16 refNum; if (!PyArg_ParseTuple(_args, "")) return NULL; ! _err = GetTopResourceFile(&refNum); ! if (_err != noErr) return PyMac_Error(_err); ! _res = Py_BuildValue("h", refNum); return _res; *************** *** 1343,1347 **** { PyObject *_res = NULL; ! OSErr _rv; SInt16 curRefNum; SInt16 nextRefNum; --- 1326,1330 ---- { PyObject *_res = NULL; ! OSErr _err; SInt16 curRefNum; SInt16 nextRefNum; *************** *** 1349,1360 **** &curRefNum)) return NULL; ! _rv = GetNextResourceFile(curRefNum, ! &nextRefNum); ! { ! OSErr _err = ResError(); ! if (_err != noErr) return PyMac_Error(_err); ! } ! _res = Py_BuildValue("hh", ! _rv, nextRefNum); return _res; --- 1332,1339 ---- &curRefNum)) return NULL; ! _err = GetNextResourceFile(curRefNum, ! &nextRefNum); ! if (_err != noErr) return PyMac_Error(_err); ! _res = Py_BuildValue("h", nextRefNum); return _res; *************** *** 1408,1413 **** } _res = Py_BuildValue("O&O&", ! PyMac_BuildFSRef, newRef, ! PyMac_BuildFSSpec, newSpec); return _res; } --- 1387,1392 ---- } _res = Py_BuildValue("O&O&", ! PyMac_BuildFSRef, &newRef, ! PyMac_BuildFSSpec, &newSpec); return _res; } *************** *** 1442,1446 **** { PyObject *_res = NULL; ! OSErr _rv; FSRef parentRef; UniChar *nameLength__in__; --- 1421,1425 ---- { PyObject *_res = NULL; ! OSErr _err; FSRef parentRef; UniChar *nameLength__in__; *************** *** 1459,1477 **** nameLength__len__ = nameLength__in_len__; forkNameLength__len__ = forkNameLength__in_len__; ! _rv = FSCreateResourceFile(&parentRef, ! nameLength__len__, nameLength__in__, ! 0, ! (FSCatalogInfo *)0, ! forkNameLength__len__, forkNameLength__in__, ! &newRef, ! &newSpec); ! { ! OSErr _err = ResError(); ! if (_err != noErr) return PyMac_Error(_err); ! } ! _res = Py_BuildValue("hO&O&", ! _rv, ! PyMac_BuildFSRef, newRef, ! PyMac_BuildFSSpec, newSpec); return _res; } --- 1438,1452 ---- nameLength__len__ = nameLength__in_len__; forkNameLength__len__ = forkNameLength__in_len__; ! _err = FSCreateResourceFile(&parentRef, ! nameLength__len__, nameLength__in__, ! 0, ! (FSCatalogInfo *)0, ! forkNameLength__len__, forkNameLength__in__, ! &newRef, ! &newSpec); ! if (_err != noErr) return PyMac_Error(_err); ! _res = Py_BuildValue("O&O&", ! PyMac_BuildFSRef, &newRef, ! PyMac_BuildFSSpec, &newSpec); return _res; } *************** *** 1483,1487 **** { PyObject *_res = NULL; ! OSErr _rv; FSRef ref; UniChar *forkNameLength__in__; --- 1458,1462 ---- { PyObject *_res = NULL; ! OSErr _err; FSRef ref; UniChar *forkNameLength__in__; *************** *** 1496,1509 **** return NULL; forkNameLength__len__ = forkNameLength__in_len__; ! _rv = FSOpenResourceFile(&ref, ! forkNameLength__len__, forkNameLength__in__, ! permissions, ! &refNum); ! { ! OSErr _err = ResError(); ! if (_err != noErr) return PyMac_Error(_err); ! } ! _res = Py_BuildValue("hh", ! _rv, refNum); return _res; --- 1471,1480 ---- return NULL; forkNameLength__len__ = forkNameLength__in_len__; ! _err = FSOpenResourceFile(&ref, ! forkNameLength__len__, forkNameLength__in__, ! permissions, ! &refNum); ! if (_err != noErr) return PyMac_Error(_err); ! _res = Py_BuildValue("h", refNum); return _res; *************** *** 1574,1578 **** "(short refNum) -> None"}, {"ResError", (PyCFunction)Res_ResError, 1, ! "() -> (OSErr _rv)"}, {"CurResFile", (PyCFunction)Res_CurResFile, 1, "() -> (short _rv)"}, --- 1545,1549 ---- "(short refNum) -> None"}, {"ResError", (PyCFunction)Res_ResError, 1, ! "() -> None"}, {"CurResFile", (PyCFunction)Res_CurResFile, 1, "() -> (short _rv)"}, *************** *** 1645,1654 **** #if TARGET_API_MAC_CARBON {"InsertResourceFile", (PyCFunction)Res_InsertResourceFile, 1, ! "(SInt16 refNum, RsrcChainLocation where) -> (OSErr _rv)"}, #endif #if TARGET_API_MAC_CARBON {"DetachResourceFile", (PyCFunction)Res_DetachResourceFile, 1, ! "(SInt16 refNum) -> (OSErr _rv)"}, #endif --- 1616,1625 ---- #if TARGET_API_MAC_CARBON {"InsertResourceFile", (PyCFunction)Res_InsertResourceFile, 1, ! "(SInt16 refNum, RsrcChainLocation where) -> None"}, #endif #if TARGET_API_MAC_CARBON {"DetachResourceFile", (PyCFunction)Res_DetachResourceFile, 1, ! "(SInt16 refNum) -> None"}, #endif *************** *** 1660,1674 **** #if TARGET_API_MAC_CARBON {"FSpOpenOrphanResFile", (PyCFunction)Res_FSpOpenOrphanResFile, 1, ! "(FSSpec spec, SignedByte permission) -> (OSErr _rv, SInt16 refNum)"}, #endif #if TARGET_API_MAC_CARBON {"GetTopResourceFile", (PyCFunction)Res_GetTopResourceFile, 1, ! "() -> (OSErr _rv, SInt16 refNum)"}, #endif #if TARGET_API_MAC_CARBON {"GetNextResourceFile", (PyCFunction)Res_GetNextResourceFile, 1, ! "(SInt16 curRefNum) -> (OSErr _rv, SInt16 nextRefNum)"}, #endif {"FSOpenResFile", (PyCFunction)Res_FSOpenResFile, 1, --- 1631,1645 ---- #if TARGET_API_MAC_CARBON {"FSpOpenOrphanResFile", (PyCFunction)Res_FSpOpenOrphanResFile, 1, ! "(FSSpec spec, SignedByte permission) -> (SInt16 refNum)"}, #endif #if TARGET_API_MAC_CARBON {"GetTopResourceFile", (PyCFunction)Res_GetTopResourceFile, 1, ! "() -> (SInt16 refNum)"}, #endif #if TARGET_API_MAC_CARBON {"GetNextResourceFile", (PyCFunction)Res_GetNextResourceFile, 1, ! "(SInt16 curRefNum) -> (SInt16 nextRefNum)"}, #endif {"FSOpenResFile", (PyCFunction)Res_FSOpenResFile, 1, *************** *** 1681,1690 **** #if TARGET_API_MAC_CARBON {"FSCreateResourceFile", (PyCFunction)Res_FSCreateResourceFile, 1, ! "(FSRef parentRef, Buffer nameLength, Buffer forkNameLength) -> (OSErr _rv, FSRef newRef, FSSpec newSpec)"}, #endif #if TARGET_API_MAC_CARBON {"FSOpenResourceFile", (PyCFunction)Res_FSOpenResourceFile, 1, ! "(FSRef ref, Buffer forkNameLength, SignedByte permissions) -> (OSErr _rv, SInt16 refNum)"}, #endif {"Resource", (PyCFunction)Res_Resource, 1, --- 1652,1661 ---- #if TARGET_API_MAC_CARBON {"FSCreateResourceFile", (PyCFunction)Res_FSCreateResourceFile, 1, ! "(FSRef parentRef, Buffer nameLength, Buffer forkNameLength) -> (FSRef newRef, FSSpec newSpec)"}, #endif #if TARGET_API_MAC_CARBON {"FSOpenResourceFile", (PyCFunction)Res_FSOpenResourceFile, 1, ! "(FSRef ref, Buffer forkNameLength, SignedByte permissions) -> (SInt16 refNum)"}, #endif {"Resource", (PyCFunction)Res_Resource, 1, Index: ressupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/res/ressupport.py,v retrieving revision 1.18.4.1 retrieving revision 1.18.4.2 diff -C2 -d -r1.18.4.1 -r1.18.4.2 *** ressupport.py 27 Feb 2002 23:16:52 -0000 1.18.4.1 --- ressupport.py 18 Mar 2002 15:38:24 -0000 1.18.4.2 *************** *** 9,20 **** def checkit(self): ! OutLbrace() ! Output("OSErr _err = ResError();") ! Output("if (_err != noErr) return PyMac_Error(_err);") ! OutRbrace() FunctionGenerator.checkit(self) # XXX ! class ResFunction(ResMixIn, FunctionGenerator): pass ! class ResMethod(ResMixIn, MethodGenerator): pass RsrcChainLocation = Type("RsrcChainLocation", "h") --- 9,21 ---- def checkit(self): ! if self.returntype.__class__ != OSErrType: ! OutLbrace() ! Output("OSErr _err = ResError();") ! Output("if (_err != noErr) return PyMac_Error(_err);") ! OutRbrace() FunctionGenerator.checkit(self) # XXX ! class ResFunction(ResMixIn, OSErrFunctionGenerator): pass ! class ResMethod(ResMixIn, OSErrMethodGenerator): pass RsrcChainLocation = Type("RsrcChainLocation", "h") From jackjansen@users.sourceforge.net Mon Mar 18 15:40:51 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 18 Mar 2002 07:40:51 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/cf _CFmodule.c,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory usw-pr-cvs1:/tmp/cvs-serv11933 Modified Files: _CFmodule.c Log Message: Lurking bug found by patch for 531291: FSSpecs should be passed to Py_BuildValue by address, not by value. 2.2.1 candidate. Index: _CFmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/_CFmodule.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** _CFmodule.c 1 Jan 2002 22:42:47 -0000 1.10 --- _CFmodule.c 18 Mar 2002 15:40:48 -0000 1.11 *************** *** 2792,2796 **** _res = Py_BuildValue("lO&", _rv, ! PyMac_BuildFSRef, fsRef); return _res; } --- 2792,2796 ---- _res = Py_BuildValue("lO&", _rv, ! PyMac_BuildFSRef, &fsRef); return _res; } From jackjansen@users.sourceforge.net Mon Mar 18 15:41:34 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 18 Mar 2002 07:41:34 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/win _Winmodule.c,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/win In directory usw-pr-cvs1:/tmp/cvs-serv12174 Modified Files: _Winmodule.c Log Message: Lurking bug found by patch for 531291: FSSpecs should be passed to Py_BuildValue by address, not by value. 2.2.1 candidate. Index: _Winmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/win/_Winmodule.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** _Winmodule.c 18 Dec 2001 15:36:06 -0000 1.7 --- _Winmodule.c 18 Mar 2002 15:41:32 -0000 1.8 *************** *** 1173,1177 **** if (_err != noErr) return PyMac_Error(_err); _res = Py_BuildValue("O&", ! PyMac_BuildFSSpec, outFile); return _res; } --- 1173,1177 ---- if (_err != noErr) return PyMac_Error(_err); _res = Py_BuildValue("O&", ! PyMac_BuildFSSpec, &outFile); return _res; } From jackjansen@users.sourceforge.net Mon Mar 18 15:54:31 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 18 Mar 2002 07:54:31 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/cf _CFmodule.c,1.9.4.1,1.9.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory usw-pr-cvs1:/tmp/cvs-serv15738/cf Modified Files: Tag: release22-maint _CFmodule.c Log Message: Backport of _CFmodule.c 1.11 and _Winmodule 1.8: Lurking bug found by patch for 531291: FSSpecs should be passed to Py_BuildValue by address, not by value. Index: _CFmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/_CFmodule.c,v retrieving revision 1.9.4.1 retrieving revision 1.9.4.2 diff -C2 -d -r1.9.4.1 -r1.9.4.2 *** _CFmodule.c 27 Feb 2002 23:10:00 -0000 1.9.4.1 --- _CFmodule.c 18 Mar 2002 15:54:29 -0000 1.9.4.2 *************** *** 2792,2796 **** _res = Py_BuildValue("lO&", _rv, ! PyMac_BuildFSRef, fsRef); return _res; } --- 2792,2796 ---- _res = Py_BuildValue("lO&", _rv, ! PyMac_BuildFSRef, &fsRef); return _res; } From jackjansen@users.sourceforge.net Mon Mar 18 15:54:32 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 18 Mar 2002 07:54:32 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/win _Winmodule.c,1.7,1.7.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/win In directory usw-pr-cvs1:/tmp/cvs-serv15738/win Modified Files: Tag: release22-maint _Winmodule.c Log Message: Backport of _CFmodule.c 1.11 and _Winmodule 1.8: Lurking bug found by patch for 531291: FSSpecs should be passed to Py_BuildValue by address, not by value. Index: _Winmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/win/_Winmodule.c,v retrieving revision 1.7 retrieving revision 1.7.4.1 diff -C2 -d -r1.7 -r1.7.4.1 *** _Winmodule.c 18 Dec 2001 15:36:06 -0000 1.7 --- _Winmodule.c 18 Mar 2002 15:54:29 -0000 1.7.4.1 *************** *** 1173,1177 **** if (_err != noErr) return PyMac_Error(_err); _res = Py_BuildValue("O&", ! PyMac_BuildFSSpec, outFile); return _res; } --- 1173,1177 ---- if (_err != noErr) return PyMac_Error(_err); _res = Py_BuildValue("O&", ! PyMac_BuildFSSpec, &outFile); return _res; } From fdrake@users.sourceforge.net Mon Mar 18 16:44:48 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 18 Mar 2002 08:44:48 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libre.tex,1.73.6.4,1.73.6.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv1716/lib Modified Files: Tag: release22-maint libre.tex Log Message: Remove extra verb; reported by Detlef Lannert. Index: libre.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v retrieving revision 1.73.6.4 retrieving revision 1.73.6.5 diff -C2 -d -r1.73.6.4 -r1.73.6.5 *** libre.tex 16 Mar 2002 13:53:23 -0000 1.73.6.4 --- libre.tex 18 Mar 2002 16:44:46 -0000 1.73.6.5 *************** *** 304,309 **** assertions, the contained pattern must only match strings of some fixed length. Patterns which start with negative lookbehind ! assertions will may match at the beginning of the string being ! searched. \end{list} --- 304,308 ---- assertions, the contained pattern must only match strings of some fixed length. Patterns which start with negative lookbehind ! assertions may match at the beginning of the string being searched. \end{list} From fdrake@users.sourceforge.net Mon Mar 18 16:45:03 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 18 Mar 2002 08:45:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libre.tex,1.79,1.80 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv1837/lib Modified Files: libre.tex Log Message: Remove extra verb; reported by Detlef Lannert. Index: libre.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** libre.tex 16 Mar 2002 14:01:12 -0000 1.79 --- libre.tex 18 Mar 2002 16:45:01 -0000 1.80 *************** *** 304,309 **** assertions, the contained pattern must only match strings of some fixed length. Patterns which start with negative lookbehind ! assertions will may match at the beginning of the string being ! searched. \end{list} --- 304,308 ---- assertions, the contained pattern must only match strings of some fixed length. Patterns which start with negative lookbehind ! assertions may match at the beginning of the string being searched. \end{list} From fdrake@users.sourceforge.net Mon Mar 18 16:47:16 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 18 Mar 2002 08:47:16 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref5.tex,1.55,1.56 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv2602/ref Modified Files: ref5.tex Log Message: Fix up unescaped tilde; reported by several people. Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** ref5.tex 16 Mar 2002 06:35:54 -0000 1.55 --- ref5.tex 18 Mar 2002 16:47:14 -0000 1.56 *************** *** 630,634 **** \production{u_expr} {\token{power} | "-" \token{u_expr} ! | "+" \token{u_expr} | "~" \token{u_expr}} \end{productionlist} --- 630,634 ---- \production{u_expr} {\token{power} | "-" \token{u_expr} ! | "+" \token{u_expr} | "{\~}" \token{u_expr}} \end{productionlist} From fdrake@users.sourceforge.net Mon Mar 18 16:47:38 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 18 Mar 2002 08:47:38 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref5.tex,1.53.4.2,1.53.4.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv2707/ref Modified Files: Tag: release22-maint ref5.tex Log Message: Fix up unescaped tilde; reported by several people. Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.53.4.2 retrieving revision 1.53.4.3 diff -C2 -d -r1.53.4.2 -r1.53.4.3 *** ref5.tex 16 Mar 2002 06:35:01 -0000 1.53.4.2 --- ref5.tex 18 Mar 2002 16:47:35 -0000 1.53.4.3 *************** *** 630,634 **** \production{u_expr} {\token{power} | "-" \token{u_expr} ! | "+" \token{u_expr} | "~" \token{u_expr}} \end{productionlist} --- 630,634 ---- \production{u_expr} {\token{power} | "-" \token{u_expr} ! | "+" \token{u_expr} | "{\~}" \token{u_expr}} \end{productionlist} From nascheme@users.sourceforge.net Mon Mar 18 18:12:37 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Mon, 18 Mar 2002 10:12:37 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include objimpl.h,2.44,2.45 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv3488/Include Modified Files: objimpl.h Log Message: Simpilify PyCore_* macros by assuming the function prototypes for malloc() and free() don't change. Index: objimpl.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/objimpl.h,v retrieving revision 2.44 retrieving revision 2.45 diff -C2 -d -r2.44 -r2.45 *** objimpl.h 28 Feb 2002 19:38:51 -0000 2.44 --- objimpl.h 18 Mar 2002 18:12:35 -0000 2.45 *************** *** 78,115 **** #ifdef WITH_PYMALLOC ! #define PyCore_OBJECT_MALLOC_FUNC _PyCore_ObjectMalloc ! #define PyCore_OBJECT_REALLOC_FUNC _PyCore_ObjectRealloc ! #define PyCore_OBJECT_FREE_FUNC _PyCore_ObjectFree ! #define NEED_TO_DECLARE_OBJECT_MALLOC_AND_FRIEND #endif /* !WITH_PYMALLOC */ - #ifndef PyCore_OBJECT_MALLOC_FUNC - #undef PyCore_OBJECT_REALLOC_FUNC - #undef PyCore_OBJECT_FREE_FUNC - #define PyCore_OBJECT_MALLOC_FUNC PyCore_MALLOC_FUNC - #define PyCore_OBJECT_REALLOC_FUNC PyCore_REALLOC_FUNC - #define PyCore_OBJECT_FREE_FUNC PyCore_FREE_FUNC - #endif - - #ifndef PyCore_OBJECT_MALLOC_PROTO - #undef PyCore_OBJECT_REALLOC_PROTO - #undef PyCore_OBJECT_FREE_PROTO - #define PyCore_OBJECT_MALLOC_PROTO PyCore_MALLOC_PROTO - #define PyCore_OBJECT_REALLOC_PROTO PyCore_REALLOC_PROTO - #define PyCore_OBJECT_FREE_PROTO PyCore_FREE_PROTO - #endif - - #ifdef NEED_TO_DECLARE_OBJECT_MALLOC_AND_FRIEND - extern void *PyCore_OBJECT_MALLOC_FUNC PyCore_OBJECT_MALLOC_PROTO; - extern void *PyCore_OBJECT_REALLOC_FUNC PyCore_OBJECT_REALLOC_PROTO; - extern void PyCore_OBJECT_FREE_FUNC PyCore_OBJECT_FREE_PROTO; - #endif - #ifndef PyCore_OBJECT_MALLOC #undef PyCore_OBJECT_REALLOC #undef PyCore_OBJECT_FREE ! #define PyCore_OBJECT_MALLOC(n) PyCore_OBJECT_MALLOC_FUNC(n) ! #define PyCore_OBJECT_REALLOC(p, n) PyCore_OBJECT_REALLOC_FUNC((p), (n)) ! #define PyCore_OBJECT_FREE(p) PyCore_OBJECT_FREE_FUNC(p) #endif --- 78,95 ---- #ifdef WITH_PYMALLOC ! void *_PyCore_ObjectMalloc(size_t nbytes); ! void *_PyCore_ObjectRealloc(void *p, size_t nbytes); ! void _PyCore_ObjectFree(void *p); ! #define PyCore_OBJECT_MALLOC _PyCore_ObjectMalloc ! #define PyCore_OBJECT_REALLOC _PyCore_ObjectRealloc ! #define PyCore_OBJECT_FREE _PyCore_ObjectFree #endif /* !WITH_PYMALLOC */ #ifndef PyCore_OBJECT_MALLOC #undef PyCore_OBJECT_REALLOC #undef PyCore_OBJECT_FREE ! #define PyCore_OBJECT_MALLOC(n) PyCore_MALLOC(n) ! #define PyCore_OBJECT_REALLOC(p, n) PyCore_REALLOC((p), (n)) ! #define PyCore_OBJECT_FREE(p) PyCore_FREE(p) #endif From nascheme@users.sourceforge.net Mon Mar 18 18:13:00 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Mon, 18 Mar 2002 10:13:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include pymem.h,2.5,2.6 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv3669/Include Modified Files: pymem.h Log Message: Simpilify PyCore_* macros by assuming the function prototypes for malloc() and free() don't change. Index: pymem.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pymem.h,v retrieving revision 2.5 retrieving revision 2.6 diff -C2 -d -r2.5 -r2.6 *** pymem.h 2 Mar 2002 08:43:19 -0000 2.5 --- pymem.h 18 Mar 2002 18:12:58 -0000 2.6 *************** *** 21,57 **** The PyCore_* macros can be defined to make the interpreter use a custom allocator. Note that they are for internal use only. Both ! the core and extension modules should use the PyMem_* API. ! ! See the comment block at the end of this file for two scenarios ! showing how to use this to use a different allocator. */ ! ! #ifndef PyCore_MALLOC_FUNC ! #undef PyCore_REALLOC_FUNC ! #undef PyCore_FREE_FUNC ! #define PyCore_MALLOC_FUNC malloc ! #define PyCore_REALLOC_FUNC realloc ! #define PyCore_FREE_FUNC free ! #endif ! ! #ifndef PyCore_MALLOC_PROTO ! #undef PyCore_REALLOC_PROTO ! #undef PyCore_FREE_PROTO ! #define PyCore_MALLOC_PROTO (size_t) ! #define PyCore_REALLOC_PROTO (void *, size_t) ! #define PyCore_FREE_PROTO (void *) ! #endif ! ! #ifdef NEED_TO_DECLARE_MALLOC_AND_FRIEND ! extern void *PyCore_MALLOC_FUNC PyCore_MALLOC_PROTO; ! extern void *PyCore_REALLOC_FUNC PyCore_REALLOC_PROTO; ! extern void PyCore_FREE_FUNC PyCore_FREE_PROTO; ! #endif #ifndef PyCore_MALLOC #undef PyCore_REALLOC #undef PyCore_FREE ! #define PyCore_MALLOC(n) PyCore_MALLOC_FUNC(n) ! #define PyCore_REALLOC(p, n) PyCore_REALLOC_FUNC((p), (n)) ! #define PyCore_FREE(p) PyCore_FREE_FUNC(p) #endif --- 21,32 ---- The PyCore_* macros can be defined to make the interpreter use a custom allocator. Note that they are for internal use only. Both ! the core and extension modules should use the PyMem_* API. */ #ifndef PyCore_MALLOC #undef PyCore_REALLOC #undef PyCore_FREE ! #define PyCore_MALLOC(n) malloc(n) ! #define PyCore_REALLOC(p, n) realloc((p), (n)) ! #define PyCore_FREE(p) free(p) #endif *************** *** 133,175 **** } #endif - - /* SCENARIOS - - Here are two scenarios by Vladimir Marangozov (the author of the - memory allocation redesign). - - 1) Scenario A - - Suppose you want to use a debugging malloc library that collects info on - where the malloc calls originate from. Assume the interface is: - - d_malloc(size_t n, char* src_file, unsigned long src_line) c.s. - - In this case, you would define (for example in pyconfig.h) : - - #define PyCore_MALLOC_FUNC d_malloc - ... - #define PyCore_MALLOC_PROTO (size_t, char *, unsigned long) - ... - #define NEED_TO_DECLARE_MALLOC_AND_FRIEND - - #define PyCore_MALLOC(n) PyCore_MALLOC_FUNC((n), __FILE__, __LINE__) - ... - - 2) Scenario B - - Suppose you want to use malloc hooks (defined & initialized in a 3rd party - malloc library) instead of malloc functions. In this case, you would - define: - - #define PyCore_MALLOC_FUNC (*malloc_hook) - ... - #define NEED_TO_DECLARE_MALLOC_AND_FRIEND - - and ignore the previous definitions about PyCore_MALLOC_FUNC, etc. - - - */ - #endif /* !Py_PYMEM_H */ --- 108,111 ---- From nascheme@users.sourceforge.net Mon Mar 18 18:13:44 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Mon, 18 Mar 2002 10:13:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.2,2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv3957/Objects Modified Files: obmalloc.c Log Message: Simpilify PyCore_* macros by assuming the function prototypes for malloc() and free() don't change. Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -d -r2.2 -r2.3 *** obmalloc.c 11 Mar 2001 18:36:13 -0000 2.2 --- obmalloc.c 18 Mar 2002 18:13:41 -0000 2.3 *************** *** 55,94 **** /* - * Public functions exported by this allocator. - * - * -- Define and use these names in your code to obtain or release memory -- - */ - #define _THIS_MALLOC PyCore_OBJECT_MALLOC_FUNC - #define _THIS_CALLOC /* unused */ - #define _THIS_REALLOC PyCore_OBJECT_REALLOC_FUNC - #define _THIS_FREE PyCore_OBJECT_FREE_FUNC - - /* - * Underlying allocator's functions called by this allocator. - * The underlying allocator is usually the one which comes with libc. - * - * -- Don't use these functions in your code (to avoid mixing allocators) -- - * - * Redefine these __only__ if you are using a 3rd party general purpose - * allocator which exports functions with names _other_ than the standard - * malloc, calloc, realloc, free. - */ - #define _SYSTEM_MALLOC PyCore_MALLOC_FUNC - #define _SYSTEM_CALLOC /* unused */ - #define _SYSTEM_REALLOC PyCore_REALLOC_FUNC - #define _SYSTEM_FREE PyCore_FREE_FUNC - - /* - * If malloc hooks are needed, names of the hooks' set & fetch - * functions exported by this allocator. - */ - #ifdef WITH_MALLOC_HOOKS - #define _SET_HOOKS _PyCore_ObjectMalloc_SetHooks - #define _FETCH_HOOKS _PyCore_ObjectMalloc_FetchHooks - #endif - - /*==========================================================================*/ - - /* * Allocation strategy abstract: * --- 55,58 ---- *************** *** 386,390 **** void * ! _THIS_MALLOC(size_t nbytes) { block *bp; --- 350,354 ---- void * ! _PyCore_ObjectMalloc(size_t nbytes) { block *bp; *************** *** 516,520 **** * per arena due to the required alignment on page boundaries. */ ! bp = (block *)_SYSTEM_MALLOC(ARENA_SIZE + SYSTEM_PAGE_SIZE); if (bp == NULL) { UNLOCK(); --- 480,484 ---- * per arena due to the required alignment on page boundaries. */ ! bp = (block *)PyCore_MALLOC(ARENA_SIZE + SYSTEM_PAGE_SIZE); if (bp == NULL) { UNLOCK(); *************** *** 547,551 **** * has been reached. */ ! return (void *)_SYSTEM_MALLOC(nbytes); } --- 511,515 ---- * has been reached. */ ! return (void *)PyCore_MALLOC(nbytes); } *************** *** 553,557 **** void ! _THIS_FREE(void *p) { poolp pool; --- 517,521 ---- void ! _PyCore_ObjectFree(void *p) { poolp pool; *************** *** 573,577 **** pool = (poolp )((block *)p - offset); if (pool->pooladdr != pool || pool->magic != (uint )POOL_MAGIC) { ! _SYSTEM_FREE(p); return; } --- 537,541 ---- pool = (poolp )((block *)p - offset); if (pool->pooladdr != pool || pool->magic != (uint )POOL_MAGIC) { ! PyCore_FREE(p); return; } *************** *** 632,636 **** void * ! _THIS_REALLOC(void *p, size_t nbytes) { block *bp; --- 596,600 ---- void * ! _PyCore_ObjectRealloc(void *p, size_t nbytes) { block *bp; *************** *** 644,648 **** if (p == NULL) ! return _THIS_MALLOC(nbytes); /* realloc(p, 0) on big blocks is redirected. */ --- 608,612 ---- if (p == NULL) ! return _PyCore_ObjectMalloc(nbytes); /* realloc(p, 0) on big blocks is redirected. */ *************** *** 655,659 **** goto malloc_copy_free; } ! bp = (block *)_SYSTEM_REALLOC(p, nbytes); } else { --- 619,623 ---- goto malloc_copy_free; } ! bp = (block *)PyCore_REALLOC(p, nbytes); } else { *************** *** 664,668 **** except for realloc(p, 0) == free(p), ret NULL */ if (nbytes == 0) { ! _THIS_FREE(p); bp = NULL; } --- 628,632 ---- except for realloc(p, 0) == free(p), ret NULL */ if (nbytes == 0) { ! _PyCore_ObjectFree(p); bp = NULL; } *************** *** 674,681 **** malloc_copy_free: ! bp = (block *)_THIS_MALLOC(nbytes); if (bp != NULL) { memcpy(bp, p, size); ! _THIS_FREE(p); } } --- 638,645 ---- malloc_copy_free: ! bp = (block *)_PyCore_ObjectMalloc(nbytes); if (bp != NULL) { memcpy(bp, p, size); ! _PyCore_ObjectFree(p); } } *************** *** 688,692 **** /* -- unused -- void * ! _THIS_CALLOC(size_t nbel, size_t elsz) { void *p; --- 652,656 ---- /* -- unused -- void * ! _PyCore_ObjectCalloc(size_t nbel, size_t elsz) { void *p; *************** *** 699,703 **** nbytes = nbel * elsz; ! p = _THIS_MALLOC(nbytes); if (p != NULL) memset(p, 0, nbytes); --- 663,667 ---- nbytes = nbel * elsz; ! p = _PyCore_ObjectMalloc(nbytes); if (p != NULL) memset(p, 0, nbytes); *************** *** 715,722 **** void ! _SET_HOOKS( void *(*malloc_func)(size_t), ! void *(*calloc_func)(size_t, size_t), ! void *(*realloc_func)(void *, size_t), ! void (*free_func)(void *) ) { LOCK(); --- 679,686 ---- void ! _PyCore_ObjectMalloc_SetHooks( void *(*malloc_func)(size_t), ! void *(*calloc_func)(size_t, size_t), ! void *(*realloc_func)(void *, size_t), ! void (*free_func)(void *) ) { LOCK(); *************** *** 729,736 **** void ! _FETCH_HOOKS( void *(**malloc_funcp)(size_t), ! void *(**calloc_funcp)(size_t, size_t), ! void *(**realloc_funcp)(void *, size_t), ! void (**free_funcp)(void *) ) { LOCK(); --- 693,700 ---- void ! _PyCore_ObjectMalloc_FetchHooks( void *(**malloc_funcp)(size_t), ! void *(**calloc_funcp)(size_t, size_t), ! void *(**realloc_funcp)(void *, size_t), ! void (**free_funcp)(void *) ) { LOCK(); From bwarsaw@users.sourceforge.net Mon Mar 18 18:53:58 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Mon, 18 Mar 2002 10:53:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc python-mode.el,4.7,4.8 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv20440 Modified Files: python-mode.el Log Message: (py-temp-directory): Add /var/tmp to the list of directories this searches. This is added after /tmp. Closes SF bug #505488, except that /var/tmp comes after /tmp instead of the patch's suggestion of putting it before /usr/tmp. Index: python-mode.el =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/python-mode.el,v retrieving revision 4.7 retrieving revision 4.8 diff -C2 -d -r4.7 -r4.8 *** python-mode.el 15 Mar 2002 16:46:46 -0000 4.7 --- python-mode.el 18 Mar 2002 18:53:56 -0000 4.8 *************** *** 205,215 **** (funcall ok "/usr/tmp") (funcall ok "/tmp") (funcall ok ".") (error "Couldn't find a usable temp directory -- set `py-temp-directory'"))) ! "*Directory used for temp files created by a *Python* process. By default, the first directory from this list that exists and that you ! can write into: the value (if any) of the environment variable TMPDIR, ! /usr/tmp, /tmp, or the current directory." :type 'string :group 'python) --- 205,216 ---- (funcall ok "/usr/tmp") (funcall ok "/tmp") + (funcall ok "/var/tmp") (funcall ok ".") (error "Couldn't find a usable temp directory -- set `py-temp-directory'"))) ! "*Directory used for temporary files created by a *Python* process. By default, the first directory from this list that exists and that you ! can write into: the value (if any) of the environment variable TMPDIR, ! /usr/tmp, /tmp, /var/tmp, or the current directory." :type 'string :group 'python) From nnorwitz@users.sourceforge.net Mon Mar 18 18:46:16 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Mon, 18 Mar 2002 10:46:16 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules sre.h,2.21,2.22 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv18136/Modules Modified Files: sre.h Log Message: Remove extraneous #define as per effbot's instructions in: [ 530285 ] redefining SRE_CODE in Modules/sre.h Index: sre.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre.h,v retrieving revision 2.21 retrieving revision 2.22 diff -C2 -d -r2.21 -r2.22 *** sre.h 2 Jul 2001 16:42:49 -0000 2.21 --- sre.h 18 Mar 2002 18:46:14 -0000 2.22 *************** *** 22,27 **** #endif - #define SRE_CODE unsigned short - typedef struct { PyObject_VAR_HEAD --- 22,25 ---- From nascheme@users.sourceforge.net Mon Mar 18 21:04:30 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Mon, 18 Mar 2002 13:04:30 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include objimpl.h,2.45,2.46 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv30988/Include Modified Files: objimpl.h Log Message: Drop the PyCore_* memory API. Index: objimpl.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/objimpl.h,v retrieving revision 2.45 retrieving revision 2.46 diff -C2 -d -r2.45 -r2.46 *** objimpl.h 18 Mar 2002 18:12:35 -0000 2.45 --- objimpl.h 18 Mar 2002 21:04:28 -0000 2.46 *************** *** 58,98 **** /* - * Core object memory allocator - * ============================ - */ - - /* The purpose of the object allocator is to make the distinction - between "object memory" and the rest within the Python heap. - - Object memory is the one allocated by PyObject_{New, NewVar}, i.e. - the one that holds the object's representation defined by its C - type structure, *excluding* any object-specific memory buffers that - might be referenced by the structure (for type structures that have - pointer fields). By default, the object memory allocator is - implemented on top of the raw memory allocator. - - The PyCore_* macros can be defined to make the interpreter use a - custom object memory allocator. They are reserved for internal - memory management purposes exclusively. Both the core and extension - modules should use the PyObject_* API. */ - - #ifdef WITH_PYMALLOC - void *_PyCore_ObjectMalloc(size_t nbytes); - void *_PyCore_ObjectRealloc(void *p, size_t nbytes); - void _PyCore_ObjectFree(void *p); - #define PyCore_OBJECT_MALLOC _PyCore_ObjectMalloc - #define PyCore_OBJECT_REALLOC _PyCore_ObjectRealloc - #define PyCore_OBJECT_FREE _PyCore_ObjectFree - #endif /* !WITH_PYMALLOC */ - - #ifndef PyCore_OBJECT_MALLOC - #undef PyCore_OBJECT_REALLOC - #undef PyCore_OBJECT_FREE - #define PyCore_OBJECT_MALLOC(n) PyCore_MALLOC(n) - #define PyCore_OBJECT_REALLOC(p, n) PyCore_REALLOC((p), (n)) - #define PyCore_OBJECT_FREE(p) PyCore_FREE(p) - #endif - - /* * Raw object memory interface * =========================== --- 58,61 ---- *************** *** 112,120 **** /* Functions */ ! /* Wrappers around PyCore_OBJECT_MALLOC and friends; useful if you ! need to be sure that you are using the same object memory allocator ! as Python. These wrappers *do not* make sure that allocating 0 ! bytes returns a non-NULL pointer. Returned pointers must be checked ! for NULL explicitly; no action is performed on failure. */ extern DL_IMPORT(void *) PyObject_Malloc(size_t); extern DL_IMPORT(void *) PyObject_Realloc(void *, size_t); --- 75,83 ---- /* Functions */ ! /* Wrappers that useful if you need to be sure that you are using the ! same object memory allocator as Python. These wrappers *do not* make ! sure that allocating 0 bytes returns a non-NULL pointer. Returned ! pointers must be checked for NULL explicitly; no action is performed ! on failure. */ extern DL_IMPORT(void *) PyObject_Malloc(size_t); extern DL_IMPORT(void *) PyObject_Realloc(void *, size_t); *************** *** 122,128 **** /* Macros */ ! #define PyObject_MALLOC(n) PyCore_OBJECT_MALLOC(n) ! #define PyObject_REALLOC(op, n) PyCore_OBJECT_REALLOC((void *)(op), (n)) ! #define PyObject_FREE(op) PyCore_OBJECT_FREE((void *)(op)) /* --- 85,91 ---- /* Macros */ ! #define PyObject_MALLOC(n) _PyMalloc_MALLOC(n) ! #define PyObject_REALLOC(op, n) _PyMalloc_REALLOC((void *)(op), (n)) ! #define PyObject_FREE(op) _PyMalloc_FREE((void *)(op)) /* From nascheme@users.sourceforge.net Mon Mar 18 21:04:56 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Mon, 18 Mar 2002 13:04:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include pymem.h,2.6,2.7 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv31099/Include Modified Files: pymem.h Log Message: Drop the PyCore_* memory API. Index: pymem.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pymem.h,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -d -r2.6 -r2.7 *** pymem.h 18 Mar 2002 18:12:58 -0000 2.6 --- pymem.h 18 Mar 2002 21:04:54 -0000 2.7 *************** *** 11,34 **** #endif - /* - * Core memory allocator - * ===================== - */ - - /* To make sure the interpreter is user-malloc friendly, all memory - APIs are implemented on top of this one. - - The PyCore_* macros can be defined to make the interpreter use a - custom allocator. Note that they are for internal use only. Both - the core and extension modules should use the PyMem_* API. */ - - #ifndef PyCore_MALLOC - #undef PyCore_REALLOC - #undef PyCore_FREE - #define PyCore_MALLOC(n) malloc(n) - #define PyCore_REALLOC(p, n) realloc((p), (n)) - #define PyCore_FREE(p) free(p) - #endif - /* BEWARE: --- 11,14 ---- *************** *** 52,58 **** */ /* Functions */ ! /* Function wrappers around PyCore_MALLOC and friends; useful if you need to be sure that you are using the same memory allocator as Python. Note that the wrappers make sure that allocating 0 bytes --- 32,41 ---- */ + /* To make sure the interpreter is user-malloc friendly, all memory + APIs are implemented on top of this one. */ + /* Functions */ ! /* Function wrappers around PyMem_MALLOC and friends; useful if you need to be sure that you are using the same memory allocator as Python. Note that the wrappers make sure that allocating 0 bytes *************** *** 67,74 **** no longer supported. They used to call PyErr_NoMemory() on failure. */ ! /* Macros */ ! #define PyMem_MALLOC(n) PyCore_MALLOC(n) ! #define PyMem_REALLOC(p, n) PyCore_REALLOC((void *)(p), (n)) ! #define PyMem_FREE(p) PyCore_FREE((void *)(p)) /* --- 50,59 ---- no longer supported. They used to call PyErr_NoMemory() on failure. */ ! /* Macros (override these if you want to a different malloc */ ! #ifndef PyMem_MALLOC ! #define PyMem_MALLOC(n) malloc(n) ! #define PyMem_REALLOC(p, n) realloc((void *)(p), (n)) ! #define PyMem_FREE(p) free((void *)(p)) ! #endif /* *************** *** 104,107 **** --- 89,108 ---- it is recommended to write the test explicitly in the code. Note that according to ANSI C, free(NULL) has no effect. */ + + + /* pymalloc (private to the interpreter) */ + #ifdef WITH_PYMALLOC + void *_PyMalloc_Malloc(size_t nbytes); + void *_PyMalloc_Realloc(void *p, size_t nbytes); + void _PyMalloc_Free(void *p); + #define _PyMalloc_MALLOC _PyMalloc_Malloc + #define _PyMalloc_REALLOC _PyMalloc_Realloc + #define _PyMalloc_FREE _PyMalloc_Free + #else + #define _PyMalloc_MALLOC PyMem_MALLOC + #define _PyMalloc_REALLOC PyMem_REALLOC + #define _PyMalloc_FREE PyMem_FREE + #endif + #ifdef __cplusplus From nascheme@users.sourceforge.net Mon Mar 18 21:06:00 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Mon, 18 Mar 2002 13:06:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects object.c,2.165,2.166 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv31484/Objects Modified Files: object.c Log Message: Drop the PyCore_* memory API. Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.165 retrieving revision 2.166 diff -C2 -d -r2.165 -r2.166 *** object.c 15 Mar 2002 13:40:30 -0000 2.165 --- object.c 18 Mar 2002 21:05:57 -0000 2.166 *************** *** 2094,2096 **** #ifdef WITH_PYMALLOC #include "obmalloc.c" ! #endif --- 2094,2111 ---- #ifdef WITH_PYMALLOC #include "obmalloc.c" ! #else ! void *_PyMalloc_Malloc(size_t n) ! { ! return PyMem_MALLOC(n); ! } ! ! void *_PyMalloc_Realloc(void *p, size_t n) ! { ! return PyMem_REALLOC(p, n); ! } ! ! void _PyMalloc_Free(void *p) ! { ! PyMem_FREE(p); ! } ! #endif /* !WITH_PYMALLOC */ From nascheme@users.sourceforge.net Mon Mar 18 21:06:23 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Mon, 18 Mar 2002 13:06:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.3,2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv31647/Objects Modified Files: obmalloc.c Log Message: Drop the PyCore_* memory API. Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -d -r2.3 -r2.4 *** obmalloc.c 18 Mar 2002 18:13:41 -0000 2.3 --- obmalloc.c 18 Mar 2002 21:06:21 -0000 2.4 *************** *** 350,354 **** void * ! _PyCore_ObjectMalloc(size_t nbytes) { block *bp; --- 350,354 ---- void * ! _PyMalloc_Malloc(size_t nbytes) { block *bp; *************** *** 480,484 **** * per arena due to the required alignment on page boundaries. */ ! bp = (block *)PyCore_MALLOC(ARENA_SIZE + SYSTEM_PAGE_SIZE); if (bp == NULL) { UNLOCK(); --- 480,484 ---- * per arena due to the required alignment on page boundaries. */ ! bp = (block *)PyMem_MALLOC(ARENA_SIZE + SYSTEM_PAGE_SIZE); if (bp == NULL) { UNLOCK(); *************** *** 511,515 **** * has been reached. */ ! return (void *)PyCore_MALLOC(nbytes); } --- 511,515 ---- * has been reached. */ ! return (void *)PyMem_MALLOC(nbytes); } *************** *** 517,521 **** void ! _PyCore_ObjectFree(void *p) { poolp pool; --- 517,521 ---- void ! _PyMalloc_Free(void *p) { poolp pool; *************** *** 537,541 **** pool = (poolp )((block *)p - offset); if (pool->pooladdr != pool || pool->magic != (uint )POOL_MAGIC) { ! PyCore_FREE(p); return; } --- 537,541 ---- pool = (poolp )((block *)p - offset); if (pool->pooladdr != pool || pool->magic != (uint )POOL_MAGIC) { ! PyMem_FREE(p); return; } *************** *** 596,600 **** void * ! _PyCore_ObjectRealloc(void *p, size_t nbytes) { block *bp; --- 596,600 ---- void * ! _PyMalloc_Realloc(void *p, size_t nbytes) { block *bp; *************** *** 608,612 **** if (p == NULL) ! return _PyCore_ObjectMalloc(nbytes); /* realloc(p, 0) on big blocks is redirected. */ --- 608,612 ---- if (p == NULL) ! return _PyMalloc_Malloc(nbytes); /* realloc(p, 0) on big blocks is redirected. */ *************** *** 619,623 **** goto malloc_copy_free; } ! bp = (block *)PyCore_REALLOC(p, nbytes); } else { --- 619,623 ---- goto malloc_copy_free; } ! bp = (block *)PyMem_REALLOC(p, nbytes); } else { *************** *** 628,632 **** except for realloc(p, 0) == free(p), ret NULL */ if (nbytes == 0) { ! _PyCore_ObjectFree(p); bp = NULL; } --- 628,632 ---- except for realloc(p, 0) == free(p), ret NULL */ if (nbytes == 0) { ! _PyMalloc_Free(p); bp = NULL; } *************** *** 638,645 **** malloc_copy_free: ! bp = (block *)_PyCore_ObjectMalloc(nbytes); if (bp != NULL) { memcpy(bp, p, size); ! _PyCore_ObjectFree(p); } } --- 638,645 ---- malloc_copy_free: ! bp = (block *)_PyMalloc_Malloc(nbytes); if (bp != NULL) { memcpy(bp, p, size); ! _PyMalloc_Free(p); } } *************** *** 652,656 **** /* -- unused -- void * ! _PyCore_ObjectCalloc(size_t nbel, size_t elsz) { void *p; --- 652,656 ---- /* -- unused -- void * ! _PyMalloc_Calloc(size_t nbel, size_t elsz) { void *p; *************** *** 663,667 **** nbytes = nbel * elsz; ! p = _PyCore_ObjectMalloc(nbytes); if (p != NULL) memset(p, 0, nbytes); --- 663,667 ---- nbytes = nbel * elsz; ! p = _PyMalloc_Malloc(nbytes); if (p != NULL) memset(p, 0, nbytes); *************** *** 679,686 **** void ! _PyCore_ObjectMalloc_SetHooks( void *(*malloc_func)(size_t), ! void *(*calloc_func)(size_t, size_t), ! void *(*realloc_func)(void *, size_t), ! void (*free_func)(void *) ) { LOCK(); --- 679,686 ---- void ! _PyMalloc_SetHooks( void *(*malloc_func)(size_t), ! void *(*calloc_func)(size_t, size_t), ! void *(*realloc_func)(void *, size_t), ! void (*free_func)(void *) ) { LOCK(); *************** *** 693,700 **** void ! _PyCore_ObjectMalloc_FetchHooks( void *(**malloc_funcp)(size_t), ! void *(**calloc_funcp)(size_t, size_t), ! void *(**realloc_funcp)(void *, size_t), ! void (**free_funcp)(void *) ) { LOCK(); --- 693,700 ---- void ! _PyMalloc_FetchHooks( void *(**malloc_funcp)(size_t), ! void *(**calloc_funcp)(size_t, size_t), ! void *(**realloc_funcp)(void *, size_t), ! void (**free_funcp)(void *) ) { LOCK(); From nascheme@users.sourceforge.net Mon Mar 18 20:45:12 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Mon, 18 Mar 2002 12:45:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python ceval.c,2.305,2.306 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv24763/Python Modified Files: ceval.c Log Message: Re-enable GC of generator objects. Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.305 retrieving revision 2.306 diff -C2 -d -r2.305 -r2.306 *** ceval.c 17 Feb 2002 19:10:14 -0000 2.305 --- ceval.c 18 Mar 2002 20:45:09 -0000 2.306 *************** *** 101,105 **** gen_new(PyFrameObject *f) { ! genobject *gen = PyObject_New(genobject, &gentype); if (gen == NULL) { Py_DECREF(f); --- 101,105 ---- gen_new(PyFrameObject *f) { ! genobject *gen = PyObject_GC_New(genobject, &gentype); if (gen == NULL) { Py_DECREF(f); *************** *** 108,112 **** gen->gi_frame = f; gen->gi_running = 0; ! PyObject_GC_Init(gen); return (PyObject *)gen; } --- 108,112 ---- gen->gi_frame = f; gen->gi_running = 0; ! _PyObject_GC_TRACK(gen); return (PyObject *)gen; } *************** *** 121,127 **** gen_dealloc(genobject *gen) { ! PyObject_GC_Fini(gen); Py_DECREF(gen->gi_frame); ! PyObject_Del(gen); } --- 121,127 ---- gen_dealloc(genobject *gen) { ! _PyObject_GC_UNTRACK(gen); Py_DECREF(gen->gi_frame); ! PyObject_GC_Del(gen); } *************** *** 205,209 **** 0, /* ob_size */ "generator", /* tp_name */ ! sizeof(genobject) + PyGC_HEAD_SIZE, /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ --- 205,209 ---- 0, /* ob_size */ "generator", /* tp_name */ ! sizeof(genobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ *************** *** 223,227 **** 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /* tp_flags */ 0, /* tp_doc */ (traverseproc)gen_traverse, /* tp_traverse */ --- 223,227 ---- 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ 0, /* tp_doc */ (traverseproc)gen_traverse, /* tp_traverse */ From nascheme@users.sourceforge.net Mon Mar 18 20:43:56 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Mon, 18 Mar 2002 12:43:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects iterobject.c,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv24270/Objects Modified Files: iterobject.c Log Message: Re-enable GC of iter objects. Index: iterobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/iterobject.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** iterobject.c 16 Aug 2001 13:15:00 -0000 1.7 --- iterobject.c 18 Mar 2002 20:43:51 -0000 1.8 *************** *** 13,17 **** { seqiterobject *it; ! it = PyObject_NEW(seqiterobject, &PySeqIter_Type); if (it == NULL) return NULL; --- 13,17 ---- { seqiterobject *it; ! it = PyObject_GC_New(seqiterobject, &PySeqIter_Type); if (it == NULL) return NULL; *************** *** 19,23 **** Py_INCREF(seq); it->it_seq = seq; ! PyObject_GC_Init(it); return (PyObject *)it; } --- 19,23 ---- Py_INCREF(seq); it->it_seq = seq; ! _PyObject_GC_TRACK(it); return (PyObject *)it; } *************** *** 25,32 **** iter_dealloc(seqiterobject *it) { ! PyObject_GC_Fini(it); Py_DECREF(it->it_seq); ! it = (seqiterobject *) PyObject_AS_GC(it); ! PyObject_DEL(it); } --- 25,31 ---- iter_dealloc(seqiterobject *it) { ! _PyObject_GC_UNTRACK(it); Py_DECREF(it->it_seq); ! PyObject_GC_Del(it); } *************** *** 101,105 **** 0, /* ob_size */ "iterator", /* tp_name */ ! sizeof(seqiterobject) + PyGC_HEAD_SIZE, /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ --- 100,104 ---- 0, /* ob_size */ "iterator", /* tp_name */ ! sizeof(seqiterobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ *************** *** 119,123 **** 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /* tp_flags */ 0, /* tp_doc */ (traverseproc)iter_traverse, /* tp_traverse */ --- 118,122 ---- 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ 0, /* tp_doc */ (traverseproc)iter_traverse, /* tp_traverse */ *************** *** 148,152 **** { calliterobject *it; ! it = PyObject_NEW(calliterobject, &PyCallIter_Type); if (it == NULL) return NULL; --- 147,151 ---- { calliterobject *it; ! it = PyObject_GC_New(calliterobject, &PyCallIter_Type); if (it == NULL) return NULL; *************** *** 155,159 **** Py_INCREF(sentinel); it->it_sentinel = sentinel; ! PyObject_GC_Init(it); return (PyObject *)it; } --- 154,158 ---- Py_INCREF(sentinel); it->it_sentinel = sentinel; ! _PyObject_GC_TRACK(it); return (PyObject *)it; } *************** *** 161,169 **** calliter_dealloc(calliterobject *it) { ! PyObject_GC_Fini(it); Py_DECREF(it->it_callable); Py_DECREF(it->it_sentinel); ! it = (calliterobject *) PyObject_AS_GC(it); ! PyObject_DEL(it); } --- 160,167 ---- calliter_dealloc(calliterobject *it) { ! _PyObject_GC_UNTRACK(it); Py_DECREF(it->it_callable); Py_DECREF(it->it_sentinel); ! PyObject_GC_Del(it); } *************** *** 219,223 **** 0, /* ob_size */ "callable-iterator", /* tp_name */ ! sizeof(calliterobject) + PyGC_HEAD_SIZE,/* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ --- 217,221 ---- 0, /* ob_size */ "callable-iterator", /* tp_name */ ! sizeof(calliterobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ *************** *** 237,241 **** 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /* tp_flags */ 0, /* tp_doc */ (traverseproc)calliter_traverse, /* tp_traverse */ --- 235,239 ---- 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ 0, /* tp_doc */ (traverseproc)calliter_traverse, /* tp_traverse */ From nascheme@users.sourceforge.net Mon Mar 18 20:44:56 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Mon, 18 Mar 2002 12:44:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects methodobject.c,2.40,2.41 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv24651/Objects Modified Files: methodobject.c Log Message: Re-enable GC of method objects. Index: methodobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/methodobject.c,v retrieving revision 2.40 retrieving revision 2.41 diff -C2 -d -r2.40 -r2.41 *** methodobject.c 20 Sep 2001 21:45:26 -0000 2.40 --- methodobject.c 18 Mar 2002 20:44:53 -0000 2.41 *************** *** 16,20 **** } else { ! op = PyObject_NEW(PyCFunctionObject, &PyCFunction_Type); if (op == NULL) return NULL; --- 16,20 ---- } else { ! op = PyObject_GC_New(PyCFunctionObject, &PyCFunction_Type); if (op == NULL) return NULL; *************** *** 23,27 **** Py_XINCREF(self); op->m_self = self; ! PyObject_GC_Init(op); return (PyObject *)op; } --- 23,27 ---- Py_XINCREF(self); op->m_self = self; ! _PyObject_GC_TRACK(op); return (PyObject *)op; } *************** *** 112,116 **** meth_dealloc(PyCFunctionObject *m) { ! PyObject_GC_Fini(m); Py_XDECREF(m->m_self); m->m_self = (PyObject *)free_list; --- 112,116 ---- meth_dealloc(PyCFunctionObject *m) { ! _PyObject_GC_UNTRACK(m); Py_XDECREF(m->m_self); m->m_self = (PyObject *)free_list; *************** *** 217,221 **** 0, "builtin_function_or_method", ! sizeof(PyCFunctionObject) + PyGC_HEAD_SIZE, 0, (destructor)meth_dealloc, /* tp_dealloc */ --- 217,221 ---- 0, "builtin_function_or_method", ! sizeof(PyCFunctionObject), 0, (destructor)meth_dealloc, /* tp_dealloc */ *************** *** 234,238 **** 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /* tp_flags */ 0, /* tp_doc */ (traverseproc)meth_traverse, /* tp_traverse */ --- 234,238 ---- 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ 0, /* tp_doc */ (traverseproc)meth_traverse, /* tp_traverse */ *************** *** 328,333 **** PyCFunctionObject *v = free_list; free_list = (PyCFunctionObject *)(v->m_self); ! v = (PyCFunctionObject *) PyObject_AS_GC(v); ! PyObject_DEL(v); } } --- 328,332 ---- PyCFunctionObject *v = free_list; free_list = (PyCFunctionObject *)(v->m_self); ! PyObject_GC_Del(v); } } From effbot@users.sourceforge.net Mon Mar 18 21:43:06 2002 From: effbot@users.sourceforge.net (Fredrik Lundh) Date: Mon, 18 Mar 2002 13:43:06 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/idle/Icons minusnode.gif,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/idle/Icons In directory usw-pr-cvs1:/tmp/cvs-serv10229/Tools/idle/Icons Modified Files: minusnode.gif Log Message: use -kb on idle/Icons/minusnode.gif ("cvs up" kept checking it out all the time...) Index: minusnode.gif =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/idle/Icons/minusnode.gif,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 Binary files /tmp/cvsCBqfh0 and /tmp/cvsGCDEpQ differ From akuchling@users.sourceforge.net Mon Mar 18 22:19:26 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Mon, 18 Mar 2002 14:19:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib urllib.py,1.135,1.135.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv23174 Modified Files: Tag: release22-maint urllib.py Log Message: To make 'urllib.py -t' run again, change FTP URL to a file that actually exists. Index: urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.135 retrieving revision 1.135.6.1 diff -C2 -d -r1.135 -r1.135.6.1 *** urllib.py 8 Dec 2001 17:09:07 -0000 1.135 --- urllib.py 18 Mar 2002 22:19:24 -0000 1.135.6.1 *************** *** 1396,1400 **** 'file:/etc/passwd', 'file://localhost/etc/passwd', ! 'ftp://ftp.python.org/etc/passwd', ## 'gopher://gopher.micro.umn.edu/1/', 'http://www.python.org/index.html', --- 1396,1400 ---- 'file:/etc/passwd', 'file://localhost/etc/passwd', ! 'ftp://ftp.python.org/pub/python/README', ## 'gopher://gopher.micro.umn.edu/1/', 'http://www.python.org/index.html', From akuchling@users.sourceforge.net Mon Mar 18 22:18:49 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Mon, 18 Mar 2002 14:18:49 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib urllib.py,1.136,1.137 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv22901 Modified Files: urllib.py Log Message: To make 'urllib.py -t' run again, change FTP URL to a file that actually exists. Index: urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.136 retrieving revision 1.137 diff -C2 -d -r1.136 -r1.137 *** urllib.py 11 Feb 2002 18:06:21 -0000 1.136 --- urllib.py 18 Mar 2002 22:18:46 -0000 1.137 *************** *** 1395,1399 **** 'file:/etc/passwd', 'file://localhost/etc/passwd', ! 'ftp://ftp.python.org/etc/passwd', ## 'gopher://gopher.micro.umn.edu/1/', 'http://www.python.org/index.html', --- 1395,1399 ---- 'file:/etc/passwd', 'file://localhost/etc/passwd', ! 'ftp://ftp.python.org/pub/python/README', ## 'gopher://gopher.micro.umn.edu/1/', 'http://www.python.org/index.html', From akuchling@users.sourceforge.net Mon Mar 18 22:51:50 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Mon, 18 Mar 2002 14:51:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib httplib.py,1.46,1.47 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv1131 Modified Files: httplib.py Log Message: [Bug #531616] Make HTTPS work again by adding a sendall method to the FakeSocket class. Without it, the sendall() call got the method on the underlying socket object, and that messed up SSL. Does httplib use other methods of sockets that FakeSocket doesn't support? Someone should take a look... (I'll try to give it a once-over.) 2.2.1 bugfix candidate. Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** httplib.py 9 Mar 2002 06:07:23 -0000 1.46 --- httplib.py 18 Mar 2002 22:51:48 -0000 1.47 *************** *** 646,649 **** --- 646,652 ---- return self.__ssl.write(stuff) + def sendall(self, stuff, flags = 0): + return self.__ssl.write(stuff) + def recv(self, len = 1024, flags = 0): return self.__ssl.read(len) From gvanrossum@users.sourceforge.net Mon Mar 18 23:06:32 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Mon, 18 Mar 2002 15:06:32 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.55,1.56 test_datetime.py,1.39,1.40 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv6481 Modified Files: datetime.py test_datetime.py Log Message: Add datetimetz type. Add unittests for it that make sure it behaves just like datetime when tzinfo=None. XXX Unittests for other tzinfo values are still missing. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** datetime.py 6 Mar 2002 04:10:37 -0000 1.55 --- datetime.py 18 Mar 2002 23:06:30 -0000 1.56 *************** *** 933,936 **** --- 933,1022 ---- + class datetimetz(datetime): + + def __init__(self, year, month, day, hour=0, minute=0, second=0, + microsecond=0, tzinfo=None): + super(datetimetz, self).__init__(year, month, day, + hour, minute, second, microsecond) + if tzinfo is not None: + # Better fail now than later + assert hasattr(tzinfo, 'utcoffset') + assert hasattr(tzinfo, 'dst') + assert hasattr(tzinfo, 'tzname') + self.__tzinfo = tzinfo + + def __hash__(self): + tz = self.__tzinfo + if tz == None: + return super(datetime, self).__hash__() + tzoff = tz.utcoffset(self) + if not tzoff: # zero or None! + return super(datetime, self).__hash__() + t = self - timedelta(minutes=tzoff) + return super(datetime, t).__hash__() + + def __add__(self, other): + result = super(datetimetz, self).__add__(other) + assert isinstance(result, datetimetz) + result.__tzinfo = self.__tzinfo + return result + + __radd__ = __add__ + + def __sub__(self, other): + supersub = super(datetimetz, self).__sub__ + if not isinstance(other, datetime): + return supersub(other) + mytz = self.__tzinfo + ottz = None + if isinstance(other, datetimetz): + ottz = other.__tzinfo + if mytz == ottz: + return supersub(other) + myoff = otoff = None + if self.__tzinfo is not None: + myoff = self.__tzinfo.utcoffset(self) + if isinstance(other, datetimetz) and other.__tzinfo is not None: + otoff = other.__tzinfo.utcoffset(other) + if myoff == otoff: + return supersub(other) + if myoff is None or otoff is None: + raise ValueError, "cannot mix naive and timezone-aware time" + return supersub(other) + timedelta(minutes=otoff-myoff) + + def __cmp__(self, other): + if not isinstance(other, datetime): + raise TypeError("can't compare datetime to %s instance" % + type(other).__name__) + superself = super(datetimetz, self) + supercmp = superself.__cmp__ + mytz = self.__tzinfo + ottz = None + if isinstance(other, datetimetz): + ottz = other.__tzinfo + if mytz == ottz: + return supercmp(other) + myoff = otoff = None + if mytz is not None: + myoff = mytz.utcoffset(self) + if ottz is not None: + otoff = ottz.utcoffset(other) + if myoff == otoff: + return supercmp(other) + if myoff is None or otoff is None: + raise ValueError, "cannot mix naive and timezone-aware time" + diff = superself.__sub__(other) + timedelta(minutes=otoff-myoff) + if diff.days < 0: + return -1 + if diff == timedelta(): + return 1 + return 1 + + + datetimetz.min = datetimetz(1, 1, 1) + datetimetz.max = datetimetz(9999, 12, 31, 23, 59, 59, 999999) + datetimetz.resolution = timedelta(microseconds=1) + + def _isoweek1monday(year): # Helper to calculate the day number of the Monday starting week 1 Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** test_datetime.py 6 Mar 2002 04:37:30 -0000 1.39 --- test_datetime.py 18 Mar 2002 23:06:30 -0000 1.40 *************** *** 7,11 **** import unittest ! from datetime import date, datetime, timedelta, MINYEAR, MAXYEAR --- 7,11 ---- import unittest ! from datetime import date, datetime, datetimetz, timedelta, MINYEAR, MAXYEAR *************** *** 517,525 **** def test_suite(): s1 = unittest.makeSuite(TestTimeDelta, 'test') s2 = unittest.makeSuite(TestDate, 'test') s3 = unittest.makeSuite(TestDateTime, 'test') ! return unittest.TestSuite([s1, s2, s3]) def test_main(): --- 517,531 ---- + class TestDateTimeTZ(TestDateTime): + + theclass = datetimetz + + def test_suite(): s1 = unittest.makeSuite(TestTimeDelta, 'test') s2 = unittest.makeSuite(TestDate, 'test') s3 = unittest.makeSuite(TestDateTime, 'test') ! s4 = unittest.makeSuite(TestDateTimeTZ, 'test') ! return unittest.TestSuite([s1, s2, s3, s4]) def test_main(): From tim_one@users.sourceforge.net Tue Mar 19 02:12:12 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 18 Mar 2002 18:12:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild BUILDno.txt,1.32,1.33 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv24978/python/PCbuild Modified Files: BUILDno.txt Log Message: Record 2.2.1c1 release date. Index: BUILDno.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/BUILDno.txt,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** BUILDno.txt 14 Mar 2002 22:48:50 -0000 1.32 --- BUILDno.txt 19 Mar 2002 02:12:10 -0000 1.33 *************** *** 35,39 **** ---------------------------- 32 2.2.1c1 ! "Soon" 31 2.1.2 final 16-Jan-2002 --- 35,39 ---- ---------------------------- 32 2.2.1c1 ! 18-Mar-2002 31 2.1.2 final 16-Jan-2002 From tim_one@users.sourceforge.net Tue Mar 19 02:13:49 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 18 Mar 2002 18:13:49 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.337.2.4.2.6,1.337.2.4.2.7 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv25258/221/Misc Modified Files: Tag: release22-maint NEWS Log Message: Record 2.2.1c1 release date. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.337.2.4.2.6 retrieving revision 1.337.2.4.2.7 diff -C2 -d -r1.337.2.4.2.6 -r1.337.2.4.2.7 *** NEWS 17 Mar 2002 20:47:11 -0000 1.337.2.4.2.6 --- NEWS 19 Mar 2002 02:13:47 -0000 1.337.2.4.2.7 *************** *** 1,5 **** What's New in Python 2.2.1c1? ! Release date: XXX ! =============================== This is primarily a bugfix release. Many bugs have been fixed since --- 1,5 ---- What's New in Python 2.2.1c1? ! Release date: 18-Mar-2002 ! ============================= This is primarily a bugfix release. Many bugs have been fixed since From tim_one@users.sourceforge.net Tue Mar 19 02:13:49 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 18 Mar 2002 18:13:49 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild BUILDno.txt,1.26.4.3,1.26.4.4 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv25258/221/PCbuild Modified Files: Tag: release22-maint BUILDno.txt Log Message: Record 2.2.1c1 release date. Index: BUILDno.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/BUILDno.txt,v retrieving revision 1.26.4.3 retrieving revision 1.26.4.4 diff -C2 -d -r1.26.4.3 -r1.26.4.4 *** BUILDno.txt 14 Mar 2002 22:43:45 -0000 1.26.4.3 --- BUILDno.txt 19 Mar 2002 02:13:47 -0000 1.26.4.4 *************** *** 35,39 **** ---------------------------- 32 2.2.1c1 ! "Soon" 28 2.2 final 21-Dec-2001 --- 35,39 ---- ---------------------------- 32 2.2.1c1 ! 18-Mar-2002 28 2.2 final 21-Dec-2001 From fdrake@users.sourceforge.net Tue Mar 19 03:33:17 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 18 Mar 2002 19:33:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcopyreg.tex,1.10,1.10.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv8343/lib Modified Files: Tag: release22-maint libcopyreg.tex Log Message: Clarify that copy_reg.pickle() is not intended for use with "classic" classes. This was stated before, but a minor grammatical error made it difficult to be sure of the meaning. This closes SF bug #530143. Index: libcopyreg.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcopyreg.tex,v retrieving revision 1.10 retrieving revision 1.10.8.1 diff -C2 -d -r1.10 -r1.10.8.1 *** libcopyreg.tex 15 Nov 2001 23:37:26 -0000 1.10 --- libcopyreg.tex 19 Mar 2002 03:33:14 -0000 1.10.8.1 *************** *** 23,29 **** \begin{funcdesc}{pickle}{type, function\optional{, constructor}} Declares that \var{function} should be used as a ``reduction'' ! function for objects of type \var{type}; \var{type} should not a ! class object. \var{function} should return either a string or a ! tuple containing two or three elements. The optional \var{constructor} parameter, if provided, is a --- 23,31 ---- \begin{funcdesc}{pickle}{type, function\optional{, constructor}} Declares that \var{function} should be used as a ``reduction'' ! function for objects of type \var{type}; \var{type} must not be a ! ``classic'' class object. (Classic classes are handled differently; ! see the documentation for the \refmodule{pickle} module for ! details.) \var{function} should return either a string or a tuple ! containing two or three elements. The optional \var{constructor} parameter, if provided, is a From fdrake@users.sourceforge.net Tue Mar 19 03:33:35 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 18 Mar 2002 19:33:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcopyreg.tex,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv8414/lib Modified Files: libcopyreg.tex Log Message: Clarify that copy_reg.pickle() is not intended for use with "classic" classes. This was stated before, but a minor grammatical error made it difficult to be sure of the meaning. This closes SF bug #530143. Index: libcopyreg.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcopyreg.tex,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** libcopyreg.tex 15 Nov 2001 23:37:26 -0000 1.10 --- libcopyreg.tex 19 Mar 2002 03:33:33 -0000 1.11 *************** *** 23,29 **** \begin{funcdesc}{pickle}{type, function\optional{, constructor}} Declares that \var{function} should be used as a ``reduction'' ! function for objects of type \var{type}; \var{type} should not a ! class object. \var{function} should return either a string or a ! tuple containing two or three elements. The optional \var{constructor} parameter, if provided, is a --- 23,31 ---- \begin{funcdesc}{pickle}{type, function\optional{, constructor}} Declares that \var{function} should be used as a ``reduction'' ! function for objects of type \var{type}; \var{type} must not be a ! ``classic'' class object. (Classic classes are handled differently; ! see the documentation for the \refmodule{pickle} module for ! details.) \var{function} should return either a string or a tuple ! containing two or three elements. The optional \var{constructor} parameter, if provided, is a From jackjansen@users.sourceforge.net Tue Mar 19 10:59:08 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 19 Mar 2002 02:59:08 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Distributions/(vise) Python 2.2.vct,1.6.4.2,1.6.4.2.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Distributions/(vise) In directory usw-pr-cvs1:/tmp/cvs-serv4277/Python 2.2/Mac/Distributions/(vise) Modified Files: Tag: release22-maint Python 2.2.vct Log Message: Files used for 2.2.1c1 distribution. Index: Python 2.2.vct =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Distributions/(vise)/Python 2.2.vct,v retrieving revision 1.6.4.2 retrieving revision 1.6.4.2.2.1 diff -C2 -d -r1.6.4.2 -r1.6.4.2.2.1 Binary files /tmp/cvsv5Iu0y and /tmp/cvsYAsgq8 differ From jackjansen@users.sourceforge.net Tue Mar 19 10:59:29 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 19 Mar 2002 02:59:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules macfsmodule.c,1.51.6.1,1.51.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules In directory usw-pr-cvs1:/tmp/cvs-serv4662/Python 2.2/Mac/Modules Modified Files: Tag: release22-maint macfsmodule.c Log Message: char/unsigned char mixup. Index: macfsmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/macfsmodule.c,v retrieving revision 1.51.6.1 retrieving revision 1.51.6.2 diff -C2 -d -r1.51.6.1 -r1.51.6.2 *** macfsmodule.c 24 Feb 2002 22:55:34 -0000 1.51.6.1 --- macfsmodule.c 19 Mar 2002 10:59:26 -0000 1.51.6.2 *************** *** 777,781 **** mfsr_as_pathname(mfsrobject *self, PyObject *args) { ! char strbuf[PATHNAMELEN]; OSStatus err; --- 777,781 ---- mfsr_as_pathname(mfsrobject *self, PyObject *args) { ! unsigned char strbuf[PATHNAMELEN]; OSStatus err; *************** *** 787,791 **** return NULL; } ! return PyString_FromString(strbuf); } --- 787,791 ---- return NULL; } ! return PyString_FromString((char *)strbuf); } From jackjansen@users.sourceforge.net Tue Mar 19 10:59:32 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 19 Mar 2002 02:59:32 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Build PythonCore.mcp,1.31.2.1,1.31.2.1.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Build In directory usw-pr-cvs1:/tmp/cvs-serv4618/Python 2.2/Mac/Build Modified Files: Tag: release22-maint PythonCore.mcp Log Message: Files used for 2.2.1c1 distribution. Index: PythonCore.mcp =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Build/PythonCore.mcp,v retrieving revision 1.31.2.1 retrieving revision 1.31.2.1.2.1 diff -C2 -d -r1.31.2.1 -r1.31.2.1.2.1 Binary files /tmp/cvsknsb0z and /tmp/cvs2dgX22 differ From jackjansen@users.sourceforge.net Tue Mar 19 10:59:36 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 19 Mar 2002 02:59:36 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Include macbuildno.h,1.22.4.2,1.22.4.2.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Include In directory usw-pr-cvs1:/tmp/cvs-serv4759/Python 2.2/Mac/Include Modified Files: Tag: release22-maint macbuildno.h Log Message: Files used for 2.2.1c1 distribution. Index: macbuildno.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Include/macbuildno.h,v retrieving revision 1.22.4.2 retrieving revision 1.22.4.2.2.1 diff -C2 -d -r1.22.4.2 -r1.22.4.2.2.1 *** macbuildno.h 26 Dec 2001 22:55:16 -0000 1.22.4.2 --- macbuildno.h 19 Mar 2002 10:59:34 -0000 1.22.4.2.2.1 *************** *** 1 **** ! #define BUILD 124 --- 1 ---- ! #define BUILD 132 From jackjansen@users.sourceforge.net Tue Mar 19 10:59:41 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 19 Mar 2002 02:59:41 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac _checkversion.py,1.11.6.1,1.11.6.1.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac In directory usw-pr-cvs1:/tmp/cvs-serv4786/Python 2.2/Mac Modified Files: Tag: release22-maint _checkversion.py Log Message: Files used for 2.2.1c1 distribution. Index: _checkversion.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/_checkversion.py,v retrieving revision 1.11.6.1 retrieving revision 1.11.6.1.2.1 diff -C2 -d -r1.11.6.1 -r1.11.6.1.2.1 *** _checkversion.py 26 Dec 2001 22:56:58 -0000 1.11.6.1 --- _checkversion.py 19 Mar 2002 10:59:38 -0000 1.11.6.1.2.1 *************** *** 6,10 **** _PACKAGE="MacPython" ! _VERSION="2.2" _URL="http://www.cwi.nl/~jack/macpythonversion.txt" --- 6,10 ---- _PACKAGE="MacPython" ! _VERSION="2.2.1" _URL="http://www.cwi.nl/~jack/macpythonversion.txt" From jackjansen@users.sourceforge.net Tue Mar 19 11:01:23 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 19 Mar 2002 03:01:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules macmodule.c,1.50,1.50.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules In directory usw-pr-cvs1:/tmp/cvs-serv5507/Python 2.2/Mac/Modules Modified Files: Tag: release22-maint macmodule.c Log Message: sync() has different return values depending on whether we build with GUSI or not. Index: macmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/macmodule.c,v retrieving revision 1.50 retrieving revision 1.50.6.1 diff -C2 -d -r1.50 -r1.50.6.1 *** macmodule.c 8 Dec 2001 18:02:51 -0000 1.50 --- macmodule.c 19 Mar 2002 11:01:20 -0000 1.50.6.1 *************** *** 59,67 **** #ifdef USE_GUSI2 - #define sync bad_sync #include #include - #undef sync - int sync(void); #else #define mode_t int --- 59,64 ---- *************** *** 644,648 **** --- 641,650 ---- return NULL; Py_BEGIN_ALLOW_THREADS + #ifdef USE_GUSI2 + sync(); + res = 0; + #else res = sync(); + #endif Py_END_ALLOW_THREADS if (res != 0) From fdrake@users.sourceforge.net Tue Mar 19 14:37:16 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 19 Mar 2002 06:37:16 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libthreading.tex,1.11,1.11.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv22468/lib Modified Files: Tag: release22-maint libthreading.tex Log Message: Adjust some poor wording in the text that explains what events are used for (reported by Keith Briggs). Wrap some very long lines. Index: libthreading.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libthreading.tex,v retrieving revision 1.11 retrieving revision 1.11.14.1 diff -C2 -d -r1.11 -r1.11.14.1 *** libthreading.tex 5 Sep 2001 13:44:54 -0000 1.11 --- libthreading.tex 19 Mar 2002 14:37:14 -0000 1.11.14.1 *************** *** 41,48 **** \begin{funcdesc}{Event}{} ! A factory function that returns a new event object. An event ! manages a flag that can be set to true with the \method{set()} method and ! reset to false with the \method{clear()} method. The \method{wait()} method blocks ! until the flag is true. \end{funcdesc} --- 41,48 ---- \begin{funcdesc}{Event}{} ! A factory function that returns a new event object. An event manages ! a flag that can be set to true with the \method{set()} method and ! reset to false with the \method{clear()} method. The \method{wait()} ! method blocks until the flag is true. \end{funcdesc} *************** *** 80,84 **** \begin{classdesc*}{Thread}{} ! A class that represents a thread of control. This class can be safely subclassed in a limited fashion. \end{classdesc*} --- 80,85 ---- \begin{classdesc*}{Thread}{} ! A class that represents a thread of control. This class can be safely ! subclassed in a limited fashion. \end{classdesc*} *************** *** 410,422 **** undetected. \subsection{Event Objects \label{event-objects}} This is one of the simplest mechanisms for communication between ! threads: one thread signals an event and one or more other threads ! are waiting for it. An event object manages an internal flag that can be set to true with ! the \method{set()} method and reset to false with the \method{clear()} method. The ! \method{wait()} method blocks until the flag is true. --- 411,423 ---- undetected. + \subsection{Event Objects \label{event-objects}} This is one of the simplest mechanisms for communication between ! threads: one thread signals an event and other threads wait for it. An event object manages an internal flag that can be set to true with ! the \method{set()} method and reset to false with the \method{clear()} ! method. The \method{wait()} method blocks until the flag is true. *************** *** 438,443 **** \begin{methoddesc}{clear}{} Reset the internal flag to false. ! Subsequently, threads calling \method{wait()} will block until \method{set()} is ! called to set the internal flag to true again. \end{methoddesc} --- 439,444 ---- \begin{methoddesc}{clear}{} Reset the internal flag to false. ! Subsequently, threads calling \method{wait()} will block until ! \method{set()} is called to set the internal flag to true again. \end{methoddesc} *************** *** 543,550 **** You may override this method in a subclass. The standard ! \method{run()} method invokes the callable object passed to the object's constructor as the ! \var{target} argument, if any, with sequential and keyword ! arguments taken from the \var{args} and \var{kwargs} arguments, ! respectively. \end{methoddesc} --- 544,551 ---- You may override this method in a subclass. The standard ! \method{run()} method invokes the callable object passed to the ! object's constructor as the \var{target} argument, if any, with ! sequential and keyword arguments taken from the \var{args} and ! \var{kwargs} arguments, respectively. \end{methoddesc} *************** *** 555,560 **** unhandled exception -- or until the optional timeout occurs. ! When the \var{timeout} argument is present and not \code{None}, it should ! be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). --- 556,561 ---- unhandled exception -- or until the optional timeout occurs. ! When the \var{timeout} argument is present and not \code{None}, it ! should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). *************** *** 604,616 **** \subsection{Timer Objects \label{timer-objects}} ! This class represents an action that should be run only after a certain amount ! of time has passed --- a timer. \class{Timer} is a subclass of \class{Thread} and ! as such also functions as an example of creating custom threads. ! Timers are started, as with threads, by calling their \method{start()} method. The ! timer can be stopped (before its action has begun) by calling the ! \method{cancel()} method. The interval the timer will wait before executing ! its action may not be exactly the same as the interval specified by the ! user. For example: --- 605,618 ---- \subsection{Timer Objects \label{timer-objects}} ! This class represents an action that should be run only after a ! certain amount of time has passed --- a timer. \class{Timer} is a ! subclass of \class{Thread} and as such also functions as an example of ! creating custom threads. ! Timers are started, as with threads, by calling their \method{start()} ! method. The timer can be stopped (before its action has begun) by ! calling the \method{cancel()} method. The interval the timer will ! wait before executing its action may not be exactly the same as the ! interval specified by the user. For example: *************** *** 629,633 **** \begin{methoddesc}{cancel}{} ! Stop the timer, and cancel the execution of the timer's action. This will only ! work if the timer is still in its waiting stage. \end{methoddesc} --- 631,635 ---- \begin{methoddesc}{cancel}{} ! Stop the timer, and cancel the execution of the timer's action. This ! will only work if the timer is still in its waiting stage. \end{methoddesc} From fdrake@users.sourceforge.net Tue Mar 19 14:37:46 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 19 Mar 2002 06:37:46 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libthreading.tex,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv22616/lib Modified Files: libthreading.tex Log Message: Adjust some poor wording in the text that explains what events are used for (reported by Keith Briggs). Wrap some very long lines. Index: libthreading.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libthreading.tex,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** libthreading.tex 5 Sep 2001 13:44:54 -0000 1.11 --- libthreading.tex 19 Mar 2002 14:37:44 -0000 1.12 *************** *** 41,48 **** \begin{funcdesc}{Event}{} ! A factory function that returns a new event object. An event ! manages a flag that can be set to true with the \method{set()} method and ! reset to false with the \method{clear()} method. The \method{wait()} method blocks ! until the flag is true. \end{funcdesc} --- 41,48 ---- \begin{funcdesc}{Event}{} ! A factory function that returns a new event object. An event manages ! a flag that can be set to true with the \method{set()} method and ! reset to false with the \method{clear()} method. The \method{wait()} ! method blocks until the flag is true. \end{funcdesc} *************** *** 80,84 **** \begin{classdesc*}{Thread}{} ! A class that represents a thread of control. This class can be safely subclassed in a limited fashion. \end{classdesc*} --- 80,85 ---- \begin{classdesc*}{Thread}{} ! A class that represents a thread of control. This class can be safely ! subclassed in a limited fashion. \end{classdesc*} *************** *** 410,422 **** undetected. \subsection{Event Objects \label{event-objects}} This is one of the simplest mechanisms for communication between ! threads: one thread signals an event and one or more other threads ! are waiting for it. An event object manages an internal flag that can be set to true with ! the \method{set()} method and reset to false with the \method{clear()} method. The ! \method{wait()} method blocks until the flag is true. --- 411,423 ---- undetected. + \subsection{Event Objects \label{event-objects}} This is one of the simplest mechanisms for communication between ! threads: one thread signals an event and other threads wait for it. An event object manages an internal flag that can be set to true with ! the \method{set()} method and reset to false with the \method{clear()} ! method. The \method{wait()} method blocks until the flag is true. *************** *** 438,443 **** \begin{methoddesc}{clear}{} Reset the internal flag to false. ! Subsequently, threads calling \method{wait()} will block until \method{set()} is ! called to set the internal flag to true again. \end{methoddesc} --- 439,444 ---- \begin{methoddesc}{clear}{} Reset the internal flag to false. ! Subsequently, threads calling \method{wait()} will block until ! \method{set()} is called to set the internal flag to true again. \end{methoddesc} *************** *** 543,550 **** You may override this method in a subclass. The standard ! \method{run()} method invokes the callable object passed to the object's constructor as the ! \var{target} argument, if any, with sequential and keyword ! arguments taken from the \var{args} and \var{kwargs} arguments, ! respectively. \end{methoddesc} --- 544,551 ---- You may override this method in a subclass. The standard ! \method{run()} method invokes the callable object passed to the ! object's constructor as the \var{target} argument, if any, with ! sequential and keyword arguments taken from the \var{args} and ! \var{kwargs} arguments, respectively. \end{methoddesc} *************** *** 555,560 **** unhandled exception -- or until the optional timeout occurs. ! When the \var{timeout} argument is present and not \code{None}, it should ! be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). --- 556,561 ---- unhandled exception -- or until the optional timeout occurs. ! When the \var{timeout} argument is present and not \code{None}, it ! should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). *************** *** 604,616 **** \subsection{Timer Objects \label{timer-objects}} ! This class represents an action that should be run only after a certain amount ! of time has passed --- a timer. \class{Timer} is a subclass of \class{Thread} and ! as such also functions as an example of creating custom threads. ! Timers are started, as with threads, by calling their \method{start()} method. The ! timer can be stopped (before its action has begun) by calling the ! \method{cancel()} method. The interval the timer will wait before executing ! its action may not be exactly the same as the interval specified by the ! user. For example: --- 605,618 ---- \subsection{Timer Objects \label{timer-objects}} ! This class represents an action that should be run only after a ! certain amount of time has passed --- a timer. \class{Timer} is a ! subclass of \class{Thread} and as such also functions as an example of ! creating custom threads. ! Timers are started, as with threads, by calling their \method{start()} ! method. The timer can be stopped (before its action has begun) by ! calling the \method{cancel()} method. The interval the timer will ! wait before executing its action may not be exactly the same as the ! interval specified by the user. For example: *************** *** 629,633 **** \begin{methoddesc}{cancel}{} ! Stop the timer, and cancel the execution of the timer's action. This will only ! work if the timer is still in its waiting stage. \end{methoddesc} --- 631,635 ---- \begin{methoddesc}{cancel}{} ! Stop the timer, and cancel the execution of the timer's action. This ! will only work if the timer is still in its waiting stage. \end{methoddesc} From loewis@users.sourceforge.net Tue Mar 19 15:15:34 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Tue, 19 Mar 2002 07:15:34 -0800 Subject: [Python-checkins] CVS: python/dist/src configure,1.287,1.288 configure.in,1.297,1.298 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv1668 Modified Files: configure configure.in Log Message: Expand LINKCC in configure.in. Suggested in bug report #529713. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.287 retrieving revision 1.288 diff -C2 -d -r1.287 -r1.288 *** configure 15 Mar 2002 13:48:19 -0000 1.287 --- configure 19 Mar 2002 15:15:30 -0000 1.288 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.296 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.297 # Guess values for system-dependent variables and create Makefiles. *************** *** 1431,1437 **** LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); $LINKCC";; dgux*) ! LINKCC="LD_RUN_PATH=$libdir $(LINKCC)";; Monterey64*) ! LINKCC="$(LINKCC) -L/usr/lib/ia64l64";; esac fi --- 1431,1437 ---- LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); $LINKCC";; dgux*) ! LINKCC="LD_RUN_PATH=$libdir $LINKCC";; Monterey64*) ! LINKCC="$LINKCC -L/usr/lib/ia64l64";; esac fi Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.297 retrieving revision 1.298 diff -C2 -d -r1.297 -r1.298 *** configure.in 15 Mar 2002 13:48:21 -0000 1.297 --- configure.in 19 Mar 2002 15:15:32 -0000 1.298 *************** *** 295,301 **** LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); $LINKCC";; dgux*) ! LINKCC="LD_RUN_PATH=$libdir $(LINKCC)";; Monterey64*) ! LINKCC="$(LINKCC) -L/usr/lib/ia64l64";; esac fi --- 295,301 ---- LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); $LINKCC";; dgux*) ! LINKCC="LD_RUN_PATH=$libdir $LINKCC";; Monterey64*) ! LINKCC="$LINKCC -L/usr/lib/ia64l64";; esac fi From akuchling@users.sourceforge.net Tue Mar 19 16:02:38 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Tue, 19 Mar 2002 08:02:38 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include traceback.h,2.18,2.19 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv14982a Modified Files: traceback.h Log Message: [Bug #528914] PyTraceBack_Store/Fetch were deleted in 1997, but their prototypes remain. Noted by Yakov Markovitch. Bugfix candidate. Index: traceback.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/traceback.h,v retrieving revision 2.18 retrieving revision 2.19 diff -C2 -d -r2.18 -r2.19 *** traceback.h 1 Sep 2000 23:29:26 -0000 2.18 --- traceback.h 19 Mar 2002 16:02:35 -0000 2.19 *************** *** 11,19 **** DL_IMPORT(int) PyTraceBack_Here(struct _frame *); - DL_IMPORT(PyObject *) PyTraceBack_Fetch(void); - DL_IMPORT(int) PyTraceBack_Store(PyObject *); DL_IMPORT(int) PyTraceBack_Print(PyObject *, PyObject *); ! /* Reveale traceback type so we can typecheck traceback objects */ extern DL_IMPORT(PyTypeObject) PyTraceBack_Type; #define PyTraceBack_Check(v) ((v)->ob_type == &PyTraceBack_Type) --- 11,17 ---- DL_IMPORT(int) PyTraceBack_Here(struct _frame *); DL_IMPORT(int) PyTraceBack_Print(PyObject *, PyObject *); ! /* Reveal traceback type so we can typecheck traceback objects */ extern DL_IMPORT(PyTypeObject) PyTraceBack_Type; #define PyTraceBack_Check(v) ((v)->ob_type == &PyTraceBack_Type) From gvanrossum@users.sourceforge.net Tue Mar 19 17:09:53 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Tue, 19 Mar 2002 09:09:53 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.56,1.57 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv5819 Modified Files: datetime.py Log Message: - Fix datetime.__repr__() not to use "days=" (it's redundant). - Fix comment for datetime.isoformat(). - Update datetimetz class: - add isoformat() - add __repr__ - add tzinfo(), utcoffset(), tzname(), dst() methods - fix return value of __cmp__ when equal Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** datetime.py 18 Mar 2002 23:06:30 -0000 1.56 --- datetime.py 19 Mar 2002 17:09:51 -0000 1.57 *************** *** 397,404 **** def __repr__(self): if self.__microseconds: ! return "%s(days=%d, %d, %d)" % (self.__class__.__name__, ! self.__days, ! self.__seconds, ! self.__microseconds) if self.__seconds: return "%s(%d, %d)" % (self.__class__.__name__, --- 397,404 ---- def __repr__(self): if self.__microseconds: ! return "%s(%d, %d, %d)" % (self.__class__.__name__, ! self.__days, ! self.__seconds, ! self.__microseconds) if self.__seconds: return "%s(%d, %d)" % (self.__class__.__name__, *************** *** 915,919 **** """Return the time formatted according to ISO. ! This is 'YYYY-MM-DD HH:MM:SS.mmmmmm-xx:yy' where -xx:yy is the timezone offset. --- 915,919 ---- """Return the time formatted according to ISO. ! This is 'YYYY-MM-DD HH:MM:SS.mmmmmm' where -xx:yy is the timezone offset. *************** *** 935,938 **** --- 935,941 ---- class datetimetz(datetime): + # XXX needs docstrings and conversion APIs + # See http://www.zope.org/Members/fdrake/DateTimeWiki/TimeZoneInfo + def __init__(self, year, month, day, hour=0, minute=0, second=0, microsecond=0, tzinfo=None): *************** *** 946,949 **** --- 949,999 ---- self.__tzinfo = tzinfo + def isoformat(self, sep='T'): + s = super(datetimetz, self).isoformat(sep) + if self.__tzinfo is not None: + off = self.__tzinfo.utcoffset(self) + if off is not None: + if off < 0: + sign = "-" + off = -off + else: + sign = "+" + hh, mm = divmod(off, 60) + s = s + "%s%02d:%02d" % (sign, hh, mm) + return s + + def __repr__(self): + s = super(datetimetz, self).__repr__() + if self.__tzinfo is not None: + assert s[-1:] == ")" + s = s[:-1] + ", tzinfo=%r" % self.__tzinfo + ")" + return s + + # XXX property or method? + #tzinfo = property(lambda self: self.__tzinfo, doc="timezone info object") + def tzinfo(self): + return self.__tzinfo + + def utcoffset(self): + tz = self.__tzinfo + if tz is None: + return None + else: + return tz.utcoffset(self) + + def tzname(self): + tz = self.__tzinfo + if tz is None: + return None + else: + return tz.tzname(self) + + def dst(self): + tz = self.__tzinfo + if tz is None: + return None + else: + return tz.dst(self) + def __hash__(self): tz = self.__tzinfo *************** *** 1010,1014 **** return -1 if diff == timedelta(): ! return 1 return 1 --- 1060,1064 ---- return -1 if diff == timedelta(): ! return 0 return 1 From gvanrossum@users.sourceforge.net Tue Mar 19 17:10:19 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Tue, 19 Mar 2002 09:10:19 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.40,1.41 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv5977 Modified Files: test_datetime.py Log Message: Add basic test for timezone support. Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** test_datetime.py 18 Mar 2002 23:06:30 -0000 1.40 --- test_datetime.py 19 Mar 2002 17:10:17 -0000 1.41 *************** *** 517,523 **** --- 517,569 ---- + class FixedOffset(object): + def __init__(self, offset, name): + self.__offset = offset + self.__name = name + def __repr__(self): + return self.__name.lower() + def utcoffset(self, dt): + return self.__offset + def tzname(self, dt): + return self.__name + def dst(self, dt): + return 0 + + class TestDateTimeTZ(TestDateTime): theclass = datetimetz + + def test_zones(self): + est = FixedOffset(-300, "EST") + utc = FixedOffset(0, "UTC") + met = FixedOffset(60, "MET") + t1 = datetimetz(2002, 3, 19, 7, 47, tzinfo=est) + t2 = datetimetz(2002, 3, 19, 12, 47, tzinfo=utc) + t3 = datetimetz(2002, 3, 19, 13, 47, tzinfo=met) + self.assertEqual(t1.tzinfo(), est) + self.assertEqual(t2.tzinfo(), utc) + self.assertEqual(t3.tzinfo(), met) + self.assertEqual(t1.utcoffset(), -300) + self.assertEqual(t2.utcoffset(), 0) + self.assertEqual(t3.utcoffset(), 60) + self.assertEqual(t1.tzname(), "EST") + self.assertEqual(t2.tzname(), "UTC") + self.assertEqual(t3.tzname(), "MET") + self.assertEqual(hash(t1), hash(t2)) + self.assertEqual(hash(t1), hash(t3)) + self.assertEqual(hash(t2), hash(t3)) + self.assertEqual(t1, t2) + self.assertEqual(t1, t3) + self.assertEqual(t2, t3) + self.assertEqual(str(t1), "2002-03-19 07:47:00.000000-05:00") + self.assertEqual(str(t2), "2002-03-19 12:47:00.000000+00:00") + self.assertEqual(str(t3), "2002-03-19 13:47:00.000000+01:00") + self.assertEqual(repr(t1), + "datetimetz(2002, 3, 19, 7, 47, tzinfo=est)") + self.assertEqual(repr(t2), + "datetimetz(2002, 3, 19, 12, 47, tzinfo=utc)") + self.assertEqual(repr(t3), + "datetimetz(2002, 3, 19, 13, 47, tzinfo=met)") From akuchling@users.sourceforge.net Wed Mar 20 02:23:00 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Tue, 19 Mar 2002 18:23:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib asynchat.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv20145 Modified Files: asynchat.py Log Message: A faster version of the find_prefix_at_end() function (that I found in the last Medusa release) Should be safe as a bugfix candidate, though it's not fixing a bug. Index: asynchat.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/asynchat.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** asynchat.py 8 Mar 2002 18:27:11 -0000 1.16 --- asynchat.py 20 Mar 2002 02:22:58 -0000 1.17 *************** *** 281,299 **** # for example: # f_p_a_e ("qwerty\r", "\r\n") => 1 - # f_p_a_e ("qwerty\r\n", "\r\n") => 2 # f_p_a_e ("qwertydkjf", "\r\n") => 0 # this could maybe be made faster with a computed regex? # [answer: no; circa Python-2.0, Jan 2001] ! # python: 18307/s # re: 12820/s # regex: 14035/s def find_prefix_at_end (haystack, needle): ! nl = len(needle) ! result = 0 ! for i in range (1,nl): ! if haystack[-(nl-i):] == needle[:(nl-i)]: ! result = nl-i ! break ! return result --- 281,297 ---- # for example: # f_p_a_e ("qwerty\r", "\r\n") => 1 # f_p_a_e ("qwertydkjf", "\r\n") => 0 + # f_p_a_e ("qwerty\r\n", "\r\n") => # this could maybe be made faster with a computed regex? # [answer: no; circa Python-2.0, Jan 2001] ! # new python: 28961/s ! # old python: 18307/s # re: 12820/s # regex: 14035/s def find_prefix_at_end (haystack, needle): ! l = len(needle) - 1 ! while l and not haystack.endswith(needle[:l]): ! l -= 1 ! return l From tim_one@users.sourceforge.net Wed Mar 20 04:02:33 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Tue, 19 Mar 2002 20:02:33 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include pymem.h,2.7,2.8 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv4503 Modified Files: pymem.h Log Message: Arrange to export the _PyMalloc_{Malloc, Realloc, Free} entry points. On Windows some modules are considered (by me, and I don't care what anyone else thinks about this ) to be part of "the core" despite that they happen to be compiled into separate DLLs (the "to DLL or not to DLL?" question on Windows is nearly arbitrary). Making the pymalloc entry points available to them allows the Windows build to complete without incident when WITH_PYMALLOC is #define'd. Note that this isn't unprecedented. Other "private API" functions we export include _PySequence_IterSearch, _PyEval_SliceIndex, _PyCodec_Lookup, _Py_ZeroStruct, _Py_TrueStruct, _PyLong_New and _PyModule_Clear. Index: pymem.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pymem.h,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -d -r2.7 -r2.8 *** pymem.h 18 Mar 2002 21:04:54 -0000 2.7 --- pymem.h 20 Mar 2002 04:02:31 -0000 2.8 *************** *** 93,99 **** /* pymalloc (private to the interpreter) */ #ifdef WITH_PYMALLOC ! void *_PyMalloc_Malloc(size_t nbytes); ! void *_PyMalloc_Realloc(void *p, size_t nbytes); ! void _PyMalloc_Free(void *p); #define _PyMalloc_MALLOC _PyMalloc_Malloc #define _PyMalloc_REALLOC _PyMalloc_Realloc --- 93,99 ---- /* pymalloc (private to the interpreter) */ #ifdef WITH_PYMALLOC ! DL_IMPORT(void *) _PyMalloc_Malloc(size_t nbytes); ! DL_IMPORT(void *) _PyMalloc_Realloc(void *p, size_t nbytes); ! DL_IMPORT(void) _PyMalloc_Free(void *p); #define _PyMalloc_MALLOC _PyMalloc_Malloc #define _PyMalloc_REALLOC _PyMalloc_Realloc From theller@users.sourceforge.net Wed Mar 20 14:37:27 2002 From: theller@users.sourceforge.net (Thomas Heller) Date: Wed, 20 Mar 2002 06:37:27 -0800 Subject: [Python-checkins] CVS: distutils/misc install.c,1.16,1.17 Message-ID: Update of /cvsroot/python/distutils/misc In directory usw-pr-cvs1:/tmp/cvs-serv30752 Modified Files: install.c Log Message: Better error messages for the create_shortcut function. Additional builtin function available to the installation script, needed for creating shortcuts: get_special_folder_path(csidl_string) csidl_string must be something like "CSIDL_COMMON_STARTMENU" or "CSIDL_DESKTOPDIRECTORY". The function will return the pathname of the folder. Not yet completely finished, but I have to get this out of the way. Index: install.c =================================================================== RCS file: /cvsroot/python/distutils/misc/install.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** install.c 19 Feb 2002 20:47:27 -0000 1.16 --- install.c 20 Mar 2002 14:37:25 -0000 1.17 *************** *** 317,320 **** --- 317,381 ---- int (*g_PyArg_ParseTuple)(PyObject *, char *, ...); + PyObject *g_PyExc_ValueError; + PyObject *g_PyExc_OSError; + + PyObject *(*g_PyErr_Format)(PyObject *, char *, ...); + + #define DEF_CSIDL(name) { name, #name } + + struct { + int nFolder; + char *name; + } csidl_names[] = { + DEF_CSIDL(CSIDL_COMMON_STARTMENU), + DEF_CSIDL(CSIDL_STARTMENU), + + /* DEF_CSIDL(CSIDL_COMMON_APPDATA), */ + /* DEF_CSIDL(CSIDL_LOCAL_APPDATA), */ + DEF_CSIDL(CSIDL_APPDATA), + + DEF_CSIDL(CSIDL_COMMON_DESKTOPDIRECTORY), + DEF_CSIDL(CSIDL_DESKTOPDIRECTORY), + + DEF_CSIDL(CSIDL_COMMON_STARTUP), + DEF_CSIDL(CSIDL_STARTUP), + + DEF_CSIDL(CSIDL_COMMON_PROGRAMS), + DEF_CSIDL(CSIDL_PROGRAMS), + + /* DEF_CSIDL(CSIDL_PROGRAM_FILES_COMMON), */ + /* DEF_CSIDL(CSIDL_PROGRAM_FILES), */ + + DEF_CSIDL(CSIDL_FONTS), + }; + + #define DIM(a) (sizeof(a) / sizeof((a)[0])) + + static PyObject *GetSpecialFolderPath(PyObject *self, PyObject *args) + { + char *name; + char lpszPath[MAX_PATH]; + int i; + + if (!g_PyArg_ParseTuple(args, "s", &name)) + return NULL; + + for (i = 0; i < DIM(csidl_names); ++i) { + if (0 == strcmpi(csidl_names[i].name, name)) { + int nFolder; + nFolder = csidl_names[i].nFolder; + if (SHGetSpecialFolderPath(NULL, lpszPath, nFolder, 0)) + return g_Py_BuildValue("s", lpszPath); + else { + g_PyErr_Format(g_PyExc_OSError, "no such folder (%s)", name); + return NULL; + } + + } + }; + g_PyErr_Format(g_PyExc_ValueError, "unknown CSIDL (%s)", name); + return NULL; + } + static PyObject *CreateShortcut(PyObject *self, PyObject *args) { *************** *** 336,341 **** hr = CoInitialize(NULL); ! if (FAILED(hr)) ! return g_Py_BuildValue("si", "CoInitialize", hr); if (!g_PyArg_ParseTuple(args, "sss|sssi", --- 397,405 ---- hr = CoInitialize(NULL); ! if (FAILED(hr)) { ! g_PyErr_Format(g_PyExc_OSError, ! "CoInitialize failed, error 0x%x", hr); ! goto error; ! } if (!g_PyArg_ParseTuple(args, "sss|sssi", *************** *** 349,386 **** &IID_IShellLink, &ps1); ! if (FAILED(hr)) ! return g_Py_BuildValue("si", "CoCreateInstance", hr); hr = ps1->lpVtbl->QueryInterface(ps1, &IID_IPersistFile, (void **)&pPf); ! if (FAILED(hr)) ! return g_Py_BuildValue("si", "QueryInterface(IPersistFile)", hr); hr = ps1->lpVtbl->SetPath(ps1, path); ! if (FAILED(hr)) ! return g_Py_BuildValue("si", "SetPath", hr); hr = ps1->lpVtbl->SetDescription(ps1, description); ! if (FAILED(hr)) ! return g_Py_BuildValue("si", "SetDescription", hr); if (arguments) { hr = ps1->lpVtbl->SetArguments(ps1, arguments); ! if (FAILED(hr)) ! return g_Py_BuildValue("si", "SetArguments", hr); ! } if (iconpath) { hr = ps1->lpVtbl->SetIconLocation(ps1, iconpath, iconindex); ! if (FAILED(hr)) ! return g_Py_BuildValue("si", "SetIconLocation", hr); } if (workdir) { hr = ps1->lpVtbl->SetWorkingDirectory(ps1, workdir); ! if (FAILED(hr)) ! return g_Py_BuildValue("si", "SetWorkingDirectory", hr); ! } --- 413,469 ---- &IID_IShellLink, &ps1); ! if (FAILED(hr)) { ! g_PyErr_Format(g_PyExc_OSError, ! "CoCreateInstance failed, error 0x%x", hr); ! goto error; ! } hr = ps1->lpVtbl->QueryInterface(ps1, &IID_IPersistFile, (void **)&pPf); ! if (FAILED(hr)) { ! g_PyErr_Format(g_PyExc_OSError, ! "QueryInterface(IPersistFile) failed, error 0x%x", hr); ! goto error; ! } hr = ps1->lpVtbl->SetPath(ps1, path); ! if (FAILED(hr)) { ! g_PyErr_Format(g_PyExc_OSError, ! "SetPath() failed, error 0x%x", hr); ! goto error; ! } hr = ps1->lpVtbl->SetDescription(ps1, description); ! if (FAILED(hr)) { ! g_PyErr_Format(g_PyExc_OSError, ! "SetDescription() failed, error 0x%x", hr); ! goto error; ! } if (arguments) { hr = ps1->lpVtbl->SetArguments(ps1, arguments); ! if (FAILED(hr)) { ! g_PyErr_Format(g_PyExc_OSError, ! "SetArguments() failed, error 0x%x", hr); ! goto error; ! } } if (iconpath) { hr = ps1->lpVtbl->SetIconLocation(ps1, iconpath, iconindex); ! if (FAILED(hr)) { ! g_PyErr_Format(g_PyExc_OSError, ! "SetIconLocation() failed, error 0x%x", hr); ! goto error; ! } } if (workdir) { hr = ps1->lpVtbl->SetWorkingDirectory(ps1, workdir); ! if (FAILED(hr)) { ! g_PyErr_Format(g_PyExc_OSError, ! "SetWorkingDirectory() failed, error 0x%x", hr); ! goto error; ! } } *************** *** 390,409 **** hr = pPf->lpVtbl->Save(pPf, wszFilename, TRUE); ! if (FAILED(hr)) ! return g_Py_BuildValue("si", "Save()", hr); ! pPf->lpVtbl->Release(pPf); - ps1->lpVtbl->Release(ps1); CoUninitialize(); ! return g_Py_BuildValue("i", 0); } #define METH_VARARGS 0x0001 ! PyMethodDef meth = { ! "create_shortcut", CreateShortcut, METH_VARARGS, NULL }; --- 473,504 ---- hr = pPf->lpVtbl->Save(pPf, wszFilename, TRUE); ! if (FAILED(hr)) { ! g_PyErr_Format(g_PyExc_OSError, ! "Save() failed, error 0x%x", hr); ! goto error; ! } ! pPf->lpVtbl->Release(pPf); ps1->lpVtbl->Release(ps1); + CoUninitialize(); + return g_Py_BuildValue("i", 0); + + error: + if (pPf) + pPf->lpVtbl->Release(pPf); + + if (ps1) + ps1->lpVtbl->Release(ps1); CoUninitialize(); ! return NULL; } #define METH_VARARGS 0x0001 ! PyMethodDef meth[] = { ! {"create_shortcut", CreateShortcut, METH_VARARGS, NULL}, ! {"get_special_folder_path", GetSpecialFolderPath, METH_VARARGS, NULL}, }; *************** *** 416,422 **** --- 511,519 ---- DECLPROC(hPython, PyObject *, PyImport_ImportModule, (char *)); DECLPROC(hPython, int, PyObject_SetAttrString, (PyObject *, char *, PyObject *)); + DECLPROC(hPython, PyObject *, PyObject_GetAttrString, (PyObject *, char *)); DECLPROC(hPython, PyObject *, Py_BuildValue, (char *, ...)); DECLPROC(hPython, PyObject *, PyCFunction_New, (PyMethodDef *, PyObject *)); DECLPROC(hPython, int, PyArg_ParseTuple, (PyObject *, char *, ...)); + DECLPROC(hPython, PyObject *, PyErr_Format, (PyObject *, char *)); PyObject *mod; *************** *** 426,447 **** if (!Py_Initialize || !PySys_SetArgv || !PyRun_SimpleFile || !Py_Finalize) ! return -1; if (!PyImport_ImportModule || !PyObject_SetAttrString || !Py_BuildValue) ! return -1; ! if (!PyCFunction_New || !PyArg_ParseTuple) ! return -1; g_Py_BuildValue = Py_BuildValue; g_PyArg_ParseTuple = PyArg_ParseTuple; ! if (pathname == NULL || pathname[0] == '\0') ! return -1; fp = fopen(pathname, "r"); if (!fp) { ! return -1; } --- 523,548 ---- if (!Py_Initialize || !PySys_SetArgv || !PyRun_SimpleFile || !Py_Finalize) ! return 0x80000000; if (!PyImport_ImportModule || !PyObject_SetAttrString || !Py_BuildValue) ! return 0x80000000; ! if (!PyCFunction_New || !PyArg_ParseTuple || !PyErr_Format) ! return 0x80000000; ! ! if (!PyObject_GetAttrString) ! return 0x80000000; ! g_Py_BuildValue = Py_BuildValue; g_PyArg_ParseTuple = PyArg_ParseTuple; ! g_PyErr_Format = PyErr_Format; if (pathname == NULL || pathname[0] == '\0') ! return 0x80000000; fp = fopen(pathname, "r"); if (!fp) { ! return 0x80000000; } *************** *** 451,456 **** mod = PyImport_ImportModule("__builtin__"); ! if (mod) ! PyObject_SetAttrString(mod, "create_shortcut", PyCFunction_New(&meth, NULL)); PySys_SetArgv(argc, argv); --- 552,561 ---- mod = PyImport_ImportModule("__builtin__"); ! if (mod) { ! g_PyExc_ValueError = PyObject_GetAttrString(mod, "ValueError"); ! g_PyExc_OSError = PyObject_GetAttrString(mod, "OSError"); ! PyObject_SetAttrString(mod, "create_shortcut", PyCFunction_New(&meth[0], NULL)); ! PyObject_SetAttrString(mod, "get_special_folder_path", PyCFunction_New(&meth[1], NULL)); ! } PySys_SetArgv(argc, argv); *************** *** 1157,1162 **** --- 1262,1272 ---- &py_major, &py_minor); if (result == 2) + #ifdef _DEBUG + wsprintf (pythondll, "c:\\python22\\PCBuild\\python%d%d_d.dll", + py_major, py_minor); + #else wsprintf (pythondll, "python%d%d.dll", py_major, py_minor); + #endif free (pbuf); } else *************** *** 1496,1500 **** hPython = LoadLibrary(pythondll); if (hPython) { ! run_installscript(hPython, fname, 2, argv); FreeLibrary(hPython); } --- 1606,1611 ---- hPython = LoadLibrary(pythondll); if (hPython) { ! if (0x80000000 == run_installscript(hPython, fname, 2, argv)) ! fprintf(stderr, "*** Could not load Python ***"); FreeLibrary(hPython); } *************** *** 1819,1823 **** hPython = LoadLibrary(dllname); if (hPython) { ! run_installscript(hPython, scriptname, 2, argv); FreeLibrary(hPython); } --- 1930,1935 ---- hPython = LoadLibrary(dllname); if (hPython) { ! if (0x80000000 == run_installscript(hPython, scriptname, 2, argv)) ! fprintf(stderr, "*** Could not load Python ***"); FreeLibrary(hPython); } From nascheme@users.sourceforge.net Wed Mar 20 18:36:02 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Wed, 20 Mar 2002 10:36:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib gzip.py,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv16084 Modified Files: gzip.py Log Message: Make GzipFile an iterator. Closes bug #532621. Index: gzip.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/gzip.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** gzip.py 11 Mar 2002 06:46:52 -0000 1.29 --- gzip.py 20 Mar 2002 18:36:00 -0000 1.30 *************** *** 352,355 **** --- 352,365 ---- self.write(line) + def __iter__(self): + return self + + def next(self): + line = self.readline() + if line: + return line + else: + raise StopIteration + def _test(): From nnorwitz@users.sourceforge.net Wed Mar 20 18:54:07 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Wed, 20 Mar 2002 10:54:07 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libfilecmp.tex,1.5,1.5.18.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv21696/Doc/lib Modified Files: Tag: release22-maint libfilecmp.tex Log Message: SF# 522426, add doc for common parameter for filecmp.cmpfiles() Index: libfilecmp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfilecmp.tex,v retrieving revision 1.5 retrieving revision 1.5.18.1 diff -C2 -d -r1.5 -r1.5.18.1 *** libfilecmp.tex 11 May 2001 17:01:32 -0000 1.5 --- libfilecmp.tex 20 Mar 2002 18:54:03 -0000 1.5.18.1 *************** *** 42,45 **** --- 42,46 ---- the comparison could not be done for some reason. + The \var{common} parameter is a list of file names found in both directories. The \var{shallow} and \var{use_statcache} parameters have the same meanings and default values as for \function{filecmp.cmp()}. From nnorwitz@users.sourceforge.net Wed Mar 20 18:55:11 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Wed, 20 Mar 2002 10:55:11 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libfilecmp.tex,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv22062/Doc/lib Modified Files: libfilecmp.tex Log Message: SF# 522426, add doc for common parameter for filecmp.cmpfiles() Index: libfilecmp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfilecmp.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** libfilecmp.tex 11 May 2001 17:01:32 -0000 1.5 --- libfilecmp.tex 20 Mar 2002 18:55:09 -0000 1.6 *************** *** 42,45 **** --- 42,46 ---- the comparison could not be done for some reason. + The \var{common} parameter is a list of file names found in both directories. The \var{shallow} and \var{use_statcache} parameters have the same meanings and default values as for \function{filecmp.cmp()}. From tim_one@users.sourceforge.net Wed Mar 20 19:32:05 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Wed, 20 Mar 2002 11:32:05 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib doctest.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv1412 Modified Files: doctest.py Log Message: Change raw "except:" constructs to pass on KeyboardInterrupt. Bugfix candidate? Don't know -- never bothered me, but it's minor either way. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** doctest.py 23 Oct 2001 02:21:52 -0000 1.21 --- doctest.py 20 Mar 2002 19:32:03 -0000 1.22 *************** *** 431,434 **** --- 431,436 ---- got = fakeout.get() state = OK + except KeyboardInterrupt: + raise except: # See whether the exception was expected. *************** *** 522,525 **** --- 524,529 ---- # to look like a string <0.9 wink> doc = str(doc) + except KeyboardInterrupt: + raise except: return 0, 0 From nnorwitz@users.sourceforge.net Wed Mar 20 21:32:09 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Wed, 20 Mar 2002 13:32:09 -0800 Subject: [Python-checkins] CVS: python/dist/src pyconfig.h.in,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv5936 Modified Files: pyconfig.h.in Log Message: Remove compiler warnings on Solaris 8. Can go into 2.2.x, but not necessary. Index: pyconfig.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/pyconfig.h.in,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** pyconfig.h.in 16 Feb 2002 23:33:23 -0000 1.22 --- pyconfig.h.in 20 Mar 2002 21:32:07 -0000 1.23 *************** *** 107,111 **** --- 107,113 ---- /* This must be set to 64 on some systems to enable large file support */ + #ifndef _FILE_OFFSET_BITS #undef _FILE_OFFSET_BITS + #endif /* Define if getpgrp() must be called as getpgrp(0). */ From nnorwitz@users.sourceforge.net Wed Mar 20 21:32:09 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Wed, 20 Mar 2002 13:32:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _hotshot.c,1.15,1.16 pyexpat.c,2.58,2.59 stropmodule.c,2.84,2.85 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv5936/Modules Modified Files: _hotshot.c pyexpat.c stropmodule.c Log Message: Remove compiler warnings on Solaris 8. Can go into 2.2.x, but not necessary. Index: _hotshot.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_hotshot.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** _hotshot.c 3 Mar 2002 02:59:15 -0000 1.15 --- _hotshot.c 20 Mar 2002 21:32:07 -0000 1.16 *************** *** 1454,1458 **** int i = 0; ! while (*rev && !isdigit(*rev)) ++rev; while (rev[i] != ' ' && rev[i] != '\0') --- 1454,1458 ---- int i = 0; ! while (*rev && !isdigit((int)*rev)) ++rev; while (rev[i] != ' ' && rev[i] != '\0') Index: pyexpat.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v retrieving revision 2.58 retrieving revision 2.59 diff -C2 -d -r2.58 -r2.59 *** pyexpat.c 11 Feb 2002 23:27:45 -0000 2.58 --- pyexpat.c 20 Mar 2002 21:32:07 -0000 2.59 *************** *** 1367,1371 **** int i = 0; ! while (!isdigit(*rev)) ++rev; while (rev[i] != ' ' && rev[i] != '\0') --- 1367,1371 ---- int i = 0; ! while (!isdigit((int)*rev)) ++rev; while (rev[i] != ' ' && rev[i] != '\0') Index: stropmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/stropmodule.c,v retrieving revision 2.84 retrieving revision 2.85 diff -C2 -d -r2.84 -r2.85 *** stropmodule.c 28 Nov 2001 22:07:30 -0000 2.84 --- stropmodule.c 20 Mar 2002 21:32:07 -0000 2.85 *************** *** 767,771 **** else x = PyOS_strtol(s, &end, base); ! if (end == s || !isalnum(end[-1])) goto bad; while (*end && isspace(Py_CHARMASK(*end))) --- 767,771 ---- else x = PyOS_strtol(s, &end, base); ! if (end == s || !isalnum((int)end[-1])) goto bad; while (*end && isspace(Py_CHARMASK(*end))) From skip@pobox.com Wed Mar 20 21:40:43 2002 From: skip@pobox.com (Skip Montanaro) Date: Wed, 20 Mar 2002 15:40:43 -0600 Subject: [Python-checkins] CVS: python/dist/src pyconfig.h.in,1.22,1.23 In-Reply-To: References: Message-ID: <15513.475.534331.133535@beluga.mojam.com> Neal> /* This must be set to 64 on some systems to enable large file support */ Neal> + #ifndef _FILE_OFFSET_BITS Neal> #undef _FILE_OFFSET_BITS Neal> + #endif This doesn't look right to me. Either you define it if it's not defined or undef it if it is. If it's not defined there's not much point in undef-ing it is there? Skip From neal@metaslash.com Wed Mar 20 21:45:44 2002 From: neal@metaslash.com (Neal Norwitz) Date: Wed, 20 Mar 2002 16:45:44 -0500 Subject: [Python-checkins] CVS: python/dist/src pyconfig.h.in,1.22,1.23 References: <15513.475.534331.133535@beluga.mojam.com> Message-ID: <3C990308.B6E93E4E@metaslash.com> Skip Montanaro wrote: > > Neal> /* This must be set to 64 on some systems to enable large file support */ > Neal> + #ifndef _FILE_OFFSET_BITS > Neal> #undef _FILE_OFFSET_BITS > Neal> + #endif > > This doesn't look right to me. Either you define it if it's not defined or > undef it if it is. If it's not defined there's not much point in undef-ing > it is there? :-) This is the preprocessed file. The #undef becomes a #define (at least on Solaris & Linux) in the result file: pyconfig.h. I suppose the real fix would be to not output the line at all (since it is already defined on Solaris), but I don't know how to do that. Neal From akuchling@users.sourceforge.net Wed Mar 20 23:56:37 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Wed, 20 Mar 2002 15:56:37 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom pulldom.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory usw-pr-cvs1:/tmp/cvs-serv27055 Modified Files: pulldom.py Log Message: [Apply patch #500457 from the PyXML tracker] Add iterator support to pulldom.DOMEventStream New feature, so not a bugfix candidate (though it should be safe for inclusion) Index: pulldom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/pulldom.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** pulldom.py 30 Nov 2001 22:22:26 -0000 1.23 --- pulldom.py 20 Mar 2002 23:56:34 -0000 1.24 *************** *** 228,231 **** --- 228,240 ---- raise IndexError + def next(self): + rc = self.getEvent() + if rc: + return rc + raise StopIteration + + def __iter__(self): + return self + def expandNode(self, node): event = self.getEvent() From bwarsaw@users.sourceforge.net Thu Mar 21 05:54:16 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Wed, 20 Mar 2002 21:54:16 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0279.txt,1.7,1.8 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv28130 Modified Files: pep-0279.txt Log Message: Raymond Hettinger's latest update. Index: pep-0279.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0279.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pep-0279.txt 11 Mar 2002 19:31:23 -0000 1.7 --- pep-0279.txt 21 Mar 2002 05:54:14 -0000 1.8 *************** *** 13,17 **** Abstract ! This PEP introduces four orthogonal (not mutually exclusive) ideas for enhancing the generators introduced in Python version 2.2 [1]. The goal is to increase the convenience, utility, and power --- 13,17 ---- Abstract ! This PEP introduces three orthogonal (not mutually exclusive) ideas for enhancing the generators introduced in Python version 2.2 [1]. The goal is to increase the convenience, utility, and power *************** *** 29,33 **** Generators, as proposed in PEP 255 [1], were introduced as a means for ! making it easier to create iterators, especially ones with a complex internal execution or variable states. When I created new programs, generators were often the tool of choice for creating an iterator. --- 29,33 ---- Generators, as proposed in PEP 255 [1], were introduced as a means for ! making it easier to create iterators, especially ones with complex internal execution or variable states. When I created new programs, generators were often the tool of choice for creating an iterator. *************** *** 35,39 **** However, when updating existing programs, I found that the tool had another use, one that improved program function as well as structure. ! Those programs exhibited a pattern of creating large lists and then looping over them. As data sizes increased, the programs encountered scalability limitations owing to excessive memory consumption (and --- 35,39 ---- However, when updating existing programs, I found that the tool had another use, one that improved program function as well as structure. ! Some programs exhibited a pattern of creating large lists and then looping over them. As data sizes increased, the programs encountered scalability limitations owing to excessive memory consumption (and *************** *** 54,61 **** all iterables with the same advantage that iteritems() affords to dictionaries -- a compact, readable, reliable index notation. ! 2. Establish a generator alternative to list comprehensions [3] ! to provide a simple way to convert a list comprehensions into ! generators whenever memory issues arise. 3. Add a generator method to enable exceptions to be passed to a --- 54,61 ---- all iterables with the same advantage that iteritems() affords to dictionaries -- a compact, readable, reliable index notation. ! 2. Establish a generator alternative to list comprehensions [3] ! that provides a simple way to convert a list comprehension into ! a generator whenever memory issues arise. 3. Add a generator method to enable exceptions to be passed to a *************** *** 64,81 **** passing helps mitigate the try/finally prohibition for generators. - 4. [Proposal 4 is now deferred until Python 2.4] - Extend the syntax of the 'yield' keyword to enable generator - parameter passing. The resulting increase in power simplifies - the creation of consumer streams which have a complex execution - state and/or variable state. - All of the suggestions are designed to take advantage of the existing implementation and require little additional effort to incorporate. Each is backward compatible and requires no new ! keywords. The first three generator tools go into Python 2.3 when generators become final and are not imported from __future__. - The fourth proposal should be considered deferred and will be - proposed for Python 2.4 after the Python community has more - experience with generators. --- 64,72 ---- passing helps mitigate the try/finally prohibition for generators. All of the suggestions are designed to take advantage of the existing implementation and require little additional effort to incorporate. Each is backward compatible and requires no new ! keywords. The three generator tools go into Python 2.3 when generators become final and are not imported from __future__. *************** *** 84,92 **** There is not currently a CPython implementation; however, a simulation ! module written in pure Python is available on SourceForge [7]. The simulation covers every feature proposed in this PEP and is meant to allow direct experimentation with the proposals. ! There is also a module [8] with working source code for all of the examples used in this PEP. It serves as a test suite for the simulator and it documents how each of the new features works in practice. --- 75,83 ---- There is not currently a CPython implementation; however, a simulation ! module written in pure Python is available on SourceForge [5]. The simulation covers every feature proposed in this PEP and is meant to allow direct experimentation with the proposals. ! There is also a module [6] with working source code for all of the examples used in this PEP. It serves as a test suite for the simulator and it documents how each of the new features works in practice. *************** *** 99,110 **** Tim did not have an opportunity to give an assessment. ! Specification for a new builtin: ! def indexed(collection, cnt=0, limit=None): 'Generates an indexed series: (0,seqn[0]), (1,seqn[1]) ...' gen = iter(collection) ! while limit is None or cnt5] - print g.next() This would be implemented as if it had been written: --- 180,183 ---- *************** *** 191,195 **** yield (len(line), line) g = __temp() ! print g.next() Note A: There is some discussion about whether the enclosing brackets --- 188,192 ---- yield (len(line), line) g = __temp() ! Note A: There is some discussion about whether the enclosing brackets *************** *** 211,215 **** code to a generator by adding yield. Likewise, it can be converted back to a list by deleting yield. This makes it easy to scale-up ! programs from small datasets to ones large enough to warrant just in time evaluation. --- 208,212 ---- code to a generator by adding yield. Likewise, it can be converted back to a list by deleting yield. This makes it easy to scale-up ! programs from small datasets to ones large enough to warrant just in time evaluation. *************** *** 235,264 **** ! Commentary from GvR: Cute hack, but I think the use of the [] syntax strongly suggests that it would return a list, not an iterator. I also think that this is trying to turn Python into a functional language, where most algorithms use lazy infinite sequences, and I ! just don't think that's where its future lies. ! Commentary from Ka-Ping Yee: I am very happy with the things you have proposed in this PEP. I feel quite positive about generator comprehensions and have no reservations. So a +1 on that. ! Commentary from Neil Schemenauer: I'm -0 on the generator list comprehensions. They don't seem to add much. You could easily use a nested generator to do the same thing. They smell like lambda. ! Commentary for Magnus Lie Hetland: Generator comprehensions seem mildly useful, but I vote +0. Defining a separate, named generator would probably be my preference. On the other hand, I do see the advantage of "scaling up" from list comprehensions. ! Author response: This may be before its time in that some people still ! don't like list comprehensions and half of this PEP's reviewers did ! not have any use for generators in any form. What I like best about ! generator comprehensions is that I can design using list ! comprehensions and then easily switch to a generator (by adding ! yield) in response to scalability requirements (when the list ! comprehension produces too large of an intermediate result). --- 232,279 ---- ! Comments from GvR: Cute hack, but I think the use of the [] syntax strongly suggests that it would return a list, not an iterator. I also think that this is trying to turn Python into a functional language, where most algorithms use lazy infinite sequences, and I ! just don't think that's where its future lies. ! Comments from Ka-Ping Yee: I am very happy with the things you have proposed in this PEP. I feel quite positive about generator comprehensions and have no reservations. So a +1 on that. ! Comments from Neil Schemenauer: I'm -0 on the generator list comprehensions. They don't seem to add much. You could easily use a nested generator to do the same thing. They smell like lambda. ! Comments for Magnus Lie Hetland: Generator comprehensions seem mildly useful, but I vote +0. Defining a separate, named generator would probably be my preference. On the other hand, I do see the advantage of "scaling up" from list comprehensions. ! Comments from the Community: The response to the generator comprehension ! proposal has been mostly favorable. There were some 0 votes from ! people who didn't see a real need or who were not energized by the ! idea. Some of the 0 votes were tempered by comments that the reviewer ! did not even like list comprehensions or did not have any use for ! generators in any form. The +1 votes outnumbered the 0 votes by about ! two to one. ! ! Author response: I've studied several syntactical variations and ! concluded that the brackets are essential for: ! - teachability (it's like a list comprehension) ! - set-off (yield applies to the comprehension not the enclosing ! function) ! - substitutability (list comprehensions can be made lazy just by ! adding yield) ! ! What I like best about generator comprehensions is that I can design ! using list comprehensions and then easily switch to a generator (by ! adding yield) in response to scalability requirements (when the list ! comprehension produces too large of an intermediate result). Had ! generators already been in-place when list comprehensions were ! accepted, the yield option might have been incorporated from the ! start. For certain, the mathematical style notation is explicit and ! readable as compared to a separate function definition with an ! embedded yield. *************** *** 269,276 **** def logger(): ! start = time.time() ! log = [] try: ! while 1:0 log.append( time.time() - start ) yield log[-1] --- 284,291 ---- def logger(): ! start = time.time() ! log = [] try: ! while 1: log.append( time.time() - start ) yield log[-1] *************** *** 280,290 **** g = logger() for i in [10,20,40,80,160]: ! testsuite(i) ! g.next() g.throw(WriteLog) There is no existing work-around for triggering an exception inside a generator. This is a true deficiency. It is the only ! case in Python where active code cannot be excepted to or through. Generator exception passing also helps address an intrinsic limitation --- 295,305 ---- g = logger() for i in [10,20,40,80,160]: ! testsuite(i) ! g.next() g.throw(WriteLog) There is no existing work-around for triggering an exception inside a generator. This is a true deficiency. It is the only ! case in Python where active code cannot be excepted to or through. Generator exception passing also helps address an intrinsic limitation *************** *** 292,296 **** trigger clean-up code [1]. Without .throw(), the current work-around forces the resolution or clean-up code to be moved outside the generator. ! Note A: The name of the throw method was selected for several --- 307,311 ---- trigger clean-up code [1]. Without .throw(), the current work-around forces the resolution or clean-up code to be moved outside the generator. ! Note A: The name of the throw method was selected for several *************** *** 308,316 **** Note B: The throw syntax should exactly match raise's syntax: ! throw([expression, [expression, [expression]]]) ! Accordingly, it should be implemented to handle all of the following: ! raise string g.throw(string) raise string, data g.throw(string,data) --- 323,331 ---- Note B: The throw syntax should exactly match raise's syntax: ! throw([expression, [expression, [expression]]]) ! Accordingly, it should be implemented to handle all of the following: ! raise string g.throw(string) raise string, data g.throw(string,data) *************** *** 320,345 **** ! Commentary from GvR: I'm not convinced that the cleanup problem that this is trying to solve exists in practice. I've never felt the need ! to put yield inside a try/except. I think the PEP doesn't make enough ! of a case that this is useful. ! Commentary from Ka-Ping Yee: I agree that the exception issue needs to be resolved and [that] you have suggested a fine solution. ! Commentary from Neil Schemenauer: The exception passing idea is one I hadn't thought of before and looks interesting. If we enable the passing of values back, then we should add this feature too. ! Commentary for Magnus Lie Hetland: Even though I cannot speak for the ease of implementation, I vote +1 for the exception passing mechanism. Author response: When the sole use of generators is to simplify writing ! iterators for lazy producers, then the odds of needing generator ! exception passing are very slim. If, on the other hand, generators are used to write lazy consumers, create coroutines, generate output streams, or simply for their marvelous capability for restarting a previously frozen state, THEN the need to raise exceptions will ! come up almost every time. I'm no judge of what is truly Pythonic, but am still astonished --- 335,369 ---- ! Comments from GvR: I'm not convinced that the cleanup problem that this is trying to solve exists in practice. I've never felt the need ! to put yield inside a try/except. I think the PEP doesn't make enough ! of a case that this is useful. ! Comments from Ka-Ping Yee: I agree that the exception issue needs to be resolved and [that] you have suggested a fine solution. ! Comments from Neil Schemenauer: The exception passing idea is one I hadn't thought of before and looks interesting. If we enable the passing of values back, then we should add this feature too. ! Comments for Magnus Lie Hetland: Even though I cannot speak for the ease of implementation, I vote +1 for the exception passing mechanism. + Comments from the Community: The response has been mostly favorable. One + negative comment from GvR is shown above. The other was from Martin von + Loewis who was concerned that it could be difficult to implement and + is withholding his support until a working patch is available. To probe + Martin's comment, I checked with the implementers of the original + generator PEP for an opinion on the ease of implementation. They felt that + implementation would be straight-forward and could be grafted onto the + existing implementation without disturbing its internals. + Author response: When the sole use of generators is to simplify writing ! iterators for lazy producers, then the odds of needing generator ! exception passing are slim. If, on the other hand, generators are used to write lazy consumers, create coroutines, generate output streams, or simply for their marvelous capability for restarting a previously frozen state, THEN the need to raise exceptions will ! come up frequently. I'm no judge of what is truly Pythonic, but am still astonished *************** *** 351,515 **** - Specification for Generator Parameter Passing [Deferred Proposal] - - 1. Allow 'yield' to assign a value as in: - - def mygen(): - while 1: - x = yield None - print x - - 2. Let the .next() method take a value to pass to the generator as in: - - g = mygen() - g.next() # runs the generator until the first 'yield' - g.next(1) # '1' is bound to 'x' in mygen(), then printed - g.next(2) # '2' is bound to 'x' in mygen(), then printed - - The control flow of 'yield' and 'next' is unchanged by this proposal. - The only change is that a value can be sent into the generator. - By analogy, consider the quality improvement from GOSUB (which had - no argument passing mechanism) to modern procedure calls (which can - pass in arguments and return values). - - Most of the underlying machinery is already in place, only the - communication needs to be added by modifying the parse syntax to - accept the new 'x = yield expr' syntax and by allowing the .next() - method to accept an optional argument. - - Yield is more than just a simple iterator creator. It does - something else truly wonderful -- it suspends execution and saves - state. It is good for a lot more than writing iterators. This - proposal further expands its capability by making it easier to - share data with the generator. - - The .next(arg) mechanism is especially useful for: - 1. Sending data to any generator - 2. Writing lazy consumers with complex execution states - 3. Writing co-routines (as demonstrated in Dr. Mertz's article [5]) - - The proposal is a clear improvement over the existing alternative - of passing data via global variables. It is also much simpler, - more readable and easier to debug than an approach involving the - threading module with its attendant mutexes, semaphores, and data - queues. A class-based approach competes well when there are no - complex execution states or variable states. However, when the - complexity increases, generators with parameter passing are much simpler - because they automatically save state (unlike classes which must - explicitly save the variable and execution state in instance variables). - - Note A: This proposal changes 'yield' from a statement to an - expression with binding and precedence similar to lambda. - - - Example of a Complex Consumer - - The encoder for arithmetic compression sends a series of - fractional values to a complex, lazy consumer. That consumer - makes computations based on previous inputs and only writes out - when certain conditions have been met. After the last fraction is - received, it has a procedure for flushing any unwritten data. - - - Example of a Consumer Stream - - def filelike(packagename, appendOrOverwrite): - cum = [] - if appendOrOverwrite == 'w+': - cum.extend(packages[packagename]) - try: - while 1: - dat = yield None - cum.append(dat) - except FlushStream: - packages[packagename] = cum - - ostream = filelike('mydest','w') # Analogous to file.open(name,flag) - ostream.next() # Advance to the first yield - ostream.next(firstdat) # Analogous to file.write(dat) - ostream.next(seconddat) - ostream.throw(FlushStream) # This feature proposed above - - - Example of a Complex Consumer - - Loop over the picture files in a directory, shrink them - one at a time to thumbnail size using PIL [6], and send them to a - lazy consumer. That consumer is responsible for creating a large - blank image, accepting thumbnails one at a time and placing them - in a 5 by 3 grid format onto the blank image. Whenever the grid is - full, it writes-out the large image as an index print. A - FlushStream exception indicates that no more thumbnails are - available and that the partial index print should be written out - if there are one or more thumbnails on it. - - - Example of a Producer and Consumer Used Together in a Pipe-like Fashion - - 'Analogy to Linux style pipes: source | upper | sink' - sink = sinkgen() - sink.next() - for word in source(): - sink.next(word.upper()) - - - Commentary from GvR: We discussed this at length when we were hashing - out generators and coroutines, and found that there's always a problem - with this: the argument to the first next() call has to be thrown away, - because it doesn't correspond to a yield statement. This looks ugly - (note that the example code has a dummy call to next() to get the - generator going). But there may be useful examples that can only be - programmed (elegantly) with this feature, so I'm reserving judgment. - I can believe that it's easy to implement. - - Commentary from Ka-Ping Yee: I also think there is a lot of power to be - gained from generator argument passing. - - Commentary from Neil Schemenauer: I like the idea of being able to pass - values back into a generator. I originally pitched this idea to Guido - but in the end we decided against it (at least for the initial - implementation). There was a few issues to work out but I can't seem - to remember what they were. My feeling is that we need to wait until - the Python community has more experience with generators before adding - this feature. Maybe for 2.4 but not for 2.3. In the mean time you - can work around this limitation by making your generator a method. - Values can be passed back by mutating the instance. - - Commentary for Magnus Lie Hetland: I like the generator parameter - passing mechanism. Although I see no need to defer it, deferral seems - to be the most likely scenario, and in the meantime I guess the - functionality can be emulated either by implementing the generator - as a method, or by passing a parameter with the exception - passing mechanism. - - Author response: Okay, consider this part of the proposal deferred - until 2.4. - - - - Restartability - - [Discussion of restartability deleted] - - Commentary from GvR: The PEP then goes on to discuss restartable - iterators. I think this is an evil idea obtained from reading too - much about C++ STL iterators. It should definitely be a separate - PEP if the author wants me to take this seriously. - - Commentary from Ka-Ping Yee: I have less of an opinion on restartability - since i have not yet had to really run into that issue. It seems - reasonable that it might be good idea, though perhaps YAGNI will apply - here until I experience the need for it first-hand. - - Commentary for Magnus Lie Hetland: I guess there is no real need to comment - on restartability, but I can't see that I have any need for it. - - Author response: Over thirty reviewers responded, only one was interested - in restartability on the theory that it made life easier for beginners - and that it made lazy evaluation more substitutable for full - evaluation. I was never sold on it myself. Consider it retracted. - - - References --- 375,378 ---- *************** *** 526,539 **** http://python.sourceforge.net/peps/pep-0234.html ! [5] Dr. David Mertz's draft column for Charming Python. ! http://gnosis.cx/publish/programming/charming_python_b5.txt ! ! [6] PIL, the Python Imaging Library can be found at: ! http://www.pythonware.com/products/pil/ ! ! [7] A pure Python simulation of every feature in this PEP is at: http://sourceforge.net/tracker/download.php?group_id=5470&atid=305470&file_id=17348&aid=513752 ! [8] The full, working source code for each of the examples in this PEP along with other examples and tests is at: http://sourceforge.net/tracker/download.php?group_id=5470&atid=305470&file_id=17412&aid=513756 --- 389,396 ---- http://python.sourceforge.net/peps/pep-0234.html ! [5] A pure Python simulation of every feature in this PEP is at: http://sourceforge.net/tracker/download.php?group_id=5470&atid=305470&file_id=17348&aid=513752 ! [6] The full, working source code for each of the examples in this PEP along with other examples and tests is at: http://sourceforge.net/tracker/download.php?group_id=5470&atid=305470&file_id=17412&aid=513756 From loewis@users.sourceforge.net Thu Mar 21 08:55:30 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Thu, 21 Mar 2002 00:55:30 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.49,1.50 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv3002/Lib/test Modified Files: test_unicode.py Log Message: Do not insert characters for unicode-escape decoders if the error mode is "ignore". Fixes #529104. Index: test_unicode.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** test_unicode.py 7 Feb 2002 11:33:49 -0000 1.49 --- test_unicode.py 21 Mar 2002 08:55:27 -0000 1.50 *************** *** 542,545 **** --- 542,553 ---- verify(unicode('Andr\202 x','ascii','replace') == u'Andr\uFFFD x') + verify("\\N{foo}xx".decode("unicode-escape", "ignore") == u"xx") + try: + "\\".decode("unicode-escape") + except ValueError: + pass + else: + raise TestFailed, '"\\".decode("unicode-escape") should fail' + verify(u'hello'.encode('ascii') == 'hello') verify(u'hello'.encode('utf-7') == 'hello') From loewis@users.sourceforge.net Thu Mar 21 08:55:30 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Thu, 21 Mar 2002 00:55:30 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.130,2.131 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv3002/Objects Modified Files: unicodeobject.c Log Message: Do not insert characters for unicode-escape decoders if the error mode is "ignore". Fixes #529104. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.130 retrieving revision 2.131 diff -C2 -d -r2.130 -r2.131 *** unicodeobject.c 28 Feb 2002 11:38:24 -0000 2.130 --- unicodeobject.c 21 Mar 2002 08:55:28 -0000 2.131 *************** *** 1515,1520 **** static ! int unicodeescape_decoding_error(const char **source, ! Py_UNICODE *x, const char *errors, const char *details) --- 1515,1519 ---- static ! int unicodeescape_decoding_error(Py_UNICODE **x, const char *errors, const char *details) *************** *** 1531,1535 **** } else if (strcmp(errors,"replace") == 0) { ! *x = Py_UNICODE_REPLACEMENT_CHARACTER; return 0; } --- 1530,1535 ---- } else if (strcmp(errors,"replace") == 0) { ! **x = Py_UNICODE_REPLACEMENT_CHARACTER; ! (*x)++; return 0; } *************** *** 1629,1635 **** c = (unsigned char) s[i]; if (!isxdigit(c)) { ! if (unicodeescape_decoding_error(&s, &x, errors, message)) goto onError; ! chr = x; i++; break; --- 1629,1635 ---- c = (unsigned char) s[i]; if (!isxdigit(c)) { ! if (unicodeescape_decoding_error(&p, errors, message)) goto onError; ! chr = 0xffffffff; i++; break; *************** *** 1644,1647 **** --- 1644,1651 ---- } s += i; + if (chr == 0xffffffff) + /* _decoding_error will have already written into the + target buffer. */ + break; store: /* when we get here, chr is a 32-bit unicode character */ *************** *** 1661,1669 **** } else { if (unicodeescape_decoding_error( ! &s, &x, errors, "illegal Unicode character") ) goto onError; - *p++ = x; /* store replacement character */ } break; --- 1665,1672 ---- } else { if (unicodeescape_decoding_error( ! &p, errors, "illegal Unicode character") ) goto onError; } break; *************** *** 1700,1711 **** } } ! if (unicodeescape_decoding_error(&s, &x, errors, message)) goto onError; - *p++ = x; break; default: ! *p++ = '\\'; ! *p++ = (unsigned char)s[-1]; break; } --- 1703,1719 ---- } } ! if (unicodeescape_decoding_error(&p, errors, message)) goto onError; break; default: ! if (s > end) { ! if (unicodeescape_decoding_error(&p, errors, "\\ at end of string")) ! goto onError; ! } ! else { ! *p++ = '\\'; ! *p++ = (unsigned char)s[-1]; ! } break; } *************** *** 1910,1914 **** while (s < end) { unsigned char c; ! Py_UNICODE x; int i; --- 1918,1922 ---- while (s < end) { unsigned char c; ! Py_UCS4 x; int i; *************** *** 1939,1945 **** c = (unsigned char)s[i]; if (!isxdigit(c)) { ! if (unicodeescape_decoding_error(&s, &x, errors, "truncated \\uXXXX")) goto onError; i++; break; --- 1947,1954 ---- c = (unsigned char)s[i]; if (!isxdigit(c)) { ! if (unicodeescape_decoding_error(&p, errors, "truncated \\uXXXX")) goto onError; + x = 0xffffffff; i++; break; *************** *** 1954,1958 **** } s += i; ! *p++ = x; } if (_PyUnicode_Resize(&v, (int)(p - buf))) --- 1963,1968 ---- } s += i; ! if (x != 0xffffffff) ! *p++ = x; } if (_PyUnicode_Resize(&v, (int)(p - buf))) From doerwalter@users.sourceforge.net Thu Mar 21 10:38:42 2002 From: doerwalter@users.sourceforge.net (Walter D?rwald) Date: Thu, 21 Mar 2002 02:38:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libwarnings.tex,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv27021/Doc/lib Modified Files: libwarnings.tex Log Message: [Apply SF patch #504943] This patch makes it possible to pass Warning instances as the first argument to warnings.warn. In this case the category argument will be ignored. The message text used will be str(warninginstance). Index: libwarnings.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwarnings.tex,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** libwarnings.tex 12 Mar 2002 19:49:31 -0000 1.7 --- libwarnings.tex 21 Mar 2002 10:38:40 -0000 1.8 *************** *** 146,150 **** Issue a warning, or maybe ignore it or raise an exception. The \var{category} argument, if given, must be a warning category class ! (see above); it defaults to \exception{UserWarning}. This function raises an exception if the particular warning issued is changed into an error by the warnings filter see above. The \var{stacklevel} --- 146,153 ---- Issue a warning, or maybe ignore it or raise an exception. The \var{category} argument, if given, must be a warning category class ! (see above); it defaults to \exception{UserWarning}. Alternatively ! \var{message} can be a \exception{Warning} instance, in which case ! \var{category} will be ignore and \code{message.__class__} will be used. ! In this case the message text will be \code{str(message)}. This function raises an exception if the particular warning issued is changed into an error by the warnings filter see above. The \var{stacklevel} *************** *** 170,173 **** --- 173,179 ---- the module). The module name defaults to the filename with \code{.py} stripped; if no registry is passed, the warning is never suppressed. + \var{message} must be a string and \var{category} a subclass of + \exception{Warning} or \var{message} may be a \exception{Warning} instance, + in which case \var{category} will be ignored. \end{funcdesc} From doerwalter@users.sourceforge.net Thu Mar 21 10:38:42 2002 From: doerwalter@users.sourceforge.net (Walter D?rwald) Date: Thu, 21 Mar 2002 02:38:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib warnings.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv27021/Lib Modified Files: warnings.py Log Message: [Apply SF patch #504943] This patch makes it possible to pass Warning instances as the first argument to warnings.warn. In this case the category argument will be ignored. The message text used will be str(warninginstance). Index: warnings.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/warnings.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** warnings.py 31 Aug 2001 17:46:35 -0000 1.9 --- warnings.py 21 Mar 2002 10:38:40 -0000 1.10 *************** *** 12,15 **** --- 12,18 ---- def warn(message, category=None, stacklevel=1): """Issue a warning, or maybe ignore it or raise an exception.""" + # Check if message is already a Warning object + if isinstance(message, Warning): + category = message.__class__ # Check category argument if category is None: *************** *** 50,54 **** if registry is None: registry = {} ! key = (message, category, lineno) # Quick test for common case if registry.get(key): --- 53,63 ---- if registry is None: registry = {} ! if isinstance(message, Warning): ! text = str(message) ! category = message.__class__ ! else: ! text = message ! message = category(message) ! key = (text, category, lineno) # Quick test for common case if registry.get(key): *************** *** 57,61 **** for item in filters: action, msg, cat, mod, ln = item ! if (msg.match(message) and issubclass(category, cat) and mod.match(module) and --- 66,70 ---- for item in filters: action, msg, cat, mod, ln = item ! if (msg.match(text) and issubclass(category, cat) and mod.match(module) and *************** *** 69,77 **** return if action == "error": ! raise category(message) # Other actions if action == "once": registry[key] = 1 ! oncekey = (message, category) if onceregistry.get(oncekey): return --- 78,86 ---- return if action == "error": ! raise message # Other actions if action == "once": registry[key] = 1 ! oncekey = (text, category) if onceregistry.get(oncekey): return *************** *** 81,85 **** elif action == "module": registry[key] = 1 ! altkey = (message, category, 0) if registry.get(altkey): return --- 90,94 ---- elif action == "module": registry[key] = 1 ! altkey = (text, category, 0) if registry.get(altkey): return From doerwalter@users.sourceforge.net Thu Mar 21 10:38:42 2002 From: doerwalter@users.sourceforge.net (Walter D?rwald) Date: Thu, 21 Mar 2002 02:38:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.365,1.366 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv27021/Misc Modified Files: NEWS Log Message: [Apply SF patch #504943] This patch makes it possible to pass Warning instances as the first argument to warnings.warn. In this case the category argument will be ignored. The message text used will be str(warninginstance). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.365 retrieving revision 1.366 diff -C2 -d -r1.365 -r1.366 *** NEWS 18 Mar 2002 12:44:08 -0000 1.365 --- NEWS 21 Mar 2002 10:38:40 -0000 1.366 *************** *** 71,74 **** --- 71,76 ---- - distutils bdist commands now offer a --skip-build option. + - warnings.warn now accepts a Warning instance as first argument. + Tools/Demos From nnorwitz@users.sourceforge.net Thu Mar 21 12:58:57 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Thu, 21 Mar 2002 04:58:57 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libwarnings.tex,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv10608/Doc/lib Modified Files: libwarnings.tex Log Message: Fix grammar Index: libwarnings.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwarnings.tex,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** libwarnings.tex 21 Mar 2002 10:38:40 -0000 1.8 --- libwarnings.tex 21 Mar 2002 12:58:54 -0000 1.9 *************** *** 148,152 **** (see above); it defaults to \exception{UserWarning}. Alternatively \var{message} can be a \exception{Warning} instance, in which case ! \var{category} will be ignore and \code{message.__class__} will be used. In this case the message text will be \code{str(message)}. This function raises an exception if the particular warning issued is changed --- 148,152 ---- (see above); it defaults to \exception{UserWarning}. Alternatively \var{message} can be a \exception{Warning} instance, in which case ! \var{category} will be ignored and \code{message.__class__} will be used. In this case the message text will be \code{str(message)}. This function raises an exception if the particular warning issued is changed From jackjansen@users.sourceforge.net Thu Mar 21 14:56:50 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Thu, 21 Mar 2002 06:56:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Resources errors.rsrc,1.4,1.4.20.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Resources In directory usw-pr-cvs1:/tmp/cvs-serv11005/Python 2.2/Mac/Resources Modified Files: Tag: release22-maint errors.rsrc Log Message: Merge rev. 1.5: Updated to new Universal Headers. Also, this checkin should make the file MacBinary again. Index: errors.rsrc =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Resources/errors.rsrc,v retrieving revision 1.4 retrieving revision 1.4.20.1 diff -C2 -d -r1.4 -r1.4.20.1 Binary files /tmp/cvsjJAXmT and /tmp/cvsiT4ZVB differ From loewis@users.sourceforge.net Thu Mar 21 15:11:01 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Thu, 21 Mar 2002 07:11:01 -0800 Subject: [Python-checkins] CVS: python/dist/src configure,1.288,1.289 configure.in,1.298,1.299 pyconfig.h.in,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv15604 Modified Files: configure configure.in pyconfig.h.in Log Message: Patch #532729: check for sem_init in -lrt. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.288 retrieving revision 1.289 diff -C2 -d -r1.288 -r1.289 *** configure 19 Mar 2002 15:15:30 -0000 1.288 --- configure 21 Mar 2002 15:10:56 -0000 1.289 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.297 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.298 [...3167 lines suppressed...] if eval "test \"`echo '$''{'ac_cv_type_socklen_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < *************** *** 7601,7605 **** SRCDIRS="Parser Grammar Objects Python Modules" echo $ac_n "checking for build directories""... $ac_c" 1>&6 ! echo "configure:7604: checking for build directories" >&5 for dir in $SRCDIRS; do if test ! -d $dir; then --- 7648,7652 ---- SRCDIRS="Parser Grammar Objects Python Modules" echo $ac_n "checking for build directories""... $ac_c" 1>&6 ! echo "configure:7651: checking for build directories" >&5 for dir in $SRCDIRS; do if test ! -d $dir; then Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.298 retrieving revision 1.299 diff -C2 -d -r1.298 -r1.299 *** configure.in 19 Mar 2002 15:15:32 -0000 1.298 --- configure.in 21 Mar 2002 15:10:58 -0000 1.299 *************** *** 917,920 **** --- 917,921 ---- AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX + AC_CHECK_LIB(rt, sem_init) # 'Real Time' functions on Solaris # checks for system dependent C++ extensions support Index: pyconfig.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/pyconfig.h.in,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** pyconfig.h.in 20 Mar 2002 21:32:07 -0000 1.23 --- pyconfig.h.in 21 Mar 2002 15:10:58 -0000 1.24 *************** *** 107,113 **** /* This must be set to 64 on some systems to enable large file support */ - #ifndef _FILE_OFFSET_BITS #undef _FILE_OFFSET_BITS - #endif /* Define if getpgrp() must be called as getpgrp(0). */ --- 107,111 ---- *************** *** 761,764 **** --- 759,765 ---- /* Define if you have the ieee library (-lieee). */ #undef HAVE_LIBIEEE + + /* Define if you have the rt library (-lrt). */ + #undef HAVE_LIBRT #ifdef __CYGWIN__ From neal@metaslash.com Thu Mar 21 15:44:32 2002 From: neal@metaslash.com (Neal Norwitz) Date: Thu, 21 Mar 2002 10:44:32 -0500 Subject: [Python-checkins] CVS: python/dist/src configure,1.288,1.289 configure.in,1.298,1.299 pyconfig.h.in,1.23,1.24 References: Message-ID: <3C99FFE0.77A7BBF8@metaslash.com> "Martin v. L?wis" wrote: > > Update of /cvsroot/python/python/dist/src > In directory usw-pr-cvs1:/tmp/cvs-serv15604 > > Modified Files: > configure configure.in pyconfig.h.in > Log Message: > Patch #532729: check for sem_init in -lrt. > > Index: pyconfig.h.in > =================================================================== > RCS file: /cvsroot/python/python/dist/src/pyconfig.h.in,v > retrieving revision 1.23 > retrieving revision 1.24 > diff -C2 -d -r1.23 -r1.24 > *** pyconfig.h.in 20 Mar 2002 21:32:07 -0000 1.23 > --- pyconfig.h.in 21 Mar 2002 15:10:58 -0000 1.24 > *************** > *** 107,113 **** > > /* This must be set to 64 on some systems to enable large file support */ > - #ifndef _FILE_OFFSET_BITS > #undef _FILE_OFFSET_BITS > - #endif > > /* Define if getpgrp() must be called as getpgrp(0). */ Martin: Was this part intentional or was the patch I submitted broken? I needed the #ifndef to stop a compiler warning about _FILE_OFFSET_BITS being redefined from /usr/include/sys/feature_tests.h on Solaris 8. Neal From loewis@informatik.hu-berlin.de Thu Mar 21 16:18:12 2002 From: loewis@informatik.hu-berlin.de (Martin v. =?iso-8859-1?q?L=F6wis?=) Date: 21 Mar 2002 17:18:12 +0100 Subject: [Python-checkins] CVS: python/dist/src configure,1.288,1.289 configure.in,1.298,1.299 pyconfig.h.in,1.23,1.24 In-Reply-To: <3C99FFE0.77A7BBF8@metaslash.com> References: <3C99FFE0.77A7BBF8@metaslash.com> Message-ID: Neal Norwitz writes: > Was this part intentional or was the patch I submitted broken? Neither, nor: pyconfig.h.in is a generated file, using autoheader. I just regenerated it. Any manual changes to it will be lost on regeneration. > I needed the #ifndef to stop a compiler warning about _FILE_OFFSET_BITS > being redefined from /usr/include/sys/feature_tests.h on Solaris 8. Using the ifndef is incorrect. If Python sets _FILE_OFFSET_BITS, that should take precedence; feature_tests.h won't interfere. Can you point to the place where this caused problems? Regards, Martin From neal@metaslash.com Thu Mar 21 17:09:52 2002 From: neal@metaslash.com (Neal Norwitz) Date: Thu, 21 Mar 2002 12:09:52 -0500 Subject: [Python-checkins] CVS: python/dist/src configure,1.288,1.289 configure.in,1.298,1.299 pyconfig.h.in,1.23,1.24 References: <3C99FFE0.77A7BBF8@metaslash.com> Message-ID: <3C9A13E0.765C7209@metaslash.com> "Martin v. L=F6wis" wrote: >=20 > Neal Norwitz writes: >=20 > > Was this part intentional or was the patch I submitted broken? >=20 > Neither, nor: pyconfig.h.in is a generated file, using autoheader. I > just regenerated it. Any manual changes to it will be lost on > regeneration. >=20 > > I needed the #ifndef to stop a compiler warning about _FILE_OFFSET_BI= TS > > being redefined from /usr/include/sys/feature_tests.h on Solaris 8. >=20 > Using the ifndef is incorrect. If Python sets _FILE_OFFSET_BITS, that > should take precedence; feature_tests.h won't interfere. Can you point > to the place where this caused problems? I don't have the warning any more. But I upgraded lots of stuff recently. I agree that the #ifndef was bad, I was just trying to get rid of a compiler warning, but since it's gone. I'm happy. Thanks, Neal From loewis@informatik.hu-berlin.de Thu Mar 21 17:18:33 2002 From: loewis@informatik.hu-berlin.de (Martin v. =?iso-8859-1?q?L=F6wis?=) Date: 21 Mar 2002 18:18:33 +0100 Subject: [Python-checkins] CVS: python/dist/src configure,1.288,1.289 configure.in,1.298,1.299 pyconfig.h.in,1.23,1.24 In-Reply-To: <3C9A13E0.765C7209@metaslash.com> References: <3C99FFE0.77A7BBF8@metaslash.com> <3C9A13E0.765C7209@metaslash.com> Message-ID: Neal Norwitz writes: > I don't have the warning any more. But I upgraded lots of stuff recently. > I agree that the #ifndef was bad, I was just trying to get rid of > a compiler warning, but since it's gone. I'm happy. Good! I guess it could have been the change in pypcre.c 2.23 then. Regards, Martin From jackjansen@users.sourceforge.net Thu Mar 21 20:18:34 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Thu, 21 Mar 2002 12:18:34 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Resources bundle.rsrc,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Resources In directory usw-pr-cvs1:/tmp/cvs-serv15204/Python/Mac/Resources Modified Files: bundle.rsrc Log Message: New checkin to convert from BinHex to AppleSingle encoding. Index: bundle.rsrc =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Resources/bundle.rsrc,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 Binary files /tmp/cvs8FUYOp and /tmp/cvsWAYXdF differ From jackjansen@users.sourceforge.net Thu Mar 21 20:19:32 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Thu, 21 Mar 2002 12:19:32 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Resources bundle.rsrc,1.12,1.12.20.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Resources In directory usw-pr-cvs1:/tmp/cvs-serv15572/Python 2.2/Mac/Resources Modified Files: Tag: release22-maint bundle.rsrc Log Message: Merge of 1.13: checked in to convert from BinHex to AppleSingle. Index: bundle.rsrc =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Resources/bundle.rsrc,v retrieving revision 1.12 retrieving revision 1.12.20.1 diff -C2 -d -r1.12 -r1.12.20.1 Binary files /tmp/cvsqMfMzq and /tmp/cvsaugSeJ differ From jackjansen@users.sourceforge.net Thu Mar 21 21:09:38 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Thu, 21 Mar 2002 13:09:38 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules macmodule.c,1.50,1.51 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules In directory usw-pr-cvs1:/tmp/cvs-serv31875 Modified Files: macmodule.c Log Message: Solve sync() signature conflict differently: manually return 0 if we have GUSI's void sync(). Index: macmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/macmodule.c,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** macmodule.c 8 Dec 2001 18:02:51 -0000 1.50 --- macmodule.c 21 Mar 2002 21:09:36 -0000 1.51 *************** *** 59,67 **** #ifdef USE_GUSI2 - #define sync bad_sync #include #include - #undef sync - int sync(void); #else #define mode_t int --- 59,64 ---- *************** *** 644,648 **** --- 641,650 ---- return NULL; Py_BEGIN_ALLOW_THREADS + #ifdef USE_GUSI2 + sync(); + res = 0; + #else res = sync(); + #endif Py_END_ALLOW_THREADS if (res != 0) From jackjansen@users.sourceforge.net Thu Mar 21 22:36:59 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Thu, 21 Mar 2002 14:36:59 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Tools/IDE Wapplication.py,1.16,1.17 Wwindows.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory usw-pr-cvs1:/tmp/cvs-serv12998 Modified Files: Wapplication.py Wwindows.py Log Message: For reasons I don't fully understand we sometimes get unexpected events in MachoPython. As we don't have MacOS.HandleEvent() we drop these on the floor (with a print). Index: Wapplication.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/Wapplication.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Wapplication.py 4 Feb 2002 12:50:24 -0000 1.16 --- Wapplication.py 21 Mar 2002 22:36:57 -0000 1.17 *************** *** 203,207 **** sys.stderr.write("XXX killed unknown (crashed?) Python window.\n") else: ! MacOS.HandleEvent(event) def suspendresume(self, onoff): --- 203,210 ---- sys.stderr.write("XXX killed unknown (crashed?) Python window.\n") else: ! if hasattr(MacOS, 'HandleEvent'): ! MacOS.HandleEvent(event) ! else: ! print 'Unexpected updateEvent:', event def suspendresume(self, onoff): Index: Wwindows.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/Wwindows.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Wwindows.py 4 Feb 2002 12:50:24 -0000 1.16 --- Wwindows.py 21 Mar 2002 22:36:57 -0000 1.17 *************** *** 520,524 **** if name == "do_inDesk": ! MacOS.HandleEvent(event) return if wid == self.wid: --- 520,527 ---- if name == "do_inDesk": ! if hasattr(MacOS, "HandleEvent"): ! MacOS.HandleEvent(event) ! else: ! print 'Unexpected inDesk event:', event return if wid == self.wid: From jackjansen@users.sourceforge.net Thu Mar 21 22:38:34 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Thu, 21 Mar 2002 14:38:34 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Lib macresource.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib In directory usw-pr-cvs1:/tmp/cvs-serv13456 Modified Files: macresource.py Log Message: Added an open_pathname() method which opens a resource file by pathname, possibly converting from AppleSingle. Index: macresource.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Lib/macresource.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** macresource.py 13 Jan 2002 23:18:00 -0000 1.4 --- macresource.py 21 Mar 2002 22:38:32 -0000 1.5 *************** *** 62,65 **** --- 62,77 ---- raise ResourceFileNotFoundError, filename + refno = open_pathname(pathname) + + # And check that the resource exists now + if type(resid) is type(1): + h = Res.GetResource(restype, resid) + else: + h = Res.GetNamedResource(restype, resid) + return refno + + def open_pathname(pathname): + """Open a resource file given by pathname, possibly decoding an + AppleSingle file""" try: refno = Res.FSpOpenResFile(pathname, 1) *************** *** 73,83 **** else: raise - - - # And check that the resource exists now - if type(resid) is type(1): - h = Res.GetResource(restype, resid) - else: - h = Res.GetNamedResource(restype, resid) return refno --- 85,88 ---- From akuchling@users.sourceforge.net Thu Mar 21 23:27:56 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Thu, 21 Mar 2002 15:27:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils/command bdist_rpm.py,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv30107 Modified Files: bdist_rpm.py Log Message: [Bug #517451] bdist_rpm didn't list all of its Boolean options. (Someone should check the other commands for this same error.) Bugfix candidate. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_rpm.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** bdist_rpm.py 6 Dec 2001 20:57:12 -0000 1.27 --- bdist_rpm.py 21 Mar 2002 23:27:54 -0000 1.28 *************** *** 96,100 **** ] ! boolean_options = ['keep-temp', 'rpm2-mode'] negative_opt = {'no-keep-temp': 'keep-temp', --- 96,100 ---- ] ! boolean_options = ['keep-temp', 'use-rpm-opt-flags', 'rpm3-mode'] negative_opt = {'no-keep-temp': 'keep-temp', From akuchling@users.sourceforge.net Thu Mar 21 23:44:03 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Thu, 21 Mar 2002 15:44:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils/command bdist_wininst.py,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv2395 Modified Files: bdist_wininst.py Log Message: Add unlisted Boolean options. Thomas H., can you please check that I got this right? Bugfix candidate, unless Thomas notes a problem. Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_wininst.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** bdist_wininst.py 20 Feb 2002 08:01:19 -0000 1.29 --- bdist_wininst.py 21 Mar 2002 23:44:01 -0000 1.30 *************** *** 44,48 **** ] ! boolean_options = ['keep-temp'] def initialize_options (self): --- 44,49 ---- ] ! boolean_options = ['keep-temp', 'no-target-compile', 'no-target-optimize', ! 'skip-build'] def initialize_options (self): From akuchling@users.sourceforge.net Thu Mar 21 23:46:56 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Thu, 21 Mar 2002 15:46:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils/command install.py,1.61,1.62 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv2889 Modified Files: install.py Log Message: Add missing Boolean options Remove unused no_compile flag Initialize the Boolean attribute .compile to 0 instead of None Bugfix candidate. Index: install.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/install.py,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** install.py 31 Jan 2002 18:56:00 -0000 1.61 --- install.py 21 Mar 2002 23:46:54 -0000 1.62 *************** *** 135,139 **** ] ! boolean_options = ['force', 'skip-build'] negative_opt = {'no-compile' : 'compile'} --- 135,139 ---- ] ! boolean_options = ['compile', 'force', 'skip-build'] negative_opt = {'no-compile' : 'compile'} *************** *** 165,170 **** self.install_data = None ! self.compile = None ! self.no_compile = None self.optimize = None --- 165,169 ---- self.install_data = None ! self.compile = 0 self.optimize = None From akuchling@users.sourceforge.net Thu Mar 21 23:52:22 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Thu, 21 Mar 2002 15:52:22 -0800 Subject: [Python-checkins] CVS: python/dist/src README,1.141,1.142 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv4827 Modified Files: README Log Message: [Bug #532136] Change path in README, as suggested by Ralph Corderoy Bugfix candidate. Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/README,v retrieving revision 1.141 retrieving revision 1.142 diff -C2 -d -r1.141 -r1.142 *** README 11 Mar 2002 01:05:32 -0000 1.141 --- README 21 Mar 2002 23:52:20 -0000 1.142 *************** *** 649,655 **** failing test manually, as follows: ! python ../Lib/test/test_whatever.py ! (substituting the top of the source tree for .. if you built in a different directory). This runs the test in verbose mode. --- 649,655 ---- failing test manually, as follows: ! ./python ./Lib/test/test_whatever.py ! (substituting the top of the source tree for '.' if you built in a different directory). This runs the test in verbose mode. From akuchling@users.sourceforge.net Fri Mar 22 02:46:43 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Thu, 21 Mar 2002 18:46:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib netrc.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv13290 Modified Files: netrc.py Log Message: [Bug #532115] netrc module was broken * 'macdef' (macro definition) wasn't parsed correctly * account value not reset for a subsequent 'default' line * typo: 'whitepace' -> 'whitespace' Bugfix candidate. Index: netrc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/netrc.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** netrc.py 18 Mar 2002 02:13:48 -0000 1.13 --- netrc.py 22 Mar 2002 02:46:41 -0000 1.14 *************** *** 45,56 **** entryname = lexer.get_token() self.macros[entryname] = [] ! lexer.whitepace = ' \t' while 1: line = lexer.instream.readline() ! if not line or line == '\012' and tt == '\012': ! lexer.whitepace = ' \t\r\n' break - tt = line self.macros[entryname].append(line) else: raise NetrcParseError( --- 45,56 ---- entryname = lexer.get_token() self.macros[entryname] = [] ! lexer.whitespace = ' \t' while 1: line = lexer.instream.readline() ! if not line or line == '\012': ! lexer.whitespace = ' \t\r\n' break self.macros[entryname].append(line) + continue else: raise NetrcParseError( *************** *** 58,70 **** # We're looking at start of an entry for a named machine or default. ! if toplevel == 'machine': ! login = account = password = None ! self.hosts[entryname] = {} while 1: tt = lexer.get_token() ! 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) lexer.push_token(tt) --- 58,68 ---- # We're looking at start of an entry for a named machine or default. ! login = account = password = None ! self.hosts[entryname] = {} while 1: tt = lexer.get_token() ! if (tt=='' or tt == 'machine' or ! tt == 'default' or tt =='macdef'): ! if login and password: self.hosts[entryname] = (login, account, password) lexer.push_token(tt) From tim_one@users.sourceforge.net Fri Mar 22 02:48:48 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 21 Mar 2002 18:48:48 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects complexobject.c,2.54,2.55 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv12235/python/objects Modified Files: complexobject.c Log Message: SF bug 533198: Complex power underflow raises exception. Konrad was too kind. Not only did it raise an exception, the specific exception it raised made no sense. These are old bugs in complex_pow() and friends: 1. Raising 0 to a negative power isn't a range error, it's a domain error, so changed c_pow() to set errno to EDOM in that case instead of ERANGE. 2. Changed complex_pow() to: A. Used the Py_ADJUST_ERANGE2 macro to try to clear errno of a spurious ERANGE error due to underflow in the libm pow() called by c_pow(). B. Produced different exceptions depending on the errno value: i) For errno==EDOM, raise ZeroDivisionError instead of ValueError. This is for consistency with the non-complex cases 0.0**-2 and 0**-2 and 0L**-2. ii) For errno==ERANGE, raise OverflowError. Bugfix candidate. Index: complexobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/complexobject.c,v retrieving revision 2.54 retrieving revision 2.55 diff -C2 -d -r2.54 -r2.55 *** complexobject.c 8 Feb 2002 21:26:07 -0000 2.54 --- complexobject.c 22 Mar 2002 02:48:46 -0000 2.55 *************** *** 132,136 **** else if (a.real == 0. && a.imag == 0.) { if (b.imag != 0. || b.real < 0.) ! errno = ERANGE; r.real = 0.; r.imag = 0.; --- 132,136 ---- else if (a.real == 0. && a.imag == 0.) { if (b.imag != 0. || b.real < 0.) ! errno = EDOM; r.real = 0.; r.imag = 0.; *************** *** 457,463 **** PyFPE_END_PROTECT(p) ! if (errno == ERANGE) { ! PyErr_SetString(PyExc_ValueError, "0.0 to a negative or complex power"); return NULL; } --- 457,469 ---- PyFPE_END_PROTECT(p) ! Py_ADJUST_ERANGE2(p.real, p.imag); ! if (errno == EDOM) { ! PyErr_SetString(PyExc_ZeroDivisionError, "0.0 to a negative or complex power"); + return NULL; + } + else if (errno == ERANGE) { + PyErr_SetString(PyExc_OverflowError, + "complex exponentiaion"); return NULL; } From akuchling@users.sourceforge.net Fri Mar 22 02:48:59 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Thu, 21 Mar 2002 18:48:59 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_netrc.py,NONE,1.1 test_sundry.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv13910 Modified Files: test_sundry.py Added Files: test_netrc.py Log Message: Add a simple test suite for netrc.py, and remove it from test_sundry --- NEW FILE: test_netrc.py --- import netrc, os, tempfile, test_support, unittest TEST_NETRC = """ machine foo login log1 password pass1 account acct1 macdef macro1 line1 line2 macdef macro2 line3 line4 default login log2 password pass2 """ temp_filename = tempfile.mktemp() class NetrcTestCase(unittest.TestCase): def setUp (self): fp = open(temp_filename, 'wt') fp.write(TEST_NETRC) fp.close() self.netrc = netrc.netrc(temp_filename) def tearDown (self): del self.netrc os.unlink(temp_filename) def test_case_1(self): self.assert_(self.netrc.macros == {'macro1':['line1\n', 'line2\n'], 'macro2':['line3\n', 'line4\n']} ) self.assert_(self.netrc.hosts['foo'] == ('log1', 'acct1', 'pass1')) self.assert_(self.netrc.hosts['default'] == ('log2', None, 'pass2')) if __name__ == "__main__": test_support.run_unittest(NetrcTestCase) Index: test_sundry.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sundry.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test_sundry.py 7 Dec 2001 16:43:19 -0000 1.8 --- test_sundry.py 22 Mar 2002 02:48:57 -0000 1.9 *************** *** 56,60 **** import multifile import mutex - import netrc import nntplib import nturl2path --- 56,59 ---- From tim_one@users.sourceforge.net Fri Mar 22 06:32:34 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 21 Mar 2002 22:32:34 -0800 Subject: [Python-checkins] CVS: python/dist/src/PC pyconfig.h,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory usw-pr-cvs1:/tmp/cvs-serv23454/python/PC Modified Files: pyconfig.h Log Message: Enable pymalloc by default in the Windows build. Index: pyconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/pyconfig.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pyconfig.h 1 Mar 2002 08:31:07 -0000 1.7 --- pyconfig.h 22 Mar 2002 06:32:32 -0000 1.8 *************** *** 194,198 **** /* egcs/gnu-win32 defines __GNUC__ and _WIN32 */ #if defined(__GNUC__) && defined(_WIN32) ! /* XXX These defines are likely incomplete, but should be easy to fix. They should be complete enough to build extension modules. */ /* Suggested by Rene Liebscher to avoid a GCC 2.91.* --- 194,198 ---- /* egcs/gnu-win32 defines __GNUC__ and _WIN32 */ #if defined(__GNUC__) && defined(_WIN32) ! /* XXX These defines are likely incomplete, but should be easy to fix. They should be complete enough to build extension modules. */ /* Suggested by Rene Liebscher to avoid a GCC 2.91.* *************** *** 240,244 **** #define HAVE_LONG_LONG 1 ! #define LONG_LONG long long #endif /* GNUC */ --- 240,244 ---- #define HAVE_LONG_LONG 1 ! #define LONG_LONG long long #endif /* GNUC */ *************** *** 246,250 **** #if defined(__LCC__) ! /* XXX These defines are likely incomplete, but should be easy to fix. They should be complete enough to build extension modules. */ --- 246,250 ---- #if defined(__LCC__) ! /* XXX These defines are likely incomplete, but should be easy to fix. They should be complete enough to build extension modules. */ *************** *** 506,509 **** --- 506,512 ---- /* Define if you want cycle garbage collection */ #define WITH_CYCLE_GC 1 + + /* Use Python's own small-block memory-allocator. */ + #define WITH_PYMALLOC 1 /* Define if you have clock. */ From mwh@users.sourceforge.net Fri Mar 22 11:22:29 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Fri, 22 Mar 2002 03:22:29 -0800 Subject: [Python-checkins] CVS: python/dist/src configure,1.279.6.3,1.279.6.4 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv21955 Modified Files: Tag: release22-maint configure Log Message: I forgot to regenerate this. Oops. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.279.6.3 retrieving revision 1.279.6.4 diff -C2 -d -r1.279.6.3 -r1.279.6.4 *** configure 8 Mar 2002 14:11:35 -0000 1.279.6.3 --- configure 22 Mar 2002 11:22:24 -0000 1.279.6.4 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.288.6.3 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.288.6.4 # Guess values for system-dependent variables and create Makefiles. *************** *** 1429,1433 **** case $ac_sys_system in AIX*) ! LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); $(LINKCC)";; dgux*) LINKCC="LD_RUN_PATH=$libdir $(LINKCC)";; --- 1429,1433 ---- case $ac_sys_system in AIX*) ! LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); $LINKCC";; dgux*) LINKCC="LD_RUN_PATH=$libdir $(LINKCC)";; From jackjansen@users.sourceforge.net Fri Mar 22 14:15:09 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 22 Mar 2002 06:15:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/scripts genpluginprojects.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/scripts In directory usw-pr-cvs1:/tmp/cvs-serv29317 Modified Files: genpluginprojects.py Log Message: - Weaklink InterfaceLib in _Res module - forgot to pass libraryflags and stdlibraryflags on to ppc/carbon project generation. First half of fix to 531398. Index: genpluginprojects.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/scripts/genpluginprojects.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** genpluginprojects.py 14 Mar 2002 23:14:43 -0000 1.28 --- genpluginprojects.py 22 Mar 2002 14:15:07 -0000 1.29 *************** *** 42,48 **** # a single multitarget project, but easier to implement for now. genpluginproject("ppc", module, project, projectdir, sources, sourcedirs, ! libraries, extradirs, extraexportsymbols, outputdir) genpluginproject("carbon", module, project, projectdir, sources, sourcedirs, ! libraries, extradirs, extraexportsymbols, outputdir) return templatename = "template-%s" % architecture --- 42,50 ---- # a single multitarget project, but easier to implement for now. genpluginproject("ppc", module, project, projectdir, sources, sourcedirs, ! libraries, extradirs, extraexportsymbols, outputdir, libraryflags, ! stdlibraryflags, prefixname) genpluginproject("carbon", module, project, projectdir, sources, sourcedirs, ! libraries, extradirs, extraexportsymbols, outputdir, libraryflags, ! stdlibraryflags, prefixname) return templatename = "template-%s" % architecture *************** *** 163,167 **** genpluginproject("carbon", "_Qt", outputdir="::Lib:Carbon") genpluginproject("all", "_Qdoffs", outputdir="::Lib:Carbon") ! genpluginproject("all", "_Res", outputdir="::Lib:Carbon") genpluginproject("all", "_Scrap", outputdir="::Lib:Carbon") genpluginproject("ppc", "_Snd", libraries=["CarbonAccessors.o", "SoundLib"], outputdir="::Lib:Carbon") --- 165,170 ---- genpluginproject("carbon", "_Qt", outputdir="::Lib:Carbon") genpluginproject("all", "_Qdoffs", outputdir="::Lib:Carbon") ! genpluginproject("all", "_Res", ! stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("all", "_Scrap", outputdir="::Lib:Carbon") genpluginproject("ppc", "_Snd", libraries=["CarbonAccessors.o", "SoundLib"], outputdir="::Lib:Carbon") From jackjansen@users.sourceforge.net Fri Mar 22 14:16:41 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 22 Mar 2002 06:16:41 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/res ressupport.py,1.20,1.21 _Resmodule.c,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/res In directory usw-pr-cvs1:/tmp/cvs-serv29941 Modified Files: ressupport.py _Resmodule.c Log Message: Generate with weaklink stubs, so missing routines (on MacOS 8.6 and earlier) don't cause import failure. Fixes 531398, 2.2.1 candidate. Index: ressupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/res/ressupport.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** ressupport.py 18 Mar 2002 15:31:08 -0000 1.20 --- ressupport.py 22 Mar 2002 14:16:38 -0000 1.21 *************** *** 16,21 **** FunctionGenerator.checkit(self) # XXX ! class ResFunction(ResMixIn, OSErrFunctionGenerator): pass ! class ResMethod(ResMixIn, OSErrMethodGenerator): pass RsrcChainLocation = Type("RsrcChainLocation", "h") --- 16,21 ---- FunctionGenerator.checkit(self) # XXX ! class ResFunction(ResMixIn, OSErrWeakLinkFunctionGenerator): pass ! class ResMethod(ResMixIn, OSErrWeakLinkMethodGenerator): pass RsrcChainLocation = Type("RsrcChainLocation", "h") Index: _Resmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/res/_Resmodule.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** _Resmodule.c 18 Mar 2002 15:31:07 -0000 1.10 --- _Resmodule.c 22 Mar 2002 14:16:39 -0000 1.11 *************** *** 106,109 **** --- 106,112 ---- PyObject *_res = NULL; short _rv; + #ifndef HomeResFile + PyMac_PRECHECK(HomeResFile); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 121,124 **** --- 124,130 ---- { PyObject *_res = NULL; + #ifndef MacLoadResource + PyMac_PRECHECK(MacLoadResource); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 136,139 **** --- 142,148 ---- { PyObject *_res = NULL; + #ifndef ReleaseResource + PyMac_PRECHECK(ReleaseResource); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 151,154 **** --- 160,166 ---- { PyObject *_res = NULL; + #ifndef DetachResource + PyMac_PRECHECK(DetachResource); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 167,170 **** --- 179,185 ---- PyObject *_res = NULL; short _rv; + #ifndef GetResAttrs + PyMac_PRECHECK(GetResAttrs); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 185,188 **** --- 200,206 ---- ResType theType; Str255 name; + #ifndef GetResInfo + PyMac_PRECHECK(GetResInfo); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 207,210 **** --- 225,231 ---- short theID; Str255 name; + #ifndef SetResInfo + PyMac_PRECHECK(SetResInfo); + #endif if (!PyArg_ParseTuple(_args, "hO&", &theID, *************** *** 229,232 **** --- 250,256 ---- short theID; Str255 name; + #ifndef AddResource + PyMac_PRECHECK(AddResource); + #endif if (!PyArg_ParseTuple(_args, "O&hO&", PyMac_GetOSType, &theType, *************** *** 251,254 **** --- 275,281 ---- PyObject *_res = NULL; long _rv; + #ifndef GetResourceSizeOnDisk + PyMac_PRECHECK(GetResourceSizeOnDisk); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 267,270 **** --- 294,300 ---- PyObject *_res = NULL; long _rv; + #ifndef GetMaxResourceSize + PyMac_PRECHECK(GetMaxResourceSize); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 285,288 **** --- 315,321 ---- PyObject *_res = NULL; long _rv; + #ifndef RsrcMapEntry + PyMac_PRECHECK(RsrcMapEntry); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 302,305 **** --- 335,341 ---- PyObject *_res = NULL; short attrs; + #ifndef SetResAttrs + PyMac_PRECHECK(SetResAttrs); + #endif if (!PyArg_ParseTuple(_args, "h", &attrs)) *************** *** 319,322 **** --- 355,361 ---- { PyObject *_res = NULL; + #ifndef ChangedResource + PyMac_PRECHECK(ChangedResource); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 334,337 **** --- 373,379 ---- { PyObject *_res = NULL; + #ifndef RemoveResource + PyMac_PRECHECK(RemoveResource); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 349,352 **** --- 391,397 ---- { PyObject *_res = NULL; + #ifndef WriteResource + PyMac_PRECHECK(WriteResource); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 365,368 **** --- 410,416 ---- PyObject *_res = NULL; long newSize; + #ifndef SetResourceSize + PyMac_PRECHECK(SetResourceSize); + #endif if (!PyArg_ParseTuple(_args, "l", &newSize)) *************** *** 383,386 **** --- 431,437 ---- PyObject *_res = NULL; Handle _rv; + #ifndef GetNextFOND + PyMac_PRECHECK(GetNextFOND); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 416,419 **** --- 467,473 ---- { PyObject *_res = NULL; + #ifndef LoadResource + PyMac_PRECHECK(LoadResource); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 578,581 **** --- 632,638 ---- PyObject *_res = NULL; short _rv; + #ifndef InitResources + PyMac_PRECHECK(InitResources); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 596,599 **** --- 653,659 ---- { PyObject *_res = NULL; + #ifndef RsrcZoneInit + PyMac_PRECHECK(RsrcZoneInit); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 613,616 **** --- 673,679 ---- PyObject *_res = NULL; short refNum; + #ifndef CloseResFile + PyMac_PRECHECK(CloseResFile); + #endif if (!PyArg_ParseTuple(_args, "h", &refNum)) *************** *** 630,633 **** --- 693,699 ---- PyObject *_res = NULL; OSErr _err; + #ifndef ResError + PyMac_PRECHECK(ResError); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 643,646 **** --- 709,715 ---- PyObject *_res = NULL; short _rv; + #ifndef CurResFile + PyMac_PRECHECK(CurResFile); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 661,664 **** --- 730,736 ---- PyObject *_res = NULL; Str255 fileName; + #ifndef CreateResFile + PyMac_PRECHECK(CreateResFile); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetStr255, fileName)) *************** *** 682,685 **** --- 754,760 ---- short _rv; Str255 fileName; + #ifndef OpenResFile + PyMac_PRECHECK(OpenResFile); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetStr255, fileName)) *************** *** 700,703 **** --- 775,781 ---- PyObject *_res = NULL; short refNum; + #ifndef UseResFile + PyMac_PRECHECK(UseResFile); + #endif if (!PyArg_ParseTuple(_args, "h", &refNum)) *************** *** 717,720 **** --- 795,801 ---- PyObject *_res = NULL; short _rv; + #ifndef CountTypes + PyMac_PRECHECK(CountTypes); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 733,736 **** --- 814,820 ---- PyObject *_res = NULL; short _rv; + #ifndef Count1Types + PyMac_PRECHECK(Count1Types); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 750,753 **** --- 834,840 ---- ResType theType; short index; + #ifndef GetIndType + PyMac_PRECHECK(GetIndType); + #endif if (!PyArg_ParseTuple(_args, "h", &index)) *************** *** 769,772 **** --- 856,862 ---- ResType theType; short index; + #ifndef Get1IndType + PyMac_PRECHECK(Get1IndType); + #endif if (!PyArg_ParseTuple(_args, "h", &index)) *************** *** 787,790 **** --- 877,883 ---- PyObject *_res = NULL; Boolean load; + #ifndef SetResLoad + PyMac_PRECHECK(SetResLoad); + #endif if (!PyArg_ParseTuple(_args, "b", &load)) *************** *** 805,808 **** --- 898,904 ---- short _rv; ResType theType; + #ifndef CountResources + PyMac_PRECHECK(CountResources); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &theType)) *************** *** 823,826 **** --- 919,925 ---- short _rv; ResType theType; + #ifndef Count1Resources + PyMac_PRECHECK(Count1Resources); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &theType)) *************** *** 842,845 **** --- 941,947 ---- ResType theType; short index; + #ifndef GetIndResource + PyMac_PRECHECK(GetIndResource); + #endif if (!PyArg_ParseTuple(_args, "O&h", PyMac_GetOSType, &theType, *************** *** 863,866 **** --- 965,971 ---- ResType theType; short index; + #ifndef Get1IndResource + PyMac_PRECHECK(Get1IndResource); + #endif if (!PyArg_ParseTuple(_args, "O&h", PyMac_GetOSType, &theType, *************** *** 884,887 **** --- 989,995 ---- ResType theType; short theID; + #ifndef GetResource + PyMac_PRECHECK(GetResource); + #endif if (!PyArg_ParseTuple(_args, "O&h", PyMac_GetOSType, &theType, *************** *** 905,908 **** --- 1013,1019 ---- ResType theType; short theID; + #ifndef Get1Resource + PyMac_PRECHECK(Get1Resource); + #endif if (!PyArg_ParseTuple(_args, "O&h", PyMac_GetOSType, &theType, *************** *** 926,929 **** --- 1037,1043 ---- ResType theType; Str255 name; + #ifndef GetNamedResource + PyMac_PRECHECK(GetNamedResource); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &theType, *************** *** 947,950 **** --- 1061,1067 ---- ResType theType; Str255 name; + #ifndef Get1NamedResource + PyMac_PRECHECK(Get1NamedResource); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &theType, *************** *** 967,970 **** --- 1084,1090 ---- short _rv; ResType theType; + #ifndef UniqueID + PyMac_PRECHECK(UniqueID); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &theType)) *************** *** 985,988 **** --- 1105,1111 ---- short _rv; ResType theType; + #ifndef Unique1ID + PyMac_PRECHECK(Unique1ID); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &theType)) *************** *** 1002,1005 **** --- 1125,1131 ---- PyObject *_res = NULL; short refNum; + #ifndef UpdateResFile + PyMac_PRECHECK(UpdateResFile); + #endif if (!PyArg_ParseTuple(_args, "h", &refNum)) *************** *** 1019,1022 **** --- 1145,1151 ---- PyObject *_res = NULL; Boolean install; + #ifndef SetResPurge + PyMac_PRECHECK(SetResPurge); + #endif if (!PyArg_ParseTuple(_args, "b", &install)) *************** *** 1037,1040 **** --- 1166,1172 ---- short _rv; short refNum; + #ifndef GetResFileAttrs + PyMac_PRECHECK(GetResFileAttrs); + #endif if (!PyArg_ParseTuple(_args, "h", &refNum)) *************** *** 1055,1058 **** --- 1187,1193 ---- short refNum; short attrs; + #ifndef SetResFileAttrs + PyMac_PRECHECK(SetResFileAttrs); + #endif if (!PyArg_ParseTuple(_args, "hh", &refNum, *************** *** 1077,1080 **** --- 1212,1218 ---- short vRefNum; SignedByte permission; + #ifndef OpenRFPerm + PyMac_PRECHECK(OpenRFPerm); + #endif if (!PyArg_ParseTuple(_args, "O&hb", PyMac_GetStr255, fileName, *************** *** 1102,1105 **** --- 1240,1246 ---- ResType theType; short theID; + #ifndef RGetResource + PyMac_PRECHECK(RGetResource); + #endif if (!PyArg_ParseTuple(_args, "O&h", PyMac_GetOSType, &theType, *************** *** 1126,1129 **** --- 1267,1273 ---- Str255 fileName; SignedByte permission; + #ifndef HOpenResFile + PyMac_PRECHECK(HOpenResFile); + #endif if (!PyArg_ParseTuple(_args, "hlO&b", &vRefNum, *************** *** 1151,1154 **** --- 1295,1301 ---- long dirID; Str255 fileName; + #ifndef HCreateResFile + PyMac_PRECHECK(HCreateResFile); + #endif if (!PyArg_ParseTuple(_args, "hlO&", &vRefNum, *************** *** 1174,1177 **** --- 1321,1327 ---- FSSpec spec; SignedByte permission; + #ifndef FSpOpenResFile + PyMac_PRECHECK(FSpOpenResFile); + #endif if (!PyArg_ParseTuple(_args, "O&b", PyMac_GetFSSpec, &spec, *************** *** 1196,1199 **** --- 1346,1352 ---- OSType fileType; ScriptCode scriptTag; + #ifndef FSpCreateResFile + PyMac_PRECHECK(FSpCreateResFile); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&h", PyMac_GetFSSpec, &spec, *************** *** 1223,1226 **** --- 1376,1382 ---- SInt16 refNum; RsrcChainLocation where; + #ifndef InsertResourceFile + PyMac_PRECHECK(InsertResourceFile); + #endif if (!PyArg_ParseTuple(_args, "hh", &refNum, *************** *** 1243,1246 **** --- 1399,1405 ---- OSErr _err; SInt16 refNum; + #ifndef DetachResourceFile + PyMac_PRECHECK(DetachResourceFile); + #endif if (!PyArg_ParseTuple(_args, "h", &refNum)) *************** *** 1263,1266 **** --- 1422,1428 ---- Boolean inChain; SInt16 refNum; + #ifndef FSpResourceFileAlreadyOpen + PyMac_PRECHECK(FSpResourceFileAlreadyOpen); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetFSSpec, &resourceFile)) *************** *** 1290,1293 **** --- 1452,1458 ---- SignedByte permission; SInt16 refNum; + #ifndef FSpOpenOrphanResFile + PyMac_PRECHECK(FSpOpenOrphanResFile); + #endif if (!PyArg_ParseTuple(_args, "O&b", PyMac_GetFSSpec, &spec, *************** *** 1311,1314 **** --- 1476,1482 ---- OSErr _err; SInt16 refNum; + #ifndef GetTopResourceFile + PyMac_PRECHECK(GetTopResourceFile); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 1329,1332 **** --- 1497,1503 ---- SInt16 curRefNum; SInt16 nextRefNum; + #ifndef GetNextResourceFile + PyMac_PRECHECK(GetNextResourceFile); + #endif if (!PyArg_ParseTuple(_args, "h", &curRefNum)) *************** *** 1347,1350 **** --- 1518,1524 ---- FSRef ref; SignedByte permission; + #ifndef FSOpenResFile + PyMac_PRECHECK(FSOpenResFile); + #endif if (!PyArg_ParseTuple(_args, "O&b", PyMac_GetFSRef, &ref, *************** *** 1371,1374 **** --- 1545,1551 ---- FSRef newRef; FSSpec newSpec; + #ifndef FSCreateResFile + PyMac_PRECHECK(FSCreateResFile); + #endif if (!PyArg_ParseTuple(_args, "O&u#", PyMac_GetFSRef, &parentRef, *************** *** 1399,1402 **** --- 1576,1582 ---- Boolean inChain; SInt16 refNum; + #ifndef FSResourceFileAlreadyOpen + PyMac_PRECHECK(FSResourceFileAlreadyOpen); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetFSRef, &resourceFileRef)) *************** *** 1431,1434 **** --- 1611,1617 ---- FSRef newRef; FSSpec newSpec; + #ifndef FSCreateResourceFile + PyMac_PRECHECK(FSCreateResourceFile); + #endif if (!PyArg_ParseTuple(_args, "O&u#u#", PyMac_GetFSRef, &parentRef, *************** *** 1465,1468 **** --- 1648,1654 ---- SignedByte permissions; SInt16 refNum; + #ifndef FSOpenResourceFile + PyMac_PRECHECK(FSOpenResourceFile); + #endif if (!PyArg_ParseTuple(_args, "O&u#b", PyMac_GetFSRef, &ref, From thomas.heller@ion-tof.com Fri Mar 22 15:14:46 2002 From: thomas.heller@ion-tof.com (Thomas Heller) Date: Fri, 22 Mar 2002 16:14:46 +0100 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils/command bdist_wininst.py,1.29,1.30 References: Message-ID: <046f01c1d1b4$4d609be0$e000a8c0@thomasnotebook> > Modified Files: > bdist_wininst.py > Log Message: > Add unlisted Boolean options. Thomas H., can you please check that I > got this right? > > Bugfix candidate, unless Thomas notes a problem. > Looks ok to me. Thomas From nascheme@users.sourceforge.net Fri Mar 22 15:25:20 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 07:25:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include objimpl.h,2.46,2.47 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv16615/Include Modified Files: objimpl.h Log Message: Make PyObject_{NEW,New,Del,DEL} always use the standard malloc (PyMem_*) and not pymalloc. Add the functions PyMalloc_New, PyMalloc_NewVar, and PyMalloc_Del that will use pymalloc if it's enabled. If pymalloc is not enabled then they use the standard malloc (PyMem_*). Index: objimpl.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/objimpl.h,v retrieving revision 2.46 retrieving revision 2.47 diff -C2 -d -r2.46 -r2.47 *** objimpl.h 18 Mar 2002 21:04:28 -0000 2.46 --- objimpl.h 22 Mar 2002 15:25:18 -0000 2.47 *************** *** 35,43 **** Note that objects created with PyObject_{New, NewVar} are allocated ! within the Python heap by an object allocator, the latter being ! implemented (by default) on top of the Python raw memory ! allocator. This ensures that Python keeps control on the user's ! objects regarding their memory management; for instance, they may be ! subject to automatic garbage collection. In case a specific form of memory management is needed, implying that --- 35,42 ---- Note that objects created with PyObject_{New, NewVar} are allocated ! within the Python heap by the raw memory allocator (usually the system ! malloc). If you want to use the specialized Python allocator use ! PyMalloc_New and PyMalloc_NewVar to allocate the objects and ! PyMalloc_Del to free them. In case a specific form of memory management is needed, implying that *************** *** 85,91 **** /* Macros */ ! #define PyObject_MALLOC(n) _PyMalloc_MALLOC(n) ! #define PyObject_REALLOC(op, n) _PyMalloc_REALLOC((void *)(op), (n)) ! #define PyObject_FREE(op) _PyMalloc_FREE((void *)(op)) /* --- 84,90 ---- /* Macros */ ! #define PyObject_MALLOC(n) PyMem_MALLOC(n) ! #define PyObject_REALLOC(op, n) PyMem_REALLOC((void *)(op), (n)) ! #define PyObject_FREE(op) PyMem_FREE((void *)(op)) /* *************** *** 178,181 **** --- 177,196 ---- the 1st step is performed automatically for you, so in a C++ class constructor you would start directly with PyObject_Init/InitVar. */ + + /* + * The PyMalloc Object Allocator + * ============================= + */ + + extern DL_IMPORT(PyObject *) _PyMalloc_New(PyTypeObject *); + extern DL_IMPORT(PyVarObject *) _PyMalloc_NewVar(PyTypeObject *, int); + extern DL_IMPORT(void) _PyMalloc_Del(PyObject *); + + #define PyMalloc_New(type, typeobj) \ + ( (type *) _PyMalloc_New(typeobj) ) + #define PyMalloc_NewVar(type, typeobj, n) \ + ( (type *) _PyMalloc_NewVar((typeobj), (n)) ) + #define PyMalloc_Del(op) _PyMalloc_Del((PyObject *)(op)) + /* From nascheme@users.sourceforge.net Fri Mar 22 15:25:57 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 07:25:57 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules gcmodule.c,2.34,2.35 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv16754/Modules Modified Files: gcmodule.c Log Message: Use pymalloc if it's enabled. Index: gcmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v retrieving revision 2.34 retrieving revision 2.35 diff -C2 -d -r2.34 -r2.35 *** gcmodule.c 29 Jan 2002 00:53:41 -0000 2.34 --- gcmodule.c 22 Mar 2002 15:25:55 -0000 2.35 *************** *** 830,834 **** #ifdef WITH_CYCLE_GC const size_t nbytes = sizeof(PyGC_Head) + basicsize; ! PyGC_Head *g = PyObject_MALLOC(nbytes); if (g == NULL) return (PyObject *)PyErr_NoMemory(); --- 830,834 ---- #ifdef WITH_CYCLE_GC const size_t nbytes = sizeof(PyGC_Head) + basicsize; ! PyGC_Head *g = _PyMalloc_MALLOC(nbytes); if (g == NULL) return (PyObject *)PyErr_NoMemory(); *************** *** 846,850 **** op = FROM_GC(g); #else ! op = PyObject_MALLOC(basicsize); if (op == NULL) return (PyObject *)PyErr_NoMemory(); --- 846,850 ---- op = FROM_GC(g); #else ! op = _PyMalloc_MALLOC(basicsize); if (op == NULL) return (PyObject *)PyErr_NoMemory(); *************** *** 897,903 **** allocated--; } ! PyObject_FREE(g); #else ! PyObject_FREE(op); #endif } --- 897,903 ---- allocated--; } ! _PyMalloc_FREE(g); #else ! _PyMalloc_FREE(op); #endif } From nascheme@users.sourceforge.net Fri Mar 22 15:26:11 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 07:26:11 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects dictobject.c,2.119,2.120 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv16833/Objects Modified Files: dictobject.c Log Message: Use pymalloc if it's enabled. Index: dictobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v retrieving revision 2.119 retrieving revision 2.120 diff -C2 -d -r2.119 -r2.120 *** dictobject.c 11 Dec 2001 18:51:08 -0000 2.119 --- dictobject.c 22 Mar 2002 15:26:09 -0000 2.120 *************** *** 1915,1919 **** { dictiterobject *di; ! di = PyObject_NEW(dictiterobject, &PyDictIter_Type); if (di == NULL) return NULL; --- 1915,1919 ---- { dictiterobject *di; ! di = PyMalloc_New(dictiterobject, &PyDictIter_Type); if (di == NULL) return NULL; *************** *** 1930,1934 **** { Py_DECREF(di->di_dict); ! PyObject_DEL(di); } --- 1930,1934 ---- { Py_DECREF(di->di_dict); ! PyMalloc_Del(di); } From nascheme@users.sourceforge.net Fri Mar 22 15:28:33 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 07:28:33 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects object.c,2.166,2.167 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv17478/Objects Modified Files: object.c Log Message: Add pymalloc object memory management functions. These must be available even if pymalloc is disabled since extension modules might use them. Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.166 retrieving revision 2.167 diff -C2 -d -r2.166 -r2.167 *** object.c 18 Mar 2002 21:05:57 -0000 2.166 --- object.c 22 Mar 2002 15:28:30 -0000 2.167 *************** *** 2110,2111 **** --- 2110,2135 ---- } #endif /* !WITH_PYMALLOC */ + + PyObject *_PyMalloc_New(PyTypeObject *tp) + { + PyObject *op; + op = (PyObject *) _PyMalloc_MALLOC(_PyObject_SIZE(tp)); + if (op == NULL) + return PyErr_NoMemory(); + return PyObject_INIT(op, tp); + } + + PyVarObject *_PyMalloc_NewVar(PyTypeObject *tp, int nitems) + { + PyVarObject *op; + const size_t size = _PyObject_VAR_SIZE(tp, nitems); + op = (PyVarObject *) _PyMalloc_MALLOC(size); + if (op == NULL) + return (PyVarObject *)PyErr_NoMemory(); + return PyObject_INIT_VAR(op, tp, nitems); + } + + void _PyMalloc_Del(PyObject *op) + { + _PyMalloc_FREE(op); + } From nascheme@users.sourceforge.net Fri Mar 22 15:28:56 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 07:28:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects rangeobject.c,2.31,2.32 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv17601/Objects Modified Files: rangeobject.c Log Message: Use pymalloc if it's enabled. Index: rangeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/rangeobject.c,v retrieving revision 2.31 retrieving revision 2.32 diff -C2 -d -r2.31 -r2.32 *** rangeobject.c 29 Jan 2002 00:53:41 -0000 2.31 --- rangeobject.c 22 Mar 2002 15:28:53 -0000 2.32 *************** *** 61,65 **** { long totlen = -1; ! rangeobject *obj = PyObject_NEW(rangeobject, &PyRange_Type); if (obj == NULL) --- 61,65 ---- { long totlen = -1; ! rangeobject *obj = PyMalloc_New(rangeobject, &PyRange_Type); if (obj == NULL) *************** *** 105,109 **** range_dealloc(rangeobject *r) { ! PyObject_DEL(r); } --- 105,109 ---- range_dealloc(rangeobject *r) { ! PyMalloc_Del(r); } From nascheme@users.sourceforge.net Fri Mar 22 15:30:13 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 07:30:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.150,2.151 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv18004/Objects Modified Files: stringobject.c Log Message: Use pymalloc if it's enabled. Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.150 retrieving revision 2.151 diff -C2 -d -r2.150 -r2.151 *** stringobject.c 28 Feb 2002 11:38:24 -0000 2.150 --- stringobject.c 22 Mar 2002 15:30:10 -0000 2.151 *************** *** 69,73 **** /* PyObject_NewVar is inlined */ op = (PyStringObject *) ! PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char)); if (op == NULL) return PyErr_NoMemory(); --- 69,73 ---- /* PyObject_NewVar is inlined */ op = (PyStringObject *) ! _PyMalloc_MALLOC(sizeof(PyStringObject) + size * sizeof(char)); if (op == NULL) return PyErr_NoMemory(); *************** *** 132,136 **** /* PyObject_NewVar is inlined */ op = (PyStringObject *) ! PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char)); if (op == NULL) return PyErr_NoMemory(); --- 132,136 ---- /* PyObject_NewVar is inlined */ op = (PyStringObject *) ! _PyMalloc_MALLOC(sizeof(PyStringObject) + size * sizeof(char)); if (op == NULL) return PyErr_NoMemory(); *************** *** 734,738 **** /* PyObject_NewVar is inlined */ op = (PyStringObject *) ! PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char)); if (op == NULL) return PyErr_NoMemory(); --- 734,738 ---- /* PyObject_NewVar is inlined */ op = (PyStringObject *) ! _PyMalloc_MALLOC(sizeof(PyStringObject) + size * sizeof(char)); if (op == NULL) return PyErr_NoMemory(); *************** *** 781,785 **** } op = (PyStringObject *) ! PyObject_MALLOC(sizeof(PyStringObject) + nbytes); if (op == NULL) return PyErr_NoMemory(); --- 781,785 ---- } op = (PyStringObject *) ! _PyMalloc_MALLOC(sizeof(PyStringObject) + nbytes); if (op == NULL) return PyErr_NoMemory(); *************** *** 2790,2794 **** 0, /* tp_alloc */ string_new, /* tp_new */ ! _PyObject_Del, /* tp_free */ }; --- 2790,2794 ---- 0, /* tp_alloc */ string_new, /* tp_new */ ! _PyMalloc_Del, /* tp_free */ }; *************** *** 2842,2849 **** _Py_ForgetReference(v); *pv = (PyObject *) ! PyObject_REALLOC((char *)v, sizeof(PyStringObject) + newsize * sizeof(char)); if (*pv == NULL) { ! PyObject_DEL(v); PyErr_NoMemory(); return -1; --- 2842,2849 ---- _Py_ForgetReference(v); *pv = (PyObject *) ! _PyMalloc_REALLOC((char *)v, sizeof(PyStringObject) + newsize * sizeof(char)); if (*pv == NULL) { ! PyMalloc_Del(v); PyErr_NoMemory(); return -1; From nascheme@users.sourceforge.net Fri Mar 22 15:29:11 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 07:29:11 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects sliceobject.c,2.10,2.11 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv17735/Objects Modified Files: sliceobject.c Log Message: Use pymalloc if it's enabled. Index: sliceobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/sliceobject.c,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -d -r2.10 -r2.11 *** sliceobject.c 30 Oct 2001 02:40:52 -0000 2.10 --- sliceobject.c 22 Mar 2002 15:29:09 -0000 2.11 *************** *** 61,65 **** PySlice_New(PyObject *start, PyObject *stop, PyObject *step) { ! PySliceObject *obj = PyObject_NEW(PySliceObject, &PySlice_Type); if (obj == NULL) --- 61,65 ---- PySlice_New(PyObject *start, PyObject *stop, PyObject *step) { ! PySliceObject *obj = PyMalloc_New(PySliceObject, &PySlice_Type); if (obj == NULL) *************** *** 116,120 **** Py_DECREF(r->start); Py_DECREF(r->stop); ! PyObject_DEL(r); } --- 116,120 ---- Py_DECREF(r->start); Py_DECREF(r->stop); ! PyMalloc_Del(r); } From nascheme@users.sourceforge.net Fri Mar 22 15:30:28 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 07:30:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects structseq.c,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv18074/Objects Modified Files: structseq.c Log Message: Use pymalloc if it's enabled. Index: structseq.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/structseq.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** structseq.c 7 Mar 2002 15:13:40 -0000 1.6 --- structseq.c 22 Mar 2002 15:30:25 -0000 1.7 *************** *** 23,27 **** PyStructSequence *obj; ! obj = PyObject_New(PyStructSequence, type); obj->ob_size = VISIBLE_SIZE_TP(type); --- 23,27 ---- PyStructSequence *obj; ! obj = PyMalloc_New(PyStructSequence, type); obj->ob_size = VISIBLE_SIZE_TP(type); *************** *** 38,42 **** Py_XDECREF(obj->ob_item[i]); } ! PyObject_FREE(obj); } --- 38,42 ---- Py_XDECREF(obj->ob_item[i]); } ! PyMalloc_Del(obj); } From nascheme@users.sourceforge.net Fri Mar 22 15:33:17 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 07:33:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.131,2.132 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv18939 Modified Files: unicodeobject.c Log Message: Use pymalloc if it's enabled. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.131 retrieving revision 2.132 diff -C2 -d -r2.131 -r2.132 *** unicodeobject.c 21 Mar 2002 08:55:28 -0000 2.131 --- unicodeobject.c 22 Mar 2002 15:33:15 -0000 2.132 *************** *** 202,206 **** } else { ! unicode = PyObject_NEW(PyUnicodeObject, &PyUnicode_Type); if (unicode == NULL) return NULL; --- 202,206 ---- } else { ! unicode = PyMalloc_New(PyUnicodeObject, &PyUnicode_Type); if (unicode == NULL) return NULL; *************** *** 220,224 **** onError: _Py_ForgetReference((PyObject *)unicode); ! PyObject_DEL(unicode); return NULL; } --- 220,224 ---- onError: _Py_ForgetReference((PyObject *)unicode); ! PyMalloc_Del(unicode); return NULL; } *************** *** 5712,5716 **** if (pnew->str == NULL) { _Py_ForgetReference((PyObject *)pnew); ! PyObject_DEL(pnew); return NULL; } --- 5712,5716 ---- if (pnew->str == NULL) { _Py_ForgetReference((PyObject *)pnew); ! PyMalloc_Del(pnew); return NULL; } *************** *** 5770,5774 **** 0, /* tp_alloc */ unicode_new, /* tp_new */ ! _PyObject_Del, /* tp_free */ }; --- 5770,5774 ---- 0, /* tp_alloc */ unicode_new, /* tp_new */ ! _PyMalloc_Del, /* tp_free */ }; *************** *** 5812,5816 **** PyMem_DEL(v->str); Py_XDECREF(v->defenc); ! PyObject_DEL(v); } unicode_freelist = NULL; --- 5812,5816 ---- PyMem_DEL(v->str); Py_XDECREF(v->defenc); ! PyMalloc_Del(v); } unicode_freelist = NULL; From nascheme@users.sourceforge.net Fri Mar 22 15:34:22 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 07:34:22 -0800 Subject: [Python-checkins] CVS: python/dist/src configure.in,1.299,1.300 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv19382 Modified Files: configure.in Log Message: Enable pymalloc by default. Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.299 retrieving revision 1.300 diff -C2 -d -r1.299 -r1.300 *** configure.in 21 Mar 2002 15:10:58 -0000 1.299 --- configure.in 22 Mar 2002 15:34:20 -0000 1.300 *************** *** 1336,1345 **** AC_MSG_CHECKING(for --with-pymalloc) AC_ARG_WITH(pymalloc, ! [ --with(out)-pymalloc disable/enable specialized mallocs], [ ! if test "$withval" != no ! then AC_DEFINE(WITH_PYMALLOC) AC_MSG_RESULT(yes) ! else AC_MSG_RESULT(no) ! fi], ! [AC_MSG_RESULT(no)]) # Check for --with-wctype-functions --- 1336,1349 ---- AC_MSG_CHECKING(for --with-pymalloc) AC_ARG_WITH(pymalloc, ! [ --with(out)-pymalloc disable/enable specialized mallocs]) ! ! if test -z "$with_pymalloc" ! then with_pymalloc="yes" ! fi ! if test "$with_pymalloc" != "no" ! then ! AC_DEFINE(WITH_PYMALLOC) ! fi ! AC_MSG_RESULT($with_pymalloc) # Check for --with-wctype-functions From nascheme@users.sourceforge.net Fri Mar 22 15:34:51 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 07:34:51 -0800 Subject: [Python-checkins] CVS: python/dist/src configure,1.289,1.290 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv19529 Modified Files: configure Log Message: Enable pymalloc by default. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.289 retrieving revision 1.290 diff -C2 -d -r1.289 -r1.290 *** configure 21 Mar 2002 15:10:56 -0000 1.289 --- configure 22 Mar 2002 15:34:49 -0000 1.290 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.298 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.300 [...4009 lines suppressed...] if eval "test \"`echo '$''{'ac_cv_type_socklen_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < *************** *** 7648,7652 **** SRCDIRS="Parser Grammar Objects Python Modules" echo $ac_n "checking for build directories""... $ac_c" 1>&6 ! echo "configure:7651: checking for build directories" >&5 for dir in $SRCDIRS; do if test ! -d $dir; then --- 7662,7666 ---- SRCDIRS="Parser Grammar Objects Python Modules" echo $ac_n "checking for build directories""... $ac_c" 1>&6 ! echo "configure:7665: checking for build directories" >&5 for dir in $SRCDIRS; do if test ! -d $dir; then From akuchling@users.sourceforge.net Fri Mar 22 15:35:19 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Fri, 22 Mar 2002 07:35:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils/command install.py,1.62,1.63 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv18708 Modified Files: install.py Log Message: Revert part of previous patch: several install_* subcommands expect .compile to be None, and set it to true if it is. Caught by Pearu Peterson. Bugfix candidate, if the previous change is accepted for release22-maint. Index: install.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/install.py,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** install.py 21 Mar 2002 23:46:54 -0000 1.62 --- install.py 22 Mar 2002 15:35:17 -0000 1.63 *************** *** 165,169 **** self.install_data = None ! self.compile = 0 self.optimize = None --- 165,169 ---- self.install_data = None ! self.compile = None self.optimize = None From nascheme@users.sourceforge.net Fri Mar 22 15:41:05 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 07:41:05 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules gcmodule.c,2.35,2.36 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv21330/Modules Modified Files: gcmodule.c Log Message: Use pymalloc for realloc() as well. Index: gcmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v retrieving revision 2.35 retrieving revision 2.36 diff -C2 -d -r2.35 -r2.36 *** gcmodule.c 22 Mar 2002 15:25:55 -0000 2.35 --- gcmodule.c 22 Mar 2002 15:41:03 -0000 2.36 *************** *** 874,883 **** #ifdef WITH_CYCLE_GC PyGC_Head *g = AS_GC(op); ! g = PyObject_REALLOC(g, sizeof(PyGC_Head) + basicsize); if (g == NULL) return (PyVarObject *)PyErr_NoMemory(); op = (PyVarObject *) FROM_GC(g); #else ! op = PyObject_REALLOC(op, basicsize); if (op == NULL) return (PyVarObject *)PyErr_NoMemory(); --- 874,883 ---- #ifdef WITH_CYCLE_GC PyGC_Head *g = AS_GC(op); ! g = _PyMalloc_REALLOC(g, sizeof(PyGC_Head) + basicsize); if (g == NULL) return (PyVarObject *)PyErr_NoMemory(); op = (PyVarObject *) FROM_GC(g); #else ! op = _PyMalloc_REALLOC(op, basicsize); if (op == NULL) return (PyVarObject *)PyErr_NoMemory(); From jackjansen@users.sourceforge.net Fri Mar 22 15:48:46 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 22 Mar 2002 07:48:46 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/res _Resmodule.c,1.7.4.2,1.7.4.3 ressupport.py,1.18.4.2,1.18.4.3 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/res In directory usw-pr-cvs1:/tmp/cvs-serv22518 Modified Files: Tag: release22-maint _Resmodule.c ressupport.py Log Message: Backport of _Resmodule.c 1.10 and ressupport.py 1.21: Generate with weaklink stubs, so missing routines (on MacOS 8.6 and earlier) don't cause import failure. Fixes 531398, 2.2.1 candidate. Index: _Resmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/res/_Resmodule.c,v retrieving revision 1.7.4.2 retrieving revision 1.7.4.3 diff -C2 -d -r1.7.4.2 -r1.7.4.3 *** _Resmodule.c 18 Mar 2002 15:38:24 -0000 1.7.4.2 --- _Resmodule.c 22 Mar 2002 15:48:44 -0000 1.7.4.3 *************** *** 106,109 **** --- 106,112 ---- PyObject *_res = NULL; short _rv; + #ifndef HomeResFile + PyMac_PRECHECK(HomeResFile); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 121,124 **** --- 124,130 ---- { PyObject *_res = NULL; + #ifndef MacLoadResource + PyMac_PRECHECK(MacLoadResource); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 136,139 **** --- 142,148 ---- { PyObject *_res = NULL; + #ifndef ReleaseResource + PyMac_PRECHECK(ReleaseResource); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 151,154 **** --- 160,166 ---- { PyObject *_res = NULL; + #ifndef DetachResource + PyMac_PRECHECK(DetachResource); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 167,170 **** --- 179,185 ---- PyObject *_res = NULL; short _rv; + #ifndef GetResAttrs + PyMac_PRECHECK(GetResAttrs); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 185,188 **** --- 200,206 ---- ResType theType; Str255 name; + #ifndef GetResInfo + PyMac_PRECHECK(GetResInfo); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 207,210 **** --- 225,231 ---- short theID; Str255 name; + #ifndef SetResInfo + PyMac_PRECHECK(SetResInfo); + #endif if (!PyArg_ParseTuple(_args, "hO&", &theID, *************** *** 229,232 **** --- 250,256 ---- short theID; Str255 name; + #ifndef AddResource + PyMac_PRECHECK(AddResource); + #endif if (!PyArg_ParseTuple(_args, "O&hO&", PyMac_GetOSType, &theType, *************** *** 251,254 **** --- 275,281 ---- PyObject *_res = NULL; long _rv; + #ifndef GetResourceSizeOnDisk + PyMac_PRECHECK(GetResourceSizeOnDisk); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 267,270 **** --- 294,300 ---- PyObject *_res = NULL; long _rv; + #ifndef GetMaxResourceSize + PyMac_PRECHECK(GetMaxResourceSize); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 285,288 **** --- 315,321 ---- PyObject *_res = NULL; long _rv; + #ifndef RsrcMapEntry + PyMac_PRECHECK(RsrcMapEntry); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 302,305 **** --- 335,341 ---- PyObject *_res = NULL; short attrs; + #ifndef SetResAttrs + PyMac_PRECHECK(SetResAttrs); + #endif if (!PyArg_ParseTuple(_args, "h", &attrs)) *************** *** 319,322 **** --- 355,361 ---- { PyObject *_res = NULL; + #ifndef ChangedResource + PyMac_PRECHECK(ChangedResource); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 334,337 **** --- 373,379 ---- { PyObject *_res = NULL; + #ifndef RemoveResource + PyMac_PRECHECK(RemoveResource); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 349,352 **** --- 391,397 ---- { PyObject *_res = NULL; + #ifndef WriteResource + PyMac_PRECHECK(WriteResource); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 365,368 **** --- 410,416 ---- PyObject *_res = NULL; long newSize; + #ifndef SetResourceSize + PyMac_PRECHECK(SetResourceSize); + #endif if (!PyArg_ParseTuple(_args, "l", &newSize)) *************** *** 383,386 **** --- 431,437 ---- PyObject *_res = NULL; Handle _rv; + #ifndef GetNextFOND + PyMac_PRECHECK(GetNextFOND); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 416,419 **** --- 467,473 ---- { PyObject *_res = NULL; + #ifndef LoadResource + PyMac_PRECHECK(LoadResource); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 578,581 **** --- 632,638 ---- PyObject *_res = NULL; short _rv; + #ifndef InitResources + PyMac_PRECHECK(InitResources); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 596,599 **** --- 653,659 ---- { PyObject *_res = NULL; + #ifndef RsrcZoneInit + PyMac_PRECHECK(RsrcZoneInit); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 613,616 **** --- 673,679 ---- PyObject *_res = NULL; short refNum; + #ifndef CloseResFile + PyMac_PRECHECK(CloseResFile); + #endif if (!PyArg_ParseTuple(_args, "h", &refNum)) *************** *** 630,633 **** --- 693,699 ---- PyObject *_res = NULL; OSErr _err; + #ifndef ResError + PyMac_PRECHECK(ResError); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 643,646 **** --- 709,715 ---- PyObject *_res = NULL; short _rv; + #ifndef CurResFile + PyMac_PRECHECK(CurResFile); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 661,664 **** --- 730,736 ---- PyObject *_res = NULL; Str255 fileName; + #ifndef CreateResFile + PyMac_PRECHECK(CreateResFile); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetStr255, fileName)) *************** *** 682,685 **** --- 754,760 ---- short _rv; Str255 fileName; + #ifndef OpenResFile + PyMac_PRECHECK(OpenResFile); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetStr255, fileName)) *************** *** 700,703 **** --- 775,781 ---- PyObject *_res = NULL; short refNum; + #ifndef UseResFile + PyMac_PRECHECK(UseResFile); + #endif if (!PyArg_ParseTuple(_args, "h", &refNum)) *************** *** 717,720 **** --- 795,801 ---- PyObject *_res = NULL; short _rv; + #ifndef CountTypes + PyMac_PRECHECK(CountTypes); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 733,736 **** --- 814,820 ---- PyObject *_res = NULL; short _rv; + #ifndef Count1Types + PyMac_PRECHECK(Count1Types); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 750,753 **** --- 834,840 ---- ResType theType; short index; + #ifndef GetIndType + PyMac_PRECHECK(GetIndType); + #endif if (!PyArg_ParseTuple(_args, "h", &index)) *************** *** 769,772 **** --- 856,862 ---- ResType theType; short index; + #ifndef Get1IndType + PyMac_PRECHECK(Get1IndType); + #endif if (!PyArg_ParseTuple(_args, "h", &index)) *************** *** 787,790 **** --- 877,883 ---- PyObject *_res = NULL; Boolean load; + #ifndef SetResLoad + PyMac_PRECHECK(SetResLoad); + #endif if (!PyArg_ParseTuple(_args, "b", &load)) *************** *** 805,808 **** --- 898,904 ---- short _rv; ResType theType; + #ifndef CountResources + PyMac_PRECHECK(CountResources); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &theType)) *************** *** 823,826 **** --- 919,925 ---- short _rv; ResType theType; + #ifndef Count1Resources + PyMac_PRECHECK(Count1Resources); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &theType)) *************** *** 842,845 **** --- 941,947 ---- ResType theType; short index; + #ifndef GetIndResource + PyMac_PRECHECK(GetIndResource); + #endif if (!PyArg_ParseTuple(_args, "O&h", PyMac_GetOSType, &theType, *************** *** 863,866 **** --- 965,971 ---- ResType theType; short index; + #ifndef Get1IndResource + PyMac_PRECHECK(Get1IndResource); + #endif if (!PyArg_ParseTuple(_args, "O&h", PyMac_GetOSType, &theType, *************** *** 884,887 **** --- 989,995 ---- ResType theType; short theID; + #ifndef GetResource + PyMac_PRECHECK(GetResource); + #endif if (!PyArg_ParseTuple(_args, "O&h", PyMac_GetOSType, &theType, *************** *** 905,908 **** --- 1013,1019 ---- ResType theType; short theID; + #ifndef Get1Resource + PyMac_PRECHECK(Get1Resource); + #endif if (!PyArg_ParseTuple(_args, "O&h", PyMac_GetOSType, &theType, *************** *** 926,929 **** --- 1037,1043 ---- ResType theType; Str255 name; + #ifndef GetNamedResource + PyMac_PRECHECK(GetNamedResource); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &theType, *************** *** 947,950 **** --- 1061,1067 ---- ResType theType; Str255 name; + #ifndef Get1NamedResource + PyMac_PRECHECK(Get1NamedResource); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &theType, *************** *** 967,970 **** --- 1084,1090 ---- short _rv; ResType theType; + #ifndef UniqueID + PyMac_PRECHECK(UniqueID); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &theType)) *************** *** 985,988 **** --- 1105,1111 ---- short _rv; ResType theType; + #ifndef Unique1ID + PyMac_PRECHECK(Unique1ID); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &theType)) *************** *** 1002,1005 **** --- 1125,1131 ---- PyObject *_res = NULL; short refNum; + #ifndef UpdateResFile + PyMac_PRECHECK(UpdateResFile); + #endif if (!PyArg_ParseTuple(_args, "h", &refNum)) *************** *** 1019,1022 **** --- 1145,1151 ---- PyObject *_res = NULL; Boolean install; + #ifndef SetResPurge + PyMac_PRECHECK(SetResPurge); + #endif if (!PyArg_ParseTuple(_args, "b", &install)) *************** *** 1037,1040 **** --- 1166,1172 ---- short _rv; short refNum; + #ifndef GetResFileAttrs + PyMac_PRECHECK(GetResFileAttrs); + #endif if (!PyArg_ParseTuple(_args, "h", &refNum)) *************** *** 1055,1058 **** --- 1187,1193 ---- short refNum; short attrs; + #ifndef SetResFileAttrs + PyMac_PRECHECK(SetResFileAttrs); + #endif if (!PyArg_ParseTuple(_args, "hh", &refNum, *************** *** 1077,1080 **** --- 1212,1218 ---- short vRefNum; SignedByte permission; + #ifndef OpenRFPerm + PyMac_PRECHECK(OpenRFPerm); + #endif if (!PyArg_ParseTuple(_args, "O&hb", PyMac_GetStr255, fileName, *************** *** 1102,1105 **** --- 1240,1246 ---- ResType theType; short theID; + #ifndef RGetResource + PyMac_PRECHECK(RGetResource); + #endif if (!PyArg_ParseTuple(_args, "O&h", PyMac_GetOSType, &theType, *************** *** 1126,1129 **** --- 1267,1273 ---- Str255 fileName; SignedByte permission; + #ifndef HOpenResFile + PyMac_PRECHECK(HOpenResFile); + #endif if (!PyArg_ParseTuple(_args, "hlO&b", &vRefNum, *************** *** 1151,1154 **** --- 1295,1301 ---- long dirID; Str255 fileName; + #ifndef HCreateResFile + PyMac_PRECHECK(HCreateResFile); + #endif if (!PyArg_ParseTuple(_args, "hlO&", &vRefNum, *************** *** 1174,1177 **** --- 1321,1327 ---- FSSpec spec; SignedByte permission; + #ifndef FSpOpenResFile + PyMac_PRECHECK(FSpOpenResFile); + #endif if (!PyArg_ParseTuple(_args, "O&b", PyMac_GetFSSpec, &spec, *************** *** 1196,1199 **** --- 1346,1352 ---- OSType fileType; ScriptCode scriptTag; + #ifndef FSpCreateResFile + PyMac_PRECHECK(FSpCreateResFile); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&h", PyMac_GetFSSpec, &spec, *************** *** 1223,1226 **** --- 1376,1382 ---- SInt16 refNum; RsrcChainLocation where; + #ifndef InsertResourceFile + PyMac_PRECHECK(InsertResourceFile); + #endif if (!PyArg_ParseTuple(_args, "hh", &refNum, *************** *** 1243,1246 **** --- 1399,1405 ---- OSErr _err; SInt16 refNum; + #ifndef DetachResourceFile + PyMac_PRECHECK(DetachResourceFile); + #endif if (!PyArg_ParseTuple(_args, "h", &refNum)) *************** *** 1263,1266 **** --- 1422,1428 ---- Boolean inChain; SInt16 refNum; + #ifndef FSpResourceFileAlreadyOpen + PyMac_PRECHECK(FSpResourceFileAlreadyOpen); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetFSSpec, &resourceFile)) *************** *** 1290,1293 **** --- 1452,1458 ---- SignedByte permission; SInt16 refNum; + #ifndef FSpOpenOrphanResFile + PyMac_PRECHECK(FSpOpenOrphanResFile); + #endif if (!PyArg_ParseTuple(_args, "O&b", PyMac_GetFSSpec, &spec, *************** *** 1311,1314 **** --- 1476,1482 ---- OSErr _err; SInt16 refNum; + #ifndef GetTopResourceFile + PyMac_PRECHECK(GetTopResourceFile); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 1329,1332 **** --- 1497,1503 ---- SInt16 curRefNum; SInt16 nextRefNum; + #ifndef GetNextResourceFile + PyMac_PRECHECK(GetNextResourceFile); + #endif if (!PyArg_ParseTuple(_args, "h", &curRefNum)) *************** *** 1347,1350 **** --- 1518,1524 ---- FSRef ref; SignedByte permission; + #ifndef FSOpenResFile + PyMac_PRECHECK(FSOpenResFile); + #endif if (!PyArg_ParseTuple(_args, "O&b", PyMac_GetFSRef, &ref, *************** *** 1371,1374 **** --- 1545,1551 ---- FSRef newRef; FSSpec newSpec; + #ifndef FSCreateResFile + PyMac_PRECHECK(FSCreateResFile); + #endif if (!PyArg_ParseTuple(_args, "O&u#", PyMac_GetFSRef, &parentRef, *************** *** 1399,1402 **** --- 1576,1582 ---- Boolean inChain; SInt16 refNum; + #ifndef FSResourceFileAlreadyOpen + PyMac_PRECHECK(FSResourceFileAlreadyOpen); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetFSRef, &resourceFileRef)) *************** *** 1431,1434 **** --- 1611,1617 ---- FSRef newRef; FSSpec newSpec; + #ifndef FSCreateResourceFile + PyMac_PRECHECK(FSCreateResourceFile); + #endif if (!PyArg_ParseTuple(_args, "O&u#u#", PyMac_GetFSRef, &parentRef, *************** *** 1465,1468 **** --- 1648,1654 ---- SignedByte permissions; SInt16 refNum; + #ifndef FSOpenResourceFile + PyMac_PRECHECK(FSOpenResourceFile); + #endif if (!PyArg_ParseTuple(_args, "O&u#b", PyMac_GetFSRef, &ref, Index: ressupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/res/ressupport.py,v retrieving revision 1.18.4.2 retrieving revision 1.18.4.3 diff -C2 -d -r1.18.4.2 -r1.18.4.3 *** ressupport.py 18 Mar 2002 15:38:24 -0000 1.18.4.2 --- ressupport.py 22 Mar 2002 15:48:44 -0000 1.18.4.3 *************** *** 16,21 **** FunctionGenerator.checkit(self) # XXX ! class ResFunction(ResMixIn, OSErrFunctionGenerator): pass ! class ResMethod(ResMixIn, OSErrMethodGenerator): pass RsrcChainLocation = Type("RsrcChainLocation", "h") --- 16,21 ---- FunctionGenerator.checkit(self) # XXX ! class ResFunction(ResMixIn, OSErrWeakLinkFunctionGenerator): pass ! class ResMethod(ResMixIn, OSErrWeakLinkMethodGenerator): pass RsrcChainLocation = Type("RsrcChainLocation", "h") From bwarsaw@users.sourceforge.net Fri Mar 22 16:19:33 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Fri, 22 Mar 2002 08:19:33 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_email.py,1.24.4.1,1.24.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv665 Modified Files: Tag: release22-maint test_email.py Log Message: test_no_parts_in_a_multipart(): A test for the layout of a multipart/mixed message with no attachments. test_one_part_in_a_multipart(): A test for the layout of a multipart/mixed message with a single attachment. test_seq_parts_in_a_multipart(): A test for the layout of a multipart/mixed message with a single attachment that happens to be a sequence of length one. These tests ensure no regressions on the fix for SF bug #531966. I will merge these into the standalone email package and Python 2.3 trunk separately. Index: test_email.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_email.py,v retrieving revision 1.24.4.1 retrieving revision 1.24.4.2 diff -C2 -d -r1.24.4.1 -r1.24.4.2 *** test_email.py 28 Jan 2002 15:31:14 -0000 1.24.4.1 --- test_email.py 22 Mar 2002 16:19:30 -0000 1.24.4.2 *************** *** 540,543 **** --- 540,619 ---- unless(not m1.is_multipart()) + def test_no_parts_in_a_multipart(self): + outer = MIMEBase('multipart', 'mixed') + outer['Subject'] = 'A subject' + outer['To'] = 'aperson@dom.ain' + outer['From'] = 'bperson@dom.ain' + outer.preamble = '' + outer.epilogue = '' + outer.set_boundary('BOUNDARY') + msg = MIMEText('hello world') + self.assertEqual(outer.as_string(), '''\ + Content-Type: multipart/mixed; boundary="BOUNDARY" + MIME-Version: 1.0 + Subject: A subject + To: aperson@dom.ain + From: bperson@dom.ain + + --BOUNDARY + + + --BOUNDARY-- + ''') + + def test_one_part_in_a_multipart(self): + outer = MIMEBase('multipart', 'mixed') + outer['Subject'] = 'A subject' + outer['To'] = 'aperson@dom.ain' + outer['From'] = 'bperson@dom.ain' + outer.preamble = '' + outer.epilogue = '' + outer.set_boundary('BOUNDARY') + msg = MIMEText('hello world') + outer.attach(msg) + self.assertEqual(outer.as_string(), '''\ + Content-Type: multipart/mixed; boundary="BOUNDARY" + MIME-Version: 1.0 + Subject: A subject + To: aperson@dom.ain + From: bperson@dom.ain + + --BOUNDARY + Content-Type: text/plain; charset="us-ascii" + MIME-Version: 1.0 + Content-Transfer-Encoding: 7bit + + hello world + + --BOUNDARY-- + ''') + + def test_seq_parts_in_a_multipart(self): + outer = MIMEBase('multipart', 'mixed') + outer['Subject'] = 'A subject' + outer['To'] = 'aperson@dom.ain' + outer['From'] = 'bperson@dom.ain' + outer.preamble = '' + outer.epilogue = '' + msg = MIMEText('hello world') + outer.attach([msg]) + outer.set_boundary('BOUNDARY') + self.assertEqual(outer.as_string(), '''\ + Content-Type: multipart/mixed; boundary="BOUNDARY" + MIME-Version: 1.0 + Subject: A subject + To: aperson@dom.ain + From: bperson@dom.ain + + --BOUNDARY + Content-Type: text/plain; charset="us-ascii" + MIME-Version: 1.0 + Content-Transfer-Encoding: 7bit + + hello world + + --BOUNDARY-- + ''') + From bwarsaw@users.sourceforge.net Fri Mar 22 16:21:58 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Fri, 22 Mar 2002 08:21:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/email Generator.py,1.6,1.6.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv1301 Modified Files: Tag: release22-maint Generator.py Log Message: _handle_multipart(): Fixes for SF bug #531966. Specifically two situations are handled now: a multipart/* containing no payload (i.e. never set), and a multipart/* containing a scalar payload (i.e. Message.add_payload() having been called exactly once, not passing in a sequence object). _make_boundary(): Fixed bogus cut-n-paste error (self as first arg). I will merge these changes into the standalone email package and Python 2.3 separately. Index: Generator.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Generator.py,v retrieving revision 1.6 retrieving revision 1.6.10.1 diff -C2 -d -r1.6 -r1.6.10.1 *** Generator.py 19 Oct 2001 04:06:39 -0000 1.6 --- Generator.py 22 Mar 2002 16:21:56 -0000 1.6.10.1 *************** *** 238,242 **** # present in the payload. msgtexts = [] ! for part in msg.get_payload(): s = StringIO() g = self.__class__(s, self._mangle_from_, self.__maxheaderlen) --- 238,255 ---- # present in the payload. msgtexts = [] ! # BAW: kludge for broken add_payload() semantics; watch out for ! # multipart/* MIME types with None or scalar payloads. ! subparts = msg.get_payload() ! if subparts is None: ! # Nothing has every been attached ! boundary = msg.get_boundary(failobj=_make_boundary()) ! print >> self._fp, '--' + boundary ! print >> self._fp, '\n' ! print >> self._fp, '--' + boundary + '--' ! return ! elif not isinstance(subparts, ListType): ! # Scalar payload ! subparts = [subparts] ! for part in subparts: s = StringIO() g = self.__class__(s, self._mangle_from_, self.__maxheaderlen) *************** *** 370,374 **** # Helper ! def _make_boundary(self, text=None): # Craft a random boundary. If text is given, ensure that the chosen # boundary doesn't appear in the text. --- 383,387 ---- # Helper ! def _make_boundary(text=None): # Craft a random boundary. If text is given, ensure that the chosen # boundary doesn't appear in the text. From bwarsaw@users.sourceforge.net Fri Mar 22 16:25:56 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Fri, 22 Mar 2002 08:25:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.337.2.4.2.7,1.337.2.4.2.8 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv2483 Modified Files: Tag: release22-maint NEWS Log Message: Added a NEWS item for the fix of SF bug #531966 in the email package. Also, added a header for 2.2.1c2 (if there isn't a c2, change this to 2.2.1 final). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.337.2.4.2.7 retrieving revision 1.337.2.4.2.8 diff -C2 -d -r1.337.2.4.2.7 -r1.337.2.4.2.8 *** NEWS 19 Mar 2002 02:13:47 -0000 1.337.2.4.2.7 --- NEWS 22 Mar 2002 16:25:54 -0000 1.337.2.4.2.8 *************** *** 1,2 **** --- 1,19 ---- + What's New in Python 2.2.1c2? + Release date: ??? + ============================= + + Core and builtins + + Extension modules + + Library + + - The email package bug #531966 was fixed. This caused exceptions to + occur when flatting multipart/* messages with zero or one (scalar) + attachment. + + Tools + + What's New in Python 2.2.1c1? Release date: 18-Mar-2002 *************** *** 60,64 **** - A few bugs in the email package have been fixed. - XXX more detail! - StringIO's attitude to unicode strings has been reverted to that of --- 77,80 ---- From bwarsaw@users.sourceforge.net Fri Mar 22 16:41:20 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Fri, 22 Mar 2002 08:41:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.337.2.4.2.8,1.337.2.4.2.9 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv7273 Modified Files: Tag: release22-maint NEWS Log Message: I was just testing you. Neil Norwitz gets the prize. (Fixed a typo in the description of the email package patch.) Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.337.2.4.2.8 retrieving revision 1.337.2.4.2.9 diff -C2 -d -r1.337.2.4.2.8 -r1.337.2.4.2.9 *** NEWS 22 Mar 2002 16:25:54 -0000 1.337.2.4.2.8 --- NEWS 22 Mar 2002 16:41:18 -0000 1.337.2.4.2.9 *************** *** 10,14 **** - The email package bug #531966 was fixed. This caused exceptions to ! occur when flatting multipart/* messages with zero or one (scalar) attachment. --- 10,14 ---- - The email package bug #531966 was fixed. This caused exceptions to ! occur when flattening multipart/* messages with zero or one (scalar) attachment. From nascheme@users.sourceforge.net Fri Mar 22 17:07:02 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 09:07:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.366,1.367 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv14041/Misc Modified Files: NEWS Log Message: Add news about pymalloc being enabled. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.366 retrieving revision 1.367 diff -C2 -d -r1.366 -r1.367 *** NEWS 21 Mar 2002 10:38:40 -0000 1.366 --- NEWS 22 Mar 2002 17:06:59 -0000 1.367 *************** *** 7,10 **** --- 7,12 ---- Core and builtins + - The optional object allocator has been enabled by default. + - If you try to pickle an instance of a class that has __slots__ but doesn't define or override __getstate__, a TypeError is now raised. *************** *** 78,81 **** --- 80,90 ---- C API + + - Objects allocated using the new PyMalloc_New and PyMalloc_NewVar + functions will be allocated using pymalloc if it is enabled. These + objects should be deallocated using PyMalloc_Del. The PyObject_{New, + NewVar,NEW_VAR,Del,DEL} APIs have been changed to always use + PyMem_MALLOC and PyMem_FREE, even if pymalloc is enabled. The + PyCore_* family of APIs have been removed. - The "u#" parser marker will now pass through Unicode object as-is From fdrake@users.sourceforge.net Fri Mar 22 17:22:40 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 22 Mar 2002 09:22:40 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/perl l2hinit.perl,1.58,1.59 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/perl In directory usw-pr-cvs1:/tmp/cvs-serv18297/perl Modified Files: l2hinit.perl Log Message: Fix broken HTML in the head; this was reported by a user as causing Opera 6.01 to crash. The user has reported the problem to Opera, but we still should generate something that passes for HTML. Index: l2hinit.perl =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/perl/l2hinit.perl,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** l2hinit.perl 4 Dec 2001 17:03:54 -0000 1.58 --- l2hinit.perl 22 Mar 2002 17:22:38 -0000 1.59 *************** *** 614,618 **** ($CHARSET && $HTML_VERSION ge "2.1" ? ('\n") : ''), ($BASE ? "\n" : ''), --- 614,618 ---- ($CHARSET && $HTML_VERSION ge "2.1" ? ('\n") : ''), ($BASE ? "\n" : ''), From fdrake@users.sourceforge.net Fri Mar 22 17:23:05 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 22 Mar 2002 09:23:05 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/perl l2hinit.perl,1.58,1.58.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/perl In directory usw-pr-cvs1:/tmp/cvs-serv18418/perl Modified Files: Tag: release22-maint l2hinit.perl Log Message: Fix broken HTML in the head; this was reported by a user as causing Opera 6.01 to crash. The user has reported the problem to Opera, but we still should generate something that passes for HTML. Index: l2hinit.perl =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/perl/l2hinit.perl,v retrieving revision 1.58 retrieving revision 1.58.6.1 diff -C2 -d -r1.58 -r1.58.6.1 *** l2hinit.perl 4 Dec 2001 17:03:54 -0000 1.58 --- l2hinit.perl 22 Mar 2002 17:23:03 -0000 1.58.6.1 *************** *** 614,618 **** ($CHARSET && $HTML_VERSION ge "2.1" ? ('\n") : ''), ($BASE ? "\n" : ''), --- 614,618 ---- ($CHARSET && $HTML_VERSION ge "2.1" ? ('\n") : ''), ($BASE ? "\n" : ''), From doerwalter@users.sourceforge.net Fri Mar 22 17:30:40 2002 From: doerwalter@users.sourceforge.net (Walter D?rwald) Date: Fri, 22 Mar 2002 09:30:40 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib urllib.py,1.137,1.138 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv20095 Modified Files: urllib.py Log Message: use stat attributes instead of tuple entries and remove the unneccessary "import stat" statement. Index: urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.137 retrieving revision 1.138 diff -C2 -d -r1.137 -r1.138 *** urllib.py 18 Mar 2002 22:18:46 -0000 1.137 --- urllib.py 22 Mar 2002 17:30:38 -0000 1.138 *************** *** 26,30 **** import socket import os - import stat import time import sys --- 26,29 ---- *************** *** 411,416 **** localname = url2pathname(file) stats = os.stat(localname) ! size = stats[stat.ST_SIZE] ! modified = rfc822.formatdate(stats[stat.ST_MTIME]) mtype = mimetypes.guess_type(url)[0] headers = mimetools.Message(StringIO.StringIO( --- 410,415 ---- localname = url2pathname(file) stats = os.stat(localname) ! size = stats.st_size ! modified = rfc822.formatdate(stats.st_mtime) mtype = mimetypes.guess_type(url)[0] headers = mimetools.Message(StringIO.StringIO( From montanaro@users.sourceforge.net Fri Mar 22 18:07:51 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Fri, 22 Mar 2002 10:07:51 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib calendar.py,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv31525 Modified Files: calendar.py Log Message: guarantee that the dst flag of synthetic "time" tuples passed to strftime is always 0. This closes bug #533234. Index: calendar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/calendar.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** calendar.py 15 Mar 2002 13:52:43 -0000 1.24 --- calendar.py 22 Mar 2002 18:07:49 -0000 1.25 *************** *** 34,38 **** if not 0 <= item < self.len: raise IndexError, "out of range" ! return strftime(self.format, (item,)*9).capitalize() elif isinstance(item, type(slice(0))): return [self[e] for e in range(self.len)].__getslice__(item.start, item.stop) --- 34,38 ---- if not 0 <= item < self.len: raise IndexError, "out of range" ! return strftime(self.format, (item,)*8+(0,)).capitalize() elif isinstance(item, type(slice(0))): return [self[e] for e in range(self.len)].__getslice__(item.start, item.stop) From montanaro@users.sourceforge.net Fri Mar 22 18:35:53 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Fri, 22 Mar 2002 10:35:53 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib calendar.py,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv7051 Modified Files: calendar.py Log Message: better solution for bug #533234 courtesy of Tim. Michael: use this version as the bugfix candidate... Index: calendar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/calendar.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** calendar.py 22 Mar 2002 18:07:49 -0000 1.25 --- calendar.py 22 Mar 2002 18:35:51 -0000 1.26 *************** *** 34,38 **** if not 0 <= item < self.len: raise IndexError, "out of range" ! return strftime(self.format, (item,)*8+(0,)).capitalize() elif isinstance(item, type(slice(0))): return [self[e] for e in range(self.len)].__getslice__(item.start, item.stop) --- 34,39 ---- if not 0 <= item < self.len: raise IndexError, "out of range" ! t = (2001, 1, item+1, 12, 0, 0, item, item+1, 0) ! return strftime(self.format, t).capitalize() elif isinstance(item, type(slice(0))): return [self[e] for e in range(self.len)].__getslice__(item.start, item.stop) From nascheme@users.sourceforge.net Fri Mar 22 20:39:00 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 12:39:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects fileobject.c,2.147,2.148 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv7920/Objects Modified Files: fileobject.c Log Message: Disallow open()ing of directories. Closes SF bug 487277. Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.147 retrieving revision 2.148 diff -C2 -d -r2.147 -r2.148 *** fileobject.c 15 Mar 2002 17:42:16 -0000 2.147 --- fileobject.c 22 Mar 2002 20:38:57 -0000 2.148 *************** *** 57,60 **** --- 57,86 ---- } + /* On Unix, fopen will succeed for directories. + In Python, there should be no file objects referring to + directories, so we need a check. */ + + static PyFileObject* + dircheck(PyFileObject* f) + { + #if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR) + struct stat buf; + if (f->f_fp == NULL) + return f; + if (fstat(fileno(f->f_fp), &buf) == 0 && + S_ISDIR(buf.st_mode)) { + #ifdef HAVE_STRERROR + char *msg = strerror(EISDIR); + #else + char *msg = "Is a directory"; + #endif + PyObject *exc = PyObject_CallFunction(PyExc_IOError, "(is)", EISDIR, msg); + PyErr_SetObject(PyExc_IOError, exc); + return NULL; + } + #endif + return f; + } + static PyObject * *************** *** 78,81 **** --- 104,108 ---- return NULL; f->f_fp = fp; + f = dircheck(f); return (PyObject *) f; } *************** *** 131,134 **** --- 158,162 ---- f = NULL; } + f = dircheck(f); return (PyObject *)f; } From nascheme@users.sourceforge.net Fri Mar 22 20:52:00 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 12:52:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.225,2.226 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv11061/Modules Modified Files: posixmodule.c Log Message: Handle os.listdir("") case correctly on Windows. Closes bug 500705. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.225 retrieving revision 2.226 diff -C2 -d -r2.225 -r2.226 *** posixmodule.c 12 Mar 2002 21:38:49 -0000 2.225 --- posixmodule.c 22 Mar 2002 20:51:58 -0000 2.226 *************** *** 981,992 **** char *bufptr = namebuf; int len = sizeof(namebuf)/sizeof(namebuf[0]); - char ch; if (!PyArg_ParseTuple(args, "et#:listdir", Py_FileSystemDefaultEncoding, &bufptr, &len)) return NULL; ! ch = namebuf[len-1]; ! if (ch != SEP && ch != ALTSEP && ch != ':') ! namebuf[len++] = '/'; strcpy(namebuf + len, "*.*"); --- 981,993 ---- char *bufptr = namebuf; int len = sizeof(namebuf)/sizeof(namebuf[0]); if (!PyArg_ParseTuple(args, "et#:listdir", Py_FileSystemDefaultEncoding, &bufptr, &len)) return NULL; ! if (len > 0) { ! char ch = namebuf[len-1]; ! if (ch != SEP && ch != ALTSEP && ch != ':') ! namebuf[len++] = '/'; ! } strcpy(namebuf + len, "*.*"); From nascheme@users.sourceforge.net Fri Mar 22 22:16:05 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 14:16:05 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libpickle.tex,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv1682/Doc/lib Modified Files: libpickle.tex Log Message: Add more example exceptions that unpickling can raise. Index: libpickle.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpickle.tex,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** libpickle.tex 26 Nov 2001 21:30:36 -0000 1.33 --- libpickle.tex 22 Mar 2002 22:16:03 -0000 1.34 *************** *** 198,202 **** such as a security violation. Note that other exceptions may also be raised during unpickling, including (but not necessarily limited to) ! \exception{AttributeError} and \exception{ImportError}. \end{excdesc} --- 198,203 ---- such as a security violation. Note that other exceptions may also be raised during unpickling, including (but not necessarily limited to) ! \exception{AttributeError}, \exception{EOFError}, ! \exception{ImportError}, and \exception{IndexError}. \end{excdesc} From nascheme@users.sourceforge.net Fri Mar 22 23:02:55 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 15:02:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules cPickle.c,2.74,2.75 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv13896 Modified Files: cPickle.c Log Message: Match behavior of the pickle.py module more closely. Index: cPickle.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cPickle.c,v retrieving revision 2.74 retrieving revision 2.75 diff -C2 -d -r2.74 -r2.75 *** cPickle.c 21 Dec 2001 20:04:22 -0000 2.74 --- cPickle.c 22 Mar 2002 23:02:53 -0000 2.75 *************** *** 3844,3847 **** --- 3844,3852 ---- continue; + case '\0': + /* end of file */ + PyErr_SetNone(PyExc_EOFError); + break; + default: cPickle_ErrFormat(UnpicklingError, "invalid load key, '%s'.", From nascheme@users.sourceforge.net Fri Mar 22 23:20:18 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 15:20:18 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.4,2.5 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv17872/Objects Modified Files: obmalloc.c Log Message: Remove malloc hooks. Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -d -r2.4 -r2.5 *** obmalloc.c 18 Mar 2002 21:06:21 -0000 2.4 --- obmalloc.c 22 Mar 2002 23:20:15 -0000 2.5 *************** *** 50,54 **** /* #undef WITH_MEMORY_LIMITS */ /* disable mem limit checks */ - #define WITH_MALLOC_HOOKS /* for profiling & debugging */ /*==========================================================================*/ --- 50,53 ---- *************** *** 327,340 **** current arena */ - /* - * Hooks - */ - #ifdef WITH_MALLOC_HOOKS - static void *(*malloc_hook)(size_t) = NULL; - static void *(*calloc_hook)(size_t, size_t) = NULL; - static void *(*realloc_hook)(void *, size_t) = NULL; - static void (*free_hook)(void *) = NULL; - #endif /* !WITH_MALLOC_HOOKS */ - /*==========================================================================*/ --- 326,329 ---- *************** *** 357,365 **** uint size; - #ifdef WITH_MALLOC_HOOKS - if (malloc_hook != NULL) - return (*malloc_hook)(nbytes); - #endif - /* * This implicitly redirects malloc(0) --- 346,349 ---- *************** *** 524,534 **** off_t offset; - #ifdef WITH_MALLOC_HOOKS - if (free_hook != NULL) { - (*free_hook)(p); - return; - } - #endif - if (p == NULL) /* free(NULL) has no effect */ return; --- 508,511 ---- *************** *** 602,610 **** uint size; - #ifdef WITH_MALLOC_HOOKS - if (realloc_hook != NULL) - return (*realloc_hook)(p, nbytes); - #endif - if (p == NULL) return _PyMalloc_Malloc(nbytes); --- 579,582 ---- *************** *** 657,665 **** size_t nbytes; - #ifdef WITH_MALLOC_HOOKS - if (calloc_hook != NULL) - return (*calloc_hook)(nbel, elsz); - #endif - nbytes = nbel * elsz; p = _PyMalloc_Malloc(nbytes); --- 629,632 ---- *************** *** 670,707 **** */ - /*==========================================================================*/ - - /* - * Hooks - */ - - #ifdef WITH_MALLOC_HOOKS - - void - _PyMalloc_SetHooks( void *(*malloc_func)(size_t), - void *(*calloc_func)(size_t, size_t), - void *(*realloc_func)(void *, size_t), - void (*free_func)(void *) ) - { - LOCK(); - malloc_hook = malloc_func; - calloc_hook = calloc_func; - realloc_hook = realloc_func; - free_hook = free_func; - UNLOCK(); - } - - void - _PyMalloc_FetchHooks( void *(**malloc_funcp)(size_t), - void *(**calloc_funcp)(size_t, size_t), - void *(**realloc_funcp)(void *, size_t), - void (**free_funcp)(void *) ) - { - LOCK(); - *malloc_funcp = malloc_hook; - *calloc_funcp = calloc_hook; - *realloc_funcp = realloc_hook; - *free_funcp = free_hook; - UNLOCK(); - } - #endif /* !WITH_MALLOC_HOOKS */ --- 637,638 ---- From nascheme@users.sourceforge.net Fri Mar 22 23:38:13 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 15:38:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Parser parser.c,2.21,2.22 Message-ID: Update of /cvsroot/python/python/dist/src/Parser In directory usw-pr-cvs1:/tmp/cvs-serv22176/Parser Modified Files: parser.c Log Message: Disable the parser hacks that allowed the "yield" keyword to be enabled by a future statement. Index: parser.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/parser.c,v retrieving revision 2.21 retrieving revision 2.22 diff -C2 -d -r2.21 -r2.22 *** parser.c 4 Dec 2001 03:18:48 -0000 2.21 --- parser.c 22 Mar 2002 23:38:11 -0000 2.22 *************** *** 80,84 **** --- 80,86 ---- return NULL; ps->p_grammar = g; + #if 0 /* future keyword */ ps->p_generators = 0; + #endif ps->p_tree = PyNode_New(start); if (ps->p_tree == NULL) { *************** *** 146,153 **** --- 148,157 ---- l->lb_str[0] == s[0] && strcmp(l->lb_str, s) == 0) { + #if 0 /* future keyword */ if (!ps->p_generators && s[0] == 'y' && strcmp(s, "yield") == 0) break; /* not a keyword */ + #endif D(printf("It's a keyword\n")); return n - i; *************** *** 171,174 **** --- 175,179 ---- } + #if 0 /* future keyword */ static void future_hack(parser_state *ps) *************** *** 192,195 **** --- 197,201 ---- } } + #endif /* future keyword */ int *************** *** 250,257 **** --- 256,265 ---- d->d_name, ps->p_stack.s_top->s_state)); + #if 0 /* future keyword */ if (d->d_name[0] == 'i' && strcmp(d->d_name, "import_stmt") == 0) future_hack(ps); + #endif s_pop(&ps->p_stack); if (s_empty(&ps->p_stack)) { *************** *** 266,272 **** --- 274,282 ---- if (s->s_accept) { + #if 0 /* future keyword */ if (d->d_name[0] == 'i' && strcmp(d->d_name, "import_stmt") == 0) future_hack(ps); + #endif /* Pop this dfa and try again */ s_pop(&ps->p_stack); From nascheme@users.sourceforge.net Fri Mar 22 23:50:32 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 15:50:32 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects fileobject.c,2.148,2.149 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv25209 Modified Files: fileobject.c Log Message: Undo last commit. It's causing the tests to file. Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.148 retrieving revision 2.149 diff -C2 -d -r2.148 -r2.149 *** fileobject.c 22 Mar 2002 20:38:57 -0000 2.148 --- fileobject.c 22 Mar 2002 23:50:30 -0000 2.149 *************** *** 57,86 **** } - /* On Unix, fopen will succeed for directories. - In Python, there should be no file objects referring to - directories, so we need a check. */ - - static PyFileObject* - dircheck(PyFileObject* f) - { - #if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR) - struct stat buf; - if (f->f_fp == NULL) - return f; - if (fstat(fileno(f->f_fp), &buf) == 0 && - S_ISDIR(buf.st_mode)) { - #ifdef HAVE_STRERROR - char *msg = strerror(EISDIR); - #else - char *msg = "Is a directory"; - #endif - PyObject *exc = PyObject_CallFunction(PyExc_IOError, "(is)", EISDIR, msg); - PyErr_SetObject(PyExc_IOError, exc); - return NULL; - } - #endif - return f; - } - static PyObject * --- 57,60 ---- *************** *** 104,108 **** return NULL; f->f_fp = fp; - f = dircheck(f); return (PyObject *) f; } --- 78,81 ---- *************** *** 158,162 **** f = NULL; } - f = dircheck(f); return (PyObject *)f; } --- 131,134 ---- From nascheme@users.sourceforge.net Fri Mar 22 23:52:37 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 15:52:37 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include parsetok.h,2.16,2.17 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv25565/Include Modified Files: parsetok.h Log Message: Disable the parser hacks that enabled the "yield" keyword using a future statement. Index: parsetok.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/parsetok.h,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -d -r2.16 -r2.17 *** parsetok.h 16 Jul 2001 05:37:24 -0000 2.16 --- parsetok.h 22 Mar 2002 23:52:35 -0000 2.17 *************** *** 18,22 **** --- 18,24 ---- } perrdetail; + #if 0 #define PyPARSE_YIELD_IS_KEYWORD 0x0001 + #endif extern DL_IMPORT(node *) PyParser_ParseString(char *, grammar *, int, From nascheme@users.sourceforge.net Fri Mar 22 23:52:51 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 15:52:51 -0800 Subject: [Python-checkins] CVS: python/dist/src/Parser parser.h,2.15,2.16 Message-ID: Update of /cvsroot/python/python/dist/src/Parser In directory usw-pr-cvs1:/tmp/cvs-serv25608/Parser Modified Files: parser.h Log Message: Disable the parser hacks that enabled the "yield" keyword using a future statement. Index: parser.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/parser.h,v retrieving revision 2.15 retrieving revision 2.16 diff -C2 -d -r2.15 -r2.16 *** parser.h 15 Jul 2001 21:08:29 -0000 2.15 --- parser.h 22 Mar 2002 23:52:49 -0000 2.16 *************** *** 26,30 **** --- 26,32 ---- grammar *p_grammar; /* Grammar to use */ node *p_tree; /* Top of parse tree */ + #if 0 /* future keyword */ int p_generators; /* 1 if yield is a keyword */ + #endif } parser_state; From nascheme@users.sourceforge.net Fri Mar 22 23:53:18 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 15:53:18 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python ceval.c,2.306,2.307 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv25715/Python Modified Files: ceval.c Log Message: Disable the parser hacks that enabled the "yield" keyword using a future statement. Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.306 retrieving revision 2.307 diff -C2 -d -r2.306 -r2.307 *** ceval.c 18 Mar 2002 20:45:09 -0000 2.306 --- ceval.c 22 Mar 2002 23:53:16 -0000 2.307 *************** *** 2985,2992 **** --- 2985,2994 ---- cf->cf_flags |= compilerflags; } + #if 0 /* future keyword */ if (codeflags & CO_GENERATOR_ALLOWED) { result = 1; cf->cf_flags |= CO_GENERATOR_ALLOWED; } + #endif } return result; From nascheme@users.sourceforge.net Fri Mar 22 23:53:38 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 15:53:38 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python pythonrun.c,2.155,2.156 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv25797/Python Modified Files: pythonrun.c Log Message: Disable the parser hacks that enabled the "yield" keyword using a future statement. Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.155 retrieving revision 2.156 diff -C2 -d -r2.155 -r2.156 *** pythonrun.c 3 Mar 2002 21:30:27 -0000 2.155 --- pythonrun.c 22 Mar 2002 23:53:36 -0000 2.156 *************** *** 543,546 **** --- 543,555 ---- } + /* compute parser flags based on compiler flags */ + #if 0 /* future keyword */ + #define PARSER_FLAGS(flags) \ + (((flags) && (flags)->cf_flags & CO_GENERATOR_ALLOWED) ? \ + PyPARSE_YIELD_IS_KEYWORD : 0) + #else + #define PARSER_FLAGS(flags) 0 + #endif + int PyRun_InteractiveOneFlags(FILE *fp, char *filename, PyCompilerFlags *flags) *************** *** 569,575 **** n = PyParser_ParseFileFlags(fp, filename, &_PyParser_Grammar, Py_single_input, ps1, ps2, &err, ! (flags && ! flags->cf_flags & CO_GENERATOR_ALLOWED) ? ! PyPARSE_YIELD_IS_KEYWORD : 0); Py_XDECREF(v); Py_XDECREF(w); --- 578,582 ---- n = PyParser_ParseFileFlags(fp, filename, &_PyParser_Grammar, Py_single_input, ps1, ps2, &err, ! PARSER_FLAGS(flags)); Py_XDECREF(v); Py_XDECREF(w); *************** *** 1032,1038 **** { return run_err_node(PyParser_SimpleParseStringFlags( ! str, start, ! (flags && flags->cf_flags & CO_GENERATOR_ALLOWED) ? ! PyPARSE_YIELD_IS_KEYWORD : 0), "", globals, locals, flags); } --- 1039,1043 ---- { return run_err_node(PyParser_SimpleParseStringFlags( ! str, start, PARSER_FLAGS(flags)), "", globals, locals, flags); } *************** *** 1051,1056 **** { node *n = PyParser_SimpleParseFileFlags(fp, filename, start, ! (flags && flags->cf_flags & CO_GENERATOR_ALLOWED) ? ! PyPARSE_YIELD_IS_KEYWORD : 0); if (closeit) fclose(fp); --- 1056,1060 ---- { node *n = PyParser_SimpleParseFileFlags(fp, filename, start, ! PARSER_FLAGS(flags)); if (closeit) fclose(fp); *************** *** 1126,1132 **** node *n; PyCodeObject *co; ! n = PyParser_SimpleParseStringFlags(str, start, ! (flags && flags->cf_flags & CO_GENERATOR_ALLOWED) ? ! PyPARSE_YIELD_IS_KEYWORD : 0); if (n == NULL) return NULL; --- 1130,1134 ---- node *n; PyCodeObject *co; ! n = PyParser_SimpleParseStringFlags(str, start, PARSER_FLAGS(flags)); if (n == NULL) return NULL; From nascheme@users.sourceforge.net Fri Mar 22 23:53:05 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 15:53:05 -0800 Subject: [Python-checkins] CVS: python/dist/src/Parser parsetok.c,2.29,2.30 Message-ID: Update of /cvsroot/python/python/dist/src/Parser In directory usw-pr-cvs1:/tmp/cvs-serv25676/Parser Modified Files: parsetok.c Log Message: Disable the parser hacks that enabled the "yield" keyword using a future statement. Index: parsetok.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/parsetok.c,v retrieving revision 2.29 retrieving revision 2.30 diff -C2 -d -r2.29 -r2.30 *** parsetok.c 5 Jan 2002 21:40:08 -0000 2.29 --- parsetok.c 22 Mar 2002 23:53:03 -0000 2.30 *************** *** 84,89 **** --- 84,91 ---- Return error code. */ + #if 0 /* future keyword */ static char yield_msg[] = "%s:%d: Warning: 'yield' will become a reserved keyword in the future\n"; + #endif static node * *************** *** 100,105 **** --- 102,109 ---- return NULL; } + #if 0 /* future keyword */ if (flags & PyPARSE_YIELD_IS_KEYWORD) ps->p_generators = 1; + #endif for (;;) { *************** *** 131,134 **** --- 135,139 ---- str[len] = '\0'; + #if 0 /* future keyword */ /* Warn about yield as NAME */ if (type == NAME && !ps->p_generators && *************** *** 138,141 **** --- 143,147 ---- "" : err_ret->filename, tok->lineno); + #endif if ((err_ret->error = From tim.one@comcast.net Sat Mar 23 00:07:22 2002 From: tim.one@comcast.net (Tim Peters) Date: Fri, 22 Mar 2002 19:07:22 -0500 Subject: [Python-checkins] CVS: python/dist/src/Objects fileobject.c,2.148,2.149 In-Reply-To: Message-ID: > Modified Files: > fileobject.c > Log Message: > Undo last commit. It's causing the tests to file. Damn, I already fixed this in my tree: open_the_file() can set f to NULL before calling dircheck. It simply shouldn't call dircheck(f) when f is NULL. At least that was the only problem on Windows. From tim_one@users.sourceforge.net Sat Mar 23 00:20:17 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 22 Mar 2002 16:20:17 -0800 Subject: [Python-checkins] CVS: python/dist/src Makefile.pre.in,1.76,1.77 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv31170/python Modified Files: Makefile.pre.in Log Message: Build obmalloc.c directly instead of #include'ing from object.c. Also move all _PyMalloc_XXX entry points into obmalloc.c. The Windows build works fine. The Unix build is changed here (Makefile.pre.in), but not tested. No other platform's build process has been fiddled. Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** Makefile.pre.in 28 Feb 2002 19:26:08 -0000 1.76 --- Makefile.pre.in 23 Mar 2002 00:20:15 -0000 1.77 *************** *** 264,267 **** --- 264,268 ---- Objects/moduleobject.o \ Objects/object.o \ + Objects/obmalloc.o \ Objects/rangeobject.o \ Objects/sliceobject.o \ *************** *** 424,429 **** Python/importdl.o: $(srcdir)/Python/importdl.c $(CC) -c $(CFLAGS) $(CPPFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c - - Objects/object.o: $(srcdir)/Objects/object.c $(srcdir)/Objects/obmalloc.c Objects/unicodectype.o: $(srcdir)/Objects/unicodectype.c \ --- 425,428 ---- From tim_one@users.sourceforge.net Sat Mar 23 00:20:17 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 22 Mar 2002 16:20:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects object.c,2.167,2.168 obmalloc.c,2.5,2.6 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv31170/python/Objects Modified Files: object.c obmalloc.c Log Message: Build obmalloc.c directly instead of #include'ing from object.c. Also move all _PyMalloc_XXX entry points into obmalloc.c. The Windows build works fine. The Unix build is changed here (Makefile.pre.in), but not tested. No other platform's build process has been fiddled. Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.167 retrieving revision 2.168 diff -C2 -d -r2.167 -r2.168 *** object.c 22 Mar 2002 15:28:30 -0000 2.167 --- object.c 23 Mar 2002 00:20:15 -0000 2.168 *************** *** 2091,2135 **** } } - - #ifdef WITH_PYMALLOC - #include "obmalloc.c" - #else - void *_PyMalloc_Malloc(size_t n) - { - return PyMem_MALLOC(n); - } - - void *_PyMalloc_Realloc(void *p, size_t n) - { - return PyMem_REALLOC(p, n); - } - - void _PyMalloc_Free(void *p) - { - PyMem_FREE(p); - } - #endif /* !WITH_PYMALLOC */ - - PyObject *_PyMalloc_New(PyTypeObject *tp) - { - PyObject *op; - op = (PyObject *) _PyMalloc_MALLOC(_PyObject_SIZE(tp)); - if (op == NULL) - return PyErr_NoMemory(); - return PyObject_INIT(op, tp); - } - - PyVarObject *_PyMalloc_NewVar(PyTypeObject *tp, int nitems) - { - PyVarObject *op; - const size_t size = _PyObject_VAR_SIZE(tp, nitems); - op = (PyVarObject *) _PyMalloc_MALLOC(size); - if (op == NULL) - return (PyVarObject *)PyErr_NoMemory(); - return PyObject_INIT_VAR(op, tp, nitems); - } - - void _PyMalloc_Del(PyObject *op) - { - _PyMalloc_FREE(op); - } --- 2091,2092 ---- Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.5 retrieving revision 2.6 diff -C2 -d -r2.5 -r2.6 *** obmalloc.c 22 Mar 2002 23:20:15 -0000 2.5 --- obmalloc.c 23 Mar 2002 00:20:15 -0000 2.6 *************** *** 1,2 **** --- 1,6 ---- + #include "Python.h" + + #ifdef WITH_PYMALLOC + /* An object allocator for Python. *************** *** 637,638 **** --- 641,688 ---- */ + #else /* ! WITH_PYMALLOC */ + void + *_PyMalloc_Malloc(size_t n) + { + return PyMem_MALLOC(n); + } + + void + *_PyMalloc_Realloc(void *p, size_t n) + { + return PyMem_REALLOC(p, n); + } + + void + _PyMalloc_Free(void *p) + { + PyMem_FREE(p); + } + #endif /* WITH_PYMALLOC */ + + PyObject + *_PyMalloc_New(PyTypeObject *tp) + { + PyObject *op; + op = (PyObject *) _PyMalloc_MALLOC(_PyObject_SIZE(tp)); + if (op == NULL) + return PyErr_NoMemory(); + return PyObject_INIT(op, tp); + } + + PyVarObject * + _PyMalloc_NewVar(PyTypeObject *tp, int nitems) + { + PyVarObject *op; + const size_t size = _PyObject_VAR_SIZE(tp, nitems); + op = (PyVarObject *) _PyMalloc_MALLOC(size); + if (op == NULL) + return (PyVarObject *)PyErr_NoMemory(); + return PyObject_INIT_VAR(op, tp, nitems); + } + + void + _PyMalloc_Del(PyObject *op) + { + _PyMalloc_FREE(op); + } From tim_one@users.sourceforge.net Sat Mar 23 00:20:17 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 22 Mar 2002 16:20:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild pythoncore.dsp,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv31170/python/PCbuild Modified Files: pythoncore.dsp Log Message: Build obmalloc.c directly instead of #include'ing from object.c. Also move all _PyMalloc_XXX entry points into obmalloc.c. The Windows build works fine. The Unix build is changed here (Makefile.pre.in), but not tested. No other platform's build process has been fiddled. Index: pythoncore.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.dsp,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** pythoncore.dsp 21 Dec 2001 22:06:12 -0000 1.31 --- pythoncore.dsp 23 Mar 2002 00:20:15 -0000 1.32 *************** *** 1269,1272 **** --- 1269,1287 ---- # Begin Source File + SOURCE=..\Objects\obmalloc.c + + !IF "$(CFG)" == "pythoncore - Win32 Release" + + !ELSEIF "$(CFG)" == "pythoncore - Win32 Debug" + + !ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Debug" + + !ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Release" + + !ENDIF + + # End Source File + # Begin Source File + SOURCE=..\Modules\operator.c From tim_one@users.sourceforge.net Sat Mar 23 00:29:00 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 22 Mar 2002 16:29:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.6,2.7 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv979/python/Objects Modified Files: obmalloc.c Log Message: Just whitespace fiddling. Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -d -r2.6 -r2.7 *** obmalloc.c 23 Mar 2002 00:20:15 -0000 2.6 --- obmalloc.c 23 Mar 2002 00:28:57 -0000 2.7 *************** *** 62,66 **** * For small requests, the allocator sub-allocates blocks of memory. * Requests greater than 256 bytes are routed to the system's allocator. ! * * Small requests are grouped in size classes spaced 8 bytes apart, due * to the required valid alignment of the returned address. Requests of --- 62,66 ---- * For small requests, the allocator sub-allocates blocks of memory. * Requests greater than 256 bytes are routed to the system's allocator. ! * * Small requests are grouped in size classes spaced 8 bytes apart, due * to the required valid alignment of the returned address. Requests of *************** *** 95,99 **** * 241-248 248 30 * 249-256 256 31 ! * * 0, 257 and up: routed to the underlying allocator. */ --- 95,99 ---- * 241-248 248 30 * 249-256 256 31 ! * * 0, 257 and up: routed to the underlying allocator. */ *************** *** 473,477 **** goto redirect; } ! /* * Keep a reference in the list of allocated arenas. We might * want to release (some of) them in the future. The first --- 473,477 ---- goto redirect; } ! /* * Keep a reference in the list of allocated arenas. We might * want to release (some of) them in the future. The first *************** *** 492,496 **** redirect: ! /* * Redirect the original request to the underlying (libc) allocator. --- 492,496 ---- redirect: ! /* * Redirect the original request to the underlying (libc) allocator. *************** *** 642,653 **** #else /* ! WITH_PYMALLOC */ ! void ! *_PyMalloc_Malloc(size_t n) { return PyMem_MALLOC(n); } ! void ! *_PyMalloc_Realloc(void *p, size_t n) { return PyMem_REALLOC(p, n); --- 642,653 ---- #else /* ! WITH_PYMALLOC */ ! void * ! _PyMalloc_Malloc(size_t n) { return PyMem_MALLOC(n); } ! void * ! _PyMalloc_Realloc(void *p, size_t n) { return PyMem_REALLOC(p, n); *************** *** 661,666 **** #endif /* WITH_PYMALLOC */ ! PyObject ! *_PyMalloc_New(PyTypeObject *tp) { PyObject *op; --- 661,666 ---- #endif /* WITH_PYMALLOC */ ! PyObject * ! _PyMalloc_New(PyTypeObject *tp) { PyObject *op; From nascheme@users.sourceforge.net Sat Mar 23 02:06:52 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 22 Mar 2002 18:06:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects fileobject.c,2.149,2.150 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv18739 Modified Files: fileobject.c Log Message: Check in (hopefully) corrected version of last change. Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.149 retrieving revision 2.150 diff -C2 -d -r2.149 -r2.150 *** fileobject.c 22 Mar 2002 23:50:30 -0000 2.149 --- fileobject.c 23 Mar 2002 02:06:50 -0000 2.150 *************** *** 57,60 **** --- 57,86 ---- } + /* On Unix, fopen will succeed for directories. + In Python, there should be no file objects referring to + directories, so we need a check. */ + + static PyFileObject* + dircheck(PyFileObject* f) + { + #if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR) + struct stat buf; + if (f->f_fp == NULL) + return f; + if (fstat(fileno(f->f_fp), &buf) == 0 && + S_ISDIR(buf.st_mode)) { + #ifdef HAVE_STRERROR + char *msg = strerror(EISDIR); + #else + char *msg = "Is a directory"; + #endif + PyObject *exc = PyObject_CallFunction(PyExc_IOError, "(is)", EISDIR, msg); + PyErr_SetObject(PyExc_IOError, exc); + return NULL; + } + #endif + return f; + } + static PyObject * *************** *** 78,81 **** --- 104,108 ---- return NULL; f->f_fp = fp; + f = dircheck(f); return (PyObject *) f; } *************** *** 131,134 **** --- 158,163 ---- f = NULL; } + if (f != NULL) + f = dircheck(f); return (PyObject *)f; } From tim_one@users.sourceforge.net Sat Mar 23 03:26:55 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 22 Mar 2002 19:26:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_calendar.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv1919/python/Lib/test Modified Files: test_calendar.py Log Message: SF bug 533234: tm_isdst > 1 Passed to strftime. One more time on this turkey, but duller instead of cleverer. Curious: The docs say __getslice__ has been deprecated since 2.0, but list.__getitem__ still doesn't work if you pass it a slice. This makes it a lot clearer to emulate a list by *being* a list . Bugfix candidate. Michael, just pile this patch on top of the others that went by -- no need to try to pick these apart. Index: test_calendar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_calendar.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_calendar.py 15 Mar 2002 03:57:04 -0000 1.2 --- test_calendar.py 23 Mar 2002 03:26:53 -0000 1.3 *************** *** 32,35 **** --- 32,58 ---- self.assertEqual(len([d for d in calendar.day_abbr]), 7) + def test_days(self): + for attr in "day_name", "day_abbr": + value = getattr(calendar, attr) + self.assertEqual(len(value), 7) + self.assertEqual(len(value[:]), 7) + # ensure they're all unique + d = {} + for v in value: + d[v] = 1 + self.assertEqual(len(d), 7) + + def test_months(self): + for attr in "month_name", "month_abbr": + value = getattr(calendar, attr) + self.assertEqual(len(value), 13) + self.assertEqual(len(value[:]), 13) + self.assertEqual(value[0], "") + # ensure they're all unique + d = {} + for v in value: + d[v] = 1 + self.assertEqual(len(d), 13) + def test_main(): run_unittest(CalendarTestCase) From tim_one@users.sourceforge.net Sat Mar 23 03:26:55 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 22 Mar 2002 19:26:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib calendar.py,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv1919/python/Lib Modified Files: calendar.py Log Message: SF bug 533234: tm_isdst > 1 Passed to strftime. One more time on this turkey, but duller instead of cleverer. Curious: The docs say __getslice__ has been deprecated since 2.0, but list.__getitem__ still doesn't work if you pass it a slice. This makes it a lot clearer to emulate a list by *being* a list . Bugfix candidate. Michael, just pile this patch on top of the others that went by -- no need to try to pick these apart. Index: calendar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/calendar.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** calendar.py 22 Mar 2002 18:35:51 -0000 1.26 --- calendar.py 23 Mar 2002 03:26:53 -0000 1.27 *************** *** 10,17 **** # Import functions and variables from time module from time import localtime, mktime, strftime __all__ = ["error","setfirstweekday","firstweekday","isleap", "leapdays","weekday","monthrange","monthcalendar", ! "prmonth","month","prcal","calendar","timegm"] # Exception raised for bad input (with string parameter for details) --- 10,19 ---- # Import functions and variables from time module from time import localtime, mktime, strftime + from types import SliceType __all__ = ["error","setfirstweekday","firstweekday","isleap", "leapdays","weekday","monthrange","monthcalendar", ! "prmonth","month","prcal","calendar","timegm", ! "month_name", "month_abbr", "day_name", "day_abbr"] # Exception raised for bad input (with string parameter for details) *************** *** 25,51 **** mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] ! class _localized_name: ! def __init__(self, format, len): self.format = format ! self.len = len ! def __getitem__(self, item): ! if isinstance(item, int): ! if item < 0: item += self.len ! if not 0 <= item < self.len: ! raise IndexError, "out of range" ! t = (2001, 1, item+1, 12, 0, 0, item, item+1, 0) ! return strftime(self.format, t).capitalize() ! elif isinstance(item, type(slice(0))): ! return [self[e] for e in range(self.len)].__getslice__(item.start, item.stop) def __len__(self): ! return self.len # Full and abbreviated names of weekdays ! day_name = _localized_name('%A', 7) ! day_abbr = _localized_name('%a', 7) # Full and abbreviated names of months (1-based arrays!!!) ! month_name = _localized_name('%B', 13) ! month_abbr = _localized_name('%b', 13) # Constants for weekdays --- 27,76 ---- mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] ! # This module used to have hard-coded lists of day and month names, as ! # English strings. The classes following emulate a read-only version of ! # that, but supply localized names. Note that the values are computed ! # fresh on each call, in case the user changes locale between calls. ! ! class _indexer: ! def __getitem__(self, i): ! if isinstance(i, SliceType): ! return self.data[i.start : i.stop] ! else: ! # May raise an appropriate exception. ! return self.data[i] ! ! class _localized_month(_indexer): ! def __init__(self, format): self.format = format ! ! def __getitem__(self, i): ! self.data = [strftime(self.format, (2001, j, 1, 12, 0, 0, 1, 1, 0)) ! for j in range(1, 13)] ! self.data.insert(0, "") ! return _indexer.__getitem__(self, i) ! def __len__(self): ! return 13 ! ! class _localized_day(_indexer): ! def __init__(self, format): ! self.format = format ! ! def __getitem__(self, i): ! # January 1, 2001, was a Monday. ! self.data = [strftime(self.format, (2001, 1, j+1, 12, 0, 0, j, j+1, 0)) ! for j in range(7)] ! return _indexer.__getitem__(self, i) ! ! def __len__(self_): ! return 7 # Full and abbreviated names of weekdays ! day_name = _localized_day('%A') ! day_abbr = _localized_day('%a') # Full and abbreviated names of months (1-based arrays!!!) ! month_name = _localized_month('%B') ! month_abbr = _localized_month('%b') # Constants for weekdays From montanaro@users.sourceforge.net Sat Mar 23 05:30:01 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Fri, 22 Mar 2002 21:30:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_urlparse,1.3,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv19265 Removed Files: test_urlparse Log Message: no longer needed - converted test_urlparse.py to use unittest --- test_urlparse DELETED --- From montanaro@users.sourceforge.net Sat Mar 23 05:32:12 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Fri, 22 Mar 2002 21:32:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_urlparse.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv19659 Modified Files: test_urlparse.py Log Message: added RFC 2396 tests from Aaron Swartz included in bug # 450225. converted to use unittest Index: test_urlparse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_urlparse.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_urlparse.py 18 Mar 2002 13:06:00 -0000 1.3 --- test_urlparse.py 23 Mar 2002 05:32:10 -0000 1.4 *************** *** 1,84 **** ! import urlparse ! errors = 0 RFC1808_BASE = "http://a/b/c/d;p?q#f" ! for url, expected in [('http://www.python.org', ! ('http', 'www.python.org', '', '', '', '')), ! ('http://www.python.org#abc', ! ('http', 'www.python.org', '', '', '', 'abc')), ! ('http://www.python.org/#abc', ! ('http', 'www.python.org', '/', '', '', 'abc')), ! (RFC1808_BASE, ! ('http', 'a', '/b/c/d', 'p', 'q', 'f')), ! ]: ! result = urlparse.urlparse(url) ! print "%-13s = %r" % (url, result) ! if result != expected: ! errors += 1 ! print "urlparse(%r)" % url ! print ("expected %r,\n" ! " got %r") % (expected, result) ! print ! def checkJoin(relurl, expected): ! global errors ! result = urlparse.urljoin(RFC1808_BASE, relurl) ! print "%-13s = %r" % (relurl, result) ! if result != expected: ! errors += 1 ! print "urljoin(%r, %r)" % (RFC1808_BASE, relurl) ! print ("expected %r,\n" ! " got %r") % (expected, result) ! print "urlparse.urljoin() tests" ! print ! # "normal" cases from RFC 1808: ! checkJoin('g:h', 'g:h') ! checkJoin('g', 'http://a/b/c/g') ! checkJoin('./g', 'http://a/b/c/g') ! checkJoin('g/', 'http://a/b/c/g/') ! checkJoin('/g', 'http://a/g') ! checkJoin('//g', 'http://g') ! checkJoin('?y', 'http://a/b/c/d;p?y') ! checkJoin('g?y', 'http://a/b/c/g?y') ! checkJoin('g?y/./x', 'http://a/b/c/g?y/./x') ! checkJoin('#s', 'http://a/b/c/d;p?q#s') ! checkJoin('g#s', 'http://a/b/c/g#s') ! checkJoin('g#s/./x', 'http://a/b/c/g#s/./x') ! checkJoin('g?y#s', 'http://a/b/c/g?y#s') ! checkJoin(';x', 'http://a/b/c/d;x') ! checkJoin('g;x', 'http://a/b/c/g;x') ! checkJoin('g;x?y#s', 'http://a/b/c/g;x?y#s') ! checkJoin('.', 'http://a/b/c/') ! checkJoin('./', 'http://a/b/c/') ! checkJoin('..', 'http://a/b/') ! checkJoin('../', 'http://a/b/') ! checkJoin('../g', 'http://a/b/g') ! checkJoin('../..', 'http://a/') ! checkJoin('../../', 'http://a/') ! checkJoin('../../g', 'http://a/g') ! # "abnormal" cases from RFC 1808: ! checkJoin('', 'http://a/b/c/d;p?q#f') ! checkJoin('../../../g', 'http://a/../g') ! checkJoin('../../../../g', 'http://a/../../g') ! checkJoin('/./g', 'http://a/./g') ! checkJoin('/../g', 'http://a/../g') ! checkJoin('g.', 'http://a/b/c/g.') ! checkJoin('.g', 'http://a/b/c/.g') ! checkJoin('g..', 'http://a/b/c/g..') ! checkJoin('..g', 'http://a/b/c/..g') ! checkJoin('./../g', 'http://a/b/g') ! checkJoin('./g/.', 'http://a/b/c/g/') ! checkJoin('g/./h', 'http://a/b/c/g/h') ! checkJoin('g/../h', 'http://a/b/c/h') ! # RFC 1808 and RFC 1630 disagree on these (according to RFC 1808), ! # so we'll not actually run these tests (which expect 1808 behavior). ! #checkJoin('http:g', 'http:g') ! #checkJoin('http:', 'http:') - print errors, "errors" --- 1,126 ---- ! #! /usr/bin/env python ! import test_support ! import unittest ! import urlparse RFC1808_BASE = "http://a/b/c/d;p?q#f" + RFC2396_BASE = "http://a/b/c/d;p?q" ! class UrlParseTestCase(unittest.TestCase): ! def test_frags(self): ! for url, expected in [('http://www.python.org', ! ('http', 'www.python.org', '', '', '', '')), ! ('http://www.python.org#abc', ! ('http', 'www.python.org', '', '', '', 'abc')), ! ('http://www.python.org/#abc', ! ('http', 'www.python.org', '/', '', '', 'abc')), ! (RFC1808_BASE, ! ('http', 'a', '/b/c/d', 'p', 'q', 'f')), ! ]: ! result = urlparse.urlparse(url) ! self.assertEqual(result, expected) ! def checkJoin(self, base, relurl, expected): ! self.assertEqual(urlparse.urljoin(base, relurl), expected) ! def test_RFC1808(self): ! # "normal" cases from RFC 1808: ! self.checkJoin(RFC1808_BASE, 'g:h', 'g:h') ! self.checkJoin(RFC1808_BASE, 'g', 'http://a/b/c/g') ! self.checkJoin(RFC1808_BASE, './g', 'http://a/b/c/g') ! self.checkJoin(RFC1808_BASE, 'g/', 'http://a/b/c/g/') ! self.checkJoin(RFC1808_BASE, '/g', 'http://a/g') ! self.checkJoin(RFC1808_BASE, '//g', 'http://g') ! self.checkJoin(RFC1808_BASE, '?y', 'http://a/b/c/d;p?y') ! self.checkJoin(RFC1808_BASE, 'g?y', 'http://a/b/c/g?y') ! self.checkJoin(RFC1808_BASE, 'g?y/./x', 'http://a/b/c/g?y/./x') ! self.checkJoin(RFC1808_BASE, '#s', 'http://a/b/c/d;p?q#s') ! self.checkJoin(RFC1808_BASE, 'g#s', 'http://a/b/c/g#s') ! self.checkJoin(RFC1808_BASE, 'g#s/./x', 'http://a/b/c/g#s/./x') ! self.checkJoin(RFC1808_BASE, 'g?y#s', 'http://a/b/c/g?y#s') ! self.checkJoin(RFC1808_BASE, ';x', 'http://a/b/c/d;x') ! self.checkJoin(RFC1808_BASE, 'g;x', 'http://a/b/c/g;x') ! self.checkJoin(RFC1808_BASE, 'g;x?y#s', 'http://a/b/c/g;x?y#s') ! self.checkJoin(RFC1808_BASE, '.', 'http://a/b/c/') ! self.checkJoin(RFC1808_BASE, './', 'http://a/b/c/') ! self.checkJoin(RFC1808_BASE, '..', 'http://a/b/') ! self.checkJoin(RFC1808_BASE, '../', 'http://a/b/') ! self.checkJoin(RFC1808_BASE, '../g', 'http://a/b/g') ! self.checkJoin(RFC1808_BASE, '../..', 'http://a/') ! self.checkJoin(RFC1808_BASE, '../../', 'http://a/') ! self.checkJoin(RFC1808_BASE, '../../g', 'http://a/g') ! # "abnormal" cases from RFC 1808: ! self.checkJoin(RFC1808_BASE, '', 'http://a/b/c/d;p?q#f') ! self.checkJoin(RFC1808_BASE, '../../../g', 'http://a/../g') ! self.checkJoin(RFC1808_BASE, '../../../../g', 'http://a/../../g') ! self.checkJoin(RFC1808_BASE, '/./g', 'http://a/./g') ! self.checkJoin(RFC1808_BASE, '/../g', 'http://a/../g') ! self.checkJoin(RFC1808_BASE, 'g.', 'http://a/b/c/g.') ! self.checkJoin(RFC1808_BASE, '.g', 'http://a/b/c/.g') ! self.checkJoin(RFC1808_BASE, 'g..', 'http://a/b/c/g..') ! self.checkJoin(RFC1808_BASE, '..g', 'http://a/b/c/..g') ! self.checkJoin(RFC1808_BASE, './../g', 'http://a/b/g') ! self.checkJoin(RFC1808_BASE, './g/.', 'http://a/b/c/g/') ! self.checkJoin(RFC1808_BASE, 'g/./h', 'http://a/b/c/g/h') ! self.checkJoin(RFC1808_BASE, 'g/../h', 'http://a/b/c/h') ! # RFC 1808 and RFC 1630 disagree on these (according to RFC 1808), ! # so we'll not actually run these tests (which expect 1808 behavior). ! #self.checkJoin(RFC1808_BASE, 'http:g', 'http:g') ! #self.checkJoin(RFC1808_BASE, 'http:', 'http:') ! def test_RFC2396(self): ! # cases from RFC 2396 ! ! ### urlparse.py as of v 1.32 fails on these two ! #self.checkJoin(RFC2396_BASE, '?y', 'http://a/b/c/?y') ! #self.checkJoin(RFC2396_BASE, ';x', 'http://a/b/c/;x') ! ! self.checkJoin(RFC2396_BASE, 'g:h', 'g:h') ! self.checkJoin(RFC2396_BASE, 'g', 'http://a/b/c/g') ! self.checkJoin(RFC2396_BASE, './g', 'http://a/b/c/g') ! self.checkJoin(RFC2396_BASE, 'g/', 'http://a/b/c/g/') ! self.checkJoin(RFC2396_BASE, '/g', 'http://a/g') ! self.checkJoin(RFC2396_BASE, '//g', 'http://g') ! self.checkJoin(RFC2396_BASE, 'g?y', 'http://a/b/c/g?y') ! self.checkJoin(RFC2396_BASE, '#s', 'http://a/b/c/d;p?q#s') ! self.checkJoin(RFC2396_BASE, 'g#s', 'http://a/b/c/g#s') ! self.checkJoin(RFC2396_BASE, 'g?y#s', 'http://a/b/c/g?y#s') ! self.checkJoin(RFC2396_BASE, 'g;x', 'http://a/b/c/g;x') ! self.checkJoin(RFC2396_BASE, 'g;x?y#s', 'http://a/b/c/g;x?y#s') ! self.checkJoin(RFC2396_BASE, '.', 'http://a/b/c/') ! self.checkJoin(RFC2396_BASE, './', 'http://a/b/c/') ! self.checkJoin(RFC2396_BASE, '..', 'http://a/b/') ! self.checkJoin(RFC2396_BASE, '../', 'http://a/b/') ! self.checkJoin(RFC2396_BASE, '../g', 'http://a/b/g') ! self.checkJoin(RFC2396_BASE, '../..', 'http://a/') ! self.checkJoin(RFC2396_BASE, '../../', 'http://a/') ! self.checkJoin(RFC2396_BASE, '../../g', 'http://a/g') ! self.checkJoin(RFC2396_BASE, '', RFC2396_BASE) ! self.checkJoin(RFC2396_BASE, '../../../g', 'http://a/../g') ! self.checkJoin(RFC2396_BASE, '../../../../g', 'http://a/../../g') ! self.checkJoin(RFC2396_BASE, '/./g', 'http://a/./g') ! self.checkJoin(RFC2396_BASE, '/../g', 'http://a/../g') ! self.checkJoin(RFC2396_BASE, 'g.', 'http://a/b/c/g.') ! self.checkJoin(RFC2396_BASE, '.g', 'http://a/b/c/.g') ! self.checkJoin(RFC2396_BASE, 'g..', 'http://a/b/c/g..') ! self.checkJoin(RFC2396_BASE, '..g', 'http://a/b/c/..g') ! self.checkJoin(RFC2396_BASE, './../g', 'http://a/b/g') ! self.checkJoin(RFC2396_BASE, './g/.', 'http://a/b/c/g/') ! self.checkJoin(RFC2396_BASE, 'g/./h', 'http://a/b/c/g/h') ! self.checkJoin(RFC2396_BASE, 'g/../h', 'http://a/b/c/h') ! self.checkJoin(RFC2396_BASE, 'g;x=1/./y', 'http://a/b/c/g;x=1/y') ! self.checkJoin(RFC2396_BASE, 'g;x=1/../y', 'http://a/b/c/y') ! self.checkJoin(RFC2396_BASE, 'g?y/./x', 'http://a/b/c/g?y/./x') ! self.checkJoin(RFC2396_BASE, 'g?y/../x', 'http://a/b/c/g?y/../x') ! self.checkJoin(RFC2396_BASE, 'g#s/./x', 'http://a/b/c/g#s/./x') ! self.checkJoin(RFC2396_BASE, 'g#s/../x', 'http://a/b/c/g#s/../x') ! ! def test_main(): ! test_support.run_unittest(UrlParseTestCase) ! ! if __name__ == "__main__": ! test_main() From montanaro@users.sourceforge.net Sat Mar 23 05:47:33 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Fri, 22 Mar 2002 21:47:33 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib CGIHTTPServer.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv21870 Modified Files: CGIHTTPServer.py Log Message: tighten up except - int() only raises ValueError Index: CGIHTTPServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/CGIHTTPServer.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** CGIHTTPServer.py 1 Feb 2002 16:27:59 -0000 1.21 --- CGIHTTPServer.py 23 Mar 2002 05:47:31 -0000 1.22 *************** *** 236,240 **** try: nbytes = int(length) ! except: nbytes = 0 files = popenx(cmdline, 'b') --- 236,240 ---- try: nbytes = int(length) ! except ValueError: nbytes = 0 files = popenx(cmdline, 'b') From montanaro@users.sourceforge.net Sat Mar 23 05:50:20 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Fri, 22 Mar 2002 21:50:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib cgi.py,1.69,1.70 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv22349 Modified Files: cgi.py Log Message: tighten up except - only ValueError can be raised in this situation Index: cgi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cgi.py,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** cgi.py 11 Feb 2002 17:57:55 -0000 1.69 --- cgi.py 23 Mar 2002 05:50:17 -0000 1.70 *************** *** 507,511 **** try: clen = int(self.headers['content-length']) ! except: pass if maxlen and clen > maxlen: --- 507,511 ---- try: clen = int(self.headers['content-length']) ! except ValueError: pass if maxlen and clen > maxlen: From montanaro@users.sourceforge.net Sat Mar 23 05:55:21 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Fri, 22 Mar 2002 21:55:21 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib quopri.py,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv23318 Modified Files: quopri.py Log Message: import statements only raise ImportError, right? Index: quopri.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/quopri.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** quopri.py 15 Oct 2001 18:44:01 -0000 1.18 --- quopri.py 23 Mar 2002 05:55:18 -0000 1.19 *************** *** 14,18 **** try: from binascii import a2b_qp, b2a_qp ! except: a2b_qp = None b2a_qp = None --- 14,18 ---- try: from binascii import a2b_qp, b2a_qp ! except ImportError: a2b_qp = None b2a_qp = None From montanaro@users.sourceforge.net Sat Mar 23 05:58:54 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Fri, 22 Mar 2002 21:58:54 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib mimetools.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv23767 Modified Files: mimetools.py Log Message: Only AttributeError can be raised in this situation - on systems without getuid or getpid. posix_getuid & posix_getpid never raise exceptions when called with no args. Index: mimetools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mimetools.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** mimetools.py 23 Feb 2001 20:04:54 -0000 1.23 --- mimetools.py 23 Mar 2002 05:58:52 -0000 1.24 *************** *** 117,125 **** try: uid = `os.getuid()` ! except: uid = '1' try: pid = `os.getpid()` ! except: pid = '1' _prefix = hostid + '.' + uid + '.' + pid --- 117,125 ---- try: uid = `os.getuid()` ! except AttributeError: uid = '1' try: pid = `os.getpid()` ! except AttributeError: pid = '1' _prefix = hostid + '.' + uid + '.' + pid From tim.one@comcast.net Sat Mar 23 08:33:21 2002 From: tim.one@comcast.net (Tim Peters) Date: Sat, 23 Mar 2002 03:33:21 -0500 Subject: [Python-checkins] CVS: python/dist/src/Lib CGIHTTPServer.py,1.21,1.22 In-Reply-To: Message-ID: > tighten up except - int() only raises ValueError Maybe in context? int() can also raise OverflowError and TypeError (e.g., int(1L << 500) and int(1j), respectively). From tim_one@users.sourceforge.net Sat Mar 23 10:03:53 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 23 Mar 2002 02:03:53 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects fileobject.c,2.150,2.151 obmalloc.c,2.7,2.8 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv24518/python/Objects Modified Files: fileobject.c obmalloc.c Log Message: Give Python a debug-mode pymalloc, much as sketched on Python-Dev. When WITH_PYMALLOC is defined, define PYMALLOC_DEBUG to enable the debug allocator. This can be done independent of build type (release or debug). A debug build automatically defines PYMALLOC_DEBUG when pymalloc is enabled. It's a detected error to define PYMALLOC_DEBUG when pymalloc isn't enabled. Two debugging entry points defined only under PYMALLOC_DEBUG: + _PyMalloc_DebugCheckAddress(const void *p) can be used (e.g., from gdb) to sanity-check a memory block obtained from pymalloc. It sprays info to stderr (see next) and dies via Py_FatalError if the block is detectably damaged. + _PyMalloc_DebugDumpAddress(const void *p) can be used to spray info about a debug memory block to stderr. A tiny start at implementing "API family" checks isn't good for anything yet. _PyMalloc_DebugRealloc() has been optimized to do little when the new size is <= old size. However, if the new size is larger, it really can't call the underlying realloc() routine without either violating its contract, or knowing something non-trivial about how the underlying realloc() works. A memcpy is always done in this case. This was a disaster for (and only) one of the std tests: test_bufio creates single text file lines up to a million characters long. On Windows, fileobject.c's get_line() uses the horridly funky getline_via_fgets(), which keeps growing and growing a string object hoping to find a newline. It grew the string object 1000 bytes each time, so for a million-character string it took approximately forever (I gave up after a few minutes). So, also: fileobject.c, getline_via_fgets(): When a single line is outrageously long, grow the string object at a mildly exponential rate, instead of just 1000 bytes at a time. That's enough so that a debug-build test_bufio finishes in about 5 seconds on my Win98SE box. I'm curious to try this on Win2K, because it has very different memory behavior than Win9X, and test_bufio always took a factor of 10 longer to complete on Win2K. It *could* be that the endless reallocs were simply killing it on Win2K even in the release build. Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.150 retrieving revision 2.151 diff -C2 -d -r2.150 -r2.151 *** fileobject.c 23 Mar 2002 02:06:50 -0000 2.150 --- fileobject.c 23 Mar 2002 10:03:50 -0000 2.151 *************** *** 773,783 **** * text-crunching job reported on Python-Dev was a mail-log crawler where over * half the lines were 254 chars. - * INCBUFSIZE is the amount by which we grow the buffer, if MAXBUFSIZE isn't - * enough. It doesn't much matter what this is set to: we only get here for - * absurdly long lines anyway. */ #define INITBUFSIZE 100 #define MAXBUFSIZE 300 - #define INCBUFSIZE 1000 char* p; /* temp */ char buf[MAXBUFSIZE]; --- 773,779 ---- *************** *** 787,790 **** --- 783,787 ---- size_t nfree; /* # of free buffer slots; pvend-pvfree */ size_t total_v_size; /* total # of slots in buffer */ + size_t increment; /* amount to increment the buffer */ /* Optimize for normal case: avoid _PyString_Resize if at all *************** *** 854,858 **** * into its buffer. */ ! total_v_size = MAXBUFSIZE + INCBUFSIZE; v = PyString_FromStringAndSize((char*)NULL, (int)total_v_size); if (v == NULL) --- 851,855 ---- * into its buffer. */ ! total_v_size = MAXBUFSIZE << 1; v = PyString_FromStringAndSize((char*)NULL, (int)total_v_size); if (v == NULL) *************** *** 898,902 **** /* expand buffer and try again */ assert(*(pvend-1) == '\0'); ! total_v_size += INCBUFSIZE; if (total_v_size > INT_MAX) { PyErr_SetString(PyExc_OverflowError, --- 895,900 ---- /* expand buffer and try again */ assert(*(pvend-1) == '\0'); ! increment = total_v_size >> 2; /* mild exponential growth */ ! total_v_size += increment; if (total_v_size > INT_MAX) { PyErr_SetString(PyExc_OverflowError, *************** *** 908,912 **** return NULL; /* overwrite the trailing null byte */ ! pvfree = BUF(v) + (total_v_size - INCBUFSIZE - 1); } if (BUF(v) + total_v_size != p) --- 906,910 ---- return NULL; /* overwrite the trailing null byte */ ! pvfree = BUF(v) + (total_v_size - increment - 1); } if (BUF(v) + total_v_size != p) *************** *** 915,919 **** #undef INITBUFSIZE #undef MAXBUFSIZE - #undef INCBUFSIZE } #endif /* ifdef USE_FGETS_IN_GETLINE */ --- 913,916 ---- Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -d -r2.7 -r2.8 *** obmalloc.c 23 Mar 2002 00:28:57 -0000 2.7 --- obmalloc.c 23 Mar 2002 10:03:50 -0000 2.8 *************** *** 624,645 **** } - /* calloc */ - - /* -- unused -- - void * - _PyMalloc_Calloc(size_t nbel, size_t elsz) - { - void *p; - size_t nbytes; - - nbytes = nbel * elsz; - p = _PyMalloc_Malloc(nbytes); - if (p != NULL) - memset(p, 0, nbytes); - return p; - } - */ - #else /* ! WITH_PYMALLOC */ void * _PyMalloc_Malloc(size_t n) --- 624,631 ---- } #else /* ! WITH_PYMALLOC */ + + /*==========================================================================*/ + /* pymalloc not enabled: Redirect the entry points to the PyMem family. */ void * _PyMalloc_Malloc(size_t n) *************** *** 687,688 **** --- 673,986 ---- _PyMalloc_FREE(op); } + + #ifdef PYMALLOC_DEBUG + /*==========================================================================*/ + /* A x-platform debugging allocator. */ + + #define PYMALLOC_CLEANBYTE 0xCB /* uninitialized memory */ + #define PYMALLOC_DEADBYTE 0xDB /* free()ed memory */ + #define PYMALLOC_FORBIDDENBYTE 0xFB /* unusable memory */ + + static ulong serialno = 0; /* incremented on each debug {m,re}alloc */ + + /* Read 4 bytes at p as a big-endian ulong. */ + static ulong + read4(const void *p) + { + const unsigned char *q = (unsigned char *)p; + return ((ulong)q[0] << 24) | + ((ulong)q[1] << 16) | + ((ulong)q[2] << 8) | + (ulong)q[3]; + } + + /* Write the 4 least-significant bytes of n as a big-endian unsigned int, + MSB at address p, LSB at p+3. */ + static void + write4(void *p, ulong n) + { + unsigned char *q = (unsigned char *)p; + q[0] = (unsigned char)((n >> 24) & 0xff); + q[1] = (unsigned char)((n >> 16) & 0xff); + q[2] = (unsigned char)((n >> 8) & 0xff); + q[3] = (unsigned char)( n & 0xff); + } + + static void + check_family(const void *p, int family) + { + const uchar *q = (const uchar *)p; + int original_family; + char buf[200]; + + assert(p != NULL); + original_family = (int)*(q-4); + if (family != original_family) { + /* XXX better msg */ + PyOS_snprintf(buf, sizeof(buf), + "free or realloc from family #%d called, " + "but block was allocated by family #%d", + family, original_family); + _PyMalloc_DebugDumpAddress(p); + Py_FatalError(buf); + } + } + + /* The debug malloc asks for 16 extra bytes and fills them with useful stuff, + here calling the underlying malloc's result p: + + p[0:4] + Number of bytes originally asked for. 4-byte unsigned integer, + big-endian (easier to read in a memory dump). + p[4] + The API "family" this malloc call belongs to. XXX todo XXX + p[5:8] + Copies of PYMALLOC_FORBIDDENBYTE. Used to catch under- writes + and reads. + p[8:8+n] + The requested memory, filled with copies of PYMALLOC_CLEANBYTE. + Used to catch reference to uninitialized memory. + &p[8] is returned. Note that this is 8-byte aligned if PyMalloc + handled the request itself. + p[8+n:8+n+4] + Copies of PYMALLOC_FORBIDDENBYTE. Used to catch over- writes + and reads. + p[8+n+4:8+n+8] + A serial number, incremented by 1 on each call to _PyMalloc_DebugMalloc + and _PyMalloc_DebugRealloc. + 4-byte unsigned integer, big-endian. + If "bad memory" is detected later, the serial number gives an + excellent way to set a breakpoint on the next run, to capture the + instant at which this block was passed out. + */ + + void * + _PyMalloc_DebugMalloc(size_t nbytes, int family) + { + uchar *p; /* base address of malloc'ed block */ + uchar *q; /* p + 8 + nbytes + */ + size_t total; /* nbytes + 16 */ + + assert(family == 0); + + ++serialno; + total = nbytes + 16; + if (total < nbytes || (total >> 31) > 1) { + /* overflow, or we can't represent it in 4 bytes */ + /* Obscure: can't do (total >> 32) != 0 instead, because + C doesn't define what happens for a right-shift of 32 + when size_t is a 32-bit type. At least C guarantees + size_t is an unsigned type. */ + return NULL; + } + + p = _PyMalloc_Malloc(total); /* XXX derive from family */ + if (p == NULL) + return NULL; + + write4(p, nbytes); + p[4] = (uchar)family; + p[5] = p[6] = p[7] = PYMALLOC_FORBIDDENBYTE; + + if (nbytes > 0) + memset(p+8, PYMALLOC_CLEANBYTE, nbytes); + + q = p + 8 + nbytes; + q[0] = q[1] = q[2] = q[3] = PYMALLOC_FORBIDDENBYTE; + write4(q+4, serialno); + + return p+8; + } + + /* The debug free first uses the address to find the number of bytes + originally asked for, then checks the 8 bytes on each end for + sanity (in particular, that the PYMALLOC_FORBIDDENBYTEs are still + intact). + Then fills the original bytes with PYMALLOC_DEADBYTE. + Then calls the underlying free. + */ + void + _PyMalloc_DebugFree(void *p, int family) + { + uchar *q = (uchar*)p; + size_t nbytes; + + assert(family == 0); + + if (p == NULL) + return; + check_family(p, family); + _PyMalloc_DebugCheckAddress(p); + nbytes = read4(q-8); + if (nbytes > 0) + memset(q, PYMALLOC_DEADBYTE, nbytes); + _PyMalloc_Free(q-8); /* XXX derive from family */ + } + + void * + _PyMalloc_DebugRealloc(void *p, size_t nbytes, int family) + { + uchar *q = (uchar *)p; + size_t original_nbytes; + uchar *fresh; /* new memory block, if needed */ + + assert(family == 0); + + if (p == NULL) + return _PyMalloc_DebugMalloc(nbytes, family); + + check_family(p, family); + _PyMalloc_DebugCheckAddress(p); + + original_nbytes = read4(q-8); + if (nbytes == original_nbytes) { + /* note that this case is likely to be common due to the + way Python appends to lists */ + ++serialno; + write4(q + nbytes + 4, serialno); + return p; + } + + if (nbytes < original_nbytes) { + /* shrinking -- leave the guts alone, except to + fill the excess with DEADBYTE */ + const size_t excess = original_nbytes - nbytes; + ++serialno; + write4(q-8, nbytes); + /* kill the excess bytes plus the trailing 8 pad bytes */ + memset(q + nbytes, PYMALLOC_DEADBYTE, excess + 8); + q += nbytes; + q[0] = q[1] = q[2] = q[3] = PYMALLOC_FORBIDDENBYTE; + write4(q+4, serialno); + return p; + } + + /* More memory is needed: get it, copy over the first original_nbytes + of the original data, and free the original memory. */ + fresh = (uchar *)_PyMalloc_DebugMalloc(nbytes, family); + if (fresh != NULL && original_nbytes > 0) + memcpy(fresh, p, original_nbytes); + _PyMalloc_DebugFree(p, family); + return fresh; + } + + void + _PyMalloc_DebugCheckAddress(const void *p) + { + const uchar *q = (const uchar *)p; + char *msg = NULL; + + if (p == NULL) + msg = "didn't expect a NULL pointer"; + + else if (*(q-3) != PYMALLOC_FORBIDDENBYTE || + *(q-2) != PYMALLOC_FORBIDDENBYTE || + *(q-1) != PYMALLOC_FORBIDDENBYTE) + msg = "bad leading pad byte"; + + else { + const ulong nbytes = read4(q-8); + const uchar *tail = q + nbytes; + int i; + for (i = 0; i < 4; ++i) { + if (tail[i] != PYMALLOC_FORBIDDENBYTE) { + msg = "bad trailing pad byte"; + break; + } + } + } + + if (msg != NULL) { + _PyMalloc_DebugDumpAddress(p); + Py_FatalError(msg); + } + } + + void + _PyMalloc_DebugDumpAddress(const void *p) + { + const uchar *q = (const uchar *)p; + const uchar *tail; + ulong nbytes, serial; + + fprintf(stderr, "Debug memory block at address p=%p:\n", p); + if (p == NULL) + return; + + nbytes = read4(q-8); + fprintf(stderr, " %lu bytes originally allocated\n", nbytes); + fprintf(stderr, " from API family #%d\n", *(q-4)); + + /* In case this is nuts, check the pad bytes before trying to read up + the serial number (the address deref could blow up). */ + + fprintf(stderr, " the 3 pad bytes at p-3 are "); + if (*(q-3) == PYMALLOC_FORBIDDENBYTE && + *(q-2) == PYMALLOC_FORBIDDENBYTE && + *(q-1) == PYMALLOC_FORBIDDENBYTE) { + fprintf(stderr, "PYMALLOC_FORBIDDENBYTE, as expected\n"); + } + else { + int i; + fprintf(stderr, "not all PYMALLOC_FORBIDDENBYTE (0x%02x):\n", + PYMALLOC_FORBIDDENBYTE); + for (i = 3; i >= 1; --i) { + const uchar byte = *(q-i); + fprintf(stderr, " at p-%d: 0x%02x", i, byte); + if (byte != PYMALLOC_FORBIDDENBYTE) + fputs(" *** OUCH", stderr); + fputc('\n', stderr); + } + } + + tail = q + nbytes; + fprintf(stderr, " the 4 pad bytes at tail=%p are ", tail); + if (tail[0] == PYMALLOC_FORBIDDENBYTE && + tail[1] == PYMALLOC_FORBIDDENBYTE && + tail[2] == PYMALLOC_FORBIDDENBYTE && + tail[3] == PYMALLOC_FORBIDDENBYTE) { + fprintf(stderr, "PYMALLOC_FORBIDDENBYTE, as expected\n"); + } + else { + int i; + fprintf(stderr, "not all PYMALLOC_FORBIDDENBYTE (0x%02x):\n", + PYMALLOC_FORBIDDENBYTE); + for (i = 0; i < 4; ++i) { + const uchar byte = tail[i]; + fprintf(stderr, " at tail+%d: 0x%02x", + i, byte); + if (byte != PYMALLOC_FORBIDDENBYTE) + fputs(" *** OUCH", stderr); + fputc('\n', stderr); + } + } + + serial = read4(tail+4); + fprintf(stderr, " the block was made by call #%lu to " + "debug malloc/realloc\n", serial); + + if (nbytes > 0) { + int i = 0; + fprintf(stderr, " data at p:"); + /* print up to 8 bytes at the start */ + while (q < tail && i < 8) { + fprintf(stderr, " %02x", *q); + ++i; + ++q; + } + /* and up to 8 at the end */ + if (q < tail) { + if (tail - q > 8) { + fprintf(stderr, " ..."); + q = tail - 8; + } + while (q < tail) { + fprintf(stderr, " %02x", *q); + ++q; + } + } + fprintf(stderr, "\n"); + } + } + + #endif /* PYMALLOC_DEBUG */ From tim_one@users.sourceforge.net Sat Mar 23 10:03:52 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 23 Mar 2002 02:03:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include Python.h,2.41,2.42 pymem.h,2.8,2.9 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv24518/python/Include Modified Files: Python.h pymem.h Log Message: Give Python a debug-mode pymalloc, much as sketched on Python-Dev. When WITH_PYMALLOC is defined, define PYMALLOC_DEBUG to enable the debug allocator. This can be done independent of build type (release or debug). A debug build automatically defines PYMALLOC_DEBUG when pymalloc is enabled. It's a detected error to define PYMALLOC_DEBUG when pymalloc isn't enabled. Two debugging entry points defined only under PYMALLOC_DEBUG: + _PyMalloc_DebugCheckAddress(const void *p) can be used (e.g., from gdb) to sanity-check a memory block obtained from pymalloc. It sprays info to stderr (see next) and dies via Py_FatalError if the block is detectably damaged. + _PyMalloc_DebugDumpAddress(const void *p) can be used to spray info about a debug memory block to stderr. A tiny start at implementing "API family" checks isn't good for anything yet. _PyMalloc_DebugRealloc() has been optimized to do little when the new size is <= old size. However, if the new size is larger, it really can't call the underlying realloc() routine without either violating its contract, or knowing something non-trivial about how the underlying realloc() works. A memcpy is always done in this case. This was a disaster for (and only) one of the std tests: test_bufio creates single text file lines up to a million characters long. On Windows, fileobject.c's get_line() uses the horridly funky getline_via_fgets(), which keeps growing and growing a string object hoping to find a newline. It grew the string object 1000 bytes each time, so for a million-character string it took approximately forever (I gave up after a few minutes). So, also: fileobject.c, getline_via_fgets(): When a single line is outrageously long, grow the string object at a mildly exponential rate, instead of just 1000 bytes at a time. That's enough so that a debug-build test_bufio finishes in about 5 seconds on my Win98SE box. I'm curious to try this on Win2K, because it has very different memory behavior than Win9X, and test_bufio always took a factor of 10 longer to complete on Win2K. It *could* be that the endless reallocs were simply killing it on Win2K even in the release build. Index: Python.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/Python.h,v retrieving revision 2.41 retrieving revision 2.42 diff -C2 -d -r2.41 -r2.42 *** Python.h 12 Jan 2002 11:05:03 -0000 2.41 --- Python.h 23 Mar 2002 10:03:50 -0000 2.42 *************** *** 62,65 **** --- 62,74 ---- #include "pyport.h" + /* Debug-mode build with pymalloc implies PYMALLOC_DEBUG. + * PYMALLOC_DEBUG is in error if pymalloc is not in use. + */ + #if defined(Py_DEBUG) && defined(WITH_PYMALLOC) && !defined(PYMALLOC_DEBUG) + #define PYMALLOC_DEBUG + #endif + #if defined(PYMALLOC_DEBUG) && !defined(WITH_PYMALLOC) + #error "PYMALLOC_DEBUG requires WITH_PYMALLOC" + #endif #include "pymem.h" Index: pymem.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pymem.h,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -d -r2.8 -r2.9 *** pymem.h 20 Mar 2002 04:02:31 -0000 2.8 --- pymem.h 23 Mar 2002 10:03:50 -0000 2.9 *************** *** 90,94 **** Note that according to ANSI C, free(NULL) has no effect. */ ! /* pymalloc (private to the interpreter) */ #ifdef WITH_PYMALLOC --- 90,94 ---- Note that according to ANSI C, free(NULL) has no effect. */ ! /* pymalloc (private to the interpreter) */ #ifdef WITH_PYMALLOC *************** *** 96,107 **** DL_IMPORT(void *) _PyMalloc_Realloc(void *p, size_t nbytes); DL_IMPORT(void) _PyMalloc_Free(void *p); #define _PyMalloc_MALLOC _PyMalloc_Malloc #define _PyMalloc_REALLOC _PyMalloc_Realloc #define _PyMalloc_FREE _PyMalloc_Free ! #else #define _PyMalloc_MALLOC PyMem_MALLOC #define _PyMalloc_REALLOC PyMem_REALLOC #define _PyMalloc_FREE PyMem_FREE ! #endif --- 96,121 ---- DL_IMPORT(void *) _PyMalloc_Realloc(void *p, size_t nbytes); DL_IMPORT(void) _PyMalloc_Free(void *p); + + #ifdef PYMALLOC_DEBUG + DL_IMPORT(void *) _PyMalloc_DebugMalloc(size_t nbytes, int family); + DL_IMPORT(void *) _PyMalloc_DebugRealloc(void *p, size_t nbytes, int family); + DL_IMPORT(void) _PyMalloc_DebugFree(void *p, int family); + DL_IMPORT(void) _PyMalloc_DebugDumpAddress(const void *p); + DL_IMPORT(void) _PyMalloc_DebugCheckAddress(const void *p); + #define _PyMalloc_MALLOC(N) _PyMalloc_DebugMalloc(N, 0) + #define _PyMalloc_REALLOC(P, N) _PyMalloc_DebugRealloc(P, N, 0) + #define _PyMalloc_FREE(P) _PyMalloc_DebugFree(P, 0) + + #else /* WITH_PYMALLOC && ! PYMALLOC_DEBUG */ #define _PyMalloc_MALLOC _PyMalloc_Malloc #define _PyMalloc_REALLOC _PyMalloc_Realloc #define _PyMalloc_FREE _PyMalloc_Free ! #endif ! ! #else /* ! WITH_PYMALLOC */ #define _PyMalloc_MALLOC PyMem_MALLOC #define _PyMalloc_REALLOC PyMem_REALLOC #define _PyMalloc_FREE PyMem_FREE ! #endif /* WITH_PYMALLOC */ From skip@pobox.com Sat Mar 23 14:09:16 2002 From: skip@pobox.com (Skip Montanaro) Date: Sat, 23 Mar 2002 08:09:16 -0600 Subject: [Python-checkins] CVS: python/dist/src/Lib CGIHTTPServer.py,1.21,1.22 In-Reply-To: References: Message-ID: <15516.35980.137841.155674@12-248-41-177.client.attbi.com> >> tighten up except - int() only raises ValueError Tim> Maybe in context? int() can also raise OverflowError and TypeError Tim> (e.g., int(1L << 500) and int(1j), respectively). Yes, in this context. In this situation it is always fed a string, the value of the Content-Length request header: length = self.headers.getheader('content-length') then later (nested): try: nbytes = int(length) except ValueError: nbytes = 0 Skip From jeremy@zope.com Sat Mar 23 18:11:28 2002 From: jeremy@zope.com (Jeremy Hylton) Date: Sat, 23 Mar 2002 13:11:28 -0500 Subject: [Python-checkins] CVS: python/dist/src/Lib cgi.py,1.69,1.70 In-Reply-To: References: Message-ID: <15516.50512.183220.31961@slothrop.zope.com> >>>>> "SM" == Skip Montanaro writes: SM> Update of /cvsroot/python/python/dist/src/Lib In directory SM> usw-pr-cvs1:/tmp/cvs-serv22349 SM> Modified Files: SM> cgi.py SM> Log Message: tighten up except - only ValueError can be raised SM> in this situation Guido recently observed that he doesn't know which exceptions can be raised by int() -- certainly ValueError and OverflowError, perhaps others. Should this try/except only catch ValueError? Jeremy From skip@pobox.com Sat Mar 23 19:14:03 2002 From: skip@pobox.com (Skip Montanaro) Date: Sat, 23 Mar 2002 13:14:03 -0600 Subject: [Python-checkins] CVS: python/dist/src/Lib cgi.py,1.69,1.70 In-Reply-To: <15516.50512.183220.31961@slothrop.zope.com> References: <15516.50512.183220.31961@slothrop.zope.com> Message-ID: <15516.54267.798838.76341@12-248-41-177.client.attbi.com> SM> cgi.py SM> Log Message: tighten up except - only ValueError can be raised SM> in this situation Jeremy> Guido recently observed that he doesn't know which exceptions Jeremy> can be raised by int() -- certainly ValueError and Jeremy> OverflowError, perhaps others. Should this try/except only Jeremy> catch ValueError? Same explanation as for CGIHTTPServer.py - it's converting a string. I haven't been able to provoke anything besides a ValueError out of string conversions. If you look at PyInt_FromString, that appears to be the only exception that can be raised. Skip From nascheme@users.sourceforge.net Sat Mar 23 19:41:36 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 23 Mar 2002 11:41:36 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects fileobject.c,2.151,2.152 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv24282/Objects Modified Files: fileobject.c Log Message: Grow the string buffer at a mildly exponential rate for the getc version of get_line. This makes test_bufio finish in 1.7 seconds instead of 57 seconds on my machine (with Py_DEBUG defined). Also, rename the local variables n1 and n2 to used_v_size and total_v_size. Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.151 retrieving revision 2.152 diff -C2 -d -r2.151 -r2.152 *** fileobject.c 23 Mar 2002 10:03:50 -0000 2.151 --- fileobject.c 23 Mar 2002 19:41:34 -0000 2.152 *************** *** 938,942 **** int c; char *buf, *end; ! size_t n1, n2; PyObject *v; --- 938,944 ---- int c; char *buf, *end; ! size_t total_v_size; /* total # of slots in buffer */ ! size_t used_v_size; /* # used slots in buffer */ ! size_t increment; /* amount to increment the buffer */ PyObject *v; *************** *** 945,954 **** return getline_via_fgets(fp); #endif ! n2 = n > 0 ? n : 100; ! v = PyString_FromStringAndSize((char *)NULL, n2); if (v == NULL) return NULL; buf = BUF(v); ! end = buf + n2; for (;;) { --- 947,956 ---- return getline_via_fgets(fp); #endif ! total_v_size = n > 0 ? n : 100; ! v = PyString_FromStringAndSize((char *)NULL, total_v_size); if (v == NULL) return NULL; buf = BUF(v); ! end = buf + total_v_size; for (;;) { *************** *** 980,986 **** if (n > 0) break; ! n1 = n2; ! n2 += 1000; ! if (n2 > INT_MAX) { PyErr_SetString(PyExc_OverflowError, "line is longer than a Python string can hold"); --- 982,989 ---- if (n > 0) break; ! used_v_size = total_v_size; ! increment = total_v_size >> 2; /* mild exponential growth */ ! total_v_size += increment; ! if (total_v_size > INT_MAX) { PyErr_SetString(PyExc_OverflowError, "line is longer than a Python string can hold"); *************** *** 988,1000 **** return NULL; } ! if (_PyString_Resize(&v, n2) < 0) return NULL; ! buf = BUF(v) + n1; ! end = BUF(v) + n2; } ! n1 = buf - BUF(v); ! if (n1 != n2) ! _PyString_Resize(&v, n1); return v; } --- 991,1003 ---- return NULL; } ! if (_PyString_Resize(&v, total_v_size) < 0) return NULL; ! buf = BUF(v) + used_v_size; ! end = BUF(v) + total_v_size; } ! used_v_size = buf - BUF(v); ! if (used_v_size != total_v_size) ! _PyString_Resize(&v, used_v_size); return v; } From nascheme@users.sourceforge.net Sat Mar 23 20:44:01 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 23 Mar 2002 12:44:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib cmd.py,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv5309/Lib Modified Files: cmd.py Log Message: Flush stdout before reading next command. Closes SF bug 526357. Index: cmd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cmd.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** cmd.py 9 Aug 2001 21:40:30 -0000 1.26 --- cmd.py 23 Mar 2002 20:43:59 -0000 1.27 *************** *** 95,98 **** --- 95,99 ---- else: sys.stdout.write(self.prompt) + sys.stdout.flush() line = sys.stdin.readline() if not len(line): From nascheme@users.sourceforge.net Sat Mar 23 20:46:37 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 23 Mar 2002 12:46:37 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python sysmodule.c,2.101,2.102 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv5721 Modified Files: sysmodule.c Log Message: Fix wording of sys.exit docstring. Close SF bug 534113. Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.101 retrieving revision 2.102 diff -C2 -d -r2.101 -r2.102 *** sysmodule.c 3 Mar 2002 15:11:17 -0000 2.101 --- sysmodule.c 23 Mar 2002 20:46:35 -0000 2.102 *************** *** 157,161 **** Exit the interpreter by raising SystemExit(status).\n\ If the status is omitted or None, it defaults to zero (i.e., success).\n\ ! If the status numeric, it will be used as the system exit status.\n\ If it is another kind of object, it will be printed and the system\n\ exit status will be one (i.e., failure)."; --- 157,161 ---- Exit the interpreter by raising SystemExit(status).\n\ If the status is omitted or None, it defaults to zero (i.e., success).\n\ ! If the status is numeric, it will be used as the system exit status.\n\ If it is another kind of object, it will be printed and the system\n\ exit status will be one (i.e., failure)."; From nascheme@users.sourceforge.net Sat Mar 23 20:57:13 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 23 Mar 2002 12:57:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/api exceptions.tex,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv8360 Modified Files: exceptions.tex Log Message: Fix example for PyErr_SetFromErrno() (need to pass exception type). Index: exceptions.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/exceptions.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** exceptions.tex 3 Dec 2001 17:56:09 -0000 1.3 --- exceptions.tex 23 Mar 2002 20:57:11 -0000 1.4 *************** *** 179,184 **** indicator, leaves it set to that. The function always returns \NULL, so a wrapper function around a system call can write ! \samp{return PyErr_SetFromErrno();} when the system call returns an ! error. \end{cfuncdesc} --- 179,184 ---- indicator, leaves it set to that. The function always returns \NULL, so a wrapper function around a system call can write ! \samp{return PyErr_SetFromErrno(\var{type});} when the system call ! returns an error. \end{cfuncdesc} From tim_one@users.sourceforge.net Sat Mar 23 22:28:20 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 23 Mar 2002 14:28:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.8,2.9 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv27491/python/Objects Modified Files: obmalloc.c Log Message: Minor code cleanup -- no semantic changes. Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -d -r2.8 -r2.9 *** obmalloc.c 23 Mar 2002 10:03:50 -0000 2.8 --- obmalloc.c 23 Mar 2002 22:28:18 -0000 2.9 *************** *** 628,631 **** --- 628,632 ---- /*==========================================================================*/ /* pymalloc not enabled: Redirect the entry points to the PyMem family. */ + void * _PyMalloc_Malloc(size_t n) *************** *** 647,650 **** --- 648,656 ---- #endif /* WITH_PYMALLOC */ + /*==========================================================================*/ + /* Regardless of whether pymalloc is enabled, export entry points for + * the object-oriented pymalloc functions. + */ + PyObject * _PyMalloc_New(PyTypeObject *tp) *************** *** 676,680 **** #ifdef PYMALLOC_DEBUG /*==========================================================================*/ ! /* A x-platform debugging allocator. */ #define PYMALLOC_CLEANBYTE 0xCB /* uninitialized memory */ --- 682,688 ---- #ifdef PYMALLOC_DEBUG /*==========================================================================*/ ! /* A x-platform debugging allocator. This doesn't manage memory directly, ! * it wraps a real allocator, adding extra debugging info to the memory blocks. ! */ #define PYMALLOC_CLEANBYTE 0xCB /* uninitialized memory */ *************** *** 688,692 **** read4(const void *p) { ! const unsigned char *q = (unsigned char *)p; return ((ulong)q[0] << 24) | ((ulong)q[1] << 16) | --- 696,700 ---- read4(const void *p) { ! const uchar *q = (const uchar *)p; return ((ulong)q[0] << 24) | ((ulong)q[1] << 16) | *************** *** 700,708 **** write4(void *p, ulong n) { ! unsigned char *q = (unsigned char *)p; ! q[0] = (unsigned char)((n >> 24) & 0xff); ! q[1] = (unsigned char)((n >> 16) & 0xff); ! q[2] = (unsigned char)((n >> 8) & 0xff); ! q[3] = (unsigned char)( n & 0xff); } --- 708,716 ---- write4(void *p, ulong n) { ! uchar *q = (uchar *)p; ! q[0] = (uchar)((n >> 24) & 0xff); ! q[1] = (uchar)((n >> 16) & 0xff); ! q[2] = (uchar)((n >> 8) & 0xff); ! q[3] = (uchar)( n & 0xff); } *************** *** 759,763 **** { uchar *p; /* base address of malloc'ed block */ ! uchar *q; /* p + 8 + nbytes + */ size_t total; /* nbytes + 16 */ --- 767,771 ---- { uchar *p; /* base address of malloc'ed block */ ! uchar *tail; /* p + 8 + nbytes == pointer to tail pad bytes */ size_t total; /* nbytes + 16 */ *************** *** 786,800 **** memset(p+8, PYMALLOC_CLEANBYTE, nbytes); ! q = p + 8 + nbytes; ! q[0] = q[1] = q[2] = q[3] = PYMALLOC_FORBIDDENBYTE; ! write4(q+4, serialno); return p+8; } ! /* The debug free first uses the address to find the number of bytes ! originally asked for, then checks the 8 bytes on each end for ! sanity (in particular, that the PYMALLOC_FORBIDDENBYTEs are still ! intact). Then fills the original bytes with PYMALLOC_DEADBYTE. Then calls the underlying free. --- 794,806 ---- memset(p+8, PYMALLOC_CLEANBYTE, nbytes); ! tail = p + 8 + nbytes; ! tail[0] = tail[1] = tail[2] = tail[3] = PYMALLOC_FORBIDDENBYTE; ! write4(tail + 4, serialno); return p+8; } ! /* The debug free first checks the 8 bytes on each end for sanity (in ! particular, that the PYMALLOC_FORBIDDENBYTEs are still intact). Then fills the original bytes with PYMALLOC_DEADBYTE. Then calls the underlying free. *************** *** 803,807 **** _PyMalloc_DebugFree(void *p, int family) { ! uchar *q = (uchar*)p; size_t nbytes; --- 809,813 ---- _PyMalloc_DebugFree(void *p, int family) { ! uchar *q = (uchar *)p; size_t nbytes; *************** *** 915,923 **** the serial number (the address deref could blow up). */ ! fprintf(stderr, " the 3 pad bytes at p-3 are "); if (*(q-3) == PYMALLOC_FORBIDDENBYTE && *(q-2) == PYMALLOC_FORBIDDENBYTE && *(q-1) == PYMALLOC_FORBIDDENBYTE) { ! fprintf(stderr, "PYMALLOC_FORBIDDENBYTE, as expected\n"); } else { --- 921,929 ---- the serial number (the address deref could blow up). */ ! fputs(" the 3 pad bytes at p-3 are ", stderr); if (*(q-3) == PYMALLOC_FORBIDDENBYTE && *(q-2) == PYMALLOC_FORBIDDENBYTE && *(q-1) == PYMALLOC_FORBIDDENBYTE) { ! fputs("PYMALLOC_FORBIDDENBYTE, as expected\n", stderr); } else { *************** *** 940,944 **** tail[2] == PYMALLOC_FORBIDDENBYTE && tail[3] == PYMALLOC_FORBIDDENBYTE) { ! fprintf(stderr, "PYMALLOC_FORBIDDENBYTE, as expected\n"); } else { --- 946,950 ---- tail[2] == PYMALLOC_FORBIDDENBYTE && tail[3] == PYMALLOC_FORBIDDENBYTE) { ! fputs("PYMALLOC_FORBIDDENBYTE, as expected\n", stderr); } else { *************** *** 962,966 **** if (nbytes > 0) { int i = 0; ! fprintf(stderr, " data at p:"); /* print up to 8 bytes at the start */ while (q < tail && i < 8) { --- 968,972 ---- if (nbytes > 0) { int i = 0; ! fputs(" data at p:", stderr); /* print up to 8 bytes at the start */ while (q < tail && i < 8) { *************** *** 972,976 **** if (q < tail) { if (tail - q > 8) { ! fprintf(stderr, " ..."); q = tail - 8; } --- 978,982 ---- if (q < tail) { if (tail - q > 8) { ! fputs(" ...", stderr); q = tail - 8; } *************** *** 980,984 **** } } ! fprintf(stderr, "\n"); } } --- 986,990 ---- } } ! fputc('\n', stderr); } } From nascheme@users.sourceforge.net Sat Mar 23 23:44:53 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 23 Mar 2002 15:44:53 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib rlcompleter.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv11979/Lib Modified Files: rlcompleter.py Log Message: Add namespace selection for rlcompleter. Closes SF patch 490026. Index: rlcompleter.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/rlcompleter.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** rlcompleter.py 15 Feb 2001 22:15:13 -0000 1.9 --- rlcompleter.py 23 Mar 2002 23:44:51 -0000 1.10 *************** *** 1,8 **** """Word completion for GNU readline 2.0. ! This requires the latest extension to the readline module (the ! completes keywords, built-ins and globals in __main__; when completing ! NAME.NAME..., it evaluates (!) the expression up to the last dot and ! completes its attributes. It's very cool to do "import string" type "string.", hit the --- 1,8 ---- """Word completion for GNU readline 2.0. ! This requires the latest extension to the readline module. The completer ! completes keywords, built-ins and globals in a selectable namespace (which ! defaults to __main__); when completing NAME.NAME..., it evaluates (!) the ! expression up to the last dot and completes its attributes. It's very cool to do "import string" type "string.", hit the *************** *** 47,50 **** --- 47,76 ---- class Completer: + def __init__(self, namespace = None): + """Create a new completer for the command line. + + Completer([namespace]) -> completer instance. + + If unspecified, the default namespace where completions are performed + is __main__ (technically, __main__.__dict__). Namespaces should be + given as dictionaries. + + Completer instances should be used as the completion mechanism of + readline via the set_completer() call: + + readline.set_completer(Completer(my_namespace).complete) + """ + + if namespace and not isinstance(namespace, dict): + raise TypeError,'namespace must be a dictionary' + + # Don't bind to namespace quite yet, but flag whether the user wants a + # specific namespace or to use __main__.__dict__. This will allow us + # to bind to __main__.__dict__ at completion time, not now. + if namespace is None: + self.use_main_ns = 1 + else: + self.use_main_ns = 0 + self.namespace = namespace def complete(self, text, state): *************** *** 55,58 **** --- 81,87 ---- """ + if self.use_main_ns: + self.namespace = __main__.__dict__ + if state == 0: if "." in text: *************** *** 68,73 **** """Compute matches when text is a simple name. ! Return a list of all keywords, built-in functions and names ! currently defines in __main__ that match. """ --- 97,102 ---- """Compute matches when text is a simple name. ! Return a list of all keywords, built-in functions and names currently ! defined in self.namespace that match. """ *************** *** 77,81 **** for list in [keyword.kwlist, __builtin__.__dict__.keys(), ! __main__.__dict__.keys()]: for word in list: if word[:n] == text and word != "__builtins__": --- 106,110 ---- for list in [keyword.kwlist, __builtin__.__dict__.keys(), ! self.namespace.keys()]: for word in list: if word[:n] == text and word != "__builtins__": *************** *** 87,94 **** Assuming the text is of the form NAME.NAME....[NAME], and is ! evaluatable in the globals of __main__, it will be evaluated ! and its attributes (as revealed by dir()) are used as possible ! completions. (For class instances, class members are are also ! considered.) WARNING: this can still invoke arbitrary C code, if an object --- 116,122 ---- Assuming the text is of the form NAME.NAME....[NAME], and is ! evaluatable in self.namespace, it will be evaluated and its attributes ! (as revealed by dir()) are used as possible completions. (For class ! instances, class members are are also considered.) WARNING: this can still invoke arbitrary C code, if an object *************** *** 101,105 **** return expr, attr = m.group(1, 3) ! object = eval(expr, __main__.__dict__) words = dir(object) if hasattr(object,'__class__'): --- 129,133 ---- return expr, attr = m.group(1, 3) ! object = eval(expr, self.namespace) words = dir(object) if hasattr(object,'__class__'): From nascheme@users.sourceforge.net Sat Mar 23 23:51:06 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 23 Mar 2002 15:51:06 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib inspect.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv15457/Lib Modified Files: inspect.py Log Message: Use linecache for loading source code. Closes SF patch 490374. Index: inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** inspect.py 17 Mar 2002 18:56:20 -0000 1.28 --- inspect.py 23 Mar 2002 23:51:04 -0000 1.29 *************** *** 28,32 **** __date__ = '1 Jan 2001' ! import sys, os, types, string, re, dis, imp, tokenize # ----------------------------------------------------------- type-checking --- 28,32 ---- __date__ = '1 Jan 2001' ! import sys, os, types, string, re, dis, imp, tokenize, linecache # ----------------------------------------------------------- type-checking *************** *** 382,391 **** in the file and the line number indexes a line in that list. An IOError is raised if the source code cannot be retrieved.""" ! try: ! file = open(getsourcefile(object)) ! except (TypeError, IOError): raise IOError, 'could not get source code' - lines = file.readlines() - file.close() if ismodule(object): --- 382,389 ---- in the file and the line number indexes a line in that list. An IOError is raised if the source code cannot be retrieved.""" ! file = getsourcefile(object) or getfile(object) ! lines = linecache.getlines(file) ! if not lines: raise IOError, 'could not get source code' if ismodule(object): *************** *** 707,711 **** raise TypeError, 'arg is not a frame or traceback object' ! filename = getsourcefile(frame) lineno = getlineno(frame) if context > 0: --- 705,709 ---- raise TypeError, 'arg is not a frame or traceback object' ! filename = getsourcefile(frame) or getfile(frame) lineno = getlineno(frame) if context > 0: From tim_one@users.sourceforge.net Sun Mar 24 00:34:23 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 23 Mar 2002 16:34:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.9,2.10 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv23620/python/Objects Modified Files: obmalloc.c Log Message: _PyMalloc_DebugRealloc(): simplify decl of "fresh". Assorted: bump the serial number via a trivial new bumpserialno() function. The point is to give a single place to set a breakpoint when waiting for a specific serial number. Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.9 retrieving revision 2.10 diff -C2 -d -r2.9 -r2.10 *** obmalloc.c 23 Mar 2002 22:28:18 -0000 2.9 --- obmalloc.c 24 Mar 2002 00:34:21 -0000 2.10 *************** *** 692,695 **** --- 692,705 ---- static ulong serialno = 0; /* incremented on each debug {m,re}alloc */ + /* serialno is always incremented via calling this routine. The point is + to supply a single place to set a breakpoint. + */ + static void + bumpserialno() + { + ++serialno; + } + + /* Read 4 bytes at p as a big-endian ulong. */ static ulong *************** *** 772,776 **** assert(family == 0); ! ++serialno; total = nbytes + 16; if (total < nbytes || (total >> 31) > 1) { --- 782,786 ---- assert(family == 0); ! bumpserialno(); total = nbytes + 16; if (total < nbytes || (total >> 31) > 1) { *************** *** 829,833 **** uchar *q = (uchar *)p; size_t original_nbytes; ! uchar *fresh; /* new memory block, if needed */ assert(family == 0); --- 839,843 ---- uchar *q = (uchar *)p; size_t original_nbytes; ! void *fresh; /* new memory block, if needed */ assert(family == 0); *************** *** 843,847 **** /* note that this case is likely to be common due to the way Python appends to lists */ ! ++serialno; write4(q + nbytes + 4, serialno); return p; --- 853,857 ---- /* note that this case is likely to be common due to the way Python appends to lists */ ! bumpserialno(); write4(q + nbytes + 4, serialno); return p; *************** *** 852,856 **** fill the excess with DEADBYTE */ const size_t excess = original_nbytes - nbytes; ! ++serialno; write4(q-8, nbytes); /* kill the excess bytes plus the trailing 8 pad bytes */ --- 862,866 ---- fill the excess with DEADBYTE */ const size_t excess = original_nbytes - nbytes; ! bumpserialno(); write4(q-8, nbytes); /* kill the excess bytes plus the trailing 8 pad bytes */ *************** *** 864,868 **** /* More memory is needed: get it, copy over the first original_nbytes of the original data, and free the original memory. */ ! fresh = (uchar *)_PyMalloc_DebugMalloc(nbytes, family); if (fresh != NULL && original_nbytes > 0) memcpy(fresh, p, original_nbytes); --- 874,878 ---- /* More memory is needed: get it, copy over the first original_nbytes of the original data, and free the original memory. */ ! fresh = _PyMalloc_DebugMalloc(nbytes, family); if (fresh != NULL && original_nbytes > 0) memcpy(fresh, p, original_nbytes); From nascheme@users.sourceforge.net Sun Mar 24 01:09:07 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 23 Mar 2002 17:09:07 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules readline.c,2.44,2.45 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv30695/Modules Modified Files: readline.c Log Message: Add get_history_item, get_current_history_length, and redisplay functions. Clarify the docstring for get_history_length. Closes SF patch 494066. Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.44 retrieving revision 2.45 diff -C2 -d -r2.44 -r2.45 *** readline.c 3 Mar 2002 02:59:16 -0000 2.44 --- readline.c 24 Mar 2002 01:09:04 -0000 2.45 *************** *** 144,148 **** static char get_history_length_doc[] = "\ get_history_length() -> int\n\ ! return the current history length value.\n\ "; --- 144,149 ---- static char get_history_length_doc[] = "\ get_history_length() -> int\n\ ! return the maximum number of items that will be written to\n\ ! the history file.\n\ "; *************** *** 333,336 **** --- 334,378 ---- "; + /* Exported function to get any element of history */ + + static PyObject * + get_history_item(PyObject *self, PyObject *args) + { + int idx = 0; + HIST_ENTRY *hist_ent; + + if (!PyArg_ParseTuple(args, "i:index", &idx)) + return NULL; + if ((hist_ent = history_get(idx))) + return PyString_FromString(hist_ent->line); + else { + Py_INCREF(Py_None); + return Py_None; + } + } + + static char doc_get_history_item[] = "\ + get_history_item() -> string\n\ + return the current contents of history item at index.\ + "; + + /* Exported function to get current length of history */ + + static PyObject * + get_current_history_length(PyObject *self, PyObject *args) + { + HISTORY_STATE *hist_st; + + if (!PyArg_NoArgs(args)) + return NULL; + hist_st = history_get_history_state(); + return PyInt_FromLong(hist_st ? (long) hist_st->length : (long) 0); + } + + static char doc_get_current_history_length[] = "\ + get_current_history_length() -> integer\n\ + return the current (not the maximum) length of history.\ + "; + /* Exported function to read the current line buffer */ *************** *** 361,365 **** } - static char doc_insert_text[] = "\ insert_text(string) -> None\n\ --- 403,406 ---- *************** *** 367,370 **** --- 408,424 ---- "; + static PyObject * + redisplay(PyObject *self) + { + rl_redisplay(); + Py_INCREF(Py_None); + return Py_None; + } + + static char doc_redisplay[] = "\ + redisplay() -> None\n\ + Change what's displayed on the screen to reflect the current\n\ + contents of the line buffer.\ + "; /* Table of functions exported by the module */ *************** *** 376,379 **** --- 430,434 ---- METH_OLDARGS, doc_get_line_buffer}, {"insert_text", insert_text, METH_VARARGS, doc_insert_text}, + {"redisplay", (PyCFunction)redisplay, METH_NOARGS, doc_redisplay}, {"read_init_file", read_init_file, METH_VARARGS, doc_read_init_file}, {"read_history_file", read_history_file, *************** *** 381,384 **** --- 436,443 ---- {"write_history_file", write_history_file, METH_VARARGS, doc_write_history_file}, + {"get_history_item", get_history_item, + METH_VARARGS, doc_get_history_item}, + {"get_current_history_length", get_current_history_length, + METH_OLDARGS, doc_get_current_history_length}, {"set_history_length", set_history_length, METH_VARARGS, set_history_length_doc}, From nascheme@users.sourceforge.net Sun Mar 24 01:24:09 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 23 Mar 2002 17:24:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_types.py,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv422 Modified Files: test_types.py Log Message: Add more tests for built-in types. Add tests for buffer objects. Closes SF patch 494871. Index: test_types.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** test_types.py 20 Dec 2001 06:18:15 -0000 1.25 --- test_types.py 24 Mar 2002 01:24:07 -0000 1.26 *************** *** 50,53 **** --- 50,85 ---- else: raise TestFailed, 'identity test failed' + try: float('') + except ValueError: pass + else: raise TestFailed, "float('') didn't raise ValueError" + + try: float('5\0') + except ValueError: pass + else: raise TestFailed, "float('5\0') didn't raise ValueError" + + try: 5.0 / 0.0 + except ZeroDivisionError: pass + else: raise TestFailed, "5.0 / 0.0 didn't raise ZeroDivisionError" + + try: 5.0 // 0.0 + except ZeroDivisionError: pass + else: raise TestFailed, "5.0 // 0.0 didn't raise ZeroDivisionError" + + try: 5.0 % 0.0 + except ZeroDivisionError: pass + else: raise TestFailed, "5.0 % 0.0 didn't raise ZeroDivisionError" + + try: 5 / 0L + except ZeroDivisionError: pass + else: raise TestFailed, "5 / 0L didn't raise ZeroDivisionError" + + try: 5 // 0L + except ZeroDivisionError: pass + else: raise TestFailed, "5 // 0L didn't raise ZeroDivisionError" + + try: 5 % 0L + except ZeroDivisionError: pass + else: raise TestFailed, "5 % 0L didn't raise ZeroDivisionError" + print '6.4 Numeric types (mostly conversions)' if 0 != 0L or 0 != 0.0 or 0L != 0.0: raise TestFailed, 'mixed comparisons' *************** *** 117,120 **** --- 149,169 ---- except OverflowError: pass else:raise TestFailed, 'long op' + + try: 5 << -5 + except ValueError: pass + else: raise TestFailed, 'int negative shift <<' + + try: 5L << -5L + except ValueError: pass + else: raise TestFailed, 'long negative shift <<' + + try: 5 >> -5 + except ValueError: pass + else: raise TestFailed, 'int negative shift >>' + + try: 5L >> -5L + except ValueError: pass + else: raise TestFailed, 'long negative shift >>' + print '6.4.3 Floating point numbers' if 12.0 + 24.0 != 36.0: raise TestFailed, 'float op' *************** *** 150,153 **** --- 199,210 ---- 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' + try: ()[0] + except IndexError: pass + else: raise TestFailed, "tuple index error didn't raise IndexError" + x = () + x += () + if x != (): raise TestFailed, 'tuple inplace add from () to () failed' + x += (1,) + if x != (1,): raise TestFailed, 'tuple resize from () failed' print '6.5.3 Lists' *************** *** 175,178 **** --- 232,257 ---- if a != [1, 1, 2, 3, 4, 5, 5]: raise TestFailed, "list self-slice-assign (center)" + try: [][0] + except IndexError: pass + else: raise TestFailed, "list index error didn't raise IndexError" + try: [][0] = 5 + except IndexError: pass + else: raise TestFailed, "list assignment index error didn't raise IndexError" + try: [].pop() + except IndexError: pass + else: raise TestFailed, "empty list.pop() didn't raise IndexError" + try: [1].pop(5) + except IndexError: pass + else: raise TestFailed, "[1].pop(5) didn't raise IndexError" + try: [][0:1] = 5 + except TypeError: pass + else: raise TestFailed, "bad list slice assignment didn't raise TypeError" + try: [].extend(None) + except TypeError: pass + else: raise TestFailed, "list.extend(None) didn't raise TypeError" + a = [1, 2, 3, 4] + a *= 0 + if a != []: + raise TestFailed, "list inplace repeat" *************** *** 247,250 **** --- 326,331 ---- d = {} if d.keys() != []: raise TestFailed, '{}.keys()' + if d.values() != []: raise TestFailed, '{}.values()' + if d.items() != []: raise TestFailed, '{}.items()' if d.has_key('a') != 0: raise TestFailed, '{}.has_key(\'a\')' if ('a' in d) != 0: raise TestFailed, "'a' in {}" *************** *** 391,394 **** --- 472,489 ---- if b: raise TestFailed, 'b not empty after popitems: %s' % str(b) + d.clear() + try: d.popitem() + except KeyError: pass + else: raise TestFailed, "{}.popitem doesn't raise KeyError" + + d[1] = 1 + try: + for i in d: + d[i+1] = 1 + except RuntimeError: + pass + else: + raise TestFailed, "changing dict size during iteration doesn't raise Error" + try: type(1, 2) except TypeError: pass *************** *** 398,399 **** --- 493,517 ---- except TypeError: pass else: raise TestFailed, 'type(), w/4 args expected TypeError' + + print 'Buffers' + try: buffer('asdf', -1) + except ValueError: pass + else: raise TestFailed, "buffer('asdf', -1) should raise ValueError" + + try: buffer(None) + except TypeError: pass + else: raise TestFailed, "buffer(None) should raise TypeError" + + a = buffer('asdf') + hash(a) + b = a * 5 + if a == b: + raise TestFailed, 'buffers should not be equal' + + try: a[1] = 'g' + except TypeError: pass + else: raise TestFailed, "buffer assignment should raise TypeError" + + try: a[0:1] = 'g' + except TypeError: pass + else: raise TestFailed, "buffer slice assignment should raise TypeError" From nascheme@users.sourceforge.net Sun Mar 24 01:24:56 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 23 Mar 2002 17:24:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_types,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv575/output Modified Files: test_types Log Message: Add more tests for built-in types. Add tests for buffer objects. Closes SF patch 494871. Index: test_types =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_types,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_types 10 Dec 1996 23:20:09 -0000 1.1 --- test_types 24 Mar 2002 01:24:54 -0000 1.2 *************** *** 14,15 **** --- 14,16 ---- 6.5.3a Additional list operations 6.6 Mappings == Dictionaries + Buffers From nascheme@users.sourceforge.net Sun Mar 24 01:38:40 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sat, 23 Mar 2002 17:38:40 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib mailbox.py,1.34,1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv2571/Lib Modified Files: mailbox.py Log Message: Try /var/mail before trying /usr/mail. Most new systems use /var. This in inside the test so it really doesn't matter much. Closes SF patch 497097. Index: mailbox.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mailbox.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** mailbox.py 1 Mar 2002 22:39:14 -0000 1.34 --- mailbox.py 24 Mar 2002 01:38:38 -0000 1.35 *************** *** 277,281 **** mbox = os.environ['HOME'] + '/Mail/' + mbox[1:] elif not '/' in mbox: ! mbox = '/usr/mail/' + mbox if os.path.isdir(mbox): if os.path.isdir(os.path.join(mbox, 'cur')): --- 277,284 ---- mbox = os.environ['HOME'] + '/Mail/' + mbox[1:] elif not '/' in mbox: ! if os.path.isfile('/var/mail/' + mbox): ! mbox = '/var/mail/' + mbox ! else: ! mbox = '/usr/mail/' + mbox if os.path.isdir(mbox): if os.path.isdir(os.path.join(mbox, 'cur')): From nascheme@users.sourceforge.net Sun Mar 24 15:30:42 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sun, 24 Mar 2002 07:30:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib smtplib.py,1.48,1.49 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv5877/Lib Modified Files: smtplib.py Log Message: Add local_hostname option to SMTP.__init__. If supplied, it is used as the fully qualified local hostname. Index: smtplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** smtplib.py 24 Feb 2002 15:07:24 -0000 1.48 --- smtplib.py 24 Mar 2002 15:30:40 -0000 1.49 *************** *** 221,225 **** does_esmtp = 0 ! def __init__(self, host = '', port = 0): """Initialize a new instance. --- 221,225 ---- does_esmtp = 0 ! def __init__(self, host = '', port = 0, local_hostname = None): """Initialize a new instance. *************** *** 227,231 **** connect. If specified, `port' specifies the port to which to connect. By default, smtplib.SMTP_PORT is used. An SMTPConnectError is raised ! if the specified `host' doesn't respond correctly. """ --- 227,233 ---- connect. If specified, `port' specifies the port to which to connect. By default, smtplib.SMTP_PORT is used. An SMTPConnectError is raised ! if the specified `host' doesn't respond correctly. If specified, ! `local_hostname` is used as the FQDN of the local host. By default, ! the local hostname is found using gethostbyname(). """ *************** *** 235,238 **** --- 237,244 ---- if code != 220: raise SMTPConnectError(code, msg) + if local_hostname: + self.local_hostname = local_hostname + else: + self.local_hostname = socket.getfqdn() def set_debuglevel(self, debuglevel): *************** *** 357,364 **** host. """ ! if name: ! self.putcmd("helo", name) ! else: ! self.putcmd("helo", socket.getfqdn()) (code,msg)=self.getreply() self.helo_resp=msg --- 363,367 ---- host. """ ! self.putcmd("helo", name or self.local_hostname) (code,msg)=self.getreply() self.helo_resp=msg *************** *** 371,378 **** """ self.esmtp_features = {} ! if name: ! self.putcmd("ehlo", name) ! else: ! self.putcmd("ehlo", socket.getfqdn()) (code,msg)=self.getreply() # According to RFC1869 some (badly written) --- 374,378 ---- """ self.esmtp_features = {} ! self.putcmd("ehlo", name or self.local_hostname) (code,msg)=self.getreply() # According to RFC1869 some (badly written) From nascheme@users.sourceforge.net Sun Mar 24 15:41:42 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sun, 24 Mar 2002 07:41:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libsmtplib.tex,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv8752/lib Modified Files: libsmtplib.tex Log Message: Add local_hostname to SMTP.__init__(). Index: libsmtplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsmtplib.tex,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** libsmtplib.tex 20 Oct 2001 04:24:09 -0000 1.21 --- libsmtplib.tex 24 Mar 2002 15:41:40 -0000 1.22 *************** *** 15,19 **** (\citetitle{SMTP Service Extensions}). ! \begin{classdesc}{SMTP}{\optional{host\optional{, port}}} A \class{SMTP} instance encapsulates an SMTP connection. It has methods that support a full repertoire of SMTP and ESMTP --- 15,20 ---- (\citetitle{SMTP Service Extensions}). ! \begin{classdesc}{SMTP}{\optional{host\optional{, port\optional{, ! local_hostname}}}} A \class{SMTP} instance encapsulates an SMTP connection. It has methods that support a full repertoire of SMTP and ESMTP From montanaro@users.sourceforge.net Sun Mar 24 16:34:24 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Sun, 24 Mar 2002 08:34:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib cmd.py,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv23215 Modified Files: cmd.py Log Message: tighten up except - in this context, AttributeError is the only exception that can be raised - do_help won't be called if arg is not a string Index: cmd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cmd.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** cmd.py 23 Mar 2002 20:43:59 -0000 1.27 --- cmd.py 24 Mar 2002 16:34:21 -0000 1.28 *************** *** 215,219 **** try: func = getattr(self, 'help_' + arg) ! except: try: doc=getattr(self, 'do_' + arg).__doc__ --- 215,219 ---- try: func = getattr(self, 'help_' + arg) ! except AttributeError: try: doc=getattr(self, 'do_' + arg).__doc__ *************** *** 221,225 **** print doc return ! except: pass print self.nohelp % (arg,) --- 221,225 ---- print doc return ! except AttributeError: pass print self.nohelp % (arg,) From montanaro@users.sourceforge.net Sun Mar 24 16:53:52 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Sun, 24 Mar 2002 08:53:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib httplib.py,1.47,1.48 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv27725 Modified Files: httplib.py Log Message: add InvalidURL exception - raised if port is given but empty or non-numeric Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** httplib.py 18 Mar 2002 22:51:48 -0000 1.47 --- httplib.py 24 Mar 2002 16:53:50 -0000 1.48 *************** *** 348,352 **** i = host.find(':') if i >= 0: ! port = int(host[i+1:]) host = host[:i] else: --- 348,355 ---- i = host.find(':') if i >= 0: ! try: ! port = int(host[i+1:]) ! except ValueError: ! raise InvalidURL, "nonnumeric port: '%s'"%host[i+1:] host = host[:i] else: *************** *** 807,810 **** --- 810,816 ---- class NotConnected(HTTPException): + pass + + class InvalidURL(HTTPException): pass From montanaro@users.sourceforge.net Sun Mar 24 16:54:19 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Sun, 24 Mar 2002 08:54:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_httplib.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv27827 Modified Files: test_httplib.py Log Message: add test of InvalidURL Index: test_httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_httplib.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_httplib.py 25 Sep 2001 19:29:35 -0000 1.2 --- test_httplib.py 24 Mar 2002 16:54:16 -0000 1.3 *************** *** 30,31 **** --- 30,41 ---- else: print "Expect BadStatusLine" + + # Check invalid host_port + + for hp in ("www.python.org:abc", "www.python.org:"): + try: + h = httplib.HTTP(hp) + except httplib.InvalidURL: + print "InvalidURL raised as expected" + else: + print "Expect InvalidURL" From montanaro@users.sourceforge.net Sun Mar 24 16:54:40 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Sun, 24 Mar 2002 08:54:40 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_httplib,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv27898 Modified Files: test_httplib Log Message: add test for InvalidURL Index: test_httplib =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_httplib,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_httplib 13 Apr 2001 14:57:44 -0000 1.1 --- test_httplib 24 Mar 2002 16:54:38 -0000 1.2 *************** *** 4,5 **** --- 4,7 ---- reply: 'HTTP/1.1 400.100 Not Ok\r\n' BadStatusLine raised as expected + InvalidURL raised as expected + InvalidURL raised as expected From montanaro@users.sourceforge.net Sun Mar 24 16:55:59 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Sun, 24 Mar 2002 08:55:59 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libhttplib.tex,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv28128 Modified Files: libhttplib.tex Log Message: document InvalidURL exception Index: libhttplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libhttplib.tex,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** libhttplib.tex 26 Dec 2001 19:48:43 -0000 1.30 --- libhttplib.tex 24 Mar 2002 16:55:57 -0000 1.31 *************** *** 58,61 **** --- 58,66 ---- \end{excdesc} + \begin{excdesc}{InvalidURL} + A subclass of \exception{HTTPException}, raised if a port is given and is + either non-numeric or empty. + \end{excdesc} + \begin{excdesc}{UnknownProtocol} A subclass of \exception{HTTPException}. From montanaro@users.sourceforge.net Sun Mar 24 16:56:47 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Sun, 24 Mar 2002 08:56:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib httplib.py,1.48,1.49 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv28282 Modified Files: httplib.py Log Message: oops - export InvalidURL in __all__ Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** httplib.py 24 Mar 2002 16:53:50 -0000 1.48 --- httplib.py 24 Mar 2002 16:56:45 -0000 1.49 *************** *** 80,84 **** "HTTPException", "NotConnected", "UnknownProtocol", "UnknownTransferEncoding", "IllegalKeywordArgument", ! "UnimplementedFileMode", "IncompleteRead", "ImproperConnectionState", "CannotSendRequest", "CannotSendHeader", "ResponseNotReady", "BadStatusLine", "error"] --- 80,84 ---- "HTTPException", "NotConnected", "UnknownProtocol", "UnknownTransferEncoding", "IllegalKeywordArgument", ! "UnimplementedFileMode", "IncompleteRead", "InvalidURL", "ImproperConnectionState", "CannotSendRequest", "CannotSendHeader", "ResponseNotReady", "BadStatusLine", "error"] From tim_one@users.sourceforge.net Sun Mar 24 19:25:02 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 24 Mar 2002 11:25:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_softspace.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv28901/python/Lib/test Added Files: test_softspace.py Log Message: SF bug 480215: softspace confused in nested print This fixes the symptom, but PRINT_ITEM has no way to know what (if anything) PyFile_WriteObject() writes unless the object being printed is a string. When the object isn't a string, this fix retains the guess that softspace should be set after PyFile_WriteObject(). We might want to say that it's the job of filelike-object write methods to leave the file's softspace in the correct state. That would probably be better -- but everyone relies on PRINT_ITEM to guess for them now. --- NEW FILE: test_softspace.py --- import test_support import StringIO # SF bug 480215: softspace confused in nested print f = StringIO.StringIO() class C: def __str__(self): print >> f, 'a' return 'b' print >> f, C(), 'c ', 'd\t', 'e' print >> f, 'f', 'g' # In 2.2 & earlier, this printed ' a\nbc d\te\nf g\n' test_support.vereq(f.getvalue(), 'a\nb c d\te\nf g\n') From tim_one@users.sourceforge.net Sun Mar 24 19:25:02 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 24 Mar 2002 11:25:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python ceval.c,2.307,2.308 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv28901/python/Python Modified Files: ceval.c Log Message: SF bug 480215: softspace confused in nested print This fixes the symptom, but PRINT_ITEM has no way to know what (if anything) PyFile_WriteObject() writes unless the object being printed is a string. When the object isn't a string, this fix retains the guess that softspace should be set after PyFile_WriteObject(). We might want to say that it's the job of filelike-object write methods to leave the file's softspace in the correct state. That would probably be better -- but everyone relies on PRINT_ITEM to guess for them now. Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.307 retrieving revision 2.308 diff -C2 -d -r2.307 -r2.308 *** ceval.c 22 Mar 2002 23:53:16 -0000 2.307 --- ceval.c 24 Mar 2002 19:25:00 -0000 2.308 *************** *** 1398,1414 **** } } ! if (w != NULL && PyFile_SoftSpace(w, 1)) err = PyFile_WriteString(" ", w); if (err == 0) err = PyFile_WriteObject(v, w, Py_PRINT_RAW); if (err == 0) { ! /* XXX move into writeobject() ? */ if (PyString_Check(v)) { char *s = PyString_AS_STRING(v); int len = PyString_GET_SIZE(v); ! if (len > 0 && ! isspace(Py_CHARMASK(s[len-1])) && ! s[len-1] != ' ') ! PyFile_SoftSpace(w, 0); } #ifdef Py_USING_UNICODE --- 1398,1414 ---- } } ! if (w != NULL && PyFile_SoftSpace(w, 0)) err = PyFile_WriteString(" ", w); if (err == 0) err = PyFile_WriteObject(v, w, Py_PRINT_RAW); if (err == 0) { ! /* XXX move into writeobject() ? */ if (PyString_Check(v)) { char *s = PyString_AS_STRING(v); int len = PyString_GET_SIZE(v); ! if (len == 0 || ! !isspace(Py_CHARMASK(s[len-1])) || ! s[len-1] == ' ') ! PyFile_SoftSpace(w, 1); } #ifdef Py_USING_UNICODE *************** *** 1416,1424 **** Py_UNICODE *s = PyUnicode_AS_UNICODE(v); int len = PyUnicode_GET_SIZE(v); ! if (len > 0 && ! Py_UNICODE_ISSPACE(s[len-1]) && ! s[len-1] != ' ') ! PyFile_SoftSpace(w, 0); } #endif } --- 1416,1426 ---- Py_UNICODE *s = PyUnicode_AS_UNICODE(v); int len = PyUnicode_GET_SIZE(v); ! if (len == 0 || ! !Py_UNICODE_ISSPACE(s[len-1]) || ! s[len-1] == ' ') ! PyFile_SoftSpace(w, 1); } + else + PyFile_SoftSpace(w, 1); #endif } From montanaro@users.sourceforge.net Sun Mar 24 20:48:28 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Sun, 24 Mar 2002 12:48:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib popen2.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv16489 Modified Files: popen2.py Log Message: tighten up except - os.close only raises OSError see bug 411881 Index: popen2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/popen2.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** popen2.py 12 Mar 2002 19:48:03 -0000 1.23 --- popen2.py 24 Mar 2002 20:48:26 -0000 1.24 *************** *** 63,67 **** try: os.close(i) ! except: pass try: --- 63,67 ---- try: os.close(i) ! except OSError: pass try: From nascheme@users.sourceforge.net Sun Mar 24 22:21:50 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sun, 24 Mar 2002 14:21:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib tempfile.py,1.37,1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv5994/Lib Modified Files: tempfile.py Log Message: If possible, set FD_CLOEXEC flag on file descriptors opened using TemporaryFile. This flag causes the fd to be closed on exec(). Index: tempfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tempfile.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** tempfile.py 30 Jan 2002 09:11:42 -0000 1.37 --- tempfile.py 24 Mar 2002 22:21:48 -0000 1.38 *************** *** 181,184 **** --- 181,195 ---- return a + try: + import fcntl as _fcntl + def _set_cloexec(fd, flag=_fcntl.FD_CLOEXEC): + flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0) + if flags >= 0: + # flags read successfully, modify + flags |= flag + _fcntl.fcntl(fd, _fcntl.F_SETFD, flags) + except (ImportError, AttributeError): + def _set_cloexec(fd): + pass def TemporaryFile(mode='w+b', bufsize=-1, suffix=""): *************** *** 188,191 **** --- 199,203 ---- # Unix -- be very careful fd = os.open(name, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700) + _set_cloexec(fd) try: os.unlink(name) From nascheme@users.sourceforge.net Sun Mar 24 22:27:41 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sun, 24 Mar 2002 14:27:41 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules resource.c,2.22,2.23 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv7635/Modules Modified Files: resource.c Log Message: Expose RLIM_INFINITY constant. Closes SF patch 489066. Index: resource.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/resource.c,v retrieving revision 2.22 retrieving revision 2.23 diff -C2 -d -r2.22 -r2.23 *** resource.c 14 Feb 2002 06:59:26 -0000 2.22 --- resource.c 24 Mar 2002 22:27:39 -0000 2.23 *************** *** 161,165 **** initresource(void) { ! PyObject *m; /* Create the module and add the functions */ --- 161,165 ---- initresource(void) { ! PyObject *m, *v; /* Create the module and add the functions */ *************** *** 234,236 **** --- 234,248 ---- PyModule_AddIntConstant(m, "RUSAGE_BOTH", RUSAGE_BOTH); #endif + + #if defined(HAVE_LONG_LONG) + if (sizeof(RLIM_INFINITY) > sizeof(long)) { + v = PyLong_FromLongLong((LONG_LONG) RLIM_INFINITY); + } else + #endif + { + v = PyInt_FromLong((long) RLIM_INFINITY); + } + if (v) { + PyModule_AddObject(m, "RLIM_INFINITY", v); + } } From jackjansen@users.sourceforge.net Sun Mar 24 22:59:26 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 14:59:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/scripts genpluginprojects.py,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/scripts In directory usw-pr-cvs1:/tmp/cvs-serv5589/Python/Mac/scripts Modified Files: genpluginprojects.py Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Index: genpluginprojects.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/scripts/genpluginprojects.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** genpluginprojects.py 22 Mar 2002 14:15:07 -0000 1.29 --- genpluginprojects.py 24 Mar 2002 22:59:16 -0000 1.30 *************** *** 133,141 **** # bgen-generated Toolbox modules genpluginproject("carbon", "_AE", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_AE", libraries=["ObjectSupportLib"], outputdir="::Lib:Carbon") genpluginproject("ppc", "_App", libraries=["CarbonAccessors.o", "AppearanceLib"], libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("carbon", "_App", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Cm", libraries=["QuickTimeLib"], outputdir="::Lib:Carbon") genpluginproject("carbon", "_Cm", outputdir="::Lib:Carbon") # XXX can't work properly because we need to set a custom fragment initializer --- 133,143 ---- # bgen-generated Toolbox modules genpluginproject("carbon", "_AE", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_AE", libraries=["ObjectSupportLib"], ! stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("ppc", "_App", libraries=["CarbonAccessors.o", "AppearanceLib"], libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("carbon", "_App", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Cm", libraries=["QuickTimeLib"], ! stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("carbon", "_Cm", outputdir="::Lib:Carbon") # XXX can't work properly because we need to set a custom fragment initializer *************** *** 151,159 **** libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("carbon", "_Drag", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Drag", libraries=["DragLib"], outputdir="::Lib:Carbon") ! genpluginproject("all", "_Evt", outputdir="::Lib:Carbon") ! genpluginproject("all", "_Fm", outputdir="::Lib:Carbon") genpluginproject("ppc", "_Help", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Icn", libraries=["IconServicesLib"], outputdir="::Lib:Carbon") genpluginproject("carbon", "_Icn", outputdir="::Lib:Carbon") genpluginproject("all", "_List", outputdir="::Lib:Carbon") --- 153,165 ---- libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("carbon", "_Drag", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Drag", libraries=["DragLib"], ! libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") ! genpluginproject("all", "_Evt", ! stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") ! genpluginproject("all", "_Fm", ! stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("ppc", "_Help", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Icn", libraries=["IconServicesLib"], ! libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("carbon", "_Icn", outputdir="::Lib:Carbon") genpluginproject("all", "_List", outputdir="::Lib:Carbon") *************** *** 161,168 **** genpluginproject("ppc", "_Menu", libraries=["CarbonAccessors.o", "MenusLib", "ContextualMenu", "AppearanceLib"], libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") ! genpluginproject("all", "_Qd", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Qt", libraries=["QuickTimeLib"], outputdir="::Lib:Carbon") ! genpluginproject("carbon", "_Qt", outputdir="::Lib:Carbon") ! genpluginproject("all", "_Qdoffs", outputdir="::Lib:Carbon") genpluginproject("all", "_Res", stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") --- 167,178 ---- genpluginproject("ppc", "_Menu", libraries=["CarbonAccessors.o", "MenusLib", "ContextualMenu", "AppearanceLib"], libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") ! genpluginproject("all", "_Qd", ! stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Qt", libraries=["QuickTimeLib"], ! libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") ! genpluginproject("carbon", "_Qt", ! libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") ! genpluginproject("all", "_Qdoffs", ! stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("all", "_Res", stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") *************** *** 171,177 **** genpluginproject("carbon", "_Snd", outputdir="::Lib:Carbon") genpluginproject("all", "_Sndihooks", sources=[":snd:_Sndihooks.c"], outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_TE", libraries=["CarbonAccessors.o", "DragLib"], outputdir="::Lib:Carbon") genpluginproject("carbon", "_TE", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Mlte", libraries=["Textension"], outputdir="::Lib:Carbon") genpluginproject("carbon", "_Mlte", outputdir="::Lib:Carbon") genpluginproject("carbon", "_Win", outputdir="::Lib:Carbon") --- 181,190 ---- genpluginproject("carbon", "_Snd", outputdir="::Lib:Carbon") genpluginproject("all", "_Sndihooks", sources=[":snd:_Sndihooks.c"], outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_TE", libraries=["CarbonAccessors.o", "DragLib"], ! stdlibraryflags="Debug, WeakImport", ! libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("carbon", "_TE", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Mlte", libraries=["Textension"], ! libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("carbon", "_Mlte", outputdir="::Lib:Carbon") genpluginproject("carbon", "_Win", outputdir="::Lib:Carbon") From jackjansen@users.sourceforge.net Sun Mar 24 23:01:46 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 15:01:46 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/cf cfscan.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory usw-pr-cvs1:/tmp/cvs-serv19607/Python/Mac/Modules/cf Modified Files: cfscan.py Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: cfscan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/cfscan.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** cfscan.py 1 Jan 2002 22:42:51 -0000 1.6 --- cfscan.py 24 Mar 2002 23:01:44 -0000 1.7 *************** *** 96,99 **** --- 96,100 ---- "CFStringSetExternalCharactersNoCopy", "CFStringGetCharacterAtIndex", # No format for single unichars yet. + "kCFStringEncodingInvalidId", # incompatible constant declaration ] From jackjansen@users.sourceforge.net Sun Mar 24 23:01:18 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 15:01:18 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/win winscan.py,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/win In directory usw-pr-cvs1:/tmp/cvs-serv16135/Python/Mac/Modules/win Modified Files: winscan.py Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: winscan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/win/winscan.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** winscan.py 18 Dec 2001 15:38:54 -0000 1.19 --- winscan.py 24 Mar 2002 23:01:16 -0000 1.20 *************** *** 33,36 **** --- 33,38 ---- def writeinitialdefs(self): self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") + self.defsfile.write("false = 0\n") + self.defsfile.write("true = 1\n") def makeblacklistnames(self): From jackjansen@users.sourceforge.net Sun Mar 24 23:01:32 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 15:01:32 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/waste wastescan.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/waste In directory usw-pr-cvs1:/tmp/cvs-serv17938/Python/Mac/Modules/waste Modified Files: wastescan.py Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: wastescan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/waste/wastescan.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** wastescan.py 11 Jan 2002 12:37:07 -0000 1.8 --- wastescan.py 24 Mar 2002 23:01:30 -0000 1.9 *************** *** 49,52 **** --- 49,54 ---- def writeinitialdefs(self): self.defsfile.write("kPascalStackBased = None # workaround for header parsing\n") + self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") + def makeblacklistnames(self): return [ *************** *** 57,60 **** --- 59,78 ---- "WEPut", # XXXX TBD: needs array of flavortypes. "WEGetOneAttribute", # XXXX TBD: output buffer + # Incompatible constant definitions + "weDoAutoScroll", + "weDoOutlineHilite", + "weDoReadOnly", + "weDoUndo", + "weDoIntCutAndPaste", + "weDoDragAndDrop", + "weDoInhibitRecal", + "weDoUseTempMem", + "weDoDrawOffscreen", + "weDoInhibitRedraw", + "weDoMonoStyled", + "weDoMultipleUndo", + "weDoNoKeyboardSync", + "weDoInhibitICSupport", + "weDoInhibitColor", ] From jackjansen@users.sourceforge.net Sun Mar 24 23:01:53 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 15:01:53 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/app _Appmodule.c,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/app In directory usw-pr-cvs1:/tmp/cvs-serv20099/Python/Mac/Modules/app Modified Files: _Appmodule.c Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _Appmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/app/_Appmodule.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** _Appmodule.c 6 Jan 2002 23:03:39 -0000 1.9 --- _Appmodule.c 24 Mar 2002 23:01:51 -0000 1.10 *************** *** 78,81 **** --- 78,84 ---- OSStatus _rv; Boolean inDisposeNow; + #ifndef SetThemeDrawingState + PyMac_PRECHECK(SetThemeDrawingState); + #endif if (!PyArg_ParseTuple(_args, "b", &inDisposeNow)) *************** *** 92,95 **** --- 95,101 ---- PyObject *_res = NULL; OSStatus _rv; + #ifndef DisposeThemeDrawingState + PyMac_PRECHECK(DisposeThemeDrawingState); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 149,152 **** --- 155,161 ---- PyObject *_res = NULL; OSStatus _err; + #ifndef RegisterAppearanceClient + PyMac_PRECHECK(RegisterAppearanceClient); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 162,165 **** --- 171,177 ---- PyObject *_res = NULL; OSStatus _err; + #ifndef UnregisterAppearanceClient + PyMac_PRECHECK(UnregisterAppearanceClient); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 178,181 **** --- 190,196 ---- SInt16 inDepth; Boolean inIsColorDevice; + #ifndef SetThemePen + PyMac_PRECHECK(SetThemePen); + #endif if (!PyArg_ParseTuple(_args, "hhb", &inBrush, *************** *** 199,202 **** --- 214,220 ---- SInt16 inDepth; Boolean inIsColorDevice; + #ifndef SetThemeBackground + PyMac_PRECHECK(SetThemeBackground); + #endif if (!PyArg_ParseTuple(_args, "hhb", &inBrush, *************** *** 220,223 **** --- 238,244 ---- SInt16 inDepth; Boolean inIsColorDevice; + #ifndef SetThemeTextColor + PyMac_PRECHECK(SetThemeTextColor); + #endif if (!PyArg_ParseTuple(_args, "hhb", &inColor, *************** *** 241,244 **** --- 262,268 ---- ThemeBrush inBrush; Boolean inUpdate; + #ifndef SetThemeWindowBackground + PyMac_PRECHECK(SetThemeWindowBackground); + #endif if (!PyArg_ParseTuple(_args, "O&hb", WinObj_Convert, &inWindow, *************** *** 261,264 **** --- 285,291 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemeWindowHeader + PyMac_PRECHECK(DrawThemeWindowHeader); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 279,282 **** --- 306,312 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemeWindowListViewHeader + PyMac_PRECHECK(DrawThemeWindowListViewHeader); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 297,300 **** --- 327,333 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemePlacard + PyMac_PRECHECK(DrawThemePlacard); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 315,318 **** --- 348,354 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemeEditTextFrame + PyMac_PRECHECK(DrawThemeEditTextFrame); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 333,336 **** --- 369,375 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemeListBoxFrame + PyMac_PRECHECK(DrawThemeListBoxFrame); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 351,354 **** --- 390,396 ---- Rect inRect; Boolean inHasFocus; + #ifndef DrawThemeFocusRect + PyMac_PRECHECK(DrawThemeFocusRect); + #endif if (!PyArg_ParseTuple(_args, "O&b", PyMac_GetRect, &inRect, *************** *** 369,372 **** --- 411,417 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemePrimaryGroup + PyMac_PRECHECK(DrawThemePrimaryGroup); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 387,390 **** --- 432,438 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemeSecondaryGroup + PyMac_PRECHECK(DrawThemeSecondaryGroup); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 405,408 **** --- 453,459 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemeSeparator + PyMac_PRECHECK(DrawThemeSeparator); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 423,426 **** --- 474,480 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemeModelessDialogFrame + PyMac_PRECHECK(DrawThemeModelessDialogFrame); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 442,445 **** --- 496,502 ---- ThemeDrawState inState; Boolean inFillCenter; + #ifndef DrawThemeGenericWell + PyMac_PRECHECK(DrawThemeGenericWell); + #endif if (!PyArg_ParseTuple(_args, "O&lb", PyMac_GetRect, &inRect, *************** *** 461,464 **** --- 518,524 ---- OSStatus _err; Boolean inHasFocus; + #ifndef DrawThemeFocusRegion + PyMac_PRECHECK(DrawThemeFocusRegion); + #endif if (!PyArg_ParseTuple(_args, "b", &inHasFocus)) *************** *** 478,481 **** --- 538,544 ---- SInt16 inDepth; Boolean inIsColorDevice; + #ifndef IsThemeInColor + PyMac_PRECHECK(IsThemeInColor); + #endif if (!PyArg_ParseTuple(_args, "hb", &inDepth, *************** *** 494,497 **** --- 557,563 ---- OSStatus _err; CTabHandle outColors; + #ifndef GetThemeAccentColors + PyMac_PRECHECK(GetThemeAccentColors); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 510,513 **** --- 576,582 ---- ThemeMenuBarState inState; UInt32 inAttributes; + #ifndef DrawThemeMenuBarBackground + PyMac_PRECHECK(DrawThemeMenuBarBackground); + #endif if (!PyArg_ParseTuple(_args, "O&Hl", PyMac_GetRect, &inBounds, *************** *** 529,532 **** --- 598,604 ---- OSStatus _err; SInt16 outHeight; + #ifndef GetThemeMenuBarHeight + PyMac_PRECHECK(GetThemeMenuBarHeight); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 544,547 **** --- 616,622 ---- Rect inMenuRect; ThemeMenuType inMenuType; + #ifndef DrawThemeMenuBackground + PyMac_PRECHECK(DrawThemeMenuBackground); + #endif if (!PyArg_ParseTuple(_args, "O&H", PyMac_GetRect, &inMenuRect, *************** *** 562,565 **** --- 637,643 ---- Rect inMenuRect; ThemeMenuType menuType; + #ifndef GetThemeMenuBackgroundRegion + PyMac_PRECHECK(GetThemeMenuBackgroundRegion); + #endif if (!PyArg_ParseTuple(_args, "O&H", PyMac_GetRect, &inMenuRect, *************** *** 580,583 **** --- 658,664 ---- OSStatus _err; Rect inItemRect; + #ifndef DrawThemeMenuSeparator + PyMac_PRECHECK(DrawThemeMenuSeparator); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetRect, &inItemRect)) *************** *** 595,598 **** --- 676,682 ---- OSStatus _err; SInt16 outHeight; + #ifndef GetThemeMenuSeparatorHeight + PyMac_PRECHECK(GetThemeMenuSeparatorHeight); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 611,614 **** --- 695,701 ---- SInt16 outHeight; SInt16 outWidth; + #ifndef GetThemeMenuItemExtra + PyMac_PRECHECK(GetThemeMenuItemExtra); + #endif if (!PyArg_ParseTuple(_args, "H", &inItemType)) *************** *** 630,633 **** --- 717,723 ---- SInt16 outWidth; Boolean inIsSquished; + #ifndef GetThemeMenuTitleExtra + PyMac_PRECHECK(GetThemeMenuTitleExtra); + #endif if (!PyArg_ParseTuple(_args, "b", &inIsSquished)) *************** *** 647,650 **** --- 737,743 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemeTabPane + PyMac_PRECHECK(DrawThemeTabPane); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 666,669 **** --- 759,765 ---- ThemeTabStyle inStyle; ThemeTabDirection inDirection; + #ifndef GetThemeTabRegion + PyMac_PRECHECK(GetThemeTabRegion); + #endif if (!PyArg_ParseTuple(_args, "O&HH", PyMac_GetRect, &inRect, *************** *** 686,689 **** --- 782,788 ---- OSStatus _err; ThemeCursor inCursor; + #ifndef SetThemeCursor + PyMac_PRECHECK(SetThemeCursor); + #endif if (!PyArg_ParseTuple(_args, "l", &inCursor)) *************** *** 702,705 **** --- 801,807 ---- ThemeCursor inCursor; UInt32 inAnimationStep; + #ifndef SetAnimatedThemeCursor + PyMac_PRECHECK(SetAnimatedThemeCursor); + #endif if (!PyArg_ParseTuple(_args, "ll", &inCursor, *************** *** 719,722 **** --- 821,827 ---- OSStatus _err; ThemeScrollBarThumbStyle outStyle; + #ifndef GetThemeScrollBarThumbStyle + PyMac_PRECHECK(GetThemeScrollBarThumbStyle); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 733,736 **** --- 838,844 ---- OSStatus _err; ThemeScrollBarArrowStyle outStyle; + #ifndef GetThemeScrollBarArrowStyle + PyMac_PRECHECK(GetThemeScrollBarArrowStyle); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 747,750 **** --- 855,861 ---- OSStatus _err; ThemeCheckBoxStyle outStyle; + #ifndef GetThemeCheckBoxStyle + PyMac_PRECHECK(GetThemeCheckBoxStyle); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 762,765 **** --- 873,879 ---- ThemeFontID inFontID; ScriptCode inScript; + #ifndef UseThemeFont + PyMac_PRECHECK(UseThemeFont); + #endif if (!PyArg_ParseTuple(_args, "Hh", &inFontID, *************** *** 786,789 **** --- 900,906 ---- Rect inBoundingBox; SInt16 inJust; + #ifndef DrawThemeTextBox + PyMac_PRECHECK(DrawThemeTextBox); + #endif if (!PyArg_ParseTuple(_args, "O&HlbO&h", CFStringRefObj_Convert, &inString, *************** *** 820,823 **** --- 937,943 ---- TruncCode inTruncWhere; Boolean outTruncated; + #ifndef TruncateThemeText + PyMac_PRECHECK(TruncateThemeText); + #endif if (!PyArg_ParseTuple(_args, "O&Hlhh", CFMutableStringRefObj_Convert, &inString, *************** *** 852,855 **** --- 972,978 ---- Point ioBounds; SInt16 outBaseline; + #ifndef GetThemeTextDimensions + PyMac_PRECHECK(GetThemeTextDimensions); + #endif if (!PyArg_ParseTuple(_args, "O&HlbO&", CFStringRefObj_Convert, &inString, *************** *** 882,885 **** --- 1005,1011 ---- ThemeDrawState inState; Rect outOutset; + #ifndef GetThemeTextShadowOutset + PyMac_PRECHECK(GetThemeTextShadowOutset); + #endif if (!PyArg_ParseTuple(_args, "Hl", &inFontID, *************** *** 905,908 **** --- 1031,1037 ---- Boolean isHoriz; Rect trackBounds; + #ifndef DrawThemeScrollBarArrows + PyMac_PRECHECK(DrawThemeScrollBarArrows); + #endif if (!PyArg_ParseTuple(_args, "O&bbb", PyMac_GetRect, &bounds, *************** *** 931,934 **** --- 1060,1066 ---- Boolean isHoriz; Rect trackBounds; + #ifndef GetThemeScrollBarTrackRect + PyMac_PRECHECK(GetThemeScrollBarTrackRect); + #endif if (!PyArg_ParseTuple(_args, "O&bbb", PyMac_GetRect, &bounds, *************** *** 959,962 **** --- 1091,1097 ---- Rect trackBounds; ControlPartCode partcode; + #ifndef HitTestThemeScrollBarArrows + PyMac_PRECHECK(HitTestThemeScrollBarArrows); + #endif if (!PyArg_ParseTuple(_args, "O&bbbO&", PyMac_GetRect, &scrollBarBounds, *************** *** 988,991 **** --- 1123,1129 ---- ThemeDrawState state; ThemeWindowAttributes attributes; + #ifndef DrawThemeScrollBarDelimiters + PyMac_PRECHECK(DrawThemeScrollBarDelimiters); + #endif if (!PyArg_ParseTuple(_args, "HO&ll", &flavor, *************** *** 1013,1016 **** --- 1151,1157 ---- ThemeButtonDrawInfo inPrevInfo; UInt32 inUserData; + #ifndef DrawThemeButton + PyMac_PRECHECK(DrawThemeButton); + #endif if (!PyArg_ParseTuple(_args, "O&HO&O&l", PyMac_GetRect, &inBounds, *************** *** 1040,1043 **** --- 1181,1187 ---- UInt16 inKind; ThemeButtonDrawInfo inNewInfo; + #ifndef GetThemeButtonRegion + PyMac_PRECHECK(GetThemeButtonRegion); + #endif if (!PyArg_ParseTuple(_args, "O&HO&", PyMac_GetRect, &inBounds, *************** *** 1063,1066 **** --- 1207,1213 ---- ThemeButtonDrawInfo inDrawInfo; Rect outBounds; + #ifndef GetThemeButtonContentBounds + PyMac_PRECHECK(GetThemeButtonContentBounds); + #endif if (!PyArg_ParseTuple(_args, "O&HO&", PyMac_GetRect, &inBounds, *************** *** 1086,1089 **** --- 1233,1239 ---- ThemeButtonDrawInfo inDrawInfo; Rect outBounds; + #ifndef GetThemeButtonBackgroundBounds + PyMac_PRECHECK(GetThemeButtonBackgroundBounds); + #endif if (!PyArg_ParseTuple(_args, "O&HO&", PyMac_GetRect, &inBounds, *************** *** 1106,1109 **** --- 1256,1262 ---- OSStatus _err; ThemeSoundKind kind; + #ifndef PlayThemeSound + PyMac_PRECHECK(PlayThemeSound); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &kind)) *************** *** 1121,1124 **** --- 1274,1280 ---- OSStatus _err; ThemeDragSoundKind kind; + #ifndef BeginThemeDragSound + PyMac_PRECHECK(BeginThemeDragSound); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &kind)) *************** *** 1135,1138 **** --- 1291,1297 ---- PyObject *_res = NULL; OSStatus _err; + #ifndef EndThemeDragSound + PyMac_PRECHECK(EndThemeDragSound); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 1150,1153 **** --- 1309,1315 ---- Rect bounds; ThemeDrawState state; + #ifndef DrawThemeTickMark + PyMac_PRECHECK(DrawThemeTickMark); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &bounds, *************** *** 1170,1173 **** --- 1332,1338 ---- ThemeDrawState state; UInt32 eraseData; + #ifndef DrawThemeChasingArrows + PyMac_PRECHECK(DrawThemeChasingArrows); + #endif if (!PyArg_ParseTuple(_args, "O&lll", PyMac_GetRect, &bounds, *************** *** 1196,1199 **** --- 1361,1367 ---- ThemeDrawState state; UInt32 eraseData; + #ifndef DrawThemePopupArrow + PyMac_PRECHECK(DrawThemePopupArrow); + #endif if (!PyArg_ParseTuple(_args, "O&HHll", PyMac_GetRect, &bounds, *************** *** 1223,1226 **** --- 1391,1397 ---- Boolean isSmall; ThemeDrawState state; + #ifndef DrawThemeStandaloneGrowBox + PyMac_PRECHECK(DrawThemeStandaloneGrowBox); + #endif if (!PyArg_ParseTuple(_args, "O&Hbl", PyMac_GetPoint, &origin, *************** *** 1247,1250 **** --- 1418,1424 ---- Boolean isSmall; ThemeDrawState state; + #ifndef DrawThemeStandaloneNoGrowBox + PyMac_PRECHECK(DrawThemeStandaloneNoGrowBox); + #endif if (!PyArg_ParseTuple(_args, "O&Hbl", PyMac_GetPoint, &origin, *************** *** 1271,1274 **** --- 1445,1451 ---- Boolean isSmall; Rect bounds; + #ifndef GetThemeStandaloneGrowBoxBounds + PyMac_PRECHECK(GetThemeStandaloneGrowBoxBounds); + #endif if (!PyArg_ParseTuple(_args, "O&Hb", PyMac_GetPoint, &origin, *************** *** 1290,1293 **** --- 1467,1473 ---- PyObject *_res = NULL; OSStatus _err; + #ifndef NormalizeThemeDrawingState + PyMac_PRECHECK(NormalizeThemeDrawingState); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 1304,1307 **** --- 1484,1490 ---- OSStatus _err; ThemeDrawingState outState; + #ifndef GetThemeDrawingState + PyMac_PRECHECK(GetThemeDrawingState); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 1322,1325 **** --- 1505,1511 ---- SInt16 inDepth; Boolean inColorDev; + #ifndef ApplyThemeBackground + PyMac_PRECHECK(ApplyThemeBackground); + #endif if (!PyArg_ParseTuple(_args, "lO&lhb", &inKind, *************** *** 1348,1351 **** --- 1534,1540 ---- SInt16 depth; Boolean isColorDev; + #ifndef SetThemeTextColorForWindow + PyMac_PRECHECK(SetThemeTextColorForWindow); + #endif if (!PyArg_ParseTuple(_args, "O&bhb", WinObj_Convert, &window, *************** *** 1369,1372 **** --- 1558,1564 ---- Boolean _rv; OSType fileType; + #ifndef IsValidAppearanceFileType + PyMac_PRECHECK(IsValidAppearanceFileType); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &fileType)) *************** *** 1386,1389 **** --- 1578,1584 ---- Boolean inColorDev; RGBColor outColor; + #ifndef GetThemeBrushAsColor + PyMac_PRECHECK(GetThemeBrushAsColor); + #endif if (!PyArg_ParseTuple(_args, "hhb", &inBrush, *************** *** 1409,1412 **** --- 1604,1610 ---- Boolean inColorDev; RGBColor outColor; + #ifndef GetThemeTextColor + PyMac_PRECHECK(GetThemeTextColor); + #endif if (!PyArg_ParseTuple(_args, "hhb", &inColor, *************** *** 1432,1435 **** --- 1630,1636 ---- ThemeMetric inMetric; SInt32 outMetric; + #ifndef GetThemeMetric + PyMac_PRECHECK(GetThemeMetric); + #endif if (!PyArg_ParseTuple(_args, "l", &inMetric)) From jackjansen@users.sourceforge.net Sun Mar 24 23:01:57 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 15:01:57 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/app appsupport.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/app In directory usw-pr-cvs1:/tmp/cvs-serv20713/Python/Mac/Modules/app Modified Files: appsupport.py Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: appsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/app/appsupport.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** appsupport.py 6 Jan 2002 23:03:39 -0000 1.13 --- appsupport.py 24 Mar 2002 23:01:55 -0000 1.14 *************** *** 119,128 **** ThemeDrawingState = OpaqueByValueType("ThemeDrawingState", "ThemeDrawingStateObj") ! Method = MethodGenerator # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator ! ##Method = OSErrMethodGenerator # Create and populate the lists --- 119,128 ---- ThemeDrawingState = OpaqueByValueType("ThemeDrawingState", "ThemeDrawingStateObj") ! Method = WeakLinkMethodGenerator # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator ! ##Method = OSErrWeakLinkMethodGenerator # Create and populate the lists From nascheme@users.sourceforge.net Sun Mar 24 23:02:09 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sun, 24 Mar 2002 15:02:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib pydoc.py,1.58,1.59 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv22152/Lib Modified Files: pydoc.py Log Message: Remove unnecessary \b. It was causing the RE to miss the tailing slash on strings like "http://www.python.org/ is good". Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** pydoc.py 7 Mar 2002 22:58:02 -0000 1.58 --- pydoc.py 24 Mar 2002 23:02:07 -0000 1.59 *************** *** 442,446 **** r'RFC[- ]?(\d+)|' r'PEP[- ]?(\d+)|' ! r'(self\.)?(\w+))\b') while 1: match = pattern.search(text, here) --- 442,446 ---- r'RFC[- ]?(\d+)|' r'PEP[- ]?(\d+)|' ! r'(self\.)?(\w+))') while 1: match = pattern.search(text, here) From jackjansen@users.sourceforge.net Sun Mar 24 23:02:40 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 15:02:40 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/qt _Qtmodule.c,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/qt In directory usw-pr-cvs1:/tmp/cvs-serv22791/Python/Mac/Modules/qt Modified Files: _Qtmodule.c Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _Qtmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/qt/_Qtmodule.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** _Qtmodule.c 18 Dec 2001 15:36:46 -0000 1.6 --- _Qtmodule.c 24 Mar 2002 23:02:37 -0000 1.7 *************** *** 141,144 **** --- 141,147 ---- WindowPtr movieWindow; Point where; + #ifndef MCSetMovie + PyMac_PRECHECK(MCSetMovie); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&", MovieObj_Convert, &theMovie, *************** *** 160,163 **** [...4018 lines suppressed...] *************** *** 8368,8371 **** --- 9577,9583 ---- Point startPt; Rect boundsRect; + #ifndef DragAlignedWindow + PyMac_PRECHECK(DragAlignedWindow); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&", WinObj_Convert, &wp, *************** *** 8387,8390 **** --- 9599,9605 ---- PyObject *_res = NULL; long maxMilliSecToUse; + #ifndef MoviesTask + PyMac_PRECHECK(MoviesTask); + #endif if (!PyArg_ParseTuple(_args, "l", &maxMilliSecToUse)) From jackjansen@users.sourceforge.net Sun Mar 24 23:02:03 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 15:02:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/te _TEmodule.c,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/te In directory usw-pr-cvs1:/tmp/cvs-serv21253/Python/Mac/Modules/te Modified Files: _TEmodule.c Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _TEmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/te/_TEmodule.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** _TEmodule.c 18 Dec 2001 15:36:19 -0000 1.7 --- _TEmodule.c 24 Mar 2002 23:02:01 -0000 1.8 *************** *** 110,113 **** --- 110,116 ---- long text__len__; int text__in_len__; + #ifndef TESetText + PyMac_PRECHECK(TESetText); + #endif if (!PyArg_ParseTuple(_args, "s#", &text__in__, &text__in_len__)) *************** *** 125,128 **** --- 128,134 ---- PyObject *_res = NULL; CharsHandle _rv; + #ifndef TEGetText + PyMac_PRECHECK(TEGetText); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 136,139 **** --- 142,148 ---- { PyObject *_res = NULL; + #ifndef TEIdle + PyMac_PRECHECK(TEIdle); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 149,152 **** --- 158,164 ---- long selStart; long selEnd; + #ifndef TESetSelect + PyMac_PRECHECK(TESetSelect); + #endif if (!PyArg_ParseTuple(_args, "ll", &selStart, *************** *** 164,167 **** --- 176,182 ---- { PyObject *_res = NULL; + #ifndef TEActivate + PyMac_PRECHECK(TEActivate); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 175,178 **** --- 190,196 ---- { PyObject *_res = NULL; + #ifndef TEDeactivate + PyMac_PRECHECK(TEDeactivate); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 187,190 **** --- 205,211 ---- PyObject *_res = NULL; CharParameter key; + #ifndef TEKey + PyMac_PRECHECK(TEKey); + #endif if (!PyArg_ParseTuple(_args, "h", &key)) *************** *** 200,203 **** --- 221,227 ---- { PyObject *_res = NULL; + #ifndef TECut + PyMac_PRECHECK(TECut); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 211,214 **** --- 235,241 ---- { PyObject *_res = NULL; + #ifndef TECopy + PyMac_PRECHECK(TECopy); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 222,225 **** --- 249,255 ---- { PyObject *_res = NULL; + #ifndef TEPaste + PyMac_PRECHECK(TEPaste); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 233,236 **** --- 263,269 ---- { PyObject *_res = NULL; + #ifndef TEDelete + PyMac_PRECHECK(TEDelete); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 247,250 **** --- 280,286 ---- long text__len__; int text__in_len__; + #ifndef TEInsert + PyMac_PRECHECK(TEInsert); + #endif if (!PyArg_ParseTuple(_args, "s#", &text__in__, &text__in_len__)) *************** *** 262,265 **** --- 298,304 ---- PyObject *_res = NULL; short just; + #ifndef TESetAlignment + PyMac_PRECHECK(TESetAlignment); + #endif if (!PyArg_ParseTuple(_args, "h", &just)) *************** *** 276,279 **** --- 315,321 ---- PyObject *_res = NULL; Rect rUpdate; + #ifndef TEUpdate + PyMac_PRECHECK(TEUpdate); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetRect, &rUpdate)) *************** *** 291,294 **** --- 333,339 ---- short dh; short dv; + #ifndef TEScroll + PyMac_PRECHECK(TEScroll); + #endif if (!PyArg_ParseTuple(_args, "hh", &dh, *************** *** 306,309 **** --- 351,357 ---- { PyObject *_res = NULL; + #ifndef TESelView + PyMac_PRECHECK(TESelView); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 319,322 **** --- 367,373 ---- short dh; short dv; + #ifndef TEPinScroll + PyMac_PRECHECK(TEPinScroll); + #endif if (!PyArg_ParseTuple(_args, "hh", &dh, *************** *** 335,338 **** --- 386,392 ---- PyObject *_res = NULL; Boolean fAuto; + #ifndef TEAutoView + PyMac_PRECHECK(TEAutoView); + #endif if (!PyArg_ParseTuple(_args, "b", &fAuto)) *************** *** 348,351 **** --- 402,408 ---- { PyObject *_res = NULL; + #ifndef TECalText + PyMac_PRECHECK(TECalText); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 361,364 **** --- 418,424 ---- short _rv; Point pt; + #ifndef TEGetOffset + PyMac_PRECHECK(TEGetOffset); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetPoint, &pt)) *************** *** 376,379 **** --- 436,442 ---- Point _rv; short offset; + #ifndef TEGetPoint + PyMac_PRECHECK(TEGetPoint); + #endif if (!PyArg_ParseTuple(_args, "h", &offset)) *************** *** 391,394 **** --- 454,460 ---- Point pt; Boolean fExtend; + #ifndef TEClick + PyMac_PRECHECK(TEClick); + #endif if (!PyArg_ParseTuple(_args, "O&b", PyMac_GetPoint, &pt, *************** *** 407,410 **** --- 473,479 ---- PyObject *_res = NULL; TEStyleHandle theHandle; + #ifndef TESetStyleHandle + PyMac_PRECHECK(TESetStyleHandle); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theHandle)) *************** *** 421,424 **** --- 490,496 ---- PyObject *_res = NULL; TEStyleHandle _rv; + #ifndef TEGetStyleHandle + PyMac_PRECHECK(TEGetStyleHandle); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 436,439 **** --- 508,514 ---- short lineHeight; short fontAscent; + #ifndef TEGetStyle + PyMac_PRECHECK(TEGetStyle); + #endif if (!PyArg_ParseTuple(_args, "h", &offset)) *************** *** 454,457 **** --- 529,535 ---- { PyObject *_res = NULL; + #ifndef TEStylePaste + PyMac_PRECHECK(TEStylePaste); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 468,471 **** --- 546,552 ---- TextStyle newStyle; Boolean fRedraw; + #ifndef TESetStyle + PyMac_PRECHECK(TESetStyle); + #endif if (!PyArg_ParseTuple(_args, "hO&b", &mode, *************** *** 489,492 **** --- 570,576 ---- TextStyle newStyle; Boolean fRedraw; + #ifndef TEReplaceStyle + PyMac_PRECHECK(TEReplaceStyle); + #endif if (!PyArg_ParseTuple(_args, "hO&O&b", &mode, *************** *** 509,512 **** --- 593,599 ---- PyObject *_res = NULL; StScrpHandle _rv; + #ifndef TEGetStyleScrapHandle + PyMac_PRECHECK(TEGetStyleScrapHandle); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 524,527 **** --- 611,617 ---- int text__in_len__; StScrpHandle hST; + #ifndef TEStyleInsert + PyMac_PRECHECK(TEStyleInsert); + #endif if (!PyArg_ParseTuple(_args, "s#O&", &text__in__, &text__in_len__, *************** *** 543,546 **** --- 633,639 ---- long endLine; long startLine; + #ifndef TEGetHeight + PyMac_PRECHECK(TEGetHeight); + #endif if (!PyArg_ParseTuple(_args, "ll", &endLine, *************** *** 561,564 **** --- 654,660 ---- short mode; TextStyle aStyle; + #ifndef TEContinuousStyle + PyMac_PRECHECK(TEContinuousStyle); + #endif if (!PyArg_ParseTuple(_args, "hO&", &mode, *************** *** 582,585 **** --- 678,684 ---- StScrpHandle newStyles; Boolean fRedraw; + #ifndef TEUseStyleScrap + PyMac_PRECHECK(TEUseStyleScrap); + #endif if (!PyArg_ParseTuple(_args, "llO&b", &rangeStart, *************** *** 604,607 **** --- 703,709 ---- long rangeStart; long rangeEnd; + #ifndef TENumStyles + PyMac_PRECHECK(TENumStyles); + #endif if (!PyArg_ParseTuple(_args, "ll", &rangeStart, *************** *** 622,625 **** --- 724,730 ---- short feature; short action; + #ifndef TEFeatureFlag + PyMac_PRECHECK(TEFeatureFlag); + #endif if (!PyArg_ParseTuple(_args, "hh", &feature, *************** *** 639,642 **** --- 744,750 ---- OSErr _err; RgnHandle region; + #ifndef TEGetHiliteRgn + PyMac_PRECHECK(TEGetHiliteRgn); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, ®ion)) *************** *** 654,657 **** --- 762,768 ---- PyObject *_res = NULL; Handle _rv; + #ifndef as_Resource + PyMac_PRECHECK(as_Resource); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 819,822 **** --- 930,936 ---- PyObject *_res = NULL; Handle _rv; + #ifndef TEScrapHandle + PyMac_PRECHECK(TEScrapHandle); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 831,834 **** --- 945,951 ---- PyObject *_res = NULL; long _rv; + #ifndef TEGetScrapLength + PyMac_PRECHECK(TEGetScrapLength); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 845,848 **** --- 962,968 ---- Rect destRect; Rect viewRect; + #ifndef TENew + PyMac_PRECHECK(TENew); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetRect, &destRect, *************** *** 864,867 **** --- 984,990 ---- Rect box; short just; + #ifndef TETextBox + PyMac_PRECHECK(TETextBox); + #endif if (!PyArg_ParseTuple(_args, "s#O&h", &text__in__, &text__in_len__, *************** *** 884,887 **** --- 1007,1013 ---- Rect destRect; Rect viewRect; + #ifndef TEStyleNew + PyMac_PRECHECK(TEStyleNew); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetRect, &destRect, *************** *** 899,902 **** --- 1025,1031 ---- PyObject *_res = NULL; long length; + #ifndef TESetScrapLength + PyMac_PRECHECK(TESetScrapLength); + #endif if (!PyArg_ParseTuple(_args, "l", &length)) *************** *** 912,915 **** --- 1041,1047 ---- PyObject *_res = NULL; OSErr _err; + #ifndef TEFromScrap + PyMac_PRECHECK(TEFromScrap); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 925,928 **** --- 1057,1063 ---- PyObject *_res = NULL; OSErr _err; + #ifndef TEToScrap + PyMac_PRECHECK(TEToScrap); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 940,943 **** --- 1075,1081 ---- PyObject *_res = NULL; Handle _rv; + #ifndef TEGetScrapHandle + PyMac_PRECHECK(TEGetScrapHandle); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 955,958 **** --- 1093,1099 ---- PyObject *_res = NULL; Handle value; + #ifndef TESetScrapHandle + PyMac_PRECHECK(TESetScrapHandle); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &value)) *************** *** 969,972 **** --- 1110,1116 ---- PyObject *_res = NULL; UInt8 _rv; + #ifndef LMGetWordRedraw + PyMac_PRECHECK(LMGetWordRedraw); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 981,984 **** --- 1125,1131 ---- PyObject *_res = NULL; UInt8 value; + #ifndef LMSetWordRedraw + PyMac_PRECHECK(LMSetWordRedraw); + #endif if (!PyArg_ParseTuple(_args, "b", &value)) *************** *** 995,998 **** --- 1142,1148 ---- TEHandle _rv; Handle h; + #ifndef as_TE + PyMac_PRECHECK(as_TE); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &h)) From jackjansen@users.sourceforge.net Sun Mar 24 23:02:44 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 15:02:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/qdoffs _Qdoffsmodule.c,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/qdoffs In directory usw-pr-cvs1:/tmp/cvs-serv25455/Python/Mac/Modules/qdoffs Modified Files: _Qdoffsmodule.c Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _Qdoffsmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/qdoffs/_Qdoffsmodule.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** _Qdoffsmodule.c 18 Dec 2001 15:36:52 -0000 1.6 --- _Qdoffsmodule.c 24 Mar 2002 23:02:42 -0000 1.7 *************** *** 81,84 **** --- 81,87 ---- PyObject *_res = NULL; GDHandle _rv; + #ifndef GetGWorldDevice + PyMac_PRECHECK(GetGWorldDevice); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 93,96 **** --- 96,102 ---- PyObject *_res = NULL; PixMapHandle _rv; + #ifndef GetGWorldPixMap + PyMac_PRECHECK(GetGWorldPixMap); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 105,108 **** --- 111,117 ---- PyObject *_res = NULL; GrafPtr _rv; + #ifndef as_GrafPtr + PyMac_PRECHECK(as_GrafPtr); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 170,173 **** --- 179,185 ---- GDHandle aGDevice; GWorldFlags flags; + #ifndef NewGWorld + PyMac_PRECHECK(NewGWorld); + #endif if (!PyArg_ParseTuple(_args, "hO&O&O&l", &PixelDepth, *************** *** 194,197 **** --- 206,212 ---- Boolean _rv; PixMapHandle pm; + #ifndef LockPixels + PyMac_PRECHECK(LockPixels); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pm)) *************** *** 207,210 **** --- 222,228 ---- PyObject *_res = NULL; PixMapHandle pm; + #ifndef UnlockPixels + PyMac_PRECHECK(UnlockPixels); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pm)) *************** *** 226,229 **** --- 244,250 ---- GDHandle aGDevice; GWorldFlags flags; + #ifndef UpdateGWorld + PyMac_PRECHECK(UpdateGWorld); + #endif if (!PyArg_ParseTuple(_args, "hO&O&O&l", &pixelDepth, *************** *** 250,253 **** --- 271,277 ---- CGrafPtr port; GDHandle gdh; + #ifndef GetGWorld + PyMac_PRECHECK(GetGWorld); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 265,268 **** --- 289,295 ---- CGrafPtr port; GDHandle gdh; + #ifndef SetGWorld + PyMac_PRECHECK(SetGWorld); + #endif if (!PyArg_ParseTuple(_args, "O&O&", GrafObj_Convert, &port, *************** *** 280,283 **** --- 307,313 ---- PyObject *_res = NULL; CTabHandle ctab; + #ifndef CTabChanged + PyMac_PRECHECK(CTabChanged); + #endif if (!PyArg_ParseTuple(_args, "O&", OptResObj_Convert, &ctab)) *************** *** 293,296 **** --- 323,329 ---- PyObject *_res = NULL; PixPatHandle ppat; + #ifndef PixPatChanged + PyMac_PRECHECK(PixPatChanged); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &ppat)) *************** *** 306,309 **** --- 339,345 ---- PyObject *_res = NULL; GrafPtr port; + #ifndef PortChanged + PyMac_PRECHECK(PortChanged); + #endif if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) *************** *** 319,322 **** --- 355,361 ---- PyObject *_res = NULL; GDHandle gdh; + #ifndef GDeviceChanged + PyMac_PRECHECK(GDeviceChanged); + #endif if (!PyArg_ParseTuple(_args, "O&", OptResObj_Convert, &gdh)) *************** *** 332,335 **** --- 371,377 ---- PyObject *_res = NULL; PixMapHandle pm; + #ifndef AllowPurgePixels + PyMac_PRECHECK(AllowPurgePixels); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pm)) *************** *** 345,348 **** --- 387,393 ---- PyObject *_res = NULL; PixMapHandle pm; + #ifndef NoPurgePixels + PyMac_PRECHECK(NoPurgePixels); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pm)) *************** *** 359,362 **** --- 404,410 ---- GWorldFlags _rv; PixMapHandle pm; + #ifndef GetPixelsState + PyMac_PRECHECK(GetPixelsState); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pm)) *************** *** 373,376 **** --- 421,427 ---- PixMapHandle pm; GWorldFlags state; + #ifndef SetPixelsState + PyMac_PRECHECK(SetPixelsState); + #endif if (!PyArg_ParseTuple(_args, "O&l", ResObj_Convert, &pm, *************** *** 389,392 **** --- 440,446 ---- long _rv; PixMapHandle pm; + #ifndef GetPixRowBytes + PyMac_PRECHECK(GetPixRowBytes); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pm)) *************** *** 406,409 **** --- 460,466 ---- GDHandle gdh; PixMapHandle offscreenPixMap; + #ifndef NewScreenBuffer + PyMac_PRECHECK(NewScreenBuffer); + #endif if (!PyArg_ParseTuple(_args, "O&b", PyMac_GetRect, &globalRect, *************** *** 425,428 **** --- 482,488 ---- PyObject *_res = NULL; PixMapHandle offscreenPixMap; + #ifndef DisposeScreenBuffer + PyMac_PRECHECK(DisposeScreenBuffer); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &offscreenPixMap)) *************** *** 439,442 **** --- 499,505 ---- Boolean _rv; GrafPtr port; + #ifndef QDDone + PyMac_PRECHECK(QDDone); + #endif if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) *************** *** 452,455 **** --- 515,521 ---- PyObject *_res = NULL; long _rv; + #ifndef OffscreenVersion + PyMac_PRECHECK(OffscreenVersion); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 468,471 **** --- 534,540 ---- GDHandle gdh; PixMapHandle offscreenPixMap; + #ifndef NewTempScreenBuffer + PyMac_PRECHECK(NewTempScreenBuffer); + #endif if (!PyArg_ParseTuple(_args, "O&b", PyMac_GetRect, &globalRect, *************** *** 488,491 **** --- 557,563 ---- Boolean _rv; PixMapHandle pmHandle; + #ifndef PixMap32Bit + PyMac_PRECHECK(PixMap32Bit); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pmHandle)) From jackjansen@users.sourceforge.net Sun Mar 24 23:03:25 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 15:03:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/icn _Icnmodule.c,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/icn In directory usw-pr-cvs1:/tmp/cvs-serv31710/Python/Mac/Modules/icn Modified Files: _Icnmodule.c Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _Icnmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/icn/_Icnmodule.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** _Icnmodule.c 18 Dec 2001 15:37:33 -0000 1.4 --- _Icnmodule.c 24 Mar 2002 23:03:23 -0000 1.5 *************** *** 35,38 **** --- 35,41 ---- CIconHandle _rv; SInt16 iconID; + #ifndef GetCIcon + PyMac_PRECHECK(GetCIcon); + #endif if (!PyArg_ParseTuple(_args, "h", &iconID)) *************** *** 49,52 **** --- 52,58 ---- Rect theRect; CIconHandle theIcon; + #ifndef PlotCIcon + PyMac_PRECHECK(PlotCIcon); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetRect, &theRect, *************** *** 64,67 **** --- 70,76 ---- PyObject *_res = NULL; CIconHandle theIcon; + #ifndef DisposeCIcon + PyMac_PRECHECK(DisposeCIcon); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theIcon)) *************** *** 78,81 **** --- 87,93 ---- Handle _rv; SInt16 iconID; + #ifndef GetIcon + PyMac_PRECHECK(GetIcon); + #endif if (!PyArg_ParseTuple(_args, "h", &iconID)) *************** *** 92,95 **** --- 104,110 ---- Rect theRect; Handle theIcon; + #ifndef PlotIcon + PyMac_PRECHECK(PlotIcon); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetRect, &theRect, *************** *** 111,114 **** --- 126,132 ---- IconTransformType transform; SInt16 theResID; + #ifndef PlotIconID + PyMac_PRECHECK(PlotIconID); + #endif if (!PyArg_ParseTuple(_args, "O&hhh", PyMac_GetRect, &theRect, *************** *** 132,135 **** --- 150,156 ---- OSErr _err; IconSuiteRef theIconSuite; + #ifndef NewIconSuite + PyMac_PRECHECK(NewIconSuite); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 148,151 **** --- 169,175 ---- IconSuiteRef theSuite; ResType theType; + #ifndef AddIconToSuite + PyMac_PRECHECK(AddIconToSuite); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&", ResObj_Convert, &theIconData, *************** *** 169,172 **** --- 193,199 ---- IconSuiteRef theSuite; ResType theType; + #ifndef GetIconFromSuite + PyMac_PRECHECK(GetIconFromSuite); + #endif if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &theSuite, *************** *** 189,192 **** --- 216,222 ---- SInt16 theResID; IconSelectorValue selector; + #ifndef GetIconSuite + PyMac_PRECHECK(GetIconSuite); + #endif if (!PyArg_ParseTuple(_args, "hl", &theResID, *************** *** 208,211 **** --- 238,244 ---- IconSuiteRef theIconSuite; Boolean disposeData; + #ifndef DisposeIconSuite + PyMac_PRECHECK(DisposeIconSuite); + #endif if (!PyArg_ParseTuple(_args, "O&b", ResObj_Convert, &theIconSuite, *************** *** 228,231 **** --- 261,267 ---- IconTransformType transform; IconSuiteRef theIconSuite; + #ifndef PlotIconSuite + PyMac_PRECHECK(PlotIconSuite); + #endif if (!PyArg_ParseTuple(_args, "O&hhO&", PyMac_GetRect, &theRect, *************** *** 252,255 **** --- 288,294 ---- IconTransformType transform; IconCacheRef theIconCache; + #ifndef LoadIconCache + PyMac_PRECHECK(LoadIconCache); + #endif if (!PyArg_ParseTuple(_args, "O&hhO&", PyMac_GetRect, &theRect, *************** *** 275,278 **** --- 314,320 ---- RGBColor labelColor; Str255 labelString; + #ifndef GetLabel + PyMac_PRECHECK(GetLabel); + #endif if (!PyArg_ParseTuple(_args, "hO&", &labelNumber, *************** *** 296,299 **** --- 338,344 ---- IconAlignmentType align; SInt16 iconID; + #ifndef PtInIconID + PyMac_PRECHECK(PtInIconID); + #endif if (!PyArg_ParseTuple(_args, "O&O&hh", PyMac_GetPoint, &testPt, *************** *** 319,322 **** --- 364,370 ---- IconAlignmentType align; IconSuiteRef theIconSuite; + #ifndef PtInIconSuite + PyMac_PRECHECK(PtInIconSuite); + #endif if (!PyArg_ParseTuple(_args, "O&O&hO&", PyMac_GetPoint, &testPt, *************** *** 342,345 **** --- 390,396 ---- IconAlignmentType align; SInt16 iconID; + #ifndef RectInIconID + PyMac_PRECHECK(RectInIconID); + #endif if (!PyArg_ParseTuple(_args, "O&O&hh", PyMac_GetRect, &testRect, *************** *** 365,368 **** --- 416,422 ---- IconAlignmentType align; IconSuiteRef theIconSuite; + #ifndef RectInIconSuite + PyMac_PRECHECK(RectInIconSuite); + #endif if (!PyArg_ParseTuple(_args, "O&O&hO&", PyMac_GetRect, &testRect, *************** *** 388,391 **** --- 442,448 ---- IconAlignmentType align; SInt16 iconID; + #ifndef IconIDToRgn + PyMac_PRECHECK(IconIDToRgn); + #endif if (!PyArg_ParseTuple(_args, "O&O&hh", ResObj_Convert, &theRgn, *************** *** 412,415 **** --- 469,475 ---- IconAlignmentType align; IconSuiteRef theIconSuite; + #ifndef IconSuiteToRgn + PyMac_PRECHECK(IconSuiteToRgn); + #endif if (!PyArg_ParseTuple(_args, "O&O&hO&", ResObj_Convert, &theRgn, *************** *** 434,437 **** --- 494,500 ---- IconSuiteRef theSuite; SInt16 theLabel; + #ifndef SetSuiteLabel + PyMac_PRECHECK(SetSuiteLabel); + #endif if (!PyArg_ParseTuple(_args, "O&h", ResObj_Convert, &theSuite, *************** *** 451,454 **** --- 514,520 ---- SInt16 _rv; IconSuiteRef theSuite; + #ifndef GetSuiteLabel + PyMac_PRECHECK(GetSuiteLabel); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theSuite)) *************** *** 468,471 **** --- 534,540 ---- IconTransformType transform; Handle theIcon; + #ifndef PlotIconHandle + PyMac_PRECHECK(PlotIconHandle); + #endif if (!PyArg_ParseTuple(_args, "O&hhO&", PyMac_GetRect, &theRect, *************** *** 492,495 **** --- 561,567 ---- IconTransformType transform; Handle theSICN; + #ifndef PlotSICNHandle + PyMac_PRECHECK(PlotSICNHandle); + #endif if (!PyArg_ParseTuple(_args, "O&hhO&", PyMac_GetRect, &theRect, *************** *** 516,519 **** --- 588,594 ---- IconTransformType transform; CIconHandle theCIcon; + #ifndef PlotCIconHandle + PyMac_PRECHECK(PlotCIconHandle); + #endif if (!PyArg_ParseTuple(_args, "O&hhO&", PyMac_GetRect, &theRect, *************** *** 537,540 **** --- 612,618 ---- { PyObject *_res = NULL; + #ifndef IconServicesTerminate + PyMac_PRECHECK(IconServicesTerminate); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 553,556 **** --- 631,637 ---- IconSelectorValue whichIcons; IconFamilyHandle iconFamily; + #ifndef IconRefToIconFamily + PyMac_PRECHECK(IconRefToIconFamily); + #endif if (!PyArg_ParseTuple(_args, "O&l", ResObj_Convert, &theIconRef, *************** *** 573,576 **** --- 654,660 ---- IconSelectorValue whichIcons; IconSuiteRef iconSuite; + #ifndef IconFamilyToIconSuite + PyMac_PRECHECK(IconFamilyToIconSuite); + #endif if (!PyArg_ParseTuple(_args, "O&l", ResObj_Convert, &iconFamily, *************** *** 593,596 **** --- 677,683 ---- IconSelectorValue whichIcons; IconFamilyHandle iconFamily; + #ifndef IconSuiteToIconFamily + PyMac_PRECHECK(IconSuiteToIconFamily); + #endif if (!PyArg_ParseTuple(_args, "O&l", ResObj_Convert, &iconSuite, *************** *** 613,616 **** --- 700,706 ---- OSType iconType; Handle h; + #ifndef SetIconFamilyData + PyMac_PRECHECK(SetIconFamilyData); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&", ResObj_Convert, &iconFamily, *************** *** 634,637 **** --- 724,730 ---- OSType iconType; Handle h; + #ifndef GetIconFamilyData + PyMac_PRECHECK(GetIconFamilyData); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&", ResObj_Convert, &iconFamily, *************** *** 654,657 **** --- 747,753 ---- IconRef theIconRef; UInt16 owners; + #ifndef GetIconRefOwners + PyMac_PRECHECK(GetIconRefOwners); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theIconRef)) *************** *** 670,673 **** --- 766,772 ---- OSErr _err; IconRef theIconRef; + #ifndef AcquireIconRef + PyMac_PRECHECK(AcquireIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theIconRef)) *************** *** 685,688 **** --- 784,790 ---- OSErr _err; IconRef theIconRef; + #ifndef ReleaseIconRef + PyMac_PRECHECK(ReleaseIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theIconRef)) *************** *** 702,705 **** --- 804,810 ---- IconRef theIconRef; SInt16 theLabel; + #ifndef GetIconRefFromFile + PyMac_PRECHECK(GetIconRefFromFile); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetFSSpec, &theFile)) *************** *** 723,726 **** --- 828,834 ---- OSType iconType; IconRef theIconRef; + #ifndef GetIconRef + PyMac_PRECHECK(GetIconRef); + #endif if (!PyArg_ParseTuple(_args, "hO&O&", &vRefNum, *************** *** 748,751 **** --- 856,862 ---- SInt8 accessPrivileges; IconRef theIconRef; + #ifndef GetIconRefFromFolder + PyMac_PRECHECK(GetIconRefFromFolder); + #endif if (!PyArg_ParseTuple(_args, "hllbb", &vRefNum, *************** *** 775,778 **** --- 886,892 ---- IconFamilyHandle iconFamily; IconRef theIconRef; + #ifndef RegisterIconRefFromIconFamily + PyMac_PRECHECK(RegisterIconRefFromIconFamily); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&", PyMac_GetOSType, &creator, *************** *** 799,802 **** --- 913,919 ---- SInt16 resourceID; IconRef theIconRef; + #ifndef RegisterIconRefFromResource + PyMac_PRECHECK(RegisterIconRefFromResource); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&h", PyMac_GetOSType, &creator, *************** *** 822,825 **** --- 939,945 ---- OSType creator; OSType iconType; + #ifndef UnregisterIconRef + PyMac_PRECHECK(UnregisterIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &creator, *************** *** 839,842 **** --- 959,965 ---- OSErr _err; IconRef theIconRef; + #ifndef UpdateIconRef + PyMac_PRECHECK(UpdateIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theIconRef)) *************** *** 856,859 **** --- 979,985 ---- FSSpec resourceFile; SInt16 resourceID; + #ifndef OverrideIconRefFromResource + PyMac_PRECHECK(OverrideIconRefFromResource); + #endif if (!PyArg_ParseTuple(_args, "O&O&h", ResObj_Convert, &theIconRef, *************** *** 876,879 **** --- 1002,1008 ---- IconRef oldIconRef; IconRef newIconRef; + #ifndef OverrideIconRef + PyMac_PRECHECK(OverrideIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &oldIconRef, *************** *** 893,896 **** --- 1022,1028 ---- OSErr _err; IconRef theIconRef; + #ifndef RemoveIconRefOverride + PyMac_PRECHECK(RemoveIconRefOverride); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theIconRef)) *************** *** 910,913 **** --- 1042,1048 ---- IconRef foregroundIconRef; IconRef compositeIconRef; + #ifndef CompositeIconRef + PyMac_PRECHECK(CompositeIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &backgroundIconRef, *************** *** 930,933 **** --- 1065,1071 ---- IconRef backgroundIconRef; IconRef foregroundIconRef; + #ifndef IsIconRefComposite + PyMac_PRECHECK(IsIconRefComposite); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &compositeIconRef)) *************** *** 948,951 **** --- 1086,1092 ---- Boolean _rv; IconRef theIconRef; + #ifndef IsValidIconRef + PyMac_PRECHECK(IsValidIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theIconRef)) *************** *** 966,969 **** --- 1107,1113 ---- IconServicesUsageFlags theIconServicesUsageFlags; IconRef theIconRef; + #ifndef PlotIconRef + PyMac_PRECHECK(PlotIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&hhlO&", PyMac_GetRect, &theRect, *************** *** 993,996 **** --- 1137,1143 ---- IconServicesUsageFlags theIconServicesUsageFlags; IconRef theIconRef; + #ifndef PtInIconRef + PyMac_PRECHECK(PtInIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&O&hlO&", PyMac_GetPoint, &testPt, *************** *** 1019,1022 **** --- 1166,1172 ---- IconServicesUsageFlags iconServicesUsageFlags; IconRef theIconRef; + #ifndef RectInIconRef + PyMac_PRECHECK(RectInIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&O&hlO&", PyMac_GetRect, &testRect, *************** *** 1045,1048 **** --- 1195,1201 ---- IconServicesUsageFlags iconServicesUsageFlags; IconRef theIconRef; + #ifndef IconRefToRgn + PyMac_PRECHECK(IconRefToRgn); + #endif if (!PyArg_ParseTuple(_args, "O&O&hlO&", ResObj_Convert, &theRgn, *************** *** 1071,1074 **** --- 1224,1230 ---- IconServicesUsageFlags iconServicesUsageFlags; IconRef theIconRef; + #ifndef GetIconSizesFromIconRef + PyMac_PRECHECK(GetIconSizesFromIconRef); + #endif if (!PyArg_ParseTuple(_args, "llO&", &iconSelectorInput, *************** *** 1092,1095 **** --- 1248,1254 ---- OSType creator; OSType iconType; + #ifndef FlushIconRefs + PyMac_PRECHECK(FlushIconRefs); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &creator, *************** *** 1109,1112 **** --- 1268,1274 ---- OSErr _err; SInt16 vRefNum; + #ifndef FlushIconRefsByVolume + PyMac_PRECHECK(FlushIconRefsByVolume); + #endif if (!PyArg_ParseTuple(_args, "h", &vRefNum)) *************** *** 1125,1128 **** --- 1287,1293 ---- SInt16 vRefNum; Boolean enableCustomIcons; + #ifndef SetCustomIconsEnabled + PyMac_PRECHECK(SetCustomIconsEnabled); + #endif if (!PyArg_ParseTuple(_args, "hb", &vRefNum, *************** *** 1143,1146 **** --- 1308,1314 ---- SInt16 vRefNum; Boolean customIconsEnabled; + #ifndef GetCustomIconsEnabled + PyMac_PRECHECK(GetCustomIconsEnabled); + #endif if (!PyArg_ParseTuple(_args, "h", &vRefNum)) *************** *** 1159,1162 **** --- 1327,1333 ---- Boolean _rv; IconRef iconRef; + #ifndef IsIconRefMaskEmpty + PyMac_PRECHECK(IsIconRefMaskEmpty); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &iconRef)) *************** *** 1177,1180 **** --- 1348,1354 ---- OSType inVariant; IconTransformType outTransform; + #ifndef GetIconRefVariant + PyMac_PRECHECK(GetIconRefVariant); + #endif if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &inIconRef, *************** *** 1201,1204 **** --- 1375,1381 ---- FSSpec iconFile; IconRef theIconRef; + #ifndef RegisterIconRefFromIconFile + PyMac_PRECHECK(RegisterIconRefFromIconFile); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&", PyMac_GetOSType, &creator, *************** *** 1225,1228 **** --- 1402,1408 ---- FSSpec iconFile; IconFamilyHandle iconFamily; + #ifndef ReadIconFile + PyMac_PRECHECK(ReadIconFile); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetFSSpec, &iconFile)) *************** *** 1245,1248 **** --- 1425,1431 ---- IconFamilyHandle iconFamily; FSSpec iconFile; + #ifndef WriteIconFile + PyMac_PRECHECK(WriteIconFile); + #endif if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &iconFamily, From jackjansen@users.sourceforge.net Sun Mar 24 23:03:32 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 15:03:32 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/fm _Fmmodule.c,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/fm In directory usw-pr-cvs1:/tmp/cvs-serv362/Python/Mac/Modules/fm Modified Files: _Fmmodule.c Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _Fmmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/fm/_Fmmodule.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** _Fmmodule.c 7 Jan 2002 14:15:02 -0000 1.5 --- _Fmmodule.c 24 Mar 2002 23:03:30 -0000 1.6 *************** *** 65,68 **** --- 65,71 ---- { PyObject *_res = NULL; + #ifndef InitFonts + PyMac_PRECHECK(InitFonts); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 79,82 **** --- 82,88 ---- short familyID; Str255 name; + #ifndef GetFontName + PyMac_PRECHECK(GetFontName); + #endif if (!PyArg_ParseTuple(_args, "h", &familyID)) *************** *** 94,97 **** --- 100,106 ---- Str255 name; short familyID; + #ifndef GetFNum + PyMac_PRECHECK(GetFNum); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetStr255, name)) *************** *** 110,113 **** --- 119,125 ---- short fontNum; short size; + #ifndef RealFont + PyMac_PRECHECK(RealFont); + #endif if (!PyArg_ParseTuple(_args, "hh", &fontNum, *************** *** 127,130 **** --- 139,145 ---- PyObject *_res = NULL; Boolean lockFlag; + #ifndef SetFontLock + PyMac_PRECHECK(SetFontLock); + #endif if (!PyArg_ParseTuple(_args, "b", &lockFlag)) *************** *** 141,144 **** --- 156,162 ---- PyObject *_res = NULL; Boolean fscaleDisable; + #ifndef SetFScaleDisable + PyMac_PRECHECK(SetFScaleDisable); + #endif if (!PyArg_ParseTuple(_args, "b", &fscaleDisable)) *************** *** 154,157 **** --- 172,178 ---- PyObject *_res = NULL; FMetricRec theMetrics; + #ifndef FontMetrics + PyMac_PRECHECK(FontMetrics); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 166,169 **** --- 187,193 ---- PyObject *_res = NULL; Boolean fractEnable; + #ifndef SetFractEnable + PyMac_PRECHECK(SetFractEnable); + #endif if (!PyArg_ParseTuple(_args, "b", &fractEnable)) *************** *** 179,182 **** --- 203,209 ---- PyObject *_res = NULL; short _rv; + #ifndef GetDefFontSize + PyMac_PRECHECK(GetDefFontSize); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 193,196 **** --- 220,226 ---- Point numer; Point denom; + #ifndef IsOutline + PyMac_PRECHECK(IsOutline); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetPoint, &numer, *************** *** 208,211 **** --- 238,244 ---- PyObject *_res = NULL; Boolean outlinePreferred; + #ifndef SetOutlinePreferred + PyMac_PRECHECK(SetOutlinePreferred); + #endif if (!PyArg_ParseTuple(_args, "b", &outlinePreferred)) *************** *** 221,224 **** --- 254,260 ---- PyObject *_res = NULL; Boolean _rv; + #ifndef GetOutlinePreferred + PyMac_PRECHECK(GetOutlinePreferred); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 233,236 **** --- 269,275 ---- PyObject *_res = NULL; Boolean preserveGlyph; + #ifndef SetPreserveGlyph + PyMac_PRECHECK(SetPreserveGlyph); + #endif if (!PyArg_ParseTuple(_args, "b", &preserveGlyph)) *************** *** 246,249 **** --- 285,291 ---- PyObject *_res = NULL; Boolean _rv; + #ifndef GetPreserveGlyph + PyMac_PRECHECK(GetPreserveGlyph); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 260,263 **** --- 302,308 ---- PyObject *_res = NULL; OSErr _err; + #ifndef FlushFonts + PyMac_PRECHECK(FlushFonts); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 274,277 **** --- 319,325 ---- PyObject *_res = NULL; short _rv; + #ifndef GetSysFont + PyMac_PRECHECK(GetSysFont); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 286,289 **** --- 334,340 ---- PyObject *_res = NULL; short _rv; + #ifndef GetAppFont + PyMac_PRECHECK(GetAppFont); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 301,304 **** --- 352,358 ---- int inText__in_len__; Rect bounds; + #ifndef QDTextBounds + PyMac_PRECHECK(QDTextBounds); + #endif if (!PyArg_ParseTuple(_args, "s#", &inText__in__, &inText__in_len__)) From jackjansen@users.sourceforge.net Sun Mar 24 23:03:37 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 15:03:37 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/evt _Evtmodule.c,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/evt In directory usw-pr-cvs1:/tmp/cvs-serv897/Python/Mac/Modules/evt Modified Files: _Evtmodule.c Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _Evtmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/evt/_Evtmodule.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** _Evtmodule.c 17 Dec 2001 11:46:45 -0000 1.5 --- _Evtmodule.c 24 Mar 2002 23:03:35 -0000 1.6 *************** *** 34,37 **** --- 34,40 ---- PyObject *_res = NULL; Point mouseLoc; + #ifndef GetMouse + PyMac_PRECHECK(GetMouse); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 46,49 **** --- 49,55 ---- PyObject *_res = NULL; Boolean _rv; + #ifndef Button + PyMac_PRECHECK(Button); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 58,61 **** --- 64,70 ---- PyObject *_res = NULL; Boolean _rv; + #ifndef StillDown + PyMac_PRECHECK(StillDown); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 70,73 **** --- 79,85 ---- PyObject *_res = NULL; Boolean _rv; + #ifndef WaitMouseUp + PyMac_PRECHECK(WaitMouseUp); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 82,85 **** --- 94,100 ---- PyObject *_res = NULL; UInt32 _rv; + #ifndef GetCaretTime + PyMac_PRECHECK(GetCaretTime); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 94,97 **** --- 109,115 ---- PyObject *_res = NULL; KeyMap theKeys__out__; + #ifndef GetKeys + PyMac_PRECHECK(GetKeys); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 106,109 **** --- 124,130 ---- PyObject *_res = NULL; UInt32 _rv; + #ifndef GetDblTime + PyMac_PRECHECK(GetDblTime); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 118,121 **** --- 139,145 ---- PyObject *_res = NULL; EventMask value; + #ifndef SetEventMask + PyMac_PRECHECK(SetEventMask); + #endif if (!PyArg_ParseTuple(_args, "H", &value)) *************** *** 133,136 **** --- 157,163 ---- EventMask eventMask; EventRecord theEvent; + #ifndef GetNextEvent + PyMac_PRECHECK(GetNextEvent); + #endif if (!PyArg_ParseTuple(_args, "H", &eventMask)) *************** *** 150,153 **** --- 177,183 ---- EventMask eventMask; EventRecord theEvent; + #ifndef EventAvail + PyMac_PRECHECK(EventAvail); + #endif if (!PyArg_ParseTuple(_args, "H", &eventMask)) *************** *** 167,170 **** --- 197,203 ---- EventKind eventNum; UInt32 eventMsg; + #ifndef PostEvent + PyMac_PRECHECK(PostEvent); + #endif if (!PyArg_ParseTuple(_args, "Hl", &eventNum, *************** *** 187,190 **** --- 220,226 ---- EventMask mask; EventRecord theEvent; + #ifndef OSEventAvail + PyMac_PRECHECK(OSEventAvail); + #endif if (!PyArg_ParseTuple(_args, "H", &mask)) *************** *** 207,210 **** --- 243,249 ---- EventMask mask; EventRecord theEvent; + #ifndef GetOSEvent + PyMac_PRECHECK(GetOSEvent); + #endif if (!PyArg_ParseTuple(_args, "H", &mask)) *************** *** 224,227 **** --- 263,269 ---- EventMask whichMask; EventMask stopMask; + #ifndef FlushEvents + PyMac_PRECHECK(FlushEvents); + #endif if (!PyArg_ParseTuple(_args, "HH", &whichMask, *************** *** 242,245 **** --- 284,290 ---- EventRecord theEvent; WindowPtr theWindow; + #ifndef SystemClick + PyMac_PRECHECK(SystemClick); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetEventRecord, &theEvent, *************** *** 259,262 **** --- 304,310 ---- { PyObject *_res = NULL; + #ifndef SystemTask + PyMac_PRECHECK(SystemTask); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 275,278 **** --- 323,329 ---- Boolean _rv; EventRecord theEvent; + #ifndef SystemEvent + PyMac_PRECHECK(SystemEvent); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetEventRecord, &theEvent)) *************** *** 291,294 **** --- 342,348 ---- PyObject *_res = NULL; Point globalMouse; + #ifndef GetGlobalMouse + PyMac_PRECHECK(GetGlobalMouse); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 306,309 **** --- 360,366 ---- PyObject *_res = NULL; UInt32 _rv; + #ifndef GetCurrentKeyModifiers + PyMac_PRECHECK(GetCurrentKeyModifiers); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 321,324 **** --- 378,384 ---- PyObject *_res = NULL; Boolean _rv; + #ifndef CheckEventQueueForUserCancel + PyMac_PRECHECK(CheckEventQueueForUserCancel); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 334,337 **** --- 394,400 ---- PyObject *_res = NULL; short code; + #ifndef KeyScript + PyMac_PRECHECK(KeyScript); + #endif if (!PyArg_ParseTuple(_args, "h", &code)) *************** *** 349,352 **** --- 412,418 ---- EventRecord event; short test; + #ifndef IsCmdChar + PyMac_PRECHECK(IsCmdChar); + #endif if (!PyArg_ParseTuple(_args, "O&h", PyMac_GetEventRecord, &event, *************** *** 364,367 **** --- 430,436 ---- PyObject *_res = NULL; SInt16 _rv; + #ifndef LMGetKeyThresh + PyMac_PRECHECK(LMGetKeyThresh); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 376,379 **** --- 445,451 ---- PyObject *_res = NULL; SInt16 value; + #ifndef LMSetKeyThresh + PyMac_PRECHECK(LMSetKeyThresh); + #endif if (!PyArg_ParseTuple(_args, "h", &value)) *************** *** 389,392 **** --- 461,467 ---- PyObject *_res = NULL; SInt16 _rv; + #ifndef LMGetKeyRepThresh + PyMac_PRECHECK(LMGetKeyRepThresh); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 401,404 **** --- 476,482 ---- PyObject *_res = NULL; SInt16 value; + #ifndef LMSetKeyRepThresh + PyMac_PRECHECK(LMSetKeyRepThresh); + #endif if (!PyArg_ParseTuple(_args, "h", &value)) *************** *** 414,417 **** --- 492,498 ---- PyObject *_res = NULL; UInt8 _rv; + #ifndef LMGetKbdLast + PyMac_PRECHECK(LMGetKbdLast); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 426,429 **** --- 507,513 ---- PyObject *_res = NULL; UInt8 value; + #ifndef LMSetKbdLast + PyMac_PRECHECK(LMSetKbdLast); + #endif if (!PyArg_ParseTuple(_args, "b", &value)) *************** *** 439,442 **** --- 523,529 ---- PyObject *_res = NULL; UInt8 _rv; + #ifndef LMGetKbdType + PyMac_PRECHECK(LMGetKbdType); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 451,454 **** --- 538,544 ---- PyObject *_res = NULL; UInt8 value; + #ifndef LMSetKbdType + PyMac_PRECHECK(LMSetKbdType); + #endif if (!PyArg_ParseTuple(_args, "b", &value)) *************** *** 464,467 **** --- 554,560 ---- PyObject *_res = NULL; UInt32 _rv; + #ifndef TickCount + PyMac_PRECHECK(TickCount); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; From jackjansen@users.sourceforge.net Sun Mar 24 23:03:43 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 15:03:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/drag _Dragmodule.c,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/drag In directory usw-pr-cvs1:/tmp/cvs-serv1555/Python/Mac/Modules/drag Modified Files: _Dragmodule.c Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _Dragmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/drag/_Dragmodule.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** _Dragmodule.c 4 Jan 2002 14:39:29 -0000 1.7 --- _Dragmodule.c 24 Mar 2002 23:03:41 -0000 1.8 *************** *** 92,95 **** --- 92,98 ---- PyObject *_res = NULL; OSErr _err; + #ifndef DisposeDrag + PyMac_PRECHECK(DisposeDrag); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 111,114 **** --- 114,120 ---- int dataPtr__in_len__; FlavorFlags theFlags; + #ifndef AddDragItemFlavor + PyMac_PRECHECK(AddDragItemFlavor); + #endif if (!PyArg_ParseTuple(_args, "lO&z#l", &theItemRef, *************** *** 139,142 **** --- 145,151 ---- int dataPtr__in_len__; UInt32 dataOffset; + #ifndef SetDragItemFlavorData + PyMac_PRECHECK(SetDragItemFlavorData); + #endif if (!PyArg_ParseTuple(_args, "lO&z#l", &theItemRef, *************** *** 165,168 **** --- 174,180 ---- Point imageOffsetPt; DragImageFlags theImageFlags; + #ifndef SetDragImage + PyMac_PRECHECK(SetDragImage); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&l", ResObj_Convert, &imagePixMap, *************** *** 188,191 **** --- 200,206 ---- DragBehaviors inBehaviorsToSet; DragBehaviors inBehaviorsToClear; + #ifndef ChangeDragBehaviors + PyMac_PRECHECK(ChangeDragBehaviors); + #endif if (!PyArg_ParseTuple(_args, "ll", &inBehaviorsToSet, *************** *** 207,210 **** --- 222,228 ---- EventRecord theEvent; RgnHandle theRegion; + #ifndef TrackDrag + PyMac_PRECHECK(TrackDrag); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetEventRecord, &theEvent, *************** *** 225,228 **** --- 243,249 ---- OSErr _err; UInt16 numItems; + #ifndef CountDragItems + PyMac_PRECHECK(CountDragItems); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 241,244 **** --- 262,268 ---- UInt16 index; ItemReference theItemRef; + #ifndef GetDragItemReferenceNumber + PyMac_PRECHECK(GetDragItemReferenceNumber); + #endif if (!PyArg_ParseTuple(_args, "H", &index)) *************** *** 259,262 **** --- 283,289 ---- ItemReference theItemRef; UInt16 numFlavors; + #ifndef CountDragItemFlavors + PyMac_PRECHECK(CountDragItemFlavors); + #endif if (!PyArg_ParseTuple(_args, "l", &theItemRef)) *************** *** 278,281 **** --- 305,311 ---- UInt16 index; FlavorType theType; + #ifndef GetFlavorType + PyMac_PRECHECK(GetFlavorType); + #endif if (!PyArg_ParseTuple(_args, "lH", &theItemRef, *************** *** 299,302 **** --- 329,335 ---- FlavorType theType; FlavorFlags theFlags; + #ifndef GetFlavorFlags + PyMac_PRECHECK(GetFlavorFlags); + #endif if (!PyArg_ParseTuple(_args, "lO&", &theItemRef, *************** *** 320,323 **** --- 353,359 ---- FlavorType theType; Size dataSize; + #ifndef GetFlavorDataSize + PyMac_PRECHECK(GetFlavorDataSize); + #endif if (!PyArg_ParseTuple(_args, "lO&", &theItemRef, *************** *** 344,347 **** --- 380,386 ---- int dataPtr__in_len__; UInt32 dataOffset; + #ifndef GetFlavorData + PyMac_PRECHECK(GetFlavorData); + #endif if (!PyArg_ParseTuple(_args, "lO&il", &theItemRef, *************** *** 375,378 **** --- 414,420 ---- ItemReference theItemRef; Rect itemBounds; + #ifndef GetDragItemBounds + PyMac_PRECHECK(GetDragItemBounds); + #endif if (!PyArg_ParseTuple(_args, "l", &theItemRef)) *************** *** 393,396 **** --- 435,441 ---- ItemReference theItemRef; Rect itemBounds; + #ifndef SetDragItemBounds + PyMac_PRECHECK(SetDragItemBounds); + #endif if (!PyArg_ParseTuple(_args, "lO&", &theItemRef, *************** *** 411,414 **** --- 456,462 ---- OSErr _err; AEDesc dropLocation; + #ifndef GetDropLocation + PyMac_PRECHECK(GetDropLocation); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 426,429 **** --- 474,480 ---- OSErr _err; AEDesc dropLocation; + #ifndef SetDropLocation + PyMac_PRECHECK(SetDropLocation); + #endif if (!PyArg_ParseTuple(_args, "O&", AEDesc_Convert, &dropLocation)) *************** *** 442,445 **** --- 493,499 ---- OSErr _err; DragAttributes flags; + #ifndef GetDragAttributes + PyMac_PRECHECK(GetDragAttributes); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 458,461 **** --- 512,518 ---- Point mouse; Point globalPinnedMouse; + #ifndef GetDragMouse + PyMac_PRECHECK(GetDragMouse); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 475,478 **** --- 532,538 ---- OSErr _err; Point globalPinnedMouse; + #ifndef SetDragMouse + PyMac_PRECHECK(SetDragMouse); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetPoint, &globalPinnedMouse)) *************** *** 491,494 **** --- 551,557 ---- OSErr _err; Point globalInitialMouse; + #ifndef GetDragOrigin + PyMac_PRECHECK(GetDragOrigin); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 508,511 **** --- 571,577 ---- SInt16 mouseDownModifiers; SInt16 mouseUpModifiers; + #ifndef GetDragModifiers + PyMac_PRECHECK(GetDragModifiers); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 528,531 **** --- 594,600 ---- RgnHandle hiliteFrame; Boolean inside; + #ifndef ShowDragHilite + PyMac_PRECHECK(ShowDragHilite); + #endif if (!PyArg_ParseTuple(_args, "O&b", ResObj_Convert, &hiliteFrame, *************** *** 545,548 **** --- 614,620 ---- PyObject *_res = NULL; OSErr _err; + #ifndef HideDragHilite + PyMac_PRECHECK(HideDragHilite); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 560,563 **** --- 632,638 ---- SInt16 dH; SInt16 dV; + #ifndef DragPreScroll + PyMac_PRECHECK(DragPreScroll); + #endif if (!PyArg_ParseTuple(_args, "hh", &dH, *************** *** 577,580 **** --- 652,658 ---- PyObject *_res = NULL; OSErr _err; + #ifndef DragPostScroll + PyMac_PRECHECK(DragPostScroll); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 591,594 **** --- 669,675 ---- OSErr _err; RgnHandle updateRgn; + #ifndef UpdateDragHilite + PyMac_PRECHECK(UpdateDragHilite); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &updateRgn)) *************** *** 702,705 **** --- 783,789 ---- OSErr _err; DragRef theDrag; + #ifndef NewDrag + PyMac_PRECHECK(NewDrag); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 717,720 **** --- 801,807 ---- WindowPtr window; RGBColor color; + #ifndef GetDragHiliteColor + PyMac_PRECHECK(GetDragHiliteColor); + #endif if (!PyArg_ParseTuple(_args, "O&", WinObj_Convert, &window)) *************** *** 733,736 **** --- 820,826 ---- Boolean _rv; Point initialMouse; + #ifndef WaitMouseMoved + PyMac_PRECHECK(WaitMouseMoved); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetPoint, &initialMouse)) *************** *** 750,753 **** --- 840,846 ---- SInt16 zoomSteps; ZoomAcceleration acceleration; + #ifndef ZoomRects + PyMac_PRECHECK(ZoomRects); + #endif if (!PyArg_ParseTuple(_args, "O&O&hh", PyMac_GetRect, &fromRect, *************** *** 774,777 **** --- 867,873 ---- SInt16 zoomSteps; ZoomAcceleration acceleration; + #ifndef ZoomRegion + PyMac_PRECHECK(ZoomRegion); + #endif if (!PyArg_ParseTuple(_args, "O&O&hh", ResObj_Convert, ®ion, From jackjansen@users.sourceforge.net Sun Mar 24 23:03:02 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 15:03:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/qd _Qdmodule.c,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/qd In directory usw-pr-cvs1:/tmp/cvs-serv26247/Python/Mac/Modules/qd Modified Files: _Qdmodule.c Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _Qdmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/qd/_Qdmodule.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** _Qdmodule.c 18 Dec 2001 15:37:03 -0000 1.7 --- _Qdmodule.c 24 Mar 2002 23:03:00 -0000 1.8 *************** *** 658,661 **** --- 658,664 ---- PyObject *_res = NULL; GrafPtr port; + #ifndef MacSetPort + PyMac_PRECHECK(MacSetPort); + #endif if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) *************** *** 671,674 **** [...3078 lines suppressed...] *************** *** 5442,5445 **** --- 6369,6375 ---- Point pt; Rect r; + #ifndef PtInRect + PyMac_PRECHECK(PtInRect); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetPoint, &pt, *************** *** 5460,5463 **** --- 6390,6396 ---- short firstByte; short byteCount; + #ifndef DrawText + PyMac_PRECHECK(DrawText); + #endif if (!PyArg_ParseTuple(_args, "s#hh", &textBuf__in__, &textBuf__in_len__, From jackjansen@users.sourceforge.net Sun Mar 24 23:04:10 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 15:04:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/cm _Cmmodule.c,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cm In directory usw-pr-cvs1:/tmp/cvs-serv5056/Python/Mac/Modules/cm Modified Files: _Cmmodule.c Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _Cmmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cm/_Cmmodule.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** _Cmmodule.c 18 Dec 2001 15:38:17 -0000 1.7 --- _Cmmodule.c 24 Mar 2002 23:04:08 -0000 1.8 *************** *** 110,113 **** --- 110,116 ---- PyObject *_res = NULL; OSErr _err; + #ifndef CloseComponent + PyMac_PRECHECK(CloseComponent); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 123,126 **** --- 126,132 ---- PyObject *_res = NULL; OSErr _err; + #ifndef GetComponentInstanceError + PyMac_PRECHECK(GetComponentInstanceError); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 136,139 **** --- 142,148 ---- PyObject *_res = NULL; OSErr theError; + #ifndef SetComponentInstanceError + PyMac_PRECHECK(SetComponentInstanceError); + #endif if (!PyArg_ParseTuple(_args, "h", &theError)) *************** *** 150,153 **** --- 159,165 ---- PyObject *_res = NULL; Handle _rv; + #ifndef GetComponentInstanceStorage + PyMac_PRECHECK(GetComponentInstanceStorage); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 162,165 **** --- 174,180 ---- PyObject *_res = NULL; Handle theStorage; + #ifndef SetComponentInstanceStorage + PyMac_PRECHECK(SetComponentInstanceStorage); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theStorage)) *************** *** 178,181 **** --- 193,199 ---- PyObject *_res = NULL; long _rv; + #ifndef GetComponentInstanceA5 + PyMac_PRECHECK(GetComponentInstanceA5); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 193,196 **** --- 211,217 ---- PyObject *_res = NULL; long theA5; + #ifndef SetComponentInstanceA5 + PyMac_PRECHECK(SetComponentInstanceA5); + #endif if (!PyArg_ParseTuple(_args, "l", &theA5)) *************** *** 209,212 **** --- 230,236 ---- long _rv; short ftnNumber; + #ifndef ComponentFunctionImplemented + PyMac_PRECHECK(ComponentFunctionImplemented); + #endif if (!PyArg_ParseTuple(_args, "h", &ftnNumber)) *************** *** 223,226 **** --- 247,253 ---- PyObject *_res = NULL; long _rv; + #ifndef GetComponentVersion + PyMac_PRECHECK(GetComponentVersion); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 236,239 **** --- 263,269 ---- long _rv; ComponentInstance target; + #ifndef ComponentSetTarget + PyMac_PRECHECK(ComponentSetTarget); + #endif if (!PyArg_ParseTuple(_args, "O&", CmpInstObj_Convert, &target)) *************** *** 362,365 **** --- 392,398 ---- PyObject *_res = NULL; OSErr _err; + #ifndef UnregisterComponent + PyMac_PRECHECK(UnregisterComponent); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 379,382 **** --- 412,418 ---- Handle componentInfo; Handle componentIcon; + #ifndef GetComponentInfo + PyMac_PRECHECK(GetComponentInfo); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&", ResObj_Convert, &componentName, *************** *** 399,402 **** --- 435,441 ---- PyObject *_res = NULL; ComponentInstance _rv; + #ifndef OpenComponent + PyMac_PRECHECK(OpenComponent); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 411,414 **** --- 450,456 ---- PyObject *_res = NULL; Component _rv; + #ifndef ResolveComponentAlias + PyMac_PRECHECK(ResolveComponentAlias); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 426,429 **** --- 468,474 ---- short strListID; short index; + #ifndef GetComponentPublicIndString + PyMac_PRECHECK(GetComponentPublicIndString); + #endif if (!PyArg_ParseTuple(_args, "O&hh", PyMac_GetStr255, theString, *************** *** 445,448 **** --- 490,496 ---- PyObject *_res = NULL; long _rv; + #ifndef GetComponentRefcon + PyMac_PRECHECK(GetComponentRefcon); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 457,460 **** --- 505,511 ---- PyObject *_res = NULL; long theRefcon; + #ifndef SetComponentRefcon + PyMac_PRECHECK(SetComponentRefcon); + #endif if (!PyArg_ParseTuple(_args, "l", &theRefcon)) *************** *** 471,474 **** --- 522,528 ---- PyObject *_res = NULL; short _rv; + #ifndef OpenComponentResFile + PyMac_PRECHECK(OpenComponentResFile); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 486,489 **** --- 540,546 ---- short resID; Handle theResource; + #ifndef GetComponentResource + PyMac_PRECHECK(GetComponentResource); + #endif if (!PyArg_ParseTuple(_args, "O&h", PyMac_GetOSType, &resType, *************** *** 507,510 **** --- 564,570 ---- short strListID; short index; + #ifndef GetComponentIndString + PyMac_PRECHECK(GetComponentIndString); + #endif if (!PyArg_ParseTuple(_args, "O&hh", PyMac_GetStr255, theString, *************** *** 526,529 **** --- 586,592 ---- PyObject *_res = NULL; long _rv; + #ifndef CountComponentInstances + PyMac_PRECHECK(CountComponentInstances); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 539,542 **** --- 602,608 ---- OSErr _err; short flags; + #ifndef SetDefaultComponent + PyMac_PRECHECK(SetDefaultComponent); + #endif if (!PyArg_ParseTuple(_args, "h", &flags)) *************** *** 555,558 **** --- 621,627 ---- Component _rv; Component capturingComponent; + #ifndef CaptureComponent + PyMac_PRECHECK(CaptureComponent); + #endif if (!PyArg_ParseTuple(_args, "O&", CmpObj_Convert, &capturingComponent)) *************** *** 569,572 **** --- 638,644 ---- PyObject *_res = NULL; OSErr _err; + #ifndef UncaptureComponent + PyMac_PRECHECK(UncaptureComponent); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 583,586 **** --- 655,661 ---- OSErr _err; Handle iconSuite; + #ifndef GetComponentIconSuite + PyMac_PRECHECK(GetComponentIconSuite); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 670,673 **** --- 745,751 ---- ComponentResourceHandle cr; short global; + #ifndef RegisterComponentResource + PyMac_PRECHECK(RegisterComponentResource); + #endif if (!PyArg_ParseTuple(_args, "O&h", ResObj_Convert, &cr, *************** *** 687,690 **** --- 765,771 ---- Component aComponent; ComponentDescription looking; + #ifndef FindNextComponent + PyMac_PRECHECK(FindNextComponent); + #endif if (!PyArg_ParseTuple(_args, "O&O&", CmpObj_Convert, &aComponent, *************** *** 703,706 **** --- 784,790 ---- long _rv; ComponentDescription looking; + #ifndef CountComponents + PyMac_PRECHECK(CountComponents); + #endif if (!PyArg_ParseTuple(_args, "O&", CmpDesc_Convert, &looking)) *************** *** 716,719 **** --- 800,806 ---- PyObject *_res = NULL; long _rv; + #ifndef GetComponentListModSeed + PyMac_PRECHECK(GetComponentListModSeed); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 729,732 **** --- 816,822 ---- OSErr _err; short refnum; + #ifndef CloseComponentResFile + PyMac_PRECHECK(CloseComponentResFile); + #endif if (!PyArg_ParseTuple(_args, "h", &refnum)) *************** *** 745,748 **** --- 835,841 ---- OSType componentType; OSType componentSubType; + #ifndef OpenDefaultComponent + PyMac_PRECHECK(OpenDefaultComponent); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &componentType, *************** *** 762,765 **** --- 855,861 ---- short resRefNum; short global; + #ifndef RegisterComponentResourceFile + PyMac_PRECHECK(RegisterComponentResourceFile); + #endif if (!PyArg_ParseTuple(_args, "hh", &resRefNum, From jackjansen@users.sourceforge.net Sun Mar 24 23:04:20 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 15:04:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/ae _AEmodule.c,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/ae In directory usw-pr-cvs1:/tmp/cvs-serv6530/Python/Mac/Modules/ae Modified Files: _AEmodule.c Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _AEmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ae/_AEmodule.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** _AEmodule.c 4 Jan 2002 13:49:36 -0000 1.9 --- _AEmodule.c 24 Mar 2002 23:04:18 -0000 1.10 *************** *** 99,102 **** --- 99,105 ---- DescType toType; AEDesc result; + #ifndef AECoerceDesc + PyMac_PRECHECK(AECoerceDesc); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &toType)) *************** *** 116,119 **** --- 119,125 ---- OSErr _err; AEDesc result; + #ifndef AEDuplicateDesc + PyMac_PRECHECK(AEDuplicateDesc); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 131,134 **** --- 137,143 ---- OSErr _err; long theCount; + #ifndef AECountItems + PyMac_PRECHECK(AECountItems); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 150,153 **** --- 159,165 ---- long dataPtr__len__; int dataPtr__in_len__; + #ifndef AEPutPtr + PyMac_PRECHECK(AEPutPtr); + #endif if (!PyArg_ParseTuple(_args, "lO&s#", &index, *************** *** 172,175 **** --- 184,190 ---- long index; AEDesc theAEDesc; + #ifndef AEPutDesc + PyMac_PRECHECK(AEPutDesc); + #endif if (!PyArg_ParseTuple(_args, "lO&", &index, *************** *** 196,199 **** --- 211,217 ---- long dataPtr__len__; int dataPtr__in_len__; + #ifndef AEGetNthPtr + PyMac_PRECHECK(AEGetNthPtr); + #endif if (!PyArg_ParseTuple(_args, "lO&i", &index, *************** *** 231,234 **** --- 249,255 ---- AEKeyword theAEKeyword; AEDesc result; + #ifndef AEGetNthDesc + PyMac_PRECHECK(AEGetNthDesc); + #endif if (!PyArg_ParseTuple(_args, "lO&", &index, *************** *** 254,257 **** --- 275,281 ---- DescType typeCode; Size dataSize; + #ifndef AESizeOfNthItem + PyMac_PRECHECK(AESizeOfNthItem); + #endif if (!PyArg_ParseTuple(_args, "l", &index)) *************** *** 273,276 **** --- 297,303 ---- OSErr _err; long index; + #ifndef AEDeleteItem + PyMac_PRECHECK(AEDeleteItem); + #endif if (!PyArg_ParseTuple(_args, "l", &index)) *************** *** 293,296 **** --- 320,326 ---- long dataPtr__len__; int dataPtr__in_len__; + #ifndef AEPutParamPtr + PyMac_PRECHECK(AEPutParamPtr); + #endif if (!PyArg_ParseTuple(_args, "O&O&s#", PyMac_GetOSType, &theAEKeyword, *************** *** 315,318 **** --- 345,351 ---- AEKeyword theAEKeyword; AEDesc theAEDesc; + #ifndef AEPutParamDesc + PyMac_PRECHECK(AEPutParamDesc); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &theAEKeyword, *************** *** 338,341 **** --- 371,377 ---- long dataPtr__len__; int dataPtr__in_len__; + #ifndef AEGetParamPtr + PyMac_PRECHECK(AEGetParamPtr); + #endif if (!PyArg_ParseTuple(_args, "O&O&i", PyMac_GetOSType, &theAEKeyword, *************** *** 370,373 **** --- 406,412 ---- DescType desiredType; AEDesc result; + #ifndef AEGetParamDesc + PyMac_PRECHECK(AEGetParamDesc); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &theAEKeyword, *************** *** 391,394 **** --- 430,436 ---- DescType typeCode; Size dataSize; + #ifndef AESizeOfParam + PyMac_PRECHECK(AESizeOfParam); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &theAEKeyword)) *************** *** 410,413 **** --- 452,458 ---- OSErr _err; AEKeyword theAEKeyword; + #ifndef AEDeleteParam + PyMac_PRECHECK(AEDeleteParam); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &theAEKeyword)) *************** *** 431,434 **** --- 476,482 ---- long dataPtr__len__; int dataPtr__in_len__; + #ifndef AEGetAttributePtr + PyMac_PRECHECK(AEGetAttributePtr); + #endif if (!PyArg_ParseTuple(_args, "O&O&i", PyMac_GetOSType, &theAEKeyword, *************** *** 463,466 **** --- 511,517 ---- DescType desiredType; AEDesc result; + #ifndef AEGetAttributeDesc + PyMac_PRECHECK(AEGetAttributeDesc); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &theAEKeyword, *************** *** 484,487 **** --- 535,541 ---- DescType typeCode; Size dataSize; + #ifndef AESizeOfAttribute + PyMac_PRECHECK(AESizeOfAttribute); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &theAEKeyword)) *************** *** 507,510 **** --- 561,567 ---- long dataPtr__len__; int dataPtr__in_len__; + #ifndef AEPutAttributePtr + PyMac_PRECHECK(AEPutAttributePtr); + #endif if (!PyArg_ParseTuple(_args, "O&O&s#", PyMac_GetOSType, &theAEKeyword, *************** *** 529,532 **** --- 586,592 ---- AEKeyword theAEKeyword; AEDesc theAEDesc; + #ifndef AEPutAttributeDesc + PyMac_PRECHECK(AEPutAttributeDesc); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &theAEKeyword, *************** *** 548,551 **** --- 608,614 ---- PyObject *_res = NULL; Size _rv; + #ifndef AEGetDescDataSize + PyMac_PRECHECK(AEGetDescDataSize); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 565,568 **** --- 628,634 ---- AESendPriority sendPriority; long timeOutInTicks; + #ifndef AESend + PyMac_PRECHECK(AESend); + #endif if (!PyArg_ParseTuple(_args, "lhl", &sendMode, *************** *** 587,590 **** --- 653,659 ---- PyObject *_res = NULL; OSErr _err; + #ifndef AEResetTimer + PyMac_PRECHECK(AEResetTimer); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 600,603 **** --- 669,675 ---- PyObject *_res = NULL; OSErr _err; + #ifndef AESuspendTheCurrentEvent + PyMac_PRECHECK(AESuspendTheCurrentEvent); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 616,619 **** --- 688,694 ---- AEEventHandlerUPP dispatcher__proc__ = upp_GenericEventHandler; PyObject *dispatcher; + #ifndef AEResumeTheCurrentEvent + PyMac_PRECHECK(AEResumeTheCurrentEvent); + #endif if (!PyArg_ParseTuple(_args, "O&O", AEDesc_Convert, &reply, *************** *** 634,637 **** --- 709,715 ---- PyObject *_res = NULL; OSErr _err; + #ifndef AEGetTheCurrentEvent + PyMac_PRECHECK(AEGetTheCurrentEvent); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 647,650 **** --- 725,731 ---- PyObject *_res = NULL; OSErr _err; + #ifndef AESetTheCurrentEvent + PyMac_PRECHECK(AESetTheCurrentEvent); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 662,665 **** --- 743,749 ---- short callbackFlags; AEDesc theToken; + #ifndef AEResolve + PyMac_PRECHECK(AEResolve); + #endif if (!PyArg_ParseTuple(_args, "h", &callbackFlags)) *************** *** 816,819 **** --- 900,906 ---- DescType toType; AEDesc result; + #ifndef AECoercePtr + PyMac_PRECHECK(AECoercePtr); + #endif if (!PyArg_ParseTuple(_args, "O&s#O&", PyMac_GetOSType, &typeCode, *************** *** 841,844 **** --- 928,934 ---- int dataPtr__in_len__; AEDesc result; + #ifndef AECreateDesc + PyMac_PRECHECK(AECreateDesc); + #endif if (!PyArg_ParseTuple(_args, "O&s#", PyMac_GetOSType, &typeCode, *************** *** 864,867 **** --- 954,960 ---- Boolean isRecord; AEDescList resultList; + #ifndef AECreateList + PyMac_PRECHECK(AECreateList); + #endif if (!PyArg_ParseTuple(_args, "s#b", &factoringPtr__in__, &factoringPtr__in_len__, *************** *** 888,891 **** --- 981,987 ---- AETransactionID transactionID; AppleEvent result; + #ifndef AECreateAppleEvent + PyMac_PRECHECK(AECreateAppleEvent); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&hl", PyMac_GetOSType, &theAEEventClass, *************** *** 918,921 **** --- 1014,1020 ---- int dataPtr__in_len__; AEDesc theAEDesc; + #ifndef AEReplaceDescData + PyMac_PRECHECK(AEReplaceDescData); + #endif if (!PyArg_ParseTuple(_args, "O&s#", PyMac_GetOSType, &typeCode, *************** *** 938,941 **** --- 1037,1043 ---- OSErr _err; EventRecord theEventRecord; + #ifndef AEProcessAppleEvent + PyMac_PRECHECK(AEProcessAppleEvent); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetEventRecord, &theEventRecord)) *************** *** 953,956 **** --- 1055,1061 ---- OSErr _err; AEInteractAllowed level; + #ifndef AEGetInteractionAllowed + PyMac_PRECHECK(AEGetInteractionAllowed); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 967,970 **** --- 1072,1078 ---- OSErr _err; AEInteractAllowed level; + #ifndef AESetInteractionAllowed + PyMac_PRECHECK(AESetInteractionAllowed); + #endif if (!PyArg_ParseTuple(_args, "b", &level)) *************** *** 982,985 **** --- 1090,1096 ---- OSErr _err; long timeOutInTicks; + #ifndef AEInteractWithUser + PyMac_PRECHECK(AEInteractWithUser); + #endif if (!PyArg_ParseTuple(_args, "l", &timeOutInTicks)) *************** *** 1002,1005 **** --- 1113,1119 ---- AEEventHandlerUPP handler__proc__ = upp_GenericEventHandler; PyObject *handler; + #ifndef AEInstallEventHandler + PyMac_PRECHECK(AEInstallEventHandler); + #endif if (!PyArg_ParseTuple(_args, "O&O&O", PyMac_GetOSType, &theAEEventClass, *************** *** 1024,1027 **** --- 1138,1144 ---- AEEventClass theAEEventClass; AEEventID theAEEventID; + #ifndef AERemoveEventHandler + PyMac_PRECHECK(AERemoveEventHandler); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &theAEEventClass, *************** *** 1046,1049 **** --- 1163,1169 ---- AEEventHandlerUPP handler__proc__ = upp_GenericEventHandler; PyObject *handler; + #ifndef AEGetEventHandler + PyMac_PRECHECK(AEGetEventHandler); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &theAEEventClass, *************** *** 1066,1069 **** --- 1186,1192 ---- OSErr _err; AEKeyword functionClass; + #ifndef AEInstallSpecialHandler + PyMac_PRECHECK(AEInstallSpecialHandler); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &functionClass)) *************** *** 1083,1086 **** --- 1206,1212 ---- OSErr _err; AEKeyword functionClass; + #ifndef AERemoveSpecialHandler + PyMac_PRECHECK(AERemoveSpecialHandler); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &functionClass)) *************** *** 1101,1104 **** --- 1227,1233 ---- AEKeyword keyWord; long result; + #ifndef AEManagerInfo + PyMac_PRECHECK(AEManagerInfo); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &keyWord)) *************** *** 1116,1119 **** --- 1245,1251 ---- PyObject *_res = NULL; OSErr _err; + #ifndef AEObjectInit + PyMac_PRECHECK(AEObjectInit); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 1130,1133 **** --- 1262,1268 ---- OSErr _err; AEDesc theToken; + #ifndef AEDisposeToken + PyMac_PRECHECK(AEDisposeToken); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 1149,1152 **** --- 1284,1290 ---- AEDesc keyData; AEDesc token; + #ifndef AECallObjectAccessor + PyMac_PRECHECK(AECallObjectAccessor); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&O&O&", PyMac_GetOSType, &desiredClass, From nascheme@users.sourceforge.net Sun Mar 24 23:11:23 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Sun, 24 Mar 2002 15:11:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib pydoc.py,1.59,1.60 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv31371/Lib Modified Files: pydoc.py Log Message: Quote href properly. Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** pydoc.py 24 Mar 2002 23:02:07 -0000 1.59 --- pydoc.py 24 Mar 2002 23:11:21 -0000 1.60 *************** *** 451,455 **** all, scheme, rfc, pep, selfdot, name = match.groups() if scheme: ! results.append('%s' % (all, escape(all))) elif rfc: url = 'http://www.rfc-editor.org/rfc/rfc%d.txt' % int(rfc) --- 451,456 ---- all, scheme, rfc, pep, selfdot, name = match.groups() if scheme: ! url = escape(all).replace('"', '"') ! results.append('%s' % (url, url)) elif rfc: url = 'http://www.rfc-editor.org/rfc/rfc%d.txt' % int(rfc) From jackjansen@users.sourceforge.net Mon Mar 25 00:31:40 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 16:31:40 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/qdoffs qdoffssupport.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/qdoffs In directory usw-pr-cvs1:/tmp/cvs-serv22319/Python/Mac/Modules/qdoffs Modified Files: qdoffssupport.py Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Index: qdoffssupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/qdoffs/qdoffssupport.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** qdoffssupport.py 5 Sep 2001 10:31:22 -0000 1.7 --- qdoffssupport.py 25 Mar 2002 00:31:38 -0000 1.8 *************** *** 84,89 **** # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator ! Method = OSErrMethodGenerator # Create and populate the lists --- 84,89 ---- # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator ! Method = OSErrWeakLinkMethodGenerator # Create and populate the lists From jackjansen@users.sourceforge.net Mon Mar 25 00:31:47 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 16:31:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/qd qdsupport.py,1.37,1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/qd In directory usw-pr-cvs1:/tmp/cvs-serv22351/Python/Mac/Modules/qd Modified Files: qdsupport.py Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Index: qdsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/qd/qdsupport.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** qdsupport.py 18 Dec 2001 15:39:23 -0000 1.37 --- qdsupport.py 25 Mar 2002 00:31:45 -0000 1.38 *************** *** 549,554 **** # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator ! Method = OSErrMethodGenerator # Create and populate the lists --- 549,554 ---- # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator ! Method = OSErrWeakLinkMethodGenerator # Create and populate the lists From jackjansen@users.sourceforge.net Mon Mar 25 00:31:29 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 16:31:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/te tesupport.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/te In directory usw-pr-cvs1:/tmp/cvs-serv22262/Python/Mac/Modules/te Modified Files: tesupport.py Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Index: tesupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/te/tesupport.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tesupport.py 23 Aug 2001 13:51:33 -0000 1.9 --- tesupport.py 25 Mar 2002 00:31:27 -0000 1.10 *************** *** 80,84 **** """ ! class TEMethodGenerator(OSErrMethodGenerator): """Similar to MethodGenerator, but has self as last argument""" --- 80,84 ---- """ ! class TEMethodGenerator(OSErrWeakLinkMethodGenerator): """Similar to MethodGenerator, but has self as last argument""" *************** *** 151,155 **** # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator Method = TEMethodGenerator --- 151,155 ---- # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator Method = TEMethodGenerator From jackjansen@users.sourceforge.net Mon Mar 25 00:31:35 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 16:31:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/qt qtsupport.py,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/qt In directory usw-pr-cvs1:/tmp/cvs-serv22286/Python/Mac/Modules/qt Modified Files: qtsupport.py Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Index: qtsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/qt/qtsupport.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** qtsupport.py 23 Aug 2001 13:50:27 -0000 1.18 --- qtsupport.py 25 Mar 2002 00:31:32 -0000 1.19 *************** *** 255,260 **** # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator ! Method = OSErrMethodGenerator # Create and populate the lists --- 255,260 ---- # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator ! Method = OSErrWeakLinkMethodGenerator # Create and populate the lists From jackjansen@users.sourceforge.net Mon Mar 25 00:31:51 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 16:31:51 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/icn icnsupport.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/icn In directory usw-pr-cvs1:/tmp/cvs-serv22388/Python/Mac/Modules/icn Modified Files: icnsupport.py Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Index: icnsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/icn/icnsupport.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** icnsupport.py 23 Aug 2001 13:49:36 -0000 1.6 --- icnsupport.py 25 Mar 2002 00:31:49 -0000 1.7 *************** *** 76,80 **** # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator ##Method = OSErrMethodGenerator --- 76,80 ---- # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator ##Method = OSErrMethodGenerator From jackjansen@users.sourceforge.net Mon Mar 25 00:31:56 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 16:31:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/fm fmsupport.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/fm In directory usw-pr-cvs1:/tmp/cvs-serv22415/Python/Mac/Modules/fm Modified Files: fmsupport.py Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Index: fmsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/fm/fmsupport.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** fmsupport.py 7 Jan 2002 14:15:02 -0000 1.5 --- fmsupport.py 25 Mar 2002 00:31:53 -0000 1.6 *************** *** 71,75 **** # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator # Create and populate the lists --- 71,75 ---- # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator # Create and populate the lists From jackjansen@users.sourceforge.net Mon Mar 25 00:32:15 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 16:32:15 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/cm cmsupport.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cm In directory usw-pr-cvs1:/tmp/cvs-serv22515/Python/Mac/Modules/cm Modified Files: cmsupport.py Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Index: cmsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cm/cmsupport.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** cmsupport.py 23 Aug 2001 13:48:02 -0000 1.5 --- cmsupport.py 25 Mar 2002 00:32:13 -0000 1.6 *************** *** 110,115 **** # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator ! Method = OSErrMethodGenerator # Create and populate the lists --- 110,115 ---- # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator ! Method = OSErrWeakLinkMethodGenerator # Create and populate the lists From jackjansen@users.sourceforge.net Mon Mar 25 00:32:01 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 16:32:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/evt evtsupport.py,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/evt In directory usw-pr-cvs1:/tmp/cvs-serv22441/Python/Mac/Modules/evt Modified Files: evtsupport.py Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Index: evtsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/evt/evtsupport.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** evtsupport.py 17 Dec 2001 11:46:50 -0000 1.14 --- evtsupport.py 25 Mar 2002 00:31:58 -0000 1.15 *************** *** 65,70 **** # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator ! ##Method = OSErrMethodGenerator # Create and populate the lists --- 65,70 ---- # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator ! ##Method = OSErrWeakLinkMethodGenerator # Create and populate the lists From jackjansen@users.sourceforge.net Mon Mar 25 00:32:06 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 16:32:06 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/drag dragsupport.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/drag In directory usw-pr-cvs1:/tmp/cvs-serv22484/Python/Mac/Modules/drag Modified Files: dragsupport.py Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Index: dragsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/drag/dragsupport.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** dragsupport.py 4 Jan 2002 14:39:29 -0000 1.9 --- dragsupport.py 25 Mar 2002 00:32:04 -0000 1.10 *************** *** 215,220 **** # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator ! Method = OSErrMethodGenerator # Create and populate the lists --- 215,220 ---- # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator ! Method = OSErrWeakLinkMethodGenerator # Create and populate the lists From jackjansen@users.sourceforge.net Mon Mar 25 00:32:19 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 24 Mar 2002 16:32:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/ae aesupport.py,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/ae In directory usw-pr-cvs1:/tmp/cvs-serv22546/Python/Mac/Modules/ae Modified Files: aesupport.py Log Message: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Index: aesupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ae/aesupport.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** aesupport.py 4 Jan 2002 13:49:36 -0000 1.25 --- aesupport.py 25 Mar 2002 00:32:17 -0000 1.26 *************** *** 78,83 **** ! AEFunction = OSErrFunctionGenerator ! AEMethod = OSErrMethodGenerator --- 78,83 ---- ! AEFunction = OSErrWeakLinkFunctionGenerator ! AEMethod = OSErrWeakLinkMethodGenerator From bwarsaw@users.sourceforge.net Mon Mar 25 04:00:40 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Sun, 24 Mar 2002 20:00:40 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib smtplib.py,1.49,1.50 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv30218 Modified Files: smtplib.py Log Message: SMTP.__init__(): Fixed minor typo in docstring. Index: smtplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** smtplib.py 24 Mar 2002 15:30:40 -0000 1.49 --- smtplib.py 25 Mar 2002 04:00:38 -0000 1.50 *************** *** 229,233 **** if the specified `host' doesn't respond correctly. If specified, `local_hostname` is used as the FQDN of the local host. By default, ! the local hostname is found using gethostbyname(). """ --- 229,233 ---- if the specified `host' doesn't respond correctly. If specified, `local_hostname` is used as the FQDN of the local host. By default, ! the local hostname is found using socket.getfqdn(). """ From tim_one@users.sourceforge.net Mon Mar 25 06:49:12 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 24 Mar 2002 22:49:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python thread.c,2.41,2.42 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv24255/python/Python Modified Files: thread.c Log Message: I've been waiting 8 years for KSR to re-emerge from bankruptcy. If they ever do, they can damn well #define _POSIX_THREADS their own damn selves. Index: thread.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread.c,v retrieving revision 2.41 retrieving revision 2.42 diff -C2 -d -r2.41 -r2.42 *** thread.c 9 Mar 2002 12:10:54 -0000 2.41 --- thread.c 25 Mar 2002 06:49:10 -0000 2.42 *************** *** 37,44 **** #include "pythread.h" - #ifdef __ksr__ - #define _POSIX_THREADS - #endif - #ifndef _POSIX_THREADS --- 37,40 ---- From tim_one@users.sourceforge.net Mon Mar 25 06:55:59 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sun, 24 Mar 2002 22:55:59 -0800 Subject: [Python-checkins] CVS: python/dist/src/Demo/threads README,1.8,1.9 bug.py,1.2,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Demo/threads In directory usw-pr-cvs1:/tmp/cvs-serv24982 Modified Files: README Removed Files: bug.py Log Message: Remove bug.py. This is something I sent to Guido via email in or before '94, demonstrating a thread bug that was later repaired via Python growing an internal import lock. It's of no current interest, and the now-std test_threaded_import.py is pretty much the same test. Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/threads/README,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** README 8 Nov 2000 15:17:49 -0000 1.8 --- README 25 Mar 2002 06:55:57 -0000 1.9 *************** *** 4,8 **** Generator.py Generator class implemented with threads. - bug.py Demonstrate a bug with importing modules in threads. find.py Parallelized "find(1)" (looks for directories). sync.py Condition variables primitives by Tim Peters. --- 4,7 ---- --- bug.py DELETED --- From jackjansen@users.sourceforge.net Mon Mar 25 10:21:44 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 25 Mar 2002 02:21:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/ae _AEmodule.c,1.8.4.1,1.8.4.2 aesupport.py,1.24.14.1,1.24.14.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/ae In directory usw-pr-cvs1:/tmp/cvs-serv28061 Modified Files: Tag: release22-maint _AEmodule.c aesupport.py Log Message: Backport of _AEmodule.c 1.10 and aesupport.py 1.26: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, inAlso blacklisted some constants with definitions that were not Python-compatible. Index: _AEmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ae/_AEmodule.c,v retrieving revision 1.8.4.1 retrieving revision 1.8.4.2 diff -C2 -d -r1.8.4.1 -r1.8.4.2 *** _AEmodule.c 24 Feb 2002 22:57:48 -0000 1.8.4.1 --- _AEmodule.c 25 Mar 2002 10:21:42 -0000 1.8.4.2 *************** *** 99,102 **** --- 99,105 ---- DescType toType; AEDesc result; + #ifndef AECoerceDesc + PyMac_PRECHECK(AECoerceDesc); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &toType)) *************** *** 116,119 **** --- 119,125 ---- OSErr _err; AEDesc result; + #ifndef AEDuplicateDesc + PyMac_PRECHECK(AEDuplicateDesc); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 131,134 **** --- 137,143 ---- OSErr _err; long theCount; + #ifndef AECountItems + PyMac_PRECHECK(AECountItems); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 150,153 **** --- 159,165 ---- long dataPtr__len__; int dataPtr__in_len__; + #ifndef AEPutPtr + PyMac_PRECHECK(AEPutPtr); + #endif if (!PyArg_ParseTuple(_args, "lO&s#", &index, *************** *** 172,175 **** --- 184,190 ---- long index; AEDesc theAEDesc; + #ifndef AEPutDesc + PyMac_PRECHECK(AEPutDesc); + #endif if (!PyArg_ParseTuple(_args, "lO&", &index, *************** *** 196,199 **** --- 211,217 ---- long dataPtr__len__; int dataPtr__in_len__; + #ifndef AEGetNthPtr + PyMac_PRECHECK(AEGetNthPtr); + #endif if (!PyArg_ParseTuple(_args, "lO&i", &index, *************** *** 231,234 **** --- 249,255 ---- AEKeyword theAEKeyword; AEDesc result; + #ifndef AEGetNthDesc + PyMac_PRECHECK(AEGetNthDesc); + #endif if (!PyArg_ParseTuple(_args, "lO&", &index, *************** *** 254,257 **** --- 275,281 ---- DescType typeCode; Size dataSize; + #ifndef AESizeOfNthItem + PyMac_PRECHECK(AESizeOfNthItem); + #endif if (!PyArg_ParseTuple(_args, "l", &index)) *************** *** 273,276 **** --- 297,303 ---- OSErr _err; long index; + #ifndef AEDeleteItem + PyMac_PRECHECK(AEDeleteItem); + #endif if (!PyArg_ParseTuple(_args, "l", &index)) *************** *** 293,296 **** --- 320,326 ---- long dataPtr__len__; int dataPtr__in_len__; + #ifndef AEPutParamPtr + PyMac_PRECHECK(AEPutParamPtr); + #endif if (!PyArg_ParseTuple(_args, "O&O&s#", PyMac_GetOSType, &theAEKeyword, *************** *** 315,318 **** --- 345,351 ---- AEKeyword theAEKeyword; AEDesc theAEDesc; + #ifndef AEPutParamDesc + PyMac_PRECHECK(AEPutParamDesc); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &theAEKeyword, *************** *** 338,341 **** --- 371,377 ---- long dataPtr__len__; int dataPtr__in_len__; + #ifndef AEGetParamPtr + PyMac_PRECHECK(AEGetParamPtr); + #endif if (!PyArg_ParseTuple(_args, "O&O&i", PyMac_GetOSType, &theAEKeyword, *************** *** 370,373 **** --- 406,412 ---- DescType desiredType; AEDesc result; + #ifndef AEGetParamDesc + PyMac_PRECHECK(AEGetParamDesc); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &theAEKeyword, *************** *** 391,394 **** --- 430,436 ---- DescType typeCode; Size dataSize; + #ifndef AESizeOfParam + PyMac_PRECHECK(AESizeOfParam); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &theAEKeyword)) *************** *** 410,413 **** --- 452,458 ---- OSErr _err; AEKeyword theAEKeyword; + #ifndef AEDeleteParam + PyMac_PRECHECK(AEDeleteParam); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &theAEKeyword)) *************** *** 431,434 **** --- 476,482 ---- long dataPtr__len__; int dataPtr__in_len__; + #ifndef AEGetAttributePtr + PyMac_PRECHECK(AEGetAttributePtr); + #endif if (!PyArg_ParseTuple(_args, "O&O&i", PyMac_GetOSType, &theAEKeyword, *************** *** 463,466 **** --- 511,517 ---- DescType desiredType; AEDesc result; + #ifndef AEGetAttributeDesc + PyMac_PRECHECK(AEGetAttributeDesc); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &theAEKeyword, *************** *** 484,487 **** --- 535,541 ---- DescType typeCode; Size dataSize; + #ifndef AESizeOfAttribute + PyMac_PRECHECK(AESizeOfAttribute); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &theAEKeyword)) *************** *** 507,510 **** --- 561,567 ---- long dataPtr__len__; int dataPtr__in_len__; + #ifndef AEPutAttributePtr + PyMac_PRECHECK(AEPutAttributePtr); + #endif if (!PyArg_ParseTuple(_args, "O&O&s#", PyMac_GetOSType, &theAEKeyword, *************** *** 529,532 **** --- 586,592 ---- AEKeyword theAEKeyword; AEDesc theAEDesc; + #ifndef AEPutAttributeDesc + PyMac_PRECHECK(AEPutAttributeDesc); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &theAEKeyword, *************** *** 548,551 **** --- 608,614 ---- PyObject *_res = NULL; Size _rv; + #ifndef AEGetDescDataSize + PyMac_PRECHECK(AEGetDescDataSize); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 565,568 **** --- 628,634 ---- AESendPriority sendPriority; long timeOutInTicks; + #ifndef AESend + PyMac_PRECHECK(AESend); + #endif if (!PyArg_ParseTuple(_args, "lhl", &sendMode, *************** *** 587,590 **** --- 653,659 ---- PyObject *_res = NULL; OSErr _err; + #ifndef AEResetTimer + PyMac_PRECHECK(AEResetTimer); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 600,603 **** --- 669,675 ---- PyObject *_res = NULL; OSErr _err; + #ifndef AESuspendTheCurrentEvent + PyMac_PRECHECK(AESuspendTheCurrentEvent); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 616,619 **** --- 688,694 ---- AEEventHandlerUPP dispatcher__proc__ = upp_GenericEventHandler; PyObject *dispatcher; + #ifndef AEResumeTheCurrentEvent + PyMac_PRECHECK(AEResumeTheCurrentEvent); + #endif if (!PyArg_ParseTuple(_args, "O&O", AEDesc_Convert, &reply, *************** *** 634,637 **** --- 709,715 ---- PyObject *_res = NULL; OSErr _err; + #ifndef AEGetTheCurrentEvent + PyMac_PRECHECK(AEGetTheCurrentEvent); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 647,650 **** --- 725,731 ---- PyObject *_res = NULL; OSErr _err; + #ifndef AESetTheCurrentEvent + PyMac_PRECHECK(AESetTheCurrentEvent); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 662,665 **** --- 743,749 ---- short callbackFlags; AEDesc theToken; + #ifndef AEResolve + PyMac_PRECHECK(AEResolve); + #endif if (!PyArg_ParseTuple(_args, "h", &callbackFlags)) *************** *** 816,819 **** --- 900,906 ---- DescType toType; AEDesc result; + #ifndef AECoercePtr + PyMac_PRECHECK(AECoercePtr); + #endif if (!PyArg_ParseTuple(_args, "O&s#O&", PyMac_GetOSType, &typeCode, *************** *** 841,844 **** --- 928,934 ---- int dataPtr__in_len__; AEDesc result; + #ifndef AECreateDesc + PyMac_PRECHECK(AECreateDesc); + #endif if (!PyArg_ParseTuple(_args, "O&s#", PyMac_GetOSType, &typeCode, *************** *** 864,867 **** --- 954,960 ---- Boolean isRecord; AEDescList resultList; + #ifndef AECreateList + PyMac_PRECHECK(AECreateList); + #endif if (!PyArg_ParseTuple(_args, "s#b", &factoringPtr__in__, &factoringPtr__in_len__, *************** *** 888,891 **** --- 981,987 ---- AETransactionID transactionID; AppleEvent result; + #ifndef AECreateAppleEvent + PyMac_PRECHECK(AECreateAppleEvent); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&hl", PyMac_GetOSType, &theAEEventClass, *************** *** 918,921 **** --- 1014,1020 ---- int dataPtr__in_len__; AEDesc theAEDesc; + #ifndef AEReplaceDescData + PyMac_PRECHECK(AEReplaceDescData); + #endif if (!PyArg_ParseTuple(_args, "O&s#", PyMac_GetOSType, &typeCode, *************** *** 938,941 **** --- 1037,1043 ---- OSErr _err; EventRecord theEventRecord; + #ifndef AEProcessAppleEvent + PyMac_PRECHECK(AEProcessAppleEvent); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetEventRecord, &theEventRecord)) *************** *** 953,956 **** --- 1055,1061 ---- OSErr _err; AEInteractAllowed level; + #ifndef AEGetInteractionAllowed + PyMac_PRECHECK(AEGetInteractionAllowed); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 967,970 **** --- 1072,1078 ---- OSErr _err; AEInteractAllowed level; + #ifndef AESetInteractionAllowed + PyMac_PRECHECK(AESetInteractionAllowed); + #endif if (!PyArg_ParseTuple(_args, "b", &level)) *************** *** 982,985 **** --- 1090,1096 ---- OSErr _err; long timeOutInTicks; + #ifndef AEInteractWithUser + PyMac_PRECHECK(AEInteractWithUser); + #endif if (!PyArg_ParseTuple(_args, "l", &timeOutInTicks)) *************** *** 1002,1005 **** --- 1113,1119 ---- AEEventHandlerUPP handler__proc__ = upp_GenericEventHandler; PyObject *handler; + #ifndef AEInstallEventHandler + PyMac_PRECHECK(AEInstallEventHandler); + #endif if (!PyArg_ParseTuple(_args, "O&O&O", PyMac_GetOSType, &theAEEventClass, *************** *** 1024,1027 **** --- 1138,1144 ---- AEEventClass theAEEventClass; AEEventID theAEEventID; + #ifndef AERemoveEventHandler + PyMac_PRECHECK(AERemoveEventHandler); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &theAEEventClass, *************** *** 1046,1049 **** --- 1163,1169 ---- AEEventHandlerUPP handler__proc__ = upp_GenericEventHandler; PyObject *handler; + #ifndef AEGetEventHandler + PyMac_PRECHECK(AEGetEventHandler); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &theAEEventClass, *************** *** 1066,1069 **** --- 1186,1192 ---- OSErr _err; AEKeyword functionClass; + #ifndef AEInstallSpecialHandler + PyMac_PRECHECK(AEInstallSpecialHandler); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &functionClass)) *************** *** 1083,1086 **** --- 1206,1212 ---- OSErr _err; AEKeyword functionClass; + #ifndef AERemoveSpecialHandler + PyMac_PRECHECK(AERemoveSpecialHandler); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &functionClass)) *************** *** 1101,1104 **** --- 1227,1233 ---- AEKeyword keyWord; long result; + #ifndef AEManagerInfo + PyMac_PRECHECK(AEManagerInfo); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &keyWord)) *************** *** 1116,1119 **** --- 1245,1251 ---- PyObject *_res = NULL; OSErr _err; + #ifndef AEObjectInit + PyMac_PRECHECK(AEObjectInit); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 1130,1133 **** --- 1262,1268 ---- OSErr _err; AEDesc theToken; + #ifndef AEDisposeToken + PyMac_PRECHECK(AEDisposeToken); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 1149,1152 **** --- 1284,1290 ---- AEDesc keyData; AEDesc token; + #ifndef AECallObjectAccessor + PyMac_PRECHECK(AECallObjectAccessor); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&O&O&", PyMac_GetOSType, &desiredClass, Index: aesupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ae/aesupport.py,v retrieving revision 1.24.14.1 retrieving revision 1.24.14.2 diff -C2 -d -r1.24.14.1 -r1.24.14.2 *** aesupport.py 27 Feb 2002 22:48:37 -0000 1.24.14.1 --- aesupport.py 25 Mar 2002 10:21:42 -0000 1.24.14.2 *************** *** 78,83 **** ! AEFunction = OSErrFunctionGenerator ! AEMethod = OSErrMethodGenerator --- 78,83 ---- ! AEFunction = OSErrWeakLinkFunctionGenerator ! AEMethod = OSErrWeakLinkMethodGenerator From jackjansen@users.sourceforge.net Mon Mar 25 10:23:58 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 25 Mar 2002 02:23:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/cf cfscan.py,1.5.18.1,1.5.18.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cf In directory usw-pr-cvs1:/tmp/cvs-serv28785 Modified Files: Tag: release22-maint cfscan.py Log Message: Backport of 1.7: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, inAlso blacklisted some constants with definitions that were not Python-compatible. Index: cfscan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/cfscan.py,v retrieving revision 1.5.18.1 retrieving revision 1.5.18.2 diff -C2 -d -r1.5.18.1 -r1.5.18.2 *** cfscan.py 27 Feb 2002 23:10:01 -0000 1.5.18.1 --- cfscan.py 25 Mar 2002 10:23:56 -0000 1.5.18.2 *************** *** 96,99 **** --- 96,100 ---- "CFStringSetExternalCharactersNoCopy", "CFStringGetCharacterAtIndex", # No format for single unichars yet. + "kCFStringEncodingInvalidId", # incompatible constant declaration ] From jackjansen@users.sourceforge.net Mon Mar 25 10:25:59 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 25 Mar 2002 02:25:59 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/win winscan.py,1.19,1.19.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/win In directory usw-pr-cvs1:/tmp/cvs-serv29032 Modified Files: Tag: release22-maint winscan.py Log Message: Backport of 1.20: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: winscan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/win/winscan.py,v retrieving revision 1.19 retrieving revision 1.19.4.1 diff -C2 -d -r1.19 -r1.19.4.1 *** winscan.py 18 Dec 2001 15:38:54 -0000 1.19 --- winscan.py 25 Mar 2002 10:25:56 -0000 1.19.4.1 *************** *** 33,36 **** --- 33,38 ---- def writeinitialdefs(self): self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") + self.defsfile.write("false = 0\n") + self.defsfile.write("true = 1\n") def makeblacklistnames(self): From jackjansen@users.sourceforge.net Mon Mar 25 10:30:38 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 25 Mar 2002 02:30:38 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/app _Appmodule.c,1.5.4.1,1.5.4.2 appsupport.py,1.9.4.1,1.9.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/app In directory usw-pr-cvs1:/tmp/cvs-serv30623 Modified Files: Tag: release22-maint _Appmodule.c appsupport.py Log Message: Backport of _Appmodule.c 1.10, appsupport.py 1.14: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _Appmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/app/_Appmodule.c,v retrieving revision 1.5.4.1 retrieving revision 1.5.4.2 diff -C2 -d -r1.5.4.1 -r1.5.4.2 *** _Appmodule.c 27 Feb 2002 23:07:46 -0000 1.5.4.1 --- _Appmodule.c 25 Mar 2002 10:30:36 -0000 1.5.4.2 *************** *** 78,81 **** --- 78,84 ---- OSStatus _rv; Boolean inDisposeNow; + #ifndef SetThemeDrawingState + PyMac_PRECHECK(SetThemeDrawingState); + #endif if (!PyArg_ParseTuple(_args, "b", &inDisposeNow)) *************** *** 92,95 **** --- 95,101 ---- PyObject *_res = NULL; OSStatus _rv; + #ifndef DisposeThemeDrawingState + PyMac_PRECHECK(DisposeThemeDrawingState); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 149,152 **** --- 155,161 ---- PyObject *_res = NULL; OSStatus _err; + #ifndef RegisterAppearanceClient + PyMac_PRECHECK(RegisterAppearanceClient); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 162,165 **** --- 171,177 ---- PyObject *_res = NULL; OSStatus _err; + #ifndef UnregisterAppearanceClient + PyMac_PRECHECK(UnregisterAppearanceClient); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 178,181 **** --- 190,196 ---- SInt16 inDepth; Boolean inIsColorDevice; + #ifndef SetThemePen + PyMac_PRECHECK(SetThemePen); + #endif if (!PyArg_ParseTuple(_args, "hhb", &inBrush, *************** *** 199,202 **** --- 214,220 ---- SInt16 inDepth; Boolean inIsColorDevice; + #ifndef SetThemeBackground + PyMac_PRECHECK(SetThemeBackground); + #endif if (!PyArg_ParseTuple(_args, "hhb", &inBrush, *************** *** 220,223 **** --- 238,244 ---- SInt16 inDepth; Boolean inIsColorDevice; + #ifndef SetThemeTextColor + PyMac_PRECHECK(SetThemeTextColor); + #endif if (!PyArg_ParseTuple(_args, "hhb", &inColor, *************** *** 241,244 **** --- 262,268 ---- ThemeBrush inBrush; Boolean inUpdate; + #ifndef SetThemeWindowBackground + PyMac_PRECHECK(SetThemeWindowBackground); + #endif if (!PyArg_ParseTuple(_args, "O&hb", WinObj_Convert, &inWindow, *************** *** 261,264 **** --- 285,291 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemeWindowHeader + PyMac_PRECHECK(DrawThemeWindowHeader); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 279,282 **** --- 306,312 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemeWindowListViewHeader + PyMac_PRECHECK(DrawThemeWindowListViewHeader); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 297,300 **** --- 327,333 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemePlacard + PyMac_PRECHECK(DrawThemePlacard); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 315,318 **** --- 348,354 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemeEditTextFrame + PyMac_PRECHECK(DrawThemeEditTextFrame); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 333,336 **** --- 369,375 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemeListBoxFrame + PyMac_PRECHECK(DrawThemeListBoxFrame); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 351,354 **** --- 390,396 ---- Rect inRect; Boolean inHasFocus; + #ifndef DrawThemeFocusRect + PyMac_PRECHECK(DrawThemeFocusRect); + #endif if (!PyArg_ParseTuple(_args, "O&b", PyMac_GetRect, &inRect, *************** *** 369,372 **** --- 411,417 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemePrimaryGroup + PyMac_PRECHECK(DrawThemePrimaryGroup); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 387,390 **** --- 432,438 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemeSecondaryGroup + PyMac_PRECHECK(DrawThemeSecondaryGroup); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 405,408 **** --- 453,459 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemeSeparator + PyMac_PRECHECK(DrawThemeSeparator); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 423,426 **** --- 474,480 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemeModelessDialogFrame + PyMac_PRECHECK(DrawThemeModelessDialogFrame); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 442,445 **** --- 496,502 ---- ThemeDrawState inState; Boolean inFillCenter; + #ifndef DrawThemeGenericWell + PyMac_PRECHECK(DrawThemeGenericWell); + #endif if (!PyArg_ParseTuple(_args, "O&lb", PyMac_GetRect, &inRect, *************** *** 461,464 **** --- 518,524 ---- OSStatus _err; Boolean inHasFocus; + #ifndef DrawThemeFocusRegion + PyMac_PRECHECK(DrawThemeFocusRegion); + #endif if (!PyArg_ParseTuple(_args, "b", &inHasFocus)) *************** *** 478,481 **** --- 538,544 ---- SInt16 inDepth; Boolean inIsColorDevice; + #ifndef IsThemeInColor + PyMac_PRECHECK(IsThemeInColor); + #endif if (!PyArg_ParseTuple(_args, "hb", &inDepth, *************** *** 494,497 **** --- 557,563 ---- OSStatus _err; CTabHandle outColors; + #ifndef GetThemeAccentColors + PyMac_PRECHECK(GetThemeAccentColors); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 510,513 **** --- 576,582 ---- ThemeMenuBarState inState; UInt32 inAttributes; + #ifndef DrawThemeMenuBarBackground + PyMac_PRECHECK(DrawThemeMenuBarBackground); + #endif if (!PyArg_ParseTuple(_args, "O&Hl", PyMac_GetRect, &inBounds, *************** *** 529,532 **** --- 598,604 ---- OSStatus _err; SInt16 outHeight; + #ifndef GetThemeMenuBarHeight + PyMac_PRECHECK(GetThemeMenuBarHeight); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 544,547 **** --- 616,622 ---- Rect inMenuRect; ThemeMenuType inMenuType; + #ifndef DrawThemeMenuBackground + PyMac_PRECHECK(DrawThemeMenuBackground); + #endif if (!PyArg_ParseTuple(_args, "O&H", PyMac_GetRect, &inMenuRect, *************** *** 562,565 **** --- 637,643 ---- Rect inMenuRect; ThemeMenuType menuType; + #ifndef GetThemeMenuBackgroundRegion + PyMac_PRECHECK(GetThemeMenuBackgroundRegion); + #endif if (!PyArg_ParseTuple(_args, "O&H", PyMac_GetRect, &inMenuRect, *************** *** 580,583 **** --- 658,664 ---- OSStatus _err; Rect inItemRect; + #ifndef DrawThemeMenuSeparator + PyMac_PRECHECK(DrawThemeMenuSeparator); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetRect, &inItemRect)) *************** *** 595,598 **** --- 676,682 ---- OSStatus _err; SInt16 outHeight; + #ifndef GetThemeMenuSeparatorHeight + PyMac_PRECHECK(GetThemeMenuSeparatorHeight); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 611,614 **** --- 695,701 ---- SInt16 outHeight; SInt16 outWidth; + #ifndef GetThemeMenuItemExtra + PyMac_PRECHECK(GetThemeMenuItemExtra); + #endif if (!PyArg_ParseTuple(_args, "H", &inItemType)) *************** *** 630,633 **** --- 717,723 ---- SInt16 outWidth; Boolean inIsSquished; + #ifndef GetThemeMenuTitleExtra + PyMac_PRECHECK(GetThemeMenuTitleExtra); + #endif if (!PyArg_ParseTuple(_args, "b", &inIsSquished)) *************** *** 647,650 **** --- 737,743 ---- Rect inRect; ThemeDrawState inState; + #ifndef DrawThemeTabPane + PyMac_PRECHECK(DrawThemeTabPane); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &inRect, *************** *** 666,669 **** --- 759,765 ---- ThemeTabStyle inStyle; ThemeTabDirection inDirection; + #ifndef GetThemeTabRegion + PyMac_PRECHECK(GetThemeTabRegion); + #endif if (!PyArg_ParseTuple(_args, "O&HH", PyMac_GetRect, &inRect, *************** *** 686,689 **** --- 782,788 ---- OSStatus _err; ThemeCursor inCursor; + #ifndef SetThemeCursor + PyMac_PRECHECK(SetThemeCursor); + #endif if (!PyArg_ParseTuple(_args, "l", &inCursor)) *************** *** 702,705 **** --- 801,807 ---- ThemeCursor inCursor; UInt32 inAnimationStep; + #ifndef SetAnimatedThemeCursor + PyMac_PRECHECK(SetAnimatedThemeCursor); + #endif if (!PyArg_ParseTuple(_args, "ll", &inCursor, *************** *** 719,722 **** --- 821,827 ---- OSStatus _err; ThemeScrollBarThumbStyle outStyle; + #ifndef GetThemeScrollBarThumbStyle + PyMac_PRECHECK(GetThemeScrollBarThumbStyle); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 733,736 **** --- 838,844 ---- OSStatus _err; ThemeScrollBarArrowStyle outStyle; + #ifndef GetThemeScrollBarArrowStyle + PyMac_PRECHECK(GetThemeScrollBarArrowStyle); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 747,750 **** --- 855,861 ---- OSStatus _err; ThemeCheckBoxStyle outStyle; + #ifndef GetThemeCheckBoxStyle + PyMac_PRECHECK(GetThemeCheckBoxStyle); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 762,765 **** --- 873,879 ---- ThemeFontID inFontID; ScriptCode inScript; + #ifndef UseThemeFont + PyMac_PRECHECK(UseThemeFont); + #endif if (!PyArg_ParseTuple(_args, "Hh", &inFontID, *************** *** 786,789 **** --- 900,906 ---- Rect inBoundingBox; SInt16 inJust; + #ifndef DrawThemeTextBox + PyMac_PRECHECK(DrawThemeTextBox); + #endif if (!PyArg_ParseTuple(_args, "O&HlbO&h", CFStringRefObj_Convert, &inString, *************** *** 820,823 **** --- 937,943 ---- TruncCode inTruncWhere; Boolean outTruncated; + #ifndef TruncateThemeText + PyMac_PRECHECK(TruncateThemeText); + #endif if (!PyArg_ParseTuple(_args, "O&Hlhh", CFMutableStringRefObj_Convert, &inString, *************** *** 852,855 **** --- 972,978 ---- Point ioBounds; SInt16 outBaseline; + #ifndef GetThemeTextDimensions + PyMac_PRECHECK(GetThemeTextDimensions); + #endif if (!PyArg_ParseTuple(_args, "O&HlbO&", CFStringRefObj_Convert, &inString, *************** *** 882,885 **** --- 1005,1011 ---- ThemeDrawState inState; Rect outOutset; + #ifndef GetThemeTextShadowOutset + PyMac_PRECHECK(GetThemeTextShadowOutset); + #endif if (!PyArg_ParseTuple(_args, "Hl", &inFontID, *************** *** 905,908 **** --- 1031,1037 ---- Boolean isHoriz; Rect trackBounds; + #ifndef DrawThemeScrollBarArrows + PyMac_PRECHECK(DrawThemeScrollBarArrows); + #endif if (!PyArg_ParseTuple(_args, "O&bbb", PyMac_GetRect, &bounds, *************** *** 931,934 **** --- 1060,1066 ---- Boolean isHoriz; Rect trackBounds; + #ifndef GetThemeScrollBarTrackRect + PyMac_PRECHECK(GetThemeScrollBarTrackRect); + #endif if (!PyArg_ParseTuple(_args, "O&bbb", PyMac_GetRect, &bounds, *************** *** 959,962 **** --- 1091,1097 ---- Rect trackBounds; ControlPartCode partcode; + #ifndef HitTestThemeScrollBarArrows + PyMac_PRECHECK(HitTestThemeScrollBarArrows); + #endif if (!PyArg_ParseTuple(_args, "O&bbbO&", PyMac_GetRect, &scrollBarBounds, *************** *** 988,991 **** --- 1123,1129 ---- ThemeDrawState state; ThemeWindowAttributes attributes; + #ifndef DrawThemeScrollBarDelimiters + PyMac_PRECHECK(DrawThemeScrollBarDelimiters); + #endif if (!PyArg_ParseTuple(_args, "HO&ll", &flavor, *************** *** 1013,1016 **** --- 1151,1157 ---- ThemeButtonDrawInfo inPrevInfo; UInt32 inUserData; + #ifndef DrawThemeButton + PyMac_PRECHECK(DrawThemeButton); + #endif if (!PyArg_ParseTuple(_args, "O&HO&O&l", PyMac_GetRect, &inBounds, *************** *** 1040,1043 **** --- 1181,1187 ---- UInt16 inKind; ThemeButtonDrawInfo inNewInfo; + #ifndef GetThemeButtonRegion + PyMac_PRECHECK(GetThemeButtonRegion); + #endif if (!PyArg_ParseTuple(_args, "O&HO&", PyMac_GetRect, &inBounds, *************** *** 1063,1066 **** --- 1207,1213 ---- ThemeButtonDrawInfo inDrawInfo; Rect outBounds; + #ifndef GetThemeButtonContentBounds + PyMac_PRECHECK(GetThemeButtonContentBounds); + #endif if (!PyArg_ParseTuple(_args, "O&HO&", PyMac_GetRect, &inBounds, *************** *** 1086,1089 **** --- 1233,1239 ---- ThemeButtonDrawInfo inDrawInfo; Rect outBounds; + #ifndef GetThemeButtonBackgroundBounds + PyMac_PRECHECK(GetThemeButtonBackgroundBounds); + #endif if (!PyArg_ParseTuple(_args, "O&HO&", PyMac_GetRect, &inBounds, *************** *** 1106,1109 **** --- 1256,1262 ---- OSStatus _err; ThemeSoundKind kind; + #ifndef PlayThemeSound + PyMac_PRECHECK(PlayThemeSound); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &kind)) *************** *** 1121,1124 **** --- 1274,1280 ---- OSStatus _err; ThemeDragSoundKind kind; + #ifndef BeginThemeDragSound + PyMac_PRECHECK(BeginThemeDragSound); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &kind)) *************** *** 1135,1138 **** --- 1291,1297 ---- PyObject *_res = NULL; OSStatus _err; + #ifndef EndThemeDragSound + PyMac_PRECHECK(EndThemeDragSound); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 1150,1153 **** --- 1309,1315 ---- Rect bounds; ThemeDrawState state; + #ifndef DrawThemeTickMark + PyMac_PRECHECK(DrawThemeTickMark); + #endif if (!PyArg_ParseTuple(_args, "O&l", PyMac_GetRect, &bounds, *************** *** 1170,1173 **** --- 1332,1338 ---- ThemeDrawState state; UInt32 eraseData; + #ifndef DrawThemeChasingArrows + PyMac_PRECHECK(DrawThemeChasingArrows); + #endif if (!PyArg_ParseTuple(_args, "O&lll", PyMac_GetRect, &bounds, *************** *** 1196,1199 **** --- 1361,1367 ---- ThemeDrawState state; UInt32 eraseData; + #ifndef DrawThemePopupArrow + PyMac_PRECHECK(DrawThemePopupArrow); + #endif if (!PyArg_ParseTuple(_args, "O&HHll", PyMac_GetRect, &bounds, *************** *** 1223,1226 **** --- 1391,1397 ---- Boolean isSmall; ThemeDrawState state; + #ifndef DrawThemeStandaloneGrowBox + PyMac_PRECHECK(DrawThemeStandaloneGrowBox); + #endif if (!PyArg_ParseTuple(_args, "O&Hbl", PyMac_GetPoint, &origin, *************** *** 1247,1250 **** --- 1418,1424 ---- Boolean isSmall; ThemeDrawState state; + #ifndef DrawThemeStandaloneNoGrowBox + PyMac_PRECHECK(DrawThemeStandaloneNoGrowBox); + #endif if (!PyArg_ParseTuple(_args, "O&Hbl", PyMac_GetPoint, &origin, *************** *** 1271,1274 **** --- 1445,1451 ---- Boolean isSmall; Rect bounds; + #ifndef GetThemeStandaloneGrowBoxBounds + PyMac_PRECHECK(GetThemeStandaloneGrowBoxBounds); + #endif if (!PyArg_ParseTuple(_args, "O&Hb", PyMac_GetPoint, &origin, *************** *** 1290,1293 **** --- 1467,1473 ---- PyObject *_res = NULL; OSStatus _err; + #ifndef NormalizeThemeDrawingState + PyMac_PRECHECK(NormalizeThemeDrawingState); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 1304,1307 **** --- 1484,1490 ---- OSStatus _err; ThemeDrawingState outState; + #ifndef GetThemeDrawingState + PyMac_PRECHECK(GetThemeDrawingState); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 1322,1325 **** --- 1505,1511 ---- SInt16 inDepth; Boolean inColorDev; + #ifndef ApplyThemeBackground + PyMac_PRECHECK(ApplyThemeBackground); + #endif if (!PyArg_ParseTuple(_args, "lO&lhb", &inKind, *************** *** 1348,1351 **** --- 1534,1540 ---- SInt16 depth; Boolean isColorDev; + #ifndef SetThemeTextColorForWindow + PyMac_PRECHECK(SetThemeTextColorForWindow); + #endif if (!PyArg_ParseTuple(_args, "O&bhb", WinObj_Convert, &window, *************** *** 1369,1372 **** --- 1558,1564 ---- Boolean _rv; OSType fileType; + #ifndef IsValidAppearanceFileType + PyMac_PRECHECK(IsValidAppearanceFileType); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetOSType, &fileType)) *************** *** 1386,1389 **** --- 1578,1584 ---- Boolean inColorDev; RGBColor outColor; + #ifndef GetThemeBrushAsColor + PyMac_PRECHECK(GetThemeBrushAsColor); + #endif if (!PyArg_ParseTuple(_args, "hhb", &inBrush, *************** *** 1409,1412 **** --- 1604,1610 ---- Boolean inColorDev; RGBColor outColor; + #ifndef GetThemeTextColor + PyMac_PRECHECK(GetThemeTextColor); + #endif if (!PyArg_ParseTuple(_args, "hhb", &inColor, *************** *** 1432,1435 **** --- 1630,1636 ---- ThemeMetric inMetric; SInt32 outMetric; + #ifndef GetThemeMetric + PyMac_PRECHECK(GetThemeMetric); + #endif if (!PyArg_ParseTuple(_args, "l", &inMetric)) Index: appsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/app/appsupport.py,v retrieving revision 1.9.4.1 retrieving revision 1.9.4.2 diff -C2 -d -r1.9.4.1 -r1.9.4.2 *** appsupport.py 27 Feb 2002 23:07:46 -0000 1.9.4.1 --- appsupport.py 25 Mar 2002 10:30:36 -0000 1.9.4.2 *************** *** 119,128 **** ThemeDrawingState = OpaqueByValueType("ThemeDrawingState", "ThemeDrawingStateObj") ! Method = MethodGenerator # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator ! ##Method = OSErrMethodGenerator # Create and populate the lists --- 119,128 ---- ThemeDrawingState = OpaqueByValueType("ThemeDrawingState", "ThemeDrawingStateObj") ! Method = WeakLinkMethodGenerator # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator ! ##Method = OSErrWeakLinkMethodGenerator # Create and populate the lists From jackjansen@users.sourceforge.net Mon Mar 25 10:38:59 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 25 Mar 2002 02:38:59 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/qt _Qtmodule.c,1.6,1.6.4.1 qtsupport.py,1.18,1.18.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/qt In directory usw-pr-cvs1:/tmp/cvs-serv733 Modified Files: Tag: release22-maint _Qtmodule.c qtsupport.py Log Message: Backport of _Qtmocule.c 1.7, qtsupport.py 1.19: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _Qtmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/qt/_Qtmodule.c,v retrieving revision 1.6 retrieving revision 1.6.4.1 diff -C2 -d -r1.6 -r1.6.4.1 *** _Qtmodule.c 18 Dec 2001 15:36:46 -0000 1.6 --- _Qtmodule.c 25 Mar 2002 10:38:57 -0000 1.6.4.1 *************** *** 141,144 **** --- 141,147 ---- WindowPtr movieWindow; Point where; + #ifndef MCSetMovie + PyMac_PRECHECK(MCSetMovie); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&", MovieObj_Convert, &theMovie, *************** *** 160,163 **** [...4018 lines suppressed...] *************** *** 8368,8371 **** --- 9577,9583 ---- Point startPt; Rect boundsRect; + #ifndef DragAlignedWindow + PyMac_PRECHECK(DragAlignedWindow); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&", WinObj_Convert, &wp, *************** *** 8387,8390 **** --- 9599,9605 ---- PyObject *_res = NULL; long maxMilliSecToUse; + #ifndef MoviesTask + PyMac_PRECHECK(MoviesTask); + #endif if (!PyArg_ParseTuple(_args, "l", &maxMilliSecToUse)) Index: qtsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/qt/qtsupport.py,v retrieving revision 1.18 retrieving revision 1.18.14.1 diff -C2 -d -r1.18 -r1.18.14.1 *** qtsupport.py 23 Aug 2001 13:50:27 -0000 1.18 --- qtsupport.py 25 Mar 2002 10:38:57 -0000 1.18.14.1 *************** *** 255,260 **** # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator ! Method = OSErrMethodGenerator # Create and populate the lists --- 255,260 ---- # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator ! Method = OSErrWeakLinkMethodGenerator # Create and populate the lists From jackjansen@users.sourceforge.net Mon Mar 25 10:41:20 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 25 Mar 2002 02:41:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/te _TEmodule.c,1.7,1.7.4.1 tesupport.py,1.9,1.9.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/te In directory usw-pr-cvs1:/tmp/cvs-serv2294 Modified Files: Tag: release22-maint _TEmodule.c tesupport.py Log Message: Backport of _TEmodule.c 1.8, tesupport.py 1.10: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _TEmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/te/_TEmodule.c,v retrieving revision 1.7 retrieving revision 1.7.4.1 diff -C2 -d -r1.7 -r1.7.4.1 *** _TEmodule.c 18 Dec 2001 15:36:19 -0000 1.7 --- _TEmodule.c 25 Mar 2002 10:41:18 -0000 1.7.4.1 *************** *** 110,113 **** --- 110,116 ---- long text__len__; int text__in_len__; + #ifndef TESetText + PyMac_PRECHECK(TESetText); + #endif if (!PyArg_ParseTuple(_args, "s#", &text__in__, &text__in_len__)) *************** *** 125,128 **** --- 128,134 ---- PyObject *_res = NULL; CharsHandle _rv; + #ifndef TEGetText + PyMac_PRECHECK(TEGetText); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 136,139 **** --- 142,148 ---- { PyObject *_res = NULL; + #ifndef TEIdle + PyMac_PRECHECK(TEIdle); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 149,152 **** --- 158,164 ---- long selStart; long selEnd; + #ifndef TESetSelect + PyMac_PRECHECK(TESetSelect); + #endif if (!PyArg_ParseTuple(_args, "ll", &selStart, *************** *** 164,167 **** --- 176,182 ---- { PyObject *_res = NULL; + #ifndef TEActivate + PyMac_PRECHECK(TEActivate); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 175,178 **** --- 190,196 ---- { PyObject *_res = NULL; + #ifndef TEDeactivate + PyMac_PRECHECK(TEDeactivate); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 187,190 **** --- 205,211 ---- PyObject *_res = NULL; CharParameter key; + #ifndef TEKey + PyMac_PRECHECK(TEKey); + #endif if (!PyArg_ParseTuple(_args, "h", &key)) *************** *** 200,203 **** --- 221,227 ---- { PyObject *_res = NULL; + #ifndef TECut + PyMac_PRECHECK(TECut); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 211,214 **** --- 235,241 ---- { PyObject *_res = NULL; + #ifndef TECopy + PyMac_PRECHECK(TECopy); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 222,225 **** --- 249,255 ---- { PyObject *_res = NULL; + #ifndef TEPaste + PyMac_PRECHECK(TEPaste); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 233,236 **** --- 263,269 ---- { PyObject *_res = NULL; + #ifndef TEDelete + PyMac_PRECHECK(TEDelete); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 247,250 **** --- 280,286 ---- long text__len__; int text__in_len__; + #ifndef TEInsert + PyMac_PRECHECK(TEInsert); + #endif if (!PyArg_ParseTuple(_args, "s#", &text__in__, &text__in_len__)) *************** *** 262,265 **** --- 298,304 ---- PyObject *_res = NULL; short just; + #ifndef TESetAlignment + PyMac_PRECHECK(TESetAlignment); + #endif if (!PyArg_ParseTuple(_args, "h", &just)) *************** *** 276,279 **** --- 315,321 ---- PyObject *_res = NULL; Rect rUpdate; + #ifndef TEUpdate + PyMac_PRECHECK(TEUpdate); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetRect, &rUpdate)) *************** *** 291,294 **** --- 333,339 ---- short dh; short dv; + #ifndef TEScroll + PyMac_PRECHECK(TEScroll); + #endif if (!PyArg_ParseTuple(_args, "hh", &dh, *************** *** 306,309 **** --- 351,357 ---- { PyObject *_res = NULL; + #ifndef TESelView + PyMac_PRECHECK(TESelView); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 319,322 **** --- 367,373 ---- short dh; short dv; + #ifndef TEPinScroll + PyMac_PRECHECK(TEPinScroll); + #endif if (!PyArg_ParseTuple(_args, "hh", &dh, *************** *** 335,338 **** --- 386,392 ---- PyObject *_res = NULL; Boolean fAuto; + #ifndef TEAutoView + PyMac_PRECHECK(TEAutoView); + #endif if (!PyArg_ParseTuple(_args, "b", &fAuto)) *************** *** 348,351 **** --- 402,408 ---- { PyObject *_res = NULL; + #ifndef TECalText + PyMac_PRECHECK(TECalText); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 361,364 **** --- 418,424 ---- short _rv; Point pt; + #ifndef TEGetOffset + PyMac_PRECHECK(TEGetOffset); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetPoint, &pt)) *************** *** 376,379 **** --- 436,442 ---- Point _rv; short offset; + #ifndef TEGetPoint + PyMac_PRECHECK(TEGetPoint); + #endif if (!PyArg_ParseTuple(_args, "h", &offset)) *************** *** 391,394 **** --- 454,460 ---- Point pt; Boolean fExtend; + #ifndef TEClick + PyMac_PRECHECK(TEClick); + #endif if (!PyArg_ParseTuple(_args, "O&b", PyMac_GetPoint, &pt, *************** *** 407,410 **** --- 473,479 ---- PyObject *_res = NULL; TEStyleHandle theHandle; + #ifndef TESetStyleHandle + PyMac_PRECHECK(TESetStyleHandle); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theHandle)) *************** *** 421,424 **** --- 490,496 ---- PyObject *_res = NULL; TEStyleHandle _rv; + #ifndef TEGetStyleHandle + PyMac_PRECHECK(TEGetStyleHandle); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 436,439 **** --- 508,514 ---- short lineHeight; short fontAscent; + #ifndef TEGetStyle + PyMac_PRECHECK(TEGetStyle); + #endif if (!PyArg_ParseTuple(_args, "h", &offset)) *************** *** 454,457 **** --- 529,535 ---- { PyObject *_res = NULL; + #ifndef TEStylePaste + PyMac_PRECHECK(TEStylePaste); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 468,471 **** --- 546,552 ---- TextStyle newStyle; Boolean fRedraw; + #ifndef TESetStyle + PyMac_PRECHECK(TESetStyle); + #endif if (!PyArg_ParseTuple(_args, "hO&b", &mode, *************** *** 489,492 **** --- 570,576 ---- TextStyle newStyle; Boolean fRedraw; + #ifndef TEReplaceStyle + PyMac_PRECHECK(TEReplaceStyle); + #endif if (!PyArg_ParseTuple(_args, "hO&O&b", &mode, *************** *** 509,512 **** --- 593,599 ---- PyObject *_res = NULL; StScrpHandle _rv; + #ifndef TEGetStyleScrapHandle + PyMac_PRECHECK(TEGetStyleScrapHandle); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 524,527 **** --- 611,617 ---- int text__in_len__; StScrpHandle hST; + #ifndef TEStyleInsert + PyMac_PRECHECK(TEStyleInsert); + #endif if (!PyArg_ParseTuple(_args, "s#O&", &text__in__, &text__in_len__, *************** *** 543,546 **** --- 633,639 ---- long endLine; long startLine; + #ifndef TEGetHeight + PyMac_PRECHECK(TEGetHeight); + #endif if (!PyArg_ParseTuple(_args, "ll", &endLine, *************** *** 561,564 **** --- 654,660 ---- short mode; TextStyle aStyle; + #ifndef TEContinuousStyle + PyMac_PRECHECK(TEContinuousStyle); + #endif if (!PyArg_ParseTuple(_args, "hO&", &mode, *************** *** 582,585 **** --- 678,684 ---- StScrpHandle newStyles; Boolean fRedraw; + #ifndef TEUseStyleScrap + PyMac_PRECHECK(TEUseStyleScrap); + #endif if (!PyArg_ParseTuple(_args, "llO&b", &rangeStart, *************** *** 604,607 **** --- 703,709 ---- long rangeStart; long rangeEnd; + #ifndef TENumStyles + PyMac_PRECHECK(TENumStyles); + #endif if (!PyArg_ParseTuple(_args, "ll", &rangeStart, *************** *** 622,625 **** --- 724,730 ---- short feature; short action; + #ifndef TEFeatureFlag + PyMac_PRECHECK(TEFeatureFlag); + #endif if (!PyArg_ParseTuple(_args, "hh", &feature, *************** *** 639,642 **** --- 744,750 ---- OSErr _err; RgnHandle region; + #ifndef TEGetHiliteRgn + PyMac_PRECHECK(TEGetHiliteRgn); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, ®ion)) *************** *** 654,657 **** --- 762,768 ---- PyObject *_res = NULL; Handle _rv; + #ifndef as_Resource + PyMac_PRECHECK(as_Resource); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 819,822 **** --- 930,936 ---- PyObject *_res = NULL; Handle _rv; + #ifndef TEScrapHandle + PyMac_PRECHECK(TEScrapHandle); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 831,834 **** --- 945,951 ---- PyObject *_res = NULL; long _rv; + #ifndef TEGetScrapLength + PyMac_PRECHECK(TEGetScrapLength); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 845,848 **** --- 962,968 ---- Rect destRect; Rect viewRect; + #ifndef TENew + PyMac_PRECHECK(TENew); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetRect, &destRect, *************** *** 864,867 **** --- 984,990 ---- Rect box; short just; + #ifndef TETextBox + PyMac_PRECHECK(TETextBox); + #endif if (!PyArg_ParseTuple(_args, "s#O&h", &text__in__, &text__in_len__, *************** *** 884,887 **** --- 1007,1013 ---- Rect destRect; Rect viewRect; + #ifndef TEStyleNew + PyMac_PRECHECK(TEStyleNew); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetRect, &destRect, *************** *** 899,902 **** --- 1025,1031 ---- PyObject *_res = NULL; long length; + #ifndef TESetScrapLength + PyMac_PRECHECK(TESetScrapLength); + #endif if (!PyArg_ParseTuple(_args, "l", &length)) *************** *** 912,915 **** --- 1041,1047 ---- PyObject *_res = NULL; OSErr _err; + #ifndef TEFromScrap + PyMac_PRECHECK(TEFromScrap); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 925,928 **** --- 1057,1063 ---- PyObject *_res = NULL; OSErr _err; + #ifndef TEToScrap + PyMac_PRECHECK(TEToScrap); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 940,943 **** --- 1075,1081 ---- PyObject *_res = NULL; Handle _rv; + #ifndef TEGetScrapHandle + PyMac_PRECHECK(TEGetScrapHandle); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 955,958 **** --- 1093,1099 ---- PyObject *_res = NULL; Handle value; + #ifndef TESetScrapHandle + PyMac_PRECHECK(TESetScrapHandle); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &value)) *************** *** 969,972 **** --- 1110,1116 ---- PyObject *_res = NULL; UInt8 _rv; + #ifndef LMGetWordRedraw + PyMac_PRECHECK(LMGetWordRedraw); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 981,984 **** --- 1125,1131 ---- PyObject *_res = NULL; UInt8 value; + #ifndef LMSetWordRedraw + PyMac_PRECHECK(LMSetWordRedraw); + #endif if (!PyArg_ParseTuple(_args, "b", &value)) *************** *** 995,998 **** --- 1142,1148 ---- TEHandle _rv; Handle h; + #ifndef as_TE + PyMac_PRECHECK(as_TE); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &h)) Index: tesupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/te/tesupport.py,v retrieving revision 1.9 retrieving revision 1.9.14.1 diff -C2 -d -r1.9 -r1.9.14.1 *** tesupport.py 23 Aug 2001 13:51:33 -0000 1.9 --- tesupport.py 25 Mar 2002 10:41:18 -0000 1.9.14.1 *************** *** 80,84 **** """ ! class TEMethodGenerator(OSErrMethodGenerator): """Similar to MethodGenerator, but has self as last argument""" --- 80,84 ---- """ ! class TEMethodGenerator(OSErrWeakLinkMethodGenerator): """Similar to MethodGenerator, but has self as last argument""" *************** *** 151,155 **** # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator Method = TEMethodGenerator --- 151,155 ---- # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator Method = TEMethodGenerator From jackjansen@users.sourceforge.net Mon Mar 25 10:43:37 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 25 Mar 2002 02:43:37 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/qdoffs _Qdoffsmodule.c,1.6,1.6.4.1 qdoffssupport.py,1.7,1.7.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/qdoffs In directory usw-pr-cvs1:/tmp/cvs-serv3815 Modified Files: Tag: release22-maint _Qdoffsmodule.c qdoffssupport.py Log Message: Backport of _Qdoffsmodule.c 1.7, qdoffssupport.py 1.8: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _Qdoffsmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/qdoffs/_Qdoffsmodule.c,v retrieving revision 1.6 retrieving revision 1.6.4.1 diff -C2 -d -r1.6 -r1.6.4.1 *** _Qdoffsmodule.c 18 Dec 2001 15:36:52 -0000 1.6 --- _Qdoffsmodule.c 25 Mar 2002 10:43:35 -0000 1.6.4.1 *************** *** 81,84 **** --- 81,87 ---- PyObject *_res = NULL; GDHandle _rv; + #ifndef GetGWorldDevice + PyMac_PRECHECK(GetGWorldDevice); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 93,96 **** --- 96,102 ---- PyObject *_res = NULL; PixMapHandle _rv; + #ifndef GetGWorldPixMap + PyMac_PRECHECK(GetGWorldPixMap); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 105,108 **** --- 111,117 ---- PyObject *_res = NULL; GrafPtr _rv; + #ifndef as_GrafPtr + PyMac_PRECHECK(as_GrafPtr); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 170,173 **** --- 179,185 ---- GDHandle aGDevice; GWorldFlags flags; + #ifndef NewGWorld + PyMac_PRECHECK(NewGWorld); + #endif if (!PyArg_ParseTuple(_args, "hO&O&O&l", &PixelDepth, *************** *** 194,197 **** --- 206,212 ---- Boolean _rv; PixMapHandle pm; + #ifndef LockPixels + PyMac_PRECHECK(LockPixels); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pm)) *************** *** 207,210 **** --- 222,228 ---- PyObject *_res = NULL; PixMapHandle pm; + #ifndef UnlockPixels + PyMac_PRECHECK(UnlockPixels); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pm)) *************** *** 226,229 **** --- 244,250 ---- GDHandle aGDevice; GWorldFlags flags; + #ifndef UpdateGWorld + PyMac_PRECHECK(UpdateGWorld); + #endif if (!PyArg_ParseTuple(_args, "hO&O&O&l", &pixelDepth, *************** *** 250,253 **** --- 271,277 ---- CGrafPtr port; GDHandle gdh; + #ifndef GetGWorld + PyMac_PRECHECK(GetGWorld); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 265,268 **** --- 289,295 ---- CGrafPtr port; GDHandle gdh; + #ifndef SetGWorld + PyMac_PRECHECK(SetGWorld); + #endif if (!PyArg_ParseTuple(_args, "O&O&", GrafObj_Convert, &port, *************** *** 280,283 **** --- 307,313 ---- PyObject *_res = NULL; CTabHandle ctab; + #ifndef CTabChanged + PyMac_PRECHECK(CTabChanged); + #endif if (!PyArg_ParseTuple(_args, "O&", OptResObj_Convert, &ctab)) *************** *** 293,296 **** --- 323,329 ---- PyObject *_res = NULL; PixPatHandle ppat; + #ifndef PixPatChanged + PyMac_PRECHECK(PixPatChanged); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &ppat)) *************** *** 306,309 **** --- 339,345 ---- PyObject *_res = NULL; GrafPtr port; + #ifndef PortChanged + PyMac_PRECHECK(PortChanged); + #endif if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) *************** *** 319,322 **** --- 355,361 ---- PyObject *_res = NULL; GDHandle gdh; + #ifndef GDeviceChanged + PyMac_PRECHECK(GDeviceChanged); + #endif if (!PyArg_ParseTuple(_args, "O&", OptResObj_Convert, &gdh)) *************** *** 332,335 **** --- 371,377 ---- PyObject *_res = NULL; PixMapHandle pm; + #ifndef AllowPurgePixels + PyMac_PRECHECK(AllowPurgePixels); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pm)) *************** *** 345,348 **** --- 387,393 ---- PyObject *_res = NULL; PixMapHandle pm; + #ifndef NoPurgePixels + PyMac_PRECHECK(NoPurgePixels); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pm)) *************** *** 359,362 **** --- 404,410 ---- GWorldFlags _rv; PixMapHandle pm; + #ifndef GetPixelsState + PyMac_PRECHECK(GetPixelsState); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pm)) *************** *** 373,376 **** --- 421,427 ---- PixMapHandle pm; GWorldFlags state; + #ifndef SetPixelsState + PyMac_PRECHECK(SetPixelsState); + #endif if (!PyArg_ParseTuple(_args, "O&l", ResObj_Convert, &pm, *************** *** 389,392 **** --- 440,446 ---- long _rv; PixMapHandle pm; + #ifndef GetPixRowBytes + PyMac_PRECHECK(GetPixRowBytes); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pm)) *************** *** 406,409 **** --- 460,466 ---- GDHandle gdh; PixMapHandle offscreenPixMap; + #ifndef NewScreenBuffer + PyMac_PRECHECK(NewScreenBuffer); + #endif if (!PyArg_ParseTuple(_args, "O&b", PyMac_GetRect, &globalRect, *************** *** 425,428 **** --- 482,488 ---- PyObject *_res = NULL; PixMapHandle offscreenPixMap; + #ifndef DisposeScreenBuffer + PyMac_PRECHECK(DisposeScreenBuffer); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &offscreenPixMap)) *************** *** 439,442 **** --- 499,505 ---- Boolean _rv; GrafPtr port; + #ifndef QDDone + PyMac_PRECHECK(QDDone); + #endif if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) *************** *** 452,455 **** --- 515,521 ---- PyObject *_res = NULL; long _rv; + #ifndef OffscreenVersion + PyMac_PRECHECK(OffscreenVersion); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 468,471 **** --- 534,540 ---- GDHandle gdh; PixMapHandle offscreenPixMap; + #ifndef NewTempScreenBuffer + PyMac_PRECHECK(NewTempScreenBuffer); + #endif if (!PyArg_ParseTuple(_args, "O&b", PyMac_GetRect, &globalRect, *************** *** 488,491 **** --- 557,563 ---- Boolean _rv; PixMapHandle pmHandle; + #ifndef PixMap32Bit + PyMac_PRECHECK(PixMap32Bit); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &pmHandle)) Index: qdoffssupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/qdoffs/qdoffssupport.py,v retrieving revision 1.7 retrieving revision 1.7.14.1 diff -C2 -d -r1.7 -r1.7.14.1 *** qdoffssupport.py 5 Sep 2001 10:31:22 -0000 1.7 --- qdoffssupport.py 25 Mar 2002 10:43:35 -0000 1.7.14.1 *************** *** 84,89 **** # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator ! Method = OSErrMethodGenerator # Create and populate the lists --- 84,89 ---- # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator ! Method = OSErrWeakLinkMethodGenerator # Create and populate the lists From jackjansen@users.sourceforge.net Mon Mar 25 10:45:23 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 25 Mar 2002 02:45:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/icn _Icnmodule.c,1.4,1.4.4.1 icnsupport.py,1.6,1.6.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/icn In directory usw-pr-cvs1:/tmp/cvs-serv4922 Modified Files: Tag: release22-maint _Icnmodule.c icnsupport.py Log Message: Backport of _Icnmodule.c 1.5, icnsupport.py 1.7: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _Icnmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/icn/_Icnmodule.c,v retrieving revision 1.4 retrieving revision 1.4.4.1 diff -C2 -d -r1.4 -r1.4.4.1 *** _Icnmodule.c 18 Dec 2001 15:37:33 -0000 1.4 --- _Icnmodule.c 25 Mar 2002 10:45:21 -0000 1.4.4.1 *************** *** 35,38 **** --- 35,41 ---- CIconHandle _rv; SInt16 iconID; + #ifndef GetCIcon + PyMac_PRECHECK(GetCIcon); + #endif if (!PyArg_ParseTuple(_args, "h", &iconID)) *************** *** 49,52 **** --- 52,58 ---- Rect theRect; CIconHandle theIcon; + #ifndef PlotCIcon + PyMac_PRECHECK(PlotCIcon); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetRect, &theRect, *************** *** 64,67 **** --- 70,76 ---- PyObject *_res = NULL; CIconHandle theIcon; + #ifndef DisposeCIcon + PyMac_PRECHECK(DisposeCIcon); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theIcon)) *************** *** 78,81 **** --- 87,93 ---- Handle _rv; SInt16 iconID; + #ifndef GetIcon + PyMac_PRECHECK(GetIcon); + #endif if (!PyArg_ParseTuple(_args, "h", &iconID)) *************** *** 92,95 **** --- 104,110 ---- Rect theRect; Handle theIcon; + #ifndef PlotIcon + PyMac_PRECHECK(PlotIcon); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetRect, &theRect, *************** *** 111,114 **** --- 126,132 ---- IconTransformType transform; SInt16 theResID; + #ifndef PlotIconID + PyMac_PRECHECK(PlotIconID); + #endif if (!PyArg_ParseTuple(_args, "O&hhh", PyMac_GetRect, &theRect, *************** *** 132,135 **** --- 150,156 ---- OSErr _err; IconSuiteRef theIconSuite; + #ifndef NewIconSuite + PyMac_PRECHECK(NewIconSuite); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 148,151 **** --- 169,175 ---- IconSuiteRef theSuite; ResType theType; + #ifndef AddIconToSuite + PyMac_PRECHECK(AddIconToSuite); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&", ResObj_Convert, &theIconData, *************** *** 169,172 **** --- 193,199 ---- IconSuiteRef theSuite; ResType theType; + #ifndef GetIconFromSuite + PyMac_PRECHECK(GetIconFromSuite); + #endif if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &theSuite, *************** *** 189,192 **** --- 216,222 ---- SInt16 theResID; IconSelectorValue selector; + #ifndef GetIconSuite + PyMac_PRECHECK(GetIconSuite); + #endif if (!PyArg_ParseTuple(_args, "hl", &theResID, *************** *** 208,211 **** --- 238,244 ---- IconSuiteRef theIconSuite; Boolean disposeData; + #ifndef DisposeIconSuite + PyMac_PRECHECK(DisposeIconSuite); + #endif if (!PyArg_ParseTuple(_args, "O&b", ResObj_Convert, &theIconSuite, *************** *** 228,231 **** --- 261,267 ---- IconTransformType transform; IconSuiteRef theIconSuite; + #ifndef PlotIconSuite + PyMac_PRECHECK(PlotIconSuite); + #endif if (!PyArg_ParseTuple(_args, "O&hhO&", PyMac_GetRect, &theRect, *************** *** 252,255 **** --- 288,294 ---- IconTransformType transform; IconCacheRef theIconCache; + #ifndef LoadIconCache + PyMac_PRECHECK(LoadIconCache); + #endif if (!PyArg_ParseTuple(_args, "O&hhO&", PyMac_GetRect, &theRect, *************** *** 275,278 **** --- 314,320 ---- RGBColor labelColor; Str255 labelString; + #ifndef GetLabel + PyMac_PRECHECK(GetLabel); + #endif if (!PyArg_ParseTuple(_args, "hO&", &labelNumber, *************** *** 296,299 **** --- 338,344 ---- IconAlignmentType align; SInt16 iconID; + #ifndef PtInIconID + PyMac_PRECHECK(PtInIconID); + #endif if (!PyArg_ParseTuple(_args, "O&O&hh", PyMac_GetPoint, &testPt, *************** *** 319,322 **** --- 364,370 ---- IconAlignmentType align; IconSuiteRef theIconSuite; + #ifndef PtInIconSuite + PyMac_PRECHECK(PtInIconSuite); + #endif if (!PyArg_ParseTuple(_args, "O&O&hO&", PyMac_GetPoint, &testPt, *************** *** 342,345 **** --- 390,396 ---- IconAlignmentType align; SInt16 iconID; + #ifndef RectInIconID + PyMac_PRECHECK(RectInIconID); + #endif if (!PyArg_ParseTuple(_args, "O&O&hh", PyMac_GetRect, &testRect, *************** *** 365,368 **** --- 416,422 ---- IconAlignmentType align; IconSuiteRef theIconSuite; + #ifndef RectInIconSuite + PyMac_PRECHECK(RectInIconSuite); + #endif if (!PyArg_ParseTuple(_args, "O&O&hO&", PyMac_GetRect, &testRect, *************** *** 388,391 **** --- 442,448 ---- IconAlignmentType align; SInt16 iconID; + #ifndef IconIDToRgn + PyMac_PRECHECK(IconIDToRgn); + #endif if (!PyArg_ParseTuple(_args, "O&O&hh", ResObj_Convert, &theRgn, *************** *** 412,415 **** --- 469,475 ---- IconAlignmentType align; IconSuiteRef theIconSuite; + #ifndef IconSuiteToRgn + PyMac_PRECHECK(IconSuiteToRgn); + #endif if (!PyArg_ParseTuple(_args, "O&O&hO&", ResObj_Convert, &theRgn, *************** *** 434,437 **** --- 494,500 ---- IconSuiteRef theSuite; SInt16 theLabel; + #ifndef SetSuiteLabel + PyMac_PRECHECK(SetSuiteLabel); + #endif if (!PyArg_ParseTuple(_args, "O&h", ResObj_Convert, &theSuite, *************** *** 451,454 **** --- 514,520 ---- SInt16 _rv; IconSuiteRef theSuite; + #ifndef GetSuiteLabel + PyMac_PRECHECK(GetSuiteLabel); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theSuite)) *************** *** 468,471 **** --- 534,540 ---- IconTransformType transform; Handle theIcon; + #ifndef PlotIconHandle + PyMac_PRECHECK(PlotIconHandle); + #endif if (!PyArg_ParseTuple(_args, "O&hhO&", PyMac_GetRect, &theRect, *************** *** 492,495 **** --- 561,567 ---- IconTransformType transform; Handle theSICN; + #ifndef PlotSICNHandle + PyMac_PRECHECK(PlotSICNHandle); + #endif if (!PyArg_ParseTuple(_args, "O&hhO&", PyMac_GetRect, &theRect, *************** *** 516,519 **** --- 588,594 ---- IconTransformType transform; CIconHandle theCIcon; + #ifndef PlotCIconHandle + PyMac_PRECHECK(PlotCIconHandle); + #endif if (!PyArg_ParseTuple(_args, "O&hhO&", PyMac_GetRect, &theRect, *************** *** 537,540 **** --- 612,618 ---- { PyObject *_res = NULL; + #ifndef IconServicesTerminate + PyMac_PRECHECK(IconServicesTerminate); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 553,556 **** --- 631,637 ---- IconSelectorValue whichIcons; IconFamilyHandle iconFamily; + #ifndef IconRefToIconFamily + PyMac_PRECHECK(IconRefToIconFamily); + #endif if (!PyArg_ParseTuple(_args, "O&l", ResObj_Convert, &theIconRef, *************** *** 573,576 **** --- 654,660 ---- IconSelectorValue whichIcons; IconSuiteRef iconSuite; + #ifndef IconFamilyToIconSuite + PyMac_PRECHECK(IconFamilyToIconSuite); + #endif if (!PyArg_ParseTuple(_args, "O&l", ResObj_Convert, &iconFamily, *************** *** 593,596 **** --- 677,683 ---- IconSelectorValue whichIcons; IconFamilyHandle iconFamily; + #ifndef IconSuiteToIconFamily + PyMac_PRECHECK(IconSuiteToIconFamily); + #endif if (!PyArg_ParseTuple(_args, "O&l", ResObj_Convert, &iconSuite, *************** *** 613,616 **** --- 700,706 ---- OSType iconType; Handle h; + #ifndef SetIconFamilyData + PyMac_PRECHECK(SetIconFamilyData); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&", ResObj_Convert, &iconFamily, *************** *** 634,637 **** --- 724,730 ---- OSType iconType; Handle h; + #ifndef GetIconFamilyData + PyMac_PRECHECK(GetIconFamilyData); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&", ResObj_Convert, &iconFamily, *************** *** 654,657 **** --- 747,753 ---- IconRef theIconRef; UInt16 owners; + #ifndef GetIconRefOwners + PyMac_PRECHECK(GetIconRefOwners); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theIconRef)) *************** *** 670,673 **** --- 766,772 ---- OSErr _err; IconRef theIconRef; + #ifndef AcquireIconRef + PyMac_PRECHECK(AcquireIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theIconRef)) *************** *** 685,688 **** --- 784,790 ---- OSErr _err; IconRef theIconRef; + #ifndef ReleaseIconRef + PyMac_PRECHECK(ReleaseIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theIconRef)) *************** *** 702,705 **** --- 804,810 ---- IconRef theIconRef; SInt16 theLabel; + #ifndef GetIconRefFromFile + PyMac_PRECHECK(GetIconRefFromFile); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetFSSpec, &theFile)) *************** *** 723,726 **** --- 828,834 ---- OSType iconType; IconRef theIconRef; + #ifndef GetIconRef + PyMac_PRECHECK(GetIconRef); + #endif if (!PyArg_ParseTuple(_args, "hO&O&", &vRefNum, *************** *** 748,751 **** --- 856,862 ---- SInt8 accessPrivileges; IconRef theIconRef; + #ifndef GetIconRefFromFolder + PyMac_PRECHECK(GetIconRefFromFolder); + #endif if (!PyArg_ParseTuple(_args, "hllbb", &vRefNum, *************** *** 775,778 **** --- 886,892 ---- IconFamilyHandle iconFamily; IconRef theIconRef; + #ifndef RegisterIconRefFromIconFamily + PyMac_PRECHECK(RegisterIconRefFromIconFamily); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&", PyMac_GetOSType, &creator, *************** *** 799,802 **** --- 913,919 ---- SInt16 resourceID; IconRef theIconRef; + #ifndef RegisterIconRefFromResource + PyMac_PRECHECK(RegisterIconRefFromResource); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&h", PyMac_GetOSType, &creator, *************** *** 822,825 **** --- 939,945 ---- OSType creator; OSType iconType; + #ifndef UnregisterIconRef + PyMac_PRECHECK(UnregisterIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &creator, *************** *** 839,842 **** --- 959,965 ---- OSErr _err; IconRef theIconRef; + #ifndef UpdateIconRef + PyMac_PRECHECK(UpdateIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theIconRef)) *************** *** 856,859 **** --- 979,985 ---- FSSpec resourceFile; SInt16 resourceID; + #ifndef OverrideIconRefFromResource + PyMac_PRECHECK(OverrideIconRefFromResource); + #endif if (!PyArg_ParseTuple(_args, "O&O&h", ResObj_Convert, &theIconRef, *************** *** 876,879 **** --- 1002,1008 ---- IconRef oldIconRef; IconRef newIconRef; + #ifndef OverrideIconRef + PyMac_PRECHECK(OverrideIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &oldIconRef, *************** *** 893,896 **** --- 1022,1028 ---- OSErr _err; IconRef theIconRef; + #ifndef RemoveIconRefOverride + PyMac_PRECHECK(RemoveIconRefOverride); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theIconRef)) *************** *** 910,913 **** --- 1042,1048 ---- IconRef foregroundIconRef; IconRef compositeIconRef; + #ifndef CompositeIconRef + PyMac_PRECHECK(CompositeIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &backgroundIconRef, *************** *** 930,933 **** --- 1065,1071 ---- IconRef backgroundIconRef; IconRef foregroundIconRef; + #ifndef IsIconRefComposite + PyMac_PRECHECK(IsIconRefComposite); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &compositeIconRef)) *************** *** 948,951 **** --- 1086,1092 ---- Boolean _rv; IconRef theIconRef; + #ifndef IsValidIconRef + PyMac_PRECHECK(IsValidIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theIconRef)) *************** *** 966,969 **** --- 1107,1113 ---- IconServicesUsageFlags theIconServicesUsageFlags; IconRef theIconRef; + #ifndef PlotIconRef + PyMac_PRECHECK(PlotIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&hhlO&", PyMac_GetRect, &theRect, *************** *** 993,996 **** --- 1137,1143 ---- IconServicesUsageFlags theIconServicesUsageFlags; IconRef theIconRef; + #ifndef PtInIconRef + PyMac_PRECHECK(PtInIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&O&hlO&", PyMac_GetPoint, &testPt, *************** *** 1019,1022 **** --- 1166,1172 ---- IconServicesUsageFlags iconServicesUsageFlags; IconRef theIconRef; + #ifndef RectInIconRef + PyMac_PRECHECK(RectInIconRef); + #endif if (!PyArg_ParseTuple(_args, "O&O&hlO&", PyMac_GetRect, &testRect, *************** *** 1045,1048 **** --- 1195,1201 ---- IconServicesUsageFlags iconServicesUsageFlags; IconRef theIconRef; + #ifndef IconRefToRgn + PyMac_PRECHECK(IconRefToRgn); + #endif if (!PyArg_ParseTuple(_args, "O&O&hlO&", ResObj_Convert, &theRgn, *************** *** 1071,1074 **** --- 1224,1230 ---- IconServicesUsageFlags iconServicesUsageFlags; IconRef theIconRef; + #ifndef GetIconSizesFromIconRef + PyMac_PRECHECK(GetIconSizesFromIconRef); + #endif if (!PyArg_ParseTuple(_args, "llO&", &iconSelectorInput, *************** *** 1092,1095 **** --- 1248,1254 ---- OSType creator; OSType iconType; + #ifndef FlushIconRefs + PyMac_PRECHECK(FlushIconRefs); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &creator, *************** *** 1109,1112 **** --- 1268,1274 ---- OSErr _err; SInt16 vRefNum; + #ifndef FlushIconRefsByVolume + PyMac_PRECHECK(FlushIconRefsByVolume); + #endif if (!PyArg_ParseTuple(_args, "h", &vRefNum)) *************** *** 1125,1128 **** --- 1287,1293 ---- SInt16 vRefNum; Boolean enableCustomIcons; + #ifndef SetCustomIconsEnabled + PyMac_PRECHECK(SetCustomIconsEnabled); + #endif if (!PyArg_ParseTuple(_args, "hb", &vRefNum, *************** *** 1143,1146 **** --- 1308,1314 ---- SInt16 vRefNum; Boolean customIconsEnabled; + #ifndef GetCustomIconsEnabled + PyMac_PRECHECK(GetCustomIconsEnabled); + #endif if (!PyArg_ParseTuple(_args, "h", &vRefNum)) *************** *** 1159,1162 **** --- 1327,1333 ---- Boolean _rv; IconRef iconRef; + #ifndef IsIconRefMaskEmpty + PyMac_PRECHECK(IsIconRefMaskEmpty); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &iconRef)) *************** *** 1177,1180 **** --- 1348,1354 ---- OSType inVariant; IconTransformType outTransform; + #ifndef GetIconRefVariant + PyMac_PRECHECK(GetIconRefVariant); + #endif if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &inIconRef, *************** *** 1201,1204 **** --- 1375,1381 ---- FSSpec iconFile; IconRef theIconRef; + #ifndef RegisterIconRefFromIconFile + PyMac_PRECHECK(RegisterIconRefFromIconFile); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&", PyMac_GetOSType, &creator, *************** *** 1225,1228 **** --- 1402,1408 ---- FSSpec iconFile; IconFamilyHandle iconFamily; + #ifndef ReadIconFile + PyMac_PRECHECK(ReadIconFile); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetFSSpec, &iconFile)) *************** *** 1245,1248 **** --- 1425,1431 ---- IconFamilyHandle iconFamily; FSSpec iconFile; + #ifndef WriteIconFile + PyMac_PRECHECK(WriteIconFile); + #endif if (!PyArg_ParseTuple(_args, "O&O&", ResObj_Convert, &iconFamily, Index: icnsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/icn/icnsupport.py,v retrieving revision 1.6 retrieving revision 1.6.14.1 diff -C2 -d -r1.6 -r1.6.14.1 *** icnsupport.py 23 Aug 2001 13:49:36 -0000 1.6 --- icnsupport.py 25 Mar 2002 10:45:21 -0000 1.6.14.1 *************** *** 76,80 **** # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator ##Method = OSErrMethodGenerator --- 76,80 ---- # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator ##Method = OSErrMethodGenerator From jackjansen@users.sourceforge.net Mon Mar 25 10:57:01 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 25 Mar 2002 02:57:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/fm _Fmmodule.c,1.4.4.1,1.4.4.2 fmsupport.py,1.4.14.1,1.4.14.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/fm In directory usw-pr-cvs1:/tmp/cvs-serv10071 Modified Files: Tag: release22-maint _Fmmodule.c fmsupport.py Log Message: Backport of _Fmmodule.c 1.6 and fmsupport.py 1.6: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _Fmmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/fm/_Fmmodule.c,v retrieving revision 1.4.4.1 retrieving revision 1.4.4.2 diff -C2 -d -r1.4.4.1 -r1.4.4.2 *** _Fmmodule.c 27 Feb 2002 23:13:04 -0000 1.4.4.1 --- _Fmmodule.c 25 Mar 2002 10:56:59 -0000 1.4.4.2 *************** *** 65,68 **** --- 65,71 ---- { PyObject *_res = NULL; + #ifndef InitFonts + PyMac_PRECHECK(InitFonts); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 79,82 **** --- 82,88 ---- short familyID; Str255 name; + #ifndef GetFontName + PyMac_PRECHECK(GetFontName); + #endif if (!PyArg_ParseTuple(_args, "h", &familyID)) *************** *** 94,97 **** --- 100,106 ---- Str255 name; short familyID; + #ifndef GetFNum + PyMac_PRECHECK(GetFNum); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetStr255, name)) *************** *** 110,113 **** --- 119,125 ---- short fontNum; short size; + #ifndef RealFont + PyMac_PRECHECK(RealFont); + #endif if (!PyArg_ParseTuple(_args, "hh", &fontNum, *************** *** 127,130 **** --- 139,145 ---- PyObject *_res = NULL; Boolean lockFlag; + #ifndef SetFontLock + PyMac_PRECHECK(SetFontLock); + #endif if (!PyArg_ParseTuple(_args, "b", &lockFlag)) *************** *** 141,144 **** --- 156,162 ---- PyObject *_res = NULL; Boolean fscaleDisable; + #ifndef SetFScaleDisable + PyMac_PRECHECK(SetFScaleDisable); + #endif if (!PyArg_ParseTuple(_args, "b", &fscaleDisable)) *************** *** 154,157 **** --- 172,178 ---- PyObject *_res = NULL; FMetricRec theMetrics; + #ifndef FontMetrics + PyMac_PRECHECK(FontMetrics); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 166,169 **** --- 187,193 ---- PyObject *_res = NULL; Boolean fractEnable; + #ifndef SetFractEnable + PyMac_PRECHECK(SetFractEnable); + #endif if (!PyArg_ParseTuple(_args, "b", &fractEnable)) *************** *** 179,182 **** --- 203,209 ---- PyObject *_res = NULL; short _rv; + #ifndef GetDefFontSize + PyMac_PRECHECK(GetDefFontSize); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 193,196 **** --- 220,226 ---- Point numer; Point denom; + #ifndef IsOutline + PyMac_PRECHECK(IsOutline); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetPoint, &numer, *************** *** 208,211 **** --- 238,244 ---- PyObject *_res = NULL; Boolean outlinePreferred; + #ifndef SetOutlinePreferred + PyMac_PRECHECK(SetOutlinePreferred); + #endif if (!PyArg_ParseTuple(_args, "b", &outlinePreferred)) *************** *** 221,224 **** --- 254,260 ---- PyObject *_res = NULL; Boolean _rv; + #ifndef GetOutlinePreferred + PyMac_PRECHECK(GetOutlinePreferred); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 233,236 **** --- 269,275 ---- PyObject *_res = NULL; Boolean preserveGlyph; + #ifndef SetPreserveGlyph + PyMac_PRECHECK(SetPreserveGlyph); + #endif if (!PyArg_ParseTuple(_args, "b", &preserveGlyph)) *************** *** 246,249 **** --- 285,291 ---- PyObject *_res = NULL; Boolean _rv; + #ifndef GetPreserveGlyph + PyMac_PRECHECK(GetPreserveGlyph); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 260,263 **** --- 302,308 ---- PyObject *_res = NULL; OSErr _err; + #ifndef FlushFonts + PyMac_PRECHECK(FlushFonts); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 274,277 **** --- 319,325 ---- PyObject *_res = NULL; short _rv; + #ifndef GetSysFont + PyMac_PRECHECK(GetSysFont); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 286,289 **** --- 334,340 ---- PyObject *_res = NULL; short _rv; + #ifndef GetAppFont + PyMac_PRECHECK(GetAppFont); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 301,304 **** --- 352,358 ---- int inText__in_len__; Rect bounds; + #ifndef QDTextBounds + PyMac_PRECHECK(QDTextBounds); + #endif if (!PyArg_ParseTuple(_args, "s#", &inText__in__, &inText__in_len__)) Index: fmsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/fm/fmsupport.py,v retrieving revision 1.4.14.1 retrieving revision 1.4.14.2 diff -C2 -d -r1.4.14.1 -r1.4.14.2 *** fmsupport.py 27 Feb 2002 23:13:06 -0000 1.4.14.1 --- fmsupport.py 25 Mar 2002 10:56:59 -0000 1.4.14.2 *************** *** 71,75 **** # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator # Create and populate the lists --- 71,75 ---- # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator # Create and populate the lists From jackjansen@users.sourceforge.net Mon Mar 25 11:14:31 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 25 Mar 2002 03:14:31 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/evt _Evtmodule.c,1.5,1.5.4.1 evtsupport.py,1.14,1.14.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/evt In directory usw-pr-cvs1:/tmp/cvs-serv27680 Modified Files: Tag: release22-maint _Evtmodule.c evtsupport.py Log Message: Backport of _Evtmodule.c 1.6, evtsupport.py 1.15: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _Evtmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/evt/_Evtmodule.c,v retrieving revision 1.5 retrieving revision 1.5.4.1 diff -C2 -d -r1.5 -r1.5.4.1 *** _Evtmodule.c 17 Dec 2001 11:46:45 -0000 1.5 --- _Evtmodule.c 25 Mar 2002 11:14:28 -0000 1.5.4.1 *************** *** 34,37 **** --- 34,40 ---- PyObject *_res = NULL; Point mouseLoc; + #ifndef GetMouse + PyMac_PRECHECK(GetMouse); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 46,49 **** --- 49,55 ---- PyObject *_res = NULL; Boolean _rv; + #ifndef Button + PyMac_PRECHECK(Button); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 58,61 **** --- 64,70 ---- PyObject *_res = NULL; Boolean _rv; + #ifndef StillDown + PyMac_PRECHECK(StillDown); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 70,73 **** --- 79,85 ---- PyObject *_res = NULL; Boolean _rv; + #ifndef WaitMouseUp + PyMac_PRECHECK(WaitMouseUp); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 82,85 **** --- 94,100 ---- PyObject *_res = NULL; UInt32 _rv; + #ifndef GetCaretTime + PyMac_PRECHECK(GetCaretTime); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 94,97 **** --- 109,115 ---- PyObject *_res = NULL; KeyMap theKeys__out__; + #ifndef GetKeys + PyMac_PRECHECK(GetKeys); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 106,109 **** --- 124,130 ---- PyObject *_res = NULL; UInt32 _rv; + #ifndef GetDblTime + PyMac_PRECHECK(GetDblTime); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 118,121 **** --- 139,145 ---- PyObject *_res = NULL; EventMask value; + #ifndef SetEventMask + PyMac_PRECHECK(SetEventMask); + #endif if (!PyArg_ParseTuple(_args, "H", &value)) *************** *** 133,136 **** --- 157,163 ---- EventMask eventMask; EventRecord theEvent; + #ifndef GetNextEvent + PyMac_PRECHECK(GetNextEvent); + #endif if (!PyArg_ParseTuple(_args, "H", &eventMask)) *************** *** 150,153 **** --- 177,183 ---- EventMask eventMask; EventRecord theEvent; + #ifndef EventAvail + PyMac_PRECHECK(EventAvail); + #endif if (!PyArg_ParseTuple(_args, "H", &eventMask)) *************** *** 167,170 **** --- 197,203 ---- EventKind eventNum; UInt32 eventMsg; + #ifndef PostEvent + PyMac_PRECHECK(PostEvent); + #endif if (!PyArg_ParseTuple(_args, "Hl", &eventNum, *************** *** 187,190 **** --- 220,226 ---- EventMask mask; EventRecord theEvent; + #ifndef OSEventAvail + PyMac_PRECHECK(OSEventAvail); + #endif if (!PyArg_ParseTuple(_args, "H", &mask)) *************** *** 207,210 **** --- 243,249 ---- EventMask mask; EventRecord theEvent; + #ifndef GetOSEvent + PyMac_PRECHECK(GetOSEvent); + #endif if (!PyArg_ParseTuple(_args, "H", &mask)) *************** *** 224,227 **** --- 263,269 ---- EventMask whichMask; EventMask stopMask; + #ifndef FlushEvents + PyMac_PRECHECK(FlushEvents); + #endif if (!PyArg_ParseTuple(_args, "HH", &whichMask, *************** *** 242,245 **** --- 284,290 ---- EventRecord theEvent; WindowPtr theWindow; + #ifndef SystemClick + PyMac_PRECHECK(SystemClick); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetEventRecord, &theEvent, *************** *** 259,262 **** --- 304,310 ---- { PyObject *_res = NULL; + #ifndef SystemTask + PyMac_PRECHECK(SystemTask); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 275,278 **** --- 323,329 ---- Boolean _rv; EventRecord theEvent; + #ifndef SystemEvent + PyMac_PRECHECK(SystemEvent); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetEventRecord, &theEvent)) *************** *** 291,294 **** --- 342,348 ---- PyObject *_res = NULL; Point globalMouse; + #ifndef GetGlobalMouse + PyMac_PRECHECK(GetGlobalMouse); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 306,309 **** --- 360,366 ---- PyObject *_res = NULL; UInt32 _rv; + #ifndef GetCurrentKeyModifiers + PyMac_PRECHECK(GetCurrentKeyModifiers); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 321,324 **** --- 378,384 ---- PyObject *_res = NULL; Boolean _rv; + #ifndef CheckEventQueueForUserCancel + PyMac_PRECHECK(CheckEventQueueForUserCancel); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 334,337 **** --- 394,400 ---- PyObject *_res = NULL; short code; + #ifndef KeyScript + PyMac_PRECHECK(KeyScript); + #endif if (!PyArg_ParseTuple(_args, "h", &code)) *************** *** 349,352 **** --- 412,418 ---- EventRecord event; short test; + #ifndef IsCmdChar + PyMac_PRECHECK(IsCmdChar); + #endif if (!PyArg_ParseTuple(_args, "O&h", PyMac_GetEventRecord, &event, *************** *** 364,367 **** --- 430,436 ---- PyObject *_res = NULL; SInt16 _rv; + #ifndef LMGetKeyThresh + PyMac_PRECHECK(LMGetKeyThresh); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 376,379 **** --- 445,451 ---- PyObject *_res = NULL; SInt16 value; + #ifndef LMSetKeyThresh + PyMac_PRECHECK(LMSetKeyThresh); + #endif if (!PyArg_ParseTuple(_args, "h", &value)) *************** *** 389,392 **** --- 461,467 ---- PyObject *_res = NULL; SInt16 _rv; + #ifndef LMGetKeyRepThresh + PyMac_PRECHECK(LMGetKeyRepThresh); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 401,404 **** --- 476,482 ---- PyObject *_res = NULL; SInt16 value; + #ifndef LMSetKeyRepThresh + PyMac_PRECHECK(LMSetKeyRepThresh); + #endif if (!PyArg_ParseTuple(_args, "h", &value)) *************** *** 414,417 **** --- 492,498 ---- PyObject *_res = NULL; UInt8 _rv; + #ifndef LMGetKbdLast + PyMac_PRECHECK(LMGetKbdLast); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 426,429 **** --- 507,513 ---- PyObject *_res = NULL; UInt8 value; + #ifndef LMSetKbdLast + PyMac_PRECHECK(LMSetKbdLast); + #endif if (!PyArg_ParseTuple(_args, "b", &value)) *************** *** 439,442 **** --- 523,529 ---- PyObject *_res = NULL; UInt8 _rv; + #ifndef LMGetKbdType + PyMac_PRECHECK(LMGetKbdType); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 451,454 **** --- 538,544 ---- PyObject *_res = NULL; UInt8 value; + #ifndef LMSetKbdType + PyMac_PRECHECK(LMSetKbdType); + #endif if (!PyArg_ParseTuple(_args, "b", &value)) *************** *** 464,467 **** --- 554,560 ---- PyObject *_res = NULL; UInt32 _rv; + #ifndef TickCount + PyMac_PRECHECK(TickCount); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; Index: evtsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/evt/evtsupport.py,v retrieving revision 1.14 retrieving revision 1.14.4.1 diff -C2 -d -r1.14 -r1.14.4.1 *** evtsupport.py 17 Dec 2001 11:46:50 -0000 1.14 --- evtsupport.py 25 Mar 2002 11:14:28 -0000 1.14.4.1 *************** *** 65,70 **** # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator ! ##Method = OSErrMethodGenerator # Create and populate the lists --- 65,70 ---- # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator ! ##Method = OSErrWeakLinkMethodGenerator # Create and populate the lists From doerwalter@users.sourceforge.net Mon Mar 25 11:16:20 2002 From: doerwalter@users.sourceforge.net (Walter D?rwald) Date: Mon, 25 Mar 2002 03:16:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.132,2.133 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv30807/Objects Modified Files: unicodeobject.c Log Message: Fix whitespace. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.132 retrieving revision 2.133 diff -C2 -d -r2.132 -r2.133 *** unicodeobject.c 22 Mar 2002 15:33:15 -0000 2.132 --- unicodeobject.c 25 Mar 2002 11:16:18 -0000 2.133 *************** *** 1644,1651 **** } s += i; ! if (chr == 0xffffffff) ! /* _decoding_error will have already written into the ! target buffer. */ ! break; store: /* when we get here, chr is a 32-bit unicode character */ --- 1644,1651 ---- } s += i; ! if (chr == 0xffffffff) ! /* _decoding_error will have already written into the ! target buffer. */ ! break; store: /* when we get here, chr is a 32-bit unicode character */ *************** *** 1655,1659 **** else if (chr <= 0x10ffff) { /* UCS-4 character. Either store directly, or as ! surrogate pair. */ #ifdef Py_UNICODE_WIDE *p++ = chr; --- 1655,1659 ---- else if (chr <= 0x10ffff) { /* UCS-4 character. Either store directly, or as ! surrogate pair. */ #ifdef Py_UNICODE_WIDE *p++ = chr; *************** *** 1708,1726 **** default: ! if (s > end) { ! if (unicodeescape_decoding_error(&p, errors, "\\ at end of string")) ! goto onError; ! } ! else { ! *p++ = '\\'; ! *p++ = (unsigned char)s[-1]; ! } break; } } if (_PyUnicode_Resize(&v, (int)(p - buf))) ! goto onError; return (PyObject *)v; ! ucnhashError: PyErr_SetString( --- 1708,1726 ---- default: ! if (s > end) { ! if (unicodeescape_decoding_error(&p, errors, "\\ at end of string")) ! goto onError; ! } ! else { ! *p++ = '\\'; ! *p++ = (unsigned char)s[-1]; ! } break; } } if (_PyUnicode_Resize(&v, (int)(p - buf))) ! goto onError; return (PyObject *)v; ! ucnhashError: PyErr_SetString( From jackjansen@users.sourceforge.net Mon Mar 25 12:17:30 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 25 Mar 2002 04:17:30 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/drag _Dragmodule.c,1.6.4.1,1.6.4.2 dragsupport.py,1.8.14.1,1.8.14.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/drag In directory usw-pr-cvs1:/tmp/cvs-serv19429 Modified Files: Tag: release22-maint _Dragmodule.c dragsupport.py Log Message: Backport of _Dragmodule.c 1.8, dragsupport.py 1.10: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _Dragmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/drag/_Dragmodule.c,v retrieving revision 1.6.4.1 retrieving revision 1.6.4.2 diff -C2 -d -r1.6.4.1 -r1.6.4.2 *** _Dragmodule.c 27 Feb 2002 23:12:31 -0000 1.6.4.1 --- _Dragmodule.c 25 Mar 2002 12:17:28 -0000 1.6.4.2 *************** *** 92,95 **** --- 92,98 ---- PyObject *_res = NULL; OSErr _err; + #ifndef DisposeDrag + PyMac_PRECHECK(DisposeDrag); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 111,114 **** --- 114,120 ---- int dataPtr__in_len__; FlavorFlags theFlags; + #ifndef AddDragItemFlavor + PyMac_PRECHECK(AddDragItemFlavor); + #endif if (!PyArg_ParseTuple(_args, "lO&z#l", &theItemRef, *************** *** 139,142 **** --- 145,151 ---- int dataPtr__in_len__; UInt32 dataOffset; + #ifndef SetDragItemFlavorData + PyMac_PRECHECK(SetDragItemFlavorData); + #endif if (!PyArg_ParseTuple(_args, "lO&z#l", &theItemRef, *************** *** 165,168 **** --- 174,180 ---- Point imageOffsetPt; DragImageFlags theImageFlags; + #ifndef SetDragImage + PyMac_PRECHECK(SetDragImage); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&l", ResObj_Convert, &imagePixMap, *************** *** 188,191 **** --- 200,206 ---- DragBehaviors inBehaviorsToSet; DragBehaviors inBehaviorsToClear; + #ifndef ChangeDragBehaviors + PyMac_PRECHECK(ChangeDragBehaviors); + #endif if (!PyArg_ParseTuple(_args, "ll", &inBehaviorsToSet, *************** *** 207,210 **** --- 222,228 ---- EventRecord theEvent; RgnHandle theRegion; + #ifndef TrackDrag + PyMac_PRECHECK(TrackDrag); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetEventRecord, &theEvent, *************** *** 225,228 **** --- 243,249 ---- OSErr _err; UInt16 numItems; + #ifndef CountDragItems + PyMac_PRECHECK(CountDragItems); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 241,244 **** --- 262,268 ---- UInt16 index; ItemReference theItemRef; + #ifndef GetDragItemReferenceNumber + PyMac_PRECHECK(GetDragItemReferenceNumber); + #endif if (!PyArg_ParseTuple(_args, "H", &index)) *************** *** 259,262 **** --- 283,289 ---- ItemReference theItemRef; UInt16 numFlavors; + #ifndef CountDragItemFlavors + PyMac_PRECHECK(CountDragItemFlavors); + #endif if (!PyArg_ParseTuple(_args, "l", &theItemRef)) *************** *** 278,281 **** --- 305,311 ---- UInt16 index; FlavorType theType; + #ifndef GetFlavorType + PyMac_PRECHECK(GetFlavorType); + #endif if (!PyArg_ParseTuple(_args, "lH", &theItemRef, *************** *** 299,302 **** --- 329,335 ---- FlavorType theType; FlavorFlags theFlags; + #ifndef GetFlavorFlags + PyMac_PRECHECK(GetFlavorFlags); + #endif if (!PyArg_ParseTuple(_args, "lO&", &theItemRef, *************** *** 320,323 **** --- 353,359 ---- FlavorType theType; Size dataSize; + #ifndef GetFlavorDataSize + PyMac_PRECHECK(GetFlavorDataSize); + #endif if (!PyArg_ParseTuple(_args, "lO&", &theItemRef, *************** *** 344,347 **** --- 380,386 ---- int dataPtr__in_len__; UInt32 dataOffset; + #ifndef GetFlavorData + PyMac_PRECHECK(GetFlavorData); + #endif if (!PyArg_ParseTuple(_args, "lO&il", &theItemRef, *************** *** 375,378 **** --- 414,420 ---- ItemReference theItemRef; Rect itemBounds; + #ifndef GetDragItemBounds + PyMac_PRECHECK(GetDragItemBounds); + #endif if (!PyArg_ParseTuple(_args, "l", &theItemRef)) *************** *** 393,396 **** --- 435,441 ---- ItemReference theItemRef; Rect itemBounds; + #ifndef SetDragItemBounds + PyMac_PRECHECK(SetDragItemBounds); + #endif if (!PyArg_ParseTuple(_args, "lO&", &theItemRef, *************** *** 411,414 **** --- 456,462 ---- OSErr _err; AEDesc dropLocation; + #ifndef GetDropLocation + PyMac_PRECHECK(GetDropLocation); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 426,429 **** --- 474,480 ---- OSErr _err; AEDesc dropLocation; + #ifndef SetDropLocation + PyMac_PRECHECK(SetDropLocation); + #endif if (!PyArg_ParseTuple(_args, "O&", AEDesc_Convert, &dropLocation)) *************** *** 442,445 **** --- 493,499 ---- OSErr _err; DragAttributes flags; + #ifndef GetDragAttributes + PyMac_PRECHECK(GetDragAttributes); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 458,461 **** --- 512,518 ---- Point mouse; Point globalPinnedMouse; + #ifndef GetDragMouse + PyMac_PRECHECK(GetDragMouse); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 475,478 **** --- 532,538 ---- OSErr _err; Point globalPinnedMouse; + #ifndef SetDragMouse + PyMac_PRECHECK(SetDragMouse); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetPoint, &globalPinnedMouse)) *************** *** 491,494 **** --- 551,557 ---- OSErr _err; Point globalInitialMouse; + #ifndef GetDragOrigin + PyMac_PRECHECK(GetDragOrigin); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 508,511 **** --- 571,577 ---- SInt16 mouseDownModifiers; SInt16 mouseUpModifiers; + #ifndef GetDragModifiers + PyMac_PRECHECK(GetDragModifiers); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 528,531 **** --- 594,600 ---- RgnHandle hiliteFrame; Boolean inside; + #ifndef ShowDragHilite + PyMac_PRECHECK(ShowDragHilite); + #endif if (!PyArg_ParseTuple(_args, "O&b", ResObj_Convert, &hiliteFrame, *************** *** 545,548 **** --- 614,620 ---- PyObject *_res = NULL; OSErr _err; + #ifndef HideDragHilite + PyMac_PRECHECK(HideDragHilite); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 560,563 **** --- 632,638 ---- SInt16 dH; SInt16 dV; + #ifndef DragPreScroll + PyMac_PRECHECK(DragPreScroll); + #endif if (!PyArg_ParseTuple(_args, "hh", &dH, *************** *** 577,580 **** --- 652,658 ---- PyObject *_res = NULL; OSErr _err; + #ifndef DragPostScroll + PyMac_PRECHECK(DragPostScroll); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 591,594 **** --- 669,675 ---- OSErr _err; RgnHandle updateRgn; + #ifndef UpdateDragHilite + PyMac_PRECHECK(UpdateDragHilite); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &updateRgn)) *************** *** 702,705 **** --- 783,789 ---- OSErr _err; DragRef theDrag; + #ifndef NewDrag + PyMac_PRECHECK(NewDrag); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 717,720 **** --- 801,807 ---- WindowPtr window; RGBColor color; + #ifndef GetDragHiliteColor + PyMac_PRECHECK(GetDragHiliteColor); + #endif if (!PyArg_ParseTuple(_args, "O&", WinObj_Convert, &window)) *************** *** 733,736 **** --- 820,826 ---- Boolean _rv; Point initialMouse; + #ifndef WaitMouseMoved + PyMac_PRECHECK(WaitMouseMoved); + #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetPoint, &initialMouse)) *************** *** 750,753 **** --- 840,846 ---- SInt16 zoomSteps; ZoomAcceleration acceleration; + #ifndef ZoomRects + PyMac_PRECHECK(ZoomRects); + #endif if (!PyArg_ParseTuple(_args, "O&O&hh", PyMac_GetRect, &fromRect, *************** *** 774,777 **** --- 867,873 ---- SInt16 zoomSteps; ZoomAcceleration acceleration; + #ifndef ZoomRegion + PyMac_PRECHECK(ZoomRegion); + #endif if (!PyArg_ParseTuple(_args, "O&O&hh", ResObj_Convert, ®ion, Index: dragsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/drag/dragsupport.py,v retrieving revision 1.8.14.1 retrieving revision 1.8.14.2 diff -C2 -d -r1.8.14.1 -r1.8.14.2 *** dragsupport.py 27 Feb 2002 23:12:31 -0000 1.8.14.1 --- dragsupport.py 25 Mar 2002 12:17:28 -0000 1.8.14.2 *************** *** 215,220 **** # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator ! Method = OSErrMethodGenerator # Create and populate the lists --- 215,220 ---- # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator ! Method = OSErrWeakLinkMethodGenerator # Create and populate the lists From jackjansen@users.sourceforge.net Mon Mar 25 12:20:45 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 25 Mar 2002 04:20:45 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/qd _Qdmodule.c,1.7,1.7.4.1 qdsupport.py,1.37,1.37.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/qd In directory usw-pr-cvs1:/tmp/cvs-serv21711 Modified Files: Tag: release22-maint _Qdmodule.c qdsupport.py Log Message: Backport of _Qdmodule.c 1.8, qdsupport.py 1.38: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _Qdmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/qd/_Qdmodule.c,v retrieving revision 1.7 retrieving revision 1.7.4.1 diff -C2 -d -r1.7 -r1.7.4.1 *** _Qdmodule.c 18 Dec 2001 15:37:03 -0000 1.7 --- _Qdmodule.c 25 Mar 2002 12:20:42 -0000 1.7.4.1 *************** *** 658,661 **** --- 658,664 ---- PyObject *_res = NULL; GrafPtr port; + #ifndef MacSetPort + PyMac_PRECHECK(MacSetPort); + #endif if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) *************** *** 671,674 **** [...3078 lines suppressed...] *************** *** 5442,5445 **** --- 6369,6375 ---- Point pt; Rect r; + #ifndef PtInRect + PyMac_PRECHECK(PtInRect); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetPoint, &pt, *************** *** 5460,5463 **** --- 6390,6396 ---- short firstByte; short byteCount; + #ifndef DrawText + PyMac_PRECHECK(DrawText); + #endif if (!PyArg_ParseTuple(_args, "s#hh", &textBuf__in__, &textBuf__in_len__, Index: qdsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/qd/qdsupport.py,v retrieving revision 1.37 retrieving revision 1.37.4.1 diff -C2 -d -r1.37 -r1.37.4.1 *** qdsupport.py 18 Dec 2001 15:39:23 -0000 1.37 --- qdsupport.py 25 Mar 2002 12:20:43 -0000 1.37.4.1 *************** *** 549,554 **** # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator ! Method = OSErrMethodGenerator # Create and populate the lists --- 549,554 ---- # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator ! Method = OSErrWeakLinkMethodGenerator # Create and populate the lists From mwh@users.sourceforge.net Mon Mar 25 12:24:26 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 25 Mar 2002 04:24:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc python-mode.el,4.6.18.1,4.6.18.2 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv25709 Modified Files: Tag: release22-maint python-mode.el Log Message: backport bwarsaw's checkin of revision 4.8 of python-mode.el (py-temp-directory): Add /var/tmp to the list of directories this searches. This is added after /tmp. Closes SF bug #505488, except that /var/tmp comes after /tmp instead of the patch's suggestion of putting it before /usr/tmp. Index: python-mode.el =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/python-mode.el,v retrieving revision 4.6.18.1 retrieving revision 4.6.18.2 diff -C2 -d -r4.6.18.1 -r4.6.18.2 *** python-mode.el 16 Mar 2002 18:03:42 -0000 4.6.18.1 --- python-mode.el 25 Mar 2002 12:24:24 -0000 4.6.18.2 *************** *** 205,215 **** (funcall ok "/usr/tmp") (funcall ok "/tmp") (funcall ok ".") (error "Couldn't find a usable temp directory -- set `py-temp-directory'"))) ! "*Directory used for temp files created by a *Python* process. By default, the first directory from this list that exists and that you ! can write into: the value (if any) of the environment variable TMPDIR, ! /usr/tmp, /tmp, or the current directory." :type 'string :group 'python) --- 205,216 ---- (funcall ok "/usr/tmp") (funcall ok "/tmp") + (funcall ok "/var/tmp") (funcall ok ".") (error "Couldn't find a usable temp directory -- set `py-temp-directory'"))) ! "*Directory used for temporary files created by a *Python* process. By default, the first directory from this list that exists and that you ! can write into: the value (if any) of the environment variable TMPDIR, ! /usr/tmp, /tmp, /var/tmp, or the current directory." :type 'string :group 'python) From jackjansen@users.sourceforge.net Mon Mar 25 12:24:52 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 25 Mar 2002 04:24:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Modules/cm _Cmmodule.c,1.7,1.7.4.1 cmsupport.py,1.5,1.5.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/cm In directory usw-pr-cvs1:/tmp/cvs-serv24571 Modified Files: Tag: release22-maint _Cmmodule.c cmsupport.py Log Message: Backport of _Cmmodule.c 1.8 and cmsupport.py 1.6: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. Index: _Cmmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cm/_Cmmodule.c,v retrieving revision 1.7 retrieving revision 1.7.4.1 diff -C2 -d -r1.7 -r1.7.4.1 *** _Cmmodule.c 18 Dec 2001 15:38:17 -0000 1.7 --- _Cmmodule.c 25 Mar 2002 12:24:50 -0000 1.7.4.1 *************** *** 110,113 **** --- 110,116 ---- PyObject *_res = NULL; OSErr _err; + #ifndef CloseComponent + PyMac_PRECHECK(CloseComponent); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 123,126 **** --- 126,132 ---- PyObject *_res = NULL; OSErr _err; + #ifndef GetComponentInstanceError + PyMac_PRECHECK(GetComponentInstanceError); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 136,139 **** --- 142,148 ---- PyObject *_res = NULL; OSErr theError; + #ifndef SetComponentInstanceError + PyMac_PRECHECK(SetComponentInstanceError); + #endif if (!PyArg_ParseTuple(_args, "h", &theError)) *************** *** 150,153 **** --- 159,165 ---- PyObject *_res = NULL; Handle _rv; + #ifndef GetComponentInstanceStorage + PyMac_PRECHECK(GetComponentInstanceStorage); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 162,165 **** --- 174,180 ---- PyObject *_res = NULL; Handle theStorage; + #ifndef SetComponentInstanceStorage + PyMac_PRECHECK(SetComponentInstanceStorage); + #endif if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &theStorage)) *************** *** 178,181 **** --- 193,199 ---- PyObject *_res = NULL; long _rv; + #ifndef GetComponentInstanceA5 + PyMac_PRECHECK(GetComponentInstanceA5); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 193,196 **** --- 211,217 ---- PyObject *_res = NULL; long theA5; + #ifndef SetComponentInstanceA5 + PyMac_PRECHECK(SetComponentInstanceA5); + #endif if (!PyArg_ParseTuple(_args, "l", &theA5)) *************** *** 209,212 **** --- 230,236 ---- long _rv; short ftnNumber; + #ifndef ComponentFunctionImplemented + PyMac_PRECHECK(ComponentFunctionImplemented); + #endif if (!PyArg_ParseTuple(_args, "h", &ftnNumber)) *************** *** 223,226 **** --- 247,253 ---- PyObject *_res = NULL; long _rv; + #ifndef GetComponentVersion + PyMac_PRECHECK(GetComponentVersion); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 236,239 **** --- 263,269 ---- long _rv; ComponentInstance target; + #ifndef ComponentSetTarget + PyMac_PRECHECK(ComponentSetTarget); + #endif if (!PyArg_ParseTuple(_args, "O&", CmpInstObj_Convert, &target)) *************** *** 362,365 **** --- 392,398 ---- PyObject *_res = NULL; OSErr _err; + #ifndef UnregisterComponent + PyMac_PRECHECK(UnregisterComponent); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 379,382 **** --- 412,418 ---- Handle componentInfo; Handle componentIcon; + #ifndef GetComponentInfo + PyMac_PRECHECK(GetComponentInfo); + #endif if (!PyArg_ParseTuple(_args, "O&O&O&", ResObj_Convert, &componentName, *************** *** 399,402 **** --- 435,441 ---- PyObject *_res = NULL; ComponentInstance _rv; + #ifndef OpenComponent + PyMac_PRECHECK(OpenComponent); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 411,414 **** --- 450,456 ---- PyObject *_res = NULL; Component _rv; + #ifndef ResolveComponentAlias + PyMac_PRECHECK(ResolveComponentAlias); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 426,429 **** --- 468,474 ---- short strListID; short index; + #ifndef GetComponentPublicIndString + PyMac_PRECHECK(GetComponentPublicIndString); + #endif if (!PyArg_ParseTuple(_args, "O&hh", PyMac_GetStr255, theString, *************** *** 445,448 **** --- 490,496 ---- PyObject *_res = NULL; long _rv; + #ifndef GetComponentRefcon + PyMac_PRECHECK(GetComponentRefcon); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 457,460 **** --- 505,511 ---- PyObject *_res = NULL; long theRefcon; + #ifndef SetComponentRefcon + PyMac_PRECHECK(SetComponentRefcon); + #endif if (!PyArg_ParseTuple(_args, "l", &theRefcon)) *************** *** 471,474 **** --- 522,528 ---- PyObject *_res = NULL; short _rv; + #ifndef OpenComponentResFile + PyMac_PRECHECK(OpenComponentResFile); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 486,489 **** --- 540,546 ---- short resID; Handle theResource; + #ifndef GetComponentResource + PyMac_PRECHECK(GetComponentResource); + #endif if (!PyArg_ParseTuple(_args, "O&h", PyMac_GetOSType, &resType, *************** *** 507,510 **** --- 564,570 ---- short strListID; short index; + #ifndef GetComponentIndString + PyMac_PRECHECK(GetComponentIndString); + #endif if (!PyArg_ParseTuple(_args, "O&hh", PyMac_GetStr255, theString, *************** *** 526,529 **** --- 586,592 ---- PyObject *_res = NULL; long _rv; + #ifndef CountComponentInstances + PyMac_PRECHECK(CountComponentInstances); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 539,542 **** --- 602,608 ---- OSErr _err; short flags; + #ifndef SetDefaultComponent + PyMac_PRECHECK(SetDefaultComponent); + #endif if (!PyArg_ParseTuple(_args, "h", &flags)) *************** *** 555,558 **** --- 621,627 ---- Component _rv; Component capturingComponent; + #ifndef CaptureComponent + PyMac_PRECHECK(CaptureComponent); + #endif if (!PyArg_ParseTuple(_args, "O&", CmpObj_Convert, &capturingComponent)) *************** *** 569,572 **** --- 638,644 ---- PyObject *_res = NULL; OSErr _err; + #ifndef UncaptureComponent + PyMac_PRECHECK(UncaptureComponent); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 583,586 **** --- 655,661 ---- OSErr _err; Handle iconSuite; + #ifndef GetComponentIconSuite + PyMac_PRECHECK(GetComponentIconSuite); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 670,673 **** --- 745,751 ---- ComponentResourceHandle cr; short global; + #ifndef RegisterComponentResource + PyMac_PRECHECK(RegisterComponentResource); + #endif if (!PyArg_ParseTuple(_args, "O&h", ResObj_Convert, &cr, *************** *** 687,690 **** --- 765,771 ---- Component aComponent; ComponentDescription looking; + #ifndef FindNextComponent + PyMac_PRECHECK(FindNextComponent); + #endif if (!PyArg_ParseTuple(_args, "O&O&", CmpObj_Convert, &aComponent, *************** *** 703,706 **** --- 784,790 ---- long _rv; ComponentDescription looking; + #ifndef CountComponents + PyMac_PRECHECK(CountComponents); + #endif if (!PyArg_ParseTuple(_args, "O&", CmpDesc_Convert, &looking)) *************** *** 716,719 **** --- 800,806 ---- PyObject *_res = NULL; long _rv; + #ifndef GetComponentListModSeed + PyMac_PRECHECK(GetComponentListModSeed); + #endif if (!PyArg_ParseTuple(_args, "")) return NULL; *************** *** 729,732 **** --- 816,822 ---- OSErr _err; short refnum; + #ifndef CloseComponentResFile + PyMac_PRECHECK(CloseComponentResFile); + #endif if (!PyArg_ParseTuple(_args, "h", &refnum)) *************** *** 745,748 **** --- 835,841 ---- OSType componentType; OSType componentSubType; + #ifndef OpenDefaultComponent + PyMac_PRECHECK(OpenDefaultComponent); + #endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &componentType, *************** *** 762,765 **** --- 855,861 ---- short resRefNum; short global; + #ifndef RegisterComponentResourceFile + PyMac_PRECHECK(RegisterComponentResourceFile); + #endif if (!PyArg_ParseTuple(_args, "hh", &resRefNum, Index: cmsupport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cm/cmsupport.py,v retrieving revision 1.5 retrieving revision 1.5.14.1 diff -C2 -d -r1.5 -r1.5.14.1 *** cmsupport.py 23 Aug 2001 13:48:02 -0000 1.5 --- cmsupport.py 25 Mar 2002 12:24:50 -0000 1.5.14.1 *************** *** 110,115 **** # Create the generator classes used to populate the lists ! Function = OSErrFunctionGenerator ! Method = OSErrMethodGenerator # Create and populate the lists --- 110,115 ---- # Create the generator classes used to populate the lists ! Function = OSErrWeakLinkFunctionGenerator ! Method = OSErrWeakLinkMethodGenerator # Create and populate the lists From mwh@users.sourceforge.net Mon Mar 25 12:25:00 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 25 Mar 2002 04:25:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib httplib.py,1.42.10.3,1.42.10.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv26521 Modified Files: Tag: release22-maint httplib.py Log Message: backport akuchling's checkin of revision 1.47 of httplib.py [Bug #531616] Make HTTPS work again by adding a sendall method to the FakeSocket class. Without it, the sendall() call got the method on the underlying socket object, and that messed up SSL. Does httplib use other methods of sockets that FakeSocket doesn't support? Someone should take a look... (I'll try to give it a once-over.) 2.2.1 bugfix candidate. Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.42.10.3 retrieving revision 1.42.10.4 diff -C2 -d -r1.42.10.3 -r1.42.10.4 *** httplib.py 11 Mar 2002 10:19:16 -0000 1.42.10.3 --- httplib.py 25 Mar 2002 12:24:58 -0000 1.42.10.4 *************** *** 647,650 **** --- 647,653 ---- return self.__ssl.write(stuff) + def sendall(self, stuff, flags = 0): + return self.__ssl.write(stuff) + def recv(self, len = 1024, flags = 0): return self.__ssl.read(len) From mwh@users.sourceforge.net Mon Mar 25 12:25:28 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 25 Mar 2002 04:25:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include traceback.h,2.18,2.18.26.1 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv27265 Modified Files: Tag: release22-maint traceback.h Log Message: backport akuchling's checkin of revision 2.19 of traceback.h [Bug #528914] PyTraceBack_Store/Fetch were deleted in 1997, but their prototypes remain. Noted by Yakov Markovitch. Bugfix candidate. Index: traceback.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/traceback.h,v retrieving revision 2.18 retrieving revision 2.18.26.1 diff -C2 -d -r2.18 -r2.18.26.1 *** traceback.h 1 Sep 2000 23:29:26 -0000 2.18 --- traceback.h 25 Mar 2002 12:25:26 -0000 2.18.26.1 *************** *** 11,19 **** DL_IMPORT(int) PyTraceBack_Here(struct _frame *); - DL_IMPORT(PyObject *) PyTraceBack_Fetch(void); - DL_IMPORT(int) PyTraceBack_Store(PyObject *); DL_IMPORT(int) PyTraceBack_Print(PyObject *, PyObject *); ! /* Reveale traceback type so we can typecheck traceback objects */ extern DL_IMPORT(PyTypeObject) PyTraceBack_Type; #define PyTraceBack_Check(v) ((v)->ob_type == &PyTraceBack_Type) --- 11,17 ---- DL_IMPORT(int) PyTraceBack_Here(struct _frame *); DL_IMPORT(int) PyTraceBack_Print(PyObject *, PyObject *); ! /* Reveal traceback type so we can typecheck traceback objects */ extern DL_IMPORT(PyTypeObject) PyTraceBack_Type; #define PyTraceBack_Check(v) ((v)->ob_type == &PyTraceBack_Type) From mwh@users.sourceforge.net Mon Mar 25 12:31:51 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 25 Mar 2002 04:31:51 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib calendar.py,1.22.18.1,1.22.18.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv3753 Modified Files: Tag: release22-maint calendar.py Log Message: Slap HEAD version of calendar.py onto branch. Hope this was right thing to do. Index: calendar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/calendar.py,v retrieving revision 1.22.18.1 retrieving revision 1.22.18.2 diff -C2 -d -r1.22.18.1 -r1.22.18.2 *** calendar.py 16 Mar 2002 18:01:05 -0000 1.22.18.1 --- calendar.py 25 Mar 2002 12:31:48 -0000 1.22.18.2 *************** *** 10,17 **** # Import functions and variables from time module from time import localtime, mktime, strftime __all__ = ["error","setfirstweekday","firstweekday","isleap", "leapdays","weekday","monthrange","monthcalendar", ! "prmonth","month","prcal","calendar","timegm"] # Exception raised for bad input (with string parameter for details) --- 10,19 ---- # Import functions and variables from time module from time import localtime, mktime, strftime + from types import SliceType __all__ = ["error","setfirstweekday","firstweekday","isleap", "leapdays","weekday","monthrange","monthcalendar", ! "prmonth","month","prcal","calendar","timegm", ! "month_name", "month_abbr", "day_name", "day_abbr"] # Exception raised for bad input (with string parameter for details) *************** *** 25,50 **** mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] ! class _localized_name: ! def __init__(self, format, len): self.format = format ! self.len = len ! def __getitem__(self, item): ! if isinstance(item, int): ! if item < 0: item += self.len ! if not 0 <= item < self.len: ! raise IndexError, "out of range" ! return strftime(self.format, (item,)*9).capitalize() ! elif isinstance(item, type(slice(0))): ! return [self[e] for e in range(self.len)].__getslice__(item.start, item.stop) def __len__(self): ! return self.len # Full and abbreviated names of weekdays ! day_name = _localized_name('%A', 7) ! day_abbr = _localized_name('%a', 7) # Full and abbreviated names of months (1-based arrays!!!) ! month_name = _localized_name('%B', 13) ! month_abbr = _localized_name('%b', 13) # Constants for weekdays --- 27,76 ---- mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] ! # This module used to have hard-coded lists of day and month names, as ! # English strings. The classes following emulate a read-only version of ! # that, but supply localized names. Note that the values are computed ! # fresh on each call, in case the user changes locale between calls. ! ! class _indexer: ! def __getitem__(self, i): ! if isinstance(i, SliceType): ! return self.data[i.start : i.stop] ! else: ! # May raise an appropriate exception. ! return self.data[i] ! ! class _localized_month(_indexer): ! def __init__(self, format): self.format = format ! ! def __getitem__(self, i): ! self.data = [strftime(self.format, (2001, j, 1, 12, 0, 0, 1, 1, 0)) ! for j in range(1, 13)] ! self.data.insert(0, "") ! return _indexer.__getitem__(self, i) ! def __len__(self): ! return 13 ! ! class _localized_day(_indexer): ! def __init__(self, format): ! self.format = format ! ! def __getitem__(self, i): ! # January 1, 2001, was a Monday. ! self.data = [strftime(self.format, (2001, 1, j+1, 12, 0, 0, j, j+1, 0)) ! for j in range(7)] ! return _indexer.__getitem__(self, i) ! ! def __len__(self_): ! return 7 # Full and abbreviated names of weekdays ! day_name = _localized_day('%A') ! day_abbr = _localized_day('%a') # Full and abbreviated names of months (1-based arrays!!!) ! month_name = _localized_month('%B') ! month_abbr = _localized_month('%b') # Constants for weekdays From mwh@users.sourceforge.net Mon Mar 25 12:33:26 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 25 Mar 2002 04:33:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_calendar.py,1.1.6.1,1.1.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv6023 Modified Files: Tag: release22-maint test_calendar.py Log Message: Repeat trick with test_calendar.py Index: test_calendar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_calendar.py,v retrieving revision 1.1.6.1 retrieving revision 1.1.6.2 diff -C2 -d -r1.1.6.1 -r1.1.6.2 *** test_calendar.py 17 Mar 2002 18:59:32 -0000 1.1.6.1 --- test_calendar.py 25 Mar 2002 12:33:24 -0000 1.1.6.2 *************** *** 32,35 **** --- 32,58 ---- self.assertEqual(len([d for d in calendar.day_abbr]), 7) + def test_days(self): + for attr in "day_name", "day_abbr": + value = getattr(calendar, attr) + self.assertEqual(len(value), 7) + self.assertEqual(len(value[:]), 7) + # ensure they're all unique + d = {} + for v in value: + d[v] = 1 + self.assertEqual(len(d), 7) + + def test_months(self): + for attr in "month_name", "month_abbr": + value = getattr(calendar, attr) + self.assertEqual(len(value), 13) + self.assertEqual(len(value[:]), 13) + self.assertEqual(value[0], "") + # ensure they're all unique + d = {} + for v in value: + d[v] = 1 + self.assertEqual(len(d), 13) + def test_main(): run_unittest(CalendarTestCase) From jackjansen@users.sourceforge.net Mon Mar 25 12:33:50 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 25 Mar 2002 04:33:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/scripts genpluginprojects.py,1.26,1.26.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/scripts In directory usw-pr-cvs1:/tmp/cvs-serv5110 Modified Files: Tag: release22-maint genpluginprojects.py Log Message: Backport of 1.27, 1.29 and 1.30: CodeWarrior includes Waste and Internet Config nowadays, obviating the need for separate downloads. - Weaklink InterfaceLib in _Res module - forgot to pass libraryflags and stdlibraryflags on to ppc/carbon project generation. First half of fix to 531398. Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, inShould finally fix 531398. 2.2.1 candidate.se an exception. Index: genpluginprojects.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/scripts/genpluginprojects.py,v retrieving revision 1.26 retrieving revision 1.26.6.1 diff -C2 -d -r1.26 -r1.26.6.1 *** genpluginprojects.py 13 Dec 2001 13:21:38 -0000 1.26 --- genpluginprojects.py 25 Mar 2002 12:33:48 -0000 1.26.6.1 *************** *** 42,48 **** # a single multitarget project, but easier to implement for now. genpluginproject("ppc", module, project, projectdir, sources, sourcedirs, ! libraries, extradirs, extraexportsymbols, outputdir) genpluginproject("carbon", module, project, projectdir, sources, sourcedirs, ! libraries, extradirs, extraexportsymbols, outputdir) return templatename = "template-%s" % architecture --- 42,50 ---- # a single multitarget project, but easier to implement for now. genpluginproject("ppc", module, project, projectdir, sources, sourcedirs, ! libraries, extradirs, extraexportsymbols, outputdir, libraryflags, ! stdlibraryflags, prefixname) genpluginproject("carbon", module, project, projectdir, sources, sourcedirs, ! libraries, extradirs, extraexportsymbols, outputdir, libraryflags, ! stdlibraryflags, prefixname) return templatename = "template-%s" % architecture *************** *** 123,131 **** # bgen-generated Toolbox modules genpluginproject("carbon", "_AE", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_AE", libraries=["ObjectSupportLib"], outputdir="::Lib:Carbon") genpluginproject("ppc", "_App", libraries=["CarbonAccessors.o", "AppearanceLib"], libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("carbon", "_App", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Cm", libraries=["QuickTimeLib"], outputdir="::Lib:Carbon") genpluginproject("carbon", "_Cm", outputdir="::Lib:Carbon") # XXX can't work properly because we need to set a custom fragment initializer --- 125,135 ---- # bgen-generated Toolbox modules genpluginproject("carbon", "_AE", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_AE", libraries=["ObjectSupportLib"], ! stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("ppc", "_App", libraries=["CarbonAccessors.o", "AppearanceLib"], libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("carbon", "_App", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Cm", libraries=["QuickTimeLib"], ! stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("carbon", "_Cm", outputdir="::Lib:Carbon") # XXX can't work properly because we need to set a custom fragment initializer *************** *** 141,149 **** libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("carbon", "_Drag", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Drag", libraries=["DragLib"], outputdir="::Lib:Carbon") ! genpluginproject("all", "_Evt", outputdir="::Lib:Carbon") ! genpluginproject("all", "_Fm", outputdir="::Lib:Carbon") genpluginproject("ppc", "_Help", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Icn", libraries=["IconServicesLib"], outputdir="::Lib:Carbon") genpluginproject("carbon", "_Icn", outputdir="::Lib:Carbon") genpluginproject("all", "_List", outputdir="::Lib:Carbon") --- 145,157 ---- libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("carbon", "_Drag", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Drag", libraries=["DragLib"], ! libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") ! genpluginproject("all", "_Evt", ! stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") ! genpluginproject("all", "_Fm", ! stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("ppc", "_Help", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Icn", libraries=["IconServicesLib"], ! libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("carbon", "_Icn", outputdir="::Lib:Carbon") genpluginproject("all", "_List", outputdir="::Lib:Carbon") *************** *** 151,166 **** genpluginproject("ppc", "_Menu", libraries=["CarbonAccessors.o", "MenusLib", "ContextualMenu", "AppearanceLib"], libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") ! genpluginproject("all", "_Qd", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Qt", libraries=["QuickTimeLib"], outputdir="::Lib:Carbon") ! genpluginproject("carbon", "_Qt", outputdir="::Lib:Carbon") ! genpluginproject("all", "_Qdoffs", outputdir="::Lib:Carbon") ! genpluginproject("all", "_Res", outputdir="::Lib:Carbon") genpluginproject("all", "_Scrap", outputdir="::Lib:Carbon") genpluginproject("ppc", "_Snd", libraries=["CarbonAccessors.o", "SoundLib"], outputdir="::Lib:Carbon") genpluginproject("carbon", "_Snd", outputdir="::Lib:Carbon") genpluginproject("all", "_Sndihooks", sources=[":snd:_Sndihooks.c"], outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_TE", libraries=["CarbonAccessors.o", "DragLib"], outputdir="::Lib:Carbon") genpluginproject("carbon", "_TE", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Mlte", libraries=["Textension"], outputdir="::Lib:Carbon") genpluginproject("carbon", "_Mlte", outputdir="::Lib:Carbon") genpluginproject("carbon", "_Win", outputdir="::Lib:Carbon") --- 159,182 ---- genpluginproject("ppc", "_Menu", libraries=["CarbonAccessors.o", "MenusLib", "ContextualMenu", "AppearanceLib"], libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") ! genpluginproject("all", "_Qd", ! stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Qt", libraries=["QuickTimeLib"], ! libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") ! genpluginproject("carbon", "_Qt", ! libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") ! genpluginproject("all", "_Qdoffs", ! stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") ! genpluginproject("all", "_Res", ! stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("all", "_Scrap", outputdir="::Lib:Carbon") genpluginproject("ppc", "_Snd", libraries=["CarbonAccessors.o", "SoundLib"], outputdir="::Lib:Carbon") genpluginproject("carbon", "_Snd", outputdir="::Lib:Carbon") genpluginproject("all", "_Sndihooks", sources=[":snd:_Sndihooks.c"], outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_TE", libraries=["CarbonAccessors.o", "DragLib"], ! stdlibraryflags="Debug, WeakImport", ! libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("carbon", "_TE", outputdir="::Lib:Carbon") ! genpluginproject("ppc", "_Mlte", libraries=["Textension"], ! libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") genpluginproject("carbon", "_Mlte", outputdir="::Lib:Carbon") genpluginproject("carbon", "_Win", outputdir="::Lib:Carbon") *************** *** 176,196 **** genpluginproject("all", "ColorPicker") genpluginproject("ppc", "Printing") genpluginproject("ppc", "waste", sources=[ "wastemodule.c", ! 'WEAccessors.c', 'WEBirthDeath.c', 'WEDebug.c', ! 'WEDrawing.c', 'WEFontTables.c', 'WEHighLevelEditing.c', ! 'WEICGlue.c', 'WEInlineInput.c', 'WELineLayout.c', 'WELongCoords.c', ! 'WELowLevelEditing.c', 'WEMouse.c', 'WEObjects.c', 'WEScraps.c', ! 'WESelecting.c', 'WESelectors.c', 'WEUserSelectors.c', 'WEUtilities.c', ! 'WEObjectHandlers.c', ! 'WETabs.c', ! 'WETabHooks.c'], ! libraries=['DragLib'], extradirs=[ ! '::::Waste 1.3 Distribution:*', ! '::::ICProgKit1.4:APIs'] ) - # This is a hack, combining parts of Waste 2.0 with parts of 1.3 genpluginproject("carbon", "waste", sources=[ --- 192,229 ---- genpluginproject("all", "ColorPicker") genpluginproject("ppc", "Printing") + ## genpluginproject("ppc", "waste", + ## sources=[ + ## "wastemodule.c", + ## 'WEAccessors.c', 'WEBirthDeath.c', 'WEDebug.c', + ## 'WEDrawing.c', 'WEFontTables.c', 'WEHighLevelEditing.c', + ## 'WEICGlue.c', 'WEInlineInput.c', 'WELineLayout.c', 'WELongCoords.c', + ## 'WELowLevelEditing.c', 'WEMouse.c', 'WEObjects.c', 'WEScraps.c', + ## 'WESelecting.c', 'WESelectors.c', 'WEUserSelectors.c', 'WEUtilities.c', + ## 'WEObjectHandlers.c', + ## 'WETabs.c', + ## 'WETabHooks.c'], + ## libraries=['DragLib'], + ## extradirs=[ + ## '::::Waste 1.3 Distribution:*', + ## '::::ICProgKit1.4:APIs'] + ## ) + # This is a hack, combining parts of Waste 2.0 with parts of 1.3 genpluginproject("ppc", "waste", sources=[ "wastemodule.c", ! "WEObjectHandlers.c", ! "WETabs.c", "WETabHooks.c"], ! libraries=[ ! "WASTE.PPC.lib", ! "TextCommon", ! "UnicodeConverter", ! "DragLib", ! ], extradirs=[ ! '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers', ! '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries', ! '::wastemods', ! ] ) genpluginproject("carbon", "waste", sources=[ *************** *** 202,214 **** '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers', '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries', ! '::::Waste 1.3 Distribution:Extras:Sample Object Handlers', ! '::::Waste 1.3 Distribution:Extras:Waste Tabs 1.3.2'] ) genpluginproject("ppc", "ctb") genpluginproject("ppc", "icglue", sources=["icgluemodule.c"], ! libraries=["ICGlueCFM-PPC.lib"], ! extradirs=["::::ICProgKit1.4:APIs"]) ! genpluginproject("carbon", "icglue", sources=["icgluemodule.c"], ! extradirs=["::::ICProgKit1.4:APIs"]) genpluginproject("ppc", "macspeech", libraries=["SpeechLib"]) --- 235,247 ---- '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers', '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries', ! '::wastemods', ! ] ) + ## '::::Waste 1.3 Distribution:Extras:Sample Object Handlers', + ## '::::Waste 1.3 Distribution:Extras:Waste Tabs 1.3.2'] genpluginproject("ppc", "ctb") genpluginproject("ppc", "icglue", sources=["icgluemodule.c"], ! libraries=["InternetConfigLib"]) ! genpluginproject("carbon", "icglue", sources=["icgluemodule.c"]) genpluginproject("ppc", "macspeech", libraries=["SpeechLib"]) From mwh@users.sourceforge.net Mon Mar 25 12:33:58 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 25 Mar 2002 04:33:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python sysmodule.c,2.98.6.3,2.98.6.4 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv6998 Modified Files: Tag: release22-maint sysmodule.c Log Message: backport nascheme's checkin of revision 2.102 of sysmodule.c Fix wording of sys.exit docstring. Close SF bug 534113. Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.98.6.3 retrieving revision 2.98.6.4 diff -C2 -d -r2.98.6.3 -r2.98.6.4 *** sysmodule.c 3 Mar 2002 15:17:07 -0000 2.98.6.3 --- sysmodule.c 25 Mar 2002 12:33:56 -0000 2.98.6.4 *************** *** 157,161 **** Exit the interpreter by raising SystemExit(status).\n\ If the status is omitted or None, it defaults to zero (i.e., success).\n\ ! If the status numeric, it will be used as the system exit status.\n\ If it is another kind of object, it will be printed and the system\n\ exit status will be one (i.e., failure)."; --- 157,161 ---- Exit the interpreter by raising SystemExit(status).\n\ If the status is omitted or None, it defaults to zero (i.e., success).\n\ ! If the status is numeric, it will be used as the system exit status.\n\ If it is another kind of object, it will be printed and the system\n\ exit status will be one (i.e., failure)."; From mwh@users.sourceforge.net Mon Mar 25 12:34:17 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 25 Mar 2002 04:34:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib cmd.py,1.26,1.26.16.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv7342 Modified Files: Tag: release22-maint cmd.py Log Message: backport nascheme's checkin of revision 1.27 of cmd.py Flush stdout before reading next command. Closes SF bug 526357. Index: cmd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cmd.py,v retrieving revision 1.26 retrieving revision 1.26.16.1 diff -C2 -d -r1.26 -r1.26.16.1 *** cmd.py 9 Aug 2001 21:40:30 -0000 1.26 --- cmd.py 25 Mar 2002 12:34:15 -0000 1.26.16.1 *************** *** 95,98 **** --- 95,99 ---- else: sys.stdout.write(self.prompt) + sys.stdout.flush() line = sys.stdin.readline() if not len(line): From mwh@users.sourceforge.net Mon Mar 25 13:11:33 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 25 Mar 2002 05:11:33 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib pydoc.py,1.56.8.1,1.56.8.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv32531 Modified Files: Tag: release22-maint pydoc.py Log Message: backport nascheme's checkin of revision 1.59 of pydoc.py Remove unnecessary \b. It was causing the RE to miss the tailing slash on strings like "http://www.python.org/ is good". Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.56.8.1 retrieving revision 1.56.8.2 diff -C2 -d -r1.56.8.1 -r1.56.8.2 *** pydoc.py 8 Mar 2002 13:40:46 -0000 1.56.8.1 --- pydoc.py 25 Mar 2002 13:11:31 -0000 1.56.8.2 *************** *** 442,446 **** r'RFC[- ]?(\d+)|' r'PEP[- ]?(\d+)|' ! r'(self\.)?(\w+))\b') while 1: match = pattern.search(text, here) --- 442,446 ---- r'RFC[- ]?(\d+)|' r'PEP[- ]?(\d+)|' ! r'(self\.)?(\w+))') while 1: match = pattern.search(text, here) From mwh@users.sourceforge.net Mon Mar 25 13:11:49 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 25 Mar 2002 05:11:49 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib pydoc.py,1.56.8.2,1.56.8.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv32693 Modified Files: Tag: release22-maint pydoc.py Log Message: backport nascheme's checkin of revision 1.60 of pydoc.py Quote href properly. Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.56.8.2 retrieving revision 1.56.8.3 diff -C2 -d -r1.56.8.2 -r1.56.8.3 *** pydoc.py 25 Mar 2002 13:11:31 -0000 1.56.8.2 --- pydoc.py 25 Mar 2002 13:11:47 -0000 1.56.8.3 *************** *** 451,455 **** all, scheme, rfc, pep, selfdot, name = match.groups() if scheme: ! results.append('%s' % (all, escape(all))) elif rfc: url = 'http://www.rfc-editor.org/rfc/rfc%d.txt' % int(rfc) --- 451,456 ---- all, scheme, rfc, pep, selfdot, name = match.groups() if scheme: ! url = escape(all).replace('"', '"') ! results.append('%s' % (url, url)) elif rfc: url = 'http://www.rfc-editor.org/rfc/rfc%d.txt' % int(rfc) From mwh@users.sourceforge.net Mon Mar 25 13:13:47 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 25 Mar 2002 05:13:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils/command bdist_rpm.py,1.27,1.27.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv1218 Modified Files: Tag: release22-maint bdist_rpm.py Log Message: backport akuchling's checkin of revision 1.28 of bdist_rpm.py [Bug #517451] bdist_rpm didn't list all of its Boolean options. (Someone should check the other commands for this same error.) Bugfix candidate. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_rpm.py,v retrieving revision 1.27 retrieving revision 1.27.6.1 diff -C2 -d -r1.27 -r1.27.6.1 *** bdist_rpm.py 6 Dec 2001 20:57:12 -0000 1.27 --- bdist_rpm.py 25 Mar 2002 13:13:45 -0000 1.27.6.1 *************** *** 96,100 **** ] ! boolean_options = ['keep-temp', 'rpm2-mode'] negative_opt = {'no-keep-temp': 'keep-temp', --- 96,100 ---- ] ! boolean_options = ['keep-temp', 'use-rpm-opt-flags', 'rpm3-mode'] negative_opt = {'no-keep-temp': 'keep-temp', From mwh@users.sourceforge.net Mon Mar 25 13:14:25 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 25 Mar 2002 05:14:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils/command bdist_wininst.py,1.27,1.27.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv1559 Modified Files: Tag: release22-maint bdist_wininst.py Log Message: Thomas said this was OK. backport akuchling's checkin of revision 1.30 of bdist_wininst.py Add unlisted Boolean options. Thomas H., can you please check that I got this right? Bugfix candidate, unless Thomas notes a problem. Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_wininst.py,v retrieving revision 1.27 retrieving revision 1.27.4.1 diff -C2 -d -r1.27 -r1.27.4.1 *** bdist_wininst.py 18 Dec 2001 21:08:15 -0000 1.27 --- bdist_wininst.py 25 Mar 2002 13:14:23 -0000 1.27.4.1 *************** *** 39,43 **** ] ! boolean_options = ['keep-temp'] def initialize_options (self): --- 39,44 ---- ] ! boolean_options = ['keep-temp', 'no-target-compile', 'no-target-optimize', ! 'skip-build'] def initialize_options (self): From mwh@users.sourceforge.net Mon Mar 25 13:15:06 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 25 Mar 2002 05:15:06 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils/command install.py,1.60,1.60.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv1944 Modified Files: Tag: release22-maint install.py Log Message: backport akuchling's checkin of revision 1.62 of install.py Add missing Boolean options Remove unused no_compile flag Initialize the Boolean attribute .compile to 0 instead of None Bugfix candidate. Index: install.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/install.py,v retrieving revision 1.60 retrieving revision 1.60.6.1 diff -C2 -d -r1.60 -r1.60.6.1 *** install.py 6 Dec 2001 20:57:12 -0000 1.60 --- install.py 25 Mar 2002 13:15:04 -0000 1.60.6.1 *************** *** 128,132 **** ] ! boolean_options = ['force', 'skip-build'] negative_opt = {'no-compile' : 'compile'} --- 128,132 ---- ] ! boolean_options = ['compile', 'force', 'skip-build'] negative_opt = {'no-compile' : 'compile'} *************** *** 158,163 **** self.install_data = None ! self.compile = None ! self.no_compile = None self.optimize = None --- 158,162 ---- self.install_data = None ! self.compile = 0 self.optimize = None From mwh@users.sourceforge.net Mon Mar 25 13:15:30 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 25 Mar 2002 05:15:30 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils/command install.py,1.60.6.1,1.60.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv2113 Modified Files: Tag: release22-maint install.py Log Message: backport akuchling's checkin of revision 1.63 of install.py Revert part of previous patch: several install_* subcommands expect .compile to be None, and set it to true if it is. Caught by Pearu Peterson. Bugfix candidate, if the previous change is accepted for release22-maint. Index: install.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/install.py,v retrieving revision 1.60.6.1 retrieving revision 1.60.6.2 diff -C2 -d -r1.60.6.1 -r1.60.6.2 *** install.py 25 Mar 2002 13:15:04 -0000 1.60.6.1 --- install.py 25 Mar 2002 13:15:28 -0000 1.60.6.2 *************** *** 158,162 **** self.install_data = None ! self.compile = 0 self.optimize = None --- 158,162 ---- self.install_data = None ! self.compile = None self.optimize = None From mwh@users.sourceforge.net Mon Mar 25 13:15:54 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 25 Mar 2002 05:15:54 -0800 Subject: [Python-checkins] CVS: python/dist/src README,1.136.4.3,1.136.4.4 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv2275 Modified Files: Tag: release22-maint README Log Message: backport akuchling's checkin of revision 1.142 of README [Bug #532136] Change path in README, as suggested by Ralph Corderoy Bugfix candidate. Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/README,v retrieving revision 1.136.4.3 retrieving revision 1.136.4.4 diff -C2 -d -r1.136.4.3 -r1.136.4.4 *** README 17 Mar 2002 19:39:24 -0000 1.136.4.3 --- README 25 Mar 2002 13:15:52 -0000 1.136.4.4 *************** *** 648,654 **** failing test manually, as follows: ! python ../Lib/test/test_whatever.py ! (substituting the top of the source tree for .. if you built in a different directory). This runs the test in verbose mode. --- 648,654 ---- failing test manually, as follows: ! ./python ./Lib/test/test_whatever.py ! (substituting the top of the source tree for '.' if you built in a different directory). This runs the test in verbose mode. From mwh@users.sourceforge.net Mon Mar 25 13:21:43 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 25 Mar 2002 05:21:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects complexobject.c,2.53.4.1,2.53.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv4722 Modified Files: Tag: release22-maint complexobject.c Log Message: backport tim_one's checkin of revision 2.55 of complexobject.c SF bug 533198: Complex power underflow raises exception. Konrad was too kind. Not only did it raise an exception, the specific exception it raised made no sense. These are old bugs in complex_pow() and friends: 1. Raising 0 to a negative power isn't a range error, it's a domain error, so changed c_pow() to set errno to EDOM in that case instead of ERANGE. 2. Changed complex_pow() to: A. Used the Py_ADJUST_ERANGE2 macro to try to clear errno of a spurious ERANGE error due to underflow in the libm pow() called by c_pow(). B. Produced different exceptions depending on the errno value: i) For errno==EDOM, raise ZeroDivisionError instead of ValueError. This is for consistency with the non-complex cases 0.0**-2 and 0**-2 and 0L**-2. ii) For errno==ERANGE, raise OverflowError. Bugfix candidate. Index: complexobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/complexobject.c,v retrieving revision 2.53.4.1 retrieving revision 2.53.4.2 diff -C2 -d -r2.53.4.1 -r2.53.4.2 *** complexobject.c 22 Feb 2002 13:23:33 -0000 2.53.4.1 --- complexobject.c 25 Mar 2002 13:21:41 -0000 2.53.4.2 *************** *** 132,136 **** else if (a.real == 0. && a.imag == 0.) { if (b.imag != 0. || b.real < 0.) ! errno = ERANGE; r.real = 0.; r.imag = 0.; --- 132,136 ---- else if (a.real == 0. && a.imag == 0.) { if (b.imag != 0. || b.real < 0.) ! errno = EDOM; r.real = 0.; r.imag = 0.; *************** *** 457,463 **** PyFPE_END_PROTECT(p) ! if (errno == ERANGE) { ! PyErr_SetString(PyExc_ValueError, "0.0 to a negative or complex power"); return NULL; } --- 457,469 ---- PyFPE_END_PROTECT(p) ! Py_ADJUST_ERANGE2(p.real, p.imag); ! if (errno == EDOM) { ! PyErr_SetString(PyExc_ZeroDivisionError, "0.0 to a negative or complex power"); + return NULL; + } + else if (errno == ERANGE) { + PyErr_SetString(PyExc_OverflowError, + "complex exponentiaion"); return NULL; } From mwh@users.sourceforge.net Mon Mar 25 13:22:17 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 25 Mar 2002 05:22:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib netrc.py,1.12,1.12.22.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv4951 Modified Files: Tag: release22-maint netrc.py Log Message: backport akuchling's checkin of revision 1.14 of netrc.py [Bug #532115] netrc module was broken * 'macdef' (macro definition) wasn't parsed correctly * account value not reset for a subsequent 'default' line * typo: 'whitepace' -> 'whitespace' Bugfix candidate. Index: netrc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/netrc.py,v retrieving revision 1.12 retrieving revision 1.12.22.1 diff -C2 -d -r1.12 -r1.12.22.1 *** netrc.py 15 Apr 2001 12:51:42 -0000 1.12 --- netrc.py 25 Mar 2002 13:22:14 -0000 1.12.22.1 *************** *** 42,53 **** entryname = lexer.get_token() self.macros[entryname] = [] ! lexer.whitepace = ' \t' while 1: line = lexer.instream.readline() ! if not line or line == '\012' and tt == '\012': ! lexer.whitepace = ' \t\r\n' break - tt = line self.macros[entryname].append(line) else: raise NetrcParseError( --- 42,53 ---- entryname = lexer.get_token() self.macros[entryname] = [] ! lexer.whitespace = ' \t' while 1: line = lexer.instream.readline() ! if not line or line == '\012': ! lexer.whitespace = ' \t\r\n' break self.macros[entryname].append(line) + continue else: raise NetrcParseError( *************** *** 55,67 **** # We're looking at start of an entry for a named machine or default. ! if toplevel == 'machine': ! login = account = password = None ! self.hosts[entryname] = {} while 1: tt = lexer.get_token() ! 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) lexer.push_token(tt) --- 55,65 ---- # We're looking at start of an entry for a named machine or default. ! login = account = password = None ! self.hosts[entryname] = {} while 1: tt = lexer.get_token() ! if (tt=='' or tt == 'machine' or ! tt == 'default' or tt =='macdef'): ! if login and password: self.hosts[entryname] = (login, account, password) lexer.push_token(tt) From mwh@users.sourceforge.net Mon Mar 25 13:23:55 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 25 Mar 2002 05:23:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_netrc.py,NONE,1.1.2.1 test_sundry.py,1.8,1.8.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv5655 Modified Files: Tag: release22-maint test_sundry.py Added Files: Tag: release22-maint test_netrc.py Log Message: Backport akuchling's netrc test. --- NEW FILE: test_netrc.py --- import netrc, os, tempfile, test_support, unittest TEST_NETRC = """ machine foo login log1 password pass1 account acct1 macdef macro1 line1 line2 macdef macro2 line3 line4 default login log2 password pass2 """ temp_filename = tempfile.mktemp() class NetrcTestCase(unittest.TestCase): def setUp (self): fp = open(temp_filename, 'wt') fp.write(TEST_NETRC) fp.close() self.netrc = netrc.netrc(temp_filename) def tearDown (self): del self.netrc os.unlink(temp_filename) def test_case_1(self): self.assert_(self.netrc.macros == {'macro1':['line1\n', 'line2\n'], 'macro2':['line3\n', 'line4\n']} ) self.assert_(self.netrc.hosts['foo'] == ('log1', 'acct1', 'pass1')) self.assert_(self.netrc.hosts['default'] == ('log2', None, 'pass2')) if __name__ == "__main__": test_support.run_unittest(NetrcTestCase) Index: test_sundry.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sundry.py,v retrieving revision 1.8 retrieving revision 1.8.6.1 diff -C2 -d -r1.8 -r1.8.6.1 *** test_sundry.py 7 Dec 2001 16:43:19 -0000 1.8 --- test_sundry.py 25 Mar 2002 13:23:53 -0000 1.8.6.1 *************** *** 56,60 **** import multifile import mutex - import netrc import nntplib import nturl2path --- 56,59 ---- From akuchling@users.sourceforge.net Mon Mar 25 13:36:07 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Mon, 25 Mar 2002 05:36:07 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0262.txt,1.1,1.2 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv8912 Modified Files: pep-0262.txt Log Message: Various changes inspired by Thomas Heller's c.l.p comments Index: pep-0262.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0262.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pep-0262.txt 9 Jul 2001 14:26:26 -0000 1.1 --- pep-0262.txt 25 Mar 2002 13:36:05 -0000 1.2 *************** *** 23,30 **** * Is package X on a system? * What version of package X is installed? ! * Where can the new version of package X be found? ! XXX Does this mean "a home page where the user can go and find a download link", or "a place where a program can find ! the newest version?" Perhaps both... * What files did package X put on my system? * What package did the file x/y/z.py come from? --- 23,30 ---- * Is package X on a system? * What version of package X is installed? ! * Where can the new version of package X be found? (This can ! be defined as either "a home page where the user can go and find a download link", or "a place where a program can find ! the newest version?" Both should probably be supported.) * What files did package X put on my system? * What package did the file x/y/z.py come from? *************** *** 47,62 **** The rationale for scanning subdirectories is that we can move to a directory-based indexing scheme if the package directory contains ! too many entries. That is, instead of INSTALLDB/Numeric, we ! could switch to INSTALLDB/N/Nu/Numeric or some similar scheme. ! ! XXX how much do we care about performance? Do we really need to ! use an anydbm file or something similar? ! ! XXX is the actual filename important? Let's say the installation ! data for PIL is in the file INSTALLDB/Numeric. Is this OK? When ! we want to figure out if Numeric is installed, do we want to open ! a single file, or have to scan them all? Note that for ! human-interface purposes, we'll often have to scan all the ! packages anyway, for a case-insensitive or keyword search. --- 47,53 ---- The rationale for scanning subdirectories is that we can move to a directory-based indexing scheme if the package directory contains ! too many entries. For example, this would let us transparently ! switch from INSTALLDB/Numeric to INSTALLDB/N/Nu/Numeric or some ! similar hashing scheme. *************** *** 71,99 **** for example to list documentation files, then we'd add a DOCS section and list it in the contents. Sections are always ! separated by blank lines. XXX too simple? ! [PKG-INFO section] An initial set of RFC-822 headers ! containing the package information for a file, as described in ! PEP 241, "Metadata for Python Software Packages". A blank line indicating the end of the PKG-INFO section. An entry for each file installed by the package. XXX Are .pyc and .pyo files in this list? What about compiled .so files? AMK thinks "no" and "yes", respectively. ! Each file's entry is a single tab-delimited line that contains the ! following fields: ! XXX should each file entry be all on one line and ! tab-delimited? More RFC-822 headers? AMK thinks tab-delimited ! seems sufficent. * The file's size - - * XXX do we need to store permissions? The owner/group? ! * An MD5 digest of the file, written in hex. (XXX All 16 ! bytes of the digest seems unnecessary; first 8 bytes only, ! maybe? Is a zlib.crc32() hash sufficient?) * The file's full path, as installed on the system. (XXX --- 62,90 ---- for example to list documentation files, then we'd add a DOCS section and list it in the contents. Sections are always ! separated by blank lines. ! PKG-INFO section ! ! An initial set of RFC-822 headers containing the package ! information for a file, as described in PEP 241, "Metadata for ! Python Software Packages". A blank line indicating the end of the PKG-INFO section. + FILES section + An entry for each file installed by the package. XXX Are .pyc and .pyo files in this list? What about compiled .so files? AMK thinks "no" and "yes", respectively. ! Each file's entry is a single tab-delimited line that contains ! the following fields: * The file's size ! * The file's permissions, and the owner/group of the file. ! XXX what to do on Windows? ! ! * An MD5 digest of the file, encoded in hex. * The file's full path, as installed on the system. (XXX *************** *** 105,125 **** * XXX some sort of type indicator, to indicate whether this is a Python module, binary module, documentation file, config ! file? Do we need this? ! A package that uses the Distutils for installation will automatically update the database. Packages that roll their own ! installation - XXX what's the relationship between this database and the RPM or - DPKG database? I'm tempted to make the Python database completely - optional; a distributor can preserve the interface of the package - management tool and replace it with their own wrapper on top of - their own package manager. (XXX but how would the Distutils know - that, and not bother to update the Python database?) - Deliverables ! Patches to the Distutils that 1) implement a InstallationDatabase class, 2) Update the database when a new package is installed. 3) a simple package management tool, features to be added to this --- 96,114 ---- * XXX some sort of type indicator, to indicate whether this is a Python module, binary module, documentation file, config ! file? Do we need this? ! A package that uses the Distutils for installation should automatically update the database. Packages that roll their own ! installation will have to use the database's API to to manually ! add or update their own entry. System package managers such as ! RPM or pkgadd can just create the new 'package name' file in the ! INSTALLDB directory. Deliverables + + A description of the database API, to be added to this PEP. ! Patches to the Distutils that 1) implement an InstallationDatabase class, 2) Update the database when a new package is installed. 3) a simple package management tool, features to be added to this *************** *** 127,130 **** --- 116,135 ---- + Rejected Suggestions + + Instead of using one text file per package, one large text file or + an anydbm file could be used. This has been rejected for a few + reasons. First, performance is probably not an extremely pressing + concern as the package database is only used when installing or + removing packages, a relatively infrequent task. Scalability also + likely isn't a problem, as people may have hundreds of Python + packages installed, but thousands seems unlikely. Finally, + individual text files are compatible with installers such as RPM + or DPKG because a package can just drop the new database file into + the database directory. If one large text file or a binary file + were used, the Python database would then have to be updated by + running a postinstall script. + + References *************** *** 136,140 **** Ideas for this PEP originally came from postings by Greg Ward, ! Fred Drake, Mats Wichmann, and others. Many changes and rewrites to this document were suggested by the --- 141,145 ---- Ideas for this PEP originally came from postings by Greg Ward, ! Fred L. Drake Jr., Thomas Heller, Mats Wichmann, and others. Many changes and rewrites to this document were suggested by the From akuchling@users.sourceforge.net Mon Mar 25 13:57:47 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Mon, 25 Mar 2002 05:57:47 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0262.txt,1.2,1.3 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv20491 Modified Files: pep-0262.txt Log Message: Remove file type indicator Rearrange order of file fields Note that .pyc/.pyo files are listed, too Index: pep-0262.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0262.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pep-0262.txt 25 Mar 2002 13:36:05 -0000 1.2 --- pep-0262.txt 25 Mar 2002 13:57:45 -0000 1.3 *************** *** 74,84 **** FILES section ! An entry for each file installed by the package. ! XXX Are .pyc and .pyo files in this list? What about compiled ! .so files? AMK thinks "no" and "yes", respectively. Each file's entry is a single tab-delimited line that contains the following fields: * The file's size --- 74,87 ---- FILES section ! An entry for each file installed by the package. Generated files ! such as .pyc and .pyo files are on this list as well as the original ! .py files installed by a package; their checksums won't be stored or ! checked, though. Each file's entry is a single tab-delimited line that contains the following fields: + * The file's full path, as installed on the system. + * The file's size *************** *** 87,100 **** * An MD5 digest of the file, encoded in hex. - - * The file's full path, as installed on the system. (XXX - should it be relative to sys.prefix, or sys.prefix + - '/lib/python?' If so, full paths are still needed; - consider a package that installs a startup script such as - /etc/init.d/zope) - - * XXX some sort of type indicator, to indicate whether this is - a Python module, binary module, documentation file, config - file? Do we need this? A package that uses the Distutils for installation should --- 90,93 ---- From mwh@users.sourceforge.net Mon Mar 25 13:59:30 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 25 Mar 2002 05:59:30 -0800 Subject: [Python-checkins] CVS: python/dist/src setup.py,1.73.4.2,1.73.4.3 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv20943 Modified Files: Tag: release22-maint setup.py Log Message: nnorwitz's fix for: [ 532618 ] install fails if build .so fails Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.73.4.2 retrieving revision 1.73.4.3 diff -C2 -d -r1.73.4.2 -r1.73.4.3 *** setup.py 7 Mar 2002 10:04:49 -0000 1.73.4.2 --- setup.py 25 Mar 2002 13:59:28 -0000 1.73.4.3 *************** *** 177,182 **** # _built_objects attribute is stored there strictly for # use here. ! for filename in self._built_objects: ! os.remove(filename) def get_platform (self): --- 177,187 ---- # _built_objects attribute is stored there strictly for # use here. ! # If there is a failure, _built_objects may not be there, ! # so catch the AttributeError and move on. ! try: ! for filename in self._built_objects: ! os.remove(filename) ! except AttributeError: ! self.announce('unable to remove files (ignored)') def get_platform (self): *************** *** 588,592 **** frameworkdir = sysconfig.get_config_var('PYTHONFRAMEWORKDIR') exts.append( Extension('gestalt', ['gestaltmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('MacOS', ['macosmodule.c'], extra_link_args=['-framework', 'Carbon']) ) --- 593,597 ---- frameworkdir = sysconfig.get_config_var('PYTHONFRAMEWORKDIR') exts.append( Extension('gestalt', ['gestaltmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('MacOS', ['macosmodule.c'], extra_link_args=['-framework', 'Carbon']) ) From nnorwitz@users.sourceforge.net Mon Mar 25 14:20:11 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Mon, 25 Mar 2002 06:20:11 -0800 Subject: [Python-checkins] CVS: python/dist/src setup.py,1.84,1.85 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv27410 Modified Files: setup.py Log Message: Fix SF # 532618 517704, install problems when building modules fail. Fix whitespace on a line also. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** setup.py 7 Mar 2002 09:58:56 -0000 1.84 --- setup.py 25 Mar 2002 14:20:09 -0000 1.85 *************** *** 189,194 **** # _built_objects attribute is stored there strictly for # use here. ! for filename in self._built_objects: ! os.remove(filename) else: self.announce('*** WARNING: importing extension "%s" ' --- 189,199 ---- # _built_objects attribute is stored there strictly for # use here. ! # If there is a failure, _built_objects may not be there, ! # so catch the AttributeError and move on. ! try: ! for filename in self._built_objects: ! os.remove(filename) ! except AttributeError: ! self.announce('unable to remove files (ignored)') else: self.announce('*** WARNING: importing extension "%s" ' *************** *** 606,610 **** frameworkdir = sysconfig.get_config_var('PYTHONFRAMEWORKDIR') exts.append( Extension('gestalt', ['gestaltmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('MacOS', ['macosmodule.c'], extra_link_args=['-framework', 'Carbon']) ) --- 611,615 ---- frameworkdir = sysconfig.get_config_var('PYTHONFRAMEWORKDIR') exts.append( Extension('gestalt', ['gestaltmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('MacOS', ['macosmodule.c'], extra_link_args=['-framework', 'Carbon']) ) From jackjansen@users.sourceforge.net Mon Mar 25 14:53:14 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 25 Mar 2002 06:53:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac ReadMe,1.38.4.2.2.1,1.38.4.2.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac In directory usw-pr-cvs1:/tmp/cvs-serv7197 Modified Files: Tag: release22-maint ReadMe Log Message: Added a note about preference file problems for non-privileged OSX users. Stopgap for bug #534158. Index: ReadMe =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/ReadMe,v retrieving revision 1.38.4.2.2.1 retrieving revision 1.38.4.2.2.2 diff -C2 -d -r1.38.4.2.2.1 -r1.38.4.2.2.2 *** ReadMe 6 Mar 2002 22:00:29 -0000 1.38.4.2.2.1 --- ReadMe 25 Mar 2002 14:53:11 -0000 1.38.4.2.2.2 *************** *** 109,112 **** --- 109,129 ---- ways. + OSX Multiple users note + ----------------------- + + Interaction with Mac OS X multiple users has been tested only very lightly. + If you install as a privileged user everything installs fine. + + If you install as a non-privileged user everything should install in your local + per-user folders. But: as there is no global PythonCore you can only run applets + if they reside in your toplevel Python folder. + + If you install as a privileged user and then try to run + Python as another (non-privileged) user you may encounter a problem with + not having a preference file: the symptom is failing to import all sorts + of standard modules. If you remove your per-user Python preference files + (in ~/Library/Preferences) and then run PythonIntpreter once everything should + be fine. + Uninstalling ------------ From jackjansen@users.sourceforge.net Mon Mar 25 15:32:03 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 25 Mar 2002 07:32:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules socketmodule.c,1.210,1.211 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv21797 Modified Files: socketmodule.c Log Message: Due to interaction between the MSL C library and the GUSI I/O library I can get reads from sockets to work consistently either for unbuffered binary files or for buffered binary files, but not for both:-( The workaround is to force socket.makefile() to disable buffering for binary files. Fixes bug 534625. 2.2.1 candidate. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.210 retrieving revision 1.211 diff -C2 -d -r1.210 -r1.211 *** socketmodule.c 3 Mar 2002 03:03:52 -0000 1.210 --- socketmodule.c 25 Mar 2002 15:32:01 -0000 1.211 *************** *** 1366,1369 **** --- 1366,1374 ---- return s->errorhandler(); } + #ifdef USE_GUSI2 + /* Workaround for bug in Metrowerks MSL vs. GUSI I/O library */ + if (strchr(mode, 'b') != NULL ) + bufsize = 0; + #endif f = PyFile_FromFile(fp, "", mode, fclose); if (f != NULL) From jackjansen@users.sourceforge.net Mon Mar 25 15:43:39 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Mon, 25 Mar 2002 07:43:39 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Build PythonStandSmall.mcp,1.33,1.34 PythonCore.mcp,1.32,1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Build In directory usw-pr-cvs1:/tmp/cvs-serv26153 Modified Files: PythonStandSmall.mcp PythonCore.mcp Log Message: Include obmalloc.c in the build. Index: PythonStandSmall.mcp =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Build/PythonStandSmall.mcp,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 Binary files /tmp/cvs4exW6N and /tmp/cvsCOHZww differ Index: PythonCore.mcp =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Build/PythonCore.mcp,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 Binary files /tmp/cvsnICteT and /tmp/cvsulZ9uD differ From fdrake@users.sourceforge.net Mon Mar 25 16:37:41 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 25 Mar 2002 08:37:41 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libbinhex.tex,1.9,1.9.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv11536/lib Modified Files: Tag: release22-maint libbinhex.tex Log Message: Added description of binhex.Error. Index: libbinhex.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libbinhex.tex,v retrieving revision 1.9 retrieving revision 1.9.6.1 diff -C2 -d -r1.9 -r1.9.6.1 *** libbinhex.tex 28 Nov 2001 07:26:15 -0000 1.9 --- libbinhex.tex 25 Mar 2002 16:37:39 -0000 1.9.6.1 *************** *** 28,31 **** --- 28,39 ---- \end{funcdesc} + The following exception is also defined: + + \begin{excdesc}{Error} + Exception raised when something can't be encoded using the binhex + format (for example, a filename is too long to fit in the filename + field), or when input is not properly encoded binhex data. + \end{excdesc} + \begin{seealso} From fdrake@users.sourceforge.net Mon Mar 25 16:37:58 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 25 Mar 2002 08:37:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libbinhex.tex,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv11662/lib Modified Files: libbinhex.tex Log Message: Added description of binhex.Error. Index: libbinhex.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libbinhex.tex,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** libbinhex.tex 28 Nov 2001 07:26:15 -0000 1.9 --- libbinhex.tex 25 Mar 2002 16:37:56 -0000 1.10 *************** *** 28,31 **** --- 28,39 ---- \end{funcdesc} + The following exception is also defined: + + \begin{excdesc}{Error} + Exception raised when something can't be encoded using the binhex + format (for example, a filename is too long to fit in the filename + field), or when input is not properly encoded binhex data. + \end{excdesc} + \begin{seealso} From tim.one@comcast.net Mon Mar 25 16:58:53 2002 From: tim.one@comcast.net (Tim Peters) Date: Mon, 25 Mar 2002 11:58:53 -0500 Subject: [Python-checkins] CVS: python/dist/src/Lib calendar.py,1.22.18.1,1.22.18.2 In-Reply-To: Message-ID: > Modified Files: > Tag: release22-maint > calendar.py > Log Message: > Slap HEAD version of calendar.py onto branch. > > Hope this was right thing to do. Looks fine to me! Thanks. From mwh@users.sourceforge.net Mon Mar 25 17:40:45 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Mon, 25 Mar 2002 09:40:45 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules socketmodule.c,1.200.6.2,1.200.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv32611 Modified Files: Tag: release22-maint socketmodule.c Log Message: backport jackjansen's checkin of revision 1.211 of socketmodule.c Due to interaction between the MSL C library and the GUSI I/O library I can get reads from sockets to work consistently either for unbuffered binary files or for buffered binary files, but not for both:-( The workaround is to force socket.makefile() to disable buffering for binary files. Fixes bug 534625. 2.2.1 candidate. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.200.6.2 retrieving revision 1.200.6.3 diff -C2 -d -r1.200.6.2 -r1.200.6.3 *** socketmodule.c 12 Jan 2002 11:13:23 -0000 1.200.6.2 --- socketmodule.c 25 Mar 2002 17:40:43 -0000 1.200.6.3 *************** *** 1454,1457 **** --- 1454,1462 ---- return PySocket_Err(); } + #ifdef USE_GUSI2 + /* Workaround for bug in Metrowerks MSL vs. GUSI I/O library */ + if (strchr(mode, 'b') != NULL ) + bufsize = 0; + #endif f = PyFile_FromFile(fp, "", mode, fclose); if (f != NULL) From doerwalter@users.sourceforge.net Mon Mar 25 17:43:25 2002 From: doerwalter@users.sourceforge.net (Walter D?rwald) Date: Mon, 25 Mar 2002 09:43:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects descrobject.c,2.22,2.23 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv894 Modified Files: descrobject.c Log Message: Add missing methods iterkeys, itervalues and iteritems to dict-proxy objects. Add real docstrings to all methods. Index: descrobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/descrobject.c,v retrieving revision 2.22 retrieving revision 2.23 diff -C2 -d -r2.22 -r2.23 *** descrobject.c 15 Dec 2001 05:00:30 -0000 2.22 --- descrobject.c 25 Mar 2002 17:43:22 -0000 2.23 *************** *** 645,648 **** --- 645,665 ---- static PyObject * + proxy_iterkeys(proxyobject *pp) + { + return PyObject_CallMethod(pp->dict, "iterkeys", NULL); + } + + static PyObject * + proxy_itervalues(proxyobject *pp) + { + return PyObject_CallMethod(pp->dict, "itervalues", NULL); + } + + static PyObject * + proxy_iteritems(proxyobject *pp) + { + return PyObject_CallMethod(pp->dict, "iteritems", NULL); + } + static PyObject * proxy_copy(proxyobject *pp) { *************** *** 651,660 **** static PyMethodDef proxy_methods[] = { ! {"has_key", (PyCFunction)proxy_has_key, METH_O, "XXX"}, ! {"get", (PyCFunction)proxy_get, METH_VARARGS, "XXX"}, ! {"keys", (PyCFunction)proxy_keys, METH_NOARGS, "XXX"}, ! {"values", (PyCFunction)proxy_values, METH_NOARGS, "XXX"}, ! {"items", (PyCFunction)proxy_items, METH_NOARGS, "XXX"}, ! {"copy", (PyCFunction)proxy_copy, METH_NOARGS, "XXX"}, {0} }; --- 668,680 ---- static PyMethodDef proxy_methods[] = { ! {"has_key", (PyCFunction)proxy_has_key, METH_O, "D.has_key(k) -> 1 if D has a key k, else 0"}, ! {"get", (PyCFunction)proxy_get, METH_VARARGS, "D.get(k[,d]) -> D[k] if D.has_key(k), else d. d defaults to None."}, ! {"keys", (PyCFunction)proxy_keys, METH_NOARGS, "D.keys() -> list of D's keys"}, ! {"values", (PyCFunction)proxy_values, METH_NOARGS, "D.values() -> list of D's values"}, ! {"items", (PyCFunction)proxy_items, METH_NOARGS, "D.items() -> list of D's (key, value) pairs, as 2-tuples"}, ! {"iterkeys", (PyCFunction)proxy_iterkeys, METH_NOARGS, "D.iterkeys() -> an iterator over the keys of D"}, ! {"itervalues",(PyCFunction)proxy_itervalues, METH_NOARGS, "D.itervalues() -> an iterator over the values of D"}, ! {"iteritems", (PyCFunction)proxy_iteritems, METH_NOARGS, "D.iteritems() -> an iterator over the (key, value) items of D"}, ! {"copy", (PyCFunction)proxy_copy, METH_NOARGS, "D.copy() -> a shallow copy of D"}, {0} }; From doerwalter@users.sourceforge.net Mon Mar 25 18:36:35 2002 From: doerwalter@users.sourceforge.net (Walter D?rwald) Date: Mon, 25 Mar 2002 10:36:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.122,1.123 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv16431 Modified Files: test_descr.py Log Message: Add tests for the iterkeys, itervalues and iteritems methods in dict-proxy objects. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.122 retrieving revision 1.123 diff -C2 -d -r1.122 -r1.123 *** test_descr.py 18 Mar 2002 03:09:06 -0000 1.122 --- test_descr.py 25 Mar 2002 18:36:32 -0000 1.123 *************** *** 2836,2839 **** --- 2836,2865 ---- vereq(m.__dict__, {"foo": 1}) + def dictproxyiterkeys(): + class C(object): + def meth(self): + pass + if verbose: print "Testing dict-proxy iterkeys..." + keys = [ key for key in C.__dict__.iterkeys() ] + keys.sort() + vereq(keys, ['__dict__', '__doc__', '__module__', '__weakref__', 'meth']) + + def dictproxyitervalues(): + class C(object): + def meth(self): + pass + if verbose: print "Testing dict-proxy itervalues..." + values = [ values for values in C.__dict__.itervalues() ] + vereq(len(values), 5) + + def dictproxyiteritems(): + class C(object): + def meth(self): + pass + if verbose: print "Testing dict-proxy iteritems..." + keys = [ key for (key, value) in C.__dict__.iteritems() ] + keys.sort() + vereq(keys, ['__dict__', '__doc__', '__module__', '__weakref__', 'meth']) + def test_main(): class_docstrings() *************** *** 2892,2895 **** --- 2918,2924 ---- deepcopyrecursive() modules() + dictproxyiterkeys() + dictproxyitervalues() + dictproxyiteritems() pickleslots() if verbose: print "All OK" From tim_one@users.sourceforge.net Mon Mar 25 19:28:45 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 25 Mar 2002 11:28:45 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include patchlevel.h,2.60.2.1.2.3,2.60.2.1.2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv2647/221/Include Modified Files: Tag: release22-maint patchlevel.h Log Message: Bump release to 2.2.1c2. Index: patchlevel.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/patchlevel.h,v retrieving revision 2.60.2.1.2.3 retrieving revision 2.60.2.1.2.4 diff -C2 -d -r2.60.2.1.2.3 -r2.60.2.1.2.4 *** patchlevel.h 14 Mar 2002 22:43:44 -0000 2.60.2.1.2.3 --- patchlevel.h 25 Mar 2002 19:28:43 -0000 2.60.2.1.2.4 *************** *** 24,31 **** #define PY_MICRO_VERSION 1 #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA ! #define PY_RELEASE_SERIAL 1 /* Version as a string */ ! #define PY_VERSION "2.2.1c1" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. --- 24,31 ---- #define PY_MICRO_VERSION 1 #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA ! #define PY_RELEASE_SERIAL 2 /* Version as a string */ ! #define PY_VERSION "2.2.1c2" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. From tim_one@users.sourceforge.net Mon Mar 25 19:30:42 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 25 Mar 2002 11:30:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild BUILDno.txt,1.26.4.4,1.26.4.5 pythoncore.dsp,1.30.4.1,1.30.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv3254/221/PCbuild Modified Files: Tag: release22-maint BUILDno.txt pythoncore.dsp Log Message: Bump Windows build number to 33. Index: BUILDno.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/BUILDno.txt,v retrieving revision 1.26.4.4 retrieving revision 1.26.4.5 diff -C2 -d -r1.26.4.4 -r1.26.4.5 *** BUILDno.txt 19 Mar 2002 02:13:47 -0000 1.26.4.4 --- BUILDno.txt 25 Mar 2002 19:30:40 -0000 1.26.4.5 *************** *** 34,37 **** --- 34,39 ---- Windows Python BUILD numbers ---------------------------- + 33 2.2.1c2 + 26-Mar-2002 32 2.2.1c1 18-Mar-2002 Index: pythoncore.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.dsp,v retrieving revision 1.30.4.1 retrieving revision 1.30.4.2 diff -C2 -d -r1.30.4.1 -r1.30.4.2 *** pythoncore.dsp 28 Feb 2002 07:43:20 -0000 1.30.4.1 --- pythoncore.dsp 25 Mar 2002 19:30:40 -0000 1.30.4.2 *************** *** 740,748 **** !IF "$(CFG)" == "pythoncore - Win32 Release" ! # ADD CPP /D BUILD=32 !ELSEIF "$(CFG)" == "pythoncore - Win32 Debug" ! # ADD CPP /D BUILD=32 !ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Debug" --- 740,748 ---- !IF "$(CFG)" == "pythoncore - Win32 Release" ! # ADD CPP /D BUILD=33 !ELSEIF "$(CFG)" == "pythoncore - Win32 Debug" ! # ADD CPP /D BUILD=33 !ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Debug" From tim_one@users.sourceforge.net Mon Mar 25 19:36:00 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 25 Mar 2002 11:36:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild BUILDno.txt,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv4649/python/PCbuild Modified Files: BUILDno.txt Log Message: Update master Windows build-number list for 2.2.1c2. Index: BUILDno.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/BUILDno.txt,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** BUILDno.txt 19 Mar 2002 02:12:10 -0000 1.33 --- BUILDno.txt 25 Mar 2002 19:35:58 -0000 1.34 *************** *** 34,37 **** --- 34,39 ---- Windows Python BUILD numbers ---------------------------- + 33 2.2.1c2 + 26-Mar-2002 32 2.2.1c1 18-Mar-2002 From fdrake@users.sourceforge.net Mon Mar 25 19:38:19 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 25 Mar 2002 11:38:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc Makefile,1.235.2.1.2.2,1.235.2.1.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory usw-pr-cvs1:/tmp/cvs-serv5355 Modified Files: Tag: release22-maint Makefile Log Message: Bump version numbers. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile,v retrieving revision 1.235.2.1.2.2 retrieving revision 1.235.2.1.2.3 diff -C2 -d -r1.235.2.1.2.2 -r1.235.2.1.2.3 *** Makefile 14 Mar 2002 22:56:04 -0000 1.235.2.1.2.2 --- Makefile 25 Mar 2002 19:38:16 -0000 1.235.2.1.2.3 *************** *** 67,71 **** # This is the *documentation* release, and is used to construct the file # names of the downloadable tarballs. ! RELEASE=2.2.1c1 PYTHON= python --- 67,71 ---- # This is the *documentation* release, and is used to construct the file # names of the downloadable tarballs. ! RELEASE=2.2.1c2 PYTHON= python From fdrake@users.sourceforge.net Mon Mar 25 19:38:19 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 25 Mar 2002 11:38:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/texinputs boilerplate.tex,1.70.2.1.2.2,1.70.2.1.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory usw-pr-cvs1:/tmp/cvs-serv5355/texinputs Modified Files: Tag: release22-maint boilerplate.tex Log Message: Bump version numbers. Index: boilerplate.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/boilerplate.tex,v retrieving revision 1.70.2.1.2.2 retrieving revision 1.70.2.1.2.3 diff -C2 -d -r1.70.2.1.2.2 -r1.70.2.1.2.3 *** boilerplate.tex 14 Mar 2002 22:56:04 -0000 1.70.2.1.2.2 --- boilerplate.tex 25 Mar 2002 19:38:17 -0000 1.70.2.1.2.3 *************** *** 8,11 **** \date{\today} % XXX update before release! \release{2.2.1} % software release, not documentation ! \setreleaseinfo{c1} % empty for final release \setshortversion{2.2} % major.minor only for software --- 8,11 ---- \date{\today} % XXX update before release! \release{2.2.1} % software release, not documentation ! \setreleaseinfo{c2} % empty for final release \setshortversion{2.2} % major.minor only for software From tim_one@users.sourceforge.net Mon Mar 25 20:17:22 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Mon, 25 Mar 2002 12:17:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python20.wse,1.98.4.2,1.98.4.3 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv16328/221/PCbuild Modified Files: Tag: release22-maint python20.wse Log Message: Embed the right 2.2.1c2 identification strings in the Windows installer. Index: python20.wse =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.wse,v retrieving revision 1.98.4.2 retrieving revision 1.98.4.3 diff -C2 -d -r1.98.4.2 -r1.98.4.3 *** python20.wse 14 Mar 2002 22:46:55 -0000 1.98.4.2 --- python20.wse 25 Mar 2002 20:17:19 -0000 1.98.4.3 *************** *** 2,6 **** item: Global Version=8.14 ! Title=Python 2.2.1 release candidate 1 Flags=00010100 Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 --- 2,6 ---- item: Global Version=8.14 ! Title=Python 2.2.1 release candidate 2 Flags=00010100 Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 *************** *** 19,25 **** Patch Threshold=85 Patch Memory=4000 ! EXE Filename=Python-2.2.1c1.exe Dialogs Version=8 ! Version File=2.2.1c1 Version Description=Python Programming Language Version Copyright=©2002 Python Software Foundation --- 19,25 ---- Patch Threshold=85 Patch Memory=4000 ! EXE Filename=Python-2.2.1c2.exe Dialogs Version=8 ! Version File=2.2.1c2 Version Description=Python Programming Language Version Copyright=©2002 Python Software Foundation *************** *** 65,69 **** item: Set Variable Variable=PYVER_STRING ! Value=2.2.1c1 end item: Remark --- 65,69 ---- item: Set Variable Variable=PYVER_STRING ! Value=2.2.1c2 end item: Remark From fdrake@users.sourceforge.net Mon Mar 25 20:22:30 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 25 Mar 2002 12:22:30 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libre.tex,1.73.6.5,1.73.6.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv17899/lib Modified Files: Tag: release22-maint libre.tex Log Message: Document the finditer() function and method. This closes SF bug #520904. Explain that many of the escapes supported by string literals are also supported by the RE compiler, and list which ones. This closes SF bug #529923. Index: libre.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v retrieving revision 1.73.6.5 retrieving revision 1.73.6.6 diff -C2 -d -r1.73.6.5 -r1.73.6.6 *** libre.tex 18 Mar 2002 16:44:46 -0000 1.73.6.5 --- libre.tex 25 Mar 2002 20:22:28 -0000 1.73.6.6 *************** *** 372,379 **** \item[\code{\e Z}]Matches only at the end of the string. - \item[\code{\e \e}] Matches a literal backslash. - \end{list} \subsection{Matching vs. Searching \label{matching-searching}} --- 372,392 ---- \item[\code{\e Z}]Matches only at the end of the string. \end{list} + Most of the standard escapes supported by Python string literals are + also accepted by the regular expression parser: + + \begin{verbatim} + \a \b \f \n + \r \t \v \x + \\ + \end{verbatim} + + Note that octal escapes are not included. While the parser can + attempt to determine whether a character is being specified by it's + ordinal value expressed in octal, doing so yields an expression which + is relatively difficult to maintain, as the same syntax is used to + refer to numbered groups. + \subsection{Matching vs. Searching \label{matching-searching}} *************** *** 545,548 **** --- 558,568 ---- \end{funcdesc} + \begin{funcdesc}{finditer}{pattern, string} + Return an iterator over all non-overlapping matches for the RE + \var{pattern} in \var{string}. For each match, the iterator returns + a match object. Empty matches are included in the result. + \versionadded{2.2} + \end{funcdesc} + \begin{funcdesc}{sub}{pattern, repl, string\optional{, count}} Return the string obtained by replacing the leftmost non-overlapping *************** *** 669,672 **** --- 689,696 ---- \begin{methoddesc}[RegexObject]{findall}{string} Identical to the \function{findall()} function, using the compiled pattern. + \end{methoddesc} + + \begin{methoddesc}[RegexObject]{finditer}{string} + Identical to the \function{finditer()} function, using the compiled pattern. \end{methoddesc} From fdrake@users.sourceforge.net Mon Mar 25 20:23:01 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Mon, 25 Mar 2002 12:23:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libre.tex,1.80,1.81 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv18060/lib Modified Files: libre.tex Log Message: Document the finditer() function and method. This closes SF bug #520904. Explain that many of the escapes supported by string literals are also supported by the RE compiler, and list which ones. This closes SF bug #529923. Index: libre.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** libre.tex 18 Mar 2002 16:45:01 -0000 1.80 --- libre.tex 25 Mar 2002 20:22:59 -0000 1.81 *************** *** 372,379 **** \item[\code{\e Z}]Matches only at the end of the string. - \item[\code{\e \e}] Matches a literal backslash. - \end{list} \subsection{Matching vs. Searching \label{matching-searching}} --- 372,392 ---- \item[\code{\e Z}]Matches only at the end of the string. \end{list} + Most of the standard escapes supported by Python string literals are + also accepted by the regular expression parser: + + \begin{verbatim} + \a \b \f \n + \r \t \v \x + \\ + \end{verbatim} + + Note that octal escapes are not included. While the parser can + attempt to determine whether a character is being specified by it's + ordinal value expressed in octal, doing so yields an expression which + is relatively difficult to maintain, as the same syntax is used to + refer to numbered groups. + \subsection{Matching vs. Searching \label{matching-searching}} *************** *** 545,548 **** --- 558,568 ---- \end{funcdesc} + \begin{funcdesc}{finditer}{pattern, string} + Return an iterator over all non-overlapping matches for the RE + \var{pattern} in \var{string}. For each match, the iterator returns + a match object. Empty matches are included in the result. + \versionadded{2.2} + \end{funcdesc} + \begin{funcdesc}{sub}{pattern, repl, string\optional{, count}} Return the string obtained by replacing the leftmost non-overlapping *************** *** 669,672 **** --- 689,696 ---- \begin{methoddesc}[RegexObject]{findall}{string} Identical to the \function{findall()} function, using the compiled pattern. + \end{methoddesc} + + \begin{methoddesc}[RegexObject]{finditer}{string} + Identical to the \function{finditer()} function, using the compiled pattern. \end{methoddesc} From nnorwitz@users.sourceforge.net Mon Mar 25 20:46:47 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Mon, 25 Mar 2002 12:46:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include Python.h,2.42,2.43 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv25705/Include Modified Files: Python.h Log Message: Remove many uses of PyArg_NoArgs macro, change METH_OLDARGS to METH_NOARGS. Index: Python.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/Python.h,v retrieving revision 2.42 retrieving revision 2.43 diff -C2 -d -r2.42 -r2.43 *** Python.h 23 Mar 2002 10:03:50 -0000 2.42 --- Python.h 25 Mar 2002 20:46:45 -0000 2.43 *************** *** 119,122 **** --- 119,125 ---- #define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a)) + + /* PyArg_NoArgs should not be necessary. + Set ml_flags in the PyMethodDef to METH_NOARGS. */ #define PyArg_NoArgs(v) PyArg_Parse(v, "") From nnorwitz@users.sourceforge.net Mon Mar 25 20:46:48 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Mon, 25 Mar 2002 12:46:48 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _curses_panel.c,1.10,1.11 _localemodule.c,2.26,2.27 bsddbmodule.c,1.32,1.33 md5module.c,2.27,2.28 pwdmodule.c,1.28,1.29 readline.c,2.45,2.46 signalmodule.c,2.63,2.64 threadmodule.c,2.44,2.45 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv25705/Modules Modified Files: _curses_panel.c _localemodule.c bsddbmodule.c md5module.c pwdmodule.c readline.c signalmodule.c threadmodule.c Log Message: Remove many uses of PyArg_NoArgs macro, change METH_OLDARGS to METH_NOARGS. Index: _curses_panel.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_curses_panel.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** _curses_panel.c 30 Jan 2002 15:47:34 -0000 1.10 --- _curses_panel.c 25 Mar 2002 20:46:45 -0000 1.11 *************** *** 356,360 **** may be undesirable. */ static PyObject * ! PyCurses_bottom_panel(PyObject *self, PyObject *args) { PANEL *pan; --- 356,360 ---- may be undesirable. */ static PyObject * ! PyCurses_bottom_panel(PyObject *self) { PANEL *pan; *************** *** 362,367 **** PyCursesInitialised; - - if (!PyArg_NoArgs(args)) return NULL; pan = panel_above(NULL); --- 362,365 ---- *************** *** 404,408 **** undesirable. */ static PyObject * ! PyCurses_top_panel(PyObject *self, PyObject *args) { PANEL *pan; --- 402,406 ---- undesirable. */ static PyObject * ! PyCurses_top_panel(PyObject *self) { PANEL *pan; *************** *** 410,415 **** PyCursesInitialised; - - if (!PyArg_NoArgs(args)) return NULL; pan = panel_below(NULL); --- 408,411 ---- *************** *** 430,437 **** } ! static PyObject *PyCurses_update_panels(PyObject *self, PyObject *args) { PyCursesInitialised; - if (!PyArg_NoArgs(args)) return NULL; update_panels(); Py_INCREF(Py_None); --- 426,432 ---- } ! static PyObject *PyCurses_update_panels(PyObject *self) { PyCursesInitialised; update_panels(); Py_INCREF(Py_None); *************** *** 443,450 **** 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 */ }; --- 438,445 ---- static PyMethodDef PyCurses_methods[] = { ! {"bottom_panel", (PyCFunction)PyCurses_bottom_panel, METH_NOARGS}, ! {"new_panel", (PyCFunction)PyCurses_new_panel, METH_VARARGS}, ! {"top_panel", (PyCFunction)PyCurses_top_panel, METH_NOARGS}, ! {"update_panels", (PyCFunction)PyCurses_update_panels, METH_NOARGS}, {NULL, NULL} /* sentinel */ }; Index: _localemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v retrieving revision 2.26 retrieving revision 2.27 diff -C2 -d -r2.26 -r2.27 *** _localemodule.c 12 Mar 2002 22:05:02 -0000 2.26 --- _localemodule.c 25 Mar 2002 20:46:45 -0000 2.27 *************** *** 246,250 **** static PyObject* ! PyLocale_localeconv(PyObject* self, PyObject* args) { PyObject* result; --- 246,250 ---- static PyObject* ! PyLocale_localeconv(PyObject* self) { PyObject* result; *************** *** 252,258 **** PyObject *x; - if (!PyArg_NoArgs(args)) - return NULL; - result = PyDict_New(); if (!result) --- 252,255 ---- *************** *** 369,380 **** #if defined(MS_WIN32) static PyObject* ! PyLocale_getdefaultlocale(PyObject* self, PyObject* args) { char encoding[100]; char locale[100]; - if (!PyArg_NoArgs(args)) - return NULL; - PyOS_snprintf(encoding, sizeof(encoding), "cp%d", GetACP()); --- 366,374 ---- #if defined(MS_WIN32) static PyObject* ! PyLocale_getdefaultlocale(PyObject* self) { char encoding[100]; char locale[100]; PyOS_snprintf(encoding, sizeof(encoding), "cp%d", GetACP()); *************** *** 409,413 **** #if defined(macintosh) static PyObject* ! PyLocale_getdefaultlocale(PyObject* self, PyObject* args) { return Py_BuildValue("Os", Py_None, PyMac_getscript()); --- 403,407 ---- #if defined(macintosh) static PyObject* ! PyLocale_getdefaultlocale(PyObject* self) { return Py_BuildValue("Os", Py_None, PyMac_getscript()); *************** *** 531,535 **** METH_VARARGS, setlocale__doc__}, {"localeconv", (PyCFunction) PyLocale_localeconv, ! 0, localeconv__doc__}, {"strcoll", (PyCFunction) PyLocale_strcoll, METH_VARARGS, strcoll__doc__}, --- 525,529 ---- METH_VARARGS, setlocale__doc__}, {"localeconv", (PyCFunction) PyLocale_localeconv, ! METH_NOARGS, localeconv__doc__}, {"strcoll", (PyCFunction) PyLocale_strcoll, METH_VARARGS, strcoll__doc__}, *************** *** 537,541 **** METH_VARARGS, strxfrm__doc__}, #if defined(MS_WIN32) || defined(macintosh) ! {"_getdefaultlocale", (PyCFunction) PyLocale_getdefaultlocale, 0}, #endif #ifdef HAVE_LANGINFO_H --- 531,535 ---- METH_VARARGS, strxfrm__doc__}, #if defined(MS_WIN32) || defined(macintosh) ! {"_getdefaultlocale", (PyCFunction) PyLocale_getdefaultlocale, METH_NOARGS}, #endif #ifdef HAVE_LANGINFO_H Index: bsddbmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/bsddbmodule.c,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** bsddbmodule.c 17 Jan 2002 23:15:58 -0000 1.32 --- bsddbmodule.c 25 Mar 2002 20:46:45 -0000 1.33 *************** *** 381,388 **** static PyObject * ! bsddb_close(bsddbobject *dp, PyObject *args) { - if (!PyArg_NoArgs(args)) - return NULL; if (dp->di_bsddb != NULL) { int status; --- 381,386 ---- static PyObject * ! bsddb_close(bsddbobject *dp) { if (dp->di_bsddb != NULL) { int status; *************** *** 402,406 **** static PyObject * ! bsddb_keys(bsddbobject *dp, PyObject *args) { PyObject *list, *item=NULL; --- 400,404 ---- static PyObject * ! bsddb_keys(bsddbobject *dp) { PyObject *list, *item=NULL; *************** *** 410,415 **** int err; - if (!PyArg_NoArgs(args)) - return NULL; check_bsddbobject_open(dp, NULL); list = PyList_New(0); --- 408,411 ---- *************** *** 563,567 **** static PyObject * ! bsddb_seq(bsddbobject *dp, PyObject *args, int sequence_request) { int status; --- 559,563 ---- static PyObject * ! bsddb_seq(bsddbobject *dp, int sequence_request) { int status; *************** *** 571,577 **** PyObject *result; - if (!PyArg_NoArgs(args)) - return NULL; - check_bsddbobject_open(dp, NULL); krec.data = 0; --- 567,570 ---- *************** *** 599,607 **** PyErr_SetFromErrno(BsddbError); else ! PyErr_SetObject(PyExc_KeyError, args); return NULL; } - if (dp->di_type == DB_RECNO) result = Py_BuildValue("is#", *((int*)kdata), --- 592,599 ---- PyErr_SetFromErrno(BsddbError); else ! PyErr_SetString(PyExc_KeyError, "no key/data pairs"); return NULL; } if (dp->di_type == DB_RECNO) result = Py_BuildValue("is#", *((int*)kdata), *************** *** 616,645 **** static PyObject * ! bsddb_next(bsddbobject *dp, PyObject *key) { ! return bsddb_seq(dp, key, R_NEXT); } static PyObject * ! bsddb_previous(bsddbobject *dp, PyObject *key) { ! return bsddb_seq(dp, key, R_PREV); } static PyObject * ! bsddb_first(bsddbobject *dp, PyObject *key) { ! return bsddb_seq(dp, key, R_FIRST); } static PyObject * ! bsddb_last(bsddbobject *dp, PyObject *key) { ! return bsddb_seq(dp, key, R_LAST); } static PyObject * ! bsddb_sync(bsddbobject *dp, PyObject *args) { int status; - if (!PyArg_NoArgs(args)) - return NULL; check_bsddbobject_open(dp, NULL); BSDDB_BGN_SAVE(dp) --- 608,635 ---- static PyObject * ! bsddb_next(bsddbobject *dp) { ! return bsddb_seq(dp, R_NEXT); } static PyObject * ! bsddb_previous(bsddbobject *dp) { ! return bsddb_seq(dp, R_PREV); } static PyObject * ! bsddb_first(bsddbobject *dp) { ! return bsddb_seq(dp, R_FIRST); } static PyObject * ! bsddb_last(bsddbobject *dp) { ! return bsddb_seq(dp, R_LAST); } static PyObject * ! bsddb_sync(bsddbobject *dp) { int status; check_bsddbobject_open(dp, NULL); BSDDB_BGN_SAVE(dp) *************** *** 653,665 **** } static PyMethodDef bsddb_methods[] = { ! {"close", (PyCFunction)bsddb_close, METH_OLDARGS}, ! {"keys", (PyCFunction)bsddb_keys, METH_OLDARGS}, {"has_key", (PyCFunction)bsddb_has_key, METH_OLDARGS}, {"set_location", (PyCFunction)bsddb_set_location, METH_OLDARGS}, ! {"next", (PyCFunction)bsddb_next, METH_OLDARGS}, ! {"previous", (PyCFunction)bsddb_previous, METH_OLDARGS}, ! {"first", (PyCFunction)bsddb_first, METH_OLDARGS}, ! {"last", (PyCFunction)bsddb_last, METH_OLDARGS}, ! {"sync", (PyCFunction)bsddb_sync, METH_OLDARGS}, {NULL, NULL} /* sentinel */ }; --- 643,655 ---- } static PyMethodDef bsddb_methods[] = { ! {"close", (PyCFunction)bsddb_close, METH_NOARGS}, ! {"keys", (PyCFunction)bsddb_keys, METH_NOARGS}, {"has_key", (PyCFunction)bsddb_has_key, METH_OLDARGS}, {"set_location", (PyCFunction)bsddb_set_location, METH_OLDARGS}, ! {"next", (PyCFunction)bsddb_next, METH_NOARGS}, ! {"previous", (PyCFunction)bsddb_previous, METH_NOARGS}, ! {"first", (PyCFunction)bsddb_first, METH_NOARGS}, ! {"last", (PyCFunction)bsddb_last, METH_NOARGS}, ! {"sync", (PyCFunction)bsddb_sync, METH_NOARGS}, {NULL, NULL} /* sentinel */ }; Index: md5module.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/md5module.c,v retrieving revision 2.27 retrieving revision 2.28 diff -C2 -d -r2.27 -r2.28 *** md5module.c 8 Dec 2001 18:02:57 -0000 2.27 --- md5module.c 25 Mar 2002 20:46:46 -0000 2.28 *************** *** 71,82 **** static PyObject * ! md5_digest(md5object *self, PyObject *args) { MD5_CTX mdContext; unsigned char aDigest[16]; - if (!PyArg_NoArgs(args)) - return NULL; - /* make a temporary copy, and perform the final */ mdContext = self->md5; --- 71,79 ---- static PyObject * ! md5_digest(md5object *self) { MD5_CTX mdContext; unsigned char aDigest[16]; /* make a temporary copy, and perform the final */ mdContext = self->md5; *************** *** 95,99 **** static PyObject * ! md5_hexdigest(md5object *self, PyObject *args) { MD5_CTX mdContext; --- 92,96 ---- static PyObject * ! md5_hexdigest(md5object *self) { MD5_CTX mdContext; *************** *** 102,108 **** int i, j; - if (!PyArg_NoArgs(args)) - return NULL; - /* make a temporary copy, and perform the final */ mdContext = self->md5; --- 99,102 ---- *************** *** 130,140 **** static PyObject * ! md5_copy(md5object *self, PyObject *args) { md5object *md5p; - if (!PyArg_NoArgs(args)) - return NULL; - if ((md5p = newmd5object()) == NULL) return NULL; --- 124,131 ---- static PyObject * ! md5_copy(md5object *self) { md5object *md5p; if ((md5p = newmd5object()) == NULL) return NULL; *************** *** 153,159 **** static PyMethodDef md5_methods[] = { {"update", (PyCFunction)md5_update, METH_OLDARGS, update_doc}, ! {"digest", (PyCFunction)md5_digest, METH_OLDARGS, digest_doc}, ! {"hexdigest", (PyCFunction)md5_hexdigest, METH_OLDARGS, hexdigest_doc}, ! {"copy", (PyCFunction)md5_copy, METH_OLDARGS, copy_doc}, {NULL, NULL} /* sentinel */ }; --- 144,150 ---- static PyMethodDef md5_methods[] = { {"update", (PyCFunction)md5_update, METH_OLDARGS, update_doc}, ! {"digest", (PyCFunction)md5_digest, METH_NOARGS, digest_doc}, ! {"hexdigest", (PyCFunction)md5_hexdigest, METH_NOARGS, hexdigest_doc}, ! {"copy", (PyCFunction)md5_copy, METH_NOARGS, copy_doc}, {NULL, NULL} /* sentinel */ }; Index: pwdmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pwdmodule.c,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** pwdmodule.c 3 Mar 2002 02:59:16 -0000 1.28 --- pwdmodule.c 25 Mar 2002 20:46:46 -0000 1.29 *************** *** 121,130 **** static PyObject * ! pwd_getpwall(PyObject *self, PyObject *args) { PyObject *d; struct passwd *p; - if (!PyArg_NoArgs(args)) - return NULL; if ((d = PyList_New(0)) == NULL) return NULL; --- 121,128 ---- static PyObject * ! pwd_getpwall(PyObject *self) { PyObject *d; struct passwd *p; if ((d = PyList_New(0)) == NULL) return NULL; *************** *** 152,156 **** {"getpwnam", pwd_getpwnam, METH_OLDARGS, pwd_getpwnam__doc__}, #ifdef HAVE_GETPWENT ! {"getpwall", pwd_getpwall, METH_OLDARGS, pwd_getpwall__doc__}, #endif {NULL, NULL} /* sentinel */ --- 150,154 ---- {"getpwnam", pwd_getpwnam, METH_OLDARGS, pwd_getpwnam__doc__}, #ifdef HAVE_GETPWENT ! {"getpwall", pwd_getpwall, METH_NOARGS, pwd_getpwall__doc__}, #endif {NULL, NULL} /* sentinel */ Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.45 retrieving revision 2.46 diff -C2 -d -r2.45 -r2.46 *** readline.c 24 Mar 2002 01:09:04 -0000 2.45 --- readline.c 25 Mar 2002 20:46:46 -0000 2.46 *************** *** 238,246 **** /* get the beginning index for the scope of the tab-completion */ static PyObject * ! get_begidx(PyObject *self, PyObject *args) { - if(!PyArg_NoArgs(args)) { - return NULL; - } Py_INCREF(begidx); return begidx; --- 238,243 ---- /* get the beginning index for the scope of the tab-completion */ static PyObject * ! get_begidx(PyObject *self) { Py_INCREF(begidx); return begidx; *************** *** 253,261 **** /* get the ending index for the scope of the tab-completion */ static PyObject * ! get_endidx(PyObject *self, PyObject *args) { - if(!PyArg_NoArgs(args)) { - return NULL; - } Py_INCREF(endidx); return endidx; --- 250,255 ---- /* get the ending index for the scope of the tab-completion */ static PyObject * ! get_endidx(PyObject *self) { Py_INCREF(endidx); return endidx; *************** *** 308,316 **** static PyObject * ! get_completer_delims(PyObject *self, PyObject *args) { - if(!PyArg_NoArgs(args)) { - return NULL; - } return PyString_FromString(rl_completer_word_break_characters); } --- 302,307 ---- static PyObject * ! get_completer_delims(PyObject *self) { return PyString_FromString(rl_completer_word_break_characters); } *************** *** 360,369 **** static PyObject * ! get_current_history_length(PyObject *self, PyObject *args) { HISTORY_STATE *hist_st; - if (!PyArg_NoArgs(args)) - return NULL; hist_st = history_get_history_state(); return PyInt_FromLong(hist_st ? (long) hist_st->length : (long) 0); --- 351,358 ---- static PyObject * ! get_current_history_length(PyObject *self) { HISTORY_STATE *hist_st; hist_st = history_get_history_state(); return PyInt_FromLong(hist_st ? (long) hist_st->length : (long) 0); *************** *** 378,385 **** static PyObject * ! get_line_buffer(PyObject *self, PyObject *args) { - if (!PyArg_NoArgs(args)) - return NULL; return PyString_FromString(rl_line_buffer); } --- 367,372 ---- static PyObject * ! get_line_buffer(PyObject *self) { return PyString_FromString(rl_line_buffer); } *************** *** 428,432 **** {"parse_and_bind", parse_and_bind, METH_VARARGS, doc_parse_and_bind}, {"get_line_buffer", get_line_buffer, ! METH_OLDARGS, doc_get_line_buffer}, {"insert_text", insert_text, METH_VARARGS, doc_insert_text}, {"redisplay", (PyCFunction)redisplay, METH_NOARGS, doc_redisplay}, --- 415,419 ---- {"parse_and_bind", parse_and_bind, METH_VARARGS, doc_parse_and_bind}, {"get_line_buffer", get_line_buffer, ! METH_NOARGS, doc_get_line_buffer}, {"insert_text", insert_text, METH_VARARGS, doc_insert_text}, {"redisplay", (PyCFunction)redisplay, METH_NOARGS, doc_redisplay}, *************** *** 439,443 **** METH_VARARGS, doc_get_history_item}, {"get_current_history_length", get_current_history_length, ! METH_OLDARGS, doc_get_current_history_length}, {"set_history_length", set_history_length, METH_VARARGS, set_history_length_doc}, --- 426,430 ---- METH_VARARGS, doc_get_history_item}, {"get_current_history_length", get_current_history_length, ! METH_NOARGS, doc_get_current_history_length}, {"set_history_length", set_history_length, METH_VARARGS, set_history_length_doc}, *************** *** 445,450 **** METH_VARARGS, get_history_length_doc}, {"set_completer", set_completer, METH_VARARGS, doc_set_completer}, ! {"get_begidx", get_begidx, METH_OLDARGS, doc_get_begidx}, ! {"get_endidx", get_endidx, METH_OLDARGS, doc_get_endidx}, {"set_completer_delims", set_completer_delims, --- 432,437 ---- METH_VARARGS, get_history_length_doc}, {"set_completer", set_completer, METH_VARARGS, doc_set_completer}, ! {"get_begidx", get_begidx, METH_NOARGS, doc_get_begidx}, ! {"get_endidx", get_endidx, METH_NOARGS, doc_get_endidx}, {"set_completer_delims", set_completer_delims, *************** *** 452,456 **** {"add_history", py_add_history, METH_VARARGS, doc_add_history}, {"get_completer_delims", get_completer_delims, ! METH_OLDARGS, doc_get_completer_delims}, {"set_startup_hook", set_startup_hook, METH_VARARGS, doc_set_startup_hook}, --- 439,443 ---- {"add_history", py_add_history, METH_VARARGS, doc_add_history}, {"get_completer_delims", get_completer_delims, ! METH_NOARGS, doc_get_completer_delims}, {"set_startup_hook", set_startup_hook, METH_VARARGS, doc_set_startup_hook}, Index: signalmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/signalmodule.c,v retrieving revision 2.63 retrieving revision 2.64 diff -C2 -d -r2.63 -r2.64 *** signalmodule.c 3 Mar 2002 02:59:16 -0000 2.63 --- signalmodule.c 25 Mar 2002 20:46:46 -0000 2.64 *************** *** 164,172 **** #ifdef HAVE_PAUSE static PyObject * ! signal_pause(PyObject *self, PyObject *args) { - if (!PyArg_NoArgs(args)) - return NULL; - Py_BEGIN_ALLOW_THREADS (void)pause(); --- 164,169 ---- #ifdef HAVE_PAUSE static PyObject * ! signal_pause(PyObject *self) { Py_BEGIN_ALLOW_THREADS (void)pause(); *************** *** 283,287 **** {"getsignal", signal_getsignal, METH_OLDARGS, getsignal_doc}, #ifdef HAVE_PAUSE ! {"pause", signal_pause, METH_OLDARGS, pause_doc}, #endif {"default_int_handler", signal_default_int_handler, --- 280,284 ---- {"getsignal", signal_getsignal, METH_OLDARGS, getsignal_doc}, #ifdef HAVE_PAUSE ! {"pause", signal_pause, METH_NOARGS, pause_doc}, #endif {"default_int_handler", signal_default_int_handler, Index: threadmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/threadmodule.c,v retrieving revision 2.44 retrieving revision 2.45 diff -C2 -d -r2.44 -r2.45 *** threadmodule.c 8 Dec 2001 18:02:58 -0000 2.44 --- threadmodule.c 25 Mar 2002 20:46:46 -0000 2.45 *************** *** 88,96 **** static PyObject * ! lock_PyThread_release_lock(lockobject *self, PyObject *args) { - if (!PyArg_NoArgs(args)) - return NULL; - /* Sanity check: the lock must be locked */ if (PyThread_acquire_lock(self->lock_lock, 0)) { --- 88,93 ---- static PyObject * ! lock_PyThread_release_lock(lockobject *self) { /* Sanity check: the lock must be locked */ if (PyThread_acquire_lock(self->lock_lock, 0)) { *************** *** 114,122 **** static PyObject * ! lock_locked_lock(lockobject *self, PyObject *args) { - if (!PyArg_NoArgs(args)) - return NULL; - if (PyThread_acquire_lock(self->lock_lock, 0)) { PyThread_release_lock(self->lock_lock); --- 111,116 ---- static PyObject * ! lock_locked_lock(lockobject *self) { if (PyThread_acquire_lock(self->lock_lock, 0)) { PyThread_release_lock(self->lock_lock); *************** *** 138,146 **** METH_OLDARGS, acquire_doc}, {"release_lock", (PyCFunction)lock_PyThread_release_lock, ! METH_OLDARGS, release_doc}, {"release", (PyCFunction)lock_PyThread_release_lock, METH_OLDARGS, release_doc}, {"locked_lock", (PyCFunction)lock_locked_lock, ! METH_OLDARGS, locked_doc}, {"locked", (PyCFunction)lock_locked_lock, METH_OLDARGS, locked_doc}, --- 132,140 ---- METH_OLDARGS, acquire_doc}, {"release_lock", (PyCFunction)lock_PyThread_release_lock, ! METH_NOARGS, release_doc}, {"release", (PyCFunction)lock_PyThread_release_lock, METH_OLDARGS, release_doc}, {"locked_lock", (PyCFunction)lock_locked_lock, ! METH_NOARGS, locked_doc}, {"locked", (PyCFunction)lock_locked_lock, METH_OLDARGS, locked_doc}, *************** *** 268,275 **** static PyObject * ! thread_PyThread_exit_thread(PyObject *self, PyObject *args) { - if (!PyArg_NoArgs(args)) - return NULL; PyErr_SetNone(PyExc_SystemExit); return NULL; --- 262,267 ---- static PyObject * ! thread_PyThread_exit_thread(PyObject *self) { PyErr_SetNone(PyExc_SystemExit); return NULL; *************** *** 296,303 **** static PyObject * ! thread_PyThread_allocate_lock(PyObject *self, PyObject *args) { - if (!PyArg_NoArgs(args)) - return NULL; return (PyObject *) newlockobject(); } --- 288,293 ---- static PyObject * ! thread_PyThread_allocate_lock(PyObject *self) { return (PyObject *) newlockobject(); } *************** *** 310,318 **** static PyObject * ! thread_get_ident(PyObject *self, PyObject *args) { long ident; - if (!PyArg_NoArgs(args)) - return NULL; ident = PyThread_get_thread_ident(); if (ident == -1) { --- 300,306 ---- static PyObject * ! thread_get_ident(PyObject *self) { long ident; ident = PyThread_get_thread_ident(); if (ident == -1) { *************** *** 342,354 **** start_new_doc}, {"allocate_lock", (PyCFunction)thread_PyThread_allocate_lock, ! METH_OLDARGS, allocate_doc}, {"allocate", (PyCFunction)thread_PyThread_allocate_lock, METH_OLDARGS, allocate_doc}, {"exit_thread", (PyCFunction)thread_PyThread_exit_thread, ! METH_OLDARGS, exit_doc}, {"exit", (PyCFunction)thread_PyThread_exit_thread, METH_OLDARGS, exit_doc}, {"get_ident", (PyCFunction)thread_get_ident, ! METH_OLDARGS, get_ident_doc}, #ifndef NO_EXIT_PROG {"exit_prog", (PyCFunction)thread_PyThread_exit_prog}, --- 330,342 ---- start_new_doc}, {"allocate_lock", (PyCFunction)thread_PyThread_allocate_lock, ! METH_NOARGS, allocate_doc}, {"allocate", (PyCFunction)thread_PyThread_allocate_lock, METH_OLDARGS, allocate_doc}, {"exit_thread", (PyCFunction)thread_PyThread_exit_thread, ! METH_NOARGS, exit_doc}, {"exit", (PyCFunction)thread_PyThread_exit_thread, METH_OLDARGS, exit_doc}, {"get_ident", (PyCFunction)thread_get_ident, ! METH_NOARGS, get_ident_doc}, #ifndef NO_EXIT_PROG {"exit_prog", (PyCFunction)thread_PyThread_exit_prog}, From nnorwitz@users.sourceforge.net Mon Mar 25 21:05:52 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Mon, 25 Mar 2002 13:05:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules threadmodule.c,2.45,2.46 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv32559/Modules Modified Files: threadmodule.c Log Message: Missed change METH_OLDARGS to METH_NOARGS for two aliased functions Index: threadmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/threadmodule.c,v retrieving revision 2.45 retrieving revision 2.46 diff -C2 -d -r2.45 -r2.46 *** threadmodule.c 25 Mar 2002 20:46:46 -0000 2.45 --- threadmodule.c 25 Mar 2002 21:05:50 -0000 2.46 *************** *** 134,142 **** METH_NOARGS, release_doc}, {"release", (PyCFunction)lock_PyThread_release_lock, ! METH_OLDARGS, release_doc}, {"locked_lock", (PyCFunction)lock_locked_lock, METH_NOARGS, locked_doc}, {"locked", (PyCFunction)lock_locked_lock, ! METH_OLDARGS, locked_doc}, {NULL, NULL} /* sentinel */ }; --- 134,142 ---- METH_NOARGS, release_doc}, {"release", (PyCFunction)lock_PyThread_release_lock, ! METH_NOARGS, release_doc}, {"locked_lock", (PyCFunction)lock_locked_lock, METH_NOARGS, locked_doc}, {"locked", (PyCFunction)lock_locked_lock, ! METH_NOARGS, locked_doc}, {NULL, NULL} /* sentinel */ }; From montanaro@users.sourceforge.net Mon Mar 25 21:37:56 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Mon, 25 Mar 2002 13:37:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib inspect.py,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv9726 Modified Files: inspect.py Log Message: tighten up unqualified except in currentframe() see bug 411881 Index: inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** inspect.py 23 Mar 2002 23:51:04 -0000 1.29 --- inspect.py 25 Mar 2002 21:37:54 -0000 1.30 *************** *** 763,768 **** """Return the frame object for the caller's stack frame.""" try: ! raise 'catch me' ! except: return sys.exc_traceback.tb_frame.f_back --- 763,768 ---- """Return the frame object for the caller's stack frame.""" try: ! 1/0 ! except ZeroDivisionError: return sys.exc_traceback.tb_frame.f_back From montanaro@users.sourceforge.net Mon Mar 25 21:40:38 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Mon, 25 Mar 2002 13:40:38 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib locale.py,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv10830 Modified Files: locale.py Log Message: eliminate unqualified except when checking for presence of LC_MESSAGES see bug 411881 Index: locale.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/locale.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** locale.py 13 Aug 2001 14:50:44 -0000 1.19 --- locale.py 25 Mar 2002 21:40:36 -0000 1.20 *************** *** 720,724 **** try: LC_MESSAGES ! except: pass else: --- 720,724 ---- try: LC_MESSAGES ! except NameError: pass else: From montanaro@users.sourceforge.net Mon Mar 25 21:44:11 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Mon, 25 Mar 2002 13:44:11 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib code.py,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv11859 Modified Files: code.py Log Message: remove unqualified excepts - catch ImportError when trying to import readline and get rid of string exception fallback when showing syntax errors. see bug 411881 Index: code.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/code.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** code.py 18 Sep 2001 13:33:01 -0000 1.18 --- code.py 25 Mar 2002 21:44:07 -0000 1.19 *************** *** 134,143 **** else: # Stuff in the right filename ! try: ! # Assume SyntaxError is a class exception ! value = SyntaxError(msg, (filename, lineno, offset, line)) ! except: ! # If that failed, assume SyntaxError is a string ! value = msg, (filename, lineno, offset, line) sys.last_value = value list = traceback.format_exception_only(type, value) --- 134,138 ---- else: # Stuff in the right filename ! value = SyntaxError(msg, (filename, lineno, offset, line)) sys.last_value = value list = traceback.format_exception_only(type, value) *************** *** 303,307 **** try: import readline ! except: pass console.interact(banner) --- 298,302 ---- try: import readline ! except ImportError: pass console.interact(banner) From montanaro@users.sourceforge.net Mon Mar 25 22:04:25 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Mon, 25 Mar 2002 14:04:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib code.py,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv19636 Modified Files: code.py Log Message: make default banner match what the real interpreter displays Index: code.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/code.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** code.py 25 Mar 2002 21:44:07 -0000 1.19 --- code.py 25 Mar 2002 22:04:23 -0000 1.20 *************** *** 217,221 **** except AttributeError: sys.ps2 = "... " ! cprt = 'Type "copyright", "credits" or "license" for more information.' if banner is None: self.write("Python %s on %s\n%s\n(%s)\n" % --- 217,221 ---- except AttributeError: sys.ps2 = "... " ! cprt = 'Type "help", "copyright", "credits" or "license" for more information.' if banner is None: self.write("Python %s on %s\n%s\n(%s)\n" % From nnorwitz@users.sourceforge.net Mon Mar 25 22:22:00 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Mon, 25 Mar 2002 14:22:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include Python.h,2.43,2.44 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv24834/Include Modified Files: Python.h Log Message: Add a comment that PyArg_GetInt is deprecated and should not be used Index: Python.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/Python.h,v retrieving revision 2.43 retrieving revision 2.44 diff -C2 -d -r2.43 -r2.44 *** Python.h 25 Mar 2002 20:46:45 -0000 2.43 --- Python.h 25 Mar 2002 22:21:58 -0000 2.44 *************** *** 118,121 **** --- 118,122 ---- #include "abstract.h" + /* PyArg_GetInt is deprecated and should not be used, use PyArg_Parse(). */ #define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a)) From nnorwitz@users.sourceforge.net Mon Mar 25 22:23:55 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Mon, 25 Mar 2002 14:23:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules socketmodule.c,1.211,1.212 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv25411/Modules Modified Files: socketmodule.c Log Message: Remove last occurrance of PyArg_GetInt. It is deprecated, Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.211 retrieving revision 1.212 diff -C2 -d -r1.211 -r1.212 *** socketmodule.c 25 Mar 2002 15:32:01 -0000 1.211 --- socketmodule.c 25 Mar 2002 22:23:53 -0000 1.212 *************** *** 970,974 **** int block; int delay_flag; ! if (!PyArg_GetInt(args, &block)) return NULL; Py_BEGIN_ALLOW_THREADS --- 970,974 ---- int block; int delay_flag; ! if (!PyArg_Parse(args, "i", &block)) return NULL; Py_BEGIN_ALLOW_THREADS From gvanrossum@users.sourceforge.net Tue Mar 26 00:51:58 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Mon, 25 Mar 2002 16:51:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib pickle.py,1.57,1.58 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv1307 Modified Files: pickle.py Log Message: Fix for SF 502085. Don't die when issubclass(t, TypeType) fails. Bugfix candidate (but I think it's too late for 2.2.1). Index: pickle.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** pickle.py 11 Feb 2002 18:12:06 -0000 1.57 --- pickle.py 26 Mar 2002 00:51:56 -0000 1.58 *************** *** 165,169 **** f = self.dispatch[t] except KeyError: ! if issubclass(t, TypeType): self.save_global(object) return --- 165,173 ---- f = self.dispatch[t] except KeyError: ! try: ! issc = issubclass(t, TypeType) ! except TypeError: # t is not a class ! issc = 0 ! if issc: self.save_global(object) return From mwh@users.sourceforge.net Tue Mar 26 09:57:16 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 26 Mar 2002 01:57:16 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib pickle.py,1.56,1.56.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv19064 Modified Files: Tag: release22-maint pickle.py Log Message: It made it. backport gvanrossum's checkin of revision 1.58 of pickle.py Fix for SF 502085. Don't die when issubclass(t, TypeType) fails. Bugfix candidate (but I think it's too late for 2.2.1). Index: pickle.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v retrieving revision 1.56 retrieving revision 1.56.4.1 diff -C2 -d -r1.56 -r1.56.4.1 *** pickle.py 19 Dec 2001 16:55:02 -0000 1.56 --- pickle.py 26 Mar 2002 09:57:13 -0000 1.56.4.1 *************** *** 164,168 **** f = self.dispatch[t] except KeyError: ! if issubclass(t, TypeType): self.save_global(object) return --- 164,172 ---- f = self.dispatch[t] except KeyError: ! try: ! issc = issubclass(t, TypeType) ! except TypeError: # t is not a class ! issc = 0 ! if issc: self.save_global(object) return From mwh@users.sourceforge.net Tue Mar 26 10:22:11 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 26 Mar 2002 02:22:11 -0800 Subject: [Python-checkins] CVS: python/dist/src LICENSE,1.18.16.1,1.18.16.2 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv25508 Modified Files: Tag: release22-maint LICENSE Log Message: Make license refer to 2.2.1 Index: LICENSE =================================================================== RCS file: /cvsroot/python/python/dist/src/LICENSE,v retrieving revision 1.18.16.1 retrieving revision 1.18.16.2 diff -C2 -d -r1.18.16.1 -r1.18.16.2 *** LICENSE 27 Feb 2002 13:33:29 -0000 1.18.16.1 --- LICENSE 26 Mar 2002 10:22:09 -0000 1.18.16.2 *************** *** 54,63 **** =============================================================== ! PSF LICENSE AGREEMENT FOR PYTHON 2.2 ! ------------------------------------ 1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"), and the Individual or Organization ("Licensee") accessing and ! otherwise using Python 2.2 software in source or binary form and its associated documentation. --- 54,63 ---- =============================================================== ! PSF LICENSE AGREEMENT FOR PYTHON 2.2.1 ! -------------------------------------- 1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"), and the Individual or Organization ("Licensee") accessing and ! otherwise using Python 2.2.1 software in source or binary form and its associated documentation. *************** *** 65,91 **** hereby grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, analyze, test, perform and/or display publicly, ! prepare derivative works, distribute, and otherwise use Python 2.2 alone or in any derivative version, provided, however, that PSF's License Agreement and PSF's notice of copyright, i.e., "Copyright (c) 2001, 2002 Python Software Foundation; All Rights Reserved" are ! retained in Python 2.2 alone or in any derivative version prepared by ! Licensee. 3. In the event Licensee prepares a derivative work that is based on ! or incorporates Python 2.2 or any part thereof, and wants to make the derivative work available to others as provided herein, then Licensee hereby agrees to include in any such work a brief summary of ! the changes made to Python 2.2. ! 4. PSF is making Python 2.2 available to Licensee on an "AS IS" basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS ! FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 2.2 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS. 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON ! 2.2 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS ! A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.2, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. --- 65,91 ---- hereby grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, analyze, test, perform and/or display publicly, ! prepare derivative works, distribute, and otherwise use Python 2.2.1 alone or in any derivative version, provided, however, that PSF's License Agreement and PSF's notice of copyright, i.e., "Copyright (c) 2001, 2002 Python Software Foundation; All Rights Reserved" are ! retained in Python 2.2.1 alone or in any derivative version prepared ! by Licensee. 3. In the event Licensee prepares a derivative work that is based on ! or incorporates Python 2.2.1 or any part thereof, and wants to make the derivative work available to others as provided herein, then Licensee hereby agrees to include in any such work a brief summary of ! the changes made to Python 2.2.1. ! 4. PSF is making Python 2.2.1 available to Licensee on an "AS IS" basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS ! FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 2.2.1 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS. 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON ! 2.2.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS ! A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.2.1, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. *************** *** 99,103 **** products or services of Licensee, or any third party. ! 8. By copying, installing or otherwise using Python 2.2, Licensee agrees to be bound by the terms and conditions of this License Agreement. --- 99,103 ---- products or services of Licensee, or any third party. ! 8. By copying, installing or otherwise using Python 2.2.1, Licensee agrees to be bound by the terms and conditions of this License Agreement. From mwh@users.sourceforge.net Tue Mar 26 10:31:38 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 26 Mar 2002 02:31:38 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.337.2.4.2.9,1.337.2.4.2.10 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv28401/Misc Modified Files: Tag: release22-maint NEWS Log Message: A stab at NEWS. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.337.2.4.2.9 retrieving revision 1.337.2.4.2.10 diff -C2 -d -r1.337.2.4.2.9 -r1.337.2.4.2.10 *** NEWS 22 Mar 2002 16:41:18 -0000 1.337.2.4.2.9 --- NEWS 26 Mar 2002 10:31:36 -0000 1.337.2.4.2.10 *************** *** 1,9 **** What's New in Python 2.2.1c2? ! Release date: ??? ============================= Core and builtins ! Extension modules Library --- 1,12 ---- What's New in Python 2.2.1c2? ! Release date: 26-Mar-2002 ============================= + There were a bunch of mostly minor fixes between 2.2.1c1 and 2.2.1c2, + including: + Core and builtins ! - The floating point behavoiur fix-up continued into complex_pow. Library *************** *** 13,17 **** attachment. ! Tools --- 16,29 ---- attachment. ! - Support for https: urls in httplib was broken (by the sendall patch ! mentioned below). ! ! - Minor bugs in the calendar module were fixed. ! ! - A few minor bugs in pydoc were fixed (better url recognition, proper ! quoting of some elements). ! ! - Some distutils commands didn't list all their "boolean options" ! which made overriding them from .cfg files not work. From montanaro@users.sourceforge.net Tue Mar 26 11:39:29 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Tue, 26 Mar 2002 03:39:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/scripts reindent.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/scripts In directory usw-pr-cvs1:/tmp/cvs-serv12414 Modified Files: reindent.py Log Message: operate as a filter when no files or directories appear on the command line Index: reindent.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/reindent.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** reindent.py 17 Feb 2002 07:03:05 -0000 1.3 --- reindent.py 26 Mar 2002 11:39:26 -0000 1.4 *************** *** 3,7 **** # Released to the public domain, by Tim Peters, 03 October 2000. ! """reindent [-d][-r][-v] path ... -d Dry run. Analyze, but don't make any changes to, files. --- 3,7 ---- # Released to the public domain, by Tim Peters, 03 October 2000. ! """reindent [-d][-r][-v] [ path ... ] -d Dry run. Analyze, but don't make any changes to, files. *************** *** 13,24 **** at the end of files. Also ensure the last line ends with a newline. ! Pass one or more file and/or directory paths. When a directory path, all ! .py files within the directory will be examined, and, if the -r option is ! given, likewise recursively for subdirectories. ! Overwrites files in place, renaming the originals with a .bak extension. ! If reindent finds nothing to change, the file is left alone. If reindent ! does change a file, the changed file is a fixed-point for reindent (i.e., ! running reindent on the resulting .py file won't change it again). The hard part of reindenting is figuring out what to do with comment --- 13,30 ---- at the end of files. Also ensure the last line ends with a newline. ! If no paths are given on the command line, reindent operates as a filter, ! reading a single source file from standard input and writing the transformed ! source to standard output. In this case, the -d, -r and -v flags are ! ignored. ! You can pass one or more file and/or directory paths. When a directory ! path, all .py files within the directory will be examined, and, if the -r ! option is given, likewise recursively for subdirectories. ! ! If output is not to standard output, reindent overwrites files in place, ! renaming the originals with a .bak extension. If it finds nothing to ! change, the file is left alone. If reindent does change a file, the changed ! file is a fixed-point for future runs (i.e., running reindent on the ! resulting .py file won't change it again). The hard part of reindenting is figuring out what to do with comment *************** *** 60,64 **** verbose += 1 if not args: ! errprint("Usage:", __doc__) return for arg in args: --- 66,72 ---- verbose += 1 if not args: ! r = Reindenter(sys.stdin) ! r.run() ! r.write(sys.stdout) return for arg in args: From mwh@users.sourceforge.net Tue Mar 26 11:51:48 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 26 Mar 2002 03:51:48 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.337.2.4.2.10,1.337.2.4.2.11 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv15173/Misc Modified Files: Tag: release22-maint NEWS Log Message: Add another line. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.337.2.4.2.10 retrieving revision 1.337.2.4.2.11 diff -C2 -d -r1.337.2.4.2.10 -r1.337.2.4.2.11 *** NEWS 26 Mar 2002 10:31:36 -0000 1.337.2.4.2.10 --- NEWS 26 Mar 2002 11:51:46 -0000 1.337.2.4.2.11 *************** *** 6,9 **** --- 6,11 ---- including: + - I remembered to run autoconf before cutting the release tarball. + Core and builtins From jvr@users.sourceforge.net Tue Mar 26 12:06:14 2002 From: jvr@users.sourceforge.net (Just van Rossum) Date: Tue, 26 Mar 2002 04:06:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Tools/IDE Wlists.py,1.11,1.12 PyBrowser.py,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory usw-pr-cvs1:/tmp/cvs-serv18549 Modified Files: Wlists.py PyBrowser.py Log Message: Make object browser work in OSX (by rewriting the old browser LDEF in Python). If at all possible, this should go into 2.2.1. Index: Wlists.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/Wlists.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Wlists.py 31 Dec 2001 14:53:05 -0000 1.11 --- Wlists.py 26 Mar 2002 12:06:11 -0000 1.12 *************** *** 44,47 **** --- 44,48 ---- rect = self._bounds rect = rect[0]+1, rect[1]+1, rect[2]-16, rect[3]-1 + self._viewbounds = rect self._list = LNew(rect, (0, 0, self._cols, 0), (0, 0), self.LDEF_ID, self._parentwindow.wid, 0, 1, 0, 1) *************** *** 68,71 **** --- 69,74 ---- width = r - l - 17 height = b - t - 2 + vl, vt, vr, vb = self._viewbounds + self._viewbounds = vl, vt, vl + width, vt + height self._list.LSize(width, height) # now *why* doesn't the list manager recalc the cellrect??? *************** *** 384,387 **** --- 387,391 ---- rect = self._bounds rect = rect[0]+1, rect[1]+1, rect[2]-16, rect[3]-1 + self._viewbounds = rect self._list = CreateCustomList( rect, Index: PyBrowser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PyBrowser.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PyBrowser.py 31 Dec 2001 15:08:04 -0000 1.14 --- PyBrowser.py 26 Mar 2002 12:06:11 -0000 1.15 *************** *** 5,8 **** --- 5,12 ---- import types import re + from Carbon import Qd, Icn, Fm, QuickDraw + from Carbon.List import GetListPort + from Carbon.QuickDraw import hilitetransfermode + nullid = '\0\0' *************** *** 45,51 **** ! class BrowserWidget(W.List): ! LDEF_ID = 471 def __init__(self, possize, object = None, col = 100, closechildren = 0): --- 49,108 ---- ! def truncString(s, maxwid): ! if maxwid < 1: ! return 1, "" ! strlen = len(s) ! strwid = Qd.TextWidth(s, 0, strlen); ! if strwid <= maxwid: ! return 0, s ! Qd.TextFace(QuickDraw.condense) ! strwid = Qd.TextWidth(s, 0, strlen) ! ellipsis = Qd.StringWidth('\xc9') ! ! if strwid <= maxwid: ! Qd.TextFace(0) ! return 1, s ! if strwid < 1: ! Qd.TextFace(0) ! return 1, "" ! ! mid = int(strlen * maxwid / strwid) ! while 1: ! if mid <= 0: ! mid = 0 ! break ! strwid = Qd.TextWidth(s, 0, mid) + ellipsis ! strwid2 = Qd.TextWidth(s, 0, mid + 1) + ellipsis ! if strwid <= maxwid and maxwid <= strwid2: ! if maxwid == strwid2: ! mid += 1 ! break ! if strwid > maxwid: ! mid -= 1 ! if mid <= 0: ! mid = 0 ! break ! elif strwid2 < maxwid: ! mid += 1 ! Qd.TextFace(0) ! return 1, s[:mid] + '\xc9' ! ! ! def drawTextCell(text, cellRect, ascent, theList): ! l, t, r, b = cellRect ! cellwidth = r - l ! Qd.MoveTo(l + 2, t + ascent) ! condense, text = truncString(text, cellwidth - 3) ! if condense: ! Qd.TextFace(QuickDraw.condense) ! Qd.DrawText(text, 0, len(text)) ! Qd.TextFace(0) ! ! ! PICTWIDTH = 16 ! ! ! class BrowserWidget(W.CustomList): def __init__(self, possize, object = None, col = 100, closechildren = 0): *************** *** 299,302 **** --- 356,442 ---- sc = Scrap.GetCurrentScrap() sc.PutScrapFlavor('TEXT', 0, text) + + def listDefDraw(self, selected, cellRect, theCell, + dataOffset, dataLen, theList): + self.myDrawCell(0, selected, cellRect, theCell, + dataOffset, dataLen, theList) + + def listDefHighlight(self, selected, cellRect, theCell, + dataOffset, dataLen, theList): + self.myDrawCell(1, selected, cellRect, theCell, + dataOffset, dataLen, theList) + + def myDrawCell(self, onlyHilite, selected, cellRect, theCell, + dataOffset, dataLen, theList): + savedPort = Qd.GetPort() + Qd.SetPort(GetListPort(theList)) + savedClip = Qd.NewRgn() + Qd.GetClip(savedClip) + Qd.ClipRect(cellRect) + savedPenState = Qd.GetPenState() + Qd.PenNormal() + + l, t, r, b = cellRect + + if not onlyHilite: + Qd.EraseRect(cellRect) + + ascent, descent, leading, size, hm = Fm.FontMetrics() + linefeed = ascent + descent + leading + + if dataLen >= 6: + data = theList.LGetCell(dataLen, theCell) + iconId, indent, tab = struct.unpack("hhh", data[:6]) + key, value = data[6:].split("\t", 1) + + if iconId: + theIcon = Icn.GetCIcon(iconId) + rect = (0, 0, 16, 16) + rect = Qd.OffsetRect(rect, l, t) + rect = Qd.OffsetRect(rect, 0, (theList.cellSize[1] - (rect[3] - rect[1])) / 2) + Icn.PlotCIcon(rect, theIcon) + + if len(key) >= 0: + cl, ct, cr, cb = cellRect + vl, vt, vr, vb = self._viewbounds + cl = vl + PICTWIDTH + indent + cr = vl + tab + if cr > vr: + cr = vr + if cl < cr: + drawTextCell(key, (cl, ct, cr, cb), ascent, theList) + cl = vl + tab + cr = vr + if cl < cr: + drawTextCell(value, (cl, ct, cr, cb), ascent, theList) + #elif dataLen != 0: + # drawTextCell("???", 3, cellRect, ascent, theList) + + # draw nice dotted line + l, t, r, b = cellRect + l = self._viewbounds[0] + tab + r = l + 1; + if not (theList.cellSize[1] & 0x01) or (t & 0x01): + myPat = "\xff\x00\xff\x00\xff\x00\xff\x00" + else: + myPat = "\x00\xff\x00\xff\x00\xff\x00\xff" + Qd.PenPat(myPat) + Qd.PenMode(QuickDraw.srcCopy) + Qd.PaintRect((l, t, r, b)) + Qd.PenNormal() + + if selected or onlyHilite: + l, t, r, b = cellRect + l = self._viewbounds[0] + PICTWIDTH + r = self._viewbounds[2] + Qd.PenMode(hilitetransfermode) + Qd.PaintRect((l, t, r, b)) + + # restore graphics environment + Qd.SetPort(savedPort) + Qd.SetClip(savedClip) + Qd.DisposeRgn(savedClip) + Qd.SetPenState(savedPenState) + From mwh@users.sourceforge.net Tue Mar 26 12:21:26 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 26 Mar 2002 04:21:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc ACKS,1.149.4.5,1.149.4.6 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv22489 Modified Files: Tag: release22-maint ACKS Log Message: People who tested 2.2.1c1. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.149.4.5 retrieving revision 1.149.4.6 diff -C2 -d -r1.149.4.5 -r1.149.4.6 *** ACKS 5 Mar 2002 15:37:46 -0000 1.149.4.5 --- ACKS 26 Mar 2002 12:21:23 -0000 1.149.4.6 *************** *** 223,226 **** --- 223,227 ---- Bill Janssen Drew Jenkins + Flemming Kjær Jensen Orjan Johansen Simon Johnston *************** *** 260,263 **** --- 261,265 ---- William Lewis Robert van Liere + Martin Ligr Christopher Lindblad Eric Lindvall *************** *** 313,316 **** --- 315,319 ---- Max Neunhöffer George Neville-Neil + Gustavo Niemeyer Oscar Nierstrasz Hrvoje Niksic *************** *** 330,333 **** --- 333,337 ---- Harri Pasanen Randy Pausch + Mark Perrego Marcel van der Peijl Samuele Pedroni *************** *** 473,476 **** --- 477,481 ---- Frank Willison Greg V. Wilson + Jody Winston Dik Winter Blake Winton From jackjansen@users.sourceforge.net Tue Mar 26 12:34:51 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 26 Mar 2002 04:34:51 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/OSX sample_sitecustomize.py,NONE,1.1.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory usw-pr-cvs1:/tmp/cvs-serv25694 Added Files: Tag: release22-maint sample_sitecustomize.py Log Message: File was missing from 2.2.1 subtree. --- NEW FILE: sample_sitecustomize.py --- import sys import os _maclib = os.path.join(sys.prefix, 'Mac/Lib') sys.path.append(_maclib) From jackjansen@users.sourceforge.net Tue Mar 26 12:49:26 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 26 Mar 2002 04:49:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Tools/IDE Wlists.py,1.10.6.1,1.10.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory usw-pr-cvs1:/tmp/cvs-serv30962 Modified Files: Tag: release22-maint Wlists.py Log Message: Backport of 1.12: Make object browser work in OSX (by rewriting the old browser LDEF in Python). If at all possible, this should go into 2.2.1. Index: Wlists.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/Wlists.py,v retrieving revision 1.10.6.1 retrieving revision 1.10.6.2 diff -C2 -d -r1.10.6.1 -r1.10.6.2 *** Wlists.py 27 Feb 2002 22:28:23 -0000 1.10.6.1 --- Wlists.py 26 Mar 2002 12:49:24 -0000 1.10.6.2 *************** *** 44,47 **** --- 44,48 ---- rect = self._bounds rect = rect[0]+1, rect[1]+1, rect[2]-16, rect[3]-1 + self._viewbounds = rect self._list = LNew(rect, (0, 0, self._cols, 0), (0, 0), self.LDEF_ID, self._parentwindow.wid, 0, 1, 0, 1) *************** *** 68,71 **** --- 69,74 ---- width = r - l - 17 height = b - t - 2 + vl, vt, vr, vb = self._viewbounds + self._viewbounds = vl, vt, vl + width, vt + height self._list.LSize(width, height) # now *why* doesn't the list manager recalc the cellrect??? *************** *** 384,387 **** --- 387,391 ---- rect = self._bounds rect = rect[0]+1, rect[1]+1, rect[2]-16, rect[3]-1 + self._viewbounds = rect self._list = CreateCustomList( rect, From jackjansen@users.sourceforge.net Tue Mar 26 12:50:43 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 26 Mar 2002 04:50:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Tools/IDE PyBrowser.py,1.12.6.1,1.12.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory usw-pr-cvs1:/tmp/cvs-serv31216 Modified Files: Tag: release22-maint PyBrowser.py Log Message: Backport of 1.15 and 1.14: Make object browser work in OSX (by rewriting the old browser LDEF in Python). If at all possible, this should go into 2.2.1. Use the Carbon scrap manager interface if the old interface isn't available. Index: PyBrowser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PyBrowser.py,v retrieving revision 1.12.6.1 retrieving revision 1.12.6.2 diff -C2 -d -r1.12.6.1 -r1.12.6.2 *** PyBrowser.py 24 Feb 2002 23:11:34 -0000 1.12.6.1 --- PyBrowser.py 26 Mar 2002 12:50:40 -0000 1.12.6.2 *************** *** 5,8 **** --- 5,12 ---- import types import re + from Carbon import Qd, Icn, Fm, QuickDraw + from Carbon.List import GetListPort + from Carbon.QuickDraw import hilitetransfermode + nullid = '\0\0' *************** *** 45,51 **** ! class BrowserWidget(W.List): ! LDEF_ID = 471 def __init__(self, possize, object = None, col = 100, closechildren = 0): --- 49,108 ---- ! def truncString(s, maxwid): ! if maxwid < 1: ! return 1, "" ! strlen = len(s) ! strwid = Qd.TextWidth(s, 0, strlen); ! if strwid <= maxwid: ! return 0, s ! Qd.TextFace(QuickDraw.condense) ! strwid = Qd.TextWidth(s, 0, strlen) ! ellipsis = Qd.StringWidth('\xc9') ! ! if strwid <= maxwid: ! Qd.TextFace(0) ! return 1, s ! if strwid < 1: ! Qd.TextFace(0) ! return 1, "" ! ! mid = int(strlen * maxwid / strwid) ! while 1: ! if mid <= 0: ! mid = 0 ! break ! strwid = Qd.TextWidth(s, 0, mid) + ellipsis ! strwid2 = Qd.TextWidth(s, 0, mid + 1) + ellipsis ! if strwid <= maxwid and maxwid <= strwid2: ! if maxwid == strwid2: ! mid += 1 ! break ! if strwid > maxwid: ! mid -= 1 ! if mid <= 0: ! mid = 0 ! break ! elif strwid2 < maxwid: ! mid += 1 ! Qd.TextFace(0) ! return 1, s[:mid] + '\xc9' ! ! ! def drawTextCell(text, cellRect, ascent, theList): ! l, t, r, b = cellRect ! cellwidth = r - l ! Qd.MoveTo(l + 2, t + ascent) ! condense, text = truncString(text, cellwidth - 3) ! if condense: ! Qd.TextFace(QuickDraw.condense) ! Qd.DrawText(text, 0, len(text)) ! Qd.TextFace(0) ! ! ! PICTWIDTH = 16 ! ! ! class BrowserWidget(W.CustomList): def __init__(self, possize, object = None, col = 100, closechildren = 0): *************** *** 292,297 **** if text: from Carbon import Scrap ! Scrap.ZeroScrap() ! Scrap.PutScrap('TEXT', text) --- 349,442 ---- if text: from Carbon import Scrap ! if hasattr(Scrap, 'PutScrap'): ! Scrap.ZeroScrap() ! Scrap.PutScrap('TEXT', text) ! else: ! Scrap.ClearCurrentScrap() ! sc = Scrap.GetCurrentScrap() ! sc.PutScrapFlavor('TEXT', 0, text) ! ! def listDefDraw(self, selected, cellRect, theCell, ! dataOffset, dataLen, theList): ! self.myDrawCell(0, selected, cellRect, theCell, ! dataOffset, dataLen, theList) ! ! def listDefHighlight(self, selected, cellRect, theCell, ! dataOffset, dataLen, theList): ! self.myDrawCell(1, selected, cellRect, theCell, ! dataOffset, dataLen, theList) ! ! def myDrawCell(self, onlyHilite, selected, cellRect, theCell, ! dataOffset, dataLen, theList): ! savedPort = Qd.GetPort() ! Qd.SetPort(GetListPort(theList)) ! savedClip = Qd.NewRgn() ! Qd.GetClip(savedClip) ! Qd.ClipRect(cellRect) ! savedPenState = Qd.GetPenState() ! Qd.PenNormal() ! ! l, t, r, b = cellRect ! ! if not onlyHilite: ! Qd.EraseRect(cellRect) ! ! ascent, descent, leading, size, hm = Fm.FontMetrics() ! linefeed = ascent + descent + leading ! ! if dataLen >= 6: ! data = theList.LGetCell(dataLen, theCell) ! iconId, indent, tab = struct.unpack("hhh", data[:6]) ! key, value = data[6:].split("\t", 1) ! ! if iconId: ! theIcon = Icn.GetCIcon(iconId) ! rect = (0, 0, 16, 16) ! rect = Qd.OffsetRect(rect, l, t) ! rect = Qd.OffsetRect(rect, 0, (theList.cellSize[1] - (rect[3] - rect[1])) / 2) ! Icn.PlotCIcon(rect, theIcon) ! ! if len(key) >= 0: ! cl, ct, cr, cb = cellRect ! vl, vt, vr, vb = self._viewbounds ! cl = vl + PICTWIDTH + indent ! cr = vl + tab ! if cr > vr: ! cr = vr ! if cl < cr: ! drawTextCell(key, (cl, ct, cr, cb), ascent, theList) ! cl = vl + tab ! cr = vr ! if cl < cr: ! drawTextCell(value, (cl, ct, cr, cb), ascent, theList) ! #elif dataLen != 0: ! # drawTextCell("???", 3, cellRect, ascent, theList) ! ! # draw nice dotted line ! l, t, r, b = cellRect ! l = self._viewbounds[0] + tab ! r = l + 1; ! if not (theList.cellSize[1] & 0x01) or (t & 0x01): ! myPat = "\xff\x00\xff\x00\xff\x00\xff\x00" ! else: ! myPat = "\x00\xff\x00\xff\x00\xff\x00\xff" ! Qd.PenPat(myPat) ! Qd.PenMode(QuickDraw.srcCopy) ! Qd.PaintRect((l, t, r, b)) ! Qd.PenNormal() ! ! if selected or onlyHilite: ! l, t, r, b = cellRect ! l = self._viewbounds[0] + PICTWIDTH ! r = self._viewbounds[2] ! Qd.PenMode(hilitetransfermode) ! Qd.PaintRect((l, t, r, b)) ! ! # restore graphics environment ! Qd.SetPort(savedPort) ! Qd.SetClip(savedClip) ! Qd.DisposeRgn(savedClip) ! Qd.SetPenState(savedPenState) ! From mwh@users.sourceforge.net Tue Mar 26 13:22:25 2002 From: mwh@users.sourceforge.net (Michael Hudson) Date: Tue, 26 Mar 2002 05:22:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.337.2.4.2.11,1.337.2.4.2.12 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv7986 Modified Files: Tag: release22-maint NEWS Log Message: Detlef Lannert noticed that I can't type. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.337.2.4.2.11 retrieving revision 1.337.2.4.2.12 diff -C2 -d -r1.337.2.4.2.11 -r1.337.2.4.2.12 *** NEWS 26 Mar 2002 11:51:46 -0000 1.337.2.4.2.11 --- NEWS 26 Mar 2002 13:22:23 -0000 1.337.2.4.2.12 *************** *** 10,14 **** Core and builtins ! - The floating point behavoiur fix-up continued into complex_pow. Library --- 10,14 ---- Core and builtins ! - The floating point behavior fix-up continued into complex_pow. Library From fdrake@acm.org Tue Mar 26 13:24:26 2002 From: fdrake@acm.org (Fred L. Drake, Jr.) Date: Tue, 26 Mar 2002 08:24:26 -0500 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.337.2.4.2.11,1.337.2.4.2.12 In-Reply-To: References: Message-ID: <15520.30346.255974.242361@grendel.zope.com> Michael Hudson writes: > Detlef Lannert noticed that I can't type. Don't worry; he does that to me too. I guess that's why we pay him the big bucks: He gets *two* free downloads of Python instead of the one we allow release managers. ;-) -Fred -- Fred L. Drake, Jr. PythonLabs at Zope Corporation From jackjansen@users.sourceforge.net Tue Mar 26 13:43:07 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 26 Mar 2002 05:43:07 -0800 Subject: [Python-checkins] CVS: python/dist/src setup.py,1.73.4.3,1.73.4.4 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv14006 Modified Files: Tag: release22-maint setup.py Log Message: Build MacOSX _Scrap module. IDE now works under MachoPython! (Checked in after conferring with Michael). Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.73.4.3 retrieving revision 1.73.4.4 diff -C2 -d -r1.73.4.3 -r1.73.4.4 *** setup.py 25 Mar 2002 13:59:28 -0000 1.73.4.3 --- setup.py 26 Mar 2002 13:43:04 -0000 1.73.4.4 *************** *** 647,651 **** extra_link_args=['-framework', 'QuickTime', '-framework', 'Carbon']) ) ! ## exts.append( Extension('_Scrap', ['scrap/_Scrapmodule.c']) ) exts.append( Extension('_TE', ['te/_TEmodule.c'], extra_link_args=['-framework', 'Carbon']) ) --- 647,652 ---- extra_link_args=['-framework', 'QuickTime', '-framework', 'Carbon']) ) ! exts.append( Extension('_Scrap', ['scrap/_Scrapmodule.c'], ! extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_TE', ['te/_TEmodule.c'], extra_link_args=['-framework', 'Carbon']) ) From jackjansen@users.sourceforge.net Tue Mar 26 13:47:18 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 26 Mar 2002 05:47:18 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac Relnotes,1.28.4.2.2.2,1.28.4.2.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Mac In directory usw-pr-cvs1:/tmp/cvs-serv15573 Modified Files: Tag: release22-maint Relnotes Log Message: Ready for 2.2c2. Index: Relnotes =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Relnotes,v retrieving revision 1.28.4.2.2.2 retrieving revision 1.28.4.2.2.3 diff -C2 -d -r1.28.4.2.2.2 -r1.28.4.2.2.3 *** Relnotes 18 Mar 2002 10:44:49 -0000 1.28.4.2.2.2 --- Relnotes 26 Mar 2002 13:47:16 -0000 1.28.4.2.2.3 *************** *** 13,16 **** --- 13,17 ---- other tests continue. - The IDE looks better under OSX after redesign of some windows. + - The IDE class browser and object browser now work under OSX. - The IDE browser now has some understanding of the 2.2 object model. - IDE readline() output is echoed to the output window. *************** *** 25,28 **** --- 26,32 ---- - macfs.FSRef objects now have an as_pathname method. - The ic module returned bogus values for creator/type. Fixed. + - Most toolbox modules now weaklink against InterfaceLib (or CarbonLib) so + they can be imported even if not all functionality is available. Calling a + method missing on your system will raise an exception. - Carbon.App: support for various missing methods added. - Carbon.CarbonEvt: various method signatures fixed. *************** *** 63,67 **** - Tkinter file events do not work, unless you have opened the file through Tcl (but then you cannot access it from Python). - - The IDE object and class browser look funny on OSX, but they work fine. - Aliases may not work in sys.path entries. - PythonInterpreter used interactively will eat a lot of processor cycles. You should use --- 67,70 ---- From nnorwitz@users.sourceforge.net Tue Mar 26 14:52:02 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Tue, 26 Mar 2002 06:52:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules threadmodule.c,2.46,2.47 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv4410/Modules Modified Files: threadmodule.c Log Message: Missed change METH_OLDARGS to METH_NOARGS for two aliased functions Index: threadmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/threadmodule.c,v retrieving revision 2.46 retrieving revision 2.47 diff -C2 -d -r2.46 -r2.47 *** threadmodule.c 25 Mar 2002 21:05:50 -0000 2.46 --- threadmodule.c 26 Mar 2002 14:52:00 -0000 2.47 *************** *** 332,340 **** METH_NOARGS, allocate_doc}, {"allocate", (PyCFunction)thread_PyThread_allocate_lock, ! METH_OLDARGS, allocate_doc}, {"exit_thread", (PyCFunction)thread_PyThread_exit_thread, METH_NOARGS, exit_doc}, {"exit", (PyCFunction)thread_PyThread_exit_thread, ! METH_OLDARGS, exit_doc}, {"get_ident", (PyCFunction)thread_get_ident, METH_NOARGS, get_ident_doc}, --- 332,340 ---- METH_NOARGS, allocate_doc}, {"allocate", (PyCFunction)thread_PyThread_allocate_lock, ! METH_NOARGS, allocate_doc}, {"exit_thread", (PyCFunction)thread_PyThread_exit_thread, METH_NOARGS, exit_doc}, {"exit", (PyCFunction)thread_PyThread_exit_thread, ! METH_NOARGS, exit_doc}, {"get_ident", (PyCFunction)thread_get_ident, METH_NOARGS, get_ident_doc}, From nnorwitz@users.sourceforge.net Tue Mar 26 16:20:28 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Tue, 26 Mar 2002 08:20:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib tokenize.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv32358/Lib Modified Files: tokenize.py Log Message: Cleanup x so it is not left in module Index: tokenize.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tokenize.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** tokenize.py 30 Aug 2001 20:51:58 -0000 1.28 --- tokenize.py 26 Mar 2002 16:20:26 -0000 1.29 *************** *** 34,37 **** --- 34,38 ---- import token __all__ = [x for x in dir(token) if x[0] != '_'] + ["COMMENT", "tokenize", "NL"] + del x del token From nnorwitz@users.sourceforge.net Tue Mar 26 16:21:55 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Tue, 26 Mar 2002 08:21:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib mimetools.py,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv315/Lib Modified Files: mimetools.py Log Message: os was already imported in the module, no need to re-import Index: mimetools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mimetools.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** mimetools.py 23 Mar 2002 05:58:52 -0000 1.24 --- mimetools.py 26 Mar 2002 16:21:52 -0000 1.25 *************** *** 113,117 **** if _prefix is None: import socket - import os hostid = socket.gethostbyname(socket.gethostname()) try: --- 113,116 ---- From nnorwitz@users.sourceforge.net Tue Mar 26 16:23:31 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Tue, 26 Mar 2002 08:23:31 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib xmlrpclib.py,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv820/Lib Modified Files: xmlrpclib.py Log Message: re was already imported in the module, no need to re-import Index: xmlrpclib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmlrpclib.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** xmlrpclib.py 19 Dec 2001 21:40:04 -0000 1.15 --- xmlrpclib.py 26 Mar 2002 16:23:28 -0000 1.16 *************** *** 354,358 **** def handle_proc(self, tag, attr): - import re m = re.search("encoding\s*=\s*['\"]([^\"']+)[\"']", attr) if m: --- 354,357 ---- From nnorwitz@users.sourceforge.net Tue Mar 26 16:25:04 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Tue, 26 Mar 2002 08:25:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib urllib.py,1.138,1.139 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv1326/Lib Modified Files: urllib.py Log Message: time and socket were already imported in the module, no need to re-import Index: urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.138 retrieving revision 1.139 diff -C2 -d -r1.138 -r1.139 *** urllib.py 22 Mar 2002 17:30:38 -0000 1.138 --- urllib.py 26 Mar 2002 16:25:01 -0000 1.139 *************** *** 497,501 **** # data := *urlchar # parameter := attribute "=" value ! import StringIO, mimetools, time try: [type, data] = url.split(',', 1) --- 497,501 ---- # data := *urlchar # parameter := attribute "=" value ! import StringIO, mimetools try: [type, data] = url.split(',', 1) *************** *** 1308,1312 **** import _winreg import re - import socket except ImportError: # Std modules, so should be around - but you never know! --- 1308,1311 ---- *************** *** 1366,1370 **** # Test and time quote() and unquote() def test1(): - import time s = '' for i in range(256): s = s + chr(i) --- 1365,1368 ---- From fdrake@users.sourceforge.net Tue Mar 26 19:13:11 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 26 Mar 2002 11:13:11 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/whatsnew - New directory Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv20647/whatsnew Log Message: Directory /cvsroot/python/python/dist/src/Doc/whatsnew added to the repository From fdrake@users.sourceforge.net Tue Mar 26 19:14:43 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 26 Mar 2002 11:14:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/texinputs python.sty,1.90,1.91 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory usw-pr-cvs1:/tmp/cvs-serv21055/texinputs Modified Files: python.sty Log Message: Make \url to force horizontal mode. Index: python.sty =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/python.sty,v retrieving revision 1.90 retrieving revision 1.91 diff -C2 -d -r1.90 -r1.91 *** python.sty 16 Mar 2002 04:52:36 -0000 1.90 --- python.sty 26 Mar 2002 19:14:41 -0000 1.91 *************** *** 797,800 **** --- 797,801 ---- \ifpdf \newcommand{\url}[1]{{% + \noindent% \pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}% \py@LinkColor% color of the link text From fdrake@users.sourceforge.net Tue Mar 26 19:17:45 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 26 Mar 2002 11:17:45 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/whatsnew whatsnew23.tex,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv21785/whatsnew Added Files: whatsnew23.tex Log Message: Add a starter for the next "What's New" document. --- NEW FILE: whatsnew23.tex --- \documentclass{howto} \title{What's New in Python 2.3} % We'll let Andrew claim ownership when he's ready. ;-) %\author{A.M. Kuchling} %\authoraddress{\email{akuchlin@mems-exchange.org}} \begin{document} \maketitle \tableofcontents \section{Introduction \label{intro}} %====================================================================== \section{Acknowledgements \label{acks}} \end{document} From fdrake@users.sourceforge.net Tue Mar 26 19:18:20 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 26 Mar 2002 11:18:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc Makefile,1.237,1.238 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory usw-pr-cvs1:/tmp/cvs-serv21951 Modified Files: Makefile Log Message: Wire in the "What's New" document. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile,v retrieving revision 1.237 retrieving revision 1.238 diff -C2 -d -r1.237 -r1.238 *** Makefile 4 Feb 2002 19:49:29 -0000 1.237 --- Makefile 26 Mar 2002 19:18:18 -0000 1.238 *************** *** 89,92 **** --- 89,94 ---- HTMLBASE= file:`pwd` + WHATSNEW=whatsnew23 + # what's what MANDVIFILES= paper-$(PAPER)/api.dvi paper-$(PAPER)/ext.dvi \ *************** *** 94,98 **** paper-$(PAPER)/ref.dvi paper-$(PAPER)/tut.dvi HOWTODVIFILES= paper-$(PAPER)/doc.dvi paper-$(PAPER)/inst.dvi \ ! paper-$(PAPER)/dist.dvi MANPDFFILES= paper-$(PAPER)/api.pdf paper-$(PAPER)/ext.pdf \ --- 96,100 ---- paper-$(PAPER)/ref.dvi paper-$(PAPER)/tut.dvi HOWTODVIFILES= paper-$(PAPER)/doc.dvi paper-$(PAPER)/inst.dvi \ ! paper-$(PAPER)/dist.dvi paper-$(PAPER)/$(WHATSNEW).dvi MANPDFFILES= paper-$(PAPER)/api.pdf paper-$(PAPER)/ext.pdf \ *************** *** 100,104 **** paper-$(PAPER)/ref.pdf paper-$(PAPER)/tut.pdf HOWTOPDFFILES= paper-$(PAPER)/doc.pdf paper-$(PAPER)/inst.pdf \ ! paper-$(PAPER)/dist.pdf MANPSFILES= paper-$(PAPER)/api.ps paper-$(PAPER)/ext.ps \ --- 102,106 ---- paper-$(PAPER)/ref.pdf paper-$(PAPER)/tut.pdf HOWTOPDFFILES= paper-$(PAPER)/doc.pdf paper-$(PAPER)/inst.pdf \ ! paper-$(PAPER)/dist.pdf paper-$(PAPER)/$(WHATSNEW).pdf MANPSFILES= paper-$(PAPER)/api.ps paper-$(PAPER)/ext.ps \ *************** *** 106,110 **** paper-$(PAPER)/ref.ps paper-$(PAPER)/tut.ps HOWTOPSFILES= paper-$(PAPER)/doc.ps paper-$(PAPER)/inst.ps \ ! paper-$(PAPER)/dist.ps DVIFILES= $(MANDVIFILES) $(HOWTODVIFILES) --- 108,112 ---- paper-$(PAPER)/ref.ps paper-$(PAPER)/tut.ps HOWTOPSFILES= paper-$(PAPER)/doc.ps paper-$(PAPER)/inst.ps \ ! paper-$(PAPER)/dist.ps paper-$(PAPER)/$(WHATSNEW).ps DVIFILES= $(MANDVIFILES) $(HOWTODVIFILES) *************** *** 142,146 **** html/tut/tut.html \ html/inst/inst.html \ ! html/dist/dist.html ALLHTMLFILES=$(INDEXFILES) html/index.html html/modindex.html html/acks.html --- 144,149 ---- html/tut/tut.html \ html/inst/inst.html \ ! html/dist/dist.html \ ! html/whatsnew/$(WHATSNEW).html ALLHTMLFILES=$(INDEXFILES) html/index.html html/modindex.html html/acks.html *************** *** 272,275 **** --- 275,285 ---- cd paper-$(PAPER) && $(MKPDF) ../tut/tut.tex + # What's New in Python X.Y + paper-$(PAPER)/$(WHATSNEW).dvi: + cd paper-$(PAPER) && $(MKDVI) ../whatsnew/$(WHATSNEW).tex + + paper-$(PAPER)/$(WHATSNEW).pdf: + cd paper-$(PAPER) && $(MKPDF) ../whatsnew/$(WHATSNEW).tex + # The remaining part of the Makefile is concerned with various # conversions, as described above. See also the README file. *************** *** 360,363 **** --- 370,377 ---- $(MKHTML) --dir html/dist --split 4 dist/dist.tex + whatsnew: html/whatsnew/$(WHATSNEW).html + html/whatsnew/$(WHATSNEW).html: whatsnew/$(WHATSNEW).tex + $(MKHTML) --dir html/whatsnew --split 4 whatsnew/$(WHATSNEW).tex + # The iSilo format is used by the iSilo document reader for PalmOS devices. *************** *** 447,450 **** --- 461,467 ---- isilo/dist/dist.html: $(DISTFILES) perl/distutils.perl $(MKISILOHTML) --dir isilo/dist dist/dist.tex + + isilo/whatsnew/$(WHATSNEW).html: whatsnew/$(WHATSNEW).tex + $(MKISILOHTML) --dir isilo/whatsnew whatsnew/$(WHATSNEW).tex # These are useful if you need to transport the iSilo-ready HTML to From fdrake@users.sourceforge.net Tue Mar 26 19:53:59 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 26 Mar 2002 11:53:59 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc Makefile,1.238,1.239 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory usw-pr-cvs1:/tmp/cvs-serv31860 Modified Files: Makefile Log Message: Wire up the makefile to more fully support the "What's New" documents. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile,v retrieving revision 1.238 retrieving revision 1.239 diff -C2 -d -r1.238 -r1.239 *** Makefile 26 Mar 2002 19:18:18 -0000 1.238 --- Makefile 26 Mar 2002 19:53:56 -0000 1.239 *************** *** 89,92 **** --- 89,94 ---- HTMLBASE= file:`pwd` + # The end of this should reflect the major/minor version numbers of + # the release: WHATSNEW=whatsnew23 *************** *** 385,389 **** isilo/tut/tut.html \ isilo/inst/inst.html \ ! isilo/dist/dist.html $(ISILOINDEXFILES): $(COMMONPERL) html/about.dat perl/isilo.perl --- 387,392 ---- isilo/tut/tut.html \ isilo/inst/inst.html \ ! isilo/dist/dist.html \ ! isilo/whatsnew/$(WHATSNEW).html $(ISILOINDEXFILES): $(COMMONPERL) html/about.dat perl/isilo.perl *************** *** 397,401 **** isilo/python-tut-$(RELEASE).pdb \ isilo/python-dist-$(RELEASE).pdb \ ! isilo/python-inst-$(RELEASE).pdb isilo/python-api-$(RELEASE).pdb: isilo/api/api.html isilo/api/api.css --- 400,405 ---- isilo/python-tut-$(RELEASE).pdb \ isilo/python-dist-$(RELEASE).pdb \ ! isilo/python-inst-$(RELEASE).pdb \ ! isilo/python-whatsnew-$(RELEASE).pdb isilo/python-api-$(RELEASE).pdb: isilo/api/api.html isilo/api/api.css *************** *** 435,438 **** --- 439,446 ---- isilo/inst/inst.html $@ + isilo/python-whatsnew-$(RELEASE).pdb: isilo/whatsnew/$(WHATSNEW).html isilo/whatsnew/$(WHATSNEW).css + $(MKISILO) "-iWhat's New in Python X.Y" \ + isilo/whatsnew/$(WHATSNEW).html $@ + isilo/api/api.html: $(APIFILES) $(MKISILOHTML) --dir isilo/api api/api.tex *************** *** 490,493 **** --- 498,502 ---- $(WEBCHECKER) $(HTMLBASE)/dist/ $(WEBCHECKER) $(HTMLBASE)/inst/ + $(WEBCHECKER) $(HTMLBASE)/whatsnew/ fastwebcheck: $(ALLHTMLFILES) *************** *** 501,504 **** --- 510,514 ---- $(WEBCHECKER) -x $(HTMLBASE)/dist/ $(WEBCHECKER) -x $(HTMLBASE)/inst/ + $(WEBCHECKER) -x $(HTMLBASE)/whatsnew/ *************** *** 634,639 **** --- 644,651 ---- rm -rf html/api/ html/doc/ html/ext/ html/lib/ html/mac/ rm -rf html/ref/ html/tut/ html/inst/ html/dist/ + rm -rf html/whatsnew/ rm -rf isilo/api/ isilo/doc/ isilo/ext/ isilo/lib/ isilo/mac/ rm -rf isilo/ref/ isilo/tut/ isilo/inst/ isilo/dist/ + rm -rf isilo/whatsnew/ rm -f isilo/python-*-$(RELEASE).pdb isilo-$(RELEASE).zip From fdrake@users.sourceforge.net Tue Mar 26 19:57:55 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 26 Mar 2002 11:57:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/perl l2hinit.perl,1.59,1.60 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/perl In directory usw-pr-cvs1:/tmp/cvs-serv455/perl Modified Files: l2hinit.perl Log Message: The to the stylesheet should include the type attribute. Index: l2hinit.perl =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/perl/l2hinit.perl,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** l2hinit.perl 22 Mar 2002 17:22:38 -0000 1.59 --- l2hinit.perl 26 Mar 2002 19:57:52 -0000 1.60 *************** *** 617,621 **** : ''), ($BASE ? "\n" : ''), ! "\n", "\n", ($HAVE_TABLE_OF_CONTENTS --- 617,621 ---- : ''), ($BASE ? "\n" : ''), ! "\n", "\n", ($HAVE_TABLE_OF_CONTENTS From bwarsaw@users.sourceforge.net Tue Mar 26 20:27:38 2002 From: bwarsaw@users.sourceforge.net (Barry Warsaw) Date: Tue, 26 Mar 2002 12:27:38 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib smtplib.py,1.50,1.51 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv9439/Lib Modified Files: smtplib.py Log Message: __init__(): We'll try to be more RFC 2821 compliant by providing for a better local_hostname default. According to RFC 2821, it is recommended that the fqdn hostname be provided in the EHLO/HELO verb and if that can't be calculated, to use a domain literal. The rationale for this change is documented in SF patch #497736 which also had privacy concerns about leaking the fqdn in the EHLO/HELO. We decided this wasn't a big concern because no user data is leaked, and the IP will always be leaked. The local_hostname argument is provided for those clients that are super paranoid. Using localhost.localdomain may break some strict smtp servers so we decided against using it as the default. Index: smtplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** smtplib.py 25 Mar 2002 04:00:38 -0000 1.50 --- smtplib.py 26 Mar 2002 20:27:35 -0000 1.51 *************** *** 238,244 **** raise SMTPConnectError(code, msg) if local_hostname: ! self.local_hostname = local_hostname else: ! self.local_hostname = socket.getfqdn() def set_debuglevel(self, debuglevel): --- 238,253 ---- raise SMTPConnectError(code, msg) if local_hostname: ! self.local_hostname = local_hostname else: ! # RFC 2821 says we should use the fqdn in the EHLO/HELO verb, and ! # if that can't be calculated, that we should use a domain literal ! # instead (essentially an encoded IP address like [A.B.C.D]). ! fqdn = socket.getfqdn() ! if '.' in fqdn: ! self.local_hostname = fqdn ! else: ! # We can't find an fqdn hostname, so use a domain literal ! addr = socket.gethostbyname(socket.gethostname()) ! self.local_hostname = '[%s]' % addr def set_debuglevel(self, debuglevel): From nascheme@users.sourceforge.net Tue Mar 26 20:28:42 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Tue, 26 Mar 2002 12:28:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib fileinput.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv9764 Modified Files: fileinput.py Log Message: Implement iterator protocol. Index: fileinput.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/fileinput.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** fileinput.py 24 Oct 2001 20:33:34 -0000 1.8 --- fileinput.py 26 Mar 2002 20:28:40 -0000 1.9 *************** *** 167,171 **** self._files = () ! def __getitem__(self, i): try: line = self._buffer[self._bufindex] --- 167,174 ---- self._files = () ! def __iter__(self): ! return self ! ! def next(self): try: line = self._buffer[self._bufindex] *************** *** 177,186 **** self._filelineno += 1 return line - if i != self._lineno: - raise RuntimeError, "accessing lines out of order" line = self.readline() if not line: ! raise IndexError, "end of input reached" return line def nextfile(self): --- 180,195 ---- self._filelineno += 1 return line line = self.readline() if not line: ! raise StopIteration return line + + def __getitem__(self, i): + if i != self._lineno: + raise RuntimeError, "accessing lines out of order" + try: + return self.next() + except StopIteration: + raise IndexError, "end of input reached" def nextfile(self): From fdrake@users.sourceforge.net Tue Mar 26 20:29:13 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 26 Mar 2002 12:29:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc Makefile,1.239,1.240 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory usw-pr-cvs1:/tmp/cvs-serv9937 Modified Files: Makefile Log Message: Add the "What's New" document to the index of HTML documents. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile,v retrieving revision 1.239 retrieving revision 1.240 diff -C2 -d -r1.239 -r1.240 *** Makefile 26 Mar 2002 19:53:56 -0000 1.239 --- Makefile 26 Mar 2002 20:29:10 -0000 1.240 *************** *** 324,328 **** html/index.html: $(INDEXFILES) html/index.html: html/index.html.in $(BOILERPLATE) tools/rewrite.py ! $(PYTHON) tools/rewrite.py $(BOILERPLATE) RELEASE=$(RELEASE) \ <$< >$@ --- 324,329 ---- html/index.html: $(INDEXFILES) html/index.html: html/index.html.in $(BOILERPLATE) tools/rewrite.py ! $(PYTHON) tools/rewrite.py $(BOILERPLATE) \ ! RELEASE=$(RELEASE) WHATSNEW=$(WHATSNEW) \ <$< >$@ From fdrake@users.sourceforge.net Tue Mar 26 20:29:13 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 26 Mar 2002 12:29:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/html index.html.in,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/html In directory usw-pr-cvs1:/tmp/cvs-serv9937/html Modified Files: index.html.in Log Message: Add the "What's New" document to the index of HTML documents. Index: index.html.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/html/index.html.in,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** index.html.in 6 Mar 2001 07:28:20 -0000 1.14 --- index.html.in 26 Mar 2002 20:29:11 -0000 1.15 *************** *** 9,12 **** --- 9,15 ---- a.title { font-weight: bold; font-size: 110%; } ul { margin-left: 1em; padding: 0pt; border: 0pt; } + ul li { margin-top: 0.2em; } + td.left-column { padding-right: 1em; } + td.right-column { padding-left: 1em; } *************** *** 46,54 **** !
    • Tutorial
      (start here) !
    • Global Module Index
      (for quick access to all documentation) --- 49,71 ---- ! ! ! ! ! ! ! ! ! ! ! ! ! !
      ! ! !
      !   !
      • Global Module Index
        (for quick access to all documentation) *************** *** 64,70 **** Python Modules
        (for administrators)
      !  
       
       
        *************** *** 96,100 ****
       
        --- 114,118 ----
       
        From fdrake@users.sourceforge.net Tue Mar 26 22:22:53 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 26 Mar 2002 14:22:53 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.c,1.7,1.8 test_cdatetime.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv12964 Modified Files: datetime.c test_cdatetime.py Log Message: Make the repr match that of the Python prototype. Implement the datetime.now() constructor. Index: datetime.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** datetime.c 12 Mar 2002 22:33:51 -0000 1.7 --- datetime.c 26 Mar 2002 22:22:50 -0000 1.8 *************** *** 6,9 **** --- 6,11 ---- #include "modsupport.h" + #include + #include "datetime.h" *************** *** 117,126 **** */ ! static PyObject * datetime_compare(PyDateTime_Object *self, PyObject *other) { ! PyErr_SetString(PyExc_NotImplementedError, ! "not yet implemented"); ! return NULL; } --- 119,132 ---- */ ! static int datetime_compare(PyDateTime_Object *self, PyObject *other) { ! if (!PyType_IsSubtype(other->ob_type, &PyDateTime_Type)) { ! PyErr_SetString(PyExc_TypeError, ! "can't compare date to %s instance"); ! return -1; ! } ! return memcmp(self->data, ((PyDateTime_Object *)other)->data, ! _PyDateTime_DATA_SIZE); } *************** *** 128,132 **** datetime_repr(PyDateTime_Object *self) { ! return PyString_FromString(""); } --- 134,161 ---- datetime_repr(PyDateTime_Object *self) { ! char buffer[1028]; ! char *typename; ! ! typename = self->ob_type->tp_name; ! if (GET_MICROSECOND(self)) { ! PyOS_snprintf(buffer, sizeof(buffer), "%s(%d, %d, %d, %d, %d, %d, %d)", ! typename, ! GET_YEAR(self), GET_MONTH(self), GET_DAY(self), ! GET_HOUR(self), GET_MINUTE(self), GET_SECOND(self), ! GET_MICROSECOND(self)); ! } ! else if (GET_SECOND(self)) { ! PyOS_snprintf(buffer, sizeof(buffer), "%s(%d, %d, %d, %d, %d, %d)", ! typename, ! GET_YEAR(self), GET_MONTH(self), GET_DAY(self), ! GET_HOUR(self), GET_MINUTE(self), GET_SECOND(self)); ! } ! else { ! PyOS_snprintf(buffer, sizeof(buffer), "%s(%d, %d, %d, %d, %d)", ! typename, ! GET_YEAR(self), GET_MONTH(self), GET_DAY(self), ! GET_HOUR(self), GET_MINUTE(self)); ! } ! return PyString_FromString(buffer); } *************** *** 341,344 **** --- 370,402 ---- }; + + static PyObject * + datetime_now(PyObject *self, PyObject *cls) + { + /* XXX need to create the instance by calling cls(y,mon,d,h,min,s,u) */ + struct timeval t; + struct tm *tm; + time_t timet; + + #ifdef GETTIMEOFDAY_NO_TZ + gettimeofday(&t); + #else /* !GETTIMEOFDAY_NO_TZ */ + gettimeofday(&t, (struct timezone *)NULL); + #endif /* !GETTIMEOFDAY_NO_TZ */ + timet = t.tv_sec; + tm = localtime(&timet); + + return PyObject_CallFunction(cls, "iiiiiil", + tm->tm_year + 1900, tm->tm_mon + 1, + tm->tm_mday, tm->tm_hour, tm->tm_min, + tm->tm_sec, t.tv_usec); + } + + static PyMethodDef datetime_now_mdef = { + "now", (PyCFunction)datetime_now, METH_O, + "Return a new datetime that represents the current time." + }; + + static char datetime_doc[] = "Basic date/time type."; *************** *** 348,352 **** PyObject_HEAD_INIT(NULL) 0, /* ob_size */ ! "datetime.datetime", /* tp_name */ sizeof(PyDateTime_Object), /* tp_basicsize */ 0, /* tp_itemsize */ --- 406,410 ---- PyObject_HEAD_INIT(NULL) 0, /* ob_size */ ! "datetime", /* tp_name */ sizeof(PyDateTime_Object), /* tp_basicsize */ 0, /* tp_itemsize */ *************** *** 400,404 **** { PyObject *m; ! PyObject *d, *dt; PyDateTime_Type.ob_type = &PyType_Type; --- 458,463 ---- { PyObject *m; ! PyObject *d, *dt, *tmp; ! int err; PyDateTime_Type.ob_type = &PyType_Type; *************** *** 416,419 **** --- 475,490 ---- return; Py_DECREF(dt); + + dt = PyCFunction_New(&datetime_now_mdef, NULL); + if (dt == NULL) + return; + tmp = PyClassMethod_New(dt); + Py_DECREF(dt); + if (tmp == NULL) + return; + err = PyDict_SetItemString(d, "now", tmp); + Py_DECREF(tmp); + if (err < 0) + return; m = Py_InitModule3("_datetime", functions, Index: test_cdatetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_cdatetime.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_cdatetime.py 6 Mar 2002 05:55:00 -0000 1.3 --- test_cdatetime.py 26 Mar 2002 22:22:50 -0000 1.4 *************** *** 35,38 **** --- 35,52 ---- self.assertEqual(dt.microsecond, 8000) + def test_roundtrip(self): + for dt in (self.theclass(1, 2, 3, 4, 5, 6, 7), + self.theclass.now()): + # Verify dt -> string -> datetime identity. + s = repr(dt) + dt2 = eval(s) + self.assertEqual(dt, dt2) + + # Verify identity via reconstructing from pieces. + dt2 = self.theclass(dt.year, dt.month, dt.day, + dt.hour, dt.minute, dt.second, + dt.microsecond) + self.assertEqual(dt, dt2) + def test_isocalendar(self): # Check examples from From fdrake@users.sourceforge.net Tue Mar 26 22:38:49 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Tue, 26 Mar 2002 14:38:49 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.c,1.8,1.9 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv18127 Modified Files: datetime.c Log Message: Make str() of datetime objects match the Python prototype. Index: datetime.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** datetime.c 26 Mar 2002 22:22:50 -0000 1.8 --- datetime.c 26 Mar 2002 22:38:45 -0000 1.9 *************** *** 160,167 **** } static PyObject * datetime_str(PyDateTime_Object *self) { ! return datetime_repr(self); } --- 160,181 ---- } + static void + isoformat(PyDateTime_Object *dt, char sep, char buffer[], int bufflen) + { + PyOS_snprintf(buffer, bufflen, + "%04d-%02d-%02d%c%02d:%02d:%02d.%06d", + GET_YEAR(dt), GET_MONTH(dt), GET_DAY(dt), + sep, + GET_HOUR(dt), GET_MINUTE(dt), GET_SECOND(dt), + GET_MICROSECOND(dt)); + } + static PyObject * datetime_str(PyDateTime_Object *self) { ! char buffer[128]; ! isoformat(self, ' ', buffer, sizeof(buffer)); ! ! return PyString_FromString(buffer); } *************** *** 316,320 **** } - static PyObject * datetime_isoformat(PyDateTime_Object *self, PyObject *args, PyObject *kw) --- 330,333 ---- *************** *** 327,337 **** if (!PyArg_ParseTupleAndKeywords(args, kw, "|c:isoformat", keywords, &sep)) return NULL; - PyOS_snprintf(buffer, sizeof(buffer), - "%04d-%02d-%02d%c%02d:%02d:%02d.%06d", - GET_YEAR(self), GET_MONTH(self), GET_DAY(self), - sep, - GET_HOUR(self), GET_MINUTE(self), GET_SECOND(self), - GET_MICROSECOND(self)); return PyString_FromString(buffer); } --- 340,345 ---- if (!PyArg_ParseTupleAndKeywords(args, kw, "|c:isoformat", keywords, &sep)) return NULL; + isoformat(self, sep, buffer, sizeof(buffer)); return PyString_FromString(buffer); } From jackjansen@users.sourceforge.net Tue Mar 26 23:38:18 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 26 Mar 2002 15:38:18 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/scripts genpluginprojects.py,1.26.6.1,1.26.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/scripts In directory usw-pr-cvs1:/tmp/cvs-serv1934/Python 2.2/Mac/scripts Modified Files: Tag: release22-maint genpluginprojects.py Log Message: Oops, missed the prefixname optional arg when I applied the previous backport. Index: genpluginprojects.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/scripts/genpluginprojects.py,v retrieving revision 1.26.6.1 retrieving revision 1.26.6.2 diff -C2 -d -r1.26.6.1 -r1.26.6.2 *** genpluginprojects.py 25 Mar 2002 12:33:48 -0000 1.26.6.1 --- genpluginprojects.py 26 Mar 2002 23:38:16 -0000 1.26.6.2 *************** *** 37,41 **** libraries=[], extradirs=[], extraexportsymbols=[], outputdir=":::Lib:lib-dynload", ! libraryflags=None, stdlibraryflags=None): if architecture == "all": # For the time being we generate two project files. Not as nice as --- 37,41 ---- libraries=[], extradirs=[], extraexportsymbols=[], outputdir=":::Lib:lib-dynload", ! libraryflags=None, stdlibraryflags=None, prefixname=None): if architecture == "all": # For the time being we generate two project files. Not as nice as *************** *** 79,83 **** print "Warning: %s: sourcefile not found: %s"%(module, sources[0]) sourcedirs = [] ! if architecture == "carbon": prefixname = "mwerks_carbonplugin_config.h" else: --- 79,85 ---- print "Warning: %s: sourcefile not found: %s"%(module, sources[0]) sourcedirs = [] ! if prefixname: ! pass ! elif architecture == "carbon": prefixname = "mwerks_carbonplugin_config.h" else: From jackjansen@users.sourceforge.net Tue Mar 26 23:40:17 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 26 Mar 2002 15:40:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Distributions/(vise) Python 2.2.vct,1.6.4.2.2.1,1.6.4.2.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Distributions/(vise) In directory usw-pr-cvs1:/tmp/cvs-serv2188/Python 2.2/Mac/Distributions/(vise) Modified Files: Tag: release22-maint Python 2.2.vct Log Message: Files used for 2.2.1c2 distribution. Index: Python 2.2.vct =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Distributions/(vise)/Python 2.2.vct,v retrieving revision 1.6.4.2.2.1 retrieving revision 1.6.4.2.2.2 diff -C2 -d -r1.6.4.2.2.1 -r1.6.4.2.2.2 Binary files /tmp/cvsa0SUYj and /tmp/cvs4GUuyF differ From jackjansen@users.sourceforge.net Tue Mar 26 23:40:21 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 26 Mar 2002 15:40:21 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Distributions binary.exclude,1.10.6.2,1.10.6.2.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Distributions In directory usw-pr-cvs1:/tmp/cvs-serv2379/Python 2.2/Mac/Distributions Modified Files: Tag: release22-maint binary.exclude Log Message: Files used for 2.2.1c2 distribution. Index: binary.exclude =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Distributions/binary.exclude,v retrieving revision 1.10.6.2 retrieving revision 1.10.6.2.2.1 diff -C2 -d -r1.10.6.2 -r1.10.6.2.2.1 *** binary.exclude 26 Dec 2001 22:55:34 -0000 1.10.6.2 --- binary.exclude 26 Mar 2002 23:40:19 -0000 1.10.6.2.2.1 *************** *** 27,30 **** --- 27,31 ---- *Icon *xMAP + *~[0-9] .#* .DS_Store *************** *** 35,37 **** Setup.in [(]*[)] - *~[0-9] --- 36,37 ---- From jackjansen@users.sourceforge.net Tue Mar 26 23:40:25 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 26 Mar 2002 15:40:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Distributions binary.include,1.19.6.2,1.19.6.2.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Distributions In directory usw-pr-cvs1:/tmp/cvs-serv2411/Python 2.2/Mac/Distributions Modified Files: Tag: release22-maint binary.include Log Message: Files used for 2.2.1c2 distribution. Index: binary.include =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Distributions/binary.include,v retrieving revision 1.19.6.2 retrieving revision 1.19.6.2.2.1 diff -C2 -d -r1.19.6.2 -r1.19.6.2.2.1 *** binary.include 26 Dec 2001 22:55:54 -0000 1.19.6.2 --- binary.include 26 Mar 2002 23:40:23 -0000 1.19.6.2.2.1 *************** *** 222,223 **** --- 222,224 ---- (':setup.py', None) (':site-packages', None) + (':Mac:OSX:sample_sitecustomize.py', None) From jackjansen@users.sourceforge.net Tue Mar 26 23:40:29 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 26 Mar 2002 15:40:29 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Distributions dev.exclude,1.8.4.1,1.8.4.1.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Distributions In directory usw-pr-cvs1:/tmp/cvs-serv2430/Python 2.2/Mac/Distributions Modified Files: Tag: release22-maint dev.exclude Log Message: Files used for 2.2.1c2 distribution. Index: dev.exclude =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Distributions/dev.exclude,v retrieving revision 1.8.4.1 retrieving revision 1.8.4.1.2.1 diff -C2 -d -r1.8.4.1 -r1.8.4.1.2.1 *** dev.exclude 26 Dec 2001 22:56:14 -0000 1.8.4.1 --- dev.exclude 26 Mar 2002 23:40:27 -0000 1.8.4.1.2.1 *************** *** 12,15 **** --- 12,16 ---- *.xSYM *Icon + *~[0-9] .#* .DS_Store *************** *** 18,20 **** CVS [(]*[)] - *~[0-9] --- 19,20 ---- From jackjansen@users.sourceforge.net Tue Mar 26 23:40:35 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Tue, 26 Mar 2002 15:40:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Distributions dev.include,1.23.4.2,1.23.4.2.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Distributions In directory usw-pr-cvs1:/tmp/cvs-serv2466/Python 2.2/Mac/Distributions Modified Files: Tag: release22-maint dev.include Log Message: Files used for 2.2.1c2 distribution. Index: dev.include =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Distributions/dev.include,v retrieving revision 1.23.4.2 retrieving revision 1.23.4.2.2.1 diff -C2 -d -r1.23.4.2 -r1.23.4.2.2.1 *** dev.include 26 Dec 2001 22:56:37 -0000 1.23.4.2 --- dev.include 26 Mar 2002 23:40:33 -0000 1.23.4.2.2.1 *************** *** 614,615 **** --- 614,616 ---- (':setup.py', None) (':site-packages', None) + (':Mac:OSX:sample_sitecustomize.py', None) From akuchling@users.sourceforge.net Wed Mar 27 02:29:50 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Tue, 26 Mar 2002 18:29:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/whatsnew whatsnew23.tex,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv6550 Modified Files: whatsnew23.tex Log Message: Fill in this document a bit, adding reminders of items that should be included Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** whatsnew23.tex 26 Mar 2002 19:17:43 -0000 1.1 --- whatsnew23.tex 27 Mar 2002 02:29:48 -0000 1.2 *************** *** 1,8 **** \documentclass{howto} - \title{What's New in Python 2.3} ! % We'll let Andrew claim ownership when he's ready. ;-) ! %\author{A.M. Kuchling} ! %\authoraddress{\email{akuchlin@mems-exchange.org}} \begin{document} --- 1,10 ---- \documentclass{howto} ! % $Id$ ! ! \title{What's New in Python 2.3} ! \release{0.01} ! \author{A.M. Kuchling} ! \authoraddress{\email{akuchlin@mems-exchange.org}} \begin{document} *************** *** 10,16 **** \tableofcontents ! \section{Introduction \label{intro}} --- 12,104 ---- \tableofcontents ! %\section{Introduction \label{intro}} ! ! {\large This article is a draft, and is currently up to date for some ! random version of the CVS tree around March 26 2002. Please send any ! additions, comments or errata to the author.} ! ! This article explains the new features in Python 2.3. The tentative ! release date of Python 2.3 is currently scheduled for August 30 2002. ! ! This article doesn't attempt to provide a complete specification of ! the new features, but instead provides a convenient overview. For ! full details, you should refer to the documentation for Python 2.3, ! such as the ! \citetitle[http://www.python.org/doc/2.3/lib/lib.html]{Python Library ! Reference} and the ! \citetitle[http://www.python.org/doc/2.3/ref/ref.html]{Python ! Reference Manual}. If you want to understand the complete ! implementation and design rationale for a change, refer to the PEP for ! a particular new feature. ! ! ! %====================================================================== ! \section{New and Improved Modules} ! ! arraymodule.c: - add Py_UNICODE arrays ! - support +=, *= ! ! Return enhanced tuples in grpmodule ! ! posixmodule: killpg, ! ! Expat is now included with the Python source ! ! Readline: Add get_history_item, get_current_history_length, and ! redisplay functions. ! ! ! %====================================================================== ! \section{Interpreter Changes and Fixes} ! ! XXX bug? Change the version string from "2.2+" to "2.3a0". disutils peels off ! the first 3 characters of this string in several places, so for as long ! as they remain "2.2" it confuses the heck out of attempts to build 2.3 ! stuff using distutils. ! ! file object can now be subtyped (did this not work before?) ! ! yield is now always available ! ! This adds the module name and a dot in front of the type name in every ! type object initializer, except for built-in types (and those that ! already had this). Note that it touches lots of Mac modules -- I have ! no way to test these but the changes look right. Apologies if they're ! not. This also touches the weakref docs, which contains a sample type ! object initializer. It also touches the mmap test output, because the ! mmap type's repr is included in that output. It touches object.h to ! put the correct description in a comment. ! ! File objects: Grow the string buffer at a mildly exponential rate for ! the getc version of get_line. This makes test_bufio finish in 1.7 ! seconds instead of 57 seconds on my machine (with Py_DEBUG defined). ! ! %====================================================================== ! \section{Other Changes and Fixes} ! ! ! % ====================================================================== ! \section{C Interface Changes} ! ! pymalloc is now enabled by default (also mention debug-mode pymalloc) ! ! Memory API reworking ! ! PyObject_DelItemString() added ! ! PyArg_NoArgs macro is now deprecated ! ! Ports: ! ! OS/2 EMX port + MacOS: Weaklink most toolbox modules, improving backward + compatibility. Modules will no longer fail to load if a single routine + is missing on the curent OS version, in stead calling the missing + routine will raise an exception. Should finally fix 531398. 2.2.1 + candidate. Also blacklisted some constants with definitions that + were not Python-compatible. + Checked in Sean Reifschneider's RPM spec file and patches. Bugfix candidate. *************** *** 18,21 **** --- 106,115 ---- \section{Acknowledgements \label{acks}} + The author would like to thank the following people for offering + suggestions, corrections and assistance with various drafts of this + article: Fred~L. Drake, Jr. \end{document} + + + From loewis@users.sourceforge.net Wed Mar 27 12:15:59 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Wed, 27 Mar 2002 04:15:59 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _localemodule.c,2.27,2.28 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv9479 Modified Files: _localemodule.c Log Message: Don't imply XPG4 constants from CODESET presence. Fixes #534153. 2.2.2 candiate. Index: _localemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v retrieving revision 2.27 retrieving revision 2.28 diff -C2 -d -r2.27 -r2.28 *** _localemodule.c 25 Mar 2002 20:46:45 -0000 2.27 --- _localemodule.c 27 Mar 2002 12:15:57 -0000 2.28 *************** *** 479,485 **** LANGINFO(PM_STR), #ifdef CODESET - /* The following constants are available only with XPG4. */ LANGINFO(CODESET), LANGINFO(T_FMT_AMPM), LANGINFO(ERA), --- 479,488 ---- LANGINFO(PM_STR), + /* The following constants are available only with XPG4. AIX 3.2. only has + CODESET. */ #ifdef CODESET LANGINFO(CODESET), + #endif + #ifdef T_FMT_AMPM LANGINFO(T_FMT_AMPM), LANGINFO(ERA), From nnorwitz@users.sourceforge.net Wed Mar 27 13:03:11 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Wed, 27 Mar 2002 05:03:11 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.367,1.368 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv31861/Misc Modified Files: NEWS Log Message: Change sys_exit to use METH_VARARGS. sys.exit() now requires 0-1 arguments. Previously 2+ arguments were allowed. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.367 retrieving revision 1.368 diff -C2 -d -r1.367 -r1.368 *** NEWS 22 Mar 2002 17:06:59 -0000 1.367 --- NEWS 27 Mar 2002 13:03:09 -0000 1.368 *************** *** 27,30 **** --- 27,33 ---- - posix.killpg has been added where available. + - sys.exit() inadvertantly allowed more than one argument. + An exception will now be raised if more than one argument is used. + Extension modules From nnorwitz@users.sourceforge.net Wed Mar 27 13:03:12 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Wed, 27 Mar 2002 05:03:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python sysmodule.c,2.102,2.103 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv31861/Python Modified Files: sysmodule.c Log Message: Change sys_exit to use METH_VARARGS. sys.exit() now requires 0-1 arguments. Previously 2+ arguments were allowed. Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.102 retrieving revision 2.103 diff -C2 -d -r2.102 -r2.103 *** sysmodule.c 23 Mar 2002 20:46:35 -0000 2.102 --- sysmodule.c 27 Mar 2002 13:03:09 -0000 2.103 *************** *** 147,152 **** sys_exit(PyObject *self, PyObject *args) { /* Raise SystemExit so callers may catch it or clean up. */ ! PyErr_SetObject(PyExc_SystemExit, args); return NULL; } --- 147,155 ---- sys_exit(PyObject *self, PyObject *args) { + PyObject *exit_code = 0; + if (!PyArg_ParseTuple(args, "|O:exit", &exit_code)) + return NULL; /* Raise SystemExit so callers may catch it or clean up. */ ! PyErr_SetObject(PyExc_SystemExit, exit_code); return NULL; } *************** *** 529,533 **** {"exc_info", (PyCFunction)sys_exc_info, METH_NOARGS, exc_info_doc}, {"excepthook", sys_excepthook, METH_VARARGS, excepthook_doc}, ! {"exit", sys_exit, METH_OLDARGS, exit_doc}, #ifdef Py_USING_UNICODE {"getdefaultencoding", (PyCFunction)sys_getdefaultencoding, METH_NOARGS, --- 532,536 ---- {"exc_info", (PyCFunction)sys_exc_info, METH_NOARGS, exc_info_doc}, {"excepthook", sys_excepthook, METH_VARARGS, excepthook_doc}, ! {"exit", sys_exit, METH_VARARGS, exit_doc}, #ifdef Py_USING_UNICODE {"getdefaultencoding", (PyCFunction)sys_getdefaultencoding, METH_NOARGS, From montanaro@users.sourceforge.net Wed Mar 27 13:42:53 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Wed, 27 Mar 2002 05:42:53 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/api exceptions.tex,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv21077 Modified Files: exceptions.tex Log Message: fix a typo in PyErr_Format table and add row for 'p' format char closes bug 534495 Index: exceptions.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/exceptions.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** exceptions.tex 23 Mar 2002 20:57:11 -0000 1.4 --- exceptions.tex 27 Mar 2002 13:42:50 -0000 1.5 *************** *** 140,144 **** \lineii{d}{Number in decimal, as an \ctype{int} parameter} \lineii{x}{Number in hexadecimal, as an \ctype{int} parameter} ! \lineii{x}{A string, as a \ctype{char *} parameter} \end{tableii} --- 140,145 ---- \lineii{d}{Number in decimal, as an \ctype{int} parameter} \lineii{x}{Number in hexadecimal, as an \ctype{int} parameter} ! \lineii{s}{A string, as a \ctype{char *} parameter} ! \lineii{p}{A hex pointer, as a \ctype{void *} parameter} \end{tableii} From fdrake@users.sourceforge.net Wed Mar 27 14:08:23 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Wed, 27 Mar 2002 06:08:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/api exceptions.tex,1.3,1.3.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv32664/api Modified Files: Tag: release22-maint exceptions.tex Log Message: Backport Skip's patch for SF bug #534495: exceptions.tex 1.5 fix a typo in PyErr_Format table and add row for 'p' format char closes bug 534495 Index: exceptions.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/exceptions.tex,v retrieving revision 1.3 retrieving revision 1.3.6.1 diff -C2 -d -r1.3 -r1.3.6.1 *** exceptions.tex 3 Dec 2001 17:56:09 -0000 1.3 --- exceptions.tex 27 Mar 2002 14:08:21 -0000 1.3.6.1 *************** *** 140,144 **** \lineii{d}{Number in decimal, as an \ctype{int} parameter} \lineii{x}{Number in hexadecimal, as an \ctype{int} parameter} ! \lineii{x}{A string, as a \ctype{char *} parameter} \end{tableii} --- 140,145 ---- \lineii{d}{Number in decimal, as an \ctype{int} parameter} \lineii{x}{Number in hexadecimal, as an \ctype{int} parameter} ! \lineii{s}{A string, as a \ctype{char *} parameter} ! \lineii{p}{A hex pointer, as a \ctype{void *} parameter} \end{tableii} From nascheme@users.sourceforge.net Wed Mar 27 15:18:26 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Wed, 27 Mar 2002 07:18:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects weakrefobject.c,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv26635/Objects Modified Files: weakrefobject.c Log Message: Remove weakref free list. This has the side effect of fixing a memory management bug. Also, move some duplicated code into the new_weakref fucntion. Index: weakrefobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/weakrefobject.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** weakrefobject.c 19 Dec 2001 16:44:30 -0000 1.8 --- weakrefobject.c 27 Mar 2002 15:18:21 -0000 1.9 *************** *** 6,12 **** ((PyWeakReference **) PyObject_GET_WEAKREFS_LISTPTR(o)) - static PyWeakReference * - free_list = NULL; - long --- 6,9 ---- *************** *** 24,42 **** static PyWeakReference * ! new_weakref(void) { PyWeakReference *result; ! if (free_list != NULL) { ! result = free_list; ! free_list = result->wr_next; ! result->ob_type = &_PyWeakref_RefType; ! _Py_NewReference((PyObject *)result); ! } ! else { ! result = PyObject_GC_New(PyWeakReference, &_PyWeakref_RefType); ! } ! if (result) result->hash = -1; return result; } --- 21,36 ---- static PyWeakReference * ! new_weakref(PyObject *ob, PyObject *callback) { PyWeakReference *result; ! result = PyObject_GC_New(PyWeakReference, &_PyWeakref_RefType); ! if (result) { result->hash = -1; + result->wr_object = ob; + Py_XINCREF(callback); + result->wr_callback = callback; + PyObject_GC_Track(result); + } return result; } *************** *** 77,82 **** PyObject_GC_UnTrack((PyObject *)self); clear_weakref(self); ! self->wr_next = free_list; ! free_list = self; } --- 71,75 ---- PyObject_GC_UnTrack((PyObject *)self); clear_weakref(self); ! PyObject_GC_Del(self); } *************** *** 581,589 **** Py_XINCREF(result); else { ! result = new_weakref(); if (result != NULL) { - Py_XINCREF(callback); - result->wr_callback = callback; - result->wr_object = ob; if (callback == NULL) { insert_head(result, list); --- 574,579 ---- Py_XINCREF(result); else { ! result = new_weakref(ob, callback); if (result != NULL) { if (callback == NULL) { insert_head(result, list); *************** *** 597,601 **** insert_after(result, prev); } - PyObject_GC_Track(result); } } --- 587,590 ---- *************** *** 625,629 **** Py_XINCREF(result); else { ! result = new_weakref(); if (result != NULL) { PyWeakReference *prev; --- 614,618 ---- Py_XINCREF(result); else { ! result = new_weakref(ob, callback); if (result != NULL) { PyWeakReference *prev; *************** *** 633,639 **** else result->ob_type = &_PyWeakref_ProxyType; - result->wr_object = ob; - Py_XINCREF(callback); - result->wr_callback = callback; if (callback == NULL) prev = ref; --- 622,625 ---- *************** *** 645,649 **** else insert_after(result, prev); - PyObject_GC_Track(result); } } --- 631,634 ---- From loewis@users.sourceforge.net Wed Mar 27 17:16:00 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Wed, 27 Mar 2002 09:16:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-tk Tkinter.py,1.160,1.161 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory usw-pr-cvs1:/tmp/cvs-serv31087 Modified Files: Tkinter.py Log Message: Ignore widgets with unknown names in winfo_children. Fixes #518283. 2.2.2 candidate. Index: Tkinter.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tkinter.py,v retrieving revision 1.160 retrieving revision 1.161 diff -C2 -d -r1.160 -r1.161 *** Tkinter.py 13 Oct 2001 09:33:51 -0000 1.160 --- Tkinter.py 27 Mar 2002 17:15:57 -0000 1.161 *************** *** 606,612 **** def winfo_children(self): """Return a list of all widgets which are children of this widget.""" ! return map(self._nametowidget, ! self.tk.splitlist(self.tk.call( ! 'winfo', 'children', self._w))) def winfo_class(self): """Return window class name of this widget.""" --- 606,620 ---- def winfo_children(self): """Return a list of all widgets which are children of this widget.""" ! result = [] ! for child in self.tk.splitlist( ! self.tk.call('winfo', 'children', self._w)): ! try: ! # Tcl sometimes returns extra windows, e.g. for ! # menus; those need to be skipped ! result.append(self._nametowidget(child)) ! except KeyError: ! pass ! return result ! def winfo_class(self): """Return window class name of this widget.""" From montanaro@users.sourceforge.net Wed Mar 27 17:29:52 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Wed, 27 Mar 2002 09:29:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libsys.tex,1.57,1.58 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv4928 Modified Files: libsys.tex Log Message: add seealso referring to site module doc where people can learn how to extend sys.path using .pth files. Index: libsys.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsys.tex,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** libsys.tex 5 Jan 2002 04:00:03 -0000 1.57 --- libsys.tex 27 Mar 2002 17:29:50 -0000 1.58 *************** *** 483,484 **** --- 483,490 ---- Availability: Windows. \end{datadesc} + + + \begin{seealso} + \seemodule{site} + {This describes how to use .pth files to extend \code{sys.path}.} + \end{seealso} From loewis@users.sourceforge.net Wed Mar 27 17:54:51 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Wed, 27 Mar 2002 09:54:51 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-tk Tix.py,1.7,1.7.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory usw-pr-cvs1:/tmp/cvs-serv13793 Modified Files: Tag: release22-maint Tix.py Log Message: Destroy and unlink notebook pane after it has been deleted from the notebook. Fixes #516703. 2.2.2 candidate. Index: Tix.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tix.py,v retrieving revision 1.7 retrieving revision 1.7.6.1 diff -C2 -d -r1.7 -r1.7.6.1 *** Tix.py 13 Dec 2001 04:53:07 -0000 1.7 --- Tix.py 27 Mar 2002 17:54:48 -0000 1.7.6.1 *************** *** 467,471 **** def delete(self): self.tk.call(self.stylename, 'delete') - del(self) def __setitem__(self,key,value): --- 467,470 ---- *************** *** 1094,1097 **** --- 1093,1098 ---- def delete(self, name): self.tk.call(self._w, 'delete', name) + self.subwidget_list[name].destroy() + del self.subwidget_list[name] def page(self, name): From loewis@users.sourceforge.net Wed Mar 27 17:59:20 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Wed, 27 Mar 2002 09:59:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-tk Tix.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory usw-pr-cvs1:/tmp/cvs-serv16522 Modified Files: Tix.py Log Message: Destroy and unlink deleted NoteBook panes. Fixes #516703. 2.2.2 candidate. Index: Tix.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tix.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Tix.py 13 Dec 2001 04:53:07 -0000 1.7 --- Tix.py 27 Mar 2002 17:59:17 -0000 1.8 *************** *** 467,471 **** def delete(self): self.tk.call(self.stylename, 'delete') - del(self) def __setitem__(self,key,value): --- 467,470 ---- *************** *** 1094,1097 **** --- 1093,1098 ---- def delete(self, name): self.tk.call(self._w, 'delete', name) + self.subwidget_list[name].destroy() + del self.subwidget_list[name] def page(self, name): From loewis@users.sourceforge.net Wed Mar 27 18:49:05 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Wed, 27 Mar 2002 10:49:05 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _localemodule.c,2.28,2.29 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv3702/Modules Modified Files: _localemodule.c Log Message: Expose C library's gettext. Fixes #516412. Index: _localemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v retrieving revision 2.28 retrieving revision 2.29 diff -C2 -d -r2.28 -r2.29 *** _localemodule.c 27 Mar 2002 12:15:57 -0000 2.28 --- _localemodule.c 27 Mar 2002 18:49:02 -0000 2.29 *************** *** 22,25 **** --- 22,29 ---- #endif + #ifdef HAVE_LIBINTL_H + #include + #endif + #if defined(MS_WIN32) #define WINDOWS_LEAN_AND_MEAN *************** *** 522,526 **** } #endif /* HAVE_LANGINFO_H */ ! static struct PyMethodDef PyLocale_Methods[] = { --- 526,609 ---- } #endif /* HAVE_LANGINFO_H */ ! ! #ifdef HAVE_LIBINTL_H ! ! static char gettext__doc__[]= ! "gettext(msg) -> string\n" ! "Return translation of msg."; ! ! static PyObject* ! PyIntl_gettext(PyObject* self, PyObject *args) ! { ! char *in; ! if (!PyArg_ParseTuple(args, "z", &in)) ! return 0; ! return PyString_FromString(gettext(in)); ! } ! ! static char dgettext__doc__[]= ! "dgettext(domain, msg) -> string\n" ! "Return translation of msg in domain."; ! ! static PyObject* ! PyIntl_dgettext(PyObject* self, PyObject *args) ! { ! char *domain, *in; ! if (!PyArg_ParseTuple(args, "zz", &domain, &in)) ! return 0; ! return PyString_FromString(dgettext(domain, in)); ! } ! ! static char dcgettext__doc__[]= ! "dcgettext(domain, msg, category) -> string\n" ! "Return translation of msg in domain and category."; ! ! static PyObject* ! PyIntl_dcgettext(PyObject *self, PyObject *args) ! { ! char *domain, *msgid; ! int category; ! if (!PyArg_ParseTuple(args, "zzi", &domain, &msgid, &category)) ! return 0; ! return PyString_FromString(dcgettext(domain,msgid,category)); ! } ! ! static char textdomain__doc__[]= ! "textdomain(domain) -> string\n" ! "Set the C library's textdmain to domain, returning the new domain."; ! ! static PyObject* ! PyIntl_textdomain(PyObject* self, PyObject* args) ! { ! char *domain; ! if (!PyArg_ParseTuple(args, "z", &domain)) ! return 0; ! domain = textdomain(domain); ! if (!domain) { ! PyErr_SetFromErrno(PyExc_OSError); ! return NULL; ! } ! return PyString_FromString(domain); ! } ! ! static char bindtextdomain__doc__[]= ! "bindtextdomain(domain, dir) -> string\n" ! "Bind the C library's domain to dir."; ! ! static PyObject* ! PyIntl_bindtextdomain(PyObject* self,PyObject*args) ! { ! char *domain,*dirname; ! if (!PyArg_ParseTuple(args, "zz", &domain, &dirname)) ! return 0; ! dirname = bindtextdomain(domain, dirname); ! if (!dirname) { ! PyErr_SetFromErrno(PyExc_OSError); ! return NULL; ! } ! return PyString_FromString(dirname); ! } ! ! #endif static struct PyMethodDef PyLocale_Methods[] = { *************** *** 540,544 **** METH_VARARGS, nl_langinfo__doc__}, #endif ! {NULL, NULL} }; --- 623,638 ---- METH_VARARGS, nl_langinfo__doc__}, #endif ! #ifdef HAVE_LANGINFO_H ! {"gettext",(PyCFunction)PyIntl_gettext,METH_VARARGS, ! gettext__doc__}, ! {"dgettext",(PyCFunction)PyIntl_dgettext,METH_VARARGS, ! dgettext__doc__}, ! {"dcgettext",(PyCFunction)PyIntl_dcgettext,METH_VARARGS, ! dcgettext__doc__}, ! {"textdomain",(PyCFunction)PyIntl_textdomain,METH_VARARGS, ! textdomain__doc__}, ! {"bindtextdomain",(PyCFunction)PyIntl_bindtextdomain,METH_VARARGS, ! bindtextdomain__doc__}, ! #endif {NULL, NULL} }; From loewis@users.sourceforge.net Wed Mar 27 18:49:04 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Wed, 27 Mar 2002 10:49:04 -0800 Subject: [Python-checkins] CVS: python/dist/src configure,1.290,1.291 configure.in,1.300,1.301 pyconfig.h.in,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv3702 Modified Files: configure configure.in pyconfig.h.in Log Message: Expose C library's gettext. Fixes #516412. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.290 retrieving revision 1.291 diff -C2 -d -r1.290 -r1.291 *** configure 22 Mar 2002 15:34:49 -0000 1.290 --- configure 27 Mar 2002 18:49:01 -0000 1.291 *************** *** 1991,1996 **** fi ! for ac_hdr in dlfcn.h fcntl.h grp.h limits.h langinfo.h locale.h \ ! ncurses.h poll.h pthread.h \ signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \ sys/audioio.h sys/file.h sys/lock.h sys/modem.h db_185.h db.h \ --- 1991,1996 ---- fi ! for ac_hdr in dlfcn.h fcntl.h grp.h limits.h langinfo.h \ [...3983 lines suppressed...] if eval "test \"`echo '$''{'ac_cv_type_socklen_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < *************** *** 7662,7666 **** SRCDIRS="Parser Grammar Objects Python Modules" echo $ac_n "checking for build directories""... $ac_c" 1>&6 ! echo "configure:7665: checking for build directories" >&5 for dir in $SRCDIRS; do if test ! -d $dir; then --- 7651,7655 ---- SRCDIRS="Parser Grammar Objects Python Modules" echo $ac_n "checking for build directories""... $ac_c" 1>&6 ! echo "configure:7654: checking for build directories" >&5 for dir in $SRCDIRS; do if test ! -d $dir; then Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.300 retrieving revision 1.301 diff -C2 -d -r1.300 -r1.301 *** configure.in 22 Mar 2002 15:34:20 -0000 1.300 --- configure.in 27 Mar 2002 18:49:02 -0000 1.301 *************** *** 521,526 **** # checks for header files AC_HEADER_STDC ! AC_CHECK_HEADERS(dlfcn.h fcntl.h grp.h limits.h langinfo.h locale.h \ ! ncurses.h poll.h pthread.h \ signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \ sys/audioio.h sys/file.h sys/lock.h sys/modem.h db_185.h db.h \ --- 521,526 ---- # checks for header files AC_HEADER_STDC ! AC_CHECK_HEADERS(dlfcn.h fcntl.h grp.h limits.h langinfo.h \ ! libintl.h locale.h ncurses.h poll.h pthread.h \ signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \ sys/audioio.h sys/file.h sys/lock.h sys/modem.h db_185.h db.h \ Index: pyconfig.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/pyconfig.h.in,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** pyconfig.h.in 21 Mar 2002 15:10:58 -0000 1.24 --- pyconfig.h.in 27 Mar 2002 18:49:02 -0000 1.25 *************** *** 646,649 **** --- 646,652 ---- #undef HAVE_LANGINFO_H + /* Define if you have the header file. */ + #undef HAVE_LIBINTL_H + /* Define if you have the header file. */ #undef HAVE_LIBUTIL_H From loewis@users.sourceforge.net Wed Mar 27 18:49:04 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Wed, 27 Mar 2002 10:49:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib liblocale.tex,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv3702/Doc/lib Modified Files: liblocale.tex Log Message: Expose C library's gettext. Fixes #516412. Index: liblocale.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liblocale.tex,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** liblocale.tex 20 Oct 2001 04:24:09 -0000 1.27 --- liblocale.tex 27 Mar 2002 18:49:02 -0000 1.28 *************** *** 468,469 **** --- 468,487 ---- table of built-in modules in the \file{config.c} file, and make sure that the \module{_locale} module is not accessible as a shared library. + + \subsection{Access to message catalogs} + + The locale module exposes the C library's gettext interface on systems + that provide this interface. It consists of the functions + \function{gettext}, \function{dgettext}, \function{dcgettext}, + \function{textdomain}, and \function{bindtextdomain}. These are + similar to the same functions in the \module{gettext} module, but use + the C library's binary format for message catalogs, and the C + library's search algorithms for locating message catalogs. + + Python applications should normally find no need to invoke these + functions, and should use \module{gettext} instead. A known exception + to this rule are applications that link use additional C libraries + which internally invoke \function{gettext} or \function{dgettext}. For + these applications, it may be necessary to bind the text domain, so + that the libraries can properly locate their message catalogs. + From loewis@users.sourceforge.net Wed Mar 27 18:49:04 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Wed, 27 Mar 2002 10:49:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.368,1.369 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv3702/Misc Modified Files: NEWS Log Message: Expose C library's gettext. Fixes #516412. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.368 retrieving revision 1.369 diff -C2 -d -r1.368 -r1.369 *** NEWS 27 Mar 2002 13:03:09 -0000 1.368 --- NEWS 27 Mar 2002 18:49:02 -0000 1.369 *************** *** 32,35 **** --- 32,37 ---- Extension modules + - The locale module now exposes the C library's gettext interface. + - A security hole ("double free") was found in zlib-1.1.3, a popular third party compression library used by some Python modules. The From fdrake@users.sourceforge.net Wed Mar 27 20:37:06 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Wed, 27 Mar 2002 12:37:06 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/html .cvsignore,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/html In directory usw-pr-cvs1:/tmp/cvs-serv17644/Doc/html Modified Files: .cvsignore Log Message: Ignore new output directory. Index: .cvsignore =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/html/.cvsignore,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** .cvsignore 5 Oct 2000 05:16:12 -0000 1.9 --- .cvsignore 27 Mar 2002 20:37:04 -0000 1.10 *************** *** 8,11 **** --- 8,12 ---- dist inst + whatsnew acks.html index.html From akuchling@users.sourceforge.net Thu Mar 28 02:18:05 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Wed, 27 Mar 2002 18:18:05 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0262.txt,1.3,1.4 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv31169 Modified Files: pep-0262.txt Log Message: Note that it's not possible to handle ownership on Windows without win32all. Remove an XXX comment Index: pep-0262.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0262.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pep-0262.txt 25 Mar 2002 13:57:45 -0000 1.3 --- pep-0262.txt 28 Mar 2002 02:18:02 -0000 1.4 *************** *** 38,44 **** called INSTALLDB through the remainder of this PEP. - XXX is that a good location? What effect does platform-dependent code - vs. platform-independent code have on this? - The structure of the database is deliberately kept simple; each file in this directory or its subdirectories (if any) describes a --- 38,41 ---- *************** *** 86,91 **** * The file's size ! * The file's permissions, and the owner/group of the file. ! XXX what to do on Windows? * An MD5 digest of the file, encoded in hex. --- 83,91 ---- * The file's size ! * The file's permissions. On Windows, this field will always be ! 'unknown' ! ! * The owner and group of the file, separated by a tab. ! On Windows, these fields will both be 'unknown'. * An MD5 digest of the file, encoded in hex. *************** *** 124,127 **** --- 124,133 ---- running a postinstall script. + On Windows, the permissions and owner/group of a file aren't + stored. Windows does in fact support ownership and access + permissions, but reading and setting them requires the win32all + extensions, and they aren't present in the basic Python installer + for Windows. + References From akuchling@users.sourceforge.net Thu Mar 28 03:03:31 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Wed, 27 Mar 2002 19:03:31 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0262.txt,1.4,1.5 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv22190 Modified Files: pep-0262.txt Log Message: Update posting date Index: pep-0262.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0262.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pep-0262.txt 28 Mar 2002 02:18:02 -0000 1.4 --- pep-0262.txt 28 Mar 2002 03:03:28 -0000 1.5 *************** *** 6,10 **** Created: 08-Jul-2001 Status: Draft ! Post-History: Introduction --- 6,10 ---- Created: 08-Jul-2001 Status: Draft ! Post-History: 27-Mar-2002 Introduction From fdrake@users.sourceforge.net Thu Mar 28 05:33:35 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Wed, 27 Mar 2002 21:33:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python modsupport.c,2.58,2.59 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv5683/Python Modified Files: modsupport.c Log Message: Introduce two new flag bits that can be set in a PyMethodDef method descriptor, as used for the tp_methods slot of a type. These new flag bits are both optional, and mutually exclusive. Most methods will not use either. These flags are used to create special method types which exist in the same namespace as normal methods without having to use tedious construction code to insert the new special method objects in the type's tp_dict after PyType_Ready() has been called. If METH_CLASS is specified, the method will represent a class method like that returned by the classmethod() built-in. If METH_STATIC is specified, the method will represent a static method like that returned by the staticmethod() built-in. These flags may not be used in the PyMethodDef table for modules since these special method types are not meaningful in that case; a ValueError will be raised if these flags are found in that context. Index: modsupport.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/modsupport.c,v retrieving revision 2.58 retrieving revision 2.59 diff -C2 -d -r2.58 -r2.59 *** modsupport.c 17 Aug 2001 18:39:25 -0000 2.58 --- modsupport.c 28 Mar 2002 05:33:33 -0000 2.59 *************** *** 58,61 **** --- 58,68 ---- d = PyModule_GetDict(m); for (ml = methods; ml->ml_name != NULL; ml++) { + if ((ml->ml_flags & METH_CLASS) || + (ml->ml_flags & METH_STATIC)) { + PyErr_SetString(PyExc_ValueError, + "module functions cannot set" + " METH_CLASS or METH_STATIC"); + return NULL; + } v = PyCFunction_New(ml, passthrough); if (v == NULL) From fdrake@users.sourceforge.net Thu Mar 28 05:33:35 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Wed, 27 Mar 2002 21:33:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include methodobject.h,2.23,2.24 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv5683/Include Modified Files: methodobject.h Log Message: Introduce two new flag bits that can be set in a PyMethodDef method descriptor, as used for the tp_methods slot of a type. These new flag bits are both optional, and mutually exclusive. Most methods will not use either. These flags are used to create special method types which exist in the same namespace as normal methods without having to use tedious construction code to insert the new special method objects in the type's tp_dict after PyType_Ready() has been called. If METH_CLASS is specified, the method will represent a class method like that returned by the classmethod() built-in. If METH_STATIC is specified, the method will represent a static method like that returned by the staticmethod() built-in. These flags may not be used in the PyMethodDef table for modules since these special method types are not meaningful in that case; a ValueError will be raised if these flags are found in that context. Index: methodobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/methodobject.h,v retrieving revision 2.23 retrieving revision 2.24 diff -C2 -d -r2.23 -r2.24 *** methodobject.h 12 Aug 2001 21:51:00 -0000 2.23 --- methodobject.h 28 Mar 2002 05:33:33 -0000 2.24 *************** *** 47,53 **** #define METH_VARARGS 0x0001 #define METH_KEYWORDS 0x0002 ! /* METH_NOARGS and METH_O must not be combined with any other flag. */ #define METH_NOARGS 0x0004 #define METH_O 0x0008 typedef struct PyMethodChain { --- 47,59 ---- #define METH_VARARGS 0x0001 #define METH_KEYWORDS 0x0002 ! /* METH_NOARGS and METH_O must not be combined with the flags above. */ #define METH_NOARGS 0x0004 #define METH_O 0x0008 + + /* METH_CLASS and METH_STATIC are a little different; these control + the construction of methods for a class. These cannot be used for + functions in modules. */ + #define METH_CLASS 0x0010 + #define METH_STATIC 0x0020 typedef struct PyMethodChain { From fdrake@users.sourceforge.net Thu Mar 28 05:33:35 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Wed, 27 Mar 2002 21:33:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/api newtypes.tex,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv5683/Doc/api Modified Files: newtypes.tex Log Message: Introduce two new flag bits that can be set in a PyMethodDef method descriptor, as used for the tp_methods slot of a type. These new flag bits are both optional, and mutually exclusive. Most methods will not use either. These flags are used to create special method types which exist in the same namespace as normal methods without having to use tedious construction code to insert the new special method objects in the type's tp_dict after PyType_Ready() has been called. If METH_CLASS is specified, the method will represent a class method like that returned by the classmethod() built-in. If METH_STATIC is specified, the method will represent a static method like that returned by the staticmethod() built-in. These flags may not be used in the PyMethodDef table for modules since these special method types are not meaningful in that case; a ValueError will be raised if these flags are found in that context. Index: newtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/newtypes.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** newtypes.tex 3 Dec 2001 17:32:27 -0000 1.3 --- newtypes.tex 28 Mar 2002 05:33:33 -0000 1.4 *************** *** 153,158 **** implementation uses a the specific C type of the \var{self} object. ! The flags can have the following values. Only \constant{METH_VARARGS} ! and \constant{METH_KEYWORDS} can be combined; the others can't. \begin{datadesc}{METH_VARARGS} --- 153,162 ---- implementation uses a the specific C type of the \var{self} object. ! The \member{ml_flags} field is a bitfield which can include the ! following flags. The individual flags indicate either a calling ! convention or a binding convention. Of the calling convention flags, ! only \constant{METH_VARARGS} and \constant{METH_KEYWORDS} can be ! combined. Any of the calling convention flags can be combined with a ! binding flag. \begin{datadesc}{METH_VARARGS} *************** *** 203,206 **** --- 207,234 ---- argument. \end{datadesc} + + These two constants are not used to indicate the calling convention + but the binding when use with methods of classes. These may not be + used for functions defined for modules. At most one of these flags + may be set for any given method. + + \begin{datadesc}{METH_CLASS} + The method will be passed the type object as the first parameter + rather than an instance of the type. This is used to create + \emph{class methods}, similar to what is created when using the + \function{classmethod()}\bifuncindex{classmethod} built-in + function. + \versionadded{2.3} + \end{datadesc} + + \begin{datadesc}{METH_STATIC} + The method will be passed \NULL{} as the first parameter rather than + an instance of the type. This is used to create \emph{static + methods}, similar to what is created when using the + \function{staticmethod()}\bifuncindex{staticmethod} built-in + function. + \versionadded{2.3} + \end{datadesc} + \begin{cfuncdesc}{PyObject*}{Py_FindMethod}{PyMethodDef table[], From fdrake@users.sourceforge.net Thu Mar 28 05:33:35 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Wed, 27 Mar 2002 21:33:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects methodobject.c,2.41,2.42 typeobject.c,2.130,2.131 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv5683/Objects Modified Files: methodobject.c typeobject.c Log Message: Introduce two new flag bits that can be set in a PyMethodDef method descriptor, as used for the tp_methods slot of a type. These new flag bits are both optional, and mutually exclusive. Most methods will not use either. These flags are used to create special method types which exist in the same namespace as normal methods without having to use tedious construction code to insert the new special method objects in the type's tp_dict after PyType_Ready() has been called. If METH_CLASS is specified, the method will represent a class method like that returned by the classmethod() built-in. If METH_STATIC is specified, the method will represent a static method like that returned by the staticmethod() built-in. These flags may not be used in the PyMethodDef table for modules since these special method types are not meaningful in that case; a ValueError will be raised if these flags are found in that context. Index: methodobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/methodobject.c,v retrieving revision 2.41 retrieving revision 2.42 diff -C2 -d -r2.41 -r2.42 *** methodobject.c 18 Mar 2002 20:44:53 -0000 2.41 --- methodobject.c 28 Mar 2002 05:33:33 -0000 2.42 *************** *** 63,67 **** PyCFunction meth = PyCFunction_GET_FUNCTION(func); PyObject *self = PyCFunction_GET_SELF(func); ! int flags = PyCFunction_GET_FLAGS(func); int size = PyTuple_GET_SIZE(arg); --- 63,67 ---- PyCFunction meth = PyCFunction_GET_FUNCTION(func); PyObject *self = PyCFunction_GET_SELF(func); ! int flags = PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC); int size = PyTuple_GET_SIZE(arg); Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.130 retrieving revision 2.131 diff -C2 -d -r2.130 -r2.131 *** typeobject.c 17 Mar 2002 18:56:20 -0000 2.130 --- typeobject.c 28 Mar 2002 05:33:33 -0000 2.131 *************** *** 1695,1698 **** --- 1695,1712 ---- /* Initialize the __dict__ in a type object */ + static PyObject * + create_specialmethod(PyMethodDef *meth, PyObject *(*func)(PyObject *)) + { + PyObject *cfunc; + PyObject *result; + + cfunc = PyCFunction_New(meth, NULL); + if (cfunc == NULL) + return NULL; + result = func(cfunc); + Py_DECREF(cfunc); + return result; + } + static int add_methods(PyTypeObject *type, PyMethodDef *meth) *************** *** 1704,1711 **** if (PyDict_GetItemString(dict, meth->ml_name)) continue; ! descr = PyDescr_NewMethod(type, meth); if (descr == NULL) return -1; ! if (PyDict_SetItemString(dict,meth->ml_name, descr) < 0) return -1; Py_DECREF(descr); --- 1718,1738 ---- if (PyDict_GetItemString(dict, meth->ml_name)) continue; ! if (meth->ml_flags & METH_CLASS) { ! if (meth->ml_flags & METH_STATIC) { ! PyErr_SetString(PyExc_ValueError, ! "method cannot be both class and static"); ! return -1; ! } ! descr = create_specialmethod(meth, PyClassMethod_New); ! } ! else if (meth->ml_flags & METH_STATIC) { ! descr = create_specialmethod(meth, PyStaticMethod_New); ! } ! else { ! descr = PyDescr_NewMethod(type, meth); ! } if (descr == NULL) return -1; ! if (PyDict_SetItemString(dict, meth->ml_name, descr) < 0) return -1; Py_DECREF(descr); From tim_one@users.sourceforge.net Thu Mar 28 07:32:13 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Wed, 27 Mar 2002 23:32:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include pymem.h,2.9,2.10 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv29408/python/Include Modified Files: pymem.h Log Message: PYMALLOC_DEBUG routines: The "check API family" gimmick was going nowhere fast, and just cluttered the code. Get rid of it for now. If a compelling case can be made for it, easy to restore it later. Index: pymem.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pymem.h,v retrieving revision 2.9 retrieving revision 2.10 diff -C2 -d -r2.9 -r2.10 *** pymem.h 23 Mar 2002 10:03:50 -0000 2.9 --- pymem.h 28 Mar 2002 07:32:11 -0000 2.10 *************** *** 98,109 **** #ifdef PYMALLOC_DEBUG ! DL_IMPORT(void *) _PyMalloc_DebugMalloc(size_t nbytes, int family); ! DL_IMPORT(void *) _PyMalloc_DebugRealloc(void *p, size_t nbytes, int family); ! DL_IMPORT(void) _PyMalloc_DebugFree(void *p, int family); DL_IMPORT(void) _PyMalloc_DebugDumpAddress(const void *p); DL_IMPORT(void) _PyMalloc_DebugCheckAddress(const void *p); ! #define _PyMalloc_MALLOC(N) _PyMalloc_DebugMalloc(N, 0) ! #define _PyMalloc_REALLOC(P, N) _PyMalloc_DebugRealloc(P, N, 0) ! #define _PyMalloc_FREE(P) _PyMalloc_DebugFree(P, 0) #else /* WITH_PYMALLOC && ! PYMALLOC_DEBUG */ --- 98,109 ---- #ifdef PYMALLOC_DEBUG ! DL_IMPORT(void *) _PyMalloc_DebugMalloc(size_t nbytes); ! DL_IMPORT(void *) _PyMalloc_DebugRealloc(void *p, size_t nbytes); ! DL_IMPORT(void) _PyMalloc_DebugFree(void *p); DL_IMPORT(void) _PyMalloc_DebugDumpAddress(const void *p); DL_IMPORT(void) _PyMalloc_DebugCheckAddress(const void *p); ! #define _PyMalloc_MALLOC _PyMalloc_DebugMalloc ! #define _PyMalloc_REALLOC _PyMalloc_DebugRealloc ! #define _PyMalloc_FREE _PyMalloc_DebugFree #else /* WITH_PYMALLOC && ! PYMALLOC_DEBUG */ From tim_one@users.sourceforge.net Thu Mar 28 07:32:13 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Wed, 27 Mar 2002 23:32:13 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.10,2.11 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv29408/python/Objects Modified Files: obmalloc.c Log Message: PYMALLOC_DEBUG routines: The "check API family" gimmick was going nowhere fast, and just cluttered the code. Get rid of it for now. If a compelling case can be made for it, easy to restore it later. Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -d -r2.10 -r2.11 *** obmalloc.c 24 Mar 2002 00:34:21 -0000 2.10 --- obmalloc.c 28 Mar 2002 07:32:11 -0000 2.11 *************** *** 725,748 **** } - static void - check_family(const void *p, int family) - { - const uchar *q = (const uchar *)p; - int original_family; - char buf[200]; - - assert(p != NULL); - original_family = (int)*(q-4); - if (family != original_family) { - /* XXX better msg */ - PyOS_snprintf(buf, sizeof(buf), - "free or realloc from family #%d called, " - "but block was allocated by family #%d", - family, original_family); - _PyMalloc_DebugDumpAddress(p); - Py_FatalError(buf); - } - } - /* The debug malloc asks for 16 extra bytes and fills them with useful stuff, here calling the underlying malloc's result p: --- 725,728 ---- *************** *** 751,757 **** Number of bytes originally asked for. 4-byte unsigned integer, big-endian (easier to read in a memory dump). ! p[4] ! The API "family" this malloc call belongs to. XXX todo XXX ! p[5:8] Copies of PYMALLOC_FORBIDDENBYTE. Used to catch under- writes and reads. --- 731,735 ---- Number of bytes originally asked for. 4-byte unsigned integer, big-endian (easier to read in a memory dump). ! p[4:8] Copies of PYMALLOC_FORBIDDENBYTE. Used to catch under- writes and reads. *************** *** 774,778 **** void * ! _PyMalloc_DebugMalloc(size_t nbytes, int family) { uchar *p; /* base address of malloc'ed block */ --- 752,756 ---- void * ! _PyMalloc_DebugMalloc(size_t nbytes) { uchar *p; /* base address of malloc'ed block */ *************** *** 780,785 **** size_t total; /* nbytes + 16 */ - assert(family == 0); - bumpserialno(); total = nbytes + 16; --- 758,761 ---- *************** *** 793,803 **** } ! p = _PyMalloc_Malloc(total); /* XXX derive from family */ if (p == NULL) return NULL; write4(p, nbytes); ! p[4] = (uchar)family; ! p[5] = p[6] = p[7] = PYMALLOC_FORBIDDENBYTE; if (nbytes > 0) --- 769,778 ---- } ! p = _PyMalloc_Malloc(total); if (p == NULL) return NULL; write4(p, nbytes); ! p[4] = p[5] = p[6] = p[7] = PYMALLOC_FORBIDDENBYTE; if (nbytes > 0) *************** *** 817,839 **** */ void ! _PyMalloc_DebugFree(void *p, int family) { uchar *q = (uchar *)p; size_t nbytes; - assert(family == 0); - if (p == NULL) return; - check_family(p, family); _PyMalloc_DebugCheckAddress(p); nbytes = read4(q-8); if (nbytes > 0) memset(q, PYMALLOC_DEADBYTE, nbytes); ! _PyMalloc_Free(q-8); /* XXX derive from family */ } void * ! _PyMalloc_DebugRealloc(void *p, size_t nbytes, int family) { uchar *q = (uchar *)p; --- 792,811 ---- */ void ! _PyMalloc_DebugFree(void *p) { uchar *q = (uchar *)p; size_t nbytes; if (p == NULL) return; _PyMalloc_DebugCheckAddress(p); nbytes = read4(q-8); if (nbytes > 0) memset(q, PYMALLOC_DEADBYTE, nbytes); ! _PyMalloc_Free(q-8); } void * ! _PyMalloc_DebugRealloc(void *p, size_t nbytes) { uchar *q = (uchar *)p; *************** *** 841,852 **** void *fresh; /* new memory block, if needed */ - assert(family == 0); - if (p == NULL) ! return _PyMalloc_DebugMalloc(nbytes, family); - check_family(p, family); _PyMalloc_DebugCheckAddress(p); - original_nbytes = read4(q-8); if (nbytes == original_nbytes) { --- 813,820 ---- void *fresh; /* new memory block, if needed */ if (p == NULL) ! return _PyMalloc_DebugMalloc(nbytes); _PyMalloc_DebugCheckAddress(p); original_nbytes = read4(q-8); if (nbytes == original_nbytes) { *************** *** 865,872 **** write4(q-8, nbytes); /* kill the excess bytes plus the trailing 8 pad bytes */ - memset(q + nbytes, PYMALLOC_DEADBYTE, excess + 8); q += nbytes; q[0] = q[1] = q[2] = q[3] = PYMALLOC_FORBIDDENBYTE; write4(q+4, serialno); return p; } --- 833,840 ---- write4(q-8, nbytes); /* kill the excess bytes plus the trailing 8 pad bytes */ q += nbytes; q[0] = q[1] = q[2] = q[3] = PYMALLOC_FORBIDDENBYTE; write4(q+4, serialno); + memset(q+8, PYMALLOC_DEADBYTE, excess); return p; } *************** *** 874,881 **** /* More memory is needed: get it, copy over the first original_nbytes of the original data, and free the original memory. */ ! fresh = _PyMalloc_DebugMalloc(nbytes, family); if (fresh != NULL && original_nbytes > 0) memcpy(fresh, p, original_nbytes); ! _PyMalloc_DebugFree(p, family); return fresh; } --- 842,849 ---- /* More memory is needed: get it, copy over the first original_nbytes of the original data, and free the original memory. */ ! fresh = _PyMalloc_DebugMalloc(nbytes); if (fresh != NULL && original_nbytes > 0) memcpy(fresh, p, original_nbytes); ! _PyMalloc_DebugFree(p); return fresh; } *************** *** 885,914 **** { const uchar *q = (const uchar *)p; ! char *msg = NULL; ! if (p == NULL) msg = "didn't expect a NULL pointer"; ! else if (*(q-3) != PYMALLOC_FORBIDDENBYTE || ! *(q-2) != PYMALLOC_FORBIDDENBYTE || ! *(q-1) != PYMALLOC_FORBIDDENBYTE) ! msg = "bad leading pad byte"; ! else { const ulong nbytes = read4(q-8); const uchar *tail = q + nbytes; - int i; for (i = 0; i < 4; ++i) { if (tail[i] != PYMALLOC_FORBIDDENBYTE) { msg = "bad trailing pad byte"; ! break; } } } ! if (msg != NULL) { ! _PyMalloc_DebugDumpAddress(p); ! Py_FatalError(msg); ! } } --- 853,887 ---- { const uchar *q = (const uchar *)p; ! char *msg; ! int i; ! if (p == NULL) { msg = "didn't expect a NULL pointer"; + goto error; + } ! for (i = 4; i >= 1; --i) { ! if (*(q-i) != PYMALLOC_FORBIDDENBYTE) { ! msg = "bad leading pad byte"; ! goto error; ! } ! } ! { const ulong nbytes = read4(q-8); const uchar *tail = q + nbytes; for (i = 0; i < 4; ++i) { if (tail[i] != PYMALLOC_FORBIDDENBYTE) { msg = "bad trailing pad byte"; ! goto error; } } } ! return; ! ! error: ! _PyMalloc_DebugDumpAddress(p); ! Py_FatalError(msg); } *************** *** 919,922 **** --- 892,896 ---- const uchar *tail; ulong nbytes, serial; + int i; fprintf(stderr, "Debug memory block at address p=%p:\n", p); *************** *** 926,936 **** nbytes = read4(q-8); fprintf(stderr, " %lu bytes originally allocated\n", nbytes); - fprintf(stderr, " from API family #%d\n", *(q-4)); /* In case this is nuts, check the pad bytes before trying to read up the serial number (the address deref could blow up). */ ! fputs(" the 3 pad bytes at p-3 are ", stderr); ! if (*(q-3) == PYMALLOC_FORBIDDENBYTE && *(q-2) == PYMALLOC_FORBIDDENBYTE && *(q-1) == PYMALLOC_FORBIDDENBYTE) { --- 900,910 ---- nbytes = read4(q-8); fprintf(stderr, " %lu bytes originally allocated\n", nbytes); /* In case this is nuts, check the pad bytes before trying to read up the serial number (the address deref could blow up). */ ! fputs(" the 4 pad bytes at p-4 are ", stderr); ! if (*(q-4) == PYMALLOC_FORBIDDENBYTE && ! *(q-3) == PYMALLOC_FORBIDDENBYTE && *(q-2) == PYMALLOC_FORBIDDENBYTE && *(q-1) == PYMALLOC_FORBIDDENBYTE) { *************** *** 938,945 **** } else { - int i; fprintf(stderr, "not all PYMALLOC_FORBIDDENBYTE (0x%02x):\n", PYMALLOC_FORBIDDENBYTE); ! for (i = 3; i >= 1; --i) { const uchar byte = *(q-i); fprintf(stderr, " at p-%d: 0x%02x", i, byte); --- 912,918 ---- } else { fprintf(stderr, "not all PYMALLOC_FORBIDDENBYTE (0x%02x):\n", PYMALLOC_FORBIDDENBYTE); ! for (i = 4; i >= 1; --i) { const uchar byte = *(q-i); fprintf(stderr, " at p-%d: 0x%02x", i, byte); *************** *** 959,963 **** } else { - int i; fprintf(stderr, "not all PYMALLOC_FORBIDDENBYTE (0x%02x):\n", PYMALLOC_FORBIDDENBYTE); --- 932,935 ---- From fdrake@users.sourceforge.net Thu Mar 28 12:40:47 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 28 Mar 2002 04:40:47 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib liblocale.tex,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv344/lib Modified Files: liblocale.tex Log Message: Minor consistency adjustments. Index: liblocale.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liblocale.tex,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** liblocale.tex 27 Mar 2002 18:49:02 -0000 1.28 --- liblocale.tex 28 Mar 2002 12:40:45 -0000 1.29 *************** *** 469,487 **** that the \module{_locale} module is not accessible as a shared library. ! \subsection{Access to message catalogs} The locale module exposes the C library's gettext interface on systems ! that provide this interface. It consists of the functions ! \function{gettext}, \function{dgettext}, \function{dcgettext}, ! \function{textdomain}, and \function{bindtextdomain}. These are ! similar to the same functions in the \module{gettext} module, but use the C library's binary format for message catalogs, and the C library's search algorithms for locating message catalogs. Python applications should normally find no need to invoke these ! functions, and should use \module{gettext} instead. A known exception ! to this rule are applications that link use additional C libraries ! which internally invoke \function{gettext} or \function{dgettext}. For ! these applications, it may be necessary to bind the text domain, so ! that the libraries can properly locate their message catalogs. ! --- 469,488 ---- that the \module{_locale} module is not accessible as a shared library. ! ! \subsection{Access to message catalogs \label{locale-gettext}} The locale module exposes the C library's gettext interface on systems ! that provide this interface. It consists of the functions ! \function{gettext()}, \function{dgettext()}, \function{dcgettext()}, ! \function{textdomain()}, and \function{bindtextdomain()}. These are ! similar to the same functions in the \refmodule{gettext} module, but use the C library's binary format for message catalogs, and the C library's search algorithms for locating message catalogs. Python applications should normally find no need to invoke these ! functions, and should use \refmodule{gettext} instead. A known ! exception to this rule are applications that link use additional C ! libraries which internally invoke \cfunction{gettext()} or ! \function{cdgettext()}. For these applications, it may be necessary to ! bind the text domain, so that the libraries can properly locate their ! message catalogs. From fdrake@users.sourceforge.net Thu Mar 28 14:07:46 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 28 Mar 2002 06:07:46 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.c,1.9,1.10 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv29339 Modified Files: datetime.c Log Message: When compiled using Python 2.3, use the new METH_CLASS method flag instead of using extra code in the module initialization. Index: datetime.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** datetime.c 26 Mar 2002 22:38:45 -0000 1.9 --- datetime.c 28 Mar 2002 14:07:43 -0000 1.10 *************** *** 361,382 **** } - static PyMethodDef datetime_methods[] = { - {"isocalendar", (PyCFunction)datetime_isocalendar, METH_NOARGS, - "Return a 3-tuple containing ISO year, week number, and weekday.\n\n" - "The first ISO week of the year is the (Mon-Sun) week containing the\n" - "year's first Thursday; everything rest derives from that."}, - {"isoformat", (PyCFunction)datetime_isoformat, METH_VARARGS|METH_KEYWORDS, - "Return the day of the week represented by the datetime.\n" - "Monday == 1 ... Sunday == 7"}, - {"isoweekday", (PyCFunction)datetime_isoweekday, METH_NOARGS, - "Return the day of the week represented by the datetime.\n" - "Monday == 1 ... Sunday == 7"}, - {"weekday", (PyCFunction)datetime_weekday, METH_NOARGS, - "Return the day of the week represented by the datetime.\n" - "Monday == 0 ... Sunday == 6"}, - {NULL} - }; - - static PyObject * datetime_now(PyObject *self, PyObject *cls) --- 361,364 ---- *************** *** 401,409 **** } static PyMethodDef datetime_now_mdef = { "now", (PyCFunction)datetime_now, METH_O, "Return a new datetime that represents the current time." }; ! static char datetime_doc[] = --- 383,416 ---- } + static PyMethodDef datetime_methods[] = { + #if PY_VERSION_HEX >= 0x02030000 + /* Class methods: */ + {"now", (PyCFunction)datetime_now, METH_O | METH_CLASS, + "Return a new datetime that represents the current time."}, + #endif + /* Instance methods: */ + {"isocalendar", (PyCFunction)datetime_isocalendar, METH_NOARGS, + "Return a 3-tuple containing ISO year, week number, and weekday.\n\n" + "The first ISO week of the year is the (Mon-Sun) week containing the\n" + "year's first Thursday; everything rest derives from that."}, + {"isoformat", (PyCFunction)datetime_isoformat, METH_VARARGS|METH_KEYWORDS, + "Return the day of the week represented by the datetime.\n" + "Monday == 1 ... Sunday == 7"}, + {"isoweekday", (PyCFunction)datetime_isoweekday, METH_NOARGS, + "Return the day of the week represented by the datetime.\n" + "Monday == 1 ... Sunday == 7"}, + {"weekday", (PyCFunction)datetime_weekday, METH_NOARGS, + "Return the day of the week represented by the datetime.\n" + "Monday == 0 ... Sunday == 6"}, + {NULL} + }; + + + #if PY_VERSION_HEX < 0x02030000 static PyMethodDef datetime_now_mdef = { "now", (PyCFunction)datetime_now, METH_O, "Return a new datetime that represents the current time." }; ! #endif static char datetime_doc[] = *************** *** 466,470 **** { PyObject *m; ! PyObject *d, *dt, *tmp; int err; --- 473,477 ---- { PyObject *m; ! PyObject *d, *dt; int err; *************** *** 484,498 **** Py_DECREF(dt); ! dt = PyCFunction_New(&datetime_now_mdef, NULL); ! if (dt == NULL) ! return; ! tmp = PyClassMethod_New(dt); ! Py_DECREF(dt); ! if (tmp == NULL) ! return; ! err = PyDict_SetItemString(d, "now", tmp); ! Py_DECREF(tmp); ! if (err < 0) ! return; m = Py_InitModule3("_datetime", functions, --- 491,510 ---- Py_DECREF(dt); ! #if PY_VERSION_HEX < 0x02030000 ! { ! PyObject *tmp; ! dt = PyCFunction_New(&datetime_now_mdef, NULL); ! if (dt == NULL) ! return; ! tmp = PyClassMethod_New(dt); ! Py_DECREF(dt); ! if (tmp == NULL) ! return; ! err = PyDict_SetItemString(d, "now", tmp); ! Py_DECREF(tmp); ! if (err < 0) ! return; ! } ! #endif m = Py_InitModule3("_datetime", functions, From loewis@users.sourceforge.net Thu Mar 28 15:46:00 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Thu, 28 Mar 2002 07:46:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-tk turtle.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory usw-pr-cvs1:/tmp/cvs-serv28660 Modified Files: turtle.py Log Message: Patch #536117: Typo in turtle.py. 2.2.2 candidate. Index: turtle.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/turtle.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** turtle.py 9 Aug 2001 16:42:07 -0000 1.5 --- turtle.py 28 Mar 2002 15:45:57 -0000 1.6 *************** *** 260,264 **** dy = distance * sin(self._angle*self._invradian) self._delete_turtle() ! self._arrow = _canvas.create_line(x-dx,y+dy,x,y, width=self._width, arrow="last", --- 260,264 ---- dy = distance * sin(self._angle*self._invradian) self._delete_turtle() ! self._arrow = self._canvas.create_line(x-dx,y+dy,x,y, width=self._width, arrow="last", From fdrake@users.sourceforge.net Thu Mar 28 15:49:56 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 28 Mar 2002 07:49:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules xxsubtype.c,2.13,2.14 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv30051/Modules Modified Files: xxsubtype.c Log Message: Add a simple test of the METH_CLASS and METH_STATIC flags for type methods. Index: xxsubtype.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/xxsubtype.c,v retrieving revision 2.13 retrieving revision 2.14 diff -C2 -d -r2.13 -r2.14 *** xxsubtype.c 12 Mar 2002 21:49:44 -0000 2.13 --- xxsubtype.c 28 Mar 2002 15:49:54 -0000 2.14 *************** *** 44,47 **** --- 44,67 ---- } + static PyObject * + spamlist_specialmeth(PyObject *self, PyObject *args, PyObject *kw) + { + PyObject *result = PyTuple_New(3); + + if (result != NULL) { + if (self == NULL) + self = Py_None; + if (kw == NULL) + kw = Py_None; + Py_INCREF(self); + PyTuple_SET_ITEM(result, 0, self); + Py_INCREF(args); + PyTuple_SET_ITEM(result, 1, args); + Py_INCREF(kw); + PyTuple_SET_ITEM(result, 2, kw); + } + return result; + } + static PyMethodDef spamlist_methods[] = { {"getstate", (PyCFunction)spamlist_getstate, METH_VARARGS, *************** *** 49,52 **** --- 69,80 ---- {"setstate", (PyCFunction)spamlist_setstate, METH_VARARGS, "setstate(state)"}, + /* These entries differ only in the flags; they are used by the tests + in test.test_descr. */ + {"classmeth", (PyCFunction)spamlist_specialmeth, + METH_VARARGS | METH_KEYWORDS | METH_CLASS, + "classmeth(*args, **kw)"}, + {"staticmeth", (PyCFunction)spamlist_specialmeth, + METH_VARARGS | METH_KEYWORDS | METH_STATIC, + "staticmeth(*args, **kw)"}, {NULL, NULL}, }; From fdrake@users.sourceforge.net Thu Mar 28 15:49:56 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 28 Mar 2002 07:49:56 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.123,1.124 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv30051/Lib/test Modified Files: test_descr.py Log Message: Add a simple test of the METH_CLASS and METH_STATIC flags for type methods. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.123 retrieving revision 1.124 diff -C2 -d -r1.123 -r1.124 *** test_descr.py 25 Mar 2002 18:36:32 -0000 1.123 --- test_descr.py 28 Mar 2002 15:49:54 -0000 1.124 *************** *** 1215,1218 **** --- 1215,1232 ---- vereq(ff.__get__(0)(42), (int, 42)) + def classmethods_in_c(): + if verbose: print "Testing C-based class methods..." + import xxsubtype as spam + a = (1, 2, 3) + d = {'abc': 123} + x, a1, d1 = spam.spamlist.classmeth(*a, **d) + veris(x, None) + vereq((spam.spamlist,) + a, a1) + vereq(d, d1) + x, a1, d1 = spam.spamlist().classmeth(*a, **d) + veris(x, None) + vereq((spam.spamlist,) + a, a1) + vereq(d, d1) + def staticmethods(): if verbose: print "Testing static methods..." *************** *** 1232,1235 **** --- 1246,1263 ---- vereq(D.foo(d, 1), (d, 1)) + def staticmethods_in_c(): + if verbose: print "Testing C-based static methods..." + import xxsubtype as spam + a = (1, 2, 3) + d = {"abc": 123} + x, a1, d1 = spam.spamlist.staticmeth(*a, **d) + veris(x, None) + vereq(a, a1) + vereq(d, d1) + x, a1, d2 = spam.spamlist().staticmeth(*a, **d) + veris(x, None) + vereq(a, a1) + vereq(d, d1) + def classic(): if verbose: print "Testing classic classes..." *************** *** 2885,2889 **** --- 2913,2919 ---- errors() classmethods() + classmethods_in_c() staticmethods() + staticmethods_in_c() classic() compattr() From loewis@users.sourceforge.net Thu Mar 28 16:26:43 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Thu, 28 Mar 2002 08:26:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-tk Tix.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory usw-pr-cvs1:/tmp/cvs-serv9063 Modified Files: Tix.py Log Message: Reindent. Index: Tix.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tix.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Tix.py 27 Mar 2002 17:59:17 -0000 1.8 --- Tix.py 28 Mar 2002 16:26:40 -0000 1.9 *************** *** 5,9 **** # Tix.py -- Tix widget wrappers. # ! # For Tix, see http://tix.sourceforge.net # # - Sudhir Shenoy (sshenoy@gol.com), Dec. 1995. --- 5,9 ---- # Tix.py -- Tix widget wrappers. # ! # For Tix, see http://tix.sourceforge.net # [...2273 lines suppressed...] ######################## *************** *** 1613,1617 **** s = '' for type in dict.keys(): ! s = s + '{{' + type + '} {' + type + ' - ' + dict[type] + '}} ' return s --- 1613,1617 ---- s = '' for type in dict.keys(): ! s = s + '{{' + type + '} {' + type + ' - ' + dict[type] + '}} ' return s *************** *** 1625,1627 **** """ pass - --- 1625,1626 ---- From fdrake@users.sourceforge.net Thu Mar 28 19:34:55 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 28 Mar 2002 11:34:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libdis.tex,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv29655/lib Modified Files: libdis.tex Log Message: Add documentation on the hasfree data object. Index: libdis.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdis.tex,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** libdis.tex 1 Oct 2001 17:04:10 -0000 1.33 --- libdis.tex 28 Mar 2002 19:34:53 -0000 1.34 *************** *** 86,89 **** --- 86,93 ---- \end{datadesc} + \begin{datadesc}{hasfree} + Sequence of byte codes that access a free variable. + \end{datadesc} + \begin{datadesc}{hasname} Sequence of byte codes that access an attribute by name. From fdrake@users.sourceforge.net Thu Mar 28 19:35:36 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 28 Mar 2002 11:35:36 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libdis.tex,1.33,1.33.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv29830/lib Modified Files: Tag: release22-maint libdis.tex Log Message: Add documentation on the hasfree data object. Index: libdis.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdis.tex,v retrieving revision 1.33 retrieving revision 1.33.10.1 diff -C2 -d -r1.33 -r1.33.10.1 *** libdis.tex 1 Oct 2001 17:04:10 -0000 1.33 --- libdis.tex 28 Mar 2002 19:35:33 -0000 1.33.10.1 *************** *** 86,89 **** --- 86,93 ---- \end{datadesc} + \begin{datadesc}{hasfree} + Sequence of byte codes that access a free variable. + \end{datadesc} + \begin{datadesc}{hasname} Sequence of byte codes that access an attribute by name. From gvanrossum@users.sourceforge.net Thu Mar 28 20:17:54 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Thu, 28 Mar 2002 12:17:54 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python ceval.c,2.308,2.309 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv8569 Modified Files: ceval.c Log Message: Fix an issue that was reported in but unrelated to the main problem of SF bug 535905 (Evil Trashcan and GC interaction). The SETLOCAL() macro should not DECREF the local variable in-place and then store the new value; it should copy the old value to a temporary value, then store the new value, and then DECREF the temporary value. This is because it is possible that during the DECREF the frame is accessed by other code (e.g. a __del__ method or gc.collect()) and the variable would be pointing to already-freed memory. BUGFIX CANDIDATE! Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.308 retrieving revision 2.309 diff -C2 -d -r2.308 -r2.309 *** ceval.c 24 Mar 2002 19:25:00 -0000 2.308 --- ceval.c 28 Mar 2002 20:17:52 -0000 2.309 *************** *** 555,560 **** #define GETLOCAL(i) (fastlocals[i]) ! #define SETLOCAL(i, value) do { Py_XDECREF(GETLOCAL(i)); \ ! GETLOCAL(i) = value; } while (0) /* Start of code */ --- 555,568 ---- #define GETLOCAL(i) (fastlocals[i]) ! ! /* The SETLOCAL() macro must not DECREF the local variable in-place and ! then store the new value; it must copy the old value to a temporary ! value, then store the new value, and then DECREF the temporary value. ! This is because it is possible that during the DECREF the frame is ! accessed by other code (e.g. a __del__ method or gc.collect()) and the ! variable would be pointing to already-freed memory. */ ! #define SETLOCAL(i, value) do { PyObject *tmp = GETLOCAL(i); \ ! GETLOCAL(i) = value; \ ! Py_XDECREF(tmp); } while (0) /* Start of code */ From gvanrossum@users.sourceforge.net Thu Mar 28 20:18:51 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Thu, 28 Mar 2002 12:18:51 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python ceval.c,2.301.4.1,2.301.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv8924 Modified Files: Tag: release22-maint ceval.c Log Message: Backport to 2.2.1. Fix an issue that was reported in but unrelated to the main problem of SF bug 535905 (Evil Trashcan and GC interaction). The SETLOCAL() macro should not DECREF the local variable in-place and then store the new value; it should copy the old value to a temporary value, then store the new value, and then DECREF the temporary value. This is because it is possible that during the DECREF the frame is accessed by other code (e.g. a __del__ method or gc.collect()) and the variable would be pointing to already-freed memory. BUGFIX CANDIDATE! Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.301.4.1 retrieving revision 2.301.4.2 diff -C2 -d -r2.301.4.1 -r2.301.4.2 *** ceval.c 28 Dec 2001 10:22:15 -0000 2.301.4.1 --- ceval.c 28 Mar 2002 20:18:48 -0000 2.301.4.2 *************** *** 555,560 **** #define GETLOCAL(i) (fastlocals[i]) ! #define SETLOCAL(i, value) do { Py_XDECREF(GETLOCAL(i)); \ ! GETLOCAL(i) = value; } while (0) /* Start of code */ --- 555,568 ---- #define GETLOCAL(i) (fastlocals[i]) ! ! /* The SETLOCAL() macro must not DECREF the local variable in-place and ! then store the new value; it must copy the old value to a temporary ! value, then store the new value, and then DECREF the temporary value. ! This is because it is possible that during the DECREF the frame is ! accessed by other code (e.g. a __del__ method or gc.collect()) and the ! variable would be pointing to already-freed memory. */ ! #define SETLOCAL(i, value) do { PyObject *tmp = GETLOCAL(i); \ ! GETLOCAL(i) = value; \ ! Py_XDECREF(tmp); } while (0) /* Start of code */ From fdrake@users.sourceforge.net Thu Mar 28 20:19:25 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 28 Mar 2002 12:19:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ext extending.tex,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory usw-pr-cvs1:/tmp/cvs-serv9157/ext Modified Files: extending.tex Log Message: Allow a page break in a code longish example. Index: extending.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/extending.tex,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** extending.tex 9 Jan 2002 16:21:27 -0000 1.12 --- extending.tex 28 Mar 2002 20:19:23 -0000 1.13 *************** *** 997,1005 **** * three. */ ! {"parrot", (PyCFunction)keywdarg_parrot, METH_VARARGS|METH_KEYWORDS, "Print a lovely skit to standard output."}, {NULL, NULL, 0, NULL} /* sentinel */ }; void initkeywdarg(void) --- 997,1007 ---- * three. */ ! {"parrot", (PyCFunction)keywdarg_parrot, METH_VARARGS | METH_KEYWORDS, "Print a lovely skit to standard output."}, {NULL, NULL, 0, NULL} /* sentinel */ }; + \end{verbatim} + \begin{verbatim} void initkeywdarg(void) From gvanrossum@users.sourceforge.net Thu Mar 28 20:21:23 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Thu, 28 Mar 2002 12:21:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python ceval.c,2.238.2.5,2.238.2.6 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv9907 Modified Files: Tag: release21-maint ceval.c Log Message: Backport for 2.1.3 (if we ever release it; we may have to because this is what Zope 2 will be using in the foreseeable future). Fix an issue that was reported in but unrelated to the main problem of SF bug 535905 (Evil Trashcan and GC interaction). The SETLOCAL() macro should not DECREF the local variable in-place and then store the new value; it should copy the old value to a temporary value, then store the new value, and then DECREF the temporary value. This is because it is possible that during the DECREF the frame is accessed by other code (e.g. a __del__ method or gc.collect()) and the variable would be pointing to already-freed memory. BUGFIX CANDIDATE! Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.238.2.5 retrieving revision 2.238.2.6 diff -C2 -d -r2.238.2.5 -r2.238.2.6 *** ceval.c 20 Dec 2001 02:07:36 -0000 2.238.2.5 --- ceval.c 28 Mar 2002 20:21:21 -0000 2.238.2.6 *************** *** 415,420 **** #define GETLOCAL(i) (fastlocals[i]) ! #define SETLOCAL(i, value) do { Py_XDECREF(GETLOCAL(i)); \ ! GETLOCAL(i) = value; } while (0) /* Start of code */ --- 415,428 ---- #define GETLOCAL(i) (fastlocals[i]) ! ! /* The SETLOCAL() macro must not DECREF the local variable in-place and ! then store the new value; it must copy the old value to a temporary ! value, then store the new value, and then DECREF the temporary value. ! This is because it is possible that during the DECREF the frame is ! accessed by other code (e.g. a __del__ method or gc.collect()) and the ! variable would be pointing to already-freed memory. */ ! #define SETLOCAL(i, value) do { PyObject *tmp = GETLOCAL(i); \ ! GETLOCAL(i) = value; \ ! Py_XDECREF(tmp); } while (0) /* Start of code */ From gvanrossum@users.sourceforge.net Thu Mar 28 20:35:01 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Thu, 28 Mar 2002 12:35:01 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects dictobject.c,2.120,2.121 frameobject.c,2.59,2.60 listobject.c,2.103,2.104 tupleobject.c,2.62,2.63 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv13618/Objects Modified Files: dictobject.c frameobject.c listobject.c tupleobject.c Log Message: This is Neil's fix for SF bug 535905 (Evil Trashcan and GC interaction). The fix makes it possible to call PyObject_GC_UnTrack() more than once on the same object, and then move the PyObject_GC_UnTrack() call to *before* the trashcan code is invoked. BUGFIX CANDIDATE! Index: dictobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v retrieving revision 2.120 retrieving revision 2.121 diff -C2 -d -r2.120 -r2.121 *** dictobject.c 22 Mar 2002 15:26:09 -0000 2.120 --- dictobject.c 28 Mar 2002 20:34:58 -0000 2.121 *************** *** 695,700 **** register dictentry *ep; int fill = mp->ma_fill; Py_TRASHCAN_SAFE_BEGIN(mp) - _PyObject_GC_UNTRACK(mp); for (ep = mp->ma_table; fill > 0; ep++) { if (ep->me_key) { --- 695,700 ---- register dictentry *ep; int fill = mp->ma_fill; + PyObject_GC_UnTrack(mp); Py_TRASHCAN_SAFE_BEGIN(mp) for (ep = mp->ma_table; fill > 0; ep++) { if (ep->me_key) { Index: frameobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/frameobject.c,v retrieving revision 2.59 retrieving revision 2.60 diff -C2 -d -r2.59 -r2.60 *** frameobject.c 6 Dec 2001 15:48:16 -0000 2.59 --- frameobject.c 28 Mar 2002 20:34:59 -0000 2.60 *************** *** 68,73 **** PyObject **p; Py_TRASHCAN_SAFE_BEGIN(f) - _PyObject_GC_UNTRACK(f); /* Kill all local variables */ slots = f->f_nlocals + f->f_ncells + f->f_nfreevars; --- 68,73 ---- PyObject **p; + PyObject_GC_UnTrack(f); Py_TRASHCAN_SAFE_BEGIN(f) /* Kill all local variables */ slots = f->f_nlocals + f->f_ncells + f->f_nfreevars; Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.103 retrieving revision 2.104 diff -C2 -d -r2.103 -r2.104 *** listobject.c 3 Dec 2001 16:32:18 -0000 2.103 --- listobject.c 28 Mar 2002 20:34:59 -0000 2.104 *************** *** 196,201 **** { int i; Py_TRASHCAN_SAFE_BEGIN(op) - _PyObject_GC_UNTRACK(op); if (op->ob_item != NULL) { /* Do it backwards, for Christian Tismer. --- 196,201 ---- { int i; + PyObject_GC_UnTrack(op); Py_TRASHCAN_SAFE_BEGIN(op) if (op->ob_item != NULL) { /* Do it backwards, for Christian Tismer. Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.62 retrieving revision 2.63 diff -C2 -d -r2.62 -r2.63 *** tupleobject.c 7 Dec 2001 20:00:04 -0000 2.62 --- tupleobject.c 28 Mar 2002 20:34:59 -0000 2.63 *************** *** 140,145 **** register int i; register int len = op->ob_size; Py_TRASHCAN_SAFE_BEGIN(op) - _PyObject_GC_UNTRACK(op); if (len > 0) { i = len; --- 140,145 ---- register int i; register int len = op->ob_size; + PyObject_GC_UnTrack(op); Py_TRASHCAN_SAFE_BEGIN(op) if (len > 0) { i = len; From gvanrossum@users.sourceforge.net Thu Mar 28 20:35:00 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Thu, 28 Mar 2002 12:35:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules gcmodule.c,2.36,2.37 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv13618/Modules Modified Files: gcmodule.c Log Message: This is Neil's fix for SF bug 535905 (Evil Trashcan and GC interaction). The fix makes it possible to call PyObject_GC_UnTrack() more than once on the same object, and then move the PyObject_GC_UnTrack() call to *before* the trashcan code is invoked. BUGFIX CANDIDATE! Index: gcmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v retrieving revision 2.36 retrieving revision 2.37 diff -C2 -d -r2.36 -r2.37 *** gcmodule.c 22 Mar 2002 15:41:03 -0000 2.36 --- gcmodule.c 28 Mar 2002 20:34:58 -0000 2.37 *************** *** 820,824 **** _PyObject_GC_UnTrack(PyObject *op) { ! _PyObject_GC_UNTRACK(op); } --- 820,826 ---- _PyObject_GC_UnTrack(PyObject *op) { ! PyGC_Head *gc = AS_GC(op); ! if (gc->gc.gc_next != NULL) ! _PyObject_GC_UNTRACK(op); } From gvanrossum@users.sourceforge.net Thu Mar 28 20:36:52 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Thu, 28 Mar 2002 12:36:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects dictobject.c,2.119,2.119.6.1 frameobject.c,2.59,2.59.6.1 listobject.c,2.103,2.103.6.1 tupleobject.c,2.62,2.62.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv14857/Objects Modified Files: Tag: release22-maint dictobject.c frameobject.c listobject.c tupleobject.c Log Message: Backport to 2.2.1: This is Neil's fix for SF bug 535905 (Evil Trashcan and GC interaction). The fix makes it possible to call PyObject_GC_UnTrack() more than once on the same object, and then move the PyObject_GC_UnTrack() call to *before* the trashcan code is invoked. BUGFIX CANDIDATE! Index: dictobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v retrieving revision 2.119 retrieving revision 2.119.6.1 diff -C2 -d -r2.119 -r2.119.6.1 *** dictobject.c 11 Dec 2001 18:51:08 -0000 2.119 --- dictobject.c 28 Mar 2002 20:36:50 -0000 2.119.6.1 *************** *** 695,700 **** register dictentry *ep; int fill = mp->ma_fill; Py_TRASHCAN_SAFE_BEGIN(mp) - _PyObject_GC_UNTRACK(mp); for (ep = mp->ma_table; fill > 0; ep++) { if (ep->me_key) { --- 695,700 ---- register dictentry *ep; int fill = mp->ma_fill; + PyObject_GC_UnTrack(mp); Py_TRASHCAN_SAFE_BEGIN(mp) for (ep = mp->ma_table; fill > 0; ep++) { if (ep->me_key) { Index: frameobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/frameobject.c,v retrieving revision 2.59 retrieving revision 2.59.6.1 diff -C2 -d -r2.59 -r2.59.6.1 *** frameobject.c 6 Dec 2001 15:48:16 -0000 2.59 --- frameobject.c 28 Mar 2002 20:36:50 -0000 2.59.6.1 *************** *** 68,73 **** PyObject **p; Py_TRASHCAN_SAFE_BEGIN(f) - _PyObject_GC_UNTRACK(f); /* Kill all local variables */ slots = f->f_nlocals + f->f_ncells + f->f_nfreevars; --- 68,73 ---- PyObject **p; + PyObject_GC_UnTrack(f); Py_TRASHCAN_SAFE_BEGIN(f) /* Kill all local variables */ slots = f->f_nlocals + f->f_ncells + f->f_nfreevars; Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.103 retrieving revision 2.103.6.1 diff -C2 -d -r2.103 -r2.103.6.1 *** listobject.c 3 Dec 2001 16:32:18 -0000 2.103 --- listobject.c 28 Mar 2002 20:36:50 -0000 2.103.6.1 *************** *** 196,201 **** { int i; Py_TRASHCAN_SAFE_BEGIN(op) - _PyObject_GC_UNTRACK(op); if (op->ob_item != NULL) { /* Do it backwards, for Christian Tismer. --- 196,201 ---- { int i; + PyObject_GC_UnTrack(op); Py_TRASHCAN_SAFE_BEGIN(op) if (op->ob_item != NULL) { /* Do it backwards, for Christian Tismer. Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.62 retrieving revision 2.62.6.1 diff -C2 -d -r2.62 -r2.62.6.1 *** tupleobject.c 7 Dec 2001 20:00:04 -0000 2.62 --- tupleobject.c 28 Mar 2002 20:36:50 -0000 2.62.6.1 *************** *** 140,145 **** register int i; register int len = op->ob_size; Py_TRASHCAN_SAFE_BEGIN(op) - _PyObject_GC_UNTRACK(op); if (len > 0) { i = len; --- 140,145 ---- register int i; register int len = op->ob_size; + PyObject_GC_UnTrack(op); Py_TRASHCAN_SAFE_BEGIN(op) if (len > 0) { i = len; From gvanrossum@users.sourceforge.net Thu Mar 28 20:36:52 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Thu, 28 Mar 2002 12:36:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules gcmodule.c,2.33.6.1,2.33.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv14857/Modules Modified Files: Tag: release22-maint gcmodule.c Log Message: Backport to 2.2.1: This is Neil's fix for SF bug 535905 (Evil Trashcan and GC interaction). The fix makes it possible to call PyObject_GC_UnTrack() more than once on the same object, and then move the PyObject_GC_UnTrack() call to *before* the trashcan code is invoked. BUGFIX CANDIDATE! Index: gcmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v retrieving revision 2.33.6.1 retrieving revision 2.33.6.2 diff -C2 -d -r2.33.6.1 -r2.33.6.2 *** gcmodule.c 6 Feb 2002 17:06:02 -0000 2.33.6.1 --- gcmodule.c 28 Mar 2002 20:36:49 -0000 2.33.6.2 *************** *** 820,824 **** _PyObject_GC_UnTrack(PyObject *op) { ! _PyObject_GC_UNTRACK(op); } --- 820,826 ---- _PyObject_GC_UnTrack(PyObject *op) { ! PyGC_Head *gc = AS_GC(op); ! if (gc->gc.gc_next != NULL) ! _PyObject_GC_UNTRACK(op); } From gvanrossum@users.sourceforge.net Thu Mar 28 20:41:04 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Thu, 28 Mar 2002 12:41:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects dictobject.c,2.76.2.1,2.76.2.2 listobject.c,2.92.4.1,2.92.4.2 tupleobject.c,2.48.4.3,2.48.4.4 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv16019/Objects Modified Files: Tag: release21-maint dictobject.c listobject.c tupleobject.c Log Message: Sort-of backport to 2.1.3 (if we ever release it) of the following. (The fix looks different, but does the same thing to the 2.1 GC code that Neil's patch does to the 2.2 GC code.) This is Neil's fix for SF bug 535905 (Evil Trashcan and GC interaction). The fix makes it possible to call PyObject_GC_UnTrack() more than once on the same object, and then move the PyObject_GC_UnTrack() call to *before* the trashcan code is invoked. BUGFIX CANDIDATE! Index: dictobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v retrieving revision 2.76.2.1 retrieving revision 2.76.2.2 diff -C2 -d -r2.76.2.1 -r2.76.2.2 *** dictobject.c 23 May 2001 15:07:55 -0000 2.76.2.1 --- dictobject.c 28 Mar 2002 20:41:02 -0000 2.76.2.2 *************** *** 620,625 **** register int i; register dictentry *ep; - Py_TRASHCAN_SAFE_BEGIN(mp) PyObject_GC_Fini(mp); for (i = 0, ep = mp->ma_table; i < mp->ma_size; i++, ep++) { if (ep->me_key != NULL) { --- 620,625 ---- register int i; register dictentry *ep; PyObject_GC_Fini(mp); + Py_TRASHCAN_SAFE_BEGIN(mp) for (i = 0, ep = mp->ma_table; i < mp->ma_size; i++, ep++) { if (ep->me_key != NULL) { Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.92.4.1 retrieving revision 2.92.4.2 diff -C2 -d -r2.92.4.1 -r2.92.4.2 *** listobject.c 6 Jul 2001 17:48:47 -0000 2.92.4.1 --- listobject.c 28 Mar 2002 20:41:02 -0000 2.92.4.2 *************** *** 177,182 **** { int i; - Py_TRASHCAN_SAFE_BEGIN(op) PyObject_GC_Fini(op); if (op->ob_item != NULL) { /* Do it backwards, for Christian Tismer. --- 177,182 ---- { int i; PyObject_GC_Fini(op); + Py_TRASHCAN_SAFE_BEGIN(op) if (op->ob_item != NULL) { /* Do it backwards, for Christian Tismer. Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.48.4.3 retrieving revision 2.48.4.4 diff -C2 -d -r2.48.4.3 -r2.48.4.4 *** tupleobject.c 6 Jul 2001 17:48:47 -0000 2.48.4.3 --- tupleobject.c 28 Mar 2002 20:41:02 -0000 2.48.4.4 *************** *** 144,149 **** register int i; register int len = op->ob_size; - Py_TRASHCAN_SAFE_BEGIN(op) PyObject_GC_Fini(op); if (len > 0) { i = len; --- 144,149 ---- register int i; register int len = op->ob_size; PyObject_GC_Fini(op); + Py_TRASHCAN_SAFE_BEGIN(op) if (len > 0) { i = len; From gvanrossum@users.sourceforge.net Thu Mar 28 20:41:04 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Thu, 28 Mar 2002 12:41:04 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules gcmodule.c,2.15.6.1,2.15.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv16019/Modules Modified Files: Tag: release21-maint gcmodule.c Log Message: Sort-of backport to 2.1.3 (if we ever release it) of the following. (The fix looks different, but does the same thing to the 2.1 GC code that Neil's patch does to the 2.2 GC code.) This is Neil's fix for SF bug 535905 (Evil Trashcan and GC interaction). The fix makes it possible to call PyObject_GC_UnTrack() more than once on the same object, and then move the PyObject_GC_UnTrack() call to *before* the trashcan code is invoked. BUGFIX CANDIDATE! Index: gcmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v retrieving revision 2.15.6.1 retrieving revision 2.15.6.2 diff -C2 -d -r2.15.6.1 -r2.15.6.2 *** gcmodule.c 1 Nov 2001 15:34:20 -0000 2.15.6.1 --- gcmodule.c 28 Mar 2002 20:41:02 -0000 2.15.6.2 *************** *** 88,97 **** gc_list_remove(PyGC_Head *node) { node->gc_prev->gc_next = node->gc_next; node->gc_next->gc_prev = node->gc_prev; #ifdef Py_DEBUG node->gc_prev = NULL; - node->gc_next = NULL; #endif } --- 88,99 ---- gc_list_remove(PyGC_Head *node) { + if (node->gc_next == NULL) + return; node->gc_prev->gc_next = node->gc_next; node->gc_next->gc_prev = node->gc_prev; #ifdef Py_DEBUG node->gc_prev = NULL; #endif + node->gc_next = NULL; } From montanaro@users.sourceforge.net Thu Mar 28 20:53:25 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Thu, 28 Mar 2002 12:53:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libexcs.tex,1.43,1.44 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv19520 Modified Files: libexcs.tex Log Message: add exception class hierarchy. This should probably be done differently, but at least the content is there. Index: libexcs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libexcs.tex,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** libexcs.tex 28 Nov 2001 07:26:15 -0000 1.43 --- libexcs.tex 28 Mar 2002 20:53:22 -0000 1.44 *************** *** 384,385 **** --- 384,429 ---- Base class for warnings about dubious runtime behavior. \end{excdesc} + + The full Exception class hierarchy is: + + \begin{verbatim} + Exception + +-- SystemExit + +-- StopIteration + +-- StandardError + | +-- KeyboardInterrupt + | +-- ImportError + | +-- EnvironmentError + | | +-- IOError + | | +-- OSError + | | +-- WindowsError + | +-- EOFError + | +-- RuntimeError + | | +-- NotImplementedError + | +-- NameError + | | +-- UnboundLocalError + | +-- AttributeError + | +-- SyntaxError + | | +-- IndentationError + | | +-- TabError + | +-- TypeError + | +-- AssertionError + | +-- LookupError + | | +-- IndexError + | | +-- KeyError + | +-- ArithmeticError + | | +-- OverflowError + | | +-- ZeroDivisionError + | | +-- FloatingPointError + | +-- ValueError + | | +-- UnicodeError + | +-- ReferenceError + | +-- SystemError + | +-- MemoryError + +---Warning + +-- UserWarning + +-- DeprecationWarning + +-- SyntaxWarning + +-- OverflowWarning + +-- RuntimeWarning + \end{verbatim} From montanaro@users.sourceforge.net Thu Mar 28 20:57:53 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Thu, 28 Mar 2002 12:57:53 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python exceptions.c,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv20816 Modified Files: exceptions.c Log Message: add comment reminding people about class hierarchy in Doc/lib/libexcs.tex Index: exceptions.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/exceptions.c,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** exceptions.c 3 Mar 2002 21:30:27 -0000 1.29 --- exceptions.c 28 Mar 2002 20:57:51 -0000 1.30 *************** *** 26,29 **** --- 26,34 ---- * compile-time literal concatenation. */ + + /* NOTE: If the exception class hierarchy changes, don't forget to update + * Doc/lib/libexcs.tex! + */ + static char module__doc__[] = From nascheme@users.sourceforge.net Thu Mar 28 21:04:17 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Thu, 28 Mar 2002 13:04:17 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules signalmodule.c,2.64,2.65 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv23064 Modified Files: signalmodule.c Log Message: Add type cast. Index: signalmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/signalmodule.c,v retrieving revision 2.64 retrieving revision 2.65 diff -C2 -d -r2.64 -r2.65 *** signalmodule.c 25 Mar 2002 20:46:46 -0000 2.64 --- signalmodule.c 28 Mar 2002 21:04:14 -0000 2.65 *************** *** 280,284 **** {"getsignal", signal_getsignal, METH_OLDARGS, getsignal_doc}, #ifdef HAVE_PAUSE ! {"pause", signal_pause, METH_NOARGS, pause_doc}, #endif {"default_int_handler", signal_default_int_handler, --- 280,285 ---- {"getsignal", signal_getsignal, METH_OLDARGS, getsignal_doc}, #ifdef HAVE_PAUSE ! {"pause", (PyCFunction)signal_pause, ! METH_NOARGS,pause_doc}, #endif {"default_int_handler", signal_default_int_handler, From nascheme@users.sourceforge.net Thu Mar 28 21:05:40 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Thu, 28 Mar 2002 13:05:40 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.11,2.12 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv23446/Objects Modified Files: obmalloc.c Log Message: Add missing "void" to function. Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.11 retrieving revision 2.12 diff -C2 -d -r2.11 -r2.12 *** obmalloc.c 28 Mar 2002 07:32:11 -0000 2.11 --- obmalloc.c 28 Mar 2002 21:05:38 -0000 2.12 *************** *** 696,700 **** */ static void ! bumpserialno() { ++serialno; --- 696,700 ---- */ static void ! bumpserialno(void) { ++serialno; From nascheme@users.sourceforge.net Thu Mar 28 21:06:19 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Thu, 28 Mar 2002 13:06:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include objimpl.h,2.47,2.48 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv23660/Include Modified Files: objimpl.h Log Message: Add _Py_AS_GC macro. It will be used by the trashcan code on object.c. Index: objimpl.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/objimpl.h,v retrieving revision 2.47 retrieving revision 2.48 diff -C2 -d -r2.47 -r2.48 *** objimpl.h 22 Mar 2002 15:25:18 -0000 2.47 --- objimpl.h 28 Mar 2002 21:06:16 -0000 2.48 *************** *** 236,243 **** extern PyGC_Head _PyGC_generation0; /* Tell the GC to track this object. NB: While the object is tracked the * collector it must be safe to call the ob_traverse method. */ #define _PyObject_GC_TRACK(o) do { \ ! PyGC_Head *g = (PyGC_Head *)(o)-1; \ if (g->gc.gc_next != NULL) \ Py_FatalError("GC object already in linked list"); \ --- 236,245 ---- extern PyGC_Head _PyGC_generation0; + #define _Py_AS_GC(o) ((PyGC_Head *)(o)-1) + /* Tell the GC to track this object. NB: While the object is tracked the * collector it must be safe to call the ob_traverse method. */ #define _PyObject_GC_TRACK(o) do { \ ! PyGC_Head *g = _Py_AS_GC(o); \ if (g->gc.gc_next != NULL) \ Py_FatalError("GC object already in linked list"); \ *************** *** 250,254 **** /* Tell the GC to stop tracking this object. */ #define _PyObject_GC_UNTRACK(o) do { \ ! PyGC_Head *g = (PyGC_Head *)(o)-1; \ g->gc.gc_prev->gc.gc_next = g->gc.gc_next; \ g->gc.gc_next->gc.gc_prev = g->gc.gc_prev; \ --- 252,256 ---- /* Tell the GC to stop tracking this object. */ #define _PyObject_GC_UNTRACK(o) do { \ ! PyGC_Head *g = _Py_AS_GC(o); \ g->gc.gc_prev->gc.gc_next = g->gc.gc_next; \ g->gc.gc_next->gc.gc_prev = g->gc.gc_prev; \ From fdrake@users.sourceforge.net Thu Mar 28 21:06:19 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 28 Mar 2002 13:06:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libexcs.tex,1.44,1.45 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv23661/lib Modified Files: libexcs.tex Log Message: Minor wording change. Index: libexcs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libexcs.tex,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** libexcs.tex 28 Mar 2002 20:53:22 -0000 1.44 --- libexcs.tex 28 Mar 2002 21:06:17 -0000 1.45 *************** *** 385,389 **** \end{excdesc} ! The full Exception class hierarchy is: \begin{verbatim} --- 385,389 ---- \end{excdesc} ! The class hierarchy for built-in exceptions is: \begin{verbatim} From tim_one@users.sourceforge.net Thu Mar 28 21:08:32 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 28 Mar 2002 13:08:32 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_gc.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv24002/python/Lib/test Modified Files: test_gc.py Log Message: New test_traschcan() test in test_gc, which reliably provokes segfaults under 2.0, 2.1 and 2.2. Bugfix candidate. Index: test_gc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_gc.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_gc.py 15 Oct 2001 22:49:27 -0000 1.12 --- test_gc.py 28 Mar 2002 21:08:30 -0000 1.13 *************** *** 172,175 **** --- 172,203 ---- apply(gc.set_threshold, thresholds) + class Ouch: + n = 0 + def __del__(self): + Ouch.n = Ouch.n + 1 + if Ouch.n % 7 == 0: + gc.collect() + + def test_trashcan(): + # "trashcan" is a hack to prevent stack overflow when deallocating + # very deeply nested tuples etc. It works in part by abusing the + # type pointer and refcount fields, and that can yield horrible + # problems when gc tries to traverse the structures. + # If this test fails (as it does in 2.0, 2.1 and 2.2), it will + # most likely die via segfault. + + gc.enable() + N = 200 + for i in range(3): + t = [] + for i in range(N): + t = [t, Ouch()] + u = [] + for i in range(N): + u = [u, Ouch()] + v = {} + for i in range(N): + v = {1: v, 2: Ouch()} + gc.disable() def test_all(): *************** *** 188,191 **** --- 216,220 ---- run_test("__del__", test_del) run_test("saveall", test_saveall) + run_test("trashcan", test_trashcan) def test(): From fdrake@users.sourceforge.net Thu Mar 28 21:17:49 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 28 Mar 2002 13:17:49 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime Makefile,1.3,1.4 datetime.c,1.10,1.11 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv27270 Modified Files: Makefile datetime.c Log Message: Guido says we don't care about Python 2.2 compatibility here, so we can keep the code as clean as possible. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/Makefile,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Makefile 5 Mar 2002 06:44:49 -0000 1.3 --- Makefile 28 Mar 2002 21:17:47 -0000 1.4 *************** *** 1,3 **** ! PYTHON=python2.2 default: check --- 1,3 ---- ! PYTHON=python2.3 default: check Index: datetime.c =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** datetime.c 28 Mar 2002 14:07:43 -0000 1.10 --- datetime.c 28 Mar 2002 21:17:47 -0000 1.11 *************** *** 384,392 **** static PyMethodDef datetime_methods[] = { - #if PY_VERSION_HEX >= 0x02030000 /* Class methods: */ {"now", (PyCFunction)datetime_now, METH_O | METH_CLASS, "Return a new datetime that represents the current time."}, ! #endif /* Instance methods: */ {"isocalendar", (PyCFunction)datetime_isocalendar, METH_NOARGS, --- 384,391 ---- static PyMethodDef datetime_methods[] = { /* Class methods: */ {"now", (PyCFunction)datetime_now, METH_O | METH_CLASS, "Return a new datetime that represents the current time."}, ! /* Instance methods: */ {"isocalendar", (PyCFunction)datetime_isocalendar, METH_NOARGS, *************** *** 407,417 **** - #if PY_VERSION_HEX < 0x02030000 - static PyMethodDef datetime_now_mdef = { - "now", (PyCFunction)datetime_now, METH_O, - "Return a new datetime that represents the current time." - }; - #endif - static char datetime_doc[] = "Basic date/time type."; --- 406,409 ---- *************** *** 490,510 **** return; Py_DECREF(dt); - - #if PY_VERSION_HEX < 0x02030000 - { - PyObject *tmp; - dt = PyCFunction_New(&datetime_now_mdef, NULL); - if (dt == NULL) - return; - tmp = PyClassMethod_New(dt); - Py_DECREF(dt); - if (tmp == NULL) - return; - err = PyDict_SetItemString(d, "now", tmp); - Py_DECREF(tmp); - if (err < 0) - return; - } - #endif m = Py_InitModule3("_datetime", functions, --- 482,485 ---- From tim_one@users.sourceforge.net Thu Mar 28 21:22:27 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 28 Mar 2002 13:22:27 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_gc.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv28635/python/Lib/test Modified Files: test_gc.py Log Message: test_trashcan: reword obscure code. Bugfix candidate. Index: test_gc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_gc.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** test_gc.py 28 Mar 2002 21:08:30 -0000 1.13 --- test_gc.py 28 Mar 2002 21:22:25 -0000 1.14 *************** *** 189,193 **** gc.enable() N = 200 ! for i in range(3): t = [] for i in range(N): --- 189,193 ---- gc.enable() N = 200 ! for count in range(3): t = [] for i in range(N): From akuchling@users.sourceforge.net Thu Mar 28 21:39:18 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Thu, 28 Mar 2002 13:39:18 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0262.txt,1.5,1.6 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv2229 Modified Files: pep-0262.txt Log Message: Add partially-written API Index: pep-0262.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0262.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pep-0262.txt 28 Mar 2002 03:03:28 -0000 1.5 --- pep-0262.txt 28 Mar 2002 21:39:16 -0000 1.6 *************** *** 99,102 **** --- 99,168 ---- + API Description + + There's a single fundamental class, InstallationDatabase. The + code for it lives in distutils/install_db.py. (XXX any + suggestions for alternate locations in the standard library, or an + alternate module name?) + + The InstallationDatabase returns instances of Package that contain + all the information about an installed package. + + XXX Several of the fields in Package are duplicates of ones in + distutils.dist.Distribution. Probably they should be factored out + into the Package class proposed here, but can this be done in a + backward-compatible way? + + InstallationDatabase has the following interface: + + class InstallationDatabase: + def __init__ (self, path=None): + """InstallationDatabase(path:string) + Read the installation database rooted at the specified path. + If path is None, INSTALLDB is used as the default. + """ + + def get_package (self, package_name): + """get_package(package_name:string) : Package + Get the object corresponding to a single package. + """ + + def list_packages (self): + """list_packages() : [Package] + Return a list of all packages installed on the system, + enumerated in no particular order. + """ + + class Package: + """Instance attributes: + name : string + Package name + files : {string : (size:int, perms:int, owner:string, group:string, + digest:string)} + Dictionary mapping the path of a file installed by this package + to information about the file. + + The following fields all come from PEP 241. + + version : distutils.version.Version + Version of this package + platform : [string] + summary : string + description : string + keywords : string + home_page : string + author : string + author_email : string + license : string + """ + + def add_file (self, path): + """add_file(path:string):None + Record the size, ownership, &c., information for an installed file. + XXX as written, this would stat() the file. Should the size/perms/ + checksum all be provided as parameters to this method instead? + """ + + Deliverables From montanaro@users.sourceforge.net Thu Mar 28 22:01:42 2002 From: montanaro@users.sourceforge.net (Skip Montanaro) Date: Thu, 28 Mar 2002 14:01:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/Tools/scripts findsyms.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/scripts In directory usw-pr-cvs1:/tmp/cvs-serv9448 Added Files: findsyms.py Log Message: new script - helps track down symbols exported by modules but not mentioned in the library reference manual --- NEW FILE: findsyms.py --- #!/usr/bin/env python # Released to the public domain by Skip Montanaro, 28 March 2002 """ findsyms.py - try to identify undocumented symbols exported by modules Usage: findsyms.py librefdir For each lib*.tex file in the libref manual source directory, identify which module is documented, import the module if possible, then search the LaTeX source for the symbols global to that module. Report any that don't seem to be documented. Certain exceptions are made to the list of undocumented symbols: * don't mention symbols in which all letters are upper case on the assumption they are manifest constants * don't mention symbols that are themselves modules * don't mention symbols that match those exported by os, math, string, types, or __builtin__ modules Finally, if a name is exported by the module but fails a getattr() lookup, that anomaly is reported. """ import __builtin__ import getopt import glob import math import os import re import string import sys import types import warnings def usage(): print >> sys.stderr, """ usage: %s dir where 'dir' is the Library Reference Manual source directory. """ % os.path.basename(sys.argv[0]) def main(): try: opts, args = getopt.getopt(sys.argv[1:], "") except getopt.error: usage() return if not args: usage() return libdir = args[0] warnings.filterwarnings("error") pat = re.compile(r"\\declaremodule\s*{[^}]*}\s*{([^}]*)}") missing = [] filelist = glob.glob(os.path.join(libdir, "lib*.tex")) filelist.sort() for f in filelist: mod = f[3:-4] if not mod: continue data = open(f).read() mods = re.findall(pat, data) if not mods: print "No module declarations found in", f continue for modname in mods: # skip special modules if modname.startswith("__"): continue try: mod = __import__(modname) except ImportError: missing.append(modname) continue except DeprecationWarning: print "Deprecated module:", modname continue if hasattr(mod, "__all__"): all = mod.__all__ else: all = [k for k in dir(mod) if k[0] != "_"] mentioned = 0 all.sort() for name in all: if data.find(name) == -1: # certain names are predominantly used for testing if name in ("main","test","_test"): continue # is it some sort of manifest constant? if name.upper() == name: continue try: item = getattr(mod, name) except AttributeError: print " ", name, "exposed, but not an attribute" continue # don't care about modules that might be exposed if type(item) == types.ModuleType: continue # check a few modules which tend to be import *'d isglobal = 0 for m in (os, math, string, __builtin__, types): if hasattr(m, name) and item == getattr(m, name): isglobal = 1 break if isglobal: continue if not mentioned: print "Not mentioned in", modname, "docs:" mentioned = 1 print " ", name if missing: missing.sort() print "Could not import:" print " ", ", ".join(missing) if __name__ == "__main__": try: main() except KeyboardInterrupt: pass From fdrake@users.sourceforge.net Thu Mar 28 22:28:45 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 28 Mar 2002 14:28:45 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/texinputs python.sty,1.91,1.92 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory usw-pr-cvs1:/tmp/cvs-serv16268/texinputs Modified Files: python.sty Log Message: Extend \verbatiminput so that the typeset version provides the same appearance as a verbatim environment. (The HTML version is already fine.) Index: python.sty =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/python.sty,v retrieving revision 1.91 retrieving revision 1.92 diff -C2 -d -r1.91 -r1.92 *** python.sty 26 Mar 2002 19:14:41 -0000 1.91 --- python.sty 28 Mar 2002 22:28:43 -0000 1.92 *************** *** 176,179 **** --- 176,180 ---- \let\py@OldEndVerbatim=\endverbatim \RequirePackage{verbatim} + \let\py@OldVerbatimInput=\verbatiminput % Variable used by begin code command *************** *** 194,197 **** --- 195,211 ---- \py@OldEndVerbatim% \end{minipage}% + } + \renewcommand{\verbatiminput}[1]{% + {\setlength{\parindent}{1cm}% + % Calculate the text width for the minipage: + \setlength{\py@codewidth}{\linewidth}% + \addtolength{\py@codewidth}{-\parindent}% + % + \small% + \begin{list}{}{\setlength{\leftmargin}{1cm}} + \item% + \py@OldVerbatimInput{#1}% + \end{list} + }% } From fdrake@users.sourceforge.net Thu Mar 28 22:36:59 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 28 Mar 2002 14:36:59 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ext extending.tex,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory usw-pr-cvs1:/tmp/cvs-serv18622 Modified Files: extending.tex Log Message: Added index entries. Index: extending.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/extending.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** extending.tex 28 Mar 2002 20:19:23 -0000 1.13 --- extending.tex 28 Mar 2002 22:36:56 -0000 1.14 *************** *** 593,596 **** --- 593,598 ---- \label{parseTuple}} + \ttindex{PyArg_ParseTuple()} + The \cfunction{PyArg_ParseTuple()} function is declared as follows: *************** *** 937,940 **** --- 939,944 ---- \section{Keyword Parameters for Extension Functions \label{parseTupleAndKeywords}} + + \ttindex{PyArg_ParseTupleAndKeywords()} The \cfunction{PyArg_ParseTupleAndKeywords()} function is declared as From jhylton@users.sourceforge.net Thu Mar 28 23:01:58 2002 From: jhylton@users.sourceforge.net (Jeremy Hylton) Date: Thu, 28 Mar 2002 15:01:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib inspect.py,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv25488 Modified Files: inspect.py Log Message: Fix getcomments() so that it doesn't fail with TypeErrors. It appears that getcomments() can get called for classes defined in C. Since these don't have source code, it can't do anything useful. A function buried many levels deep was raising a TypeError that was not caught. Who knows why this broke... Index: inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** inspect.py 25 Mar 2002 21:37:54 -0000 1.30 --- inspect.py 28 Mar 2002 23:01:56 -0000 1.31 *************** *** 417,423 **** def getcomments(object): ! """Get lines of comments immediately preceding an object's source code.""" ! try: lines, lnum = findsource(object) ! except IOError: return None if ismodule(object): --- 417,428 ---- def getcomments(object): ! """Get lines of comments immediately preceding an object's source code. ! ! Returns None when source can't be found. ! """ ! try: ! lines, lnum = findsource(object) ! except (IOError, TypeError): ! return None if ismodule(object): From fdrake@users.sourceforge.net Thu Mar 28 23:12:11 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 28 Mar 2002 15:12:11 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ext newtypes.tex,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory usw-pr-cvs1:/tmp/cvs-serv28605/ext Modified Files: newtypes.tex Log Message: Move some of the longer example code to external fragments, and include them using \verbatiminput. This has the advantage that pages can still break at reasonable places, and examples that go longer than a page won't get cut off. Make a few small markup adjustments for consistency. Explain that PyObject_New() is not a C function but a polymorphic beast that returns a pointer to the type that's passed as the first arg. Explain why type objects use the PyObject_VAR_HEAD. Index: newtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/newtypes.tex,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** newtypes.tex 13 Mar 2002 03:55:11 -0000 1.8 --- newtypes.tex 28 Mar 2002 23:12:09 -0000 1.9 *************** *** 31,94 **** minimal, but complete, module that defines a new type: ! \begin{verbatim} ! #include ! ! staticforward PyTypeObject noddy_NoddyType; ! ! typedef struct { ! PyObject_HEAD ! } noddy_NoddyObject; ! ! static PyObject* ! noddy_new_noddy(PyObject* self, PyObject* args) ! { ! noddy_NoddyObject* noddy; ! ! if (!PyArg_ParseTuple(args,":new_noddy")) ! return NULL; ! ! noddy = PyObject_New(noddy_NoddyObject, &noddy_NoddyType); ! ! return (PyObject*)noddy; ! } ! ! static void ! noddy_noddy_dealloc(PyObject* self) ! { ! PyObject_Del(self); ! } ! ! static PyTypeObject noddy_NoddyType = { ! PyObject_HEAD_INIT(NULL) ! 0, ! "Noddy", ! sizeof(noddy_NoddyObject), ! 0, ! noddy_noddy_dealloc, /*tp_dealloc*/ ! 0, /*tp_print*/ ! 0, /*tp_getattr*/ ! 0, /*tp_setattr*/ ! 0, /*tp_compare*/ ! 0, /*tp_repr*/ ! 0, /*tp_as_number*/ ! 0, /*tp_as_sequence*/ ! 0, /*tp_as_mapping*/ ! 0, /*tp_hash */ ! }; ! ! static PyMethodDef noddy_methods[] = { ! {"new_noddy", noddy_new_noddy, METH_VARARGS, ! "Create a new Noddy object."}, ! {NULL, NULL, 0, NULL} ! }; ! ! DL_EXPORT(void) ! initnoddy(void) ! { ! noddy_NoddyType.ob_type = &PyType_Type; ! ! Py_InitModule("noddy", noddy_methods); ! } ! \end{verbatim} Now that's quite a bit to take in at once, but hopefully bits will --- 31,35 ---- minimal, but complete, module that defines a new type: ! \verbatiminput{noddy.c} Now that's quite a bit to take in at once, but hopefully bits will *************** *** 151,157 **** This is in fact just a regular module function, as described in the last chapter. The reason it gets special mention is that this is ! where we create our Noddy object. Defining PyTypeObject structures is ! all very well, but if there's no way to actually \emph{create} one ! of the wretched things it is not going to do anyone much good. Almost always, you create objects with a call of the form: --- 92,99 ---- This is in fact just a regular module function, as described in the last chapter. The reason it gets special mention is that this is ! where we create our Noddy object. Defining \ctype{PyTypeObject} ! structures is all very well, but if there's no way to actually ! \emph{create} one of the wretched things it is not going to do anyone ! much good. Almost always, you create objects with a call of the form: *************** *** 162,170 **** This allocates the memory and then initializes the object (sets ! the reference count to one, makes the \cdata{ob_type} pointer point at the right place and maybe some other stuff, depending on build options). You \emph{can} do these steps separately if you have some reason to --- but at this level we don't bother. We cast the return value to a \ctype{PyObject*} because that's what the Python runtime expects. This is safe because of guarantees about --- 104,124 ---- This allocates the memory and then initializes the object (sets ! the reference count to one, makes the \member{ob_type} pointer point at the right place and maybe some other stuff, depending on build options). You \emph{can} do these steps separately if you have some reason to --- but at this level we don't bother. + Note that \cfunction{PyObject_New()} is a polymorphic macro rather + than a real function. The first parameter is the name of the C + structure that represents an object of our new type, and the return + value is a pointer to that type. This would be + \ctype{noddy_NoddyObject} in our example: + + \begin{verbatim} + noddy_NoddyObject *my_noddy; + + my_noddy = PyObject_New(noddy_NoddyObject, &noddy_NoddyType); + \end{verbatim} + We cast the return value to a \ctype{PyObject*} because that's what the Python runtime expects. This is safe because of guarantees about *************** *** 237,241 **** as the type of a type object is ``type'', but this isn't strictly conforming C and some compilers complain. So instead we fill in the ! \cdata{ob_type} field of \cdata{noddy_NoddyType} at the earliest oppourtunity --- in \cfunction{initnoddy()}. --- 191,195 ---- as the type of a type object is ``type'', but this isn't strictly conforming C and some compilers complain. So instead we fill in the ! \member{ob_type} field of \cdata{noddy_NoddyType} at the earliest oppourtunity --- in \cfunction{initnoddy()}. *************** *** 244,248 **** \end{verbatim} ! XXX why does the type info struct start PyObject_*VAR*_HEAD?? \begin{verbatim} --- 198,205 ---- \end{verbatim} ! The \member{ob_size} field of the header is not used; it's presence in ! the type structure is a historical artifact that is maintained for ! binary compatibility with extension modules compiled for older ! versions of Python. Always set this field to zero. \begin{verbatim} *************** *** 283,288 **** \end{verbatim} ! From here, all the type methods are nil so I won't go over them yet - ! that's for the next section! Everything else in the file should be familiar, except for this line --- 240,245 ---- \end{verbatim} ! From here, all the type methods are \NULL, so I won't go over them yet ! --- that's for the next section! Everything else in the file should be familiar, except for this line *************** *** 303,308 **** \begin{verbatim} from distutils.core import setup, Extension ! setup(name = "noddy", version = "1.0", ! ext_modules = [Extension("noddy", ["noddymodule.c"])]) \end{verbatim} --- 260,265 ---- \begin{verbatim} from distutils.core import setup, Extension ! setup(name="noddy", version="1.0", ! ext_modules=[Extension("noddy", ["noddymodule.c"])]) \end{verbatim} *************** *** 310,315 **** \begin{verbatim} ! $ python setup.py build%$ ! \end{verbatim} at a shell should produce a file \file{noddy.so} in a subdirectory; --- 267,272 ---- \begin{verbatim} ! $ python setup.py build ! \end{verbatim} %$ <-- bow to font-lock ;-( at a shell should produce a file \file{noddy.so} in a subdirectory; *************** *** 329,407 **** used in debug builds omitted: ! \begin{verbatim} ! typedef struct _typeobject { ! PyObject_VAR_HEAD ! char *tp_name; /* For printing */ ! int tp_basicsize, tp_itemsize; /* For allocation */ ! ! /* Methods to implement standard operations */ ! ! destructor tp_dealloc; ! printfunc tp_print; ! getattrfunc tp_getattr; ! setattrfunc tp_setattr; ! cmpfunc tp_compare; ! reprfunc tp_repr; ! ! /* Method suites for standard classes */ ! ! PyNumberMethods *tp_as_number; ! PySequenceMethods *tp_as_sequence; ! PyMappingMethods *tp_as_mapping; ! ! /* More standard operations (here for binary compatibility) */ ! ! hashfunc tp_hash; ! ternaryfunc tp_call; ! reprfunc tp_str; ! getattrofunc tp_getattro; ! setattrofunc tp_setattro; ! ! /* Functions to access object as input/output buffer */ ! PyBufferProcs *tp_as_buffer; ! ! /* Flags to define presence of optional/expanded features */ ! long tp_flags; ! ! char *tp_doc; /* Documentation string */ ! ! /* Assigned meaning in release 2.0 */ ! /* call function for all accessible objects */ ! traverseproc tp_traverse; ! ! /* delete references to contained objects */ ! inquiry tp_clear; ! ! /* Assigned meaning in release 2.1 */ ! /* rich comparisons */ ! richcmpfunc tp_richcompare; ! ! /* weak reference enabler */ ! long tp_weaklistoffset; ! ! /* Added in release 2.2 */ ! /* Iterators */ ! getiterfunc tp_iter; ! iternextfunc tp_iternext; ! ! /* Attribute descriptor and subclassing stuff */ ! struct PyMethodDef *tp_methods; ! struct memberlist *tp_members; ! struct getsetlist *tp_getset; ! struct _typeobject *tp_base; ! PyObject *tp_dict; ! descrgetfunc tp_descr_get; ! descrsetfunc tp_descr_set; ! long tp_dictoffset; ! initproc tp_init; ! allocfunc tp_alloc; ! newfunc tp_new; ! destructor tp_free; /* Low-level free-memory routine */ ! PyObject *tp_bases; ! PyObject *tp_mro; /* method resolution order */ ! PyObject *tp_defined; ! ! } PyTypeObject; ! \end{verbatim} Now that's a \emph{lot} of methods. Don't worry too much though - if --- 286,290 ---- used in debug builds omitted: ! \verbatiminput{typestruct.h} Now that's a \emph{lot} of methods. Don't worry too much though - if *************** *** 433,437 **** objects of this typed are created. Python has some builtin support for variable length structures (think: strings, lists) which is where ! the \cdata{tp_itemsize} field comes in. This will be dealt with later. --- 316,320 ---- objects of this typed are created. Python has some builtin support for variable length structures (think: strings, lists) which is where ! the \member{tp_itemsize} field comes in. This will be dealt with later. From tim_one@users.sourceforge.net Thu Mar 28 23:18:12 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 28 Mar 2002 15:18:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_gc.py,1.12,1.12.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv30082/221/Lib/test Modified Files: Tag: release22-maint test_gc.py Log Message: Backport of a new test to check the interaction between cyclic GC and the trashcan mechanism. Index: test_gc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_gc.py,v retrieving revision 1.12 retrieving revision 1.12.10.1 diff -C2 -d -r1.12 -r1.12.10.1 *** test_gc.py 15 Oct 2001 22:49:27 -0000 1.12 --- test_gc.py 28 Mar 2002 23:18:08 -0000 1.12.10.1 *************** *** 172,175 **** --- 172,203 ---- apply(gc.set_threshold, thresholds) + class Ouch: + n = 0 + def __del__(self): + Ouch.n = Ouch.n + 1 + if Ouch.n % 7 == 0: + gc.collect() + + def test_trashcan(): + # "trashcan" is a hack to prevent stack overflow when deallocating + # very deeply nested tuples etc. It works in part by abusing the + # type pointer and refcount fields, and that can yield horrible + # problems when gc tries to traverse the structures. + # If this test fails (as it does in 2.0, 2.1 and 2.2), it will + # most likely die via segfault. + + gc.enable() + N = 200 + for count in range(3): + t = [] + for i in range(N): + t = [t, Ouch()] + u = [] + for i in range(N): + u = [u, Ouch()] + v = {} + for i in range(N): + v = {1: v, 2: Ouch()} + gc.disable() def test_all(): *************** *** 188,191 **** --- 216,220 ---- run_test("__del__", test_del) run_test("saveall", test_saveall) + run_test("trashcan", test_trashcan) def test(): From fdrake@users.sourceforge.net Thu Mar 28 23:32:55 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 28 Mar 2002 15:32:55 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ext noddy.c,NONE,1.1 typestruct.h,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory usw-pr-cvs1:/tmp/cvs-serv1381/ext Added Files: noddy.c typestruct.h Log Message: The new files included by \verbatiminput in newtypes.tex. --- NEW FILE: noddy.c --- #include staticforward PyTypeObject noddy_NoddyType; typedef struct { PyObject_HEAD } noddy_NoddyObject; static PyObject* noddy_new_noddy(PyObject* self, PyObject* args) { noddy_NoddyObject* noddy; if (!PyArg_ParseTuple(args,":new_noddy")) return NULL; noddy = PyObject_New(noddy_NoddyObject, &noddy_NoddyType); return (PyObject*)noddy; } static void noddy_noddy_dealloc(PyObject* self) { PyObject_Del(self); } static PyTypeObject noddy_NoddyType = { PyObject_HEAD_INIT(NULL) 0, "Noddy", sizeof(noddy_NoddyObject), 0, noddy_noddy_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash */ }; static PyMethodDef noddy_methods[] = { {"new_noddy", noddy_new_noddy, METH_VARARGS, "Create a new Noddy object."}, {NULL, NULL, 0, NULL} }; DL_EXPORT(void) initnoddy(void) { noddy_NoddyType.ob_type = &PyType_Type; Py_InitModule("noddy", noddy_methods); } --- NEW FILE: typestruct.h --- typedef struct _typeobject { PyObject_VAR_HEAD char *tp_name; /* For printing, in format "." */ int tp_basicsize, tp_itemsize; /* For allocation */ /* Methods to implement standard operations */ destructor tp_dealloc; printfunc tp_print; getattrfunc tp_getattr; setattrfunc tp_setattr; cmpfunc tp_compare; reprfunc tp_repr; /* Method suites for standard classes */ PyNumberMethods *tp_as_number; PySequenceMethods *tp_as_sequence; PyMappingMethods *tp_as_mapping; /* More standard operations (here for binary compatibility) */ hashfunc tp_hash; ternaryfunc tp_call; reprfunc tp_str; getattrofunc tp_getattro; setattrofunc tp_setattro; /* Functions to access object as input/output buffer */ PyBufferProcs *tp_as_buffer; /* Flags to define presence of optional/expanded features */ long tp_flags; char *tp_doc; /* Documentation string */ /* Assigned meaning in release 2.0 */ /* call function for all accessible objects */ traverseproc tp_traverse; /* delete references to contained objects */ inquiry tp_clear; /* Assigned meaning in release 2.1 */ /* rich comparisons */ richcmpfunc tp_richcompare; /* weak reference enabler */ long tp_weaklistoffset; /* Added in release 2.2 */ /* Iterators */ getiterfunc tp_iter; iternextfunc tp_iternext; /* Attribute descriptor and subclassing stuff */ struct PyMethodDef *tp_methods; struct memberlist *tp_members; struct getsetlist *tp_getset; struct _typeobject *tp_base; PyObject *tp_dict; descrgetfunc tp_descr_get; descrsetfunc tp_descr_set; long tp_dictoffset; initproc tp_init; allocfunc tp_alloc; newfunc tp_new; destructor tp_free; /* Low-level free-memory routine */ inquiry tp_is_gc; /* For PyObject_IS_GC */ PyObject *tp_bases; PyObject *tp_mro; /* method resolution order */ PyObject *tp_cache; PyObject *tp_subclasses; PyObject *tp_weaklist; } PyTypeObject; From fdrake@users.sourceforge.net Thu Mar 28 23:45:24 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 28 Mar 2002 15:45:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ext newtypes.tex,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory usw-pr-cvs1:/tmp/cvs-serv4840/ext Modified Files: newtypes.tex Log Message: Added comments for more entries of the type structure in the example type implementation. Index: newtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/newtypes.tex,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** newtypes.tex 28 Mar 2002 23:12:09 -0000 1.9 --- newtypes.tex 28 Mar 2002 23:45:22 -0000 1.10 *************** *** 153,170 **** static PyTypeObject noddy_NoddyType = { PyObject_HEAD_INIT(NULL) ! 0, ! "Noddy", ! sizeof(noddy_NoddyObject), ! 0, ! noddy_noddy_dealloc, /*tp_dealloc*/ ! 0, /*tp_print*/ ! 0, /*tp_getattr*/ ! 0, /*tp_setattr*/ ! 0, /*tp_compare*/ ! 0, /*tp_repr*/ ! 0, /*tp_as_number*/ ! 0, /*tp_as_sequence*/ ! 0, /*tp_as_mapping*/ ! 0, /*tp_hash */ }; \end{verbatim} --- 153,170 ---- static PyTypeObject noddy_NoddyType = { PyObject_HEAD_INIT(NULL) ! 0, /* ob_size */ ! "Noddy", /* tp_name */ ! sizeof(noddy_NoddyObject), /* tp_basicsize */ ! 0, /* tp_itemsize */ ! noddy_noddy_dealloc, /* tp_dealloc */ ! 0, /* tp_print */ ! 0, /* tp_getattr */ ! 0, /* tp_setattr */ ! 0, /* tp_compare */ ! 0, /* tp_repr */ ! 0, /* tp_as_number */ ! 0, /* tp_as_sequence */ ! 0, /* tp_as_mapping */ ! 0, /* tp_hash */ }; \end{verbatim} *************** *** 195,199 **** \begin{verbatim} ! 0, \end{verbatim} --- 195,199 ---- \begin{verbatim} ! 0, /* ob_size */ \end{verbatim} *************** *** 204,208 **** \begin{verbatim} ! "Noddy", \end{verbatim} --- 204,208 ---- \begin{verbatim} ! "Noddy", /* tp_name */ \end{verbatim} *************** *** 218,222 **** \begin{verbatim} ! sizeof(noddy_NoddyObject), \end{verbatim} --- 218,222 ---- \begin{verbatim} ! sizeof(noddy_NoddyObject), /* tp_basicsize */ \end{verbatim} *************** *** 225,229 **** \begin{verbatim} ! 0, \end{verbatim} --- 225,229 ---- \begin{verbatim} ! 0, /* tp_itemsize */ \end{verbatim} *************** *** 237,241 **** \begin{verbatim} ! noddy_noddy_dealloc, /*tp_dealloc*/ \end{verbatim} --- 237,241 ---- \begin{verbatim} ! noddy_noddy_dealloc, /* tp_dealloc */ \end{verbatim} From fdrake@users.sourceforge.net Thu Mar 28 23:46:43 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Thu, 28 Mar 2002 15:46:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ext extending.tex,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory usw-pr-cvs1:/tmp/cvs-serv5168/ext Modified Files: extending.tex Log Message: Mark a couple of types that had not been marked. Index: extending.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/extending.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** extending.tex 28 Mar 2002 22:36:56 -0000 1.14 --- extending.tex 28 Mar 2002 23:46:41 -0000 1.15 *************** *** 664,671 **** \item[\samp{u} (Unicode object) {[Py_UNICODE *]}] Convert a Python Unicode object to a C pointer to a null-terminated ! buffer of 16-bit Unicode (UTF-16) data. As with \samp{s}, there is no need ! to provide storage for the Unicode data buffer; a pointer to the ! existing Unicode data is stored into the Py_UNICODE pointer variable whose ! address you pass. \item[\samp{u\#} (Unicode object) {[Py_UNICODE *, int]}] --- 664,671 ---- \item[\samp{u} (Unicode object) {[Py_UNICODE *]}] Convert a Python Unicode object to a C pointer to a null-terminated ! buffer of 16-bit Unicode (UTF-16) data. As with \samp{s}, there is no ! need to provide storage for the Unicode data buffer; a pointer to the ! existing Unicode data is stored into the \ctype{Py_UNICODE} pointer ! variable whose address you pass. \item[\samp{u\#} (Unicode object) {[Py_UNICODE *, int]}] *************** *** 673,677 **** a pointer to a Unicode data buffer, the second one its length. Non-Unicode objects are handled by interpreting their read buffer ! pointer as pointer to a Py_UNICODE array. \item[\samp{es} (string, Unicode object or character buffer compatible --- 673,677 ---- a pointer to a Unicode data buffer, the second one its length. Non-Unicode objects are handled by interpreting their read buffer ! pointer as pointer to a \ctype{Py_UNICODE} array. \item[\samp{es} (string, Unicode object or character buffer compatible From gvanrossum@users.sourceforge.net Fri Mar 29 01:05:12 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Thu, 28 Mar 2002 17:05:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.337.2.4.2.12,1.337.2.4.2.13 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv25122 Modified Files: Tag: release22-maint NEWS Log Message: News for SF #535905. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.337.2.4.2.12 retrieving revision 1.337.2.4.2.13 diff -C2 -d -r1.337.2.4.2.12 -r1.337.2.4.2.13 *** NEWS 26 Mar 2002 13:22:23 -0000 1.337.2.4.2.12 --- NEWS 29 Mar 2002 01:05:09 -0000 1.337.2.4.2.13 *************** *** 1,2 **** --- 1,15 ---- + What's New in Python 2.2.1 final? + Release date: XX-Apr-2002 + ================================= + + Core + + - Fixed two bugs reported as SF #535905: under certain conditions, + deallocating a deeply nested structure could cause a segfault in the + garbage collector, due to interaction with the "trashcan" code; + access to the current frame during destruction of a local variable + could access a pointer to freed memory. + + What's New in Python 2.2.1c2? Release date: 26-Mar-2002 From gvanrossum@users.sourceforge.net Fri Mar 29 01:07:26 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Thu, 28 Mar 2002 17:07:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.369,1.370 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv25629 Modified Files: NEWS Log Message: News for SF #535905. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.369 retrieving revision 1.370 diff -C2 -d -r1.369 -r1.370 *** NEWS 27 Mar 2002 18:49:02 -0000 1.369 --- NEWS 29 Mar 2002 01:07:24 -0000 1.370 *************** *** 7,10 **** --- 7,16 ---- Core and builtins + - Fixed two bugs reported as SF #535905: under certain conditions, + deallocating a deeply nested structure could cause a segfault in the + garbage collector, due to interaction with the "trashcan" code; + access to the current frame during destruction of a local variable + could access a pointer to freed memory. + - The optional object allocator has been enabled by default. From gvanrossum@users.sourceforge.net Fri Mar 29 01:06:37 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Thu, 28 Mar 2002 17:06:37 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.146.2.9,1.146.2.10 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv25444 Modified Files: Tag: release21-maint NEWS Log Message: News for SF #535905. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.146.2.9 retrieving revision 1.146.2.10 diff -C2 -d -r1.146.2.9 -r1.146.2.10 *** NEWS 15 Jan 2002 22:13:16 -0000 1.146.2.9 --- NEWS 29 Mar 2002 01:06:35 -0000 1.146.2.10 *************** *** 1,2 **** --- 1,15 ---- + What's New in Python 2.1.3? + Release date: XX-XXX-XXXX + =========================== + + Core + + - Fixed two bugs reported as SF #535905: under certain conditions, + deallocating a deeply nested structure could cause a segfault in the + garbage collector, due to interaction with the "trashcan" code; + access to the current frame during destruction of a local variable + could access a pointer to freed memory. + + What's New in Python 2.1.2 (final)? =================================== From nascheme@users.sourceforge.net Fri Mar 29 03:04:28 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Thu, 28 Mar 2002 19:04:28 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules gcmodule.c,2.37,2.38 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv17618/Modules Modified Files: gcmodule.c Log Message: Make _PyObject_GC_UnTrack do nothing if WITH_CYCLE_GC is not defined. Index: gcmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v retrieving revision 2.37 retrieving revision 2.38 diff -C2 -d -r2.37 -r2.38 *** gcmodule.c 28 Mar 2002 20:34:58 -0000 2.37 --- gcmodule.c 29 Mar 2002 03:04:25 -0000 2.38 *************** *** 820,826 **** --- 820,828 ---- _PyObject_GC_UnTrack(PyObject *op) { + #ifdef WITH_CYCLE_GC PyGC_Head *gc = AS_GC(op); if (gc->gc.gc_next != NULL) _PyObject_GC_UNTRACK(op); + #endif } From nascheme@users.sourceforge.net Fri Mar 29 03:05:57 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Thu, 28 Mar 2002 19:05:57 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects object.c,2.168,2.169 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv17993/Objects Modified Files: object.c Log Message: If the GC is enabled then don't use the ob_type pointer to create a list of trash objects. Use the gc_prev pointer instead. Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.168 retrieving revision 2.169 diff -C2 -d -r2.168 -r2.169 *** object.c 23 Mar 2002 00:20:15 -0000 2.168 --- object.c 29 Mar 2002 03:05:54 -0000 2.169 *************** *** 2038,2041 **** --- 2038,2042 ---- _PyTrash_deposit_object(PyObject *op) { + #ifndef WITH_CYCLE_GC int typecode; *************** *** 2055,2060 **** } op->ob_refcnt = typecode; - op->ob_type = (PyTypeObject*)_PyTrash_delete_later; _PyTrash_delete_later = op; } --- 2056,2064 ---- } op->ob_refcnt = typecode; op->ob_type = (PyTypeObject*)_PyTrash_delete_later; + #else + assert (_Py_AS_GC(op)->gc.gc_next == NULL); + _Py_AS_GC(op)->gc.gc_prev = (PyGC_Head *)_PyTrash_delete_later; + #endif _PyTrash_delete_later = op; } *************** *** 2065,2068 **** --- 2069,2074 ---- while (_PyTrash_delete_later) { PyObject *shredder = _PyTrash_delete_later; + + #ifndef WITH_CYCLE_GC _PyTrash_delete_later = (PyObject*) shredder->ob_type; *************** *** 2084,2087 **** --- 2090,2098 ---- break; } + #else + _PyTrash_delete_later = + (PyObject*) _Py_AS_GC(shredder)->gc.gc_prev; + #endif + _Py_NewReference(shredder); From nascheme@users.sourceforge.net Fri Mar 29 03:07:31 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Thu, 28 Mar 2002 19:07:31 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python traceback.c,2.36,2.37 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv18310/Python Modified Files: traceback.c Log Message: Call PyObject_GC_UnTrack before putting an object on the list of trash. Index: traceback.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/traceback.c,v retrieving revision 2.36 retrieving revision 2.37 diff -C2 -d -r2.36 -r2.37 *** traceback.c 28 Nov 2001 20:42:20 -0000 2.36 --- traceback.c 29 Mar 2002 03:07:29 -0000 2.37 *************** *** 36,41 **** tb_dealloc(tracebackobject *tb) { Py_TRASHCAN_SAFE_BEGIN(tb) - _PyObject_GC_UNTRACK(tb); Py_XDECREF(tb->tb_next); Py_XDECREF(tb->tb_frame); --- 36,41 ---- tb_dealloc(tracebackobject *tb) { + PyObject_GC_UnTrack(tb); Py_TRASHCAN_SAFE_BEGIN(tb) Py_XDECREF(tb->tb_next); Py_XDECREF(tb->tb_frame); *************** *** 121,125 **** tb->tb_lasti = lasti; tb->tb_lineno = lineno; ! _PyObject_GC_TRACK(tb); } return tb; --- 121,125 ---- tb->tb_lasti = lasti; tb->tb_lineno = lineno; ! PyObject_GC_Track(tb); } return tb; From tim_one@users.sourceforge.net Fri Mar 29 03:29:09 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 28 Mar 2002 19:29:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include stringobject.h,2.32,2.33 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv21495/python/Include Modified Files: stringobject.h Log Message: Remove the CACHE_HASH and INTERN_STRINGS preprocessor symbols. Index: stringobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/stringobject.h,v retrieving revision 2.32 retrieving revision 2.33 diff -C2 -d -r2.32 -r2.33 *** stringobject.h 23 Oct 2001 02:21:03 -0000 2.32 --- stringobject.h 29 Mar 2002 03:29:07 -0000 2.33 *************** *** 25,50 **** */ ! /* Two speedup hacks. Caching the hash saves recalculation of a ! string's hash value. Interning strings (which requires hash ! caching) tries to ensure that only one string object with a given ! value exists, so equality tests are one pointer comparison. ! Together, these can speed the interpreter up by as much as 20%. ! Each costs the size of a long or pointer per string object. In ! addition, interned strings live until the end of times. If you are ! concerned about memory footprint, simply comment the #define out ! here (and rebuild everything!). */ ! #define CACHE_HASH ! #ifdef CACHE_HASH ! #define INTERN_STRINGS ! #endif typedef struct { PyObject_VAR_HEAD - #ifdef CACHE_HASH long ob_shash; - #endif - #ifdef INTERN_STRINGS PyObject *ob_sinterned; - #endif char ob_sval[1]; } PyStringObject; --- 25,40 ---- */ ! /* Caching the hash (ob_shash) saves recalculation of a string's hash value. ! Interning strings (ob_sinterned) tries to ensure that only one string ! object with a given value exists, so equality tests can be one pointer ! comparison. This is generally restricted to strings that "look like" ! Python identifiers, although the intern() builtin can be used to force ! interning of any string. ! Together, these sped the interpreter by up to 20%. */ typedef struct { PyObject_VAR_HEAD long ob_shash; PyObject *ob_sinterned; char ob_sval[1]; } PyStringObject; *************** *** 71,83 **** int, char**, int*); - #ifdef INTERN_STRINGS extern DL_IMPORT(void) PyString_InternInPlace(PyObject **); extern DL_IMPORT(PyObject *) PyString_InternFromString(const char *); extern DL_IMPORT(void) _Py_ReleaseInternedStrings(void); - #else - #define PyString_InternInPlace(p) - #define PyString_InternFromString(cp) PyString_FromString(cp) - #define _Py_ReleaseInternedStrings() - #endif /* Macro, trading safety for speed */ --- 61,67 ---- From tim_one@users.sourceforge.net Fri Mar 29 03:29:10 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 28 Mar 2002 19:29:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects bufferobject.c,2.16,2.17 dictobject.c,2.121,2.122 stringobject.c,2.151,2.152 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv21495/python/Objects Modified Files: bufferobject.c dictobject.c stringobject.c Log Message: Remove the CACHE_HASH and INTERN_STRINGS preprocessor symbols. Index: bufferobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/bufferobject.c,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -d -r2.16 -r2.17 *** bufferobject.c 19 Oct 2001 13:49:35 -0000 2.16 --- bufferobject.c 29 Mar 2002 03:29:07 -0000 2.17 *************** *** 11,17 **** int b_size; int b_readonly; - #ifdef CACHE_HASH long b_hash; - #endif } PyBufferObject; --- 11,15 ---- *************** *** 37,43 **** b->b_size = size; b->b_readonly = readonly; - #ifdef CACHE_HASH b->b_hash = -1; - #endif return (PyObject *) b; --- 35,39 ---- *************** *** 153,159 **** b->b_size = size; b->b_readonly = 0; - #ifdef CACHE_HASH b->b_hash = -1; - #endif return o; --- 149,153 ---- *************** *** 212,219 **** register long x; - #ifdef CACHE_HASH if ( self->b_hash != -1 ) return self->b_hash; - #endif if ( !self->b_readonly ) --- 206,211 ---- *************** *** 232,238 **** if (x == -1) x = -2; - #ifdef CACHE_HASH self->b_hash = x; - #endif return x; } --- 224,228 ---- Index: dictobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v retrieving revision 2.121 retrieving revision 2.122 diff -C2 -d -r2.121 -r2.122 *** dictobject.c 28 Mar 2002 20:34:58 -0000 2.121 --- dictobject.c 29 Mar 2002 03:29:07 -0000 2.122 *************** *** 481,488 **** return NULL; } - #ifdef CACHE_HASH if (!PyString_CheckExact(key) || (hash = ((PyStringObject *) key)->ob_shash) == -1) - #endif { hash = PyObject_Hash(key); --- 481,486 ---- *************** *** 513,526 **** } mp = (dictobject *)op; - #ifdef CACHE_HASH if (PyString_CheckExact(key)) { - #ifdef INTERN_STRINGS if (((PyStringObject *)key)->ob_sinterned != NULL) { key = ((PyStringObject *)key)->ob_sinterned; hash = ((PyStringObject *)key)->ob_shash; } ! else ! #endif ! { hash = ((PyStringObject *)key)->ob_shash; if (hash == -1) --- 511,520 ---- } mp = (dictobject *)op; if (PyString_CheckExact(key)) { if (((PyStringObject *)key)->ob_sinterned != NULL) { key = ((PyStringObject *)key)->ob_sinterned; hash = ((PyStringObject *)key)->ob_shash; } ! else { hash = ((PyStringObject *)key)->ob_shash; if (hash == -1) *************** *** 528,534 **** } } ! else ! #endif ! { hash = PyObject_Hash(key); if (hash == -1) --- 522,526 ---- } } ! else { hash = PyObject_Hash(key); if (hash == -1) *************** *** 565,573 **** return -1; } - #ifdef CACHE_HASH if (!PyString_CheckExact(key) || ! (hash = ((PyStringObject *) key)->ob_shash) == -1) ! #endif ! { hash = PyObject_Hash(key); if (hash == -1) --- 557,562 ---- return -1; } if (!PyString_CheckExact(key) || ! (hash = ((PyStringObject *) key)->ob_shash) == -1) { hash = PyObject_Hash(key); if (hash == -1) *************** *** 845,853 **** long hash; assert(mp->ma_table != NULL); - #ifdef CACHE_HASH if (!PyString_CheckExact(key) || ! (hash = ((PyStringObject *) key)->ob_shash) == -1) ! #endif ! { hash = PyObject_Hash(key); if (hash == -1) --- 834,839 ---- long hash; assert(mp->ma_table != NULL); if (!PyString_CheckExact(key) || ! (hash = ((PyStringObject *) key)->ob_shash) == -1) { hash = PyObject_Hash(key); if (hash == -1) *************** *** 1437,1445 **** long hash; register long ok; - #ifdef CACHE_HASH if (!PyString_CheckExact(key) || ! (hash = ((PyStringObject *) key)->ob_shash) == -1) ! #endif ! { hash = PyObject_Hash(key); if (hash == -1) --- 1423,1428 ---- long hash; register long ok; if (!PyString_CheckExact(key) || ! (hash = ((PyStringObject *) key)->ob_shash) == -1) { hash = PyObject_Hash(key); if (hash == -1) *************** *** 1461,1469 **** return NULL; - #ifdef CACHE_HASH if (!PyString_CheckExact(key) || ! (hash = ((PyStringObject *) key)->ob_shash) == -1) ! #endif ! { hash = PyObject_Hash(key); if (hash == -1) --- 1444,1449 ---- return NULL; if (!PyString_CheckExact(key) || ! (hash = ((PyStringObject *) key)->ob_shash) == -1) { hash = PyObject_Hash(key); if (hash == -1) *************** *** 1490,1498 **** return NULL; - #ifdef CACHE_HASH if (!PyString_CheckExact(key) || ! (hash = ((PyStringObject *) key)->ob_shash) == -1) ! #endif ! { hash = PyObject_Hash(key); if (hash == -1) --- 1470,1475 ---- return NULL; if (!PyString_CheckExact(key) || ! (hash = ((PyStringObject *) key)->ob_shash) == -1) { hash = PyObject_Hash(key); if (hash == -1) *************** *** 1726,1734 **** long hash; - #ifdef CACHE_HASH if (!PyString_CheckExact(key) || ! (hash = ((PyStringObject *) key)->ob_shash) == -1) ! #endif ! { hash = PyObject_Hash(key); if (hash == -1) --- 1703,1708 ---- long hash; if (!PyString_CheckExact(key) || ! (hash = ((PyStringObject *) key)->ob_shash) == -1) { hash = PyObject_Hash(key); if (hash == -1) Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.151 retrieving revision 2.152 diff -C2 -d -r2.151 -r2.152 *** stringobject.c 22 Mar 2002 15:30:10 -0000 2.151 --- stringobject.c 29 Mar 2002 03:29:07 -0000 2.152 *************** *** 73,82 **** return PyErr_NoMemory(); PyObject_INIT_VAR(op, &PyString_Type, size); - #ifdef CACHE_HASH op->ob_shash = -1; - #endif - #ifdef INTERN_STRINGS op->ob_sinterned = NULL; - #endif if (str != NULL) memcpy(op->ob_sval, str, size); --- 73,78 ---- *************** *** 136,145 **** return PyErr_NoMemory(); PyObject_INIT_VAR(op, &PyString_Type, size); - #ifdef CACHE_HASH op->ob_shash = -1; - #endif - #ifdef INTERN_STRINGS op->ob_sinterned = NULL; - #endif memcpy(op->ob_sval, str, size+1); #ifndef DONT_SHARE_SHORT_STRINGS --- 132,137 ---- *************** *** 738,747 **** return PyErr_NoMemory(); PyObject_INIT_VAR(op, &PyString_Type, size); - #ifdef CACHE_HASH op->ob_shash = -1; - #endif - #ifdef INTERN_STRINGS op->ob_sinterned = NULL; - #endif memcpy(op->ob_sval, a->ob_sval, (int) a->ob_size); memcpy(op->ob_sval + a->ob_size, b->ob_sval, (int) b->ob_size); --- 730,735 ---- *************** *** 785,794 **** return PyErr_NoMemory(); PyObject_INIT_VAR(op, &PyString_Type, size); - #ifdef CACHE_HASH op->ob_shash = -1; - #endif - #ifdef INTERN_STRINGS op->ob_sinterned = NULL; - #endif for (i = 0; i < size; i += a->ob_size) memcpy(op->ob_sval+i, a->ob_sval, (int) a->ob_size); --- 773,778 ---- *************** *** 946,958 **** register long x; - #ifdef CACHE_HASH if (a->ob_shash != -1) return a->ob_shash; - #ifdef INTERN_STRINGS if (a->ob_sinterned != NULL) return (a->ob_shash = ((PyStringObject *)(a->ob_sinterned))->ob_shash); - #endif - #endif len = a->ob_size; p = (unsigned char *) a->ob_sval; --- 930,938 ---- *************** *** 963,969 **** if (x == -1) x = -2; - #ifdef CACHE_HASH a->ob_shash = x; - #endif return x; } --- 943,947 ---- *************** *** 2731,2742 **** if (pnew != NULL) { memcpy(PyString_AS_STRING(pnew), PyString_AS_STRING(tmp), n+1); - #ifdef CACHE_HASH ((PyStringObject *)pnew)->ob_shash = ((PyStringObject *)tmp)->ob_shash; - #endif - #ifdef INTERN_STRINGS ((PyStringObject *)pnew)->ob_sinterned = ((PyStringObject *)tmp)->ob_sinterned; - #endif } Py_DECREF(tmp); --- 2709,2716 ---- *************** *** 3580,3584 **** - #ifdef INTERN_STRINGS /* This dictionary will leak at PyString_Fini() time. That's acceptable --- 3554,3557 ---- *************** *** 3657,3662 **** } - #endif - void PyString_Fini(void) --- 3630,3633 ---- *************** *** 3671,3675 **** nullstring = NULL; #endif - #ifdef INTERN_STRINGS if (interned) { int pos, changed; --- 3642,3645 ---- *************** *** 3686,3693 **** } while (changed); } - #endif } - #ifdef INTERN_STRINGS void _Py_ReleaseInternedStrings(void) { --- 3656,3661 ---- *************** *** 3699,3701 **** } } - #endif /* INTERN_STRINGS */ --- 3667,3668 ---- From tim_one@users.sourceforge.net Fri Mar 29 03:29:09 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 28 Mar 2002 19:29:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.370,1.371 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv21495/python/Misc Modified Files: NEWS Log Message: Remove the CACHE_HASH and INTERN_STRINGS preprocessor symbols. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.370 retrieving revision 1.371 diff -C2 -d -r1.370 -r1.371 *** NEWS 29 Mar 2002 01:07:24 -0000 1.370 --- NEWS 29 Mar 2002 03:29:07 -0000 1.371 *************** *** 90,93 **** --- 90,97 ---- Build + - References to the CACHE_HASH and INTERN_STRINGS preprocessor symbols + were eliminated. They were always defined, and the internal features + they enabled stopped being experimental long ago. + C API From tim_one@users.sourceforge.net Fri Mar 29 03:29:10 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Thu, 28 Mar 2002 19:29:10 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python import.c,2.195,2.196 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv21495/python/Python Modified Files: import.c Log Message: Remove the CACHE_HASH and INTERN_STRINGS preprocessor symbols. Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.195 retrieving revision 2.196 diff -C2 -d -r2.195 -r2.196 *** import.c 26 Feb 2002 11:41:34 -0000 2.195 --- import.c 29 Mar 2002 03:29:08 -0000 2.196 *************** *** 979,983 **** continue; /* v contains '\0' */ #ifdef macintosh - #ifdef INTERN_STRINGS /* ** Speedup: each sys.path item is interned, and --- 979,982 ---- *************** *** 988,992 **** PyString_InternInPlace(&PyList_GET_ITEM(path, i)); v = PyList_GET_ITEM(path, i); - #endif if (PyMac_FindResourceModule((PyStringObject *)v, name, buf)) { static struct filedescr resfiledescr = --- 987,990 ---- From jackjansen@users.sourceforge.net Fri Mar 29 14:15:24 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 29 Mar 2002 06:15:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/OSX pythonw.sh,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory usw-pr-cvs1:/tmp/cvs-serv19322 Added Files: pythonw.sh Log Message: Shell script that invokes Python.app from the command line. Called pythonw because of similarity to the same program on Windows. --- NEW FILE: pythonw.sh --- #!/bin/sh exec /Applications/Python.app/Contents/MacOS/python $@ From jackjansen@users.sourceforge.net Fri Mar 29 14:18:20 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 29 Mar 2002 06:18:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/OSX Makefile,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory usw-pr-cvs1:/tmp/cvs-serv19599 Modified Files: Makefile Log Message: Added target "installunixprograms" which installs python and pythonw in /usr/local/bin (referring to the framework-based interpreter and Python.app). Added target symlinkmacsubtree to aid in debugging. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Makefile,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Makefile 27 Jan 2002 20:05:20 -0000 1.8 --- Makefile 29 Mar 2002 14:18:18 -0000 1.9 *************** *** 3,12 **** --- 3,19 ---- APPINSTALLDIR=/Applications/Python.app + # Variables for installing the "normal" unix binaries + UNIXBINDIR=/usr/local/bin + INSTALLED_PYTHON=$(INSTALLDIR)/bin/python + INSTALLED_PYTHONW=$(APPINSTALLDIR)/Contents/MacOS/python + # Items more-or-less copied from the main Makefile DIRMODE=755 INSTALL=/usr/bin/install -c + INSTALL_SYMLINK=/usr/bin/install -l as INSTALL_PROGRAM=${INSTALL} INSTALL_SCRIPT= ${INSTALL_PROGRAM} INSTALL_DATA= ${INSTALL} -m 644 + STRIPFLAG=-s OPT=-g -O3 -Wall -Wstrict-prototypes -no-cpp-precomp -fno-common -dynamic INCLUDES=-I$(PYTHONBUILDDIR) -I$(PYTHONBUILDDIR)/Include \ *************** *** 72,76 **** done; \ done ! $(INSTALL_PROGRAM) pythonforbundle $(APPINSTALLDIR)/Contents/MacOS/python # Create a temporary version of the resources here $(PYTHON) $(RFCONVERTER) -r $(RESOURCEDIR)/dialogs.rsrc dialogs.rsrc --- 79,83 ---- done; \ done ! $(INSTALL_PROGRAM) $(STRIPFLAG) pythonforbundle $(APPINSTALLDIR)/Contents/MacOS/python # Create a temporary version of the resources here $(PYTHON) $(RFCONVERTER) -r $(RESOURCEDIR)/dialogs.rsrc dialogs.rsrc *************** *** 180,183 **** @echo '** Copy the contents of sample_sitecustomize.py (or similar code) into' ! @echo '**' $(INSTALLDIR)/lib/python2.2/sitecustomize.py --- 187,203 ---- @echo '** Copy the contents of sample_sitecustomize.py (or similar code) into' ! @echo '**' $(INSTALLDIR)/lib/python2.3/sitecustomize.py ! ! # Put symlinks "python" and "pythonw" in the standard place ! installunixprograms: $(INSTALLED_PYTHON) pythonw.sh ! $(INSTALL) -d $(UNIXBINDIR) ! $(INSTALL_SYMLINK) $(INSTALLED_PYTHON) $(UNIXBINDIR)/python ! $(INSTALL) pythonw.sh $(UNIXBINDIR)/pythonw + # This is for development purposes: put a symlink to the Mac source subtree in the + # framework + symlinkmacsubtree: + ln -sf `cd $(PYTHONBUILDDIR)/Mac; pwd` $(INSTALLDIR)/Mac + + @echo '** Copy the contents of sample_sitecustomize.py (or similar code) into' + @echo '**' $(INSTALLDIR)/lib/python2.3/sitecustomize.py From jackjansen@users.sourceforge.net Fri Mar 29 14:27:08 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 29 Mar 2002 06:27:08 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Python macmain.c,1.73,1.74 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Python In directory usw-pr-cvs1:/tmp/cvs-serv22346 Modified Files: macmain.c Log Message: In MachoPython print "Pythonw" in banner to distinguish from command-line python. Removed debug output. Index: macmain.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Python/macmain.c,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** macmain.c 2 Jan 2002 22:53:38 -0000 1.73 --- macmain.c 29 Mar 2002 14:27:06 -0000 1.74 *************** *** 536,540 **** main(int argc, char **argv) { - int i; static char scriptpath[1024]; char *script = NULL; --- 536,539 ---- *************** *** 557,567 **** script = scriptpath; - printf("original argc=%d\n", argc); - for(i=0; i Update of /cvsroot/python/python/dist/src/Mac/Lib In directory usw-pr-cvs1:/tmp/cvs-serv22724 Modified Files: applesingle.py Log Message: Removed debug. Index: applesingle.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Lib/applesingle.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** applesingle.py 9 Sep 2001 00:35:19 -0000 1.1 --- applesingle.py 29 Mar 2002 14:28:09 -0000 1.2 *************** *** 29,33 **** # Should we also test for FSSpecs or FSRefs? header = input.read(AS_HEADER_LENGTH) - print `header` try: magic, version, dummy, nentry = struct.unpack(AS_HEADER_FORMAT, header) --- 29,32 ---- From jackjansen@users.sourceforge.net Fri Mar 29 14:29:37 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 29 Mar 2002 06:29:37 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Lib macresource.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib In directory usw-pr-cvs1:/tmp/cvs-serv22918 Modified Files: macresource.py Log Message: If the file has no resource fork first check to see whether it's a datafork-based resource file before trying to decode it as AppleSingle. Index: macresource.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Lib/macresource.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** macresource.py 21 Mar 2002 22:38:32 -0000 1.5 --- macresource.py 29 Mar 2002 14:29:35 -0000 1.6 *************** *** 78,88 **** except Res.Error, arg: if arg[0] in (-37, -39): ! # No resource fork. We may be on OSX, try to decode ! # the applesingle file. ! pathname = _decode(pathname) ! if pathname: refno = Res.FSOpenResourceFile(pathname, u'', 1) else: ! raise return refno --- 78,95 ---- except Res.Error, arg: if arg[0] in (-37, -39): ! # No resource fork. We may be on OSX, and this may be either ! # a data-fork based resource file or a AppleSingle file ! # from the CVS repository. ! try: refno = Res.FSOpenResourceFile(pathname, u'', 1) + except Res.Error, arg: + if arg[0] != -199: + # -199 is "bad resource map" + raise else: ! return refno ! # Finally try decoding an AppleSingle file ! pathname = _decode(pathname) ! refno = Res.FSOpenResourceFile(pathname, u'', 1) return refno From jackjansen@users.sourceforge.net Fri Mar 29 14:43:52 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 29 Mar 2002 06:43:52 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Python macmain.c,1.74,1.75 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Python In directory usw-pr-cvs1:/tmp/cvs-serv26303 Modified Files: macmain.c Log Message: Allow .pyc files as applets as well as .py files. .py files have priority, for safety reasons. Index: macmain.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Python/macmain.c,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** macmain.c 29 Mar 2002 14:27:06 -0000 1.74 --- macmain.c 29 Mar 2002 14:43:50 -0000 1.75 *************** *** 477,481 **** static int ! locateResourcePy(char * resourceName, char * resourceURLCStr, int length) { CFBundleRef mainBundle = NULL; CFURLRef URL, absoluteURL; --- 477,482 ---- static int ! locateResourcePy(CFStringRef resourceType, char *resourceName, char *resourceURLCStr, int length) ! { CFBundleRef mainBundle = NULL; CFURLRef URL, absoluteURL; *************** *** 501,505 **** /* Look for py files in the main bundle by type */ arrayRef = CFBundleCopyResourceURLsOfType( mainBundle, ! CFSTR("py"), NULL ); --- 502,506 ---- /* Look for py files in the main bundle by type */ arrayRef = CFBundleCopyResourceURLsOfType( mainBundle, ! resourceType, NULL ); *************** *** 542,546 **** ** is there */ ! if (locateResourcePy("__rawmain__.py", scriptpath, 1024)) { /* If we have a raw main we don't do AppleEvent processing. ** Notice that this also means we keep the -psn.... argv[1] --- 543,547 ---- ** is there */ ! if (locateResourcePy(CFSTR("py"), "__rawmain__.py", scriptpath, 1024)) { /* If we have a raw main we don't do AppleEvent processing. ** Notice that this also means we keep the -psn.... argv[1] *************** *** 549,557 **** */ script = scriptpath; } else { /* Otherwise we look for __main__.py. Whether that is ** found or not we also process AppleEvent arguments. */ ! if (locateResourcePy("__main__.py", scriptpath, 1024)) script = scriptpath; --- 550,562 ---- */ script = scriptpath; + } else if (locateResourcePy(CFSTR("pyc"), "__rawmain__.pyc", scriptpath, 1024)) { + script = scriptpath; } else { /* Otherwise we look for __main__.py. Whether that is ** found or not we also process AppleEvent arguments. */ ! if (locateResourcePy(CFSTR("py"), "__main__.py", scriptpath, 1024)) ! script = scriptpath; ! else if (locateResourcePy(CFSTR("pyc"), "__main__.pyc", scriptpath, 1024)) script = scriptpath; From gvanrossum@users.sourceforge.net Fri Mar 29 14:47:20 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 29 Mar 2002 06:47:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python traceback.c,2.36,2.36.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv27430 Modified Files: Tag: release22-maint traceback.c Log Message: Backport to 2.2.1: This is Neil's fix for SF bug 535905 (Evil Trashcan and GC interaction). The fix makes it possible to call PyObject_GC_UnTrack() more than once on the same object, and then move the PyObject_GC_UnTrack() call to *before* the trashcan code is invoked. BUGFIX CANDIDATE! Index: traceback.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/traceback.c,v retrieving revision 2.36 retrieving revision 2.36.6.1 diff -C2 -d -r2.36 -r2.36.6.1 *** traceback.c 28 Nov 2001 20:42:20 -0000 2.36 --- traceback.c 29 Mar 2002 14:47:18 -0000 2.36.6.1 *************** *** 36,41 **** tb_dealloc(tracebackobject *tb) { Py_TRASHCAN_SAFE_BEGIN(tb) - _PyObject_GC_UNTRACK(tb); Py_XDECREF(tb->tb_next); Py_XDECREF(tb->tb_frame); --- 36,41 ---- tb_dealloc(tracebackobject *tb) { + PyObject_GC_UnTrack(tb); Py_TRASHCAN_SAFE_BEGIN(tb) Py_XDECREF(tb->tb_next); Py_XDECREF(tb->tb_frame); From akuchling@users.sourceforge.net Fri Mar 29 16:00:16 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Fri, 29 Mar 2002 08:00:16 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test string_tests.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv13417 Modified Files: string_tests.py Log Message: Add two tests for string.zfill Index: string_tests.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/string_tests.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** string_tests.py 17 Aug 2001 18:39:24 -0000 1.10 --- string_tests.py 29 Mar 2002 16:00:13 -0000 1.11 *************** *** 216,219 **** --- 216,222 ---- test('endswith', 'ab', 0, 'ab', 0, 0) + test('zfill', '34', '34', 1) + test('zfill', '34', '0034', 4) + # Encoding/decoding codecs = [('rot13', 'uryyb jbeyq'), From akuchling@users.sourceforge.net Fri Mar 29 16:20:35 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Fri, 29 Mar 2002 08:20:35 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib string.py,1.61,1.62 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv19491 Modified Files: string.py Log Message: [Bug #536241] string.zfill() produces mangled output for a Unicode string. Walter Doerwald provided a patch, which I've modified in two ways: 1) (Uncontroversial) Removed code to make module work in earlier versions of Python without the unicode() built-in 2) (Poss. controversial) Instead of making string.zfill take the repr() of non-string objects, take the str(). Should a warning be added to this branch of the code so that the automatic str() can be deprecated? 2.2.2 bugfix candidate, assuming the repr()->str() change is deemed OK. Index: string.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/string.py,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** string.py 30 Jan 2002 16:15:13 -0000 1.61 --- string.py 29 Mar 2002 16:20:33 -0000 1.62 *************** *** 191,195 **** _int = int _long = long ! _StringType = type('') # Convert string to float --- 191,195 ---- _int = int _long = long ! _StringTypes = (str, unicode) # Convert string to float *************** *** 277,288 **** """ ! if type(x) == type(''): s = x ! else: s = `x` ! n = len(s) ! if n >= width: return s sign = '' ! if s[0] in ('-', '+'): ! sign, s = s[0], s[1:] ! return sign + '0'*(width-n) + s # Expand tabs in a string. --- 277,288 ---- """ ! if not isinstance(x, _StringTypes): ! x = str(x) ! n = len(x) ! if n >= width: return x sign = '' ! if x[0] in '-+': ! sign, x = x[0], x[1:] ! return sign + '0'*(width-n) + x # Expand tabs in a string. From akuchling@users.sourceforge.net Fri Mar 29 16:21:46 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Fri, 29 Mar 2002 08:21:46 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.50,1.51 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv19823 Modified Files: test_unicode.py Log Message: As part of fixing bug #536241, add a test case for string.zfill() with Unicode Index: test_unicode.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** test_unicode.py 21 Mar 2002 08:55:27 -0000 1.50 --- test_unicode.py 29 Mar 2002 16:21:44 -0000 1.51 *************** *** 7,11 **** """#" from test_support import verify, verbose, TestFailed ! import sys if not sys.platform.startswith('java'): --- 7,11 ---- """#" from test_support import verify, verbose, TestFailed ! import sys, string if not sys.platform.startswith('java'): *************** *** 206,209 **** --- 206,212 ---- test('capwords', u'abc\tdef\nghi', u'Abc Def Ghi') test('capwords', u'abc\t def \nghi', u'Abc Def Ghi') + + verify(string.zfill(u'34', 1) == u'34') + verify(string.zfill(u'34', 5) == u'00034') # Comparisons: From loewis@users.sourceforge.net Fri Mar 29 16:28:33 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 29 Mar 2002 08:28:33 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc ACKS,1.163,1.164 NEWS,1.371,1.372 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv21694/Misc Modified Files: ACKS NEWS Log Message: Patch #527027: Allow building python as shared library. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.163 retrieving revision 1.164 diff -C2 -d -r1.163 -r1.164 *** ACKS 1 Mar 2002 22:24:49 -0000 1.163 --- ACKS 29 Mar 2002 16:28:31 -0000 1.164 *************** *** 336,339 **** --- 336,340 ---- Harri Pasanen Randy Pausch + Ondrej Palkovsky Marcel van der Peijl Samuele Pedroni Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.371 retrieving revision 1.372 diff -C2 -d -r1.371 -r1.372 *** NEWS 29 Mar 2002 03:29:07 -0000 1.371 --- NEWS 29 Mar 2002 16:28:31 -0000 1.372 *************** *** 90,93 **** --- 90,95 ---- Build + - On Unix, a shared libpython2.3.so can be created with --enable-shared. + - References to the CACHE_HASH and INTERN_STRINGS preprocessor symbols were eliminated. They were always defined, and the internal features From loewis@users.sourceforge.net Fri Mar 29 16:28:33 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Fri, 29 Mar 2002 08:28:33 -0800 Subject: [Python-checkins] CVS: python/dist/src Makefile.pre.in,1.77,1.78 README,1.142,1.143 configure,1.291,1.292 configure.in,1.301,1.302 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv21694 Modified Files: Makefile.pre.in README configure configure.in Log Message: Patch #527027: Allow building python as shared library. Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** Makefile.pre.in 23 Mar 2002 00:20:15 -0000 1.77 --- Makefile.pre.in 29 Mar 2002 16:28:30 -0000 1.78 *************** *** 109,112 **** --- 109,115 ---- PYTHONFRAMEWORKINSTALLDIR= @PYTHONFRAMEWORKINSTALLDIR@ + # Environment to run shared python without installed libraries + RUNSHARED= @RUNSHARED@ + # Modes for directories, executables and data files created by the # install process. Default to user-only-writable for all file types. *************** *** 137,140 **** --- 140,144 ---- DLLLIBRARY= @DLLLIBRARY@ LDLIBRARYDIR= @LDLIBRARYDIR@ + INSTSONAME= @INSTSONAME@ *************** *** 293,297 **** # Build the interpreter ! $(BUILDPYTHON): Modules/$(MAINOBJ) $(LDLIBRARY) $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \ Modules/$(MAINOBJ) \ --- 297,301 ---- # Build the interpreter ! $(BUILDPYTHON): Modules/$(MAINOBJ) $(LIBRARY) $(LDLIBRARY) $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \ Modules/$(MAINOBJ) \ *************** *** 299,303 **** platform: $(BUILDPYTHON) ! ./$(BUILDPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform --- 303,307 ---- platform: $(BUILDPYTHON) ! $(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform *************** *** 305,310 **** sharedmods: $(BUILDPYTHON) case $$MAKEFLAGS in \ ! *-s*) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \ ! *) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \ esac --- 309,314 ---- sharedmods: $(BUILDPYTHON) case $$MAKEFLAGS in \ ! *-s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \ ! *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \ esac *************** *** 334,349 **** $(RANLIB) $@ ! # This rule is only here for DG/UX and BeOS!!! ! libpython$(VERSION).so: $(LIBRARY) ! case `uname -s | tr -d '/ ' | tr '[A-Z]' '[a-z]'` in \ ! *dgux*) \ ! test -d dgux || mkdir dgux; \ ! (cd dgux;ar x ../$^;ld -G -o ../$@ * ); \ ! /bin/rm -rf ./dgux \ ! ;; \ ! beos) \ ! $(AR) so $(LIBRARY) $@ \ ! ;; \ ! esac # This rule is here for OPENSTEP/Rhapsody/MacOSX --- 338,346 ---- $(RANLIB) $@ ! libpython$(VERSION).so: $(LIBRARY_OBJS) ! $(LDSHARED) -o $@ $(LIBRARY_OBJS) $(LIBC) $(LIBM) ! ! libpython$(VERSION).sl: $(LIBRARY_OBJS) ! $(LDSHARED) -o $@ $(LIBRARY_OBJS) $(LIBC) $(LIBM) # This rule is here for OPENSTEP/Rhapsody/MacOSX *************** *** 421,428 **** Python/getplatform.o: $(srcdir)/Python/getplatform.c ! $(CC) -c $(CFLAGS) $(CPPFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c Python/importdl.o: $(srcdir)/Python/importdl.c ! $(CC) -c $(CFLAGS) $(CPPFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c Objects/unicodectype.o: $(srcdir)/Objects/unicodectype.c \ --- 418,425 ---- Python/getplatform.o: $(srcdir)/Python/getplatform.c ! $(CC) -c $(CFLAGS) $(CPPFLAGS) $(CFLAGSFORSHARED) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c Python/importdl.o: $(srcdir)/Python/importdl.c ! $(CC) -c $(CFLAGS) $(CPPFLAGS) $(CFLAGSFORSHARED) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c Objects/unicodectype.o: $(srcdir)/Objects/unicodectype.c \ *************** *** 487,491 **** TESTOPTS= -l TESTPROG= $(srcdir)/Lib/test/regrtest.py ! TESTPYTHON= ./$(BUILDPYTHON) -E -tt test: all platform -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f --- 484,488 ---- TESTOPTS= -l TESTPROG= $(srcdir)/Lib/test/regrtest.py ! TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) -E -tt test: all platform -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f *************** *** 557,562 **** done $(INSTALL_PROGRAM) $(BUILDPYTHON) $(BINDIR)/python$(VERSION)$(EXE) ! if test -f libpython$(VERSION).so; then \ ! $(INSTALL_DATA) libpython$(VERSION).so $(LIBDIR); \ else true; \ fi --- 554,559 ---- done $(INSTALL_PROGRAM) $(BUILDPYTHON) $(BINDIR)/python$(VERSION)$(EXE) ! if test -f libpython$(VERSION)$(SO); then \ ! $(INSTALL_SHARED) libpython$(VERSION)$(SO) $(LIBDIR)/$(INSTSONAME); \ else true; \ fi *************** *** 641,648 **** done $(INSTALL_DATA) $(srcdir)/LICENSE $(LIBDEST)/LICENSE.txt ! PYTHONPATH=$(LIBDEST) \ ./$(BUILDPYTHON) -tt $(LIBDEST)/compileall.py -x badsyntax \ $(LIBDEST) ! PYTHONPATH=$(LIBDEST) \ ./$(BUILDPYTHON) -O $(LIBDEST)/compileall.py -x badsyntax $(LIBDEST) --- 638,645 ---- done $(INSTALL_DATA) $(srcdir)/LICENSE $(LIBDEST)/LICENSE.txt ! PYTHONPATH=$(LIBDEST) $(RUNSHARED) \ ./$(BUILDPYTHON) -tt $(LIBDEST)/compileall.py -x badsyntax \ $(LIBDEST) ! PYTHONPATH=$(LIBDEST) $(RUNSHARED) \ ./$(BUILDPYTHON) -O $(LIBDEST)/compileall.py -x badsyntax $(LIBDEST) *************** *** 687,696 **** fi; \ done ! @if test -d $(LDLIBRARY); then :; else \ if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \ ! $(INSTALL_DATA) $(LDLIBRARY) $(LIBPL)/$(LDLIBRARY) ; \ ! $(RANLIB) $(LIBPL)/$(LDLIBRARY) ; \ else \ ! echo Skip install of $(LDLIBRARY) - use make frameworkinstall; \ fi; \ fi --- 684,693 ---- fi; \ done ! @if test -d $(LIBRARY); then :; else \ if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \ ! $(INSTALL_DATA) $(LIBRARY) $(LIBPL)/$(LIBRARY) ; \ ! $(RANLIB) $(LIBPL)/$(LIBRARY) ; \ else \ ! echo Skip install of $(LIBRARY) - use make frameworkinstall; \ fi; \ fi *************** *** 734,738 **** # This goes into $(exec_prefix) sharedinstall: ! ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \ --install-scripts=$(BINDIR) \ --install-platlib=$(DESTSHARED) --- 731,736 ---- # This goes into $(exec_prefix) sharedinstall: ! $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \ ! --prefix=$(prefix) \ --install-scripts=$(BINDIR) \ --install-platlib=$(DESTSHARED) Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/README,v retrieving revision 1.142 retrieving revision 1.143 diff -C2 -d -r1.142 -r1.143 *** README 21 Mar 2002 23:52:20 -0000 1.142 --- README 29 Mar 2002 16:28:30 -0000 1.143 *************** *** 559,562 **** --- 559,571 ---- + Building a shared libpython + --------------------------- + + Starting with Python 2.3, the majority of the interpreter can be built + into a shared library, which can then be used by the interpreter + executable, and by applications embedding Python. To enable this feature, + configure with --enable-shared. + + Configuring additional built-in modules --------------------------------------- Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.291 retrieving revision 1.292 diff -C2 -d -r1.291 -r1.292 *** configure 27 Mar 2002 18:49:01 -0000 1.291 --- configure 29 Mar 2002 16:28:30 -0000 1.292 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.300 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.301 [...5234 lines suppressed...] ! echo "configure:7710: checking for build directories" >&5 for dir in $SRCDIRS; do if test ! -d $dir; then *************** *** 7794,7797 **** --- 7850,7854 ---- s%@mandir@%$mandir%g s%@VERSION@%$VERSION%g + s%@SOVERSION@%$SOVERSION%g s%@CONFIG_ARGS@%$CONFIG_ARGS%g s%@PYTHONFRAMEWORK@%$PYTHONFRAMEWORK%g *************** *** 7812,7815 **** --- 7869,7874 ---- s%@BLDLIBRARY@%$BLDLIBRARY%g s%@LDLIBRARYDIR@%$LDLIBRARYDIR%g + s%@INSTSONAME@%$INSTSONAME%g + s%@RUNSHARED@%$RUNSHARED%g s%@LINKCC@%$LINKCC%g s%@RANLIB@%$RANLIB%g Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.301 retrieving revision 1.302 diff -C2 -d -r1.301 -r1.302 *** configure.in 27 Mar 2002 18:49:02 -0000 1.301 --- configure.in 29 Mar 2002 16:28:31 -0000 1.302 *************** *** 9,12 **** --- 9,15 ---- VERSION=2.3 + AC_SUBST(SOVERSION) + SOVERSION=1.0 + # Arguments passed to configure. AC_SUBST(CONFIG_ARGS) *************** *** 258,269 **** --- 261,280 ---- # DLLLIBRARY is the shared (i.e., DLL) library. # + # RUNSHARED is used to run shared python without installed libraries + # + # INSTSONAME is the name of the shared library that will be use to install + # on the system - some systems like version suffix, others don't AC_SUBST(LDLIBRARY) AC_SUBST(DLLLIBRARY) AC_SUBST(BLDLIBRARY) AC_SUBST(LDLIBRARYDIR) + AC_SUBST(INSTSONAME) + AC_SUBST(RUNSHARED) LDLIBRARY="$LIBRARY" BLDLIBRARY='$(LDLIBRARY)' + INSTSONMAE='$(LDLIBRARY)' DLLLIBRARY='' LDLIBRARYDIR='' + RUNSHARED='' # LINKCC is the command that links the python executable -- default is $(CC). *************** *** 302,321 **** AC_MSG_RESULT($LINKCC) ! AC_MSG_CHECKING(LDLIBRARY) ! # DG/UX requires some fancy ld contortions to produce a .so from an .a ! case $MACHDEP in ! dguxR4) ! LDLIBRARY='libpython$(VERSION).so' ! OPT="$OPT -pic" ! ;; ! beos*) ! LDLIBRARY='libpython$(VERSION).so' ! ;; ! cygwin*) ! LDLIBRARY='libpython$(VERSION).dll.a' ! DLLLIBRARY='libpython$(VERSION).dll' ! ;; ! esac # MacOSX framework builds need more magic. LDLIBRARY is the dynamic --- 313,328 ---- AC_MSG_RESULT($LINKCC) ! AC_MSG_CHECKING(for --enable-shared) ! AC_ARG_ENABLE(shared, ! [ --enable-shared disable/enable building shared python library]) ! if test -z "$enable_shared" ! then ! enable_shared="no" ! fi ! AC_MSG_RESULT($enable_shared) ! ! ! AC_MSG_CHECKING(LDLIBRARY) # MacOSX framework builds need more magic. LDLIBRARY is the dynamic *************** *** 334,337 **** --- 341,385 ---- fi + # Other platforms follow + if test $enable_shared = "yes"; then + case $ac_sys_system in + BeOS*) + LDLIBRARY='libpython$(VERSION).so' + ;; + CYGWIN*) + LDLIBRARY='libpython$(VERSION).dll.a' + DLLLIBRARY='libpython$(VERSION).dll' + ;; + SunOS*) + LDLIBRARY='libpython$(VERSION).so' + BLDLIBRARY='-Wl,-rpath,$(LIBDIR) -L. -lpython$(VERSION)' + RUNSHARED=LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH + ;; + Linux*) + LDLIBRARY='libpython$(VERSION).so' + BLDLIBRARY='-L. -lpython$(VERSION)' + RUNSHARED=LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH + INSTSONAME="$LDLIBRARY".$SOVERSION + ;; + hp*|HP*) + LDLIBRARY='libpython$(VERSION).sl' + BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)' + RUNSHARED=SHLIB_PATH=`pwd`:$SHLIB_PATH + ;; + OSF*) + LDLIBRARY='libpython$(VERSION).so' + BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)' + RUNSHARED=LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH + ;; + esac + # DG/UX requires some fancy ld contortions to produce a .so from an .a + case $MACHDEP in + dguxR4) + LDLIBRARY='libpython$(VERSION).so' + OPT="$OPT -pic" + ;; + esac + fi + AC_MSG_RESULT($LDLIBRARY) *************** *** 862,866 **** AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';; hp*|HP*) ! LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";; BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";; Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";; --- 910,915 ---- AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';; hp*|HP*) ! LINKFORSHARED="-Wl,-E -Wl,+s";; ! # LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";; BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";; Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";; From akuchling@users.sourceforge.net Fri Mar 29 18:00:22 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Fri, 29 Mar 2002 10:00:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils extension.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv13424/Lib/distutils Modified Files: extension.py Log Message: [Patch #536769] Add -Xcompiler flag for adding arguments and switches for the compiler Index: extension.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/extension.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** extension.py 21 Dec 2001 15:34:17 -0000 1.10 --- extension.py 29 Mar 2002 18:00:19 -0000 1.11 *************** *** 189,192 **** --- 189,194 ---- elif word == "-Xlinker": append_next_word = ext.extra_link_args + elif word == "-Xcompiler": + append_next_word = ext.extra_compile_args elif switch == "-u": ext.extra_link_args.append(word) From akuchling@users.sourceforge.net Fri Mar 29 18:00:21 2002 From: akuchling@users.sourceforge.net (A.M. Kuchling) Date: Fri, 29 Mar 2002 10:00:21 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules makesetup,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv13424/Modules Modified Files: makesetup Log Message: [Patch #536769] Add -Xcompiler flag for adding arguments and switches for the compiler Index: makesetup =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/makesetup,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** makesetup 2 Jun 2001 06:16:02 -0000 1.36 --- makesetup 29 Mar 2002 18:00:18 -0000 1.37 *************** *** 160,163 **** --- 160,164 ---- ;; -[IDUCfF]*) cpps="$cpps $arg";; + -Xcompiler) skip=cpps;; -Xlinker) libs="$libs $arg"; skip=libs;; -rpath) libs="$libs $arg"; skip=libs;; From nascheme@users.sourceforge.net Fri Mar 29 19:58:27 2002 From: nascheme@users.sourceforge.net (Neil Schemenauer) Date: Fri, 29 Mar 2002 11:58:27 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules pwdmodule.c,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv10517/Modules Modified Files: pwdmodule.c Log Message: Add missing typecast. Index: pwdmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pwdmodule.c,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** pwdmodule.c 25 Mar 2002 20:46:46 -0000 1.29 --- pwdmodule.c 29 Mar 2002 19:58:25 -0000 1.30 *************** *** 150,154 **** {"getpwnam", pwd_getpwnam, METH_OLDARGS, pwd_getpwnam__doc__}, #ifdef HAVE_GETPWENT ! {"getpwall", pwd_getpwall, METH_NOARGS, pwd_getpwall__doc__}, #endif {NULL, NULL} /* sentinel */ --- 150,155 ---- {"getpwnam", pwd_getpwnam, METH_OLDARGS, pwd_getpwnam__doc__}, #ifdef HAVE_GETPWENT ! {"getpwall", (PyCFunction)pwd_getpwall, ! METH_NOARGS, pwd_getpwall__doc__}, #endif {NULL, NULL} /* sentinel */ From jackjansen@users.sourceforge.net Fri Mar 29 21:16:43 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 29 Mar 2002 13:16:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/OSXResources/app Info.plist,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSXResources/app In directory usw-pr-cvs1:/tmp/cvs-serv28531/app Modified Files: Info.plist Log Message: Changed visible name (in dock, menubar) of the interpreter to PythonW. Changed version numbers and copyright. Index: Info.plist =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSXResources/app/Info.plist,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Info.plist 12 Dec 2001 21:40:38 -0000 1.4 --- Info.plist 29 Mar 2002 21:16:41 -0000 1.5 *************** *** 54,73 **** CFBundleGetInfoString ! Python Interpreter version 2.2, (c) 2001 Python Software Foundation. CFBundleLongVersionString ! 2.2, (c) 2001 Python Software Foundation. NSHumanReadableCopyright ! Copyright 2001 Python Software Foundation. CFBundleShortVersionString ! 6.5 CFBundleIconFile PythonInterpreter.icns CFBundleIdentifier ! org.python.interpreter CFBundleInfoDictionaryVersion 6.0 CFBundleName ! PythonInterpreter CFBundlePackageType APPL --- 54,73 ---- CFBundleGetInfoString ! Python Interpreter version 2.3, (c) 2002 Python Software Foundation. CFBundleLongVersionString ! 2.3, (c) 2002 Python Software Foundation. NSHumanReadableCopyright ! Copyright 2002 Python Software Foundation. CFBundleShortVersionString ! 2.3 CFBundleIconFile PythonInterpreter.icns CFBundleIdentifier ! org.python.pythonw CFBundleInfoDictionaryVersion 6.0 CFBundleName ! PythonW CFBundlePackageType APPL From jackjansen@users.sourceforge.net Fri Mar 29 21:16:43 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 29 Mar 2002 13:16:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/OSXResources/app/Resources/English.lproj InfoPlist.strings,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSXResources/app/Resources/English.lproj In directory usw-pr-cvs1:/tmp/cvs-serv28531/app/Resources/English.lproj Modified Files: InfoPlist.strings Log Message: Changed visible name (in dock, menubar) of the interpreter to PythonW. Changed version numbers and copyright. Index: InfoPlist.strings =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSXResources/app/Resources/English.lproj/InfoPlist.strings,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** InfoPlist.strings 12 Dec 2001 22:44:59 -0000 1.2 --- InfoPlist.strings 29 Mar 2002 21:16:41 -0000 1.3 *************** *** 1,7 **** /* Localized versions of Info.plist keys */ ! CFBundleName = "PythonInterpreter"; ! CFBundleShortVersionString = "Python Interpreter version 2.2"; ! CFBundleGetInfoString = "Python Interpreter version 2.2, (c) 2001 Python Software Foundation."; ! CFBundleLongVersionString = "2.2, (c) 2001 Python Software Foundation."; ! NSHumanReadableCopyright = "Copyright 2001 Python Software Foundation."; --- 1,7 ---- /* Localized versions of Info.plist keys */ ! CFBundleName = "PythonW"; ! CFBundleShortVersionString = "Python Interpreter version 2.3"; ! CFBundleGetInfoString = "Python Interpreter version 2.3, (c) 2002 Python Software Foundation."; ! CFBundleLongVersionString = "2.3, (c) 2002 Python Software Foundation."; ! NSHumanReadableCopyright = "Copyright 2002 Python Software Foundation."; From jackjansen@users.sourceforge.net Fri Mar 29 21:17:16 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 29 Mar 2002 13:17:16 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/OSX Makefile,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory usw-pr-cvs1:/tmp/cvs-serv28915 Modified Files: Makefile Log Message: Added -Wno-long-double Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Makefile,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Makefile 29 Mar 2002 14:18:18 -0000 1.9 --- Makefile 29 Mar 2002 21:17:14 -0000 1.10 *************** *** 16,20 **** INSTALL_DATA= ${INSTALL} -m 644 STRIPFLAG=-s ! OPT=-g -O3 -Wall -Wstrict-prototypes -no-cpp-precomp -fno-common -dynamic INCLUDES=-I$(PYTHONBUILDDIR) -I$(PYTHONBUILDDIR)/Include \ -I$(PYTHONBUILDDIR)/Mac/Include --- 16,21 ---- INSTALL_DATA= ${INSTALL} -m 644 STRIPFLAG=-s ! OPT=-g -O3 -Wall -Wstrict-prototypes -Wno-long-double -no-cpp-precomp \ ! -fno-common -dynamic INCLUDES=-I$(PYTHONBUILDDIR) -I$(PYTHONBUILDDIR)/Include \ -I$(PYTHONBUILDDIR)/Mac/Include From jackjansen@users.sourceforge.net Fri Mar 29 21:17:59 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 29 Mar 2002 13:17:59 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Lib macresource.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib In directory usw-pr-cvs1:/tmp/cvs-serv29117 Modified Files: macresource.py Log Message: Re-raise the Res.Error if the file doesn't exist. Index: macresource.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Lib/macresource.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** macresource.py 29 Mar 2002 14:29:35 -0000 1.6 --- macresource.py 29 Mar 2002 21:17:57 -0000 1.7 *************** *** 92,95 **** --- 92,97 ---- pathname = _decode(pathname) refno = Res.FSOpenResourceFile(pathname, u'', 1) + else: + raise return refno From jackjansen@users.sourceforge.net Fri Mar 29 21:19:43 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 29 Mar 2002 13:19:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Lib macfsn.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib In directory usw-pr-cvs1:/tmp/cvs-serv29439 Modified Files: macfsn.py Log Message: Don't attempt to create a dummy fsspec if the user cancelled out, just return None. For now, if the user asks for TEXT files files without type are also accepted. But it is time to phase out StandardGetFile and friends, really. Index: macfsn.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Lib/macfsn.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** macfsn.py 31 Oct 2001 22:58:23 -0000 1.6 --- macfsn.py 29 Mar 2002 21:19:37 -0000 1.7 *************** *** 13,16 **** --- 13,19 ---- def _mktypelist(typelist): + # Workaround for OSX typeless files: + if 'TEXT' in typelist and not '\0\0\0\0' in typelist: + typelist = typelist + ('\0\0\0\0',) if not typelist: return None *************** *** 45,49 **** raise Nav.error, arg good = 0 ! fss = macfs.FSSpec(':cancelled') else: if rr.selection: --- 48,52 ---- raise Nav.error, arg good = 0 ! fss = None else: if rr.selection: *************** *** 75,79 **** raise Nav.error, arg good = 0 ! fss = macfs.FSSpec(':cancelled') else: fss = rr.selection[0] --- 78,82 ---- raise Nav.error, arg good = 0 ! fss = None else: fss = rr.selection[0] *************** *** 116,120 **** raise Nav.error, arg good = 0 ! fss = macfs.FSSpec(':cancelled') else: fss = rr.selection[0] --- 119,123 ---- raise Nav.error, arg good = 0 ! fss = None else: fss = rr.selection[0] From gvanrossum@users.sourceforge.net Fri Mar 29 21:20:34 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 29 Mar 2002 13:20:34 -0800 Subject: [Python-checkins] CVS: python/nondist/sandbox/datetime datetime.py,1.57,1.58 test_datetime.py,1.41,1.42 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/datetime In directory usw-pr-cvs1:/tmp/cvs-serv29203 Modified Files: datetime.py test_datetime.py Log Message: - Make tzinfo a property instead of a method. - Add some XXX comments. - Move timedatetz's __hash__ after __cmp__, since it should match __cmp__ (and not the other way around). - Use 'is' instead of '==' to compare tzinfo objects. Index: datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.py,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** datetime.py 19 Mar 2002 17:09:51 -0000 1.57 --- datetime.py 29 Mar 2002 21:20:32 -0000 1.58 *************** *** 249,252 **** --- 249,253 ---- + # XXX I don't think we should use this. Let's rip it out. class basetime(object): """Abstract date/time type. *************** *** 494,497 **** --- 495,499 ---- __init__() + fromtimestamp() today() fromordinal() *************** *** 949,952 **** --- 951,956 ---- self.__tzinfo = tzinfo + tzinfo = property(lambda self: self.__tzinfo, doc="timezone info object") + def isoformat(self, sep='T'): s = super(datetimetz, self).isoformat(sep) *************** *** 970,978 **** return s - # XXX property or method? - #tzinfo = property(lambda self: self.__tzinfo, doc="timezone info object") - def tzinfo(self): - return self.__tzinfo - def utcoffset(self): tz = self.__tzinfo --- 974,977 ---- *************** *** 996,1009 **** return tz.dst(self) - def __hash__(self): - tz = self.__tzinfo - if tz == None: - return super(datetime, self).__hash__() - tzoff = tz.utcoffset(self) - if not tzoff: # zero or None! - return super(datetime, self).__hash__() - t = self - timedelta(minutes=tzoff) - return super(datetime, t).__hash__() - def __add__(self, other): result = super(datetimetz, self).__add__(other) --- 995,998 ---- *************** *** 1017,1031 **** supersub = super(datetimetz, self).__sub__ if not isinstance(other, datetime): ! return supersub(other) mytz = self.__tzinfo ottz = None if isinstance(other, datetimetz): ottz = other.__tzinfo ! if mytz == ottz: return supersub(other) myoff = otoff = None ! if self.__tzinfo is not None: myoff = self.__tzinfo.utcoffset(self) ! if isinstance(other, datetimetz) and other.__tzinfo is not None: otoff = other.__tzinfo.utcoffset(other) if myoff == otoff: --- 1006,1020 ---- supersub = super(datetimetz, self).__sub__ if not isinstance(other, datetime): ! return supersub(other) # XXX should set tzinfo on result mytz = self.__tzinfo ottz = None if isinstance(other, datetimetz): ottz = other.__tzinfo ! if mytz is ottz: return supersub(other) myoff = otoff = None ! if mytz is not None: myoff = self.__tzinfo.utcoffset(self) ! if ottz is not None: otoff = other.__tzinfo.utcoffset(other) if myoff == otoff: *************** *** 1045,1049 **** if isinstance(other, datetimetz): ottz = other.__tzinfo ! if mytz == ottz: return supercmp(other) myoff = otoff = None --- 1034,1038 ---- if isinstance(other, datetimetz): ottz = other.__tzinfo ! if mytz is ottz: return supercmp(other) myoff = otoff = None *************** *** 1056,1059 **** --- 1045,1049 ---- if myoff is None or otoff is None: raise ValueError, "cannot mix naive and timezone-aware time" + # XXX What follows could be done more efficiently... diff = superself.__sub__(other) + timedelta(minutes=otoff-myoff) if diff.days < 0: *************** *** 1062,1065 **** --- 1052,1065 ---- return 0 return 1 + + def __hash__(self): + tz = self.__tzinfo + if tz == None: + return super(datetimetz, self).__hash__() + tzoff = tz.utcoffset(self) + if not tzoff: # zero or None! + return super(datetimetz, self).__hash__() + t = self - timedelta(minutes=tzoff) + return super(datetimetz, t).__hash__() Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** test_datetime.py 19 Mar 2002 17:10:17 -0000 1.41 --- test_datetime.py 29 Mar 2002 21:20:32 -0000 1.42 *************** *** 542,548 **** t2 = datetimetz(2002, 3, 19, 12, 47, tzinfo=utc) t3 = datetimetz(2002, 3, 19, 13, 47, tzinfo=met) ! self.assertEqual(t1.tzinfo(), est) ! self.assertEqual(t2.tzinfo(), utc) ! self.assertEqual(t3.tzinfo(), met) self.assertEqual(t1.utcoffset(), -300) self.assertEqual(t2.utcoffset(), 0) --- 542,548 ---- t2 = datetimetz(2002, 3, 19, 12, 47, tzinfo=utc) t3 = datetimetz(2002, 3, 19, 13, 47, tzinfo=met) ! self.assertEqual(t1.tzinfo, est) ! self.assertEqual(t2.tzinfo, utc) ! self.assertEqual(t3.tzinfo, met) self.assertEqual(t1.utcoffset(), -300) self.assertEqual(t2.utcoffset(), 0) From jackjansen@users.sourceforge.net Fri Mar 29 21:21:31 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 29 Mar 2002 13:21:31 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Lib buildtools.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib In directory usw-pr-cvs1:/tmp/cvs-serv29893 Modified Files: buildtools.py Log Message: Implemented buildtools for MachoPython .app bundles. The API is compatible enough that IDE and BuildApplet can create applets, yeah! Index: buildtools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Lib/buildtools.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** buildtools.py 25 Aug 2001 12:01:58 -0000 1.9 --- buildtools.py 29 Mar 2002 21:21:28 -0000 1.10 *************** *** 11,15 **** --- 11,17 ---- import MacOS import macostools + import macresource import EasyDialogs + import shutil *************** *** 43,46 **** --- 45,52 ---- def findtemplate(template=None): """Locate the applet template along sys.path""" + if MacOS.runtimemodel == 'macho': + if template: + return template + return findtemplate_macho() if not template: template=TEMPLATE *************** *** 56,59 **** --- 62,72 ---- file = file.as_pathname() return file + + def findtemplate_macho(): + execpath = sys.executable.split('/') + if not 'Contents' in execpath: + raise BuildError, "Not running from a .app bundle: %s" % sys.executable + i = execpath.index('Contents') + return '/'.join(execpath[:i]) *************** *** 83,87 **** rsrcname = destname + '.rsrc' else: ! destname = filename + ".applet" rsrcname = filename + '.rsrc' --- 96,103 ---- rsrcname = destname + '.rsrc' else: ! if MacOS.runtimemodel == 'macho': ! destname = filename + '.app' ! else: ! destname = filename + ".applet" rsrcname = filename + '.rsrc' *************** *** 89,93 **** destname = output ! # Try removing the output file try: os.remove(destname) --- 105,110 ---- destname = output ! # Try removing the output file. This fails in MachO, but it should ! # do any harm. try: os.remove(destname) *************** *** 98,101 **** --- 115,120 ---- def update(template, filename, output): + if MacOS.runtimemodel == 'macho': + raise BuildError, "No updating yet for MachO applets" if DEBUG: progress = EasyDialogs.ProgressBar("Updating %s..."%os.path.split(filename)[1], 120) *************** *** 114,117 **** --- 133,138 ---- def process_common(template, progress, code, rsrcname, destname, is_update, copy_codefragment): + if MacOS.runtimemodel == 'macho': + return process_common_macho(template, progress, code, rsrcname, destname, is_update) # Create FSSpecs for the various files template_fss = macfs.FSSpec(template) *************** *** 239,242 **** --- 260,356 ---- progress.label("Done.") + def process_common_macho(template, progress, code, rsrcname, destname, is_update): + # First make sure the name ends in ".app" + if destname[-4:] != '.app': + destname = destname + '.app' + # Now deduce the short name + shortname = os.path.split(destname)[1] + if shortname[-4:] == '.app': + # Strip the .app suffix + shortname = shortname[:-4] + plistname = shortname + '.plist' + # Start with copying the .app framework + if not is_update: + exceptlist = ["Contents/Info.plist", + "Contents/Resources/English.lproj/InfoPlist.strings", + "Contents/Resources/python.rsrc", + ] + copyapptree(template, destname, exceptlist) + # Now either use the .plist file or the default + if plistname and os.path.exists(plistname): + shutil.copy2(plistname, os.path.join(destname, 'Contents/Info.plist')) + # XXXX Wrong. This should be parsed from plist file + # icnsname = 'PythonApplet.icns' + ownertype = 'PytA' + # XXXX Should copy .icns file + else: + plistname = os.path.join(template, 'Contents/Resources/Applet-Info.plist') + plistdata = open(plistname).read() + plistdata = plistdata % {'appletname':shortname} + ofp = open(os.path.join(destname, 'Contents/Info.plist'), 'w') + ofp.write(plistdata) + ofp.close() + ownertype = 'PytA' + # Create the PkgInfo file + ofp = open(os.path.join(destname, 'Contents/PkgInfo'), 'wb') + ofp.write('APPL' + ownertype) + ofp.close() + + + if DEBUG: + progress.label("Copy resources...") + progress.set(20) + resfilename = '%s.rsrc' % shortname + respartialpathname = 'Contents/Resources/%s' % resfilename + try: + output = Res.FSOpenResourceFile( + os.path.join(destname, respartialpathname), + u'', WRITE) + except MacOS.Error: + fsr, dummy = Res.FSCreateResourceFile( + os.path.join(destname, 'Contents/Resources'), + unicode(resfilename), '') + output = Res.FSOpenResourceFile(fsr, u'', WRITE) + + # Copy the resources from the target specific resource template, if any + typesfound, ownertype = [], None + try: + input = macresource.open_pathname(rsrcname) + except (MacOS.Error, ValueError): + pass + if DEBUG: + progress.inc(50) + else: + typesfound, ownertype = copyres(input, output, [], 0, progress) + Res.CloseResFile(input) + + # Check which resource-types we should not copy from the template + skiptypes = [] + ## if 'vers' in typesfound: skiptypes.append('vers') + ## if 'SIZE' in typesfound: skiptypes.append('SIZE') + ## if 'BNDL' in typesfound: skiptypes = skiptypes + ['BNDL', 'FREF', 'icl4', + ## 'icl8', 'ics4', 'ics8', 'ICN#', 'ics#'] + ## if not copy_codefragment: + ## skiptypes.append('cfrg') + ## skipowner = (ownertype <> None) + + # Copy the resources from the template + + input = Res.FSOpenResourceFile( + os.path.join(template, 'Contents/Resources/python.rsrc'), u'', READ) + dummy, tmplowner = copyres(input, output, skiptypes, 1, progress) + + Res.CloseResFile(input) + ## if ownertype == None: + ## raise BuildError, "No owner resource found in either resource file or template" + # Make sure we're manipulating the output resource file now + + Res.CloseResFile(output) + + if code: + outputfilename = os.path.join(destname, 'Contents/Resources/__main__.pyc') + writepycfile(code, outputfilename) + + ## macostools.touched(dest_fss) # Copy resources between two resource file descriptors. *************** *** 290,292 **** --- 404,440 ---- return alltypes, ctor + def copyapptree(srctree, dsttree, exceptlist=[]): + names = [] + if os.path.exists(dsttree): + shutil.rmtree(dsttree) + os.mkdir(dsttree) + todo = os.listdir(srctree) + while todo: + this, todo = todo[0], todo[1:] + if this in exceptlist: + continue + thispath = os.path.join(srctree, this) + if os.path.isdir(thispath): + thiscontent = os.listdir(thispath) + for t in thiscontent: + todo.append(os.path.join(this, t)) + names.append(this) + for this in names: + srcpath = os.path.join(srctree, this) + dstpath = os.path.join(dsttree, this) + if os.path.isdir(srcpath): + os.mkdir(dstpath) + else: + shutil.copy2(srcpath, dstpath) + + def writepycfile(codeobject, cfile): + import marshal + fc = open(cfile, 'wb') + fc.write('\0\0\0\0') # MAGIC placeholder, written later + fc.write('\0\0\0\0') # Timestap placeholder, not needed + marshal.dump(codeobject, fc) + fc.flush() + fc.seek(0, 0) + fc.write(MAGIC) + fc.close() From fdrake@users.sourceforge.net Fri Mar 29 21:23:42 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 29 Mar 2002 13:23:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc Makefile,1.235.2.1.2.3,1.235.2.1.2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory usw-pr-cvs1:/tmp/cvs-serv30673 Modified Files: Tag: release22-maint Makefile Log Message: Set version info for the emergency "Don't Kill Opera" documentation release. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile,v retrieving revision 1.235.2.1.2.3 retrieving revision 1.235.2.1.2.4 diff -C2 -d -r1.235.2.1.2.3 -r1.235.2.1.2.4 *** Makefile 25 Mar 2002 19:38:16 -0000 1.235.2.1.2.3 --- Makefile 29 Mar 2002 21:23:40 -0000 1.235.2.1.2.4 *************** *** 67,71 **** # This is the *documentation* release, and is used to construct the file # names of the downloadable tarballs. ! RELEASE=2.2.1c2 PYTHON= python --- 67,71 ---- # This is the *documentation* release, and is used to construct the file # names of the downloadable tarballs. ! RELEASE=2.2p1 PYTHON= python From fdrake@users.sourceforge.net Fri Mar 29 21:23:42 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 29 Mar 2002 13:23:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/texinputs boilerplate.tex,1.70.2.1.2.3,1.70.2.1.2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory usw-pr-cvs1:/tmp/cvs-serv30673/texinputs Modified Files: Tag: release22-maint boilerplate.tex Log Message: Set version info for the emergency "Don't Kill Opera" documentation release. Index: boilerplate.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/boilerplate.tex,v retrieving revision 1.70.2.1.2.3 retrieving revision 1.70.2.1.2.4 diff -C2 -d -r1.70.2.1.2.3 -r1.70.2.1.2.4 *** boilerplate.tex 25 Mar 2002 19:38:17 -0000 1.70.2.1.2.3 --- boilerplate.tex 29 Mar 2002 21:23:40 -0000 1.70.2.1.2.4 *************** *** 7,11 **** \date{\today} % XXX update before release! ! \release{2.2.1} % software release, not documentation ! \setreleaseinfo{c2} % empty for final release \setshortversion{2.2} % major.minor only for software --- 7,11 ---- \date{\today} % XXX update before release! ! \release{2.2} % software release, not documentation ! \setreleaseinfo{p1} % empty for final release \setshortversion{2.2} % major.minor only for software From jackjansen@users.sourceforge.net Fri Mar 29 21:23:49 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 29 Mar 2002 13:23:49 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Tools/IDE PythonIDEMain.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory usw-pr-cvs1:/tmp/cvs-serv30422 Modified Files: PythonIDEMain.py Log Message: Allow file without filetype as long as they end in ".py". Added a -D flag (can really only be specified on OSX commandline) to not revector sys.stderr, for debugging the IDE itself. Not sure whether this should stay. Index: PythonIDEMain.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PythonIDEMain.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PythonIDEMain.py 4 Feb 2002 12:48:06 -0000 1.16 --- PythonIDEMain.py 29 Mar 2002 21:23:47 -0000 1.17 *************** *** 7,10 **** --- 7,11 ---- import W import os + import sys import macfs import MacOS *************** *** 43,49 **** import PyConsole, PyEdit Splash.wait() PyConsole.installoutput() PyConsole.installconsole() ! import sys for path in sys.argv[1:]: self.opendoc(path) --- 44,57 ---- import PyConsole, PyEdit Splash.wait() + # With -D option (OSX command line only) keep stderr, for debugging the IDE + # itself. + debug_stderr = None + if sys.argv[1] == '-D': + debug_stderr = sys.stderr + del sys.argv[1] PyConsole.installoutput() PyConsole.installconsole() ! if debug_stderr: ! sys.stderr = debug_stderr for path in sys.argv[1:]: self.opendoc(path) *************** *** 171,174 **** --- 179,184 ---- fcreator, ftype = macfs.FSSpec(path).GetCreatorType() if ftype == 'TEXT': + self.openscript(path) + elif ftype == '\0\0\0\0' and path[-3:] == '.py': self.openscript(path) else: From jackjansen@users.sourceforge.net Fri Mar 29 21:26:06 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 29 Mar 2002 13:26:06 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Tools/IDE PyEdit.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory usw-pr-cvs1:/tmp/cvs-serv30823 Modified Files: PyEdit.py Log Message: Completely revamped newline handling. PyEdit is now newline-preserving (if a single newline convention is used in the sourcefile), and the "save options" has a newline style radio button. The creator radio button also has the new choices PythonW and None. Just: just shout (and revert) if you don't agree. Index: PyEdit.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PyEdit.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** PyEdit.py 4 Feb 2002 12:50:24 -0000 1.28 --- PyEdit.py 29 Mar 2002 21:26:04 -0000 1.29 *************** *** 52,55 **** --- 52,56 ---- text = "" self._creator = W._signature + self._eoln = os.linesep elif os.path.exists(path): path = resolvealiases(path) *************** *** 68,83 **** import EasyDialogs if string.find(text, '\r\n') >= 0: ! sourceOS = 'DOS' ! searchString = '\r\n' else: ! sourceOS = 'UNIX' ! searchString = '\n' ! change = EasyDialogs.AskYesNoCancel('"%s" contains %s-style line feeds. ' ! 'Change them to MacOS carriage returns?' % (self.title, sourceOS), 1) ! # bug: Cancel is treated as No ! if change > 0: ! text = string.replace(text, searchString, '\r') else: change = 0 self.settings = {} --- 69,80 ---- import EasyDialogs if string.find(text, '\r\n') >= 0: ! self._eoln = '\r\n' else: ! self._eoln = '\n' ! text = string.replace(text, self._eoln, '\r') ! change = 0 else: change = 0 + self._eoln = '\r' self.settings = {} *************** *** 319,326 **** def domenu_options(self, *args): ! rv = SaveOptions(self._creator) ! if rv: self.editgroup.editor.selectionchanged() # ouch... ! self._creator = rv def clicklinefield(self): --- 316,324 ---- def domenu_options(self, *args): ! rvcreator, rveoln = SaveOptions(self._creator, self._eoln) ! if rvcreator != self._creator or rveoln != self._eoln: self.editgroup.editor.selectionchanged() # ouch... ! self._creator = rvcreator ! self._eoln = rveoln def clicklinefield(self): *************** *** 384,387 **** --- 382,387 ---- return self.domenu_save_as() data = self.editgroup.editor.get() + if self._eoln != '\r': + data = string.replace(data, '\r', self._eoln) fp = open(self.path, 'wb') # open file in binary mode, data has '\r' line-endings fp.write(data) *************** *** 745,757 **** class _saveoptions: ! def __init__(self, creator): self.rv = None ! self.w = w = W.ModalDialog((240, 140), 'Save options') radiobuttons = [] w.label = W.TextBox((8, 8, 80, 18), "File creator:") w.ide_radio = W.RadioButton((8, 22, 160, 18), "This application", radiobuttons, self.ide_hit) ! w.interp_radio = W.RadioButton((8, 42, 160, 18), "Python Interpreter", radiobuttons, self.interp_hit) ! w.other_radio = W.RadioButton((8, 62, 50, 18), "Other:", radiobuttons) ! w.other_creator = W.EditText((62, 62, 40, 20), creator, self.otherselect) w.cancelbutton = W.Button((-180, -30, 80, 16), "Cancel", self.cancelbuttonhit) w.okbutton = W.Button((-90, -30, 80, 16), "Done", self.okbuttonhit) --- 745,760 ---- class _saveoptions: ! def __init__(self, creator, eoln): self.rv = None ! self.eoln = eoln ! self.w = w = W.ModalDialog((260, 160), 'Save options') radiobuttons = [] w.label = W.TextBox((8, 8, 80, 18), "File creator:") w.ide_radio = W.RadioButton((8, 22, 160, 18), "This application", radiobuttons, self.ide_hit) ! w.interp_radio = W.RadioButton((8, 42, 160, 18), "MacPython Interpreter", radiobuttons, self.interp_hit) ! w.interpx_radio = W.RadioButton((8, 62, 160, 18), "OSX PythonW Interpreter", radiobuttons, self.interpx_hit) ! w.other_radio = W.RadioButton((8, 82, 50, 18), "Other:", radiobuttons) ! w.other_creator = W.EditText((62, 82, 40, 20), creator, self.otherselect) ! w.none_radio = W.RadioButton((8, 102, 160, 18), "None", radiobuttons, self.none_hit) w.cancelbutton = W.Button((-180, -30, 80, 16), "Cancel", self.cancelbuttonhit) w.okbutton = W.Button((-90, -30, 80, 16), "Done", self.okbuttonhit) *************** *** 761,766 **** --- 764,786 ---- elif creator == W._signature: w.ide_radio.set(1) + elif creator == 'PytX': + w.interpx_radio.set(1) + elif creator == '\0\0\0\0': + w.none_radio.set(1) else: w.other_radio.set(1) + + w.eolnlabel = W.TextBox((168, 8, 80, 18), "Newline style:") + radiobuttons = [] + w.unix_radio = W.RadioButton((168, 22, 80, 18), "Unix", radiobuttons, self.unix_hit) + w.mac_radio = W.RadioButton((168, 42, 80, 18), "Macintosh", radiobuttons, self.mac_hit) + w.win_radio = W.RadioButton((168, 62, 80, 18), "Windows", radiobuttons, self.win_hit) + if self.eoln == '\n': + w.unix_radio.set(1) + elif self.eoln == '\r\n': + w.win_radio.set(1) + else: + w.mac_radio.set(1) + w.bind("cmd.", w.cancelbutton.push) w.open() *************** *** 772,775 **** --- 792,801 ---- self.w.other_creator.set("Pyth") + def interpx_hit(self): + self.w.other_creator.set("PytX") + + def none_hit(self): + self.w.other_creator.set("\0\0\0\0") + def otherselect(self, *args): sel_from, sel_to = self.w.other_creator.getselection() *************** *** 780,793 **** self.w.other_radio.set(1) def cancelbuttonhit(self): self.w.close() def okbuttonhit(self): ! self.rv = self.w.other_creator.get()[:4] self.w.close() ! def SaveOptions(creator): ! s = _saveoptions(creator) return s.rv --- 806,828 ---- self.w.other_radio.set(1) + def mac_hit(self): + self.eoln = '\r' + + def unix_hit(self): + self.eoln = '\n' + + def win_hit(self): + self.eoln = '\r\n' + def cancelbuttonhit(self): self.w.close() def okbuttonhit(self): ! self.rv = (self.w.other_creator.get()[:4], self.eoln) self.w.close() ! def SaveOptions(creator, eoln): ! s = _saveoptions(creator, eoln) return s.rv From fdrake@users.sourceforge.net Fri Mar 29 21:32:27 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 29 Mar 2002 13:32:27 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc Makefile,1.235.2.1.2.4,1.235.2.1.2.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory usw-pr-cvs1:/tmp/cvs-serv418 Modified Files: Tag: release22-maint Makefile Log Message: Preparing for the next release. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile,v retrieving revision 1.235.2.1.2.4 retrieving revision 1.235.2.1.2.5 diff -C2 -d -r1.235.2.1.2.4 -r1.235.2.1.2.5 *** Makefile 29 Mar 2002 21:23:40 -0000 1.235.2.1.2.4 --- Makefile 29 Mar 2002 21:32:25 -0000 1.235.2.1.2.5 *************** *** 67,71 **** # This is the *documentation* release, and is used to construct the file # names of the downloadable tarballs. ! RELEASE=2.2p1 PYTHON= python --- 67,71 ---- # This is the *documentation* release, and is used to construct the file # names of the downloadable tarballs. ! RELEASE=2.2.1 PYTHON= python From jvr@users.sourceforge.net Fri Mar 29 21:47:58 2002 From: jvr@users.sourceforge.net (Just van Rossum) Date: Fri, 29 Mar 2002 13:47:58 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Tools/IDE PythonIDEMain.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory usw-pr-cvs1:/tmp/cvs-serv4122 Modified Files: PythonIDEMain.py Log Message: repair damage: now works again as a CFM app. Index: PythonIDEMain.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PythonIDEMain.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** PythonIDEMain.py 29 Mar 2002 21:23:47 -0000 1.17 --- PythonIDEMain.py 29 Mar 2002 21:47:56 -0000 1.18 *************** *** 47,51 **** # itself. debug_stderr = None ! if sys.argv[1] == '-D': debug_stderr = sys.stderr del sys.argv[1] --- 47,51 ---- # itself. debug_stderr = None ! if len(sys.argv) >= 2 and sys.argv[1] == '-D': debug_stderr = sys.stderr del sys.argv[1] From jvr@users.sourceforge.net Fri Mar 29 21:48:44 2002 From: jvr@users.sourceforge.net (Just van Rossum) Date: Fri, 29 Mar 2002 13:48:44 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Tools/IDE PyEdit.py,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory usw-pr-cvs1:/tmp/cvs-serv4313 Modified Files: PyEdit.py Log Message: repair damage: canceling the "save options" dialog now works again. Index: PyEdit.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PyEdit.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** PyEdit.py 29 Mar 2002 21:26:04 -0000 1.29 --- PyEdit.py 29 Mar 2002 21:48:42 -0000 1.30 *************** *** 316,324 **** def domenu_options(self, *args): ! rvcreator, rveoln = SaveOptions(self._creator, self._eoln) ! if rvcreator != self._creator or rveoln != self._eoln: self.editgroup.editor.selectionchanged() # ouch... ! self._creator = rvcreator ! self._eoln = rveoln def clicklinefield(self): --- 316,323 ---- def domenu_options(self, *args): ! rv = SaveOptions(self._creator, self._eoln) ! if rv: self.editgroup.editor.selectionchanged() # ouch... ! self._creator, self._eoln = rv def clicklinefield(self): From jackjansen@users.sourceforge.net Fri Mar 29 22:28:34 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 29 Mar 2002 14:28:34 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/OSXResources/iconsrc IDE.psd,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSXResources/iconsrc In directory usw-pr-cvs1:/tmp/cvs-serv13381/Python/Mac/OSXResources/iconsrc Added Files: IDE.psd Log Message: First stab at an icon for the IDE. --- NEW FILE: IDE.psd --- (This appears to be a binary file; contents omitted.) From fdrake@users.sourceforge.net Fri Mar 29 22:45:30 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 29 Mar 2002 14:45:30 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ext newtypes.tex,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory usw-pr-cvs1:/tmp/cvs-serv18425/ext Modified Files: newtypes.tex Log Message: Started updating information about defining attributes on types. There's still a long way to go, but we're starting to see some real content in the docs. Index: newtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/newtypes.tex,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** newtypes.tex 28 Mar 2002 23:45:22 -0000 1.10 --- newtypes.tex 29 Mar 2002 22:45:28 -0000 1.11 *************** *** 431,435 **** { return PyString_FromFormat("Repr-ified_newdatatype{{size:\%d}}", ! obj->obj_UnderlyingDatatypePtr->size); } \end{verbatim} --- 431,435 ---- { return PyString_FromFormat("Repr-ified_newdatatype{{size:\%d}}", ! obj->obj_UnderlyingDatatypePtr->size); } \end{verbatim} *************** *** 454,459 **** { return PyString_FromFormat("Stringified_newdatatype{{size:\%d}}", ! obj->obj_UnderlyingDatatypePtr->size ! ); } \end{verbatim} --- 454,458 ---- { return PyString_FromFormat("Stringified_newdatatype{{size:\%d}}", ! obj->obj_UnderlyingDatatypePtr->size); } \end{verbatim} *************** *** 495,504 **** \subsection{Attribute Management Functions} \begin{verbatim} ! getattrfunc tp_getattr; ! setattrfunc tp_setattr; \end{verbatim} ! The \member{tp_getattr} handle is called when the object requires an attribute look-up. It is called in the same situations where the \method{__getattr__()} method of a class would be called. --- 494,666 ---- \subsection{Attribute Management Functions} + For every object which can support attributes, the corresponding type + must provide the functions that control how the attributes are + resolved. There needs to be a function which can retrieve attributes + (if any are defined), and another to set attributes (if setting + attributes is allowed). Removing an attribute is a special case, for + which the new value passed to the handler is \NULL. + + Python supports two pairs of attribute handlers; a type that supports + attributes only needs to implement the functions for one pair. The + difference is that one pair takes the name of the attribute as a + \ctype{char*}, while the other accepts a \ctype{PyObject*}. Each type + can use whichever pair makes more sense for the implementation's + convenience. + \begin{verbatim} ! getattrfunc tp_getattr; /* char * version */ ! setattrfunc tp_setattr; ! /* ... */ ! getattrofunc tp_getattrofunc; /* PyObject * version */ ! setattrofunc tp_setattrofunc; \end{verbatim} ! If accessing attributes of an object is always a simple operation ! (this will be explained shortly), there are generic implementations ! which can be used to provide the \ctype{PyObject*} version of the ! attribute management functions. The actual need for type-specific ! attribute handlers almost completely disappeared starting with Python ! 2.2, though there are many examples which have not been updated to use ! some of the new generic mechanism that is available. ! ! ! \subsubsection{Generic Attribute Management} ! ! \versionadded{2.2} ! ! Most extension types only use \emph{simple} attributes. So, what ! makes the attributes simple? There are only a couple of conditions ! that must be met: ! ! \begin{enumerate} ! \item The name of the attributes must be known when ! \cfunction{PyType_Ready()} is called. ! ! \item No special processing is need to record that an attribute ! was looked up or set, nor do actions need to be taken based ! on the value. ! \end{enumerate} ! ! Note that this list does not place any restrictions on the values of ! the attributes, when the values are computed, or how relevant data is ! stored. ! ! When \cfunction{PyType_Ready()} is called, it uses three tables ! referenced by the type object to create \emph{descriptors} which are ! placed in the dictionary of the type object. Each descriptor controls ! access to one attribute of the instance object. Each of the tables is ! optional; if all three are \NULL, instances of the type will only have ! attributes that are inherited from their base type, and should leave ! the \member{tp_getattro} and \member{tp_setattro} fields \NULL{} as ! well, allowing the base type to handle attributes. ! ! The tables are declared as three fields of the type object: ! ! \begin{verbatim} ! struct PyMethodDef *tp_methods; ! struct PyMemberDef *tp_members; ! struct PyGetSetDef *tp_getset; ! \end{verbatim} ! ! If \member{tp_methods} is not \NULL, it must refer to an array of ! \ctype{PyMethodDef} structures. Each entry in the table is an ! instance of this structure: ! ! \begin{verbatim} ! typedef struct PyMethodDef { ! char *ml_name; /* method name */ ! PyCFunction ml_meth; /* implementation function */ ! int ml_flags; /* flags */ ! char *ml_doc; /* docstring */ ! } PyMethodDef; ! \end{verbatim} ! ! One entry should be defined for each method provided by the type; no ! entries are needed for methods inherited from a base type. One ! additional entry is needed at the end; it is a sentinel that marks the ! end of the array. The \member{ml_name} field of the sentinel must be ! \NULL. ! ! XXX Need to refer to some unified discussion of the structure fields, ! shared with the next section. ! ! The second table is used to define attributes which map directly to ! data stored in the instance. A variety of primitive C types are ! supported, and access may be read-only or read-write. The structures ! in the table are defined as: ! ! \begin{verbatim} ! typedef struct PyMemberDef { ! char *name; ! int type; ! int offset; ! int flags; ! char *doc; ! } PyMemberDef; ! \end{verbatim} ! ! For each entry in the table, a descriptor will be constructed and ! added to the type which will be able to extract a value from the ! instance structure. The \member{type} field should contain one of the ! type codes defined in the \file{structmember.h} header; the value will ! be used to determine how to convert Python values to and from C ! values. The \member{flags} field is used to store flags which control ! how the attribute can be accessed. ! ! XXX Need to move some of this to a shared section! ! ! The following flag constants are defined in \file{structmember.h}; ! they may be combined using bitwise-OR. ! ! \begin{tableii}{l|l}{constant}{Constant}{Meaning} ! \lineii{READONLY \ttindex{READONLY}} ! {Never writable.} ! \lineii{RO \ttindex{RO}} ! {Shorthand for \constant{READONLY}.} ! \lineii{READ_RESTRICTED \ttindex{READ_RESTRICTED}} ! {Not readable in restricted mode.} ! \lineii{WRITE_RESTRICTED \ttindex{WRITE_RESTRICTED}} ! {Not writable in restricted mode.} ! \lineii{RESTRICTED \ttindex{RESTRICTED}} ! {Not readable or writable in restricted mode.} ! \end{tableii} ! ! An interesting advantage of using the \member{tp_members} table to ! build descriptors that are used at runtime is that any attribute ! defined this way can have an associated docstring simply by providing ! the text in the table. An application can use the introspection API ! to retrieve the descriptor from the class object, and get the ! docstring using its \member{__doc__} attribute. ! ! As with the \member{tp_methods} table, a sentinel entry with a ! \member{name} value of \NULL{} is required. ! ! ! % XXX Descriptors need to be explained in more detail somewhere, but ! % not here. ! % ! % Descriptor objects have two handler functions which correspond to ! % the \member{tp_getattro} and \member{tp_setattro} handlers. The ! % \method{__get__()} handler is a function which is passed the ! % descriptor, instance, and type objects, and returns the value of the ! % attribute, or it returns \NULL{} and sets an exception. The ! % \method{__set__()} handler is passed the descriptor, instance, type, ! % and new value; ! ! ! \subsubsection{Type-specific Attribute Management} ! ! For simplicity, only the \ctype{char*} version will be demonstrated ! here; the type of the name parameter is the only difference between ! the \ctype{char*} and \ctype{PyObject*} flavors of the interface. ! This example effectively does the same thing as the generic example ! above, but does not use the generic support added in Python 2.2. The ! value in showing this is two-fold: it demonstrates how basic attribute ! management can be done in a way that is portable to older versions of ! Python, and explains how the handler functions are called, so that if ! you do need to extend their functionality, you'll understand what ! needs to be done. ! ! The \member{tp_getattr} handler is called when the object requires an attribute look-up. It is called in the same situations where the \method{__getattr__()} method of a class would be called. *************** *** 508,512 **** \cfunction{newdatatype_setSize()} in the example below), (2) provide a method table listing these functions, and (3) provide a getattr ! function that returns the result of a lookup in that table. Here is an example: --- 670,676 ---- \cfunction{newdatatype_setSize()} in the example below), (2) provide a method table listing these functions, and (3) provide a getattr ! function that returns the result of a lookup in that table. The ! method table uses the same structure as the \member{tp_methods} field ! of the type object. Here is an example: From fdrake@users.sourceforge.net Fri Mar 29 22:46:06 2002 From: fdrake@users.sourceforge.net (Fred L. Drake) Date: Fri, 29 Mar 2002 14:46:06 -0800 Subject: [Python-checkins] CVS: python/dist/src/Doc/ext typestruct.h,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory usw-pr-cvs1:/tmp/cvs-serv18649/ext Modified Files: typestruct.h Log Message: Use the right types for a couple of fields of the type structure. Index: typestruct.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/typestruct.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** typestruct.h 28 Mar 2002 23:32:53 -0000 1.1 --- typestruct.h 29 Mar 2002 22:46:04 -0000 1.2 *************** *** 56,61 **** /* Attribute descriptor and subclassing stuff */ struct PyMethodDef *tp_methods; ! struct memberlist *tp_members; ! struct getsetlist *tp_getset; struct _typeobject *tp_base; PyObject *tp_dict; --- 56,61 ---- /* Attribute descriptor and subclassing stuff */ struct PyMethodDef *tp_methods; ! struct PyMemberDef *tp_members; ! struct PyGetSetDef *tp_getset; struct _typeobject *tp_base; PyObject *tp_dict; From jackjansen@users.sourceforge.net Fri Mar 29 23:43:23 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 29 Mar 2002 15:43:23 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/OSXResources/app Info.plist,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSXResources/app In directory usw-pr-cvs1:/tmp/cvs-serv604/OSXResources/app Modified Files: Info.plist Log Message: Missed one version number. Index: Info.plist =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSXResources/app/Info.plist,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Info.plist 29 Mar 2002 21:16:41 -0000 1.5 --- Info.plist 29 Mar 2002 23:43:21 -0000 1.6 *************** *** 75,79 **** PytX CFBundleVersion ! 2.2 LSRequiresCarbon --- 75,79 ---- PytX CFBundleVersion ! 2.3 LSRequiresCarbon From jackjansen@users.sourceforge.net Fri Mar 29 23:44:39 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 29 Mar 2002 15:44:39 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Lib buildtools.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib In directory usw-pr-cvs1:/tmp/cvs-serv794 Modified Files: buildtools.py Log Message: Handle .icns and .plist files for applets. Also, for now (until we learn to parse .plist files) we make a special case for the IDE, setting the creator to "Pide". Index: buildtools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Lib/buildtools.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** buildtools.py 29 Mar 2002 21:21:28 -0000 1.10 --- buildtools.py 29 Mar 2002 23:44:37 -0000 1.11 *************** *** 269,273 **** # Strip the .app suffix shortname = shortname[:-4] ! plistname = shortname + '.plist' # Start with copying the .app framework if not is_update: --- 269,284 ---- # Strip the .app suffix shortname = shortname[:-4] ! # And deduce the .plist and .icns names ! plistname = None ! icnsname = None ! if rsrcname and rsrcname[-5:] == '.rsrc': ! tmp = rsrcname[:-5] ! plistname = tmp + '.plist' ! if os.path.exists(plistname): ! icnsname = tmp + '.icns' ! if not os.path.exists(icnsname): ! icnsname = None ! else: ! plistname = None # Start with copying the .app framework if not is_update: *************** *** 278,286 **** copyapptree(template, destname, exceptlist) # Now either use the .plist file or the default ! if plistname and os.path.exists(plistname): shutil.copy2(plistname, os.path.join(destname, 'Contents/Info.plist')) ! # XXXX Wrong. This should be parsed from plist file ! # icnsname = 'PythonApplet.icns' ! ownertype = 'PytA' # XXXX Should copy .icns file else: --- 289,304 ---- copyapptree(template, destname, exceptlist) # Now either use the .plist file or the default ! if plistname: shutil.copy2(plistname, os.path.join(destname, 'Contents/Info.plist')) ! if icnsname: ! icnsdest = os.path.split(icnsname)[1] ! icnsdest = os.path.join(destname, ! os.path.join('Contents/Resources', icnsdest)) ! shutil.copy2(icnsname, icnsdest) ! # XXXX Wrong. This should be parsed from plist file. Also a big hack:-) ! if shortname == 'PythonIDE': ! ownertype = 'Pide' ! else: ! ownertype = 'PytA' # XXXX Should copy .icns file else: From jackjansen@users.sourceforge.net Fri Mar 29 23:46:36 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 29 Mar 2002 15:46:36 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Tools/IDE PythonIDE.icns,NONE,1.1 PythonIDE.plist,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory usw-pr-cvs1:/tmp/cvs-serv1259 Added Files: PythonIDE.icns PythonIDE.plist Log Message: Auxiliary files for building the IDE applet. Running the IDE through BuildApplet for MachoPython now seems to do the right thing, yeah! --- NEW FILE: PythonIDE.icns --- (This appears to be a binary file; contents omitted.) --- NEW FILE: PythonIDE.plist --- (This appears to be a binary file; contents omitted.) From jackjansen@users.sourceforge.net Fri Mar 29 23:48:57 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Fri, 29 Mar 2002 15:48:57 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/OSXResources/app/Resources Applet-Info.plist,NONE,1.1 Applet-InfoPlist.strings,NONE,1.1 PythonApplet.icns,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSXResources/app/Resources In directory usw-pr-cvs1:/tmp/cvs-serv2080 Added Files: Applet-Info.plist Applet-InfoPlist.strings PythonApplet.icns Log Message: Auxiliary files used by BuildApplet for MachoPython. --- NEW FILE: Applet-Info.plist --- (This appears to be a binary file; contents omitted.) --- NEW FILE: Applet-InfoPlist.strings --- /* Localized versions of Info.plist keys */ CFBundleName = "%(appletname)s"; CFBundleShortVersionString = "%(appletname)s"; CFBundleGetInfoString = "%(appletname)s, a Python application"; CFBundleLongVersionString = ""; NSHumanReadableCopyright = ""; --- NEW FILE: PythonApplet.icns --- (This appears to be a binary file; contents omitted.) From slrlfl2000@yahoo.co.kr Sat Mar 30 04:32:12 2002 From: slrlfl2000@yahoo.co.kr (slrlfl2000) Date: Sat, 30 Mar 2002 13:32:12 +0900 Subject: [Python-checkins] [±¤°í] Á¾·®Á¦ ºÀÅõ Àý¾àÇü ¾ÐÃྲ·¹±âÅë ¼Ò°³ Message-ID:



         

        ¢¹ ¿øÄ¡¾ÊÀº Á¤º¸¿´´Ù¸é Á¤ÁßÈ÷ »ç°ú µå¸®¸ç, ¼ö½Å °ÅºÎ¸¦ ÇØÁÖ½Ã¸é ´ÙÀ½ºÎÅÍ´Â ¸ÞÀÏÀÌ ¹ß¼ÛµÇÁö ¾ÊÀ» °ÍÀÔ´Ï´Ù.
        ¢¹ ¸ÞÀÏŬ¶óÀ̾ðÆ®ÀÇ ÇÊÅÍ ±â´ÉÀ» ÀÌ¿ëÇÏ¿© [±¤°í] ¹®±¸¸¦ ÇÊÅ͸µÇÏ¸é ¸ðµç ±¤°í ¸ÞÀÏÀ» ÀÚµ¿À¸·Î Â÷´ÜÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.

        ¼ö½Å°ÅºÎ(Unsubscribe)
        From gvanrossum@users.sourceforge.net Sat Mar 30 05:02:45 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 29 Mar 2002 21:02:45 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0285.txt,1.8,1.9 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv26121 Modified Files: pep-0285.txt Log Message: Slightly updated; corrected typos; added one extra argument. Index: pep-0285.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0285.txt,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** pep-0285.txt 10 Mar 2002 05:47:36 -0000 1.8 --- pep-0285.txt 30 Mar 2002 05:02:42 -0000 1.9 *************** *** 8,12 **** Created: 8-Mar-2002 Python-Version: 2.3 ! Post-History: 8-Mar-2002 --- 8,12 ---- Created: 8-Mar-2002 Python-Version: 2.3 ! Post-History: 8-Mar-2002, 30-Mar-2002 *************** *** 20,33 **** str(). All built-in operations that conceptually return a Boolean result will be changed to return False or True instead of 0 or 1; ! for example, comparisons and the "not" operator. Rationale ! Most languages eventually grow a Boolean type; even C99 has one. Many programmers apparently feel the need for a Boolean type; most Python documentation contains a bit of an apology for the absence ! of a Boolean type. I've seen lots of module that defined constants "False=0" and "True=1" (or similar) at the top and used those. The problem with this is that everybody does it --- 20,35 ---- str(). All built-in operations that conceptually return a Boolean result will be changed to return False or True instead of 0 or 1; ! for example, comparisons, the "not" operator, and predicates like ! isinstance(). Rationale ! Most languages eventually grow a Boolean type; even C99 (the new ! and improved C standard, not yet widely adopted) has one. Many programmers apparently feel the need for a Boolean type; most Python documentation contains a bit of an apology for the absence ! of a Boolean type. I've seen lots of modules that defined constants "False=0" and "True=1" (or similar) at the top and used those. The problem with this is that everybody does it *************** *** 40,49 **** Some external libraries (like databases and RPC packages) need to be able to distinguish between Boolean and integral values, and ! while it's usually possible to create a solution, it would be easier if the language offered a standard Boolean type. ! And here's an argument derived from teaching Python. When showing ! people comparison operators etc. in the interactive shell, I think ! this is a bit ugly: >>> a = 13 --- 42,61 ---- Some external libraries (like databases and RPC packages) need to be able to distinguish between Boolean and integral values, and ! while it's usually possible to craft a solution, it would be easier if the language offered a standard Boolean type. ! The standard bool type can also serve as a way to force a value to ! be interpreted as a Boolean, which can be used to normalize ! Boolean values. Writing bool(x) is much clearer than "not not x" ! and much more concise than ! ! if x: ! return 1 ! else: ! return 0 ! ! Here are some arguments derived from teaching Python. When ! showing people comparison operators etc. in the interactive shell, ! I think this is a bit ugly: >>> a = 13 *************** *** 74,78 **** you might be tempted to believe that cmp() also returned a truth value. If ints are not (normally) used for Booleans results, this ! would stand out much more clearly as something completely different. --- 86,91 ---- you might be tempted to believe that cmp() also returned a truth value. If ints are not (normally) used for Booleans results, this ! would stand out much more clearly as something completely ! different. *************** *** 85,90 **** def __new__(cls, val=0): ! # This constructor doesn't return a new instance; ! # it returns an existing instance if val: return True --- 98,102 ---- def __new__(cls, val=0): ! # This constructor always returns an existing instance if val: return True *************** *** 131,146 **** implementation will not allow other instances of bool to be created. At the C level, the existing globals Py_False and ! Py_True will be identical to the built-in singletons False and ! True. All built-in operations that are defined to return a Boolean result will be changed to return False or True instead of 0 or 1. In particular, this affects comparisons (<, <=, ==, !=, >, >=, is, ! is not, in, not it), the unary operator 'not', the built-in functions callable(), hasattr(), isinstance() and issubclass(), the dict method has_key(), the string and unicode methods endswith(), isalnum(), isalpha(), isdigit(), islower(), isspace(), istitle(), isupper(), and startswith(), the unicode methods ! isdecimal() and isnumeric(), and the closed attribute of file objects. --- 143,157 ---- implementation will not allow other instances of bool to be created. At the C level, the existing globals Py_False and ! Py_True will be appropriated to refer to False and True. All built-in operations that are defined to return a Boolean result will be changed to return False or True instead of 0 or 1. In particular, this affects comparisons (<, <=, ==, !=, >, >=, is, ! is not, in, not in), the unary operator 'not', the built-in functions callable(), hasattr(), isinstance() and issubclass(), the dict method has_key(), the string and unicode methods endswith(), isalnum(), isalpha(), isdigit(), islower(), isspace(), istitle(), isupper(), and startswith(), the unicode methods ! isdecimal() and isnumeric(), and the 'closed' attribute of file objects. *************** *** 162,174 **** I don't see this as a problem, and I don't want evolve the language in this direction either; I don't believe that a stricter ! interpretation of "Booleanness" makes the language much clearer. Another consequence of the compatibility requirement is that the expression "True and 6" has the value 6, and similarly the ! expression "False or 0" has the value 0. The "and" and "or" operators are usefully defined to return the first argument that ! determines the outcome. Of course, if both arguments are bools, ! the outcome is always a bool. It can also easily be coerced into ! being a bool by writing for example "bool(x and y)". --- 173,187 ---- I don't see this as a problem, and I don't want evolve the language in this direction either; I don't believe that a stricter ! interpretation of "Booleanness" makes the language any clearer. Another consequence of the compatibility requirement is that the expression "True and 6" has the value 6, and similarly the ! expression "False or None" has the value None. The "and" and "or" operators are usefully defined to return the first argument that ! determines the outcome, and this won't change; in particular, they ! don't force the outcome to be a bool. Of course, if both ! arguments are bools, the outcome is always a bool. It can also ! easily be coerced into being a bool by writing for example ! "bool(x and y)". From gvanrossum@users.sourceforge.net Sat Mar 30 05:09:05 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 29 Mar 2002 21:09:05 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0273.txt,1.6,1.7 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv26950 Modified Files: pep-0273.txt Log Message: Update SF patch reference. Index: pep-0273.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0273.txt,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pep-0273.txt 13 Nov 2001 20:25:43 -0000 1.6 --- pep-0273.txt 30 Mar 2002 05:09:03 -0000 1.7 *************** *** 179,184 **** Implementation ! A C implementation is available as SourceForge patch 476047. ! http://sourceforge.net/tracker/index.php?func=detail&aid=476047&group_id=5470&atid=305470 --- 179,184 ---- Implementation ! A C implementation is available as SourceForge patch 492105. ! http://python.org/sf/492105 From gvanrossum@users.sourceforge.net Sat Mar 30 05:16:18 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 29 Mar 2002 21:16:18 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0285.txt,1.9,1.10 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv27556 Modified Files: pep-0285.txt Log Message: On the eve of posting this to c.l.py, add a response to a common but nonsensical suggestion (that x == True should hold for all true x). Index: pep-0285.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0285.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pep-0285.txt 30 Mar 2002 05:02:42 -0000 1.9 --- pep-0285.txt 30 Mar 2002 05:16:16 -0000 1.10 *************** *** 204,207 **** --- 204,220 ---- lowercase alternatives if enough people think it looks better. + It has been suggested that, in order to satisfy user expectations, + for every x that is considered true in a Boolean context, the + expression x == True should be true, and likewise if x is + considered false, x == False should be true. This is of course + impossible; it would mean that e.g. 6 == True and 7 == True, from + which one could infer 6 == 7. Similarly, [] == False == None + would be true, and one could infer [] == None, which is not the + case. I'm not sure where this suggestion came from; it was made + several times during the first review period. For truth testing + of a value, one should use "if", e.g. "if x: print 'Yes'", not + comparison to a truth value; "if x == True: print 'Yes'" is not + only wrong, it is also strangely redundant. + Implementation From gvanrossum@users.sourceforge.net Sat Mar 30 05:17:24 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 29 Mar 2002 21:17:24 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0285.txt,1.10,1.11 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv27660 Modified Files: pep-0285.txt Log Message: Shorter URL for patch. Index: pep-0285.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0285.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pep-0285.txt 30 Mar 2002 05:16:16 -0000 1.10 --- pep-0285.txt 30 Mar 2002 05:17:22 -0000 1.11 *************** *** 223,227 **** uploaded to the SourceForge patch manager: ! http://sourceforge.net/tracker/index.php?func=detail&aid=528022&group_id=5470&atid=305470 --- 223,227 ---- uploaded to the SourceForge patch manager: ! http://python.org/sf/528022 From gvanrossum@users.sourceforge.net Sat Mar 30 05:37:04 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Fri, 29 Mar 2002 21:37:04 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0285.txt,1.11,1.12 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv30375 Modified Files: pep-0285.txt Log Message: Add a section with the most pressing issues for reviewers. Index: pep-0285.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0285.txt,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** pep-0285.txt 30 Mar 2002 05:17:22 -0000 1.11 --- pep-0285.txt 30 Mar 2002 05:37:02 -0000 1.12 *************** *** 24,27 **** --- 24,64 ---- + Review + + Dear reviewers: + + I'm particularly interested in hearing your opinion about the + following three issues: + + 1) Should this PEP be accepted at all. + + 2) Should str(True) return "True" or "1": "1" might reduce + backwards compatibility problems, but looks strange to me. + (repr(True) would always return "True".) + + 3) Should the constants be called 'True' and 'False' + (corresponding to None) or 'true' and 'false' (as in C++, Java + and C99). + + Most other details of the proposal are pretty much forced by the + backwards compatibility requirement; e.g. True == 1 and + True+1 == 2 must hold, else reams of existing code would break. + + Minor additional issues: + + 4) Should we strive to eliminate non-Boolean operations on bools + in the future, through suitable warnings, so that e.g. True+1 + would eventually (e.g. in Python 3000 be illegal). Personally, + I think we shouldn't; 28+isleap(y) seems totally reasonable to + me. + + 5) Should operator.truth(x) return an int or a bool. Tim Peters + believes it should return an int because it's been documented + as such. I think it should return a bool; most other standard + predicates (e.g. issubtype()) have also been documented as + returning 0 or 1, and it's obvious that we want to change those + to return a bool. + + Rationale From tim_one@users.sourceforge.net Sat Mar 30 06:09:25 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 29 Mar 2002 22:09:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.12,2.13 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv31971/python/Objects Modified Files: obmalloc.c Log Message: Lots of changes: + A new scheme for determining whether an address belongs to a pymalloc arena. This should be 100% reliable. The poolp->pooladdr and poolp->magic members are gone. A new poolp->arenaindex member takes their place. Note that the pool header overhead doesn't actually shrink, though, since the header is padded to a multiple of 8 bytes. + _PyMalloc_Free and _PyMalloc_Realloc should now be safe to call for any legit address, whether obtained from a _PyMalloc function or from the system malloc/realloc. It should even be safe to call _PyMalloc_Free when *not* holding the GIL, provided that the passed-in address was obtained from system malloc/realloc. Since this is accomplished without any locks, you better believe the code is subtle. I hope it's sufficiently commented. + The above implies we don't need the new PyMalloc_{New, NewVar, Del} API anymore, and could switch back to PyObject_XXX without breaking existing code mixing PyObject_XXX with PyMem_{Del, DEL, Free, FREE}. Nothing is done here about that yet, and I'd like to see this new code exercised more first. + The small object threshhold is boosted to 256 (the max). We should play with that some more, but the old 64 was way too small for 2.3. + Getting a new arena is now done via new function new_arena(). + Removed some unused macros, and squashed out some macros that were used only once to define other macros. + Arenas are no longer linked together. A new vector of arena base addresses had to be created anyway to make address classification bulletproof. + A lot of the patch size is an illusion: given the way address classification works now, it was more convenient to switch the sense of the prime "if" tests in the realloc and free functions, so the "if" and "else" blocks got swapped. + Assorted minor code, comment and whitespace cleanup. Back to the Windows installer . Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -d -r2.12 -r2.13 *** obmalloc.c 28 Mar 2002 21:05:38 -0000 2.12 --- obmalloc.c 30 Mar 2002 06:09:22 -0000 2.13 *************** *** 113,117 **** * You shouldn't change this unless you know what you are doing. */ - #define ALIGNMENT 8 /* must be 2^N */ #define ALIGNMENT_SHIFT 3 --- 113,116 ---- *************** *** 125,147 **** * The following invariants must hold: * 1) ALIGNMENT <= SMALL_REQUEST_THRESHOLD <= 256 ! * 2) SMALL_REQUEST_THRESHOLD == N * ALIGNMENT * * Although not required, for better performance and space efficiency, * it is recommended that SMALL_REQUEST_THRESHOLD is set to a power of 2. */ ! ! /* ! * For Python compiled on systems with 32 bit pointers and integers, ! * a value of 64 (= 8 * 8) is a reasonable speed/space tradeoff for ! * the object allocator. To adjust automatically this threshold for ! * systems with 64 bit pointers, we make this setting depend on a ! * Python-specific slot size unit = sizeof(long) + sizeof(void *), ! * which is expected to be 8, 12 or 16 bytes. ! */ ! ! #define _PYOBJECT_THRESHOLD ((SIZEOF_LONG + SIZEOF_VOID_P) * ALIGNMENT) ! ! #define SMALL_REQUEST_THRESHOLD _PYOBJECT_THRESHOLD /* must be N * ALIGNMENT */ ! #define NB_SMALL_SIZE_CLASSES (SMALL_REQUEST_THRESHOLD / ALIGNMENT) --- 124,133 ---- * The following invariants must hold: * 1) ALIGNMENT <= SMALL_REQUEST_THRESHOLD <= 256 ! * 2) SMALL_REQUEST_THRESHOLD is evenly divisible by ALIGNMENT * * Although not required, for better performance and space efficiency, * it is recommended that SMALL_REQUEST_THRESHOLD is set to a power of 2. */ ! #define SMALL_REQUEST_THRESHOLD 256 #define NB_SMALL_SIZE_CLASSES (SMALL_REQUEST_THRESHOLD / ALIGNMENT) *************** *** 153,157 **** * have to be. */ - #define SYSTEM_PAGE_SIZE (4 * 1024) #define SYSTEM_PAGE_SIZE_MASK (SYSTEM_PAGE_SIZE - 1) --- 139,142 ---- *************** *** 160,164 **** * Maximum amount of memory managed by the allocator for small requests. */ - #ifdef WITH_MEMORY_LIMITS #ifndef SMALL_MEMORY_LIMIT --- 145,148 ---- *************** *** 178,185 **** * Therefore, allocating arenas with malloc is not optimal, because there is * some address space wastage, but this is the most portable way to request ! * memory from the system accross various platforms. */ ! #define ARENA_SIZE (256 * 1024 - SYSTEM_PAGE_SIZE) /* 256k - 1p */ #ifdef WITH_MEMORY_LIMITS --- 162,173 ---- * Therefore, allocating arenas with malloc is not optimal, because there is * some address space wastage, but this is the most portable way to request ! * memory from the system across various platforms. */ ! /* ALLOCATED_ARENA_SIZE is passed to malloc; after alignment, we can't ! * count on more than ARENA_SIZE bytes being usable for pools. ! */ ! #define ALLOCATED_ARENA_SIZE (256 << 10) /* 256KB */ ! #define ARENA_SIZE (ALLOCATED_ARENA_SIZE - SYSTEM_PAGE_SIZE) #ifdef WITH_MEMORY_LIMITS *************** *** 191,201 **** * between 1K and SYSTEM_PAGE_SIZE, that is: 1k, 2k, 4k, eventually 8k. */ - #define POOL_SIZE SYSTEM_PAGE_SIZE /* must be 2^N */ #define POOL_SIZE_MASK SYSTEM_PAGE_SIZE_MASK - #define POOL_MAGIC 0x74D3A651 /* authentication id */ - #define ARENA_NB_POOLS (ARENA_SIZE / POOL_SIZE) - #define ARENA_NB_PAGES (ARENA_SIZE / SYSTEM_PAGE_SIZE) /* --- 179,185 ---- *************** *** 233,237 **** * I don't care if these are defined in or elsewhere. Axiom. */ - #undef uchar #define uchar unsigned char /* assuming == 8 bits */ --- 217,220 ---- *************** *** 249,252 **** --- 232,238 ---- #define off_t uint /* 16 bits <= off_t <= 64 bits */ + #undef uptr + #define uptr Py_uintptr_t + /* When you say memory, my mind reasons in terms of (pointers to) blocks */ typedef uchar block; *************** *** 259,264 **** struct pool_header *nextpool; /* next pool of this size class */ struct pool_header *prevpool; /* previous pool "" */ ! struct pool_header *pooladdr; /* pool address (always aligned) */ ! uint magic; /* pool magic number */ uint szidx; /* block size class index */ uint capacity; /* pool capacity in # of blocks */ --- 245,249 ---- struct pool_header *nextpool; /* next pool of this size class */ struct pool_header *prevpool; /* previous pool "" */ ! ulong arenaindex; /* index into arenas of base adr */ uint szidx; /* block size class index */ uint capacity; /* pool capacity in # of blocks */ *************** *** 273,276 **** --- 258,265 ---- #define DUMMY_SIZE_IDX 0xffff /* size class of newly cached pools */ + /* Round pointer P down to the closest pool-aligned address <= P, as a poolp */ + #define POOL_ADDR(P) \ + ((poolp)((uptr)(P) & ~(uptr)POOL_SIZE_MASK)) + /*==========================================================================*/ *************** *** 320,333 **** static poolp freepools = NULL; /* free list for cached pools */ ! /* ! * Arenas */ ! static uint arenacnt = 0; /* number of allocated arenas */ ! static uint watermark = ARENA_NB_POOLS; /* number of pools allocated from ! the current arena */ ! static block *arenalist = NULL; /* list of allocated arenas */ ! static block *arenabase = NULL; /* free space start address in ! current arena */ /*==========================================================================*/ --- 309,444 ---- static poolp freepools = NULL; /* free list for cached pools */ ! /*==========================================================================*/ ! /* Arena management. */ ! ! /* arenas is a vector of arena base addresses, in order of allocation time. ! * arenas currently contains narenas entries, and has space allocated ! * for at most maxarenas entries. ! * ! * CAUTION: See the long comment block about thread safety in new_arena(): ! * the code currently relies in deep ways on that this vector only grows, ! * and only grows by appending at the end. For now we never return an arena ! * to the OS. */ ! static uptr *arenas = NULL; ! static ulong narenas = 0; ! static ulong maxarenas = 0; ! ! /* Number of pools already allocated from the current arena. This is ! * initialized to the max # of pools to provoke the first allocation request ! * into allocating a new arena. ! */ ! static uint watermark = ARENA_NB_POOLS; ! ! /* Free space start address in current arena. */ ! static block *arenabase = NULL; ! ! #if 0 ! static ulong wasmine = 0; ! static ulong wasntmine = 0; ! ! static void ! dumpem(void *ptr) ! { ! if (ptr) ! printf("inserted new arena at %08x\n", ptr); ! printf("# arenas %d\n", narenas); ! printf("was mine %lu wasn't mine %lu\n", wasmine, wasntmine); ! } ! #define INCMINE ++wasmine ! #define INCTHEIRS ++wasntmine ! ! #else ! #define dumpem(ptr) ! #define INCMINE ! #define INCTHEIRS ! #endif ! ! /* Allocate a new arena and return its base address. If we run out of ! * memory, return NULL. ! */ ! static block * ! new_arena(void) ! { ! block *bp = (block *)PyMem_MALLOC(ALLOCATED_ARENA_SIZE); ! if (bp == NULL) ! return NULL; ! ! watermark = 0; ! /* Page-round up */ ! arenabase = bp + (SYSTEM_PAGE_SIZE - ! ((off_t )bp & SYSTEM_PAGE_SIZE_MASK)); ! ! /* Make room for a new entry in the arenas vector. */ ! if (arenas == NULL) { ! arenas = (uptr *)PyMem_MALLOC(16 * sizeof(*arenas)); ! if (arenas == NULL) ! goto error; ! maxarenas = 16; ! narenas = 0; ! } ! else if (narenas == maxarenas) { ! /* Grow arenas. Don't use realloc: if this fails, we ! * don't want to lose the base addresses we already have. ! * Exceedingly subtle: Someone may be calling the pymalloc ! * free via PyMem_{DEL, Del, FREE, Free} without holding the ! *.GIL. Someone else may simultaneously be calling the ! * pymalloc malloc while holding the GIL via, e.g., ! * PyObject_New. Now the pymalloc free may index into arenas ! * for an address check, while the pymalloc malloc calls ! * new_arena and we end up here to grow a new arena *and* ! * grow the arenas vector. If the value for arenas pymalloc ! * free picks up "vanishes" during this resize, anything may ! * happen, and it would be an incredibly rare bug. Therefore ! * the code here takes great pains to make sure that, at every ! * moment, arenas always points to an intact vector of ! * addresses. It doesn't matter whether arenas points to a ! * wholly up-to-date vector when pymalloc free checks it in ! * this case, because the only legal (and that even this is ! * legal is debatable) way to call PyMem_{Del, etc} while not ! * holding the GIL is if the memory being released is not ! * object memory, i.e. if the address check in pymalloc free ! * is supposed to fail. Having an incomplete vector can't ! * make a supposed-to-fail case succeed by mistake (it could ! * only make a supposed-to-succeed case fail by mistake). ! * Read the above 50 times before changing anything in this ! * block. ! */ ! uptr *oldarenas; ! int newmax = maxarenas + (maxarenas >> 1); ! uptr *p = (uptr *)PyMem_MALLOC(newmax * sizeof(*arenas)); ! if (p == NULL) ! goto error; ! memcpy(p, arenas, narenas * sizeof(*arenas)); ! oldarenas = arenas; ! arenas = p; ! PyMem_FREE(oldarenas); ! maxarenas = newmax; ! } ! ! /* Append the new arena address to arenas. */ ! assert(narenas < maxarenas); ! arenas[narenas] = (uptr)bp; ! ++narenas; ! dumpem(bp); ! return bp; ! ! error: ! PyMem_FREE(bp); ! return NULL; ! } + /* Return true if and only if P is an address that was allocated by + * pymalloc. I must be the index into arenas that the address claims + * to come from. + * Tricky: Letting B be the arena base address in arenas[I], P belongs to the + * arena if and only if + * B <= P < B + ALLOCATED_ARENA_SIZE + * Subtracting B throughout, this is true iff + * 0 <= P-B < ALLOCATED_ARENA_SIZE + * By using unsigned arithmetic, the "0 <=" half of the test can be skipped. + */ + #define ADDRESS_IN_RANGE(P, I) \ + ((I) < narenas && (uptr)(P) - arenas[I] < (uptr)ALLOCATED_ARENA_SIZE) /*==========================================================================*/ *************** *** 450,455 **** pool = (poolp )arenabase; arenabase += POOL_SIZE; ! pool->pooladdr = pool; ! pool->magic = (uint )POOL_MAGIC; pool->szidx = DUMMY_SIZE_IDX; goto init_pool; --- 561,565 ---- pool = (poolp )arenabase; arenabase += POOL_SIZE; ! pool->arenaindex = narenas - 1; pool->szidx = DUMMY_SIZE_IDX; goto init_pool; *************** *** 459,496 **** */ #ifdef WITH_MEMORY_LIMITS ! if (!(arenacnt < MAX_ARENAS)) { UNLOCK(); goto redirect; } #endif ! /* ! * With malloc, we can't avoid loosing one page address space ! * per arena due to the required alignment on page boundaries. ! */ ! bp = (block *)PyMem_MALLOC(ARENA_SIZE + SYSTEM_PAGE_SIZE); ! if (bp == NULL) { ! UNLOCK(); ! goto redirect; ! } ! /* ! * Keep a reference in the list of allocated arenas. We might ! * want to release (some of) them in the future. The first ! * word is never used, no matter whether the returned address ! * is page-aligned or not, so we safely store a pointer in it. ! */ ! *(block **)bp = arenalist; ! arenalist = bp; ! arenacnt++; ! watermark = 0; ! /* Page-round up */ ! arenabase = bp + (SYSTEM_PAGE_SIZE - ! ((off_t )bp & SYSTEM_PAGE_SIZE_MASK)); ! goto commit_pool; } /* The small block allocator ends here. */ ! redirect: ! /* * Redirect the original request to the underlying (libc) allocator. --- 569,587 ---- */ #ifdef WITH_MEMORY_LIMITS ! if (!(narenas < MAX_ARENAS)) { UNLOCK(); goto redirect; } #endif ! bp = new_arena(); ! if (bp != NULL) ! goto commit_pool; ! UNLOCK(); ! goto redirect; } /* The small block allocator ends here. */ ! redirect: /* * Redirect the original request to the underlying (libc) allocator. *************** *** 510,575 **** poolp next, prev; uint size; - off_t offset; if (p == NULL) /* free(NULL) has no effect */ return; ! offset = (off_t )p & POOL_SIZE_MASK; ! pool = (poolp )((block *)p - offset); ! if (pool->pooladdr != pool || pool->magic != (uint )POOL_MAGIC) { ! PyMem_FREE(p); ! return; ! } ! ! LOCK(); ! /* ! * At this point, the pool is not empty ! */ ! if ((*(block **)p = pool->freeblock) == NULL) { /* ! * Pool was full */ pool->freeblock = (block *)p; ! --pool->ref.count; /* ! * Frontlink to used pools ! * This mimics LRU pool usage for new allocations and ! * targets optimal filling when several pools contain ! * blocks of the same size class. */ ! size = pool->szidx; ! next = usedpools[size + size]; ! prev = next->prevpool; ! pool->nextpool = next; ! pool->prevpool = prev; ! next->prevpool = pool; ! prev->nextpool = pool; ! UNLOCK(); ! return; ! } ! /* ! * Pool was not full ! */ ! pool->freeblock = (block *)p; ! if (--pool->ref.count != 0) { UNLOCK(); return; } ! /* ! * Pool is now empty, unlink from used pools ! */ ! next = pool->nextpool; ! prev = pool->prevpool; ! next->prevpool = prev; ! prev->nextpool = next; ! /* ! * Frontlink to free pools ! * This ensures that previously freed pools will be allocated ! * later (being not referenced, they are perhaps paged out). ! */ ! pool->nextpool = freepools; ! freepools = pool; ! UNLOCK(); ! return; } --- 601,667 ---- poolp next, prev; uint size; if (p == NULL) /* free(NULL) has no effect */ return; ! pool = POOL_ADDR(p); ! if (ADDRESS_IN_RANGE(p, pool->arenaindex)) { ! /* We allocated this address. */ ! INCMINE; ! LOCK(); /* ! * At this point, the pool is not empty ! */ ! if ((*(block **)p = pool->freeblock) == NULL) { ! /* ! * Pool was full ! */ ! pool->freeblock = (block *)p; ! --pool->ref.count; ! /* ! * Frontlink to used pools ! * This mimics LRU pool usage for new allocations and ! * targets optimal filling when several pools contain ! * blocks of the same size class. ! */ ! size = pool->szidx; ! next = usedpools[size + size]; ! prev = next->prevpool; ! pool->nextpool = next; ! pool->prevpool = prev; ! next->prevpool = pool; ! prev->nextpool = pool; ! UNLOCK(); ! return; ! } ! /* ! * Pool was not full */ pool->freeblock = (block *)p; ! if (--pool->ref.count != 0) { ! UNLOCK(); ! return; ! } /* ! * Pool is now empty, unlink from used pools */ ! next = pool->nextpool; ! prev = pool->prevpool; ! next->prevpool = prev; ! prev->nextpool = next; ! /* ! * Frontlink to free pools ! * This ensures that previously freed pools will be allocated ! * later (being not referenced, they are perhaps paged out). ! */ ! pool->nextpool = freepools; ! freepools = pool; UNLOCK(); return; } ! ! /* We did not allocate this address. */ ! INCTHEIRS; ! PyMem_FREE(p); } *************** *** 587,606 **** /* realloc(p, 0) on big blocks is redirected. */ ! pool = (poolp )((block *)p - ((off_t )p & POOL_SIZE_MASK)); ! if (pool->pooladdr != pool || pool->magic != (uint )POOL_MAGIC) { ! /* We haven't allocated this block */ ! if (!(nbytes > SMALL_REQUEST_THRESHOLD) && nbytes) { ! /* small request */ ! size = nbytes; ! goto malloc_copy_free; ! } ! bp = (block *)PyMem_REALLOC(p, nbytes); ! } ! else { /* We're in charge of this block */ size = (pool->szidx + 1) << ALIGNMENT_SHIFT; /* block size */ if (size >= nbytes) { /* Don't bother if a smaller size was requested except for realloc(p, 0) == free(p), ret NULL */ if (nbytes == 0) { _PyMalloc_Free(p); --- 679,692 ---- /* realloc(p, 0) on big blocks is redirected. */ ! pool = POOL_ADDR(p); ! if (ADDRESS_IN_RANGE(p, pool->arenaindex)) { /* We're in charge of this block */ + INCMINE; size = (pool->szidx + 1) << ALIGNMENT_SHIFT; /* block size */ if (size >= nbytes) { /* Don't bother if a smaller size was requested except for realloc(p, 0) == free(p), ret NULL */ + /* XXX but Python guarantees that *its* flavor of + resize(p, 0) will not do a free or return NULL */ if (nbytes == 0) { _PyMalloc_Free(p); *************** *** 611,617 **** } else { - - malloc_copy_free: - bp = (block *)_PyMalloc_Malloc(nbytes); if (bp != NULL) { --- 697,700 ---- *************** *** 620,623 **** --- 703,721 ---- } } + } + else { + /* We haven't allocated this block */ + INCTHEIRS; + if (nbytes <= SMALL_REQUEST_THRESHOLD && nbytes) { + /* small request */ + size = nbytes; + bp = (block *)_PyMalloc_Malloc(nbytes); + if (bp != NULL) { + memcpy(bp, p, size); + _PyMalloc_Free(p); + } + } + else + bp = (block *)PyMem_REALLOC(p, nbytes); } return (void *)bp; From tim_one@users.sourceforge.net Sat Mar 30 06:20:25 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 29 Mar 2002 22:20:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.13,2.14 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv3755/python/Objects Modified Files: obmalloc.c Log Message: Retract the claim that this is always safe if PyMem_{Del, DEL, Free, FREE} are called without the GIL. It's incredibly unlikely to fail, but I can't make this bulletproof without either adding a lock for exclusion, or giving up on growing the arena base-address vector (it would be safe if this were a static array). Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.13 retrieving revision 2.14 diff -C2 -d -r2.13 -r2.14 *** obmalloc.c 30 Mar 2002 06:09:22 -0000 2.13 --- obmalloc.c 30 Mar 2002 06:20:23 -0000 2.14 *************** *** 404,407 **** --- 404,411 ---- * Read the above 50 times before changing anything in this * block. + * XXX Fudge. This is still vulnerable: there's nothing + * XXX to stop the bad-guy thread from picking up the + * XXX current value of arenas, but not indexing off of it + * XXX until after the PyMem_FREE(oldarenas) below completes. */ uptr *oldarenas; From tim_one@users.sourceforge.net Sat Mar 30 07:04:43 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 29 Mar 2002 23:04:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.14,2.15 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv8692/python/Objects Modified Files: obmalloc.c Log Message: Now that we're no longer linking arenas together, there's no need to waste the first pool if malloc happens to return a pool-aligned address. This means the number of pools per arena can now vary by 1. Unfortunately, the code counted up from 0 to a presumed constant number of pools. So changed the increasing "watermark" counter to a decreasing "nfreepools" counter instead, and fiddled various stuff accordingly. This also allowed getting rid of two more macros. Also changed the code to align the first address to a pool boundary instead of a page boundary. These are two parallel sets of macro #defines that happen to be identical now, but the page macros are in theory more restrictive (bigger), and there's simply no reason I can see that it wasn't aligning to the less restrictive pool size all along (the code only relies on pool alignment). Hmm. The "page size" macros aren't used for anything *except* defining the pool size macros, and the comments claim the latter isn't necessary. So this has the feel of a layer of indirection that doesn't serve a purpose; should probably get rid of the page macros now. Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.14 retrieving revision 2.15 diff -C2 -d -r2.14 -r2.15 *** obmalloc.c 30 Mar 2002 06:20:23 -0000 2.14 --- obmalloc.c 30 Mar 2002 07:04:41 -0000 2.15 *************** *** 164,173 **** * memory from the system across various platforms. */ ! ! /* ALLOCATED_ARENA_SIZE is passed to malloc; after alignment, we can't ! * count on more than ARENA_SIZE bytes being usable for pools. ! */ ! #define ALLOCATED_ARENA_SIZE (256 << 10) /* 256KB */ ! #define ARENA_SIZE (ALLOCATED_ARENA_SIZE - SYSTEM_PAGE_SIZE) #ifdef WITH_MEMORY_LIMITS --- 164,168 ---- * memory from the system across various platforms. */ ! #define ARENA_SIZE (256 << 10) /* 256KB */ #ifdef WITH_MEMORY_LIMITS *************** *** 181,185 **** #define POOL_SIZE SYSTEM_PAGE_SIZE /* must be 2^N */ #define POOL_SIZE_MASK SYSTEM_PAGE_SIZE_MASK - #define ARENA_NB_POOLS (ARENA_SIZE / POOL_SIZE) /* --- 176,179 ---- *************** *** 325,335 **** static ulong maxarenas = 0; ! /* Number of pools already allocated from the current arena. This is ! * initialized to the max # of pools to provoke the first allocation request ! * into allocating a new arena. ! */ ! static uint watermark = ARENA_NB_POOLS; ! /* Free space start address in current arena. */ static block *arenabase = NULL; --- 319,326 ---- static ulong maxarenas = 0; ! /* Number of pools still available to be allocated in the current arena. */ ! static uint nfreepools = 0; ! /* Free space start address in current arena. This is pool-aligned. */ static block *arenabase = NULL; *************** *** 361,372 **** new_arena(void) { ! block *bp = (block *)PyMem_MALLOC(ALLOCATED_ARENA_SIZE); if (bp == NULL) return NULL; ! watermark = 0; ! /* Page-round up */ ! arenabase = bp + (SYSTEM_PAGE_SIZE - ! ((off_t )bp & SYSTEM_PAGE_SIZE_MASK)); /* Make room for a new entry in the arenas vector. */ --- 352,369 ---- new_arena(void) { ! uint excess; /* number of bytes above pool alignment */ ! block *bp = (block *)PyMem_MALLOC(ARENA_SIZE); if (bp == NULL) return NULL; ! /* arenabase <- first pool-aligned address in the arena ! nfreepools <- number of whole pools that fit after alignment */ ! arenabase = bp; ! nfreepools = ARENA_SIZE / POOL_SIZE; ! excess = (uint)bp & POOL_SIZE_MASK; ! if (excess != 0) { ! --nfreepools; ! arenabase += POOL_SIZE - excess; ! } /* Make room for a new entry in the arenas vector. */ *************** *** 438,448 **** * Tricky: Letting B be the arena base address in arenas[I], P belongs to the * arena if and only if ! * B <= P < B + ALLOCATED_ARENA_SIZE * Subtracting B throughout, this is true iff ! * 0 <= P-B < ALLOCATED_ARENA_SIZE * By using unsigned arithmetic, the "0 <=" half of the test can be skipped. */ #define ADDRESS_IN_RANGE(P, I) \ ! ((I) < narenas && (uptr)(P) - arenas[I] < (uptr)ALLOCATED_ARENA_SIZE) /*==========================================================================*/ --- 435,445 ---- * Tricky: Letting B be the arena base address in arenas[I], P belongs to the * arena if and only if ! * B <= P < B + ARENA_SIZE * Subtracting B throughout, this is true iff ! * 0 <= P-B < ARENA_SIZE * By using unsigned arithmetic, the "0 <=" half of the test can be skipped. */ #define ADDRESS_IN_RANGE(P, I) \ ! ((I) < narenas && (uptr)(P) - arenas[I] < (uptr)ARENA_SIZE) /*==========================================================================*/ *************** *** 559,567 **** * Allocate new pool */ ! if (watermark < ARENA_NB_POOLS) { ! /* commit malloc(POOL_SIZE) from the current arena */ commit_pool: ! watermark++; ! pool = (poolp )arenabase; arenabase += POOL_SIZE; pool->arenaindex = narenas - 1; --- 556,563 ---- * Allocate new pool */ ! if (nfreepools) { commit_pool: ! --nfreepools; ! pool = (poolp)arenabase; arenabase += POOL_SIZE; pool->arenaindex = narenas - 1; From tim_one@users.sourceforge.net Sat Mar 30 07:07:26 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Fri, 29 Mar 2002 23:07:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.15,2.16 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv10346/python/Objects Modified Files: obmalloc.c Log Message: Turns out the off_t macro isn't used anymore, so got rid of it. Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.15 retrieving revision 2.16 diff -C2 -d -r2.15 -r2.16 *** obmalloc.c 30 Mar 2002 07:04:41 -0000 2.15 --- obmalloc.c 30 Mar 2002 07:07:24 -0000 2.16 *************** *** 223,229 **** #define ulong unsigned long /* assuming >= 32 bits */ - #undef off_t - #define off_t uint /* 16 bits <= off_t <= 64 bits */ - #undef uptr #define uptr Py_uintptr_t --- 223,226 ---- From loewis@users.sourceforge.net Sat Mar 30 08:57:14 2002 From: loewis@users.sourceforge.net (Martin v. L?wis) Date: Sat, 30 Mar 2002 00:57:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Include cStringIO.h,2.15,2.16 descrobject.h,2.8,2.9 iterobject.h,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv25805 Modified Files: cStringIO.h descrobject.h iterobject.h Log Message: Patch #536908: Add missing #include guards/extern "C". Index: cStringIO.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/cStringIO.h,v retrieving revision 2.15 retrieving revision 2.16 diff -C2 -d -r2.15 -r2.16 *** cStringIO.h 9 Jun 2001 07:59:43 -0000 2.15 --- cStringIO.h 30 Mar 2002 08:57:12 -0000 2.16 *************** *** 1,4 **** --- 1,7 ---- #ifndef CSTRINGIO_INCLUDED #define CSTRINGIO_INCLUDED + #ifdef __cplusplus + extern "C" { + #endif /* *************** *** 129,131 **** --- 132,137 ---- PycStringIO=(struct PycStringIO_CAPI*)xxxPyCObject_Import("cStringIO", "cStringIO_CAPI") + #ifdef __cplusplus + } + #endif #endif /* CSTRINGIO_INCLUDED */ Index: descrobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/descrobject.h,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -d -r2.8 -r2.9 *** descrobject.h 22 Oct 2001 00:43:43 -0000 2.8 --- descrobject.h 30 Mar 2002 08:57:12 -0000 2.9 *************** *** 1,3 **** --- 1,8 ---- /* Descriptors */ + #ifndef Py_DESCROBJECT_H + #define Py_DESCROBJECT_H + #ifdef __cplusplus + extern "C" { + #endif typedef PyObject *(*getter)(PyObject *, void *); *************** *** 79,80 **** --- 84,90 ---- extern DL_IMPORT(PyTypeObject) PyProperty_Type; + #ifdef __cplusplus + } + #endif + #endif /* !Py_DESCROBJECT_H */ + Index: iterobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/iterobject.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** iterobject.h 23 Apr 2001 14:08:49 -0000 1.3 --- iterobject.h 30 Mar 2002 08:57:12 -0000 1.4 *************** *** 1,3 **** --- 1,8 ---- + #ifndef Py_ITEROBJECT_H + #define Py_ITEROBJECT_H /* Iterators (the basic kind, over a sequence) */ + #ifdef __cplusplus + extern "C" { + #endif extern DL_IMPORT(PyTypeObject) PySeqIter_Type; *************** *** 12,13 **** --- 17,23 ---- extern DL_IMPORT(PyObject *) PyCallIter_New(PyObject *, PyObject *); + #ifdef __cplusplus + } + #endif + #endif /* !Py_ITEROBJECT_H */ + From tim_one@users.sourceforge.net Sat Mar 30 10:06:09 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 30 Mar 2002 02:06:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.372,1.373 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv6238/python/Misc Modified Files: NEWS Log Message: Eliminate DONT_SHARE_SHORT_STRINGS. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.372 retrieving revision 1.373 diff -C2 -d -r1.372 -r1.373 *** NEWS 29 Mar 2002 16:28:31 -0000 1.372 --- NEWS 30 Mar 2002 10:06:07 -0000 1.373 *************** *** 92,98 **** - On Unix, a shared libpython2.3.so can be created with --enable-shared. ! - References to the CACHE_HASH and INTERN_STRINGS preprocessor symbols ! were eliminated. They were always defined, and the internal features ! they enabled stopped being experimental long ago. C API --- 92,98 ---- - On Unix, a shared libpython2.3.so can be created with --enable-shared. ! - All uses of the CACHE_HASH, INTERN_STRINGS, and DONT_SHARE_SHORT_STRINGS ! preprocessor symbols were eliminated. The internal decisions they ! controlled stopped being experimental long ago. C API From tim_one@users.sourceforge.net Sat Mar 30 10:06:09 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 30 Mar 2002 02:06:09 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.152,2.153 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv6238/python/Objects Modified Files: stringobject.c Log Message: Eliminate DONT_SHARE_SHORT_STRINGS. Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.152 retrieving revision 2.153 diff -C2 -d -r2.152 -r2.153 *** stringobject.c 29 Mar 2002 03:29:07 -0000 2.152 --- stringobject.c 30 Mar 2002 10:06:07 -0000 2.153 *************** *** 15,21 **** static PyStringObject *characters[UCHAR_MAX + 1]; - #ifndef DONT_SHARE_SHORT_STRINGS static PyStringObject *nullstring; - #endif /* --- 15,19 ---- *************** *** 48,52 **** { register PyStringObject *op; - #ifndef DONT_SHARE_SHORT_STRINGS if (size == 0 && (op = nullstring) != NULL) { #ifdef COUNT_ALLOCS --- 46,49 ---- *************** *** 65,69 **** return (PyObject *)op; } - #endif /* DONT_SHARE_SHORT_STRINGS */ /* PyObject_NewVar is inlined */ --- 62,65 ---- *************** *** 78,82 **** memcpy(op->ob_sval, str, size); op->ob_sval[size] = '\0'; ! #ifndef DONT_SHARE_SHORT_STRINGS if (size == 0) { PyObject *t = (PyObject *)op; --- 74,78 ---- memcpy(op->ob_sval, str, size); op->ob_sval[size] = '\0'; ! /* share short strings */ if (size == 0) { PyObject *t = (PyObject *)op; *************** *** 92,96 **** Py_INCREF(op); } - #endif return (PyObject *) op; } --- 88,91 ---- *************** *** 109,113 **** return NULL; } - #ifndef DONT_SHARE_SHORT_STRINGS if (size == 0 && (op = nullstring) != NULL) { #ifdef COUNT_ALLOCS --- 104,107 ---- *************** *** 124,128 **** return (PyObject *)op; } - #endif /* DONT_SHARE_SHORT_STRINGS */ /* PyObject_NewVar is inlined */ --- 118,121 ---- *************** *** 135,139 **** op->ob_sinterned = NULL; memcpy(op->ob_sval, str, size+1); ! #ifndef DONT_SHARE_SHORT_STRINGS if (size == 0) { PyObject *t = (PyObject *)op; --- 128,132 ---- op->ob_sinterned = NULL; memcpy(op->ob_sval, str, size+1); ! /* share short strings */ if (size == 0) { PyObject *t = (PyObject *)op; *************** *** 149,153 **** Py_INCREF(op); } - #endif return (PyObject *) op; } --- 142,145 ---- *************** *** 3638,3645 **** characters[i] = NULL; } - #ifndef DONT_SHARE_SHORT_STRINGS Py_XDECREF(nullstring); nullstring = NULL; - #endif if (interned) { int pos, changed; --- 3630,3635 ---- From tim_one@users.sourceforge.net Sat Mar 30 10:35:12 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 30 Mar 2002 02:35:12 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.16,2.17 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv10662/python/Objects Modified Files: obmalloc.c Log Message: Changed the #-of-arenas counters to uints -- no need to be insane about this. But added an overflow check just in case there is. Got rid of the ushort macro. It wasn't used anymore (it was only used in the no-longer-exists off_t macro), and there's no plausible use for it. Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -d -r2.16 -r2.17 *** obmalloc.c 30 Mar 2002 07:07:24 -0000 2.16 --- obmalloc.c 30 Mar 2002 10:35:09 -0000 2.17 *************** *** 214,220 **** #define uchar unsigned char /* assuming == 8 bits */ - #undef ushort - #define ushort unsigned short /* assuming >= 16 bits */ - #undef uint #define uint unsigned int /* assuming >= 16 bits */ --- 214,217 ---- *************** *** 236,240 **** struct pool_header *nextpool; /* next pool of this size class */ struct pool_header *prevpool; /* previous pool "" */ ! ulong arenaindex; /* index into arenas of base adr */ uint szidx; /* block size class index */ uint capacity; /* pool capacity in # of blocks */ --- 233,237 ---- struct pool_header *nextpool; /* next pool of this size class */ struct pool_header *prevpool; /* previous pool "" */ ! uint arenaindex; /* index into arenas of base adr */ uint szidx; /* block size class index */ uint capacity; /* pool capacity in # of blocks */ *************** *** 313,318 **** */ static uptr *arenas = NULL; ! static ulong narenas = 0; ! static ulong maxarenas = 0; /* Number of pools still available to be allocated in the current arena. */ --- 310,315 ---- */ static uptr *arenas = NULL; ! static uint narenas = 0; ! static uint maxarenas = 0; /* Number of pools still available to be allocated in the current arena. */ *************** *** 331,335 **** if (ptr) printf("inserted new arena at %08x\n", ptr); ! printf("# arenas %d\n", narenas); printf("was mine %lu wasn't mine %lu\n", wasmine, wasntmine); } --- 328,332 ---- if (ptr) printf("inserted new arena at %08x\n", ptr); ! printf("# arenas %u\n", narenas); printf("was mine %lu wasn't mine %lu\n", wasmine, wasntmine); } *************** *** 404,409 **** */ uptr *oldarenas; ! int newmax = maxarenas + (maxarenas >> 1); ! uptr *p = (uptr *)PyMem_MALLOC(newmax * sizeof(*arenas)); if (p == NULL) goto error; --- 401,410 ---- */ uptr *oldarenas; ! uptr *p; ! uint newmax = maxarenas + (maxarenas >> 1); ! ! if (newmax <= maxarenas) /* overflow */ ! goto error; ! p = (uptr *)PyMem_MALLOC(newmax * sizeof(*arenas)); if (p == NULL) goto error; *************** *** 418,422 **** assert(narenas < maxarenas); arenas[narenas] = (uptr)bp; ! ++narenas; dumpem(bp); return bp; --- 419,423 ---- assert(narenas < maxarenas); arenas[narenas] = (uptr)bp; ! ++narenas; /* can't overflow, since narenas < maxarenas before */ dumpem(bp); return bp; From tim_one@users.sourceforge.net Sat Mar 30 10:42:11 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 30 Mar 2002 02:42:11 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.17,2.18 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv11987/python/Objects Modified Files: obmalloc.c Log Message: new_arena(): In error cases, reset the number of available pools to 0. Else the pymalloc malloc will go insane the next time it's called. Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -d -r2.17 -r2.18 *** obmalloc.c 30 Mar 2002 10:35:09 -0000 2.17 --- obmalloc.c 30 Mar 2002 10:42:09 -0000 2.18 *************** *** 425,428 **** --- 425,429 ---- error: PyMem_FREE(bp); + nfreepools = 0; return NULL; } From gvanrossum@users.sourceforge.net Sat Mar 30 13:39:02 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sat, 30 Mar 2002 05:39:02 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0285.txt,1.12,1.13 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv13882 Modified Files: pep-0285.txt Log Message: Typo fix. Index: pep-0285.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0285.txt,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** pep-0285.txt 30 Mar 2002 05:37:02 -0000 1.12 --- pep-0285.txt 30 Mar 2002 13:39:00 -0000 1.13 *************** *** 229,233 **** possibly database code that relies on things like "%s" % truth) may fail. How much of a backwards compatibility problem this will ! be, I don't know. If we this turns out to be a real problem, we could changes the rules so that str() of a bool returns "0" or "1", while repr() of a bool still returns "False" or "True". --- 229,233 ---- possibly database code that relies on things like "%s" % truth) may fail. How much of a backwards compatibility problem this will ! be, I don't know. If this turns out to be a real problem, we could changes the rules so that str() of a bool returns "0" or "1", while repr() of a bool still returns "False" or "True". From tim_one@users.sourceforge.net Sat Mar 30 21:36:06 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 30 Mar 2002 13:36:06 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.18,2.19 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv13490/python/Objects Modified Files: obmalloc.c Log Message: It's once again thought safe to call the pymalloc free/realloc with an address obtained from system malloc/realloc without holding the GIL. When the vector of arena base addresses has to grow, the old vector is deliberately leaked. This makes "stale" x-thread references safe. arenas and narenas are also declared volatile, and changed in an order that prevents a thread from picking up a value of narenas too large for the value of arenas it sees. Added more asserts. Fixed an old inaccurate comment. Added a comment explaining why it's safe to call pymalloc free/realloc with an address obtained from system malloc/realloc even when arenas is still NULL (this is obscure, since the ADDRESS_IN_RANGE macro appears to index into arenas). Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.18 retrieving revision 2.19 diff -C2 -d -r2.18 -r2.19 *** obmalloc.c 30 Mar 2002 10:42:09 -0000 2.18 --- obmalloc.c 30 Mar 2002 21:36:04 -0000 2.19 *************** *** 172,176 **** /* * Size of the pools used for small blocks. Should be a power of 2, ! * between 1K and SYSTEM_PAGE_SIZE, that is: 1k, 2k, 4k, eventually 8k. */ #define POOL_SIZE SYSTEM_PAGE_SIZE /* must be 2^N */ --- 172,176 ---- /* * Size of the pools used for small blocks. Should be a power of 2, ! * between 1K and SYSTEM_PAGE_SIZE, that is: 1k, 2k, 4k. */ #define POOL_SIZE SYSTEM_PAGE_SIZE /* must be 2^N */ *************** *** 309,314 **** * to the OS. */ ! static uptr *arenas = NULL; ! static uint narenas = 0; static uint maxarenas = 0; --- 309,314 ---- * to the OS. */ ! static uptr *volatile arenas = NULL; /* the pointer itself is volatile */ ! static volatile uint narenas = 0; static uint maxarenas = 0; *************** *** 355,358 **** --- 355,359 ---- arenabase = bp; nfreepools = ARENA_SIZE / POOL_SIZE; + assert(POOL_SIZE * nfreepools == ARENA_SIZE); excess = (uint)bp & POOL_SIZE_MASK; if (excess != 0) { *************** *** 363,375 **** /* Make room for a new entry in the arenas vector. */ if (arenas == NULL) { arenas = (uptr *)PyMem_MALLOC(16 * sizeof(*arenas)); if (arenas == NULL) goto error; maxarenas = 16; - narenas = 0; } else if (narenas == maxarenas) { /* Grow arenas. Don't use realloc: if this fails, we * don't want to lose the base addresses we already have. * Exceedingly subtle: Someone may be calling the pymalloc * free via PyMem_{DEL, Del, FREE, Free} without holding the --- 364,377 ---- /* Make room for a new entry in the arenas vector. */ if (arenas == NULL) { + assert(narenas == 0 && maxarenas == 0); arenas = (uptr *)PyMem_MALLOC(16 * sizeof(*arenas)); if (arenas == NULL) goto error; maxarenas = 16; } else if (narenas == maxarenas) { /* Grow arenas. Don't use realloc: if this fails, we * don't want to lose the base addresses we already have. + * * Exceedingly subtle: Someone may be calling the pymalloc * free via PyMem_{DEL, Del, FREE, Free} without holding the *************** *** 393,407 **** * make a supposed-to-fail case succeed by mistake (it could * only make a supposed-to-succeed case fail by mistake). * Read the above 50 times before changing anything in this * block. - * XXX Fudge. This is still vulnerable: there's nothing - * XXX to stop the bad-guy thread from picking up the - * XXX current value of arenas, but not indexing off of it - * XXX until after the PyMem_FREE(oldarenas) below completes. */ - uptr *oldarenas; uptr *p; ! uint newmax = maxarenas + (maxarenas >> 1); ! if (newmax <= maxarenas) /* overflow */ goto error; --- 395,415 ---- * make a supposed-to-fail case succeed by mistake (it could * only make a supposed-to-succeed case fail by mistake). + * + * In addition, without a lock we can't know for sure when + * an old vector is no longer referenced, so we simply let + * old vectors leak. + * + * And on top of that, since narenas and arenas can't be + * changed as-a-pair atomically without a lock, we're also + * careful to declare them volatile and ensure that we change + * arenas first. This prevents another thread from picking + * up an narenas value too large for the arenas value it + * reads up (arenas never shrinks). + * * Read the above 50 times before changing anything in this * block. */ uptr *p; ! uint newmax = maxarenas << 1; if (newmax <= maxarenas) /* overflow */ goto error; *************** *** 410,416 **** goto error; memcpy(p, arenas, narenas * sizeof(*arenas)); ! oldarenas = arenas; ! arenas = p; ! PyMem_FREE(oldarenas); maxarenas = newmax; } --- 418,422 ---- goto error; memcpy(p, arenas, narenas * sizeof(*arenas)); ! arenas = p; /* old arenas deliberately leaked */ maxarenas = newmax; } *************** *** 432,435 **** --- 438,442 ---- * pymalloc. I must be the index into arenas that the address claims * to come from. + * * Tricky: Letting B be the arena base address in arenas[I], P belongs to the * arena if and only if *************** *** 438,441 **** --- 445,454 ---- * 0 <= P-B < ARENA_SIZE * By using unsigned arithmetic, the "0 <=" half of the test can be skipped. + * + * Obscure: A PyMem "free memory" function can call the pymalloc free or + * realloc before the first arena has been allocated. arenas is still + * NULL in that case. We're relying on that narenas is also 0 in that case, + * so the (I) < narenas must be false, saving us from trying to index into + * a NULL arenas. */ #define ADDRESS_IN_RANGE(P, I) \ From jackjansen@users.sourceforge.net Sat Mar 30 23:43:07 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sat, 30 Mar 2002 15:43:07 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/scripts gensuitemodule.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/scripts In directory usw-pr-cvs1:/tmp/cvs-serv8393/scripts Modified Files: gensuitemodule.py Log Message: Modified to allow it to run in MachoPython in a reasonable way. It still needs a decent commandline interface, though. Index: gensuitemodule.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/scripts/gensuitemodule.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** gensuitemodule.py 24 Jan 2002 22:44:07 -0000 1.21 --- gensuitemodule.py 30 Mar 2002 23:43:04 -0000 1.22 *************** *** 15,32 **** import macfs import keyword from Carbon.Res import * def main(): ! fss, ok = macfs.PromptGetFile('Select file with aeut/aete resource:') ! if not ok: ! sys.exit(0) ! processfile(fss.as_pathname()) def processfile(fullname): """Process all resources in a single file""" cur = CurResFile() ! print fullname ! rf = OpenRFPerm(fullname, 0, 1) try: UseResFile(rf) --- 15,39 ---- import macfs import keyword + import macresource from Carbon.Res import * + DEFAULT_PACKAGEFOLDER=os.path.join(sys.prefix, 'Mac', 'Lib', 'lib-scriptpackages') + def main(): ! if len(sys.argv) > 1: ! for filename in sys.argv[1:]: ! processfile(filename) ! else: ! fss, ok = macfs.PromptGetFile('Select file with aeut/aete resource:') ! if not ok: ! sys.exit(0) ! processfile(fss.as_pathname()) def processfile(fullname): """Process all resources in a single file""" cur = CurResFile() ! print "Processing", fullname ! rf = macresource.open_pathname(fullname) try: UseResFile(rf) *************** *** 226,230 **** fss = macfs.FSSpec(fname) creatorsignature, dummy = fss.GetCreatorType() ! packagename = identify(os.path.basename(fname)) if language: packagename = packagename+'_lang%d'%language --- 233,237 ---- fss = macfs.FSSpec(fname) creatorsignature, dummy = fss.GetCreatorType() ! packagename = identify(os.path.splitext(os.path.basename(fname))[0]) if language: packagename = packagename+'_lang%d'%language *************** *** 233,238 **** if len(packagename) > 27: packagename = packagename[:27] ! macfs.SetFolder(os.path.join(sys.prefix, ':Mac:Lib:lib-scriptpackages')) ! fss, ok = macfs.GetDirectory('Package folder for %s'%packagename) if not ok: return --- 240,245 ---- if len(packagename) > 27: packagename = packagename[:27] ! macfs.SetFolder(DEFAULT_PACKAGEFOLDER) ! fss, ok = macfs.GetDirectory('Create and select package folder for %s'%packagename) if not ok: return *************** *** 289,293 **** fp.write(",\n\t\t%s_Events"%modname) fp.write(",\n\t\taetools.TalkTo):\n") ! fp.write("\t_signature = '%s'\n\n"%creatorsignature) fp.close() --- 296,300 ---- fp.write(",\n\t\t%s_Events"%modname) fp.write(",\n\t\taetools.TalkTo):\n") ! fp.write("\t_signature = %s\n\n"%`creatorsignature`) fp.close() From jackjansen@users.sourceforge.net Sat Mar 30 23:43:38 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sat, 30 Mar 2002 15:43:38 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/OSX sample_sitecustomize.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory usw-pr-cvs1:/tmp/cvs-serv8576/OSX Modified Files: sample_sitecustomize.py Log Message: Add Mac/Lib/lib-scriptpackages to sys.path too. Index: sample_sitecustomize.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/sample_sitecustomize.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sample_sitecustomize.py 18 Jan 2002 16:12:26 -0000 1.1 --- sample_sitecustomize.py 30 Mar 2002 23:43:36 -0000 1.2 *************** *** 1,4 **** import sys import os ! _maclib = os.path.join(sys.prefix, 'Mac/Lib') ! sys.path.append(_maclib) \ No newline at end of file --- 1,6 ---- import sys import os ! _maclib = os.path.join(sys.prefix, 'Mac', 'Lib') ! _scriptlib = os.path.join(_maclib, 'lib-scriptpackages') ! sys.path.append(_maclib) ! sys.path.append(_scriptlib) From jackjansen@users.sourceforge.net Sat Mar 30 23:45:00 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sat, 30 Mar 2002 15:45:00 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Lib aepack.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib In directory usw-pr-cvs1:/tmp/cvs-serv8701/Lib Modified Files: aepack.py Log Message: Got rid of obsolete way to get at various toolbox types. Index: aepack.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Lib/aepack.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** aepack.py 5 Feb 2002 21:24:47 -0000 1.3 --- aepack.py 30 Mar 2002 23:44:58 -0000 1.4 *************** *** 58,66 **** # Some python types we need in the packer: # ! AEDescType = type(AE.AECreateDesc('TEXT', '')) ! _sample_fss = macfs.FSSpec(':') ! _sample_alias = _sample_fss.NewAliasMinimal() ! FSSType = type(_sample_fss) ! AliasType = type(_sample_alias) def pack(x, forcetype = None): --- 58,64 ---- # Some python types we need in the packer: # ! AEDescType = AE.AEDescType ! FSSType = macfs.FSSpecType ! AliasType = macfs.AliasType def pack(x, forcetype = None): From jackjansen@users.sourceforge.net Sat Mar 30 23:45:42 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sat, 30 Mar 2002 15:45:42 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Lib/lib-scriptpackages/Terminal - New directory Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib/lib-scriptpackages/Terminal In directory usw-pr-cvs1:/tmp/cvs-serv8932/Terminal Log Message: Directory /cvsroot/python/python/dist/src/Mac/Lib/lib-scriptpackages/Terminal added to the repository From jackjansen@users.sourceforge.net Sat Mar 30 23:46:18 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sat, 30 Mar 2002 15:46:18 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Lib/lib-scriptpackages/Terminal Terminal_Suite.py,NONE,1.1 __init__.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib/lib-scriptpackages/Terminal In directory usw-pr-cvs1:/tmp/cvs-serv9029 Added Files: Terminal_Suite.py __init__.py Log Message: Suite to talk to the OSX Terminal application. --- NEW FILE: Terminal_Suite.py --- """Suite Terminal Suite: Terms and Events for controlling the Terminal application Level 1, version 1 Generated from /Applications/Utilities/Terminal.app/Contents/Resources/Terminal.rsrc AETE/AEUT resource version 1/0, language 0, script 0 """ import aetools import MacOS _code = 'trmx' class Terminal_Suite_Events: def run(self, _no_object=None, _attributes={}, **_arguments): """run: Run the Terminal application Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'core' _subcode = 'oapp' if _arguments: raise TypeError, 'No optional args expected' if _no_object != None: raise TypeError, 'No direct arg expected' _reply, _arguments, _attributes = self.send(_code, _subcode, _arguments, _attributes) if _arguments.has_key('errn'): raise aetools.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result if _arguments.has_key('----'): return _arguments['----'] def quit(self, _no_object=None, _attributes={}, **_arguments): """quit: Quit the Terminal application Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'core' _subcode = 'quit' if _arguments: raise TypeError, 'No optional args expected' if _no_object != None: raise TypeError, 'No direct arg expected' _reply, _arguments, _attributes = self.send(_code, _subcode, _arguments, _attributes) if _arguments.has_key('errn'): raise aetools.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result if _arguments.has_key('----'): return _arguments['----'] def count(self, _object=None, _attributes={}, **_arguments): """count: Return the number of elements of a particular class within an object Required argument: a reference to the objects to be counted Keyword argument _attributes: AppleEvent attribute dictionary Returns: the number of objects counted """ _code = 'core' _subcode = 'cnte' if _arguments: raise TypeError, 'No optional args expected' _arguments['----'] = _object _reply, _arguments, _attributes = self.send(_code, _subcode, _arguments, _attributes) if _arguments.has_key('errn'): raise aetools.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result if _arguments.has_key('----'): return _arguments['----'] _argmap_do_script = { 'with_command' : 'cmnd', } def do_script(self, _no_object=None, _attributes={}, **_arguments): """do script: Run a UNIX shell script or command Keyword argument with_command: data to be passed to the Terminal application as the command line Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'core' _subcode = 'dosc' aetools.keysubst(_arguments, self._argmap_do_script) if _no_object != None: raise TypeError, 'No direct arg expected' _reply, _arguments, _attributes = self.send(_code, _subcode, _arguments, _attributes) if _arguments.has_key('errn'): raise aetools.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result if _arguments.has_key('----'): return _arguments['----'] class application(aetools.ComponentItem): """application - The Terminal program """ want = 'capp' class name(aetools.NProperty): """name - the name of the application """ which = 'pnam' want = 'TEXT' class version(aetools.NProperty): """version - the version of the application """ which = 'vers' want = 'vers' class frontmost(aetools.NProperty): """frontmost - Is this the active application? """ which = 'pisf' want = 'bool' # element 'cwin' as ['name', 'indx'] applications = application class window(aetools.ComponentItem): """window - A Terminal window """ want = 'cwin' class index(aetools.NProperty): """index - the number of the window """ which = 'pidx' want = 'long' class visible(aetools.NProperty): """visible - Is the window visible? """ which = 'pvis' want = 'bool' class has_close_box(aetools.NProperty): """has close box - Does the window have a close box? """ which = 'hclb' want = 'bool' class has_title_bar(aetools.NProperty): """has title bar - Does the window have a title bar? """ which = 'ptit' want = 'bool' class floating(aetools.NProperty): """floating - Does the window float? """ which = 'isfl' want = 'bool' class modal(aetools.NProperty): """modal - Is the window modal? """ which = 'pmod' want = 'bool' class resizable(aetools.NProperty): """resizable - Is the window resizable? """ which = 'prsz' want = 'bool' class zoomable(aetools.NProperty): """zoomable - Is the window zoomable? """ which = 'iszm' want = 'bool' class zoomed(aetools.NProperty): """zoomed - Is the window zoomed? """ which = 'pzum' want = 'bool' class miniaturizable(aetools.NProperty): """miniaturizable - Is the window miniaturizable? """ which = 'mini' want = 'bool' class miniaturized(aetools.NProperty): """miniaturized - Is the window miniaturized? """ which = 'mina' want = 'bool' class position(aetools.NProperty): """position - the upper left coordinates of window """ which = 'ppos' want = 'QDpt' class bounds(aetools.NProperty): """bounds - the boundary rectangle for the window """ which = 'pbnd' want = 'qdrt' class title_displays_device_name(aetools.NProperty): """title displays device name - Does the title for the window contain the device name? """ which = 'tddn' want = 'bool' class title_displays_shell_path(aetools.NProperty): """title displays shell path - Does the title for the window contain the shell path? """ which = 'tdsp' want = 'bool' class title_displays_window_size(aetools.NProperty): """title displays window size - Does the title for the window contain the window size? """ which = 'tdws' want = 'bool' class title_displays_file_name(aetools.NProperty): """title displays file name - Does the title for the window contain the file name? """ which = 'tdfn' want = 'bool' class title_displays_custom_title(aetools.NProperty): """title displays custom title - Does the title for the window contain a custom title? """ which = 'tdct' want = 'bool' class custom_title(aetools.NProperty): """custom title - the custom title for the window """ which = 'titl' want = 'TEXT' class contents(aetools.NProperty): """contents - the currently visible contents of the window """ which = 'pcnt' want = 'TEXT' class history(aetools.NProperty): """history - the contents of the entire scrolling buffer of the window """ which = 'hist' want = 'TEXT' class number_of_rows(aetools.NProperty): """number of rows - the number of rows in the window """ which = 'crow' want = 'long' class number_of_columns(aetools.NProperty): """number of columns - the number of columns in the window """ which = 'ccol' want = 'long' class cursor_color(aetools.NProperty): """cursor color - the cursor color for the window """ which = 'pcuc' want = 'TEXT' class background_color(aetools.NProperty): """background color - the background color for the window """ which = 'pbcl' want = 'TEXT' class normal_text_color(aetools.NProperty): """normal text color - the normal text color for the window """ which = 'ptxc' want = 'TEXT' class bold_text_color(aetools.NProperty): """bold text color - the bold text color for the window """ which = 'pbtc' want = 'TEXT' windows = window application._propdict = { 'name' : name, 'version' : version, 'frontmost' : frontmost, } application._elemdict = { 'window' : window, } window._propdict = { 'name' : name, 'index' : index, 'visible' : visible, 'has_close_box' : has_close_box, 'has_title_bar' : has_title_bar, 'floating' : floating, 'modal' : modal, 'resizable' : resizable, 'zoomable' : zoomable, 'zoomed' : zoomed, 'miniaturizable' : miniaturizable, 'miniaturized' : miniaturized, 'position' : position, 'bounds' : bounds, 'title_displays_device_name' : title_displays_device_name, 'title_displays_shell_path' : title_displays_shell_path, 'title_displays_window_size' : title_displays_window_size, 'title_displays_file_name' : title_displays_file_name, 'title_displays_custom_title' : title_displays_custom_title, 'custom_title' : custom_title, 'contents' : contents, 'history' : history, 'number_of_rows' : number_of_rows, 'number_of_columns' : number_of_columns, 'cursor_color' : cursor_color, 'background_color' : background_color, 'normal_text_color' : normal_text_color, 'bold_text_color' : bold_text_color, } window._elemdict = { } # # Indices of types declared in this module # _classdeclarations = { 'cwin' : window, 'capp' : application, } _propdeclarations = { 'tdfn' : title_displays_file_name, 'mini' : miniaturizable, 'vers' : version, 'pidx' : index, 'prsz' : resizable, 'pbnd' : bounds, 'mina' : miniaturized, 'pbcl' : background_color, 'tddn' : title_displays_device_name, 'iszm' : zoomable, 'hclb' : has_close_box, 'isfl' : floating, 'pcnt' : contents, 'ppos' : position, 'ptxc' : normal_text_color, 'pcuc' : cursor_color, 'tdsp' : title_displays_shell_path, 'pvis' : visible, 'tdct' : title_displays_custom_title, 'pmod' : modal, 'titl' : custom_title, 'pisf' : frontmost, 'hist' : history, 'pzum' : zoomed, 'crow' : number_of_rows, 'pnam' : name, 'ccol' : number_of_columns, 'tdws' : title_displays_window_size, 'pbtc' : bold_text_color, 'ptit' : has_title_bar, } _compdeclarations = { } _enumdeclarations = { } --- NEW FILE: __init__.py --- """ Package generated from /Applications/Utilities/Terminal.app/Contents/Resources/Terminal.rsrc Resource aete resid 0 Terminal Terminology """ # Note: hand-edited _signature to 'trmx'. import aetools Error = aetools.Error import Terminal_Suite _code_to_module = { 'trmx' : Terminal_Suite, } _code_to_fullname = { 'trmx' : ('Terminal.Terminal_Suite', 'Terminal_Suite'), } from Terminal_Suite import * class Terminal(Terminal_Suite_Events, aetools.TalkTo): _signature = 'trmx' From tim_one@users.sourceforge.net Sun Mar 31 01:05:24 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 30 Mar 2002 17:05:24 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.19,2.20 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv23826/python/Objects Modified Files: obmalloc.c Log Message: Added a long-overdue comment block giving an overview of pool operations and terminology, plus explanation of some extreme obscurities. Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.19 retrieving revision 2.20 diff -C2 -d -r2.19 -r2.20 *** obmalloc.c 30 Mar 2002 21:36:04 -0000 2.19 --- obmalloc.c 31 Mar 2002 01:05:22 -0000 2.20 *************** *** 262,267 **** /* ! * Pool table -- doubly linked lists of partially used pools ! */ #define PTA(x) ((poolp )((uchar *)&(usedpools[2*(x)]) - 2*sizeof(block *))) #define PT(x) PTA(x), PTA(x) --- 262,324 ---- /* ! * Pool table -- headed, circular, doubly-linked lists of partially used pools. ! ! This is involved. For an index i, usedpools[i+i] is the header for a list of ! all partially used pools holding small blocks with "size class idx" i. So ! usedpools[0] corresponds to blocks of size 8, usedpools[2] to blocks of size ! 16, and so on: index 2*i <-> blocks of size (i+1)<nextpool and p->prevpool are both p (meaning that the headed ! circular list is empty). ! ! It's unclear why the usedpools setup is so convoluted. It could be to ! minimize the amount of cache required to hold this heavily-referenced table ! (which only *needs* the two interpool pointer members of a pool_header). OTOH, ! referencing code has to remember to "double the index" and doing so isn't ! free, usedpools[0] isn't a strictly legal pointer, and we're crucially relying ! on that C doesn't insert any padding anywhere in a pool_header at or before ! the prevpool member. ! **************************************************************************** */ ! #define PTA(x) ((poolp )((uchar *)&(usedpools[2*(x)]) - 2*sizeof(block *))) #define PT(x) PTA(x), PTA(x) *************** *** 620,625 **** if (ADDRESS_IN_RANGE(p, pool->arenaindex)) { /* We allocated this address. */ - INCMINE; LOCK(); /* * At this point, the pool is not empty --- 677,682 ---- if (ADDRESS_IN_RANGE(p, pool->arenaindex)) { /* We allocated this address. */ LOCK(); + INCMINE; /* * At this point, the pool is not empty From tim_one@users.sourceforge.net Sun Mar 31 02:18:03 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 30 Mar 2002 18:18:03 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.20,2.21 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv3326/python/Objects Modified Files: obmalloc.c Log Message: _PyMalloc_Free(): As was already done for _PyMalloc_Malloc, rearranged the code so that the most frequent cases come first. Added comments. Found a hidden assumption that a pool contains room for at least two blocks, and added an assert to catch a violation if it ever happens in a place where that matters. Gave the normal "I allocated this block" case a longer basic block to work with before it has to do its first branch (via breaking apart an embedded assignment in an "if", and hoisting common code out of both branches). Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.20 retrieving revision 2.21 diff -C2 -d -r2.20 -r2.21 *** obmalloc.c 31 Mar 2002 01:05:22 -0000 2.20 --- obmalloc.c 31 Mar 2002 02:18:01 -0000 2.21 *************** *** 668,671 **** --- 668,672 ---- { poolp pool; + block *lastfree; poolp next, prev; uint size; *************** *** 680,734 **** INCMINE; /* ! * At this point, the pool is not empty */ ! if ((*(block **)p = pool->freeblock) == NULL) { /* ! * Pool was full */ ! pool->freeblock = (block *)p; ! --pool->ref.count; /* ! * Frontlink to used pools ! * This mimics LRU pool usage for new allocations and ! * targets optimal filling when several pools contain ! * blocks of the same size class. */ ! size = pool->szidx; ! next = usedpools[size + size]; ! prev = next->prevpool; ! pool->nextpool = next; ! pool->prevpool = prev; ! next->prevpool = pool; ! prev->nextpool = pool; ! UNLOCK(); ! return; ! } ! /* ! * Pool was not full ! */ ! pool->freeblock = (block *)p; ! if (--pool->ref.count != 0) { UNLOCK(); return; } /* ! * Pool is now empty, unlink from used pools ! */ ! next = pool->nextpool; ! prev = pool->prevpool; ! next->prevpool = prev; ! prev->nextpool = next; ! /* ! * Frontlink to free pools ! * This ensures that previously freed pools will be allocated ! * later (being not referenced, they are perhaps paged out). */ ! pool->nextpool = freepools; ! freepools = pool; UNLOCK(); return; } ! /* We did not allocate this address. */ INCTHEIRS; PyMem_FREE(p); --- 681,744 ---- INCMINE; /* ! * Link p to the start of the pool's freeblock list. Since ! * the pool had at least the p block outstanding, the pool ! * wasn't empty (so it's already in a usedpools[] list, or ! * was full and is in no list -- it's not in the freeblocks ! * list in any case). */ ! *(block **)p = lastfree = pool->freeblock; ! pool->freeblock = (block *)p; ! if (lastfree) { /* ! * freeblock wasn't NULL, so the pool wasn't full, ! * and the pool is in a usedpools[] list. */ ! assert(pool->ref.count < pool.capacity); ! if (--pool->ref.count != 0) { ! /* pool isn't empty: leave it in usedpools */ ! UNLOCK(); ! return; ! } /* ! * Pool is now empty: unlink from usedpools, and ! * link to the front of usedpools. This ensures that ! * previously freed pools will be allocated later ! * (being not referenced, they are perhaps paged out). */ ! next = pool->nextpool; ! prev = pool->prevpool; ! next->prevpool = prev; ! prev->nextpool = next; ! /* Link to freepools. This is a singly-linked list, ! * and pool->prevpool isn't used there. ! */ ! pool->nextpool = freepools; ! freepools = pool; UNLOCK(); return; } /* ! * Pool was full, so doesn't currently live in any list: ! * link it to the front of the appropriate usedpools[] list. ! * This mimics LRU pool usage for new allocations and ! * targets optimal filling when several pools contain ! * blocks of the same size class. */ ! assert(pool->ref.count == pool->capacity); /* else not full */ ! --pool->ref.count; ! assert(pool->ref.count > 0); /* else the pool is empty */ ! size = pool->szidx; ! next = usedpools[size + size]; ! prev = next->prevpool; ! /* insert pool before next: prev <-> pool <-> next */ ! pool->nextpool = next; ! pool->prevpool = prev; ! next->prevpool = pool; ! prev->nextpool = pool; UNLOCK(); return; } ! /* We didn't allocate this address. */ INCTHEIRS; PyMem_FREE(p); From tim_one@users.sourceforge.net Sun Mar 31 02:51:43 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 30 Mar 2002 18:51:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.21,2.22 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv10157/python/Objects Modified Files: obmalloc.c Log Message: Fixed a typo in a new comment. Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.21 retrieving revision 2.22 diff -C2 -d -r2.21 -r2.22 *** obmalloc.c 31 Mar 2002 02:18:01 -0000 2.21 --- obmalloc.c 31 Mar 2002 02:51:40 -0000 2.22 *************** *** 702,706 **** /* * Pool is now empty: unlink from usedpools, and ! * link to the front of usedpools. This ensures that * previously freed pools will be allocated later * (being not referenced, they are perhaps paged out). --- 702,706 ---- /* * Pool is now empty: unlink from usedpools, and ! * link to the front of freepools. This ensures that * previously freed pools will be allocated later * (being not referenced, they are perhaps paged out). From tim_one@users.sourceforge.net Sun Mar 31 02:52:31 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 30 Mar 2002 18:52:31 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.22,2.23 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv10271/python/Objects Modified Files: obmalloc.c Log Message: Fixed an error in a new assert. Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.22 retrieving revision 2.23 diff -C2 -d -r2.22 -r2.23 *** obmalloc.c 31 Mar 2002 02:51:40 -0000 2.22 --- obmalloc.c 31 Mar 2002 02:52:29 -0000 2.23 *************** *** 694,698 **** * and the pool is in a usedpools[] list. */ ! assert(pool->ref.count < pool.capacity); if (--pool->ref.count != 0) { /* pool isn't empty: leave it in usedpools */ --- 694,698 ---- * and the pool is in a usedpools[] list. */ ! assert(pool->ref.count < pool->capacity); if (--pool->ref.count != 0) { /* pool isn't empty: leave it in usedpools */ From tim_one@users.sourceforge.net Sun Mar 31 02:59:50 2002 From: tim_one@users.sourceforge.net (Tim Peters) Date: Sat, 30 Mar 2002 18:59:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.23,2.24 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv11358/python/Objects Modified Files: obmalloc.c Log Message: Add one more assert that indirectly interlocking conditions are consistent with each other. Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.23 retrieving revision 2.24 diff -C2 -d -r2.23 -r2.24 *** obmalloc.c 31 Mar 2002 02:52:29 -0000 2.23 --- obmalloc.c 31 Mar 2002 02:59:48 -0000 2.24 *************** *** 687,690 **** --- 687,691 ---- * list in any case). */ + assert(pool->ref.count > 0); /* else it was empty */ *(block **)p = lastfree = pool->freeblock; pool->freeblock = (block *)p; From gvanrossum@users.sourceforge.net Sun Mar 31 11:26:18 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sun, 31 Mar 2002 03:26:18 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0285.txt,1.13,1.14 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv13437 Modified Files: pep-0285.txt Log Message: Incorporated review feedback. Added Jython argument. Added mention of standard library. Added clarification that "if :" remains as valid as ever. Minor rewordings all over, got rid of "e.g." again. Index: pep-0285.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0285.txt,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** pep-0285.txt 30 Mar 2002 13:39:00 -0000 1.13 --- pep-0285.txt 31 Mar 2002 11:26:16 -0000 1.14 *************** *** 33,46 **** 1) Should this PEP be accepted at all. 2) Should str(True) return "True" or "1": "1" might reduce backwards compatibility problems, but looks strange to me. (repr(True) would always return "True".) 3) Should the constants be called 'True' and 'False' (corresponding to None) or 'true' and 'false' (as in C++, Java and C99). Most other details of the proposal are pretty much forced by the ! backwards compatibility requirement; e.g. True == 1 and True+1 == 2 must hold, else reams of existing code would break. --- 33,61 ---- 1) Should this PEP be accepted at all. + => The majority of reviewers so far are in favor, ranging from +0 + (don't hate it) to 1 (yes please). Votes against are mixed: + some are against all change, some think it's not needed, some + think it will just add more confusion or complexity, some have + irrational fears about code breakage based on misunderstanding + the PEP (believing it adds reserved words, or believing it will + require you to write "if bool(x):" where previously "if x:" + worked; neither belief is true). + 2) Should str(True) return "True" or "1": "1" might reduce backwards compatibility problems, but looks strange to me. (repr(True) would always return "True".) + => Most reviewers prefer str(True) == "True" (which may mean that + they don't appreciate the specific + 3) Should the constants be called 'True' and 'False' (corresponding to None) or 'true' and 'false' (as in C++, Java and C99). + => There's no clear preference either way here, so I'll break the + tie by pronouncing False and True. + Most other details of the proposal are pretty much forced by the ! backwards compatibility requirement; for example, True == 1 and True+1 == 2 must hold, else reams of existing code would break. *************** *** 48,63 **** 4) Should we strive to eliminate non-Boolean operations on bools ! in the future, through suitable warnings, so that e.g. True+1 ! would eventually (e.g. in Python 3000 be illegal). Personally, ! I think we shouldn't; 28+isleap(y) seems totally reasonable to ! me. 5) Should operator.truth(x) return an int or a bool. Tim Peters believes it should return an int because it's been documented as such. I think it should return a bool; most other standard ! predicates (e.g. issubtype()) have also been documented as returning 0 or 1, and it's obvious that we want to change those to return a bool. Rationale --- 63,118 ---- 4) Should we strive to eliminate non-Boolean operations on bools ! in the future, through suitable warnings, so that for example ! True+1 would eventually (in Python 3000) be illegal. ! Personally, I think we shouldn't; 28+isleap(y) seems totally ! reasonable to me. ! ! => Most reviewers agree with me. 5) Should operator.truth(x) return an int or a bool. Tim Peters believes it should return an int because it's been documented as such. I think it should return a bool; most other standard ! predicates (like issubtype()) have also been documented as returning 0 or 1, and it's obvious that we want to change those to return a bool. + => Most reviewers agree with me. My take: operator.truth() exists + to force a Boolean context on its argument (it calls the C API + PyObject_IsTrue()). Whether the outcome is reported as int or + bool is secondary; if bool exists there's no reason not to use + it. + + New issues brought up during the review: + + 6) Should bool inherit from int? + + => My take: in an ideal world, bool might be better implemented as + a separate integer type that knows how to perform mixed-mode + arithmetic. However, inheriting bool from int eases the + implementation enormously (in part since all C code that calls + PyInt_Check() will continue to work -- this returns true for + subclasses of int). Also, I believe in terms of + substitutability, this is right: code that requires an int can + be fed a bool and it will behave the same as 0 or 1. Code that + requires a bool may not work when it is given an int; for + example, 3 & 4 is 0, but both 3 and 4 are true when considered + as truth values. + + 7) Should the name 'bool' be changed? + + => Some reviewers argue for boolean instead of bool, because this + would be easier to understand (novices may have heard of + Boolean algebra but may not make the connection with bool) or + because they hate abbreviations. My take: Python uses + abbreviations judiciously (like 'def', 'int', 'dict') and I + don't think these are a burden to understanding. + + One reviewer argues to make the name 'truth'. I find this an + unattractive name, and would actually prefer to reserve this + term (in documentation) for the more abstract concept of truth + values that already exists in Python. For example: "when a + container is interpreted as a truth value, an empty container + is considered false and a non-empty one is considered true." + Rationale *************** *** 80,89 **** be able to distinguish between Boolean and integral values, and while it's usually possible to craft a solution, it would be ! easier if the language offered a standard Boolean type. The standard bool type can also serve as a way to force a value to be interpreted as a Boolean, which can be used to normalize ! Boolean values. Writing bool(x) is much clearer than "not not x" ! and much more concise than if x: --- 135,148 ---- be able to distinguish between Boolean and integral values, and while it's usually possible to craft a solution, it would be ! easier if the language offered a standard Boolean type. This also ! applies to Jython: some Java classes have separately overloaded ! methods or constructors for int and boolean arguments. The bool ! type can be used to select the boolean variant. The standard bool type can also serve as a way to force a value to be interpreted as a Boolean, which can be used to normalize ! Boolean values. When a Boolean value needs to be normalized to ! one of two values, bool(x) is much clearer than "not not x" and ! much more concise than if x: *************** *** 193,201 **** objects. ! Note that subclassing from int means that True+1 is valid and ! equals 2, and so on. This is important for backwards ! compatibility: because comparisons and so on currently return ! integer values, there's no way of telling what uses existing ! applications make of these values. --- 252,280 ---- objects. ! Because bool inherits from int, True+1 is valid and equals 2, and ! so on. This is important for backwards compatibility: because ! comparisons and so on currently return integer values, there's no ! way of telling what uses existing applications make of these ! values. ! ! It is expected that over time, the standard library will be ! updated to use False and True when appropriate (but not to require ! a bool argument type where previous an int was allowed). This ! change should not pose additional problems and is not specified in ! detail by this PEP. ! ! ! Clarification ! ! This PEP does *not* change the fact that almost all object types ! can be used as truth values. For example, when used in an if ! statement, an empty list is false and a non-empty one is true; ! this does not change and there is no plan to ever change this. ! ! The only thing that changes is the preferred values to represent ! truth values when returned or assigned explicitly. Previously, ! these preferred truth values were 0 and 1; the PEP changes the ! preferred values to False and True, and changes built-in ! operations to return these preferred values. *************** *** 245,254 **** expression x == True should be true, and likewise if x is considered false, x == False should be true. This is of course ! impossible; it would mean that e.g. 6 == True and 7 == True, from ! which one could infer 6 == 7. Similarly, [] == False == None ! would be true, and one could infer [] == None, which is not the ! case. I'm not sure where this suggestion came from; it was made ! several times during the first review period. For truth testing ! of a value, one should use "if", e.g. "if x: print 'Yes'", not comparison to a truth value; "if x == True: print 'Yes'" is not only wrong, it is also strangely redundant. --- 324,333 ---- expression x == True should be true, and likewise if x is considered false, x == False should be true. This is of course ! impossible; it would mean that for example 6 == True and 7 == ! True, from which one could infer 6 == 7. Similarly, [] == False ! == None would be true, and one could infer [] == None, which is ! not the case. I'm not sure where this suggestion came from; it ! was made several times during the first review period. For truth ! testing, one should use "if", as in "if x: print 'Yes'", not comparison to a truth value; "if x == True: print 'Yes'" is not only wrong, it is also strangely redundant. From nnorwitz@users.sourceforge.net Sun Mar 31 13:58:22 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 31 Mar 2002 05:58:22 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib bdb.py,1.35,1.36 macpath.py,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv3797 Modified Files: bdb.py macpath.py Log Message: Stop using string exceptions Index: bdb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/bdb.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** bdb.py 25 Feb 2002 23:23:24 -0000 1.35 --- bdb.py 31 Mar 2002 13:58:20 -0000 1.36 *************** *** 7,11 **** __all__ = ["BdbQuit","Bdb","Breakpoint"] ! BdbQuit = 'bdb.BdbQuit' # Exception to give up completely --- 7,11 ---- __all__ = ["BdbQuit","Bdb","Breakpoint"] ! class BdbQuit(Exception): pass Index: macpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/macpath.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** macpath.py 10 Oct 2001 04:16:20 -0000 1.31 --- macpath.py 31 Mar 2002 13:58:20 -0000 1.32 *************** *** 171,175 **** return path ! norm_error = 'macpath.norm_error: path cannot be normalized' def normpath(s): --- 171,175 ---- return path ! class norm_error(Exception): pass def normpath(s): From nnorwitz@users.sourceforge.net Sun Mar 31 13:59:20 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 31 Mar 2002 05:59:20 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib tabnanny.py,1.16,1.17 xdrlib.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv3973 Modified Files: tabnanny.py xdrlib.py Log Message: Derive exception classes from Exception Index: tabnanny.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tabnanny.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tabnanny.py 7 Aug 2001 17:19:25 -0000 1.16 --- tabnanny.py 31 Mar 2002 13:59:18 -0000 1.17 *************** *** 48,52 **** check(arg) ! class NannyNag: def __init__(self, lineno, msg, line): self.lineno, self.msg, self.line = lineno, msg, line --- 48,52 ---- check(arg) ! class NannyNag(Exception): def __init__(self, lineno, msg, line): self.lineno, self.msg, self.line = lineno, msg, line Index: xdrlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xdrlib.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** xdrlib.py 16 Aug 2001 17:06:44 -0000 1.13 --- xdrlib.py 31 Mar 2002 13:59:18 -0000 1.14 *************** *** 14,18 **** # exceptions ! class Error: """Exception class for this module. Use: --- 14,18 ---- # exceptions ! class Error(Exception): """Exception class for this module. Use: From nnorwitz@users.sourceforge.net Sun Mar 31 14:06:43 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 31 Mar 2002 06:06:43 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib bdb.py,1.36,1.37 macpath.py,1.32,1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv5715 Modified Files: bdb.py macpath.py Log Message: Use docstrings for exception classes Index: bdb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/bdb.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** bdb.py 31 Mar 2002 13:58:20 -0000 1.36 --- bdb.py 31 Mar 2002 14:06:41 -0000 1.37 *************** *** 7,11 **** __all__ = ["BdbQuit","Bdb","Breakpoint"] ! class BdbQuit(Exception): pass --- 7,12 ---- __all__ = ["BdbQuit","Bdb","Breakpoint"] ! class BdbQuit(Exception): ! """Exception to give up completely""" Index: macpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/macpath.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** macpath.py 31 Mar 2002 13:58:20 -0000 1.32 --- macpath.py 31 Mar 2002 14:06:41 -0000 1.33 *************** *** 171,175 **** return path ! class norm_error(Exception): pass def normpath(s): --- 171,176 ---- return path ! class norm_error(Exception): ! """Path cannot be normalized""" def normpath(s): From nnorwitz@users.sourceforge.net Sun Mar 31 14:37:46 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 31 Mar 2002 06:37:46 -0800 Subject: [Python-checkins] CVS: python/dist/src/Python import.c,2.196,2.197 marshal.c,1.69,1.70 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv11467/Python Modified Files: import.c marshal.c Log Message: Use symbolic METH_VARARGS instead of 1 for ml_flags Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.196 retrieving revision 2.197 diff -C2 -d -r2.196 -r2.197 *** import.c 29 Mar 2002 03:29:08 -0000 2.196 --- import.c 31 Mar 2002 14:37:44 -0000 2.197 *************** *** 2506,2530 **** static PyMethodDef imp_methods[] = { ! {"find_module", imp_find_module, 1, doc_find_module}, ! {"get_magic", imp_get_magic, 1, doc_get_magic}, ! {"get_suffixes", imp_get_suffixes, 1, doc_get_suffixes}, ! {"load_module", imp_load_module, 1, doc_load_module}, ! {"new_module", imp_new_module, 1, doc_new_module}, ! {"lock_held", imp_lock_held, 1, doc_lock_held}, /* The rest are obsolete */ ! {"get_frozen_object", imp_get_frozen_object, 1}, ! {"init_builtin", imp_init_builtin, 1}, ! {"init_frozen", imp_init_frozen, 1}, ! {"is_builtin", imp_is_builtin, 1}, ! {"is_frozen", imp_is_frozen, 1}, ! {"load_compiled", imp_load_compiled, 1}, #ifdef HAVE_DYNAMIC_LOADING ! {"load_dynamic", imp_load_dynamic, 1}, #endif ! {"load_package", imp_load_package, 1}, #ifdef macintosh ! {"load_resource", imp_load_resource, 1}, #endif ! {"load_source", imp_load_source, 1}, {NULL, NULL} /* sentinel */ }; --- 2506,2530 ---- static PyMethodDef imp_methods[] = { ! {"find_module", imp_find_module, METH_VARARGS, doc_find_module}, ! {"get_magic", imp_get_magic, METH_VARARGS, doc_get_magic}, ! {"get_suffixes", imp_get_suffixes, METH_VARARGS, doc_get_suffixes}, ! {"load_module", imp_load_module, METH_VARARGS, doc_load_module}, ! {"new_module", imp_new_module, METH_VARARGS, doc_new_module}, ! {"lock_held", imp_lock_held, METH_VARARGS, doc_lock_held}, /* The rest are obsolete */ ! {"get_frozen_object", imp_get_frozen_object, METH_VARARGS}, ! {"init_builtin", imp_init_builtin, METH_VARARGS}, ! {"init_frozen", imp_init_frozen, METH_VARARGS}, ! {"is_builtin", imp_is_builtin, METH_VARARGS}, ! {"is_frozen", imp_is_frozen, METH_VARARGS}, ! {"load_compiled", imp_load_compiled, METH_VARARGS}, #ifdef HAVE_DYNAMIC_LOADING ! {"load_dynamic", imp_load_dynamic, METH_VARARGS}, #endif ! {"load_package", imp_load_package, METH_VARARGS}, #ifdef macintosh ! {"load_resource", imp_load_resource, METH_VARARGS}, #endif ! {"load_source", imp_load_source, METH_VARARGS}, {NULL, NULL} /* sentinel */ }; Index: marshal.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/marshal.c,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** marshal.c 9 Nov 2001 22:02:48 -0000 1.69 --- marshal.c 31 Mar 2002 14:37:44 -0000 1.70 *************** *** 853,860 **** static PyMethodDef marshal_methods[] = { ! {"dump", marshal_dump, 1}, ! {"load", marshal_load, 1}, ! {"dumps", marshal_dumps, 1}, ! {"loads", marshal_loads, 1}, {NULL, NULL} /* sentinel */ }; --- 853,860 ---- static PyMethodDef marshal_methods[] = { ! {"dump", marshal_dump, METH_VARARGS}, ! {"load", marshal_load, METH_VARARGS}, ! {"dumps", marshal_dumps, METH_VARARGS}, ! {"loads", marshal_loads, METH_VARARGS}, {NULL, NULL} /* sentinel */ }; From nnorwitz@users.sourceforge.net Sun Mar 31 14:37:46 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 31 Mar 2002 06:37:46 -0800 Subject: [Python-checkins] CVS: python/dist/src/PC _winreg.c,1.8,1.9 msvcrtmodule.c,1.7,1.8 winsound.c,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory usw-pr-cvs1:/tmp/cvs-serv11467/PC Modified Files: _winreg.c msvcrtmodule.c winsound.c Log Message: Use symbolic METH_VARARGS instead of 1 for ml_flags Index: _winreg.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/_winreg.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** _winreg.c 28 Jul 2000 03:44:41 -0000 1.8 --- _winreg.c 31 Mar 2002 14:37:44 -0000 1.9 *************** *** 522,527 **** static struct PyMethodDef PyHKEY_methods[] = { ! {"Close", PyHKEY_CloseMethod, 1, PyHKEY_Close_doc}, ! {"Detach", PyHKEY_DetachMethod, 1, PyHKEY_Detach_doc}, {NULL} }; --- 522,527 ---- static struct PyMethodDef PyHKEY_methods[] = { ! {"Close", PyHKEY_CloseMethod, METH_VARARGS, PyHKEY_Close_doc}, ! {"Detach", PyHKEY_DetachMethod, METH_VARARGS, PyHKEY_Detach_doc}, {NULL} }; *************** *** 1383,1403 **** static struct PyMethodDef winreg_methods[] = { ! {"CloseKey", PyCloseKey, 1, CloseKey_doc}, ! {"ConnectRegistry", PyConnectRegistry, 1, ConnectRegistry_doc}, ! {"CreateKey", PyCreateKey, 1, CreateKey_doc}, ! {"DeleteKey", PyDeleteKey, 1, DeleteKey_doc}, ! {"DeleteValue", PyDeleteValue, 1, DeleteValue_doc}, ! {"EnumKey", PyEnumKey, 1, EnumKey_doc}, ! {"EnumValue", PyEnumValue, 1, EnumValue_doc}, ! {"FlushKey", PyFlushKey, 1, FlushKey_doc}, ! {"LoadKey", PyLoadKey, 1, LoadKey_doc}, ! {"OpenKey", PyOpenKey, 1, OpenKey_doc}, ! {"OpenKeyEx", PyOpenKey, 1, OpenKeyEx_doc}, ! {"QueryValue", PyQueryValue, 1, QueryValue_doc}, ! {"QueryValueEx", PyQueryValueEx, 1, QueryValueEx_doc}, ! {"QueryInfoKey", PyQueryInfoKey, 1, QueryInfoKey_doc}, ! {"SaveKey", PySaveKey, 1, SaveKey_doc}, ! {"SetValue", PySetValue, 1, SetValue_doc}, ! {"SetValueEx", PySetValueEx, 1, SetValueEx_doc}, NULL, }; --- 1383,1403 ---- static struct PyMethodDef winreg_methods[] = { ! {"CloseKey", PyCloseKey, METH_VARARGS, CloseKey_doc}, ! {"ConnectRegistry", PyConnectRegistry, METH_VARARGS, ConnectRegistry_doc}, ! {"CreateKey", PyCreateKey, METH_VARARGS, CreateKey_doc}, ! {"DeleteKey", PyDeleteKey, METH_VARARGS, DeleteKey_doc}, ! {"DeleteValue", PyDeleteValue, METH_VARARGS, DeleteValue_doc}, ! {"EnumKey", PyEnumKey, METH_VARARGS, EnumKey_doc}, ! {"EnumValue", PyEnumValue, METH_VARARGS, EnumValue_doc}, ! {"FlushKey", PyFlushKey, METH_VARARGS, FlushKey_doc}, ! {"LoadKey", PyLoadKey, METH_VARARGS, LoadKey_doc}, ! {"OpenKey", PyOpenKey, METH_VARARGS, OpenKey_doc}, ! {"OpenKeyEx", PyOpenKey, METH_VARARGS, OpenKeyEx_doc}, ! {"QueryValue", PyQueryValue, METH_VARARGS, QueryValue_doc}, ! {"QueryValueEx", PyQueryValueEx, METH_VARARGS, QueryValueEx_doc}, ! {"QueryInfoKey", PyQueryInfoKey, METH_VARARGS, QueryInfoKey_doc}, ! {"SaveKey", PySaveKey, METH_VARARGS, SaveKey_doc}, ! {"SetValue", PySetValue, METH_VARARGS, SetValue_doc}, ! {"SetValueEx", PySetValueEx, METH_VARARGS, SetValueEx_doc}, NULL, }; Index: msvcrtmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/msvcrtmodule.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** msvcrtmodule.c 29 Aug 2001 21:37:09 -0000 1.7 --- msvcrtmodule.c 31 Mar 2002 14:37:44 -0000 1.8 *************** *** 205,218 **** /* List of functions exported by this module */ static struct PyMethodDef msvcrt_functions[] = { ! {"heapmin", msvcrt_heapmin, 1}, ! {"locking", msvcrt_locking, 1}, ! {"setmode", msvcrt_setmode, 1}, ! {"open_osfhandle", msvcrt_open_osfhandle, 1}, ! {"get_osfhandle", msvcrt_get_osfhandle, 1}, ! {"kbhit", msvcrt_kbhit, 1}, ! {"getch", msvcrt_getch, 1}, ! {"getche", msvcrt_getche, 1}, ! {"putch", msvcrt_putch, 1}, ! {"ungetch", msvcrt_ungetch, 1}, {NULL, NULL} }; --- 205,218 ---- /* List of functions exported by this module */ static struct PyMethodDef msvcrt_functions[] = { ! {"heapmin", msvcrt_heapmin, METH_VARARGS}, ! {"locking", msvcrt_locking, METH_VARARGS}, ! {"setmode", msvcrt_setmode, METH_VARARGS}, ! {"open_osfhandle", msvcrt_open_osfhandle, METH_VARARGS}, ! {"get_osfhandle", msvcrt_get_osfhandle, METH_VARARGS}, ! {"kbhit", msvcrt_kbhit, METH_VARARGS}, ! {"getch", msvcrt_getch, METH_VARARGS}, ! {"getche", msvcrt_getche, METH_VARARGS}, ! {"putch", msvcrt_putch, METH_VARARGS}, ! {"ungetch", msvcrt_ungetch, METH_VARARGS}, {NULL, NULL} }; Index: winsound.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/winsound.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** winsound.c 20 Feb 2001 10:02:21 -0000 1.8 --- winsound.c 31 Mar 2002 14:37:44 -0000 1.9 *************** *** 176,181 **** static struct PyMethodDef sound_methods[] = { ! {"PlaySound", sound_playsound, 1, sound_playsound_doc}, ! {"Beep", sound_beep, 1, sound_beep_doc}, {NULL, NULL} }; --- 176,181 ---- static struct PyMethodDef sound_methods[] = { ! {"PlaySound", sound_playsound, METH_VARARGS, sound_playsound_doc}, ! {"Beep", sound_beep, METH_VARARGS, sound_beep_doc}, {NULL, NULL} }; From nnorwitz@users.sourceforge.net Sun Mar 31 14:44:25 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 31 Mar 2002 06:44:25 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.77,2.78 _tkinter.c,1.123,1.124 cPickle.c,2.75,2.76 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv12872 Modified Files: _sre.c _tkinter.c cPickle.c Log Message: Use symbolic METH_VARARGS/METH_OLDARGS instead of 1/0 for ml_flags Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.77 retrieving revision 2.78 diff -C2 -d -r2.77 -r2.78 *** _sre.c 9 Dec 2001 16:13:15 -0000 2.77 --- _sre.c 31 Mar 2002 14:44:22 -0000 2.78 *************** *** 2939,2944 **** static PyMethodDef scanner_methods[] = { ! {"match", (PyCFunction) scanner_match, 0}, ! {"search", (PyCFunction) scanner_search, 0}, {NULL, NULL} }; --- 2939,2944 ---- static PyMethodDef scanner_methods[] = { ! {"match", (PyCFunction) scanner_match, METH_OLDARGS}, ! {"search", (PyCFunction) scanner_search, METH_OLDARGS}, {NULL, NULL} }; *************** *** 2975,2981 **** static PyMethodDef _functions[] = { ! {"compile", _compile, 1}, ! {"getcodesize", sre_codesize, 1}, ! {"getlower", sre_getlower, 1}, {NULL, NULL} }; --- 2975,2981 ---- static PyMethodDef _functions[] = { ! {"compile", _compile, METH_VARARGS}, ! {"getcodesize", sre_codesize, METH_VARARGS}, ! {"getlower", sre_getlower, METH_VARARGS}, {NULL, NULL} }; Index: _tkinter.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.123 retrieving revision 1.124 diff -C2 -d -r1.123 -r1.124 *** _tkinter.c 26 Jan 2002 20:21:50 -0000 1.123 --- _tkinter.c 31 Mar 2002 14:44:22 -0000 1.124 *************** *** 1547,1551 **** static PyMethodDef Tktt_methods[] = { ! {"deletetimerhandler", Tktt_DeleteTimerHandler, 1}, {NULL, NULL} }; --- 1547,1551 ---- static PyMethodDef Tktt_methods[] = { ! {"deletetimerhandler", Tktt_DeleteTimerHandler, METH_VARARGS}, {NULL, NULL} }; Index: cPickle.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cPickle.c,v retrieving revision 2.75 retrieving revision 2.76 diff -C2 -d -r2.75 -r2.76 *** cPickle.c 22 Mar 2002 23:02:53 -0000 2.75 --- cPickle.c 31 Mar 2002 14:44:22 -0000 2.76 *************** *** 2260,2270 **** static struct PyMethodDef Pickler_methods[] = { ! {"dump", (PyCFunction)Pickler_dump, 1, "dump(object) --" "Write an object in pickle format to the object's pickle stream\n" }, ! {"clear_memo", (PyCFunction)Pickle_clear_memo, 1, "clear_memo() -- Clear the picklers memo"}, ! {"getvalue", (PyCFunction)Pickle_getvalue, 1, "getvalue() -- Finish picking a list-based pickle"}, {NULL, NULL} /* sentinel */ --- 2260,2270 ---- static struct PyMethodDef Pickler_methods[] = { ! {"dump", (PyCFunction)Pickler_dump, METH_VARARGS, "dump(object) --" "Write an object in pickle format to the object's pickle stream\n" }, ! {"clear_memo", (PyCFunction)Pickle_clear_memo, METH_VARARGS, "clear_memo() -- Clear the picklers memo"}, ! {"getvalue", (PyCFunction)Pickle_getvalue, METH_VARARGS, "getvalue() -- Finish picking a list-based pickle"}, {NULL, NULL} /* sentinel */ *************** *** 4180,4187 **** static struct PyMethodDef Unpickler_methods[] = { ! {"load", (PyCFunction)Unpickler_load, 1, "load() -- Load a pickle" }, ! {"noload", (PyCFunction)Unpickler_noload, 1, "noload() -- not load a pickle, but go through most of the motions\n" "\n" --- 4180,4187 ---- static struct PyMethodDef Unpickler_methods[] = { ! {"load", (PyCFunction)Unpickler_load, METH_VARARGS, "load() -- Load a pickle" }, ! {"noload", (PyCFunction)Unpickler_noload, METH_VARARGS, "noload() -- not load a pickle, but go through most of the motions\n" "\n" *************** *** 4514,4518 **** static struct PyMethodDef cPickle_methods[] = { ! {"dump", (PyCFunction)cpm_dump, 1, "dump(object, file, [binary]) --" "Write an object in pickle format to the given file\n" --- 4514,4518 ---- static struct PyMethodDef cPickle_methods[] = { ! {"dump", (PyCFunction)cpm_dump, METH_VARARGS, "dump(object, file, [binary]) --" "Write an object in pickle format to the given file\n" *************** *** 4522,4526 **** "computationally efficient. \n" }, ! {"dumps", (PyCFunction)cpm_dumps, 1, "dumps(object, [binary]) --" "Return a string containing an object in pickle format\n" --- 4522,4526 ---- "computationally efficient. \n" }, ! {"dumps", (PyCFunction)cpm_dumps, METH_VARARGS, "dumps(object, [binary]) --" "Return a string containing an object in pickle format\n" *************** *** 4530,4538 **** "computationally efficient. \n" }, ! {"load", (PyCFunction)cpm_load, 1, "load(file) -- Load a pickle from the given file"}, ! {"loads", (PyCFunction)cpm_loads, 1, "loads(string) -- Load a pickle from the given string"}, ! {"Pickler", (PyCFunction)get_Pickler, 1, "Pickler(file, [binary]) -- Create a pickler\n" "\n" --- 4530,4538 ---- "computationally efficient. \n" }, ! {"load", (PyCFunction)cpm_load, METH_VARARGS, "load(file) -- Load a pickle from the given file"}, ! {"loads", (PyCFunction)cpm_loads, METH_VARARGS, "loads(string) -- Load a pickle from the given string"}, ! {"Pickler", (PyCFunction)get_Pickler, METH_VARARGS, "Pickler(file, [binary]) -- Create a pickler\n" "\n" *************** *** 4541,4545 **** "computationally efficient. \n" }, ! {"Unpickler", (PyCFunction)get_Unpickler, 1, "Unpickler(file) -- Create an unpickler"}, { NULL, NULL } --- 4541,4545 ---- "computationally efficient. \n" }, ! {"Unpickler", (PyCFunction)get_Unpickler, METH_VARARGS, "Unpickler(file) -- Create an unpickler"}, { NULL, NULL } From nnorwitz@users.sourceforge.net Sun Mar 31 14:55:19 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 31 Mar 2002 06:55:19 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _curses_panel.c,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv18253 Modified Files: _curses_panel.c Log Message: Fix whitespace Index: _curses_panel.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_curses_panel.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** _curses_panel.c 25 Mar 2002 20:46:45 -0000 1.11 --- _curses_panel.c 31 Mar 2002 14:55:17 -0000 1.12 *************** *** 314,319 **** {"hide", (PyCFunction)PyCursesPanel_hide_panel, METH_NOARGS}, {"move", (PyCFunction)PyCursesPanel_move_panel, METH_VARARGS}, ! {"replace", (PyCFunction)PyCursesPanel_replace_panel, ! METH_VARARGS}, {"set_userptr", (PyCFunction)PyCursesPanel_set_panel_userptr, METH_O}, {"show", (PyCFunction)PyCursesPanel_show_panel, METH_NOARGS}, --- 314,318 ---- {"hide", (PyCFunction)PyCursesPanel_hide_panel, METH_NOARGS}, {"move", (PyCFunction)PyCursesPanel_move_panel, METH_VARARGS}, ! {"replace", (PyCFunction)PyCursesPanel_replace_panel, METH_VARARGS}, {"set_userptr", (PyCFunction)PyCursesPanel_set_panel_userptr, METH_O}, {"show", (PyCFunction)PyCursesPanel_show_panel, METH_NOARGS}, From nnorwitz@users.sourceforge.net Sun Mar 31 14:57:26 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 31 Mar 2002 06:57:26 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules timingmodule.c,2.9,2.10 fmmodule.c,1.19,1.20 clmodule.c,2.26,2.27 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv18584 Modified Files: timingmodule.c fmmodule.c clmodule.c Log Message: Convert from using METH_OLDARGS to METH_NOARGS. These should be safe. Index: timingmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/timingmodule.c,v retrieving revision 2.9 retrieving revision 2.10 diff -C2 -d -r2.9 -r2.10 *** timingmodule.c 17 Jan 2002 23:15:58 -0000 2.9 --- timingmodule.c 31 Mar 2002 14:57:24 -0000 2.10 *************** *** 9,17 **** static PyObject * ! start_timing(PyObject *self, PyObject *args) { - if (!PyArg_Parse(args, "")) - return NULL; - Py_INCREF(Py_None); BEGINTIMING; --- 9,14 ---- static PyObject * ! start_timing(PyObject *self) { Py_INCREF(Py_None); BEGINTIMING; *************** *** 20,28 **** static PyObject * ! finish_timing(PyObject *self, PyObject *args) { - if (!PyArg_Parse(args, "")) - return NULL; - ENDTIMING Py_INCREF(Py_None); --- 17,22 ---- static PyObject * ! finish_timing(PyObject *self) { ENDTIMING Py_INCREF(Py_None); *************** *** 31,69 **** static PyObject * ! seconds(PyObject *self, PyObject *args) { - if (!PyArg_Parse(args, "")) - return NULL; - return PyInt_FromLong(TIMINGS); - } static PyObject * ! milli(PyObject *self, PyObject *args) { - if (!PyArg_Parse(args, "")) - return NULL; - return PyInt_FromLong(TIMINGMS); - } static PyObject * ! micro(PyObject *self, PyObject *args) { - if (!PyArg_Parse(args, "")) - return NULL; - return PyInt_FromLong(TIMINGUS); - } static PyMethodDef timing_methods[] = { ! {"start", start_timing, METH_OLDARGS}, ! {"finish", finish_timing, METH_OLDARGS}, ! {"seconds", seconds, METH_OLDARGS}, ! {"milli", milli, METH_OLDARGS}, ! {"micro", micro, METH_OLDARGS}, {NULL, NULL} }; --- 25,52 ---- static PyObject * ! seconds(PyObject *self) { return PyInt_FromLong(TIMINGS); } static PyObject * ! milli(PyObject *self) { return PyInt_FromLong(TIMINGMS); } + static PyObject * ! micro(PyObject *self) { return PyInt_FromLong(TIMINGUS); } static PyMethodDef timing_methods[] = { ! {"start", (PyCFunction)start_timing, METH_NOARGS}, ! {"finish", (PyCFunction)finish_timing, METH_NOARGS}, ! {"seconds", (PyCFunction)seconds, METH_NOARGS}, ! {"milli", (PyCFunction)milli, METH_NOARGS}, ! {"micro", (PyCFunction)micro, METH_NOARGS}, {NULL, NULL} }; Index: fmmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/fmmodule.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** fmmodule.c 17 Jan 2002 23:15:58 -0000 1.19 --- fmmodule.c 31 Mar 2002 14:57:24 -0000 1.20 *************** *** 50,57 **** static PyObject * ! fh_setfont(fhobject *self, PyObject *args) { - if (!PyArg_NoArgs(args)) - return NULL; fmsetfont(self->fh_fh); Py_INCREF(Py_None); --- 50,55 ---- static PyObject * ! fh_setfont(fhobject *self) { fmsetfont(self->fh_fh); Py_INCREF(Py_None); *************** *** 60,69 **** static PyObject * ! fh_getfontname(fhobject *self, PyObject *args) { char fontname[256]; int len; - if (!PyArg_NoArgs(args)) - return NULL; len = fmgetfontname(self->fh_fh, sizeof fontname, fontname); if (len < 0) { --- 58,65 ---- static PyObject * ! fh_getfontname(fhobject *self) { char fontname[256]; int len; len = fmgetfontname(self->fh_fh, sizeof fontname, fontname); if (len < 0) { *************** *** 75,84 **** static PyObject * ! fh_getcomment(fhobject *self, PyObject *args) { char comment[256]; int len; - if (!PyArg_NoArgs(args)) - return NULL; len = fmgetcomment(self->fh_fh, sizeof comment, comment); if (len < 0) { --- 71,78 ---- static PyObject * ! fh_getcomment(fhobject *self) { char comment[256]; int len; len = fmgetcomment(self->fh_fh, sizeof comment, comment); if (len < 0) { *************** *** 90,98 **** static PyObject * ! fh_getfontinfo(fhobject *self, PyObject *args) { fmfontinfo info; - if (!PyArg_NoArgs(args)) - return NULL; if (fmgetfontinfo(self->fh_fh, &info) < 0) { PyErr_SetString(PyExc_RuntimeError, "error in fmgetfontinfo"); --- 84,90 ---- static PyObject * ! fh_getfontinfo(fhobject *self) { fmfontinfo info; if (fmgetfontinfo(self->fh_fh, &info) < 0) { PyErr_SetString(PyExc_RuntimeError, "error in fmgetfontinfo"); *************** *** 127,135 **** static PyMethodDef fh_methods[] = { ! {"scalefont", (PyCFunction)fh_scalefont, METH_OLDARGS}, ! {"setfont", (PyCFunction)fh_setfont, METH_OLDARGS}, ! {"getfontname", (PyCFunction)fh_getfontname, METH_OLDARGS}, ! {"getcomment", (PyCFunction)fh_getcomment, METH_OLDARGS}, ! {"getfontinfo", (PyCFunction)fh_getfontinfo, METH_OLDARGS}, #if 0 {"getwholemetrics", (PyCFunction)fh_getwholemetrics, METH_OLDARGS}, --- 119,127 ---- static PyMethodDef fh_methods[] = { ! {"scalefont", (PyCFunction)fh_scalefont, METH_OLDARGS}, ! {"setfont", (PyCFunction)fh_setfont, METH_NOARGS}, ! {"getfontname", (PyCFunction)fh_getfontname, METH_NOARGS}, ! {"getcomment", (PyCFunction)fh_getcomment, METH_NOARGS}, ! {"getfontinfo", (PyCFunction)fh_getfontinfo, METH_NOARGS}, #if 0 {"getwholemetrics", (PyCFunction)fh_getwholemetrics, METH_OLDARGS}, *************** *** 171,178 **** static PyObject * ! fm_init(PyObject *self, PyObject *args) { - if (!PyArg_NoArgs(args)) - return NULL; fminit(); Py_INCREF(Py_None); --- 163,168 ---- static PyObject * ! fm_init(PyObject *self) { fminit(); Py_INCREF(Py_None); *************** *** 225,233 **** static PyObject * ! fm_enumerate(PyObject *self, PyObject *args) { PyObject *res; - if (!PyArg_NoArgs(args)) - return NULL; fontlist = PyList_New(0); if (fontlist == NULL) --- 215,221 ---- static PyObject * ! fm_enumerate(PyObject *self) { PyObject *res; fontlist = PyList_New(0); if (fontlist == NULL) *************** *** 251,268 **** static PyObject * ! fm_fontpath(PyObject *self, PyObject *args) { - if (!PyArg_NoArgs(args)) - return NULL; return PyString_FromString(fmfontpath()); } static PyMethodDef fm_methods[] = { ! {"init", fm_init, METH_OLDARGS}, ! {"findfont", fm_findfont, METH_OLDARGS}, ! {"enumerate", fm_enumerate, METH_OLDARGS}, ! {"prstr", fm_prstr, METH_OLDARGS}, ! {"setpath", fm_setpath, METH_OLDARGS}, ! {"fontpath", fm_fontpath, METH_OLDARGS}, {NULL, NULL} /* sentinel */ }; --- 239,254 ---- static PyObject * ! fm_fontpath(PyObject *self) { return PyString_FromString(fmfontpath()); } static PyMethodDef fm_methods[] = { ! {"init", fm_init, METH_NOARGS}, ! {"findfont", fm_findfont, METH_OLDARGS}, ! {"enumerate", fm_enumerate, METH_NOARGS}, ! {"prstr", fm_prstr, METH_OLDARGS}, ! {"setpath", fm_setpath, METH_OLDARGS}, ! {"fontpath", fm_fontpath, METH_NOARGS}, {NULL, NULL} /* sentinel */ }; Index: clmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/clmodule.c,v retrieving revision 2.26 retrieving revision 2.27 diff -C2 -d -r2.26 -r2.27 *** clmodule.c 17 Jan 2002 23:15:58 -0000 2.26 --- clmodule.c 31 Mar 2002 14:57:24 -0000 2.27 *************** *** 184,194 **** static PyObject * ! doClose(clobject *self, PyObject *args, int (*close_func)(CL_Handle)) { CheckCompressor(self); - if (!PyArg_NoArgs(args)) - return NULL; - error_handler_called = 0; if ((*close_func)(self->ob_compressorHdl) == FAILURE || --- 184,191 ---- static PyObject * ! doClose(clobject *self, int (*close_func)(CL_Handle)) { CheckCompressor(self); error_handler_called = 0; if ((*close_func)(self->ob_compressorHdl) == FAILURE || *************** *** 210,222 **** static PyObject * ! clm_CloseCompressor(PyObject *self, PyObject *args) { ! return doClose(SELF, args, clCloseCompressor); } static PyObject * ! clm_CloseDecompressor(PyObject *self, PyObject *args) { ! return doClose(SELF, args, clCloseDecompressor); } --- 207,219 ---- static PyObject * ! clm_CloseCompressor(PyObject *self) { ! return doClose(SELF, clCloseCompressor); } static PyObject * ! clm_CloseDecompressor(PyObject *self) { ! return doClose(SELF, clCloseDecompressor); } *************** *** 480,484 **** static PyObject * ! clm_QueryParams(PyObject *self, PyObject *args) { int bufferlength; --- 477,481 ---- static PyObject * ! clm_QueryParams(PyObject *self) { int bufferlength; *************** *** 489,495 **** CheckCompressor(SELF); - if (!PyArg_NoArgs(args)) - return NULL; - error_handler_called = 0; bufferlength = clQueryParams(SELF->ob_compressorHdl, 0, 0); --- 486,489 ---- *************** *** 575,585 **** static PyObject * ! clm_QuerySchemeFromHandle(PyObject *self, PyObject *args) { CheckCompressor(SELF); - - if (!PyArg_NoArgs(args)) - return NULL; - return PyInt_FromLong(clQuerySchemeFromHandle(SELF->ob_compressorHdl)); } --- 569,575 ---- static PyObject * ! clm_QuerySchemeFromHandle(PyObject *self) { CheckCompressor(SELF); return PyInt_FromLong(clQuerySchemeFromHandle(SELF->ob_compressorHdl)); } *************** *** 601,606 **** static PyMethodDef compressor_methods[] = { ! {"close", clm_CloseCompressor, METH_OLDARGS}, /* alias */ ! {"CloseCompressor", clm_CloseCompressor, METH_OLDARGS}, {"Compress", clm_Compress, METH_OLDARGS}, {"GetDefault", clm_GetDefault, METH_OLDARGS}, --- 591,596 ---- static PyMethodDef compressor_methods[] = { ! {"close", clm_CloseCompressor, METH_NOARGS}, /* alias */ ! {"CloseCompressor", clm_CloseCompressor, METH_NOARGS}, {"Compress", clm_Compress, METH_OLDARGS}, {"GetDefault", clm_GetDefault, METH_OLDARGS}, *************** *** 610,615 **** {"GetParamID", clm_GetParamID, METH_OLDARGS}, {"GetParams", clm_GetParams, METH_OLDARGS}, ! {"QueryParams", clm_QueryParams, METH_OLDARGS}, ! {"QuerySchemeFromHandle",clm_QuerySchemeFromHandle, METH_OLDARGS}, {"SetParam", clm_SetParam, METH_OLDARGS}, {"SetParams", clm_SetParams, METH_OLDARGS}, --- 600,605 ---- {"GetParamID", clm_GetParamID, METH_OLDARGS}, {"GetParams", clm_GetParams, METH_OLDARGS}, ! {"QueryParams", clm_QueryParams, METH_NOARGS}, ! {"QuerySchemeFromHandle",clm_QuerySchemeFromHandle, METH_NOARGS}, {"SetParam", clm_SetParam, METH_OLDARGS}, {"SetParams", clm_SetParams, METH_OLDARGS}, *************** *** 618,623 **** static PyMethodDef decompressor_methods[] = { ! {"close", clm_CloseDecompressor, METH_OLDARGS}, /* alias */ ! {"CloseDecompressor", clm_CloseDecompressor, METH_OLDARGS}, {"Decompress", clm_Decompress, METH_OLDARGS}, {"GetDefault", clm_GetDefault, METH_OLDARGS}, --- 608,613 ---- static PyMethodDef decompressor_methods[] = { ! {"close", clm_CloseDecompressor, METH_NOARGS}, /* alias */ ! {"CloseDecompressor", clm_CloseDecompressor, METH_NOARGS}, {"Decompress", clm_Decompress, METH_OLDARGS}, {"GetDefault", clm_GetDefault, METH_OLDARGS}, *************** *** 628,633 **** {"GetParams", clm_GetParams, METH_OLDARGS}, {"ReadHeader", clm_ReadHeader, METH_OLDARGS}, ! {"QueryParams", clm_QueryParams, METH_OLDARGS}, ! {"QuerySchemeFromHandle",clm_QuerySchemeFromHandle, METH_OLDARGS}, {"SetParam", clm_SetParam, METH_OLDARGS}, {"SetParams", clm_SetParams, METH_OLDARGS}, --- 618,623 ---- {"GetParams", clm_GetParams, METH_OLDARGS}, {"ReadHeader", clm_ReadHeader, METH_OLDARGS}, ! {"QueryParams", clm_QueryParams, METH_NOARGS}, ! {"QuerySchemeFromHandle",clm_QuerySchemeFromHandle, METH_NOARGS}, {"SetParam", clm_SetParam, METH_OLDARGS}, {"SetParams", clm_SetParams, METH_OLDARGS}, From guido@python.org Sun Mar 31 15:27:27 2002 From: guido@python.org (Guido van Rossum) Date: Sun, 31 Mar 2002 10:27:27 -0500 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.77,2.78 _tkinter.c,1.123,1.124 cPickle.c,2.75,2.76 In-Reply-To: Your message of "Sun, 31 Mar 2002 06:44:25 PST." References: Message-ID: <200203311527.g2VFRRK23350@pcp742651pcs.reston01.va.comcast.net> > Modified Files: > _sre.c _tkinter.c cPickle.c > Log Message: > Use symbolic METH_VARARGS/METH_OLDARGS instead of 1/0 for ml_flags I hope for you that those symbols also exist in Python 1.5.2, otherwise /F will revert your changes to _sre.c right away! :-) --Guido van Rossum (home page: http://www.python.org/~guido/) From nnorwitz@users.sourceforge.net Sun Mar 31 15:27:02 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 31 Mar 2002 07:27:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules cryptmodule.c,2.10,2.11 md5module.c,2.28,2.29 mpzmodule.c,2.40,2.41 nismodule.c,2.22,2.23 pwdmodule.c,1.30,1.31 regexmodule.c,1.46,1.47 rgbimgmodule.c,2.24,2.25 rotormodule.c,2.32,2.33 signalmodule.c,2.65,2.66 sunaudiodev.c,1.28,1.29 threadmodule.c,2.47,2.48 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv26238 Modified Files: cryptmodule.c md5module.c mpzmodule.c nismodule.c pwdmodule.c regexmodule.c rgbimgmodule.c rotormodule.c signalmodule.c sunaudiodev.c threadmodule.c Log Message: Remove METH_OLDARGS: Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple Convert METH_OLDARGS -> METH_NOARGS: remove args parameter Please review. All tests pass, but some modules don't have tests. I spot checked various functions to try to make sure nothing broke. Index: cryptmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cryptmodule.c,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -d -r2.10 -r2.11 *** cryptmodule.c 3 Aug 2000 02:34:44 -0000 2.10 --- cryptmodule.c 31 Mar 2002 15:27:00 -0000 2.11 *************** *** 15,19 **** extern char * crypt(const char *, const char *); ! if (!PyArg_Parse(args, "(ss)", &word, &salt)) { return NULL; } --- 15,19 ---- extern char * crypt(const char *, const char *); ! if (!PyArg_ParseTuple(args, "ss:crypt", &word, &salt)) { return NULL; } *************** *** 32,36 **** static PyMethodDef crypt_methods[] = { ! {"crypt", crypt_crypt, METH_OLDARGS, crypt_crypt__doc__}, {NULL, NULL} /* sentinel */ }; --- 32,36 ---- static PyMethodDef crypt_methods[] = { ! {"crypt", crypt_crypt, METH_VARARGS, crypt_crypt__doc__}, {NULL, NULL} /* sentinel */ }; Index: md5module.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/md5module.c,v retrieving revision 2.28 retrieving revision 2.29 diff -C2 -d -r2.28 -r2.29 *** md5module.c 25 Mar 2002 20:46:46 -0000 2.28 --- md5module.c 31 Mar 2002 15:27:00 -0000 2.29 *************** *** 53,57 **** int len; ! if (!PyArg_Parse(args, "s#", &cp, &len)) return NULL; --- 53,57 ---- int len; ! if (!PyArg_ParseTuple(args, "s#:update", &cp, &len)) return NULL; *************** *** 143,147 **** static PyMethodDef md5_methods[] = { ! {"update", (PyCFunction)md5_update, METH_OLDARGS, update_doc}, {"digest", (PyCFunction)md5_digest, METH_NOARGS, digest_doc}, {"hexdigest", (PyCFunction)md5_hexdigest, METH_NOARGS, hexdigest_doc}, --- 143,147 ---- static PyMethodDef md5_methods[] = { ! {"update", (PyCFunction)md5_update, METH_VARARGS, update_doc}, {"digest", (PyCFunction)md5_digest, METH_NOARGS, digest_doc}, {"hexdigest", (PyCFunction)md5_hexdigest, METH_NOARGS, hexdigest_doc}, Index: mpzmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mpzmodule.c,v retrieving revision 2.40 retrieving revision 2.41 diff -C2 -d -r2.40 -r2.41 *** mpzmodule.c 1 Mar 2002 21:30:55 -0000 2.40 --- mpzmodule.c 31 Mar 2002 15:27:00 -0000 2.41 *************** *** 1243,1263 **** - /* MPZ methods-as-attributes */ - #ifdef MPZ_CONVERSIONS_AS_METHODS - static PyObject * - mpz_int(mpzobject *self, PyObject *args) - #else /* def MPZ_CONVERSIONS_AS_METHODS */ static PyObject * mpz_int(mpzobject *self) - #endif /* def MPZ_CONVERSIONS_AS_METHODS else */ { long sli; - #ifdef MPZ_CONVERSIONS_AS_METHODS - if (!PyArg_NoArgs(args)) - return NULL; - #endif /* def MPZ_CONVERSIONS_AS_METHODS */ - if (mpz_size(&self->mpz) > 1 || (sli = (long)mpz_get_ui(&self->mpz)) < (long)0 ) { --- 1243,1252 ---- *************** *** 1274,1282 **** static PyObject * - #ifdef MPZ_CONVERSIONS_AS_METHODS - mpz_long(mpzobject *self, PyObject *args) - #else /* def MPZ_CONVERSIONS_AS_METHODS */ mpz_long(mpzobject *self) - #endif /* def MPZ_CONVERSIONS_AS_METHODS else */ { int i, isnegative; --- 1263,1267 ---- *************** *** 1288,1296 **** - #ifdef MPZ_CONVERSIONS_AS_METHODS - if (!PyArg_NoArgs(args)) - return NULL; - #endif /* def MPZ_CONVERSIONS_AS_METHODS */ - /* determine length of python-long to be allocated */ if ((longobjp = _PyLong_New(i = (int) --- 1273,1276 ---- *************** *** 1353,1363 **** static const double multiplier = 256.0 * 256.0 * 256.0 * 256.0; - #ifdef MPZ_CONVERSIONS_AS_METHODS - static PyObject * - mpz_float(mpzobject *self, PyObject *args) - #else /* def MPZ_CONVERSIONS_AS_METHODS */ static PyObject * mpz_float(mpzobject *self) - #endif /* def MPZ_CONVERSIONS_AS_METHODS else */ { int i, isnegative; --- 1333,1338 ---- *************** *** 1367,1375 **** - #ifdef MPZ_CONVERSIONS_AS_METHODS - if (!PyArg_NoArgs(args)) - return NULL; - #endif /* def MPZ_CONVERSIONS_AS_METHODS */ - i = (int)mpz_size(&self->mpz); --- 1342,1345 ---- *************** *** 1407,1444 **** } /* mpz_float() */ - #ifdef MPZ_CONVERSIONS_AS_METHODS - static PyObject * - mpz_hex(mpzobject *self, PyObject *args) - #else /* def MPZ_CONVERSIONS_AS_METHODS */ static PyObject * mpz_hex(mpzobject *self) - #endif /* def MPZ_CONVERSIONS_AS_METHODS else */ { - #ifdef MPZ_CONVERSIONS_AS_METHODS - if (!PyArg_NoArgs(args)) - return NULL; - #endif /* def MPZ_CONVERSIONS_AS_METHODS */ - return mpz_format((PyObject *)self, 16, (unsigned char)1); } /* mpz_hex() */ - #ifdef MPZ_CONVERSIONS_AS_METHODS - static PyObject * - mpz_oct(mpzobject *self, PyObject *args) - #else /* def MPZ_CONVERSIONS_AS_METHODS */ static PyObject * mpz_oct(mpzobject *self) - #endif /* def MPZ_CONVERSIONS_AS_METHODS else */ { - #ifdef MPZ_CONVERSIONS_AS_METHODS - if (!PyArg_NoArgs(args)) - return NULL; - #endif /* def MPZ_CONVERSIONS_AS_METHODS */ - return mpz_format((PyObject *)self, 8, (unsigned char)1); } /* mpz_oct() */ static PyObject * ! mpz_binary(mpzobject *self, PyObject *args) { int size; --- 1377,1394 ---- } /* mpz_float() */ static PyObject * mpz_hex(mpzobject *self) { return mpz_format((PyObject *)self, 16, (unsigned char)1); } /* mpz_hex() */ static PyObject * mpz_oct(mpzobject *self) { return mpz_format((PyObject *)self, 8, (unsigned char)1); } /* mpz_oct() */ static PyObject * ! mpz_binary(mpzobject *self) { int size; *************** *** 1448,1454 **** unsigned long ldigit; - if (!PyArg_NoArgs(args)) - return NULL; - if (mpz_cmp_ui(&self->mpz, (unsigned long int)0) < 0) { PyErr_SetString(PyExc_ValueError, --- 1398,1401 ---- *************** *** 1494,1504 **** static PyMethodDef mpz_methods[] = { #ifdef MPZ_CONVERSIONS_AS_METHODS ! {"int", mpz_int}, ! {"long", mpz_long}, ! {"float", mpz_float}, ! {"hex", mpz_hex}, ! {"oct", mpz_oct}, #endif /* def MPZ_CONVERSIONS_AS_METHODS */ ! {"binary", (PyCFunction)mpz_binary}, {NULL, NULL} /* sentinel */ }; --- 1441,1451 ---- static PyMethodDef mpz_methods[] = { #ifdef MPZ_CONVERSIONS_AS_METHODS ! {"int", mpz_int, METH_NOARGS}, ! {"long", mpz_long, METH_NOARGS}, ! {"float", mpz_float, METH_NOARGS}, ! {"hex", mpz_hex, METH_NOARGS}, ! {"oct", mpz_oct, METH_NOARGS}, #endif /* def MPZ_CONVERSIONS_AS_METHODS */ ! {"binary", (PyCFunction)mpz_binary, METH_NOARGS}, {NULL, NULL} /* sentinel */ }; Index: nismodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/nismodule.c,v retrieving revision 2.22 retrieving revision 2.23 diff -C2 -d -r2.22 -r2.23 *** nismodule.c 17 Jan 2002 23:15:58 -0000 2.22 --- nismodule.c 31 Mar 2002 15:27:00 -0000 2.23 *************** *** 121,125 **** int fix; ! if (!PyArg_Parse(args, "(t#s)", &key, &keylen, &map)) return NULL; if ((err = yp_get_default_domain(&domain)) != 0) --- 121,125 ---- int fix; ! if (!PyArg_ParseTuple(args, "t#s:match", &key, &keylen, &map)) return NULL; if ((err = yp_get_default_domain(&domain)) != 0) *************** *** 150,154 **** int err; ! if (!PyArg_Parse(args, "s", &map)) return NULL; if ((err = yp_get_default_domain(&domain)) != 0) --- 150,154 ---- int err; ! if (!PyArg_ParseTuple(args, "s:cat", &map)) return NULL; if ((err = yp_get_default_domain(&domain)) != 0) *************** *** 339,349 **** static PyObject * ! nis_maps (PyObject *self, PyObject *args) { nismaplist *maps; PyObject *list; - if (!PyArg_NoArgs(args)) - return NULL; if ((maps = nis_maplist ()) == NULL) return NULL; --- 339,347 ---- static PyObject * ! nis_maps (PyObject *self) { nismaplist *maps; PyObject *list; if ((maps = nis_maplist ()) == NULL) return NULL; *************** *** 365,371 **** static PyMethodDef nis_methods[] = { ! {"match", nis_match, METH_OLDARGS}, ! {"cat", nis_cat, METH_OLDARGS}, ! {"maps", nis_maps, METH_OLDARGS}, {NULL, NULL} /* Sentinel */ }; --- 363,369 ---- static PyMethodDef nis_methods[] = { ! {"match", nis_match, METH_VARARGS}, ! {"cat", nis_cat, METH_VARARGS}, ! {"maps", (PyCFunction)nis_maps, METH_NOARGS}, {NULL, NULL} /* Sentinel */ }; Index: pwdmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pwdmodule.c,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** pwdmodule.c 29 Mar 2002 19:58:25 -0000 1.30 --- pwdmodule.c 31 Mar 2002 15:27:00 -0000 1.31 *************** *** 85,89 **** int uid; struct passwd *p; ! if (!PyArg_Parse(args, "i", &uid)) return NULL; if ((p = getpwuid(uid)) == NULL) { --- 85,89 ---- int uid; struct passwd *p; ! if (!PyArg_ParseTuple(args, "i:getpwuid", &uid)) return NULL; if ((p = getpwuid(uid)) == NULL) { *************** *** 104,108 **** char *name; struct passwd *p; ! if (!PyArg_Parse(args, "s", &name)) return NULL; if ((p = getpwnam(name)) == NULL) { --- 104,108 ---- char *name; struct passwd *p; ! if (!PyArg_ParseTuple(args, "s:getpwnam", &name)) return NULL; if ((p = getpwnam(name)) == NULL) { *************** *** 147,152 **** static PyMethodDef pwd_methods[] = { ! {"getpwuid", pwd_getpwuid, METH_OLDARGS, pwd_getpwuid__doc__}, ! {"getpwnam", pwd_getpwnam, METH_OLDARGS, pwd_getpwnam__doc__}, #ifdef HAVE_GETPWENT {"getpwall", (PyCFunction)pwd_getpwall, --- 147,152 ---- static PyMethodDef pwd_methods[] = { ! {"getpwuid", pwd_getpwuid, METH_VARARGS, pwd_getpwuid__doc__}, ! {"getpwnam", pwd_getpwnam, METH_VARARGS, pwd_getpwnam__doc__}, #ifdef HAVE_GETPWENT {"getpwall", (PyCFunction)pwd_getpwall, Index: regexmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/regexmodule.c,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** regexmodule.c 17 Jan 2002 23:15:58 -0000 1.46 --- regexmodule.c 31 Mar 2002 15:27:00 -0000 1.47 *************** *** 584,588 **** PyObject *tuple, *v; ! if (!PyArg_Parse(args, "(SS)", &pat, &string)) return NULL; if (update_cache(pat) < 0) --- 584,588 ---- PyObject *tuple, *v; ! if (!PyArg_ParseTuple(args, "SS:match", &pat, &string)) return NULL; if (update_cache(pat) < 0) *************** *** 602,606 **** PyObject *tuple, *v; ! if (!PyArg_Parse(args, "(SS)", &pat, &string)) return NULL; if (update_cache(pat) < 0) --- 602,606 ---- PyObject *tuple, *v; ! if (!PyArg_ParseTuple(args, "SS:search", &pat, &string)) return NULL; if (update_cache(pat) < 0) *************** *** 618,622 **** { int syntax; ! if (!PyArg_Parse(args, "i", &syntax)) return NULL; syntax = re_set_syntax(syntax); --- 618,622 ---- { int syntax; ! if (!PyArg_ParseTuple(args, "i:set_syntax", &syntax)) return NULL; syntax = re_set_syntax(syntax); *************** *** 630,637 **** static PyObject * ! regex_get_syntax(PyObject *self, PyObject *args) { - if (!PyArg_Parse(args, "")) - return NULL; return PyInt_FromLong((long)re_syntax); } --- 630,635 ---- static PyObject * ! regex_get_syntax(PyObject *self) { return PyInt_FromLong((long)re_syntax); } *************** *** 641,648 **** {"compile", regex_compile, METH_VARARGS}, {"symcomp", regex_symcomp, METH_VARARGS}, ! {"match", regex_match, METH_OLDARGS}, ! {"search", regex_search, METH_OLDARGS}, ! {"set_syntax", regex_set_syntax, METH_OLDARGS}, ! {"get_syntax", regex_get_syntax, METH_OLDARGS}, {NULL, NULL} /* sentinel */ }; --- 639,646 ---- {"compile", regex_compile, METH_VARARGS}, {"symcomp", regex_symcomp, METH_VARARGS}, ! {"match", regex_match, METH_VARARGS}, ! {"search", regex_search, METH_VARARGS}, ! {"set_syntax", regex_set_syntax, METH_VARARGS}, ! {"get_syntax", (PyCFunction)regex_get_syntax, METH_NOARGS}, {NULL, NULL} /* sentinel */ }; Index: rgbimgmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/rgbimgmodule.c,v retrieving revision 2.24 retrieving revision 2.25 diff -C2 -d -r2.24 -r2.25 *** rgbimgmodule.c 17 Jan 2002 23:15:58 -0000 2.24 --- rgbimgmodule.c 31 Mar 2002 15:27:00 -0000 2.25 *************** *** 237,241 **** FILE *inf; ! if (!PyArg_Parse(args, "s", &name)) return NULL; --- 237,241 ---- FILE *inf; ! if (!PyArg_ParseTuple(args, "s:sizeofimage", &name)) return NULL; *************** *** 276,280 **** PyObject *rv = NULL; ! if (!PyArg_Parse(args, "s", &name)) return NULL; --- 276,280 ---- PyObject *rv = NULL; ! if (!PyArg_ParseTuple(args, "s:longimagedata", &name)) return NULL; *************** *** 571,576 **** PyObject *retval = NULL; ! if (!PyArg_Parse(args, "(s#iiis)", &lptr, &len, &xsize, &ysize, &zsize, ! &name)) return NULL; --- 571,576 ---- PyObject *retval = NULL; ! if (!PyArg_ParseTuple(args, "s#iiis:longstoimage", &lptr, &len, ! &xsize, &ysize, &zsize, &name)) return NULL; *************** *** 735,739 **** int order, oldorder; ! if (!PyArg_Parse(args, "i", &order)) return NULL; oldorder = reverse_order; --- 735,739 ---- int order, oldorder; ! if (!PyArg_ParseTuple(args, "i:ttob", &order)) return NULL; oldorder = reverse_order; *************** *** 744,751 **** static PyMethodDef rgbimg_methods[] = { ! {"sizeofimage", sizeofimage, METH_OLDARGS}, ! {"longimagedata", longimagedata, METH_OLDARGS}, ! {"longstoimage", longstoimage, METH_OLDARGS}, ! {"ttob", ttob, METH_OLDARGS}, {NULL, NULL} /* sentinel */ }; --- 744,751 ---- static PyMethodDef rgbimg_methods[] = { ! {"sizeofimage", sizeofimage, METH_VARARGS}, ! {"longimagedata", longimagedata, METH_VARARGS}, ! {"longstoimage", longstoimage, METH_VARARGS}, ! {"ttob", ttob, METH_VARARGS}, {NULL, NULL} /* sentinel */ }; Index: rotormodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/rotormodule.c,v retrieving revision 2.32 retrieving revision 2.33 diff -C2 -d -r2.32 -r2.33 *** rotormodule.c 17 Jan 2002 23:15:58 -0000 2.32 --- rotormodule.c 31 Mar 2002 15:27:00 -0000 2.33 *************** *** 464,468 **** char *tmp; ! if (!PyArg_Parse(args, "s#", &string, &len)) return NULL; if (!(tmp = PyMem_NEW(char, len+5))) { --- 464,468 ---- char *tmp; ! if (!PyArg_ParseTuple(args, "s#:encrypt", &string, &len)) return NULL; if (!(tmp = PyMem_NEW(char, len+5))) { *************** *** 486,490 **** char *tmp; ! if (!PyArg_Parse(args, "s#", &string, &len)) return NULL; if (!(tmp = PyMem_NEW(char, len+5))) { --- 486,490 ---- char *tmp; ! if (!PyArg_ParseTuple(args, "s#:encrypt_more", &string, &len)) return NULL; if (!(tmp = PyMem_NEW(char, len+5))) { *************** *** 508,512 **** char *tmp; ! if (!PyArg_Parse(args, "s#", &string, &len)) return NULL; if (!(tmp = PyMem_NEW(char, len+5))) { --- 508,512 ---- char *tmp; ! if (!PyArg_ParseTuple(args, "s#:decrypt", &string, &len)) return NULL; if (!(tmp = PyMem_NEW(char, len+5))) { *************** *** 530,534 **** char *tmp; ! if (!PyArg_Parse(args, "s#", &string, &len)) return NULL; if (!(tmp = PyMem_NEW(char, len+5))) { --- 530,534 ---- char *tmp; ! if (!PyArg_ParseTuple(args, "s#:decrypt_more", &string, &len)) return NULL; if (!(tmp = PyMem_NEW(char, len+5))) { *************** *** 559,566 **** static struct PyMethodDef rotorobj_methods[] = { ! {"encrypt", (PyCFunction)rotorobj_encrypt, METH_OLDARGS}, ! {"encryptmore", (PyCFunction)rotorobj_encrypt_more, METH_OLDARGS}, ! {"decrypt", (PyCFunction)rotorobj_decrypt, METH_OLDARGS}, ! {"decryptmore", (PyCFunction)rotorobj_decrypt_more, METH_OLDARGS}, {"setkey", (PyCFunction)rotorobj_setkey, METH_VARARGS}, {NULL, NULL} /* sentinel */ --- 559,566 ---- static struct PyMethodDef rotorobj_methods[] = { ! {"encrypt", (PyCFunction)rotorobj_encrypt, METH_VARARGS}, ! {"encryptmore", (PyCFunction)rotorobj_encrypt_more, METH_VARARGS}, ! {"decrypt", (PyCFunction)rotorobj_decrypt, METH_VARARGS}, ! {"decryptmore", (PyCFunction)rotorobj_decrypt_more, METH_VARARGS}, {"setkey", (PyCFunction)rotorobj_setkey, METH_VARARGS}, {NULL, NULL} /* sentinel */ *************** *** 612,616 **** static struct PyMethodDef rotor_methods[] = { ! {"newrotor", rotor_rotor, 1}, {NULL, NULL} /* sentinel */ }; --- 612,616 ---- static struct PyMethodDef rotor_methods[] = { ! {"newrotor", rotor_rotor, METH_VARARGS}, {NULL, NULL} /* sentinel */ }; Index: signalmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/signalmodule.c,v retrieving revision 2.65 retrieving revision 2.66 diff -C2 -d -r2.65 -r2.66 *** signalmodule.c 28 Mar 2002 21:04:14 -0000 2.65 --- signalmodule.c 31 Mar 2002 15:27:00 -0000 2.66 *************** *** 150,154 **** { int t; ! if (!PyArg_Parse(args, "i", &t)) return NULL; /* alarm() returns the number of seconds remaining */ --- 150,154 ---- { int t; ! if (!PyArg_ParseTuple(args, "i:alarm", &t)) return NULL; /* alarm() returns the number of seconds remaining */ *************** *** 193,197 **** PyObject *old_handler; void (*func)(int); ! if (!PyArg_Parse(args, "(iO)", &sig_num, &obj)) return NULL; #ifdef WITH_THREAD --- 193,197 ---- PyObject *old_handler; void (*func)(int); ! if (!PyArg_ParseTuple(args, "iO:signal", &sig_num, &obj)) return NULL; #ifdef WITH_THREAD *************** *** 249,253 **** int sig_num; PyObject *old_handler; ! if (!PyArg_Parse(args, "i", &sig_num)) return NULL; if (sig_num < 1 || sig_num >= NSIG) { --- 249,253 ---- int sig_num; PyObject *old_handler; ! if (!PyArg_ParseTuple(args, "i:getsignal", &sig_num)) return NULL; if (sig_num < 1 || sig_num >= NSIG) { *************** *** 275,282 **** static PyMethodDef signal_methods[] = { #ifdef HAVE_ALARM ! {"alarm", signal_alarm, METH_OLDARGS, alarm_doc}, #endif ! {"signal", signal_signal, METH_OLDARGS, signal_doc}, ! {"getsignal", signal_getsignal, METH_OLDARGS, getsignal_doc}, #ifdef HAVE_PAUSE {"pause", (PyCFunction)signal_pause, --- 275,282 ---- static PyMethodDef signal_methods[] = { #ifdef HAVE_ALARM ! {"alarm", signal_alarm, METH_VARARGS, alarm_doc}, #endif ! {"signal", signal_signal, METH_VARARGS, signal_doc}, ! {"getsignal", signal_getsignal, METH_VARARGS, getsignal_doc}, #ifdef HAVE_PAUSE {"pause", (PyCFunction)signal_pause, *************** *** 284,288 **** #endif {"default_int_handler", signal_default_int_handler, ! METH_OLDARGS, default_int_handler_doc}, {NULL, NULL} /* sentinel */ }; --- 284,288 ---- #endif {"default_int_handler", signal_default_int_handler, ! METH_VARARGS, default_int_handler_doc}, {NULL, NULL} /* sentinel */ }; Index: sunaudiodev.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sunaudiodev.c,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** sunaudiodev.c 17 Jan 2002 23:15:58 -0000 1.28 --- sunaudiodev.c 31 Mar 2002 15:27:00 -0000 1.29 *************** *** 59,63 **** /* Check arg for r/w/rw */ ! if (!PyArg_Parse(args, "s", &mode)) return NULL; if (strcmp(mode, "r") == 0) --- 59,63 ---- /* Check arg for r/w/rw */ ! if (!PyArg_ParseTuple(args, "s", &mode)) return NULL; if (strcmp(mode, "r") == 0) *************** *** 134,138 **** PyObject *rv; ! if (!PyArg_Parse(args, "i", &size)) return NULL; rv = PyString_FromStringAndSize(NULL, size); --- 134,138 ---- PyObject *rv; ! if (!PyArg_ParseTuple(args, "i:read", &size)) return NULL; rv = PyString_FromStringAndSize(NULL, size); *************** *** 170,174 **** int count, size; ! if (!PyArg_Parse(args, "s#", &cp, &size)) return NULL; --- 170,174 ---- int count, size; ! if (!PyArg_ParseTuple(args, "s#:write", &cp, &size)) return NULL; *************** *** 189,198 **** static PyObject * ! sad_getinfo(sadobject *self, PyObject *args) { sadstatusobject *rv; - if (!PyArg_Parse(args, "")) - return NULL; if (!(rv = sads_alloc())) return NULL; --- 189,196 ---- static PyObject * ! sad_getinfo(sadobject *self) { sadstatusobject *rv; if (!(rv = sads_alloc())) return NULL; *************** *** 223,232 **** static PyObject * ! sad_ibufcount(sadobject *self, PyObject *args) { audio_info_t ai; - if (!PyArg_Parse(args, "")) - return NULL; if (ioctl(self->x_fd, AUDIO_GETINFO, &ai) < 0) { PyErr_SetFromErrno(SunAudioError); --- 221,228 ---- static PyObject * ! sad_ibufcount(sadobject *self) { audio_info_t ai; if (ioctl(self->x_fd, AUDIO_GETINFO, &ai) < 0) { PyErr_SetFromErrno(SunAudioError); *************** *** 237,246 **** static PyObject * ! sad_obufcount(sadobject *self, PyObject *args) { audio_info_t ai; - if (!PyArg_Parse(args, "")) - return NULL; if (ioctl(self->x_fd, AUDIO_GETINFO, &ai) < 0) { PyErr_SetFromErrno(SunAudioError); --- 233,240 ---- static PyObject * ! sad_obufcount(sadobject *self) { audio_info_t ai; if (ioctl(self->x_fd, AUDIO_GETINFO, &ai) < 0) { PyErr_SetFromErrno(SunAudioError); *************** *** 255,263 **** static PyObject * ! sad_drain(sadobject *self, PyObject *args) { - - if (!PyArg_Parse(args, "")) - return NULL; if (ioctl(self->x_fd, AUDIO_DRAIN, 0) < 0) { PyErr_SetFromErrno(SunAudioError); --- 249,254 ---- static PyObject * ! sad_drain(sadobject *self) { if (ioctl(self->x_fd, AUDIO_DRAIN, 0) < 0) { PyErr_SetFromErrno(SunAudioError); *************** *** 270,279 **** #ifdef SOLARIS static PyObject * ! sad_getdev(sadobject *self, PyObject *args) { struct audio_device ad; - if (!PyArg_Parse(args, "")) - return NULL; if (ioctl(self->x_fd, AUDIO_GETDEV, &ad) < 0) { PyErr_SetFromErrno(SunAudioError); --- 261,268 ---- #ifdef SOLARIS static PyObject * ! sad_getdev(sadobject *self) { struct audio_device ad; if (ioctl(self->x_fd, AUDIO_GETDEV, &ad) < 0) { PyErr_SetFromErrno(SunAudioError); *************** *** 285,293 **** static PyObject * ! sad_flush(sadobject *self, PyObject *args) { - - if (!PyArg_Parse(args, "")) - return NULL; if (ioctl(self->x_fd, I_FLUSH, FLUSHW) < 0) { PyErr_SetFromErrno(SunAudioError); --- 274,279 ---- static PyObject * ! sad_flush(sadobject *self) { if (ioctl(self->x_fd, I_FLUSH, FLUSHW) < 0) { PyErr_SetFromErrno(SunAudioError); *************** *** 299,307 **** static PyObject * ! sad_close(sadobject *self, PyObject *args) { - if (!PyArg_Parse(args, "")) - return NULL; if (self->x_fd >= 0) { close(self->x_fd); --- 285,291 ---- static PyObject * ! sad_close(sadobject *self) { if (self->x_fd >= 0) { close(self->x_fd); *************** *** 313,321 **** static PyObject * ! sad_fileno(sadobject *self, PyObject *args) { - if (!PyArg_Parse(args, "")) - return NULL; - return PyInt_FromLong(self->x_fd); } --- 297,302 ---- static PyObject * ! sad_fileno(sadobject *self) { return PyInt_FromLong(self->x_fd); } *************** *** 323,340 **** static PyMethodDef sad_methods[] = { ! { "read", (PyCFunction)sad_read, METH_OLDARGS }, ! { "write", (PyCFunction)sad_write, METH_OLDARGS }, ! { "ibufcount", (PyCFunction)sad_ibufcount, METH_OLDARGS }, ! { "obufcount", (PyCFunction)sad_obufcount, METH_OLDARGS }, #define CTL_METHODS 4 ! { "getinfo", (PyCFunction)sad_getinfo, METH_OLDARGS }, ! { "setinfo", (PyCFunction)sad_setinfo, METH_OLDARGS }, ! { "drain", (PyCFunction)sad_drain, METH_OLDARGS }, ! { "flush", (PyCFunction)sad_flush, METH_OLDARGS }, #ifdef SOLARIS ! { "getdev", (PyCFunction)sad_getdev, METH_OLDARGS }, #endif ! { "close", (PyCFunction)sad_close, METH_OLDARGS }, ! { "fileno", (PyCFunction)sad_fileno, METH_OLDARGS }, {NULL, NULL} /* sentinel */ }; --- 304,321 ---- static PyMethodDef sad_methods[] = { ! { "read", (PyCFunction)sad_read, METH_VARARGS }, ! { "write", (PyCFunction)sad_write, METH_VARARGS }, ! { "ibufcount", (PyCFunction)sad_ibufcount, METH_NOARGS }, ! { "obufcount", (PyCFunction)sad_obufcount, METH_NOARGS }, #define CTL_METHODS 4 ! { "getinfo", (PyCFunction)sad_getinfo, METH_NOARGS }, ! { "setinfo", (PyCFunction)sad_setinfo, METH_O}, ! { "drain", (PyCFunction)sad_drain, METH_NOARGS }, ! { "flush", (PyCFunction)sad_flush, METH_NOARGS }, #ifdef SOLARIS ! { "getdev", (PyCFunction)sad_getdev, METH_NOARGS }, #endif ! { "close", (PyCFunction)sad_close, METH_NOARGS }, ! { "fileno", (PyCFunction)sad_fileno, METH_NOARGS }, {NULL, NULL} /* sentinel */ }; *************** *** 466,470 **** static PyMethodDef sunaudiodev_methods[] = { ! { "open", sadopen, METH_OLDARGS }, { 0, 0 }, }; --- 447,451 ---- static PyMethodDef sunaudiodev_methods[] = { ! { "open", sadopen, METH_VARARGS }, { 0, 0 }, }; Index: threadmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/threadmodule.c,v retrieving revision 2.47 retrieving revision 2.48 diff -C2 -d -r2.47 -r2.48 *** threadmodule.c 26 Mar 2002 14:52:00 -0000 2.47 --- threadmodule.c 31 Mar 2002 15:27:00 -0000 2.48 *************** *** 55,66 **** lock_PyThread_acquire_lock(lockobject *self, PyObject *args) { ! int i; ! if (args != NULL) { ! if (!PyArg_Parse(args, "i", &i)) ! return NULL; ! } ! else ! i = 1; Py_BEGIN_ALLOW_THREADS --- 55,62 ---- lock_PyThread_acquire_lock(lockobject *self, PyObject *args) { ! int i = 1; ! if (!PyArg_ParseTuple(args, "|i:acquire", &i)) ! return NULL; Py_BEGIN_ALLOW_THREADS *************** *** 128,134 **** static PyMethodDef lock_methods[] = { {"acquire_lock", (PyCFunction)lock_PyThread_acquire_lock, ! METH_OLDARGS, acquire_doc}, {"acquire", (PyCFunction)lock_PyThread_acquire_lock, ! METH_OLDARGS, acquire_doc}, {"release_lock", (PyCFunction)lock_PyThread_release_lock, METH_NOARGS, release_doc}, --- 124,130 ---- static PyMethodDef lock_methods[] = { {"acquire_lock", (PyCFunction)lock_PyThread_acquire_lock, ! METH_VARARGS, acquire_doc}, {"acquire", (PyCFunction)lock_PyThread_acquire_lock, ! METH_VARARGS, acquire_doc}, {"release_lock", (PyCFunction)lock_PyThread_release_lock, METH_NOARGS, release_doc}, *************** *** 280,284 **** { int sts; ! if (!PyArg_Parse(args, "i", &sts)) return NULL; Py_Exit(sts); /* Calls PyThread_exit_prog(sts) or _PyThread_exit_prog(sts) */ --- 276,280 ---- { int sts; ! if (!PyArg_ParseTuple(args, "i:exit_prog", &sts)) return NULL; Py_Exit(sts); /* Calls PyThread_exit_prog(sts) or _PyThread_exit_prog(sts) */ *************** *** 340,344 **** METH_NOARGS, get_ident_doc}, #ifndef NO_EXIT_PROG ! {"exit_prog", (PyCFunction)thread_PyThread_exit_prog}, #endif {NULL, NULL} /* sentinel */ --- 336,341 ---- METH_NOARGS, get_ident_doc}, #ifndef NO_EXIT_PROG ! {"exit_prog", (PyCFunction)thread_PyThread_exit_prog, ! METH_VARARGS}, #endif {NULL, NULL} /* sentinel */ From neal@metaslash.com Sun Mar 31 15:32:41 2002 From: neal@metaslash.com (Neal Norwitz) Date: Sun, 31 Mar 2002 10:32:41 -0500 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.77,2.78 _tkinter.c,1.123,1.124 cPickle.c,2.75,2.76 References: <200203311527.g2VFRRK23350@pcp742651pcs.reston01.va.comcast.net> Message-ID: <3CA72C19.CEA34B3F@metaslash.com> Guido van Rossum wrote: > > > Modified Files: > > _sre.c _tkinter.c cPickle.c > > Log Message: > > Use symbolic METH_VARARGS/METH_OLDARGS instead of 1/0 for ml_flags > > I hope for you that those symbols also exist in Python 1.5.2, > otherwise /F will revert your changes to _sre.c right away! :-) METH_VARARGS does exist in 1.5.2, but METH_OLDARGS doesn't seem to be. I'll revert the OLDARGS. Thanks for the heads up :-) Neal From nnorwitz@users.sourceforge.net Sun Mar 31 15:43:30 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 31 Mar 2002 07:43:30 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules imgfile.c,1.29,1.30 dlmodule.c,2.20,2.21 bsddbmodule.c,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv29694 Modified Files: imgfile.c dlmodule.c bsddbmodule.c Log Message: Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple Please review for correctness. Index: imgfile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/imgfile.c,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** imgfile.c 17 Jan 2002 23:15:58 -0000 1.29 --- imgfile.c 31 Mar 2002 15:43:28 -0000 1.30 *************** *** 76,80 **** PyObject *rv; ! if (!PyArg_Parse(args, "i", &newval)) return NULL; rv = PyInt_FromLong(top_to_bottom); --- 76,80 ---- PyObject *rv; ! if (!PyArg_ParseTuple(args, "i:ttob", &newval)) return NULL; rv = PyInt_FromLong(top_to_bottom); *************** *** 96,100 **** int yfirst, ylast, ystep; ! if ( !PyArg_Parse(args, "s", &fname) ) return NULL; --- 96,100 ---- int yfirst, ylast, ystep; ! if ( !PyArg_ParseTuple(args, "s:read", &fname) ) return NULL; *************** *** 251,258 **** int xwtd, ywtd, xorig, yorig; float xfac, yfac; - int cnt; IMAGE *image; char *filter; ! double blur; int extended; int fmode = 0; --- 251,257 ---- int xwtd, ywtd, xorig, yorig; float xfac, yfac; IMAGE *image; char *filter; ! double blur = 1.0; int extended; int fmode = 0; *************** *** 264,281 **** ** extended scale algorithm in stead of simple-minded pixel drop/dup. */ ! extended = 0; ! cnt = PyTuple_Size(args); ! if ( cnt == 5 ) { ! extended = 1; ! if ( !PyArg_Parse(args, "(siisd)", ! &fname, &xwtd, &ywtd, &filter, &blur) ) ! return NULL; ! } else if ( cnt == 4 ) { ! extended = 1; ! if ( !PyArg_Parse(args, "(siis)", ! &fname, &xwtd, &ywtd, &filter) ) ! return NULL; ! blur = 1.0; ! } else if ( !PyArg_Parse(args, "(sii)", &fname, &xwtd, &ywtd) ) return NULL; --- 263,269 ---- ** extended scale algorithm in stead of simple-minded pixel drop/dup. */ ! extended = PyTuple_Size(args) >= 4; ! if ( !PyArg_ParseTuple(args, "sii|sd", ! &fname, &xwtd, &ywtd, &filter, &blur) ) return NULL; *************** *** 392,396 **** IMAGE *image; ! if ( !PyArg_Parse(args, "s", &fname) ) return NULL; --- 380,384 ---- IMAGE *image; ! if ( !PyArg_ParseTuple(args, "s:getsizes", &fname) ) return NULL; *************** *** 417,421 **** ! if ( !PyArg_Parse(args, "(ss#iii)", &fname, &cdatap, &len, &xsize, &ysize, &zsize) ) return NULL; --- 405,409 ---- ! if ( !PyArg_ParseTuple(args, "ss#iii:write", &fname, &cdatap, &len, &xsize, &ysize, &zsize) ) return NULL; *************** *** 491,499 **** static PyMethodDef imgfile_methods[] = { ! { "getsizes", imgfile_getsizes, METH_OLDARGS }, ! { "read", imgfile_read, METH_OLDARGS }, { "readscaled", imgfile_readscaled, METH_VARARGS}, ! { "write", imgfile_write, METH_OLDARGS }, ! { "ttob", imgfile_ttob, METH_OLDARGS }, { NULL, NULL } /* Sentinel */ }; --- 479,487 ---- static PyMethodDef imgfile_methods[] = { ! { "getsizes", imgfile_getsizes, METH_VARARGS }, ! { "read", imgfile_read, METH_VARARGS }, { "readscaled", imgfile_readscaled, METH_VARARGS}, ! { "write", imgfile_write, METH_VARARGS }, ! { "ttob", imgfile_ttob, METH_VARARGS }, { NULL, NULL } /* Sentinel */ }; Index: dlmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/dlmodule.c,v retrieving revision 2.20 retrieving revision 2.21 diff -C2 -d -r2.20 -r2.21 *** dlmodule.c 17 Jan 2002 23:15:58 -0000 2.20 --- dlmodule.c 31 Mar 2002 15:43:28 -0000 2.21 *************** *** 40,47 **** static PyObject * ! dl_close(dlobject *xp, PyObject *args) { - if (!PyArg_Parse(args, "")) - return NULL; if (xp->dl_handle != NULL) { dlclose(xp->dl_handle); --- 40,45 ---- static PyObject * ! dl_close(dlobject *xp) { if (xp->dl_handle != NULL) { dlclose(xp->dl_handle); *************** *** 57,62 **** char *name; PyUnivPtr *func; ! if (!PyArg_Parse(args, "s", &name)) return NULL; func = dlsym(xp->dl_handle, name); if (func == NULL) { --- 55,65 ---- char *name; PyUnivPtr *func; ! if (PyString_Check(args)) { ! name = PyString_AS_STRING(args); ! } else { ! PyErr_Format(PyExc_TypeError, "expected string, found %.200s", ! args->ob_type->tp_name); return NULL; + } func = dlsym(xp->dl_handle, name); if (func == NULL) { *************** *** 122,127 **** static PyMethodDef dlobject_methods[] = { {"call", (PyCFunction)dl_call, METH_VARARGS}, ! {"sym", (PyCFunction)dl_sym, METH_OLDARGS}, ! {"close", (PyCFunction)dl_close, METH_OLDARGS}, {NULL, NULL} /* Sentinel */ }; --- 125,130 ---- static PyMethodDef dlobject_methods[] = { {"call", (PyCFunction)dl_call, METH_VARARGS}, ! {"sym", (PyCFunction)dl_sym, METH_O}, ! {"close", (PyCFunction)dl_close, METH_NOARGS}, {NULL, NULL} /* Sentinel */ }; *************** *** 166,174 **** } ! if (PyArg_Parse(args, "z", &name)) mode = RTLD_LAZY; else { PyErr_Clear(); ! if (!PyArg_Parse(args, "(zi)", &name, &mode)) return NULL; #ifndef RTLD_NOW --- 169,177 ---- } ! if (PyArg_ParseTuple(args, "z:open", &name)) mode = RTLD_LAZY; else { PyErr_Clear(); ! if (!PyArg_ParseTuple(args, "zi:open", &name, &mode)) return NULL; #ifndef RTLD_NOW *************** *** 188,192 **** static PyMethodDef dl_methods[] = { ! {"open", dl_open, METH_OLDARGS}, {NULL, NULL} /* sentinel */ }; --- 191,195 ---- static PyMethodDef dl_methods[] = { ! {"open", dl_open, METH_VARARGS}, {NULL, NULL} /* sentinel */ }; Index: bsddbmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/bsddbmodule.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** bsddbmodule.c 25 Mar 2002 20:46:45 -0000 1.33 --- bsddbmodule.c 31 Mar 2002 15:43:28 -0000 1.34 *************** *** 471,477 **** if (dp->di_type == DB_RECNO) { ! if (!PyArg_Parse(args, "i", &recno)) { ! PyErr_SetString(PyExc_TypeError, ! "key type must be integer"); return NULL; } --- 471,476 ---- if (dp->di_type == DB_RECNO) { ! if (!PyArg_ParseTuple(args, "i;key type must be integer", ! &recno)) { return NULL; } *************** *** 480,486 **** } else { ! if (!PyArg_Parse(args, "s#", &data, &size)) { ! PyErr_SetString(PyExc_TypeError, ! "key type must be string"); return NULL; } --- 479,484 ---- } else { ! if (!PyArg_ParseTuple(args, "s#;key type must be string", ! &data, &size)) { return NULL; } *************** *** 512,518 **** if (dp->di_type == DB_RECNO) { ! if (!PyArg_Parse(key, "i", &recno)) { ! PyErr_SetString(PyExc_TypeError, ! "key type must be integer"); return NULL; } --- 510,515 ---- if (dp->di_type == DB_RECNO) { ! if (!PyArg_ParseTuple(key, "i;key type must be integer", ! &recno)) { return NULL; } *************** *** 521,527 **** } else { ! if (!PyArg_Parse(key, "s#", &data, &size)) { ! PyErr_SetString(PyExc_TypeError, ! "key type must be string"); return NULL; } --- 518,523 ---- } else { ! if (!PyArg_ParseTuple(key, "s#;key type must be string", ! &data, &size)) { return NULL; } *************** *** 645,650 **** {"close", (PyCFunction)bsddb_close, METH_NOARGS}, {"keys", (PyCFunction)bsddb_keys, METH_NOARGS}, ! {"has_key", (PyCFunction)bsddb_has_key, METH_OLDARGS}, ! {"set_location", (PyCFunction)bsddb_set_location, METH_OLDARGS}, {"next", (PyCFunction)bsddb_next, METH_NOARGS}, {"previous", (PyCFunction)bsddb_previous, METH_NOARGS}, --- 641,646 ---- {"close", (PyCFunction)bsddb_close, METH_NOARGS}, {"keys", (PyCFunction)bsddb_keys, METH_NOARGS}, ! {"has_key", (PyCFunction)bsddb_has_key, METH_VARARGS}, ! {"set_location", (PyCFunction)bsddb_set_location, METH_VARARGS}, {"next", (PyCFunction)bsddb_next, METH_NOARGS}, {"previous", (PyCFunction)bsddb_previous, METH_NOARGS}, From nnorwitz@users.sourceforge.net Sun Mar 31 15:46:02 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 31 Mar 2002 07:46:02 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.78,2.79 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv30333 Modified Files: _sre.c Log Message: Revert use of METH_OLDARGS (use 0) to support 1.5.2 Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.78 retrieving revision 2.79 diff -C2 -d -r2.78 -r2.79 *** _sre.c 31 Mar 2002 14:44:22 -0000 2.78 --- _sre.c 31 Mar 2002 15:46:00 -0000 2.79 *************** *** 2939,2944 **** static PyMethodDef scanner_methods[] = { ! {"match", (PyCFunction) scanner_match, METH_OLDARGS}, ! {"search", (PyCFunction) scanner_search, METH_OLDARGS}, {NULL, NULL} }; --- 2939,2946 ---- static PyMethodDef scanner_methods[] = { ! /* FIXME: use METH_OLDARGS instead of 0 or fix to use METH_VARARGS */ ! /* METH_OLDARGS is not in Python 1.5.2 */ ! {"match", (PyCFunction) scanner_match, 0}, ! {"search", (PyCFunction) scanner_search, 0}, {NULL, NULL} }; From nnorwitz@users.sourceforge.net Sun Mar 31 15:56:59 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 31 Mar 2002 07:56:59 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules flmodule.c,1.48,1.49 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv32129 Modified Files: flmodule.c Log Message: Convert METH_OLDARGS -> METH_NOARGS: remove args parameter Use METH_OLDARGS explicitly rather than implicitly. Index: flmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/flmodule.c,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** flmodule.c 17 Jan 2002 23:15:58 -0000 1.48 --- flmodule.c 31 Mar 2002 15:56:56 -0000 1.49 *************** *** 172,179 **** static PyObject * ! generic_call(genericobject *g, PyObject *args, void (*func)(FL_OBJECT *)) { - if (!PyArg_NoArgs(args)) - return NULL; (*func)(g->ob_generic); Py_INCREF(Py_None); --- 172,177 ---- [...1257 lines suppressed...] /* {"new_events", forms_new_events, METH_OLDARGS}, */ *************** *** 2101,2108 **** {"getmcolor", forms_getmcolor, METH_OLDARGS}, /* interaction */ ! {"do_forms", forms_do_forms, METH_OLDARGS}, ! {"do_only_forms", forms_do_only_forms, METH_OLDARGS}, ! {"check_forms", forms_check_forms, METH_OLDARGS}, ! {"check_only_forms", forms_check_only_forms, METH_OLDARGS}, {"set_event_call_back", forms_set_event_call_back, METH_OLDARGS}, /* goodies */ --- 2105,2112 ---- {"getmcolor", forms_getmcolor, METH_OLDARGS}, /* interaction */ ! {"do_forms", forms_do_forms, METH_NOARGS}, ! {"do_only_forms", forms_do_only_forms, METH_NOARGS}, ! {"check_forms", forms_check_forms, METH_NOARGS}, ! {"check_only_forms", forms_check_only_forms, METH_NOARGS}, {"set_event_call_back", forms_set_event_call_back, METH_OLDARGS}, /* goodies */ From nnorwitz@users.sourceforge.net Sun Mar 31 16:06:14 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 31 Mar 2002 08:06:14 -0800 Subject: [Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.131,2.132 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv2043/Objects Modified Files: typeobject.c Log Message: Use METH_VARARGS rather than METH_OLDARGS implicitly (args are ignored) Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.131 retrieving revision 2.132 diff -C2 -d -r2.131 -r2.132 *** typeobject.c 28 Mar 2002 05:33:33 -0000 2.131 --- typeobject.c 31 Mar 2002 16:06:11 -0000 2.132 *************** *** 879,883 **** } ! static PyMethodDef bozo_ml = {"__getstate__", bozo_func}; static PyObject *bozo_obj = NULL; --- 879,883 ---- } ! static PyMethodDef bozo_ml = {"__getstate__", bozo_func, METH_VARARGS}; static PyObject *bozo_obj = NULL; From nnorwitz@users.sourceforge.net Sun Mar 31 16:13:41 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 31 Mar 2002 08:13:41 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules readline.c,2.46,2.47 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv3568/Modules Modified Files: readline.c Log Message: Get rid of warnings due to changing to METH_NOARGS Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.46 retrieving revision 2.47 diff -C2 -d -r2.46 -r2.47 *** readline.c 25 Mar 2002 20:46:46 -0000 2.46 --- readline.c 31 Mar 2002 16:13:39 -0000 2.47 *************** *** 414,418 **** { {"parse_and_bind", parse_and_bind, METH_VARARGS, doc_parse_and_bind}, ! {"get_line_buffer", get_line_buffer, METH_NOARGS, doc_get_line_buffer}, {"insert_text", insert_text, METH_VARARGS, doc_insert_text}, --- 414,418 ---- { {"parse_and_bind", parse_and_bind, METH_VARARGS, doc_parse_and_bind}, ! {"get_line_buffer", (PyCFunction)get_line_buffer, METH_NOARGS, doc_get_line_buffer}, {"insert_text", insert_text, METH_VARARGS, doc_insert_text}, *************** *** 425,429 **** {"get_history_item", get_history_item, METH_VARARGS, doc_get_history_item}, ! {"get_current_history_length", get_current_history_length, METH_NOARGS, doc_get_current_history_length}, {"set_history_length", set_history_length, --- 425,429 ---- {"get_history_item", get_history_item, METH_VARARGS, doc_get_history_item}, ! {"get_current_history_length", (PyCFunction)get_current_history_length, METH_NOARGS, doc_get_current_history_length}, {"set_history_length", set_history_length, *************** *** 432,442 **** METH_VARARGS, get_history_length_doc}, {"set_completer", set_completer, METH_VARARGS, doc_set_completer}, ! {"get_begidx", get_begidx, METH_NOARGS, doc_get_begidx}, ! {"get_endidx", get_endidx, METH_NOARGS, doc_get_endidx}, {"set_completer_delims", set_completer_delims, METH_VARARGS, doc_set_completer_delims}, {"add_history", py_add_history, METH_VARARGS, doc_add_history}, ! {"get_completer_delims", get_completer_delims, METH_NOARGS, doc_get_completer_delims}, --- 432,442 ---- METH_VARARGS, get_history_length_doc}, {"set_completer", set_completer, METH_VARARGS, doc_set_completer}, ! {"get_begidx", (PyCFunction)get_begidx, METH_NOARGS, doc_get_begidx}, ! {"get_endidx", (PyCFunction)get_endidx, METH_NOARGS, doc_get_endidx}, {"set_completer_delims", set_completer_delims, METH_VARARGS, doc_set_completer_delims}, {"add_history", py_add_history, METH_VARARGS, doc_add_history}, ! {"get_completer_delims", (PyCFunction)get_completer_delims, METH_NOARGS, doc_get_completer_delims}, From jackjansen@users.sourceforge.net Sun Mar 31 22:01:36 2002 From: jackjansen@users.sourceforge.net (Jack Jansen) Date: Sun, 31 Mar 2002 14:01:36 -0800 Subject: [Python-checkins] CVS: python/dist/src/Mac/Tools/IDE PyEdit.py,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory usw-pr-cvs1:/tmp/cvs-serv12224 Modified Files: PyEdit.py Log Message: Added a "run with commandline Python" flag. Works in MachoPython, should work in OSX MacPython (untested), and should be disabled/removed in OS9 (but that doesn't happen yet). Index: PyEdit.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PyEdit.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** PyEdit.py 29 Mar 2002 21:48:42 -0000 1.30 --- PyEdit.py 31 Mar 2002 22:01:33 -0000 1.31 *************** *** 111,122 **** self.debugging = 0 self.profiling = 0 ! if self.settings.has_key("run_as_main"): ! self.run_as_main = self.settings["run_as_main"] ! else: ! self.run_as_main = 0 ! if self.settings.has_key("run_with_interpreter"): ! self.run_with_interpreter = self.settings["run_with_interpreter"] ! else: ! self.run_with_interpreter = 0 self._threadstate = (0, 0) self._thread = None --- 111,117 ---- self.debugging = 0 self.profiling = 0 ! self.run_as_main = self.settings.get("run_as_main", 0) ! self.run_with_interpreter = self.settings.get("run_with_interpreter", 0) ! self.run_with_cl_interpreter = self.settings.get("run_with_cl_interpreter", 0) self._threadstate = (0, 0) self._thread = None *************** *** 162,165 **** --- 157,161 ---- self.settings["run_as_main"] = self.run_as_main self.settings["run_with_interpreter"] = self.run_with_interpreter + self.settings["run_with_cl_interpreter"] = self.run_with_cl_interpreter def get(self): *************** *** 231,236 **** '-', ('\0' + chr(self.run_as_main) + 'Run as __main__', self.domenu_toggle_run_as_main), ! #('\0' + chr(self.run_with_interpreter) + 'Run with Interpreter', self.domenu_toggle_run_with_interpreter), ! #'-', ('Modularize', self.domenu_modularize), ('Browse namespace\xc9', self.domenu_browsenamespace), --- 227,233 ---- '-', ('\0' + chr(self.run_as_main) + 'Run as __main__', self.domenu_toggle_run_as_main), ! #('\0' + chr(self.run_with_interpreter) + 'Run with Interpreter', self.domenu_dtoggle_run_with_interpreter), ! ('\0' + chr(self.run_with_cl_interpreter) + 'Run with commandline Python', self.domenu_toggle_run_with_cl_interpreter), ! '-', ('Modularize', self.domenu_modularize), ('Browse namespace\xc9', self.domenu_browsenamespace), *************** *** 251,259 **** self.run_as_main = not self.run_as_main self.run_with_interpreter = 0 self.editgroup.editor.selectionchanged() ! def domenu_toggle_run_with_interpreter(self): self.run_with_interpreter = not self.run_with_interpreter self.run_as_main = 0 self.editgroup.editor.selectionchanged() --- 248,264 ---- self.run_as_main = not self.run_as_main self.run_with_interpreter = 0 + self.run_with_cl_interpreter = 0 self.editgroup.editor.selectionchanged() ! def XXdomenu_toggle_run_with_interpreter(self): self.run_with_interpreter = not self.run_with_interpreter self.run_as_main = 0 + self.run_with_cl_interpreter = 0 + self.editgroup.editor.selectionchanged() + + def domenu_toggle_run_with_cl_interpreter(self): + self.run_with_cl_interpreter = not self.run_with_cl_interpreter + self.run_as_main = 0 + self.run_with_interpreter = 0 self.editgroup.editor.selectionchanged() *************** *** 515,518 **** --- 520,543 ---- raise W.AlertError, "Can't run unsaved file" self._run_with_interpreter() + elif self.run_with_cl_interpreter: + # Until universal newline support + if self._eoln != '\n': + import EasyDialogs + ok = EasyDialogs.AskYesNoCancel('Warning: "%s" does not have Unix line-endings' + % self.title, 1, yes='OK', no='') + if not ok: + return + if self.editgroup.editor.changed: + import EasyDialogs + import Qd; Qd.InitCursor() + save = EasyDialogs.AskYesNoCancel('Save "%s" before running?' % self.title, 1) + if save > 0: + if self.domenu_save(): + return + elif save < 0: + return + if not self.path: + raise W.AlertError, "Can't run unsaved file" + self._run_with_cl_interpreter() else: pytext = self.editgroup.editor.get() *************** *** 526,529 **** --- 551,571 ---- import findertools XXX + + def _run_with_cl_interpreter(self): + import Terminal + interp_path = os.path.join(sys.exec_prefix, "bin", "python") + file_path = self.path + if not os.path.exists(interp_path): + # This "can happen" if we are running IDE under MacPython. Try + # the standard location. + interp_path = "/Library/Frameworks/Python.framework/Versions/2.3/bin/python" + try: + fsr = macfs.FSRef(interp_path) + except macfs.Error: + raise W.AlertError, "Can't find command-line Python" + file_path = macfs.FSRef(macfs.FSSpec(self.path)).as_pathname() + cmd = '"%s" "%s" ; exit' % (interp_path, file_path) + t = Terminal.Terminal() + t.do_script(with_command=cmd) def runselection(self): *************** *** 538,542 **** def _runselection(self): ! if self.run_with_interpreter: raise W.AlertError, "Can't run selection with Interpreter" globals, file, modname = self.getenvironment() --- 580,584 ---- def _runselection(self): ! if self.run_with_interpreter or self.run_with_cl_interpreter: raise W.AlertError, "Can't run selection with Interpreter" globals, file, modname = self.getenvironment() From nnorwitz@users.sourceforge.net Sun Mar 31 22:02:41 2002 From: nnorwitz@users.sourceforge.net (Neal Norwitz) Date: Sun, 31 Mar 2002 14:02:41 -0800 Subject: [Python-checkins] CVS: python/dist/src/Modules mpzmodule.c,2.41,2.42 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv13107/Modules Modified Files: mpzmodule.c Log Message: mpz_float() only takes one parameter now Index: mpzmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mpzmodule.c,v retrieving revision 2.41 retrieving revision 2.42 diff -C2 -d -r2.41 -r2.42 *** mpzmodule.c 31 Mar 2002 15:27:00 -0000 2.41 --- mpzmodule.c 31 Mar 2002 22:02:37 -0000 2.42 *************** *** 1478,1488 **** } else { - #ifdef MPZ_CONVERSIONS_AS_METHODS - if ((z = mpz_float((mpzobject *)(*pv), NULL)) == NULL) - return -1; - #else /* def MPZ_CONVERSIONS_AS_METHODS */ if ((z = mpz_float((mpzobject *)(*pv))) == NULL) return -1; - #endif /* def MPZ_CONVERSIONS_AS_METHODS else */ Py_INCREF(*pw); --- 1478,1483 ---- From gvanrossum@users.sourceforge.net Sun Mar 31 23:02:30 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sun, 31 Mar 2002 15:02:30 -0800 Subject: [Python-checkins] CVS: python/nondist/peps pep-0285.txt,1.14,1.15 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv31266 Modified Files: pep-0285.txt Log Message: Add reference to COM. Index: pep-0285.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0285.txt,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** pep-0285.txt 31 Mar 2002 11:26:16 -0000 1.14 --- pep-0285.txt 31 Mar 2002 23:02:27 -0000 1.15 *************** *** 138,142 **** applies to Jython: some Java classes have separately overloaded methods or constructors for int and boolean arguments. The bool ! type can be used to select the boolean variant. The standard bool type can also serve as a way to force a value to --- 138,143 ---- applies to Jython: some Java classes have separately overloaded methods or constructors for int and boolean arguments. The bool ! type can be used to select the boolean variant. (The same is ! apparently the case for some COM interfaces.) The standard bool type can also serve as a way to force a value to From gvanrossum@users.sourceforge.net Sun Mar 31 23:38:50 2002 From: gvanrossum@users.sourceforge.net (Guido van Rossum) Date: Sun, 31 Mar 2002 15:38:50 -0800 Subject: [Python-checkins] CVS: python/dist/src/Lib urllib.py,1.139,1.140 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv10390 Modified Files: urllib.py Log Message: Hopeful fix for SF bug 503031: urllib.py: open_http() host problem. I really can't test this, but from reading the discussion in that bug report, it's likely that this works. It may also close a whole bunch of other bug reports related to urllib and proxies on Windows, but who knows. Index: urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.139 retrieving revision 1.140 diff -C2 -d -r1.139 -r1.140 *** urllib.py 26 Mar 2002 16:25:01 -0000 1.139 --- urllib.py 31 Mar 2002 23:38:48 -0000 1.140 *************** *** 1279,1283 **** for p in proxyServer.split(';'): protocol, address = p.split('=', 1) ! proxies[protocol] = '%s://%s' % (protocol, address) else: # Use one setting for all protocols --- 1279,1287 ---- for p in proxyServer.split(';'): protocol, address = p.split('=', 1) ! # See if address has a type:// prefix ! type, address = splittype(address) ! if not type: ! address = '%s://%s' % (protocol, address) ! proxies[protocol] = address else: # Use one setting for all protocols